Module VirtualizedFX
Interface VFXGridHelper<T,C extends VFXCell<T>>
- All Known Implementing Classes:
VFXGridHelper.DefaultHelper
public interface VFXGridHelper<T,C extends VFXCell<T>>
This interface is a utility API for
VFXGrid
, despite computations not depending on other properties
(some VFXList values depend on the orientation, for example),
it's still a nice way to adhere to the encapsulation and separation of concerns principles.
Has one concrete implementation: VFXGridHelper.DefaultHelper
.-
Property Summary
PropertiesTypePropertyDescriptionjavafx.beans.property.ReadOnlyObjectProperty
<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> Specifies the range of columns that should be present in the viewport.javafx.beans.property.ReadOnlyDoubleProperty
Specifies the maximum possible horizontal position.javafx.beans.property.ReadOnlyDoubleProperty
Specifies the maximum possible vertical position.javafx.beans.property.ReadOnlyObjectProperty
<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> Specifies the range of rows that should be present in the viewport.javafx.beans.property.ReadOnlyObjectProperty
<io.github.palexdev.mfxcore.base.beans.Position> Cells are actually contained in a separate pane called 'viewport'.javafx.beans.property.ReadOnlyDoubleProperty
Specifies the total number of pixels on the x-axis.javafx.beans.property.ReadOnlyDoubleProperty
Specifies the total number of pixels on the y-axis. -
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
VFXGridHelper.DefaultHelper<T,
C extends VFXCell<T>> Concrete implementation ofVFXGridHelper
, here the range of rows and columns to display, as well as the viewport position, the virtual max x and y properties are defined as follows: -
Method Summary
Modifier and TypeMethodDescriptiondefault io.github.palexdev.mfxcore.base.beans.range.IntegerRange
javafx.beans.property.ReadOnlyObjectProperty
<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> Specifies the range of columns that should be present in the viewport.default void
dispose()
Automatically called byVFXGrid
when a helper is not needed anymore (changed).int
int
firstRow()
getGrid()
default double
default double
io.github.palexdev.mfxcore.base.beans.Size
default io.github.palexdev.mfxcore.base.beans.Position
default double
default double
default C
indexToCell
(int index) Converts the given index to a cell.default T
indexToItem
(int index) Converts the given index to an item (shortcut forgetGrid().getItems().get(index)
).default void
Forces theVFXGrid.vPosProperty()
andVFXGrid.hPosProperty()
to be invalidated.default C
itemToCell
(T item) Converts the given item to a cell.int
int
lastRow()
void
Lays out the given cell.int
javafx.beans.property.ReadOnlyDoubleProperty
Specifies the maximum possible horizontal position.int
maxRows()
javafx.beans.property.ReadOnlyDoubleProperty
Specifies the maximum possible vertical position.default io.github.palexdev.mfxcore.base.beans.range.IntegerRange
javafx.beans.property.ReadOnlyObjectProperty
<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> Specifies the range of rows that should be present in the viewport.default void
scrollToColumn
(int column) Scrolls to the given column index by setting theVFXGrid.hPosProperty()
tocolumnIndex * totalCellWidth
.default void
scrollToRow
(int row) Scrolls to the given row index by setting theVFXGrid.vPosProperty()
torowIndex * totalCellHeight
.default int
int
int
javafx.beans.property.ReadOnlyObjectProperty
<io.github.palexdev.mfxcore.base.beans.Position> Cells are actually contained in a separate pane called 'viewport'.javafx.beans.property.ReadOnlyDoubleProperty
Specifies the total number of pixels on the x-axis.javafx.beans.property.ReadOnlyDoubleProperty
Specifies the total number of pixels on the y-axis.default int
int
int
-
Property Details
-
columnsRange
javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> columnsRangePropertySpecifies the range of columns that should be present in the viewport. This also takes into account buffer columns, seevisibleColumns()
andtotalColumns()
.- See Also:
-
rowsRange
javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> rowsRangePropertySpecifies the range of rows that should be present in the viewport. This also takes into account buffer rows, seevisibleRows()
andtotalRows()
.- See Also:
-
virtualMaxX
javafx.beans.property.ReadOnlyDoubleProperty virtualMaxXPropertySpecifies the total number of pixels on the x-axis.- See Also:
-
virtualMaxY
javafx.beans.property.ReadOnlyDoubleProperty virtualMaxYPropertySpecifies the total number of pixels on the y-axis.- See Also:
-
maxVScroll
javafx.beans.property.ReadOnlyDoubleProperty maxVScrollPropertySpecifies the maximum possible vertical position.- See Also:
-
maxHScroll
javafx.beans.property.ReadOnlyDoubleProperty maxHScrollPropertySpecifies the maximum possible horizontal position.- See Also:
-
viewportPosition
javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.Position> viewportPositionPropertyCells are actually contained in a separate pane called 'viewport'. The scroll is applied on this pane.This property specifies the translation of the viewport, the value depends on the implementation.
- See Also:
-
-
Method Details
-
maxColumns
int maxColumns()- Returns:
- the maximum number of columns the grid can have. This value is essentially the same as
VFXGrid.columnsNumProperty()
but it's also taken into account the number of items (you can't have more columns than the number of items)
-
firstColumn
int firstColumn()- Returns:
- the index of the first visible column
-
lastColumn
int lastColumn()- Returns:
- the index of the last visible column
-
visibleColumns
int visibleColumns()- Returns:
- the number of columns visible in the viewport. Not necessarily the same as
totalColumns()
-
totalColumns
int totalColumns()- Returns:
- the total number of columns in the viewport which doesn't include only the number of visible columns but also the number of buffer columns
-
columnsRangeProperty
javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> columnsRangeProperty()Specifies the range of columns that should be present in the viewport. This also takes into account buffer columns, seevisibleColumns()
andtotalColumns()
.- Returns:
- the
columnsRange
property
-
columnsRange
default io.github.palexdev.mfxcore.base.beans.range.IntegerRange columnsRange()- Returns:
- the range of columns that should be present in the viewport. This also takes into account buffer columns,
see
visibleColumns()
andtotalColumns()
-
maxRows
int maxRows()- Returns:
- the maximum number of rows the grid can have. This value depends on the number of items and the number of columns
-
firstRow
int firstRow()- Returns:
- the index of the first visible row
-
lastRow
int lastRow()- Returns:
- the index of the last visible row
-
visibleRows
int visibleRows()- Returns:
- the number of rows visible in the viewport. Not necessarily the same as
totalRows()
-
totalRows
int totalRows()- Returns:
- the total number of rows in the viewport which doesn't include only the number of visible rows but also the number of buffer rows
-
rowsRangeProperty
javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> rowsRangeProperty()Specifies the range of rows that should be present in the viewport. This also takes into account buffer rows, seevisibleRows()
andtotalRows()
.- Returns:
- the
rowsRange
property
-
rowsRange
default io.github.palexdev.mfxcore.base.beans.range.IntegerRange rowsRange()- Returns:
- the range of rows that should be present in the viewport. This also takes into account buffer rows,
see
visibleRows()
andtotalRows()
.
-
virtualMaxXProperty
javafx.beans.property.ReadOnlyDoubleProperty virtualMaxXProperty()Specifies the total number of pixels on the x-axis.- Returns:
- the
virtualMaxX
property - See Also:
-
getVirtualMaxX
default double getVirtualMaxX()- Returns:
- the total number of pixels on the x-axis.
-
virtualMaxYProperty
javafx.beans.property.ReadOnlyDoubleProperty virtualMaxYProperty()Specifies the total number of pixels on the y-axis.- Returns:
- the
virtualMaxY
property - See Also:
-
getVirtualMaxY
default double getVirtualMaxY()- Returns:
- the total number of pixels on the y-axis.
-
getMaxVScroll
default double getMaxVScroll()- Returns:
- the maximum possible vertical position.
-
maxVScrollProperty
javafx.beans.property.ReadOnlyDoubleProperty maxVScrollProperty()Specifies the maximum possible vertical position.- Returns:
- the
maxVScroll
property - See Also:
-
getMaxHScroll
default double getMaxHScroll()- Returns:
- the maximum possible horizontal position.
-
maxHScrollProperty
javafx.beans.property.ReadOnlyDoubleProperty maxHScrollProperty()Specifies the maximum possible horizontal position.- Returns:
- the
maxHScroll
property - See Also:
-
viewportPositionProperty
javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.Position> viewportPositionProperty()Cells are actually contained in a separate pane called 'viewport'. The scroll is applied on this pane.This property specifies the translation of the viewport, the value depends on the implementation.
- Returns:
- the
viewportPosition
property - See Also:
-
getViewportPosition
default io.github.palexdev.mfxcore.base.beans.Position getViewportPosition()- Returns:
- the position the viewport should be at in the container
-
layout
Lays out the given cell. The row and column layout indexes are necessary to identify the position of a cell among the others (comes before/after, above/below).- See Also:
-
getTotalCellSize
io.github.palexdev.mfxcore.base.beans.Size getTotalCellSize()- Returns:
- the total size of each cell, given by the
VFXGrid.cellSizeProperty()
summed to the horizontal and vertical spacing values
-
getGrid
- Returns:
- the
VFXGrid
instance associated to this helper
-
visibleCells
default int visibleCells()- Returns:
- the theoretical number of cells in the viewport. The value depends on the number of visible columns and rows,
however, doesn't take into account the possibility of incomplete columns/rows. For a precise value,
use
totalCells()
instead
-
totalCells
default int totalCells()- Returns:
- the precise number of cells present in the viewport at a given time. The value depends on the current range of rows and columns. Unfortunately, it's not very efficient as the count is computed by iterating over each row and column, but it's the only stable way I found to have a correct value.
-
scrollToRow
default void scrollToRow(int row) Scrolls to the given row index by setting theVFXGrid.vPosProperty()
torowIndex * totalCellHeight
. -
scrollToColumn
default void scrollToColumn(int column) Scrolls to the given column index by setting theVFXGrid.hPosProperty()
tocolumnIndex * totalCellWidth
. -
invalidatePos
default void invalidatePos()Forces theVFXGrid.vPosProperty()
andVFXGrid.hPosProperty()
to be invalidated. This is simply done by calling the respective setters with their current respective values. Those two properties will automatically callgetMaxVScroll()
andgetMaxHScroll()
to ensure the values are correct. Automatically invoked by theVFXGridManager
when needed. -
indexToItem
Converts the given index to an item (shortcut forgetGrid().getItems().get(index)
). -
indexToCell
Converts the given index to a cell. UsesitemToCell(Object)
. -
itemToCell
Converts the given item to a cell. The result is either on of the cells cached inVFXCellsCache
that is updated with the given item, or a totally new one created by theVFXGrid.cellFactoryProperty()
. -
dispose
default void dispose()Automatically called byVFXGrid
when a helper is not needed anymore (changed). If the helper uses listeners/bindings that may lead to memory leaks, this is the right place to remove them.
-