1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 """
20 Defines the interface that drawers should adhere to.
21 """
22
23
25 """
26 Draw timeline onto a device context and provide information about drawing.
27 """
28
29 - def draw(self, dc, timeline, view_properties, config, fast_draw=False):
30 """
31 Draw a representation of a timeline.
32
33 The dc is used to do the actual drawing. The timeline is used to get
34 the events to visualize. The view properties contains information like
35 which events are selected in the view we are drawing for and what
36 period is currently displayed.
37
38 When the dc is temporarily stored in a class variable such as self.dc,
39 this class variable must be deleted before the draw method ends.
40 """
41
43 """
44 Return True if the event time_period will make the event appear
45 below the center line, as a period event.
46 """
47 return None
48
49 - def snap(self, time, snap_region=10):
50 """Snap time to minor strip if within snap_region pixels."""
51 return time
52
54 """
55 Return a tuple where the selection has been stretched to fit to minor
56 strip.
57
58 period_selection: (start, end)
59 Return: (new_start, new_end)
60 """
61 return period_selection
62
64 """
65 Return the event at pixel coordinate (x, y) or None if no event there.
66 """
67 return None
68
70 """
71 Return the event at pixel coordinate (x, y) and its rect in a tuple
72 (event, rect) or None if no event there.
73 """
74 return None
75
77 """
78 Return the rect for the given event or None if no event isn't found.
79 """
80 return None
81
83 """
84 Return True if a balloon for event is drawn at (x, y), otherwise False.
85 """
86
88 raise NotImplementedError()
89
90
92 """
93 An interface for strips.
94
95 The different strips are implemented in subclasses below.
96
97 The timeline is divided in major and minor strips. The minor strip might
98 for example be days, and the major strip months. Major strips are divided
99 with a solid line and minor strips with dotted lines. Typically maximum
100 three major strips should be shown and the rest will be minor strips.
101 """
102
103 - def label(self, time, major=False):
104 """
105 Return the label for this strip at the given time when used as major or
106 minor strip.
107 """
108
110 """
111 Return the start time for this strip and the given time.
112
113 For example, if the time is 2008-08-31 and the strip is month, the
114 start would be 2008-08-01.
115 """
116
118 """
119 Increment the given time so that it points to the start of the next
120 strip.
121 """
122
125