Class VirtualGrid<T extends TemporalUnit>

  • Type Parameters:
    T - the type of the temporal unit (e.g. ChronoUnit)
    Direct Known Subclasses:
    ChronoUnitGrid, SimpleUnitGrid

    public abstract class VirtualGrid<T extends TemporalUnit>
    extends Object
    A utility class for supporting an invisible grid for editing operations on activities. When a grid is set the start and end times of activities will "snap" to locations defined by the grid.
    Since:
    1.0
    • Constructor Detail

      • VirtualGrid

        public VirtualGrid​(String name,
                           String shortName,
                           T unit,
                           int amount)
        Constructs a new grid.
        Parameters:
        name - a name that can be shown in the user interface (e.g. "15 Minutes")
        shortName - a short name that can be shown in the user interface (e.g. "15 Min.")
        unit - the temporal unit of the grid (e.g. MINUTES)
        amount - the amount of the temporal unit (e.g. "15")
        Since:
        1.1
      • VirtualGrid

        public VirtualGrid​(String name,
                           T unit,
                           int amount)
        Constructs a new grid.
        Parameters:
        name - a name that can be shown in the user interface (e.g. "15 Minutes"), will also be used as the short name
        unit - the temporal unit of the grid (e.g. MINUTES)
        amount - the amount of the temporal unit (e.g. "15")
        Since:
        1.0
    • Method Detail

      • getName

        public final String getName()
        Returns the grid name that can be used for grid selection controls.
        Returns:
        the name of the grid settings
        Since:
        1.0
      • getShortName

        public final String getShortName()
        Returns the grid short name that can be used for grid selection controls.
        Returns:
        the short name of the grid settings
        Since:
        1.1
      • getUnit

        public final T getUnit()
        The temporal unit used for the grid.
        Returns:
        the temporal unit of the grid
        Since:
        1.0
      • getAmount

        public final int getAmount()
        The number of units used for the grid.
        Returns:
        the number of units
        Since:
        1.0
      • adjustTime

        public abstract Instant adjustTime​(Instant instant,
                                           ZoneId zoneId,
                                           boolean roundUp,
                                           DayOfWeek firstDayOfWeek)
        Adjusts the given instant so that the returned instant will snap to the position defined by the grid settings.
        Parameters:
        instant - the time to adjust to a grid location
        zoneId - the time zone for which the adjustment is performed (can be different from row to row)
        roundUp - a flag signaling whether we want the adjusted time to snap to an earlier or later time (start time or end time)
        firstDayOfWeek - the weekday that is considered to be the first day of the week (mostly Monday or Sunday)
        Returns:
        the grid adjusted time
        Since:
        1.0
      • adjustTime

        public abstract LocalTime adjustTime​(LocalTime time,
                                             boolean roundUp)
        Adjusts the given local time so that the returned time will snap to the position defined by the grid settings.
        Parameters:
        time - the time to adjust to a grid location
        roundUp - a flag signaling whether we want the adjusted time to snap to an earlier or later time (start time or end time)
        Returns:
        the grid adjusted local time
        Since:
        1.0