Class OrientationHelper.VerticalHelper
- All Implemented Interfaces:
OrientationHelper
- Enclosing interface:
- OrientationHelper
OrientationHelper
for Orientation.VERTICAL
.
This helper is also responsible for listening to changes to the VirtualFlow's height,
because in such cases it's needed to recompute the number of cells needed (to add or remove),
and changes to the VirtualFlow.verticalPositionProperty()
to update the container's layoutY
property and call SimpleVirtualFlowContainer.update(double)
with the new position.
- See Also:
OrientationHelper
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.palexdev.virtualizedfx.flow.base.OrientationHelper
OrientationHelper.HorizontalHelper, OrientationHelper.VerticalHelper
-
Constructor Summary
ConstructorsConstructorDescriptionVerticalHelper(VirtualFlow<?,?> virtualFlow, SimpleVirtualFlowContainer<?,?> container)
-
Method Summary
Modifier and TypeMethodDescriptionint
double
computeEstimatedHeight(double cellHeight)
Computes the estimated height of the flow.double
computeEstimatedWidth(double cellWidth)
Computes the estimated width of the flow.void
dispose()
Removes and clears any listener.int
Computes the first visible cell index in the viewport with this formula:double
double
If the Node's maxWidth is set toDouble.MAX_VALUE
then returns the VirtualFlow's width, otherwise callsOrientationHelper.boundSize(double, double, double)
.void
DO NOT CALL THIS METHOD, it's automatically handled by the VirtualFlow.int
Computes the first visible cell index in the viewport with this formula:void
Computes the Node's y position and then callsresizeRelocate(Node, double, double, double)
.void
resizeRelocate(Node node, double pos, double w, double h)
Resizes and relocated the given node with the given parameters, the x offset is always 0.void
scrollBy(double pixels)
Scrolls the flow by the given amount of pixels.void
scrollTo(int index)
Scrolls the flow to the given cell index.void
CallsscrollTo(int)
with 0 as argument.void
CallsscrollTo(int)
with items size - 1 as argument.void
scrollToPixel(double pixel)
Scrolls the flow to the given pixel value.
-
Constructor Details
-
VerticalHelper
-
-
Method Details
-
initialize
public void initialize()DO NOT CALL THIS METHOD, it's automatically handled by the VirtualFlow. -
firstVisible
public int firstVisible()Computes the first visible cell index in the viewport with this formula:(int) Math.floor(scrolled / cellHeight)
The scrolled parameter is the amount of pixels scrolled from the top and cellHeight is the fixed cells' height.
The result is clamped between 0 and the number of items -1.
- Specified by:
firstVisible
in interfaceOrientationHelper
- Returns:
- the index of the first visible cell in the viewport
-
lastVisible
public int lastVisible()Computes the first visible cell index in the viewport with this formula:(int) Math.ceil((scrolled + virtualFlowHeight) / cellHeight - 1)
The scrolled parameter is the amount of pixels scrolled from the top, the virtualFlowHeight well... is self-explanatory, and cellHeight is the fixed cells' height.
The result is clamped between 0 and the number of items -1.
- Specified by:
lastVisible
in interfaceOrientationHelper
- Returns:
- the index of the last visible cell in the viewport
-
computeCellsNumber
public int computeCellsNumber()- Specified by:
computeCellsNumber
in interfaceOrientationHelper
- Returns:
- the number of cells to show based on the viewport's height and cells' height
-
computeEstimatedHeight
public double computeEstimatedHeight(double cellHeight)Description copied from interface:OrientationHelper
Computes the estimated height of the flow.- Specified by:
computeEstimatedHeight
in interfaceOrientationHelper
- Returns:
- the given cellHeight multiplied by the number of items
-
computeEstimatedWidth
public double computeEstimatedWidth(double cellWidth)Description copied from interface:OrientationHelper
Computes the estimated width of the flow.- Specified by:
computeEstimatedWidth
in interfaceOrientationHelper
- Returns:
- the VirtualFlow's width
-
getHeight
- Specified by:
getHeight
in interfaceOrientationHelper
- Returns:
- the Node's pref height
-
getWidth
If the Node's maxWidth is set toDouble.MAX_VALUE
then returns the VirtualFlow's width, otherwise callsOrientationHelper.boundSize(double, double, double)
.- Specified by:
getWidth
in interfaceOrientationHelper
- Returns:
- the width of the given node
-
resizeRelocate
Resizes and relocated the given node with the given parameters, the x offset is always 0.- Specified by:
resizeRelocate
in interfaceOrientationHelper
- Parameters:
node
- the Node to resize and relocatepos
- the y positionw
- the widthh
- the height
-
layout
Computes the Node's y position and then callsresizeRelocate(Node, double, double, double)
.- Specified by:
layout
in interfaceOrientationHelper
-
scrollBy
public void scrollBy(double pixels)Scrolls the flow by the given amount of pixels. Gets the current vertical position and adds the given amount of pixels to it. The result is clamped between 0 and the vBar's max property.- Specified by:
scrollBy
in interfaceOrientationHelper
-
scrollTo
public void scrollTo(int index)Scrolls the flow to the given cell index. Computes the pixel value by multiplying the given index for the fixed cells' height, then callsscrollToPixel(double)
with the result.- Specified by:
scrollTo
in interfaceOrientationHelper
-
scrollToFirst
public void scrollToFirst()CallsscrollTo(int)
with 0 as argument.- Specified by:
scrollToFirst
in interfaceOrientationHelper
-
scrollToLast
public void scrollToLast()CallsscrollTo(int)
with items size - 1 as argument.- Specified by:
scrollToLast
in interfaceOrientationHelper
-
scrollToPixel
public void scrollToPixel(double pixel)Scrolls the flow to the given pixel value. The given pixel value is clamped between 0 and the vBar's max property before.- Specified by:
scrollToPixel
in interfaceOrientationHelper
-
dispose
public void dispose()Removes and clears any listener.This must be called every time the OrientationHelper of the VirtualFlow is changed (typically occurs when the orientation changes).
- Specified by:
dispose
in interfaceOrientationHelper
-