module timelinelib.canvas.drawing.interface

Defines the interface that drawers should adhere to.

class timelinelib.canvas.drawing.interface.Drawer[source]

Bases: object

Draw timeline onto a device context and provide information about drawing.

draw(dc, timeline, view_properties, config, fast_draw=False)[source]

Draw a representation of a timeline.

The dc is used to do the actual drawing. The timeline is used to get the events to visualize. The view properties contains information like which events are selected in the view we are drawing for and what period is currently displayed.

When the dc is temporarily stored in a class variable such as self.dc, this class variable must be deleted before the draw method ends.

event_is_period(time_period)[source]

Return True if the event time_period will make the event appear below the center line, as a period event.

snap(time, snap_region=10)[source]

Snap time to minor strip if within snap_region pixels.

snap_selection(period_selection)[source]

Return a tuple where the selection has been stretched to fit to minor strip.

period_selection: (start, end) Return: (new_start, new_end)

event_at(x, y)[source]

Return the event at pixel coordinate (x, y) or None if no event there.

event_with_rect_at(x, y)[source]

Return the event at pixel coordinate (x, y) and its rect in a tuple (event, rect) or None if no event there.

event_rect_at(event)[source]

Return the rect for the given event or None if no event isn’t found.

is_balloon_at(event, x, y)[source]

Return True if a balloon for event is drawn at (x, y), otherwise False.

get_closest_overlapping_event(event_to_move, up=True)[source]
class timelinelib.canvas.drawing.interface.Strip[source]

Bases: object

An interface for strips.

The different strips are implemented in subclasses below.

The timeline is divided in major and minor strips. The minor strip might for example be days, and the major strip months. Major strips are divided with a solid line and minor strips with dotted lines. Typically maximum three major strips should be shown and the rest will be minor strips.

label(time, major=False)[source]

Return the label for this strip at the given time when used as major or minor strip.

start(time)[source]

Return the start time for this strip and the given time.

For example, if the time is 2008-08-31 and the strip is month, the start would be 2008-08-01.

increment(time)[source]

Increment the given time so that it points to the start of the next strip.

is_day()[source]