public TreeSet < TimelineEvent > getOverlappedEvents ( TimelineEvent event ) { if ( event == null ) { return null ; } List < TimelineEvent > overlappedEvents = null ; for ( TimelineEvent e : events ) { if ( e . equals ( event ) ) { // given event should not be included continue ; } if ( event . getGroup ( ) == null && e . getGroup ( ) != null || ( event . getGroup ( ) != null && ! event . getGroup ( ) . equals ( e . getGroup ( ) ) ) ) { // ignore different groups continue ; } if ( isOverlapping ( event , e ) ) { if ( overlappedEvents == null ) { overlappedEvents = new ArrayList <> ( ) ; } overlappedEvents . add ( e ) ; } } if ( overlappedEvents == null ) { return null ; } // order overlapped events according to their start / end dates TreeSet < TimelineEvent > orderedOverlappedEvents = new TreeSet <> ( new TimelineEventComparator ( ) ) ; orderedOverlappedEvents . addAll ( overlappedEvents ) ; return orderedOverlappedEvents ; }
Gets all overlapped events to the given one . The given and overlapped events belong to the same group . Events are ordered by their start dates - first events with more recent start dates and then events with older start dates . If start dates are equal events will be ordered by their end dates . In this case if an event has a null end date it is ordered before the event with a not null end date .