Top Description Fields Constructors Methods
com.calendarfx.view

public Class VirtualGrid

extends Object
Class Inheritance
Imports
impl.com.calendarfx.view.util.Util, java.time.DayOfWeek, .Instant, .LocalDateTime, .ZoneId, .ZonedDateTime, java.time.temporal.ChronoUnit

A virtual grid used to make entries snap to virtual grid lines while being edited.
See Also
DateControl#setVirtualGrid(VirtualGrid)

Field Summary

Modifier and TypeField and Description
private final int
private final String
public static final VirtualGrid
OFF

The virtual grid in DateControl can never be null, hence we need a virtual grid that does nothing, the OFF grid.

private final String
private final ChronoUnit

Constructor Summary

AccessConstructor and Description
public
VirtualGrid(String
the name of the grid (e.g. "15 Minutes")
name
,
String
the short name of the grid (e.g. "15 Min.")
shortName
,
ChronoUnit
the time unit of the grid (seconds, minutes, hours)
unit
,
int
the amount of the unit (5, 10, 15 minutes)
amount
)

Constructs a new virtual grid.

Method Summary

Modifier and TypeMethod and Description
public ZonedDateTime

Returns:

the adjusted time
adjustTime
(ZonedDateTime
the time to adjust
time
,
boolean
the rounding direction
roundUp
,
DayOfWeek
the first day of the week (needed for rounding weeks)
firstDayOfWeek
)

Adjusts the given time either rounding it up or down.

public Instant

Returns:

the adjusted instant
adjustTime
(Instant
the instant to adjust
instant
,
ZoneId
the time zone
zoneId
,
boolean
the rounding direction
roundUp
,
DayOfWeek
the first day of the week (needed for rounding weeks)
firstDayOfWeek
)

Adjusts the given instant either rounding it up or down.

public LocalDateTime

Returns:

the adjusted time
adjustTime
(LocalDateTime
the time to adjust
time
,
boolean
the rounding direction
roundUp
,
DayOfWeek
the first day of the week (needed for rounding weeks)
firstDayOfWeek
)

Adjusts the given time either rounding it up or down.

public final int

Returns:

the number of units
getAmount
()

The number of units used for the grid.

public final String

Returns:

the name of the grid settings
getName
()

Returns the grid name that can be used for grid selection controls.

public final String

Returns:

the short name of the grid settings
getShortName
()

Returns the grid short name that can be used for grid selection controls.

public final ChronoUnit

Returns:

the temporal unit of the grid
getUnit
()

The temporal unit used for the grid.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

amountback to summary
private final int amount
nameback to summary
private final String name
OFFback to summary
public static final VirtualGrid OFF

The virtual grid in DateControl can never be null, hence we need a virtual grid that does nothing, the OFF grid.

See Also
DateControl#setVirtualGrid(VirtualGrid)
shortNameback to summary
private final String shortName
unitback to summary
private final ChronoUnit unit

Constructor Detail

VirtualGridback to summary
public VirtualGrid(String name, String shortName, ChronoUnit unit, int amount)

Constructs a new virtual grid.

Parameters
name:String

the name of the grid (e.g. "15 Minutes")

shortName:String

the short name of the grid (e.g. "15 Min.")

unit:ChronoUnit

the time unit of the grid (seconds, minutes, hours)

amount:int

the amount of the unit (5, 10, 15 minutes)

Method Detail

adjustTimeback to summary
public ZonedDateTime adjustTime(ZonedDateTime time, boolean roundUp, DayOfWeek firstDayOfWeek)

Adjusts the given time either rounding it up or down.

Parameters
time:ZonedDateTime

the time to adjust

roundUp:boolean

the rounding direction

firstDayOfWeek:DayOfWeek

the first day of the week (needed for rounding weeks)

Returns:ZonedDateTime

the adjusted time

adjustTimeback to summary
public Instant adjustTime(Instant instant, ZoneId zoneId, boolean roundUp, DayOfWeek firstDayOfWeek)

Adjusts the given instant either rounding it up or down.

Parameters
instant:Instant

the instant to adjust

zoneId:ZoneId

the time zone

roundUp:boolean

the rounding direction

firstDayOfWeek:DayOfWeek

the first day of the week (needed for rounding weeks)

Returns:Instant

the adjusted instant

adjustTimeback to summary
public LocalDateTime adjustTime(LocalDateTime time, boolean roundUp, DayOfWeek firstDayOfWeek)

Adjusts the given time either rounding it up or down.

Parameters
time:LocalDateTime

the time to adjust

roundUp:boolean

the rounding direction

firstDayOfWeek:DayOfWeek

the first day of the week (needed for rounding weeks)

Returns:LocalDateTime

the adjusted time

getAmountback to summary
public final int getAmount()

The number of units used for the grid.

Returns:int

the number of units

getNameback to summary
public final String getName()

Returns the grid name that can be used for grid selection controls.

Returns:String

the name of the grid settings

getShortNameback to summary
public final String getShortName()

Returns the grid short name that can be used for grid selection controls.

Returns:String

the short name of the grid settings

getUnitback to summary
public final ChronoUnit getUnit()

The temporal unit used for the grid.

Returns:ChronoUnit

the temporal unit of the grid

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override