Class Resolution<T extends TemporalUnit>

java.lang.Object
com.flexganttfx.model.dateline.Resolution<T>
Type Parameters:
T - the type of the temporal unit
Direct Known Subclasses:
ChronoUnitResolution, SimpleUnitResolution

public abstract class Resolution<T extends TemporalUnit>
extends Object
A resolution represents the visual representation of a temporal unit. The unit will be displayed in the given format, step rate, and in the given positions.
Since:
1.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  Resolution.Position  
  • Constructor Summary

    Constructors
    Constructor Description
    Resolution​(T temporalUnit, String format, int stepRate)
    Constructs a new resolution for the given temporal unit, in the given format, step rate, for all positions.
    Resolution​(T temporalUnit, String format, int stepRate, Resolution.Position... supportedPositions)
    Constructs a new resolution for the given temporal unit, in the given format, step rate, and for the given supported positions.
  • Method Summary

    Modifier and Type Method Description
    abstract VirtualGrid<T> createGrid()
    Creates a virtual grid for editing operations based on the settings of this resolution.
    abstract Instant decrement​(Instant instant, ZoneId zoneId)
    Decrements the given time based on the temporal unit represented by this resolution.
    abstract String format​(Instant instant, ZoneId zoneId)
    Formats the given time / instant for the given time zone based on the settings of this resolution.
    String getFormat()
    Returns the format in which the resolution will be displayed.
    int getStepRate()
    Returns the step rate of this resolution, e.g.
    T getTemporalUnit()
    Returns the temporal unit represented by this resolution.
    abstract Instant increment​(Instant instant, ZoneId zoneId)
    Increments the given time based on the temporal unit represented by this resolution.
    boolean isSupportingPosition​(Resolution.Position position)
    Determines if the given position is supported by this resolution.
    String toString()  
    abstract Instant truncate​(Instant instant, ZoneId zoneId, DayOfWeek firstDayOfWeek)
    Truncates the given time based on the temporal unit represented by this resolution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Resolution

      public Resolution​(T temporalUnit, String format, int stepRate, Resolution.Position... supportedPositions)
      Constructs a new resolution for the given temporal unit, in the given format, step rate, and for the given supported positions.
      Parameters:
      temporalUnit - the temporal unit (e.g. DAYS)
      format - the display format (e.g. HH:MM)
      stepRate - the step rate (e.g. 1, 5, 10, 15, 30)
      supportedPositions - the supported positions (top, middle, bottom) inside the dateline
      Since:
      1.0
    • Resolution

      public Resolution​(T temporalUnit, String format, int stepRate)
      Constructs a new resolution for the given temporal unit, in the given format, step rate, for all positions.
      Parameters:
      temporalUnit - the temporal unit (e.g. DAYS)
      format - the display format (e.g. HH:MM)
      stepRate - the step rate (e.g. 1, 5, 10, 15, 30)
      Since:
      1.0
  • Method Details

    • isSupportingPosition

      public final boolean isSupportingPosition​(Resolution.Position position)
      Determines if the given position is supported by this resolution.
      Parameters:
      position - the position
      Returns:
      true if the position is supported
      Since:
      1.0
    • getTemporalUnit

      public final T getTemporalUnit()
      Returns the temporal unit represented by this resolution.
      Returns:
      the temporal unit
      Since:
      1.0
    • getFormat

      public final String getFormat()
      Returns the format in which the resolution will be displayed.
      Returns:
      the format string for the date time formatter
      Since:
      1.0
      See Also:
      DateTimeFormatter.format(TemporalAccessor)
    • getStepRate

      public final int getStepRate()
      Returns the step rate of this resolution, e.g. "5" for "5 Minutes". Normally values are 1, 5, 10, 15, or 30.
      Returns:
      the step rate
      Since:
      1.0
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • format

      public abstract String format​(Instant instant, ZoneId zoneId)
      Formats the given time / instant for the given time zone based on the settings of this resolution.
      Parameters:
      instant - the time used for the formatting
      zoneId - the time zone
      Returns:
      the formatted time
      Since:
      1.0
    • truncate

      public abstract Instant truncate​(Instant instant, ZoneId zoneId, DayOfWeek firstDayOfWeek)
      Truncates the given time based on the temporal unit represented by this resolution. Example: a date located on a Wednesday will be adjusted to a date on the previous Monday (if Monday is the first day of the week in the given time zone).
      Parameters:
      instant - the time to truncate
      zoneId - the time zone
      firstDayOfWeek - the weekday that is considered to be the first day of the week
      Returns:
      the truncated time
      Since:
      1.0
    • increment

      public abstract Instant increment​(Instant instant, ZoneId zoneId)
      Increments the given time based on the temporal unit represented by this resolution. Example: if the temporal unit is DAY and the given time is located on Monday, then the incremented time will be Tuesday. If the temporal unit is WEEK then the incremented time will be the Monday of the next week. This function is very important for building the cells in the dateline control.
      Parameters:
      instant - the time to increment
      zoneId - the time zone
      Returns:
      the incremented time
      Since:
      1.0
    • decrement

      public abstract Instant decrement​(Instant instant, ZoneId zoneId)
      Decrements the given time based on the temporal unit represented by this resolution. Example: if the temporal unit is DAY and the given time is located on Monday, then the decremented time will be Sunday. If the temporal unit is WEEK then the decremented time will be the Monday of the previous week. This function is very important for building the cells in the dateline control.
      Parameters:
      instant - the time to increment
      zoneId - the time zone
      Returns:
      the incremented time
    • createGrid

      public abstract VirtualGrid<T> createGrid()
      Creates a virtual grid for editing operations based on the settings of this resolution.
      Returns:
      the virtual grid
      Since:
      1.1