Class TimelineModel<T extends TemporalUnit>

  • 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).
    This class is also responsible for calculating the location for a given time and vice versa.

    • Constructor Detail

      • TimelineModel

        protected TimelineModel()
        Constructs a new timeline model.
    • 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
      • setHorizonStartTime

        public final void setHorizonStartTime​(Instant time)
        Sets the value of horizonStartTimeProperty().
        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
      • setHorizonEndTime

        public final void setHorizonEndTime​(Instant time)
        Sets the value of horizonEndTimeProperty().
        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 the millisPerPixelProperty().
        Parameters:
        millis - the millis represented by a pixel
      • getMillisPerPixel

        public final double getMillisPerPixel()
        Returns the value of millisPerPixelProperty().
        Returns:
        the millis represented by a pixel
      • 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 of startTimeProperty().
        Parameters:
        time - 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 of nowProperty().
        Parameters:
        now - the "now" time
      • getNow

        public final Instant getNow()
        Returns the value of nowProperty().
        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 of nowLocationProperty().
        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 of smallestTemporalUnitProperty().
        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