Class SimpleVirtualFlow<T,C extends Cell<T>>
- Type Parameters:
T
- the type of objects to representC
- the type of Cell to use
- All Implemented Interfaces:
VirtualFlow<T,
,C> Styleable
,EventTarget
VirtualFlow
.
This VirtualFlow creates Cells of type Cell
, it's features are:
- The items list is managed automatically (insertions, removals or updates to the items)
- The cell factory can be changed any time
- Can show the cells from TOP to BOTTOM or from LEFT to RIGHT, this is the orientation property
- It's possible to change the orientation event at runtime (but it's also recommended resizing both the VirtualFlow and the cells)
- It's not necessary to wrap the flow in a scroll pane as it already includes both the scroll bars
- It's possible to set the speed of both the scroll bars
- It's possible to scroll manually by pixels or to cell index
- It's possible to get the currently shown/built cells or a specific cell by index
To build a SimpleVirtualFlow use theSimpleVirtualFlow.Builder
class.
The cells are contained in a Group
which is a SimpleVirtualFlowContainer
.-
Property Summary
TypePropertyDescriptionProperty for the cell factory function.Property for the horizontal scroll bar's value.Property for the items list.The orientation property of the VirtualFlow.Property for the vertical scroll bar's value.Properties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
Properties inherited from class javafx.scene.Parent
needsLayout
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder class to createSimpleVirtualFlow
s.class
Helper class to manage extra features of the VirtualFlow. -
Field Summary
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
Constructor Summary
ModifierConstructorDescriptionprotected
SimpleVirtualFlow
(ObjectProperty<ObservableList<T>> items, Function<T, C> cellFactory, Orientation orientation) SimpleVirtualFlow
(ObservableList<T> items, Function<T, C> cellFactory, Orientation orientation) -
Method Summary
Modifier and TypeMethodDescriptionProperty for the cell factory function.protected double
computePrefHeight
(double width) protected double
computePrefWidth
(double height) features()
getCell
(int index) double
getCells()
double
getHBar()
double
getItems()
protected OrientationHelper
getVBar()
double
Property for the horizontal scroll bar's value.protected void
Adds the container to the children list, callssetupScrollBars()
.boolean
Gets the value of the property fitToHeight.boolean
Gets the value of the property fitToWidth.Property for the items list.protected void
The orientation property of the VirtualFlow.void
scrollBy
(double pixels) Scrolls by the given amount of pixels.void
scrollTo
(int index) Scrolls to the given cell index.void
Scrolls to the first cell.void
Scrolls to the last cell.void
scrollToPixel
(double pixel) Scrolls to the given pixel value.void
setCellFactory
(Function<T, C> cellFactory) Sets the function used to build a Cell from an object of type T.void
setFitToHeight
(boolean fitToHeight) Sets the value of the property fitToHeight.void
setFitToWidth
(boolean fitToWidth) Sets the value of the property fitToWidth.void
setHorizontalPosition
(double hValue) Sets the horizontal scroll bar's valuevoid
setHSpeed
(double unit, double block) Sets the horizontal scroll bar speeds.void
setItems
(ObservableList<T> items) Replaces the items list with the given one.void
setOrientation
(Orientation orientation) Sets the orientation of the VirtualFlow.void
setVerticalPosition
(double vValue) Sets the vertical scroll bar's valuevoid
setVSpeed
(double unit, double block) Sets the vertical scroll bar speeds.Property for the vertical scroll bar's value.Methods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
Methods inherited from class javafx.scene.Parent
getBaselineOffset, getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
items
Property for the items list.- See Also:
-
cellFactory
Property for the cell factory function.- Specified by:
cellFactoryProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
fitToWidth
- Specified by:
fitToWidthProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
fitToHeight
- Specified by:
fitToHeightProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
verticalPosition
Property for the vertical scroll bar's value.- Specified by:
verticalPositionProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
horizontalPosition
Property for the horizontal scroll bar's value.- Specified by:
horizontalPositionProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
orientation
The orientation property of the VirtualFlow.- See Also:
-
-
Constructor Details
-
SimpleVirtualFlow
protected SimpleVirtualFlow() -
SimpleVirtualFlow
public SimpleVirtualFlow(ObservableList<T> items, Function<T, C> cellFactory, Orientation orientation) -
SimpleVirtualFlow
public SimpleVirtualFlow(ObjectProperty<ObservableList<T>> items, Function<T, C> cellFactory, Orientation orientation)
-
-
Method Details
-
initialize
protected void initialize()Adds the container to the children list, callssetupScrollBars()
.Also adds listeners for the cellFactory property and the orientation property. Also initializes the orientation helper and the container when
A little note: the orientation helper is initialized manually at this specific point because otherwise the added listeners cause an infinite loop that will eat RAM for some reason.Parent.needsLayoutProperty()
is becomes false. -
getCell
- Returns:
- the cell at the specified index, null if not found
-
getCells
- Returns:
- all the currently shown cells
-
scrollBy
public void scrollBy(double pixels) Scrolls by the given amount of pixels. -
scrollTo
public void scrollTo(int index) Scrolls to the given cell index. -
scrollToFirst
public void scrollToFirst()Scrolls to the first cell. -
scrollToLast
public void scrollToLast()Scrolls to the last cell. -
scrollToPixel
public void scrollToPixel(double pixel) Scrolls to the given pixel value. -
setHSpeed
public void setHSpeed(double unit, double block) Sets the horizontal scroll bar speeds. -
setVSpeed
public void setVSpeed(double unit, double block) Sets the vertical scroll bar speeds. -
computePrefWidth
protected double computePrefWidth(double height) - Overrides:
computePrefWidth
in classRegion
-
computePrefHeight
protected double computePrefHeight(double width) - Overrides:
computePrefHeight
in classRegion
-
getUserAgentStylesheet
- Overrides:
getUserAgentStylesheet
in classRegion
-
layoutChildren
protected void layoutChildren()- Overrides:
layoutChildren
in classParent
-
getItems
-
itemsProperty
Property for the items list.- See Also:
-
setItems
Replaces the items list with the given one. -
getCellFactory
- Specified by:
getCellFactory
in interfaceVirtualFlow<T,
C extends Cell<T>> - Returns:
- the function used to build a Cell from an object of type T
-
cellFactoryProperty
Property for the cell factory function.- Specified by:
cellFactoryProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
setCellFactory
Sets the function used to build a Cell from an object of type T.- Specified by:
setCellFactory
in interfaceVirtualFlow<T,
C extends Cell<T>>
-
getCellWidth
public double getCellWidth()- Specified by:
getCellWidth
in interfaceVirtualFlow<T,
C extends Cell<T>> - Returns:
- the width of the cells
-
getCellHeight
public double getCellHeight()- Specified by:
getCellHeight
in interfaceVirtualFlow<T,
C extends Cell<T>> - Returns:
- the height of the cells
-
getHBar
-
getVBar
-
isFitToWidth
public boolean isFitToWidth()Gets the value of the property fitToWidth.- Specified by:
isFitToWidth
in interfaceVirtualFlow<T,
C extends Cell<T>> - Property description:
-
fitToWidthProperty
- Specified by:
fitToWidthProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
setFitToWidth
public void setFitToWidth(boolean fitToWidth) Sets the value of the property fitToWidth.- Specified by:
setFitToWidth
in interfaceVirtualFlow<T,
C extends Cell<T>> - Property description:
-
isFitToHeight
public boolean isFitToHeight()Gets the value of the property fitToHeight.- Specified by:
isFitToHeight
in interfaceVirtualFlow<T,
C extends Cell<T>> - Property description:
-
fitToHeightProperty
- Specified by:
fitToHeightProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
setFitToHeight
public void setFitToHeight(boolean fitToHeight) Sets the value of the property fitToHeight.- Specified by:
setFitToHeight
in interfaceVirtualFlow<T,
C extends Cell<T>> - Property description:
-
getVerticalPosition
public double getVerticalPosition()- Specified by:
getVerticalPosition
in interfaceVirtualFlow<T,
C extends Cell<T>> - Returns:
- the vertical scroll bar's value
-
verticalPositionProperty
Property for the vertical scroll bar's value.- Specified by:
verticalPositionProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
setVerticalPosition
public void setVerticalPosition(double vValue) Sets the vertical scroll bar's value- Specified by:
setVerticalPosition
in interfaceVirtualFlow<T,
C extends Cell<T>>
-
getHorizontalPosition
public double getHorizontalPosition()- Specified by:
getHorizontalPosition
in interfaceVirtualFlow<T,
C extends Cell<T>> - Returns:
- the horizontal scroll bar's value
-
horizontalPositionProperty
Property for the horizontal scroll bar's value.- Specified by:
horizontalPositionProperty
in interfaceVirtualFlow<T,
C extends Cell<T>> - See Also:
-
setHorizontalPosition
public void setHorizontalPosition(double hValue) Sets the horizontal scroll bar's value- Specified by:
setHorizontalPosition
in interfaceVirtualFlow<T,
C extends Cell<T>>
-
getOrientation
- Returns:
- the orientation of the VirtualFlow
-
orientationProperty
The orientation property of the VirtualFlow.- See Also:
-
setOrientation
Sets the orientation of the VirtualFlow. -
getOrientationHelper
- Returns:
- the current
OrientationHelper
instance
-
features
-
getVirtualFlow
- Specified by:
getVirtualFlow
in interfaceVirtualFlow<T,
C extends Cell<T>> - Returns:
- the instance of the virtual flow
-