Top Description Inners Constructors Methods
impl.com.calendarfx.view.util

public final Class Util

extends Object
Class Inheritance
Imports
com.calendarfx.view.DateControl, .Messages, javafx.application.Platform, javafx.beans.InvalidationListener, .Observable, .WeakListener, javafx.beans.property.Property, javafx.collections.FXCollections, .ObservableList, javafx.geometry.Orientation, javafx.scene.Group, .Node, .Parent, javafx.scene.control.MultipleSelectionModel, .ScrollBar, javafx.scene.layout.Pane, net.fortuna.ical4j.model.Recur, .WeekDay, net.fortuna.ical4j.transform.recurrence.Frequency, java.lang.ref.WeakReference, java.text.MessageFormat, java.time.DayOfWeek, .LocalDate, .LocalDateTime, .LocalTime, .ZonedDateTime, java.time.format.DateTimeFormatter, .DateTimeParseException, .FormatStyle, java.time.temporal.ChronoField, .ChronoUnit, java.util.ArrayList, .List, .Objects, java.util.function.Predicate, java.util.stream.Collectors

A collection of useful static methods for easy re-use in various places of the framework.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static interface
Util.Converter<
the first (left) type
L
,
the second (right) type
R
>

An interface used for converting an object of one type to an object of another type.

private static class

Constructor Summary

AccessConstructor and Description
public
Util()

Method Summary

Modifier and TypeMethod and Description
private static ZonedDateTime
adjustField(ZonedDateTime time, ChronoField field, int stepRate)

private static LocalDateTime
adjustField(LocalDateTime time, ChronoField field, int stepRate)

private static LocalTime
adjustField(LocalTime time, ChronoField field, int stepRate)

public static LocalDate

Returns:

the date of the first day of the week
adjustToFirstDayOfWeek
(LocalDate
the date to adjust
date
,
DayOfWeek
the day of week that is considered the start of the week ("Monday" in Germany, "Sunday" in the US)
firstDayOfWeek
)

Adjusts the given date to a new date that marks the beginning of the week where the given date is located.

public static LocalDate

Returns:

the date of the first day of the week
adjustToLastDayOfWeek
(LocalDate
the date to adjust
date
,
DayOfWeek
the day of week that is considered the start of the week ("Monday" in Germany, "Sunday" in the US)
firstDayOfWeek
)

Adjusts the given date to a new date that marks the end of the week where the given date is located.

public static <
the type of the left property
L
,
the type of the right property
R
>
void
bindBidirectional(Property<L>
the left property
leftProperty
,
Property<R>
the right property
rightProperty
,
Util.Converter<L, R>
the converter
converter
)

Creates a bidirectional binding between the two given properties of different types via the help of a Converter.

public static String

Returns:

a nice text describing the rule
convertRFC2445ToText
(String
the rule
rrule
,
LocalDate
the start date for the rule
startDate
)

Converts the given recurrence rule (according to RFC 2445) into a human-readable text, e.g. "RRULE:FREQ=DAILY;" becomes "Every day".

public static <T> MultipleSelectionModel<T>
public static ScrollBar

Returns:

a scrollbar or null if none can be found
findScrollBar
(Parent
the parent node
parent
,
Orientation
the orientation (horizontal, vertical)
orientation
)

Searches for a ScrollBar of the given orientation (vertical, horizontal) somewhere in the containment hierarchy of the given parent node.

public static boolean
intersect(LocalDate aStart, LocalDate aEnd, LocalDate bStart, LocalDate bEnd)

public static boolean
intersect(LocalTime aStart, LocalTime aEnd, LocalTime bStart, LocalTime bEnd)

public static boolean
private static String
private static String
makeHuman(int num)

public static boolean
removeChildren(Pane parent, Predicate<Node> predicate)

public static boolean
removeChildren(Group group, Predicate<Node> predicate)

public static void
public static LocalDateTime
truncate(LocalDateTime time, ChronoUnit unit, int stepRate, DayOfWeek firstDayOfWeek)

public static ZonedDateTime
truncate(ZonedDateTime time, ChronoUnit unit, int stepRate, DayOfWeek firstDayOfWeek)

public static LocalTime
truncate(LocalTime time, ChronoUnit unit, int stepRate)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Utilback to summary
public Util()

Method Detail

adjustFieldback to summary
private static ZonedDateTime adjustField(ZonedDateTime time, ChronoField field, int stepRate)
adjustFieldback to summary
private static LocalDateTime adjustField(LocalDateTime time, ChronoField field, int stepRate)
adjustFieldback to summary
private static LocalTime adjustField(LocalTime time, ChronoField field, int stepRate)
adjustToFirstDayOfWeekback to summary
public static LocalDate adjustToFirstDayOfWeek(LocalDate date, DayOfWeek firstDayOfWeek)

Adjusts the given date to a new date that marks the beginning of the week where the given date is located. If "Monday" is the first day of the week and the given date is a "Wednesday" then this method will return a date that is two days earlier than the given date.

Parameters
date:LocalDate

the date to adjust

firstDayOfWeek:DayOfWeek

the day of week that is considered the start of the week ("Monday" in Germany, "Sunday" in the US)

Returns:LocalDate

the date of the first day of the week

See Also
adjustToLastDayOfWeek(LocalDate, DayOfWeek), DateControl#getFirstDayOfWeek()
adjustToLastDayOfWeekback to summary
public static LocalDate adjustToLastDayOfWeek(LocalDate date, DayOfWeek firstDayOfWeek)

Adjusts the given date to a new date that marks the end of the week where the given date is located. If "Monday" is the first day of the week and the given date is a "Wednesday" then this method will return a date that is four days later than the given date. This method calculates the first day of the week and then adds six days to it.

Parameters
date:LocalDate

the date to adjust

firstDayOfWeek:DayOfWeek

the day of week that is considered the start of the week ("Monday" in Germany, "Sunday" in the US)

Returns:LocalDate

the date of the first day of the week

See Also
adjustToFirstDayOfWeek(LocalDate, DayOfWeek), DateControl#getFirstDayOfWeek()
bindBidirectionalback to summary
public static <L, R> void bindBidirectional(Property<L> leftProperty, Property<R> rightProperty, Util.Converter<L, R> converter)

Creates a bidirectional binding between the two given properties of different types via the help of a Converter.

Parameters
<L>
the type of the left property
<R>
the type of the right property
leftProperty:Property<L>

the left property

rightProperty:Property<R>

the right property

converter:Util.Converter<L, R>

the converter

convertRFC2445ToTextback to summary
public static String convertRFC2445ToText(String rrule, LocalDate startDate)

Converts the given recurrence rule (according to RFC 2445) into a human-readable text, e.g. "RRULE:FREQ=DAILY;" becomes "Every day".

Parameters
rrule:String

the rule

startDate:LocalDate

the start date for the rule

Returns:String

a nice text describing the rule

createEmptySelectionModelback to summary
public static <T> MultipleSelectionModel<T> createEmptySelectionModel()
findScrollBarback to summary
public static ScrollBar findScrollBar(Parent parent, Orientation orientation)

Searches for a ScrollBar of the given orientation (vertical, horizontal) somewhere in the containment hierarchy of the given parent node.

Parameters
parent:Parent

the parent node

orientation:Orientation

the orientation (horizontal, vertical)

Returns:ScrollBar

a scrollbar or null if none can be found

intersectback to summary
public static boolean intersect(LocalDate aStart, LocalDate aEnd, LocalDate bStart, LocalDate bEnd)
intersectback to summary
public static boolean intersect(LocalTime aStart, LocalTime aEnd, LocalTime bStart, LocalTime bEnd)
intersectback to summary
public static boolean intersect(ZonedDateTime aStart, ZonedDateTime aEnd, ZonedDateTime bStart, ZonedDateTime bEnd)
makeHumanback to summary
private static String makeHuman(WeekDay.Day wday)
makeHumanback to summary
private static String makeHuman(int num)
removeChildrenback to summary
public static boolean removeChildren(Pane parent, Predicate<Node> predicate)
removeChildrenback to summary
public static boolean removeChildren(Group group, Predicate<Node> predicate)
runInFXThreadback to summary
public static void runInFXThread(Runnable runnable)
truncateback to summary
public static LocalDateTime truncate(LocalDateTime time, ChronoUnit unit, int stepRate, DayOfWeek firstDayOfWeek)
truncateback to summary
public static ZonedDateTime truncate(ZonedDateTime time, ChronoUnit unit, int stepRate, DayOfWeek firstDayOfWeek)
truncateback to summary
public static LocalTime truncate(LocalTime time, ChronoUnit unit, int stepRate)
impl.com.calendarfx.view.util back to summary

private Class Util.BidirectionalConversionBinding<L, R>

extends Object
implements InvalidationListener, WeakListener
Class Inheritance
  • java.lang.Object
  • impl.com.calendarfx.view.util.Util.BidirectionalConversionBinding
All Implemented Interfaces
javafx.beans.WeakListener, javafx.beans.InvalidationListener

Field Summary

Modifier and TypeField and Description
private final Util.Converter<L, R>
private final WeakReference<Property<L>>
private final WeakReference<Property<R>>
private boolean

Constructor Summary

AccessConstructor and Description
private
BidirectionalConversionBinding(Property<L> leftProperty, Property<R> rightProperty, Util.Converter<L, R> converter)

Method Summary

Modifier and TypeMethod and Description
public Property<L>
public Property<R>
public void
invalidated(Observable
The Observable that became invalid
observable
)

Implements javafx.beans.InvalidationListener.invalidated.

This method needs to be provided by an implementation of InvalidationListener.

public boolean
wasGarbageCollected()

Implements javafx.beans.WeakListener.wasGarbageCollected.

Returns true if the linked listener was garbage-collected.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

converterback to summary
private final Util.Converter<L, R> converter
leftReferenceback to summary
private final WeakReference<Property<L>> leftReference
rightReferenceback to summary
private final WeakReference<Property<R>> rightReference
updatingback to summary
private boolean updating

Constructor Detail

BidirectionalConversionBindingback to summary
private BidirectionalConversionBinding(Property<L> leftProperty, Property<R> rightProperty, Util.Converter<L, R> converter)

Method Detail

getLeftPropertyback to summary
public Property<L> getLeftProperty()
getRightPropertyback to summary
public Property<R> getRightProperty()
invalidatedback to summary
public void invalidated(Observable observable)

Implements javafx.beans.InvalidationListener.invalidated.

Doc from javafx.beans.InvalidationListener.invalidated.

This method needs to be provided by an implementation of InvalidationListener. It is called if an Observable becomes invalid.

In general, it is considered bad practice to modify the observed value in this method.

Parameters
observable:Observable

The Observable that became invalid

Annotations
@Override
wasGarbageCollectedback to summary
public boolean wasGarbageCollected()

Implements javafx.beans.WeakListener.wasGarbageCollected.

Doc from javafx.beans.WeakListener.wasGarbageCollected.

Returns true if the linked listener was garbage-collected. In this case, the listener can be removed from the observable.

Returns:boolean

true if the linked listener was garbage-collected.

Annotations
@Override
impl.com.calendarfx.view.util back to summary

public Interface Util.Converter<L, R>

Type Parameters
<L>
the first (left) type
<R>
the second (right) type

An interface used for converting an object of one type to an object of another type.

Method Summary

Modifier and TypeMethod and Description
public L
toLeft(R right)

public R
toRight(L left)

Method Detail

toLeftback to summary
public L toLeft(R right)
toRightback to summary
public R toRight(L left)
impl.com.calendarfx.view.util back to summary

private Class Util.EmptySelectionModel<T>

extends MultipleSelectionModel<T>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ObservableList<Integer>
private final ObservableList<T>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
clearAndSelect(int
The index that should be the only selected index in this selection model.
index
)

Implements abstract javafx.scene.control.SelectionModel.clearAndSelect.

A method that clears any selection prior to setting the selection to the given index.

public void
clearSelection(int
The selected item to deselect.
index
)

Implements abstract javafx.scene.control.SelectionModel.clearSelection.

This method will clear the selection of the item in the given index.

public void
clearSelection()

Implements abstract javafx.scene.control.SelectionModel.clearSelection.

Clears the selection model of all selected indices.

public ObservableList<Integer>
getSelectedIndices()

Implements abstract javafx.scene.control.MultipleSelectionModel.getSelectedIndices.

Returns a read-only ObservableList of all selected indices.

public ObservableList<T>
getSelectedItems()

Implements abstract javafx.scene.control.MultipleSelectionModel.getSelectedItems.

Returns a read-only ObservableList of all selected items.

public boolean
isEmpty()

Implements abstract javafx.scene.control.SelectionModel.isEmpty.

This method is available to test whether there are any selected indices/items.

public boolean
isSelected(int
The index to check as to whether it is currently selected or not.
index
)

Implements abstract javafx.scene.control.SelectionModel.isSelected.

This method tests whether the given index is currently selected in this SelectionModel.

public void
select(int
The position of the item to select in the selection model.
index
)

Implements abstract javafx.scene.control.SelectionModel.select.

This will select the given index in the selection model, assuming the index is within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model).

public void
select(T
The object to attempt to select in the underlying data model.
obj
)

Implements abstract javafx.scene.control.SelectionModel.select.

This method will attempt to select the index that contains the given object.

public void
selectAll()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectAll.

Convenience method to select all available indices.

public void
selectFirst()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectFirst.

This method will attempt to select the first index in the control.

public void
selectIndices(int
the first index to select
index
,
int...
zero or more additional indices to select
indices
)

Implements abstract javafx.scene.control.MultipleSelectionModel.selectIndices.

This method allows for one or more selections to be set at the same time.

public void
selectLast()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectLast.

This method will attempt to select the last index in the control.

public void
selectNext()

Implements abstract javafx.scene.control.SelectionModel.selectNext.

This method will attempt to select the index directly after the current focused index.

public void
selectPrevious()

Implements abstract javafx.scene.control.SelectionModel.selectPrevious.

This method will attempt to select the index directly before the current focused index.

Inherited from javafx.scene.control.MultipleSelectionModel:
getSelectionModeselectionModePropertyselectRangesetSelectionMode

Field Detail

selectedIndicesback to summary
private final ObservableList<Integer> selectedIndices
selectedItemsback to summary
private final ObservableList<T> selectedItems

Constructor Detail

EmptySelectionModelback to summary
private EmptySelectionModel()

Method Detail

clearAndSelectback to summary
public void clearAndSelect(int index)

Implements abstract javafx.scene.control.SelectionModel.clearAndSelect.

Doc from javafx.scene.control.SelectionModel.clearAndSelect.

A method that clears any selection prior to setting the selection to the given index. The purpose of this method is to avoid having to call clearSelection() first, meaning that observers that are listening to the selected index property will not see the selected index being temporarily set to -1.

Parameters
index:int

The index that should be the only selected index in this selection model.

Annotations
@Override
clearSelectionback to summary
public void clearSelection(int index)

Implements abstract javafx.scene.control.SelectionModel.clearSelection.

Doc from javafx.scene.control.SelectionModel.clearSelection.

This method will clear the selection of the item in the given index. If the given index is not selected, nothing will happen.

Parameters
index:int

The selected item to deselect.

Annotations
@Override
clearSelectionback to summary
public void clearSelection()

Implements abstract javafx.scene.control.SelectionModel.clearSelection.

Doc from javafx.scene.control.SelectionModel.clearSelection.

Clears the selection model of all selected indices.

Annotations
@Override
getSelectedIndicesback to summary
public ObservableList<Integer> getSelectedIndices()

Implements abstract javafx.scene.control.MultipleSelectionModel.getSelectedIndices.

Doc from javafx.scene.control.MultipleSelectionModel.getSelectedIndices.

Returns a read-only ObservableList of all selected indices. The ObservableList will be updated by the selection model to always reflect changes in selection. This can be observed by adding a ListChangeListener to the returned ObservableList.

Returns:ObservableList<Integer>

the list of selected indices

Annotations
@Override
getSelectedItemsback to summary
public ObservableList<T> getSelectedItems()

Implements abstract javafx.scene.control.MultipleSelectionModel.getSelectedItems.

Doc from javafx.scene.control.MultipleSelectionModel.getSelectedItems.

Returns a read-only ObservableList of all selected items. The ObservableList will be updated further by the selection model to always reflect changes in selection. This can be observed by adding a ListChangeListener to the returned ObservableList.

Returns:ObservableList<T>

the list of selected items

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements abstract javafx.scene.control.SelectionModel.isEmpty.

Doc from javafx.scene.control.SelectionModel.isEmpty.

This method is available to test whether there are any selected indices/items. It will return true if there are no selected items, and false if there are.

Returns:boolean

Will return true if there are no selected items, and false if there are.

Annotations
@Override
isSelectedback to summary
public boolean isSelected(int index)

Implements abstract javafx.scene.control.SelectionModel.isSelected.

Doc from javafx.scene.control.SelectionModel.isSelected.

This method tests whether the given index is currently selected in this SelectionModel.

Parameters
index:int

The index to check as to whether it is currently selected or not.

Returns:boolean

True if the given index is selected, false otherwise.

Annotations
@Override
selectback to summary
public void select(int index)

Implements abstract javafx.scene.control.SelectionModel.select.

Doc from javafx.scene.control.SelectionModel.select.

This will select the given index in the selection model, assuming the index is within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model).

If there is already one or more indices selected in this model, calling this method will not clear these selections - to do so it is necessary to first call clearSelection().

If the index is already selected, it will not be selected again, or unselected. However, if multiple selection is implemented, then calling select on an already selected index will have the effect of making the index the new selected index (as returned by getSelectedIndex().

Parameters
index:int

The position of the item to select in the selection model.

Annotations
@Override
selectback to summary
public void select(T obj)

Implements abstract javafx.scene.control.SelectionModel.select.

Doc from javafx.scene.control.SelectionModel.select.

This method will attempt to select the index that contains the given object. It will iterate through the underlying data model until it finds an item whose value is equal to the given object. At this point it will stop iterating - this means that this method will not select multiple indices.

Parameters
obj:T

The object to attempt to select in the underlying data model.

Annotations
@Override
selectAllback to summary
public void selectAll()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectAll.

Doc from javafx.scene.control.MultipleSelectionModel.selectAll.

Convenience method to select all available indices.

Annotations
@Override
selectFirstback to summary
public void selectFirst()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectFirst.

Doc from javafx.scene.control.MultipleSelectionModel.selectFirst.

This method will attempt to select the first index in the control. If clearSelection is not called first, this method will have the result of selecting the first index, whilst retaining the selection of any other currently selected indices.

If the first index is already selected, calling this method will have no result, and no selection event will take place.

Annotations
@Override
selectIndicesback to summary
public void selectIndices(int index, int... indices)

Implements abstract javafx.scene.control.MultipleSelectionModel.selectIndices.

Doc from javafx.scene.control.MultipleSelectionModel.selectIndices.

This method allows for one or more selections to be set at the same time. It will ignore any value that is not within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model). Any duplication of indices will be ignored.

If there is already one or more indices selected in this model, calling this method will not clear these selections - to do so it is necessary to first call clearSelection.

The last valid value given will become the selected index / selected item.

Parameters
index:int

the first index to select

indices:int[]

zero or more additional indices to select

Annotations
@Override
selectLastback to summary
public void selectLast()

Implements abstract javafx.scene.control.MultipleSelectionModel.selectLast.

Doc from javafx.scene.control.MultipleSelectionModel.selectLast.

This method will attempt to select the last index in the control. If clearSelection is not called first, this method will have the result of selecting the last index, whilst retaining the selection of any other currently selected indices.

If the last index is already selected, calling this method will have no result, and no selection event will take place.

Annotations
@Override
selectNextback to summary
public void selectNext()

Implements abstract javafx.scene.control.SelectionModel.selectNext.

Doc from javafx.scene.control.SelectionModel.selectNext.

This method will attempt to select the index directly after the current focused index. If clearSelection is not called first, this method will have the result of selecting the next index, whilst retaining the selection of any other currently selected indices.

Calling this method will only succeed if:

  • There is currently a lead/focused index.
  • The lead/focus index is not the last index in the control.
  • The next index is not already selected.

If any of these conditions is false, no selection event will take place.

Annotations
@Override
selectPreviousback to summary
public void selectPrevious()

Implements abstract javafx.scene.control.SelectionModel.selectPrevious.

Doc from javafx.scene.control.SelectionModel.selectPrevious.

This method will attempt to select the index directly before the current focused index. If clearSelection is not called first, this method will have the result of selecting the previous index, whilst retaining the selection of any other currently selected indices.

Calling this method will only succeed if:

  • There is currently a lead/focused index.
  • The lead/focus index is not the first index in the control.
  • The previous index is not already selected.

If any of these conditions is false, no selection event will take place.

Annotations
@Override