Module com.flexganttfx.model
Package com.flexganttfx.model.timeline
Class TimelineModel<T extends TemporalUnit>
- java.lang.Object
-
- com.flexganttfx.model.timeline.TimelineModel<T>
-
- Type Parameters:
T
- the temporal unit supported by the model (e.g. ChronoUnit).
- Direct Known Subclasses:
ChronoUnitTimelineModel
,SimpleUnitTimelineModel
public abstract class TimelineModel<T extends TemporalUnit> extends Object
The timeline model stores the most important properties related to navigating within time (move forward and backward in time, zoom in and out).- Now - the "current" time (e.g. system time).
- Start time - the first time point that will be visible to the user.
- Millis per pixel - how much time is represented by a single pixel (important for zooming).
- Horizon - the earliest and latest point in time to which the user can scroll.
- Lowest temporal unit - the lowest unit that the user will be able to see (e.g. MINUTES).
- Highest temporal unit - the highest unit that the user will be able to see (e.g. MONTHS).
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TimelineModel()
Constructs a new timeline model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
calculateLocationForTime(Instant time)
Returns the pixel location of the given time.Instant
calculateTimeForLocation(double location)
Returns the time for the given location.Instant
getHorizonEndTime()
Returns the value ofhorizonEndTimeProperty()
.Instant
getHorizonStartTime()
Returns the value ofhorizonStartTimeProperty()
.double
getMaximumMillisPerPixel()
Returns the value ofmaximumMillisPerPixelProperty()
.double
getMillisPerPixel()
Returns the value ofmillisPerPixelProperty()
.double
getMinimumMillisPerPixel()
Returns the value ofminimumMillisPerPixelProperty()
.Instant
getNow()
Returns the value ofnowProperty()
.double
getNowLocation()
Returns the value ofnowLocationProperty()
.T
getSmallestTemporalUnit()
Returns the value ofsmallestTemporalUnitProperty()
.Instant
getStartTime()
Returns the value ofstartTimeProperty()
.ObjectProperty<Instant>
horizonEndTimeProperty()
Returns the object property used for storing the end time of the horizon.ObjectProperty<Instant>
horizonStartTimeProperty()
Returns the object property used for storing the start time of the horizon.DoubleProperty
maximumMillisPerPixelProperty()
A property used to store the maximum number of milliseconds that will be represented by a single pixel on the screen.DoubleProperty
millisPerPixelProperty()
Returns the property used to store the millis per pixel value.DoubleProperty
minimumMillisPerPixelProperty()
A property used to store the minimum number of milliseconds that will be represented by a single pixel on the screen.ReadOnlyDoubleProperty
nowLocationProperty()
Stores the location of the "now" time.ObjectProperty<Instant>
nowProperty()
Returns the property used to store "now", the current time, e.g.void
setHorizonEndTime(Instant time)
Sets the value ofhorizonEndTimeProperty()
.void
setHorizonStartTime(Instant time)
Sets the value ofhorizonStartTimeProperty()
.void
setMaximumMillisPerPixel(double max)
Sets the value ofmaximumMillisPerPixelProperty()
.void
setMillisPerPixel(double millis)
Sets the value of themillisPerPixelProperty()
.void
setMinimumMillisPerPixel(double min)
Sets the value ofminimumMillisPerPixelProperty()
.void
setNow(Instant now)
Sets the value ofnowProperty()
.void
setStartTime(Instant time)
Sets the value ofstartTimeProperty()
.void
setZoomRange(T smallestUnit, int smallestUnitCount, double smallestUnitWidth, T largestUnit, int largestUnitCount, double largestUnitWidth)
Sets the range in which the user can zoom in and out of the timeline.ReadOnlyObjectProperty<T>
smallestTemporalUnitProperty()
Stores the smallest temporal unit supported by the control.ObjectProperty<Instant>
startTimeProperty()
Returns the property used to store the first visible time point.
-
-
-
Method Detail
-
horizonStartTimeProperty
public final ObjectProperty<Instant> horizonStartTimeProperty()
Returns the object property used for storing the start time of the horizon.- Returns:
- the horizon start time
-
getHorizonStartTime
public final Instant getHorizonStartTime()
Returns the value ofhorizonStartTimeProperty()
.- Returns:
- the horizon start time
-
setHorizonStartTime
public final void setHorizonStartTime(Instant time)
Sets the value ofhorizonStartTimeProperty()
.- Parameters:
time
- the horizon start time
-
horizonEndTimeProperty
public final ObjectProperty<Instant> horizonEndTimeProperty()
Returns the object property used for storing the end time of the horizon.- Returns:
- the horizon end time
-
getHorizonEndTime
public final Instant getHorizonEndTime()
Returns the value ofhorizonEndTimeProperty()
.- Returns:
- the horizon end time
-
setHorizonEndTime
public final void setHorizonEndTime(Instant time)
Sets the value ofhorizonEndTimeProperty()
.- Parameters:
time
- the horizon end time
-
millisPerPixelProperty
public final DoubleProperty millisPerPixelProperty()
Returns the property used to store the millis per pixel value. This value determines how much time is represented by a single pixel in the user interface. Changing the value of this property will cause the control to show more or less time within the visible timeline area, meaning zooming can be controlled by this property.- Returns:
- the millis per pixel property
-
setMillisPerPixel
public final void setMillisPerPixel(double millis)
Sets the value of themillisPerPixelProperty()
.- Parameters:
millis
- the millis represented by a pixel
-
getMillisPerPixel
public final double getMillisPerPixel()
Returns the value ofmillisPerPixelProperty()
.- Returns:
- the millis represented by a pixel
-
minimumMillisPerPixelProperty
public final DoubleProperty minimumMillisPerPixelProperty()
A property used to store the minimum number of milliseconds that will be represented by a single pixel on the screen. Zoom-In operations will be limited by this value.- Returns:
- the minimum MPP value
- Since:
- 1.4
- See Also:
setZoomRange(TemporalUnit, int, double, TemporalUnit, int, double)
-
setMinimumMillisPerPixel
public final void setMinimumMillisPerPixel(double min)
Sets the value ofminimumMillisPerPixelProperty()
.- Parameters:
min
- the minimum MPP value- Since:
- 1.4
- See Also:
setZoomRange(TemporalUnit, int, double, TemporalUnit, int, double)
-
getMinimumMillisPerPixel
public final double getMinimumMillisPerPixel()
Returns the value ofminimumMillisPerPixelProperty()
.- Returns:
- the minimum MPP value
- Since:
- 1.4
- See Also:
setZoomRange(TemporalUnit, int, double, TemporalUnit, int, double)
-
maximumMillisPerPixelProperty
public final DoubleProperty maximumMillisPerPixelProperty()
A property used to store the maximum number of milliseconds that will be represented by a single pixel on the screen. Zoom-Out operations will be limited by this value.- Returns:
- the maximum MPP value
- Since:
- 1.4
- See Also:
setZoomRange(TemporalUnit, int, double, TemporalUnit, int, double)
-
setMaximumMillisPerPixel
public final void setMaximumMillisPerPixel(double max)
Sets the value ofmaximumMillisPerPixelProperty()
.- Parameters:
max
- the maximum MPP value- Since:
- 1.4
- See Also:
setZoomRange(TemporalUnit, int, double, TemporalUnit, int, double)
-
getMaximumMillisPerPixel
public final double getMaximumMillisPerPixel()
Returns the value ofmaximumMillisPerPixelProperty()
.- Returns:
- the maximum MPP value
- Since:
- 1.4
- See Also:
setZoomRange(TemporalUnit, int, double, TemporalUnit, int, double)
-
setZoomRange
public final void setZoomRange(T smallestUnit, int smallestUnitCount, double smallestUnitWidth, T largestUnit, int largestUnitCount, double largestUnitWidth)
Sets the range in which the user can zoom in and out of the timeline.- Parameters:
smallestUnit
- the smallest unit to which the user can zoom (e.g. "MINUTES")smallestUnitCount
- the number of smallest units (e.g. "5" MINUTES)smallestUnitWidth
- the width of the unit in pixels, must be larger than 10 (e.g. "30")largestUnit
- the largest unit to which the user can zoom (e.g. "YEARS")largestUnitCount
- the number of largest units (e.g. "1" YEAR)largestUnitWidth
- the width of the unit in pixels, must be larger than 10 (e.g. "30")- Since:
- 1.4
- See Also:
setMinimumMillisPerPixel(double)
,setMaximumMillisPerPixel(double)
-
startTimeProperty
public final ObjectProperty<Instant> startTimeProperty()
Returns the property used to store the first visible time point.- Returns:
- the start time property
-
setStartTime
public final void setStartTime(Instant time)
Sets the value ofstartTimeProperty()
.- Parameters:
time
- the start time
-
getStartTime
public final Instant getStartTime()
Returns the value ofstartTimeProperty()
.- Returns:
- the start time
-
nowProperty
public final ObjectProperty<Instant> nowProperty()
Returns the property used to store "now", the current time, e.g. the current system time.- Returns:
- the "now" time
-
setNow
public final void setNow(Instant now)
Sets the value ofnowProperty()
.- Parameters:
now
- the "now" time
-
getNow
public final Instant getNow()
Returns the value ofnowProperty()
.- Returns:
- the "now" time
-
nowLocationProperty
public final ReadOnlyDoubleProperty nowLocationProperty()
Stores the location of the "now" time. The location can be computed based on the millis per pixel and the start time value.- Returns:
- the pixel location of "now"
-
getNowLocation
public final double getNowLocation()
Returns the value ofnowLocationProperty()
.- Returns:
- the pixel location of "now"
-
smallestTemporalUnitProperty
public final ReadOnlyObjectProperty<T> smallestTemporalUnitProperty()
Stores the smallest temporal unit supported by the control.- Returns:
- the smallest temporal unit supported (e.g. "MINUTES").
-
getSmallestTemporalUnit
public final T getSmallestTemporalUnit()
Returns the value ofsmallestTemporalUnitProperty()
.- Returns:
- the smallest temporal unit
-
calculateLocationForTime
public final double calculateLocationForTime(Instant time)
Returns the pixel location of the given time.- Parameters:
time
- the time for which to return the pixel location- Returns:
- the location of the given time
-
calculateTimeForLocation
public final Instant calculateTimeForLocation(double location)
Returns the time for the given location.- Parameters:
location
- the location in pixels- Returns:
- the location time
-
-