Module com.flexganttfx.model
Package com.flexganttfx.model.dateline
Class VirtualGrid<T extends TemporalUnit>
java.lang.Object
com.flexganttfx.model.dateline.VirtualGrid<T>
- 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 Summary
Constructors Constructor Description VirtualGrid(String name, String shortName, T unit, int amount)
Constructs a new grid.VirtualGrid(String name, T unit, int amount)
Constructs a new grid. -
Method Summary
Modifier and Type Method Description 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.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.int
getAmount()
The number of units used for the grid.String
getName()
Returns the grid name that can be used for grid selection controls.String
getShortName()
Returns the grid short name that can be used for grid selection controls.T
getUnit()
The temporal unit used for the grid.String
toString()
-
Constructor Details
-
VirtualGrid
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
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 nameunit
- the temporal unit of the grid (e.g. MINUTES)amount
- the amount of the temporal unit (e.g. "15")- Since:
- 1.0
-
-
Method Details
-
getName
Returns the grid name that can be used for grid selection controls.- Returns:
- the name of the grid settings
- Since:
- 1.0
-
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
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 locationzoneId
- 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
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 locationroundUp
- 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
-
toString
-