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
PropertiesTypePropertyDescriptionProperty 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, widthProperties inherited from class javafx.scene.Parent
needsLayoutProperties 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
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to createSimpleVirtualFlows.classHelper class to manage extra features of the VirtualFlow. -
Field Summary
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZEFields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSimpleVirtualFlow(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 doublecomputePrefHeight(double width) protected doublecomputePrefWidth(double height) features()getCell(int index) doublegetCells()doublegetHBar()doublegetItems()protected OrientationHelpergetVBar()doubleProperty for the horizontal scroll bar's value.protected voidAdds the container to the children list, callssetupScrollBars().booleanGets the value of the property fitToHeight.booleanGets the value of the property fitToWidth.Property for the items list.protected voidThe orientation property of the VirtualFlow.voidscrollBy(double pixels) Scrolls by the given amount of pixels.voidscrollTo(int index) Scrolls to the given cell index.voidScrolls to the first cell.voidScrolls to the last cell.voidscrollToPixel(double pixel) Scrolls to the given pixel value.voidsetCellFactory(Function<T, C> cellFactory) Sets the function used to build a Cell from an object of type T.voidsetFitToHeight(boolean fitToHeight) Sets the value of the property fitToHeight.voidsetFitToWidth(boolean fitToWidth) Sets the value of the property fitToWidth.voidsetHorizontalPosition(double hValue) Sets the horizontal scroll bar's valuevoidsetHSpeed(double unit, double block) Sets the horizontal scroll bar speeds.voidsetItems(ObservableList<T> items) Replaces the items list with the given one.voidsetOrientation(Orientation orientation) Sets the orientation of the VirtualFlow.voidsetVerticalPosition(double vValue) Sets the vertical scroll bar's valuevoidsetVSpeed(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, widthPropertyMethods inherited from class javafx.scene.Parent
getBaselineOffset, getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBoundsMethods 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, visiblePropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
cellFactoryPropertyin interfaceVirtualFlow<T,C extends Cell<T>> - See Also:
-
fitToWidth
- Specified by:
fitToWidthPropertyin interfaceVirtualFlow<T,C extends Cell<T>> - See Also:
-
fitToHeight
- Specified by:
fitToHeightPropertyin interfaceVirtualFlow<T,C extends Cell<T>> - See Also:
-
verticalPosition
Property for the vertical scroll bar's value.- Specified by:
verticalPositionPropertyin interfaceVirtualFlow<T,C extends Cell<T>> - See Also:
-
horizontalPosition
Property for the horizontal scroll bar's value.- Specified by:
horizontalPositionPropertyin 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:
computePrefWidthin classRegion
-
computePrefHeight
protected double computePrefHeight(double width) - Overrides:
computePrefHeightin classRegion
-
getUserAgentStylesheet
- Overrides:
getUserAgentStylesheetin classRegion
-
layoutChildren
protected void layoutChildren()- Overrides:
layoutChildrenin classParent
-
getItems
-
itemsProperty
Property for the items list.- See Also:
-
setItems
Replaces the items list with the given one. -
getCellFactory
- Specified by:
getCellFactoryin 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:
cellFactoryPropertyin 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:
setCellFactoryin interfaceVirtualFlow<T,C extends Cell<T>>
-
getCellWidth
public double getCellWidth()- Specified by:
getCellWidthin interfaceVirtualFlow<T,C extends Cell<T>> - Returns:
- the width of the cells
-
getCellHeight
public double getCellHeight()- Specified by:
getCellHeightin 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:
isFitToWidthin interfaceVirtualFlow<T,C extends Cell<T>> - Property description:
-
fitToWidthProperty
- Specified by:
fitToWidthPropertyin interfaceVirtualFlow<T,C extends Cell<T>> - See Also:
-
setFitToWidth
public void setFitToWidth(boolean fitToWidth) Sets the value of the property fitToWidth.- Specified by:
setFitToWidthin interfaceVirtualFlow<T,C extends Cell<T>> - Property description:
-
isFitToHeight
public boolean isFitToHeight()Gets the value of the property fitToHeight.- Specified by:
isFitToHeightin interfaceVirtualFlow<T,C extends Cell<T>> - Property description:
-
fitToHeightProperty
- Specified by:
fitToHeightPropertyin interfaceVirtualFlow<T,C extends Cell<T>> - See Also:
-
setFitToHeight
public void setFitToHeight(boolean fitToHeight) Sets the value of the property fitToHeight.- Specified by:
setFitToHeightin interfaceVirtualFlow<T,C extends Cell<T>> - Property description:
-
getVerticalPosition
public double getVerticalPosition()- Specified by:
getVerticalPositionin interfaceVirtualFlow<T,C extends Cell<T>> - Returns:
- the vertical scroll bar's value
-
verticalPositionProperty
Property for the vertical scroll bar's value.- Specified by:
verticalPositionPropertyin interfaceVirtualFlow<T,C extends Cell<T>> - See Also:
-
setVerticalPosition
public void setVerticalPosition(double vValue) Sets the vertical scroll bar's value- Specified by:
setVerticalPositionin interfaceVirtualFlow<T,C extends Cell<T>>
-
getHorizontalPosition
public double getHorizontalPosition()- Specified by:
getHorizontalPositionin interfaceVirtualFlow<T,C extends Cell<T>> - Returns:
- the horizontal scroll bar's value
-
horizontalPositionProperty
Property for the horizontal scroll bar's value.- Specified by:
horizontalPositionPropertyin interfaceVirtualFlow<T,C extends Cell<T>> - See Also:
-
setHorizontalPosition
public void setHorizontalPosition(double hValue) Sets the horizontal scroll bar's value- Specified by:
setHorizontalPositionin 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
OrientationHelperinstance
-
features
-
getVirtualFlow
- Specified by:
getVirtualFlowin interfaceVirtualFlow<T,C extends Cell<T>> - Returns:
- the instance of the virtual flow
-