Module com.flexganttfx.model
Package com.flexganttfx.model.repository
Class ListActivityRepository<A extends Activity>
java.lang.Object
com.flexganttfx.model.repository.ActivityRepositoryBase<A>
com.flexganttfx.model.repository.MutableActivityRepositoryBase<A>
com.flexganttfx.model.repository.ListActivityRepository<A>
- Type Parameters:
A
- the type of the activities
- All Implemented Interfaces:
ActivityRepository<A>
,MutableActivityRepository<A>
,EventTarget
public class ListActivityRepository<A extends Activity> extends MutableActivityRepositoryBase<A>
A repository implementation that utilizes several lists for storing activities.
The repository can return three different iterator types when the application is
asking for the activities within a given time interval.
- Since:
- 1.0
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ListActivityRepository.IteratorType
A list of possible iterators that the repository can return when the application queries the repository for the activities within a given time interval. -
Constructor Summary
Constructors Constructor Description ListActivityRepository()
Constructs a new repository that returns a binary iterator when the application queries the repository for the activities within a specific time interval.ListActivityRepository(ListActivityRepository.IteratorType iteratorType)
Constructs a new repository that returns an iterator of the specified type when the application queries the repository for the activities within a specific time interval. -
Method Summary
Modifier and Type Method Description void
addActivity(ActivityRef<A> activityRef)
Adds the given activity to the repository.void
clearActivities()
Removes all activities from all layers from the repository.void
clearActivities(Layer layer)
Removes the activities on the given layer from the repository.Iterator<A>
getActivities(Layer layer, Instant startTime, Instant endTime, TemporalUnit temporalUnit, ZoneId zoneId)
Returns an iterator for iterating over all activities found for the given layer and time interval.List<A>
getAllActivities()
Returns all activities on all layers.Instant
getEarliestTimeUsed()
Returns the earliest time used by the activities stored in this repository / on this row.ListActivityRepository.IteratorType
getIteratorType()
Returns the iterator type that is being returned by the repository.Instant
getLatestTimeUsed()
Returns the latest time used by the activities stored in this repository / on this row.void
removeActivity(ActivityRef<A> activityRef)
Removes the given activity from the repository.void
setIteratorType(ListActivityRepository.IteratorType iteratorType)
Sets a different iterator type on this repository.Methods inherited from class com.flexganttfx.model.repository.ActivityRepositoryBase
addEventHandler, buildEventDispatchChain, fireEvent, removeEventHandler
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.flexganttfx.model.ActivityRepository
addEventHandler, removeEventHandler
Methods inherited from interface javafx.event.EventTarget
buildEventDispatchChain
-
Constructor Details
-
ListActivityRepository
public ListActivityRepository()Constructs a new repository that returns a binary iterator when the application queries the repository for the activities within a specific time interval.- Since:
- 1.0
- See Also:
ListActivityRepository.IteratorType.BINARY_ITERATOR
-
ListActivityRepository
Constructs a new repository that returns an iterator of the specified type when the application queries the repository for the activities within a specific time interval.- Since:
- 1.0
-
-
Method Details
-
getIteratorType
Returns the iterator type that is being returned by the repository.- Returns:
- the iterator type
- Since:
- 1.0
-
setIteratorType
Sets a different iterator type on this repository.- Parameters:
iteratorType
- the new iterator type- Since:
- 1.0
-
getActivities
public final Iterator<A> getActivities(Layer layer, Instant startTime, Instant endTime, TemporalUnit temporalUnit, ZoneId zoneId)Description copied from interface:ActivityRepository
Returns an iterator for iterating over all activities found for the given layer and time interval. This method has to return very fast as it gets called many times during rendering of the chart. A slow implementation will have a direct impact on scrolling / rendering performance.- Parameters:
layer
- the layer for which to return the activitiesstartTime
- the start time of the time interval for which to return the activitiesendTime
- the end time of the time interval for which to return the activitiestemporalUnit
- the temporal unit currently displayed in the datelinezoneId
- the timezone currently displayed in the dateline- Returns:
- the activities on the given layer and in the given time interval
-
addActivity
Description copied from interface:MutableActivityRepository
Adds the given activity to the repository.- Parameters:
activityRef
- the activity
-
removeActivity
Description copied from interface:MutableActivityRepository
Removes the given activity from the repository.- Parameters:
activityRef
- the activity
-
clearActivities
public final void clearActivities()Description copied from interface:MutableActivityRepository
Removes all activities from all layers from the repository. -
clearActivities
Description copied from interface:MutableActivityRepository
Removes the activities on the given layer from the repository.- Parameters:
layer
- the layer to clear
-
getEarliestTimeUsed
Description copied from interface:ActivityRepository
Returns the earliest time used by the activities stored in this repository / on this row. This method gets used for navigation (e.g. "scroll to earliest time used in the Gantt chart", "zoom out to show all activities").- Specified by:
getEarliestTimeUsed
in interfaceActivityRepository<A extends Activity>
- Overrides:
getEarliestTimeUsed
in classActivityRepositoryBase<A extends Activity>
- Returns:
- the earliest time used by the activities in this repository / row (null if no activities found)
-
getLatestTimeUsed
Description copied from interface:ActivityRepository
Returns the latest time used by the activities stored in this repository / on this row. This method gets used for navigation (e.g. "scroll to latest time used in the Gantt chart", "zoom out to show all activities").- Specified by:
getLatestTimeUsed
in interfaceActivityRepository<A extends Activity>
- Overrides:
getLatestTimeUsed
in classActivityRepositoryBase<A extends Activity>
- Returns:
- the latest time used by the activities in this repository / row (null if no activities found)
-
getAllActivities
Returns all activities on all layers.- Returns:
- all activities
- Since:
- 1.0
-