Skip to content

Calendar DayView CollisionAlgorithms

Zdmason edited this page Dec 19, 2013 · 2 revisions

CollisionAlgorithms is where event / commitment overlapping is handled in the day/weekCalendar. A list of events taken from the server and the displayed day are input into createEventsReallyNicely(List events, DateTime displayedDay) and returned in sorted dayItem form.

Events and commitments are first split into 2 EventEndpoints based on start / end time using splitEvents (commitments only have due date, so their "end time" is set to be 45 minutes after start time) and sorted from earliest to latest. A new list of OverlappedDisplayables is created, with each OverlappedDisplayable representing one event or commitment and recording the number of collisions that displayable has with other displayables in the same interval. xSort then assigns each OverlappedDisplayable a rational number based on the number of collisions detected in the previous step; a rational of 1/1 means the event has no collisions and can take up the width of the dayView panel, a rational of 1/4 means the event has 3 other events colliding with it and will take up the first 1/4 of the panel, a rational of 2/4 means the event has 3 other collisions and will take up the second 1/4 of the panel after the first collision, ect. The updated list of OverlappedDisplayables is converted into a list dayItems holding the collision information, and are returned by createEventsReallyNicely to the day/weekview class.