Class TimelineModel<E,​G>

    • Method Detail

      • add

        public void add​(TimelineEvent<E> event)
        Adds a given event to the model without UI update.
        Parameters:
        event - event to be added
      • addGroup

        public void addGroup​(TimelineGroup<G> group)
        Adds a given group to the model.
        Parameters:
        group - group to be added
      • add

        public void add​(TimelineEvent<E> event,
                        TimelineUpdater timelineUpdater)
        Adds a given event to the model with UI update.
        Parameters:
        event - event to be added
        timelineUpdater - TimelineUpdater instance to add the event in UI
      • addAll

        public void addAll​(Collection<TimelineEvent<E>> events)
        Adds all given event to the model without UI update.
        Parameters:
        events - collection of events to be added
      • addAllGroups

        public void addAllGroups​(Collection<TimelineGroup<G>> groups)
        Adds all given groups to the model.
        Parameters:
        groups - collection of groups to be added
      • addAll

        public void addAll​(Collection<TimelineEvent<E>> events,
                           TimelineUpdater timelineUpdater)
        Adds all given events to the model with UI update.
        Parameters:
        events - collection of events to be added
        timelineUpdater - TimelineUpdater instance to add the events in UI
      • update

        public void update​(TimelineEvent<E> event)
        Updates a given event in the model without UI update.
        Parameters:
        event - event to be updated
      • update

        public void update​(TimelineEvent<E> event,
                           TimelineUpdater timelineUpdater)
        Updates a given event in the model with UI update.
        Parameters:
        event - event to be added
        timelineUpdater - TimelineUpdater instance to update the event in UI
      • updateAll

        public void updateAll​(Collection<TimelineEvent<E>> events)
        Updates all given events in the model without UI update.
        Parameters:
        events - collection of events to be updated
      • updateAll

        public void updateAll​(Collection<TimelineEvent<E>> events,
                              TimelineUpdater timelineUpdater)
        Updates all given events in the model with UI update.
        Parameters:
        events - collection of events to be updated
        timelineUpdater - TimelineUpdater instance to update the events in UI
      • delete

        public void delete​(TimelineEvent<E> event)
        Deletes a given event in the model without UI update.
        Parameters:
        event - event to be deleted
      • delete

        public void delete​(TimelineEvent<E> event,
                           TimelineUpdater timelineUpdater)
        Deletes a given event in the model with UI update.
        Parameters:
        event - event to be deleted
        timelineUpdater - TimelineUpdater instance to delete the event in UI
      • deleteAll

        public void deleteAll​(Collection<TimelineEvent<E>> events)
        Deletes all given events in the model without UI update.
        Parameters:
        events - collection of events to be deleted
      • deleteAll

        public void deleteAll​(Collection<TimelineEvent<E>> events,
                              TimelineUpdater timelineUpdater)
        Deletes all given events in the model with UI update.
        Parameters:
        events - collection of events to be deleted
        timelineUpdater - TimelineUpdater instance to delete the events in UI
      • select

        public void select​(TimelineEvent<E> event,
                           TimelineUpdater timelineUpdater)
        Selects a given event in UI visually. To unselect all events, pass a null as event.
        Parameters:
        event - event to be selected
        timelineUpdater - TimelineUpdater instance to select the event in UI
      • clear

        public void clear()
        Clears the timeline model without UI update (no events are available after that)
      • clear

        public void clear​(TimelineUpdater timelineUpdater)
        Clears the timeline model with UI update (no events are available after that)
        Parameters:
        timelineUpdater - TimelineUpdater instance to clear the timeline in UI
      • getOverlappedEvents

        public Set<TimelineEvent<E>> getOverlappedEvents​(TimelineEvent<E> event)
        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.
        Parameters:
        event - given event
        Returns:
        TreeSet<TimelineEvent<E>> ordered overlapped events or null if no overlapping exist
      • merge

        public TimelineEvent<E> merge​(TimelineEvent<E> event,
                                      Collection<TimelineEvent<E>> events)
        Merge the given one event with the given collection of events without UI update. Only events within one group can be merged. Note: after merging, the merged event will get the same properties as the given one event except start and end dates.
        Parameters:
        event - given event to be merged with collection of events
        events - collection of events
        Returns:
        TimelineEvent result event after merging
        Throws:
        IllegalStateException - thrown if not all events are within the same group
      • merge

        public TimelineEvent<E> merge​(TimelineEvent<E> event,
                                      Collection<TimelineEvent<E>> events,
                                      TimelineUpdater timelineUpdater)
        Merge the given one event with the given collection of events with UI update. Only events within one group can be merged. Note: after merging, the merged event will get the same properties as the given one event except start and end dates.
        Parameters:
        event - given event to be merged with collection of events
        events - collection of events
        timelineUpdater - TimelineUpdater instance to update the merged events in UI
        Returns:
        TimelineEvent result event after merging
        Throws:
        IllegalStateException - thrown if not all events are within the same group
      • getEvents

        public List<TimelineEvent<E>> getEvents()
        Gets all events in this model
        Returns:
        List<TimelineEvent<E>> list of events
      • setEvents

        public void setEvents​(List<TimelineEvent<E>> events)
        Sets events into this model
        Parameters:
        events - List<TimelineEvent<E>> list of events
      • getGroups

        public List<TimelineGroup<G>> getGroups()
        Gets all groups in this model
        Returns:
        List<TimelineGroup<G>> list of groups
      • setGroups

        public void setGroups​(List<TimelineGroup<G>> groups)
        Sets groups into this model
        Parameters:
        groups - List<TimelineGroup<G>> list of groups
      • getEvent

        public TimelineEvent<E> getEvent​(String id)
        Gets event by its id property.
        Parameters:
        id - id property of the event
        Returns:
        TimelineEvent found event or null
      • hasEvent

        public boolean hasEvent​(TimelineEvent<E> event)
        Check if current model has the event passed as parameter.
        Parameters:
        event -
        Returns: