Package Gnumed :: Package timelinelib :: Package canvas :: Package data :: Module item |
[frames] | no frames]

# Source Code for Module Gnumed.timelinelib.canvas.data.item

     1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg
     2  #
     3  # This file is part of Timeline.
     4  #
     5  # Timeline is free software: you can redistribute it and/or modify
     6  # it under the terms of the GNU General Public License as published by
     7  # the Free Software Foundation, either version 3 of the License, or
     8  # (at your option) any later version.
     9  #
    10  # Timeline is distributed in the hope that it will be useful,
    11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  # GNU General Public License for more details.
    14  #
    15  # You should have received a copy of the GNU General Public License
    16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>.
    17
    18
    19  from timelinelib.canvas.data.timeperiod import TimePeriod
    20
    21
    22 -class TimelineItem(object):
    23      """
    24      I represent any item that should be displayed on a timeline.
    25
    26      I have a time period and methods to manipulate it.
    27
    28      Specific items inherit from me.
    29      """
    30
    31 -    def get_time_period(self):
    32          return self._immutable_value.time_period
    33
    34 -    def get_start_time(self):
    35          return self.time_period.get_start_time()
    36
    37 -    def get_end_time(self):
    38          return self.time_period.get_end_time()
    39
    40 -    def set_time_period(self, time_period):
    41          self._immutable_value = self._immutable_value.update(time_period=time_period)
    42          return self
    43
    44      time_period = property(get_time_period, set_time_period)
    45
    46 -    def update_period(self, start_time, end_time):
    47          self.set_time_period(TimePeriod(start_time, end_time))
    48
    49 -    def update_period_o(self, new_period):
    50          self.update_period(new_period.start_time, new_period.end_time)
    51
    52 -    def start_to_start(self, event):
    53          return self.time_period.start_to_start(event.get_time_period())
    54
    55 -    def start_to_end(self, event):
    56          return self.time_period.start_to_end(event.get_time_period())
    57
    58 -    def end_to_end(self, event):
    59          return self.time_period.end_to_end(event.get_time_period())
    60
    61 -    def move_delta(self, delta):
    62          self.set_time_period(self.time_period.move_delta(delta))
    63
    64 -    def inside_period(self, time_period):
    65          return self.time_period.inside_period(time_period)
    66
    67 -    def is_period(self):
    68          return self.time_period.is_period()
    69
    70 -    def mean_time(self):
    71          return self.time_period.mean_time()
    72
    73 -    def time_span(self):
    74          return self.time_period.end_time - self.time_period.start_time
    75
    76 -    def overlaps(self, event):
    77          return self.time_period.overlaps(event.get_time_period())
    78
    79 -    def distance_to(self, event):
    80          return self.time_period.distance_to(event.get_time_period())
    81