public class ScrollPaneEx
extends javafx.scene.layout.Region
ScrollPaneEx
provides a scrollable Pane
in which contents
can be placed. ScrollBar
s are automatically added to the ScrollPaneEx
when its contents exceed the viewport.
On the top level, a ScrollPaneEx consists of a "scrolled pane" and a "scrollbars group". Inside of the scrolled pane, a "contents group" contains all user nodes, which can be scrolled by the ScrollPaneEx. The scrollbars group contains the horizontal and vertical scrollbars. It is rendered above the scrolled pane.
In order to rotate or scale the viewport, you can access a "viewport transformation" which is applied to the contents group. Scrolling is done independently of this viewport transformation, using the translate-x and translate-y properties of the scrolled pane.
The ScrollPaneEx computes two bounds: a) the contents-bounds, and b) the scrollable bounds. The contents-bounds are the bounds of the contents group within the ScrollPaneEx's coordinate system. The scrollable bounds are at least as big as the contents-bounds but also include the viewport, i.e. any empty space that is currently visible.
The ScrollPaneEx provides the scroll position in multiple formats: a) the
values of the scrollbars (depends on scrollable bounds), b) the ratios of the
scrollbars (in range [0;1]
), and c) the translation values of
the scrolled pane. You can use the various compute()
,
lerp()
, and norm()
methods to convert from one
format to the other.
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, heightProperty, insetsProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, opaqueInsetsProperty, paddingProperty, prefHeightProperty, prefWidthProperty, scaleShapeProperty, shapeProperty, snapToPixelProperty, widthProperty
impl_traversalEngineProperty, needsLayoutProperty
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, impl_showMnemonicsProperty, impl_treeVisibleProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParentTransformProperty, localToSceneTransformProperty, managedProperty, mouseTransparentProperty, nodeOrientationProperty, 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, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, visibleProperty
Constructor and Description |
---|
ScrollPaneEx()
Constructs a new
ScrollPaneEx . |
Modifier and Type | Method and Description |
---|---|
double[] |
computeContentBoundsInLocal()
Computes the bounds
[min-x, min-y, max-x, max-y] surrounding
the content group within the coordinate system
of this ScrollPaneEx . |
double |
computeHv(double tx)
Converts a horizontal translation distance into the corresponding
horizontal scrollbar value.
|
double[] |
computeScrollableBoundsInLocal()
Computes and returns the bounds of the scrollable area within this
ScrollPaneEx . |
double |
computeTx(double hv)
Converts a horizontal scrollbar value into the corresponding horizontal
translation distance.
|
double |
computeTy(double vv)
Converts a vertical scrollbar value into the corresponding vertical
translation distance.
|
double |
computeVv(double ty)
Converts a vertical translation distance into the corresponding vertical
scrollbar value.
|
protected javafx.scene.Group |
createContentGroup()
Creates the
Group designated for holding the scrolled content. |
protected javafx.scene.Group |
createScrollbarGroup()
Creates the
Group designated for holding the scrollbars and
places the scrollbars in it. |
protected javafx.scene.layout.Pane |
createScrolledPane()
Creates the
Pane which is translated when scrolling and inserts
the content group into it. |
double |
getBottomExcess(javafx.scene.Node child)
Returns the amount of units the given child
Node exceeds the
bottom side of the viewport. |
javafx.geometry.Bounds |
getBoundsInViewport(javafx.scene.Node child)
Transforms the bounds-in-local of the given
Node into the
coordinate system of this ScrollPaneEx , i.e. the viewport
coordinate system. |
javafx.beans.binding.ObjectBinding<javafx.geometry.Bounds> |
getContentBoundsBinding()
Returns an
ObjectBinding for the Bounds of the
content group within the coordinate system of
this ScrollPaneEx . |
javafx.scene.Group |
getContentGroup()
Returns the
Group designated for holding the scrolled content. |
javafx.scene.control.ScrollBar |
getHorizontalScrollBar()
Returns the horizontal
ScrollBar . |
double |
getLeftExcess(javafx.scene.Node child)
Returns the amount of units the given child
Node exceeds the left
side of the viewport. |
double |
getRightExcess(javafx.scene.Node child)
Returns the amount of units the given child
Node exceeds the
right side of the viewport. |
javafx.beans.binding.ObjectBinding<javafx.geometry.Bounds> |
getScrollableBoundsBinding()
Returns an
ObjectBinding for the Bounds of the scrollable
area within the coordinate system of this ScrollPaneEx . |
javafx.scene.Group |
getScrollbarGroup()
Returns the
Group designated for holding the ScrollBar s. |
javafx.scene.layout.Pane |
getScrolledPane()
Returns the
Pane which is translated when scrolling. |
double |
getScrollOffsetX()
Returns the current horizontal scroll offset.
|
double |
getScrollOffsetY()
Returns the current vertical scroll offset.
|
double |
getTopExcess(javafx.scene.Node child)
Returns the amount of units the given child
Node exceeds the top
side of the viewport. |
javafx.scene.control.ScrollBar |
getVerticalScrollBar()
Returns the vertical
ScrollBar . |
javafx.scene.transform.Affine |
getViewportTransform()
Returns the transformation that is applied to the
content group . |
boolean |
isFullyVisible(javafx.scene.Node child)
Returns
true when the given direct or indirect child
Node is fully visible, i.e. does not exceed the viewport in any
direction. |
boolean |
isVisible(javafx.scene.Node child)
Returns
true when the given direct or indirect child
Node is visible, i.e. does not exceed the viewport in all
directions. |
double |
lerpHvRatio(double hvRatio)
Linear intERPolation (LERP) of the given horizontal ratio (in range
[0;1] ) onto the horizontal scroll offset range. |
double |
lerpVvRatio(double vvRatio)
Linear intERPolation (LERP) of the given vertical ratio (in range
[0;1] ) onto the vertical scroll offset range. |
double |
normHv(double hv)
Normalizes the given horizontal scroll offset to a ratio in the range
[0;1] . |
double |
normVv(double vv)
Normalizes the given vertical scroll offset to a ratio in the range
[0;1] . |
void |
reveal(javafx.scene.Node child)
Ensures that the specified child
Node is visible to the user by
scrolling to its position. |
void |
setScrollOffsetX(double scrollOffsetX)
Sets the horizontal scroll offset to the given value.
|
void |
setScrollOffsetY(double scrollOffsetY)
Sets the vertical scroll offset to the given value.
|
void |
setViewportTransform(javafx.scene.transform.Affine tx)
Sets the transformation matrix of the
viewport transform to the values specified by the given Affine . |
protected void |
updateScrollbars()
Updates the
ScrollBar s' visibilities, value ranges and value
increments based on the content
bounds and the scrollable
bounds . |
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, 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, snapSize, snapSpace, snapToPixelProperty, widthProperty
getBaselineOffset, getChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processCSS, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, layoutChildren, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, 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, 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, hasProperties, hoverProperty, idProperty, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_cssGetFocusTraversableInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, 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, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
public ScrollPaneEx()
ScrollPaneEx
.public double[] computeContentBoundsInLocal()
[min-x, min-y, max-x, max-y]
surrounding
the content group
within the coordinate system
of this ScrollPaneEx
.[min-x, min-y, max-x, max-y]
surrounding
the content group
within the
coordinate system of this ScrollPaneEx
.public double computeHv(double tx)
tx
- The horizontal translation distance.public double[] computeScrollableBoundsInLocal()
ScrollPaneEx
.[minx, miny, maxx, maxy]
.public double computeTx(double hv)
hv
- The horizontal scrollbar value.public double computeTy(double vv)
vv
- The vertical scrollbar value.public double computeVv(double ty)
ty
- The vertical translation distance.protected javafx.scene.Group createContentGroup()
Group
designated for holding the scrolled content.
The viewport transform
is added to the
transforms list of that Group
.Group
designated for holding the scrolled content.protected javafx.scene.Group createScrollbarGroup()
Group
designated for holding the scrollbars and
places the scrollbars in it. Furthermore, event listeners are registered
to update the scroll offset upon scrollbar movement.Group
designated for holding the scrollbars.protected javafx.scene.layout.Pane createScrolledPane()
Pane
which is translated when scrolling and inserts
the content group
into it. Therefore, the
viewport transform
does not influence the
scroll offset.Pane
which is translated when scrolling.public double getBottomExcess(javafx.scene.Node child)
Node
exceeds the
bottom side of the viewport.child
- A direct or indirect child Node
of this
ScrollPaneEx
.Node
exceeds the
bottom side of the viewport.public javafx.geometry.Bounds getBoundsInViewport(javafx.scene.Node child)
Node
into the
coordinate system of this ScrollPaneEx
, i.e. the viewport
coordinate system.child
- The Node
whose bounds-in-local are transformed.Bounds
.public javafx.beans.binding.ObjectBinding<javafx.geometry.Bounds> getContentBoundsBinding()
ObjectBinding
for the Bounds
of the
content group
within the coordinate system of
this ScrollPaneEx
.ObjectBinding
for the Bounds
of the
content group
within the coordinate
system of this ScrollPaneEx
.public javafx.scene.Group getContentGroup()
Group
designated for holding the scrolled content.Group
designated for holding the scrolled content.public javafx.scene.control.ScrollBar getHorizontalScrollBar()
ScrollBar
.ScrollBar
.public double getLeftExcess(javafx.scene.Node child)
Node
exceeds the left
side of the viewport.child
- A direct or indirect child Node
of this
ScrollPaneEx
.Node
exceeds the left
side of the viewport.public double getRightExcess(javafx.scene.Node child)
Node
exceeds the
right side of the viewport.child
- A direct or indirect child Node
of this
ScrollPaneEx
.Node
exceeds the
right side of the viewport.public javafx.beans.binding.ObjectBinding<javafx.geometry.Bounds> getScrollableBoundsBinding()
ObjectBinding
for the Bounds
of the scrollable
area within the coordinate system of this ScrollPaneEx
.ObjectBinding
for the Bounds
of the scrollable
area within the coordinate system of this ScrollPaneEx
.public javafx.scene.Group getScrollbarGroup()
Group
designated for holding the ScrollBar
s.Group
designated for holding the ScrollBar
s.public javafx.scene.layout.Pane getScrolledPane()
Pane
which is translated when scrolling. This
Pane
contains the content group
,
therefore, the viewport transform
does
not influence the scroll offset.Pane
which is translated when scrolling.public double getScrollOffsetX()
public double getScrollOffsetY()
public double getTopExcess(javafx.scene.Node child)
Node
exceeds the top
side of the viewport.child
- A direct or indirect child Node
of this
ScrollPaneEx
.Node
exceeds the top
side of the viewport.public javafx.scene.control.ScrollBar getVerticalScrollBar()
ScrollBar
.ScrollBar
.public javafx.scene.transform.Affine getViewportTransform()
content group
.content group
.public boolean isFullyVisible(javafx.scene.Node child)
true
when the given direct or indirect child
Node
is fully visible, i.e. does not exceed the viewport in any
direction. Otherwise returns false
.child
- A direct or indirect child Node
of this
ScrollPaneEx
.true
when the given child Node
is fully
visible, otherwise false
.public boolean isVisible(javafx.scene.Node child)
true
when the given direct or indirect child
Node
is visible, i.e. does not exceed the viewport in all
directions. Otherwise returns false
.child
- A direct or indirect child Node
of this
ScrollPaneEx
.true
when the given child Node
is fully
visible, otherwise false
.public double lerpHvRatio(double hvRatio)
[0;1]
) onto the horizontal scroll offset range.hvRatio
- The horizontal ratio to lerp (in range [0;1]
).horizontal scrollbar
.public double lerpVvRatio(double vvRatio)
[0;1]
) onto the vertical scroll offset range.vvRatio
- The vertical ratio to lerp (in range [0;1]
).vertical scrollbar
.public double normHv(double hv)
[0;1]
.hv
- The horizontal scroll offset to normalize.[0;1]
.public double normVv(double vv)
[0;1]
.vv
- The vertical scroll offset to normalize.[0;1]
.public void reveal(javafx.scene.Node child)
Node
is visible to the user by
scrolling to its position. The effect and style of the node are taken
into consideration. After revealing a node, it will be fully visible, if
it fits within the current viewport bounds.
When the child node's left side is left to the viewport, it will touch the left border of the viewport after revealing. When the child node's right side is right to the viewport, it will touch the right border of the viewport after revealing. When the child node's top side is above the viewport, it will touch the top border of the viewport after revealing. When the child node's bottom side is below the viewport, it will touch the bottom border of the viewport after revealing.
TODO: When the child node does not fit within the viewport bounds, it is not revealed.
child
- The child Node
to reveal.public void setScrollOffsetX(double scrollOffsetX)
scrollOffsetX
- The new horizontal scroll offset.java.lang.IllegalArgumentException
- when the given horizontal scroll offset is outside of the
value range of the horizontal scrollbar
.public void setScrollOffsetY(double scrollOffsetY)
scrollOffsetY
- The new vertical scroll offset.java.lang.IllegalArgumentException
- when the given vertical scroll offset is outside of the value
range of the vertical
scrollbar
.public void setViewportTransform(javafx.scene.transform.Affine tx)
viewport transform
to the values specified by the given Affine
.tx
- The Affine
determining the new
viewport transform
.protected void updateScrollbars()
ScrollBar
s' visibilities, value ranges and value
increments based on the content
bounds
and the scrollable
bounds
. The update is not done if any of the ScrollBar
s is
currently in use.Copyright (c) 2014 itemis AG and others. All rights reserved.