Class InfiniteCanvas
- All Implemented Interfaces:
javafx.css.Styleable,javafx.event.EventTarget
InfiniteCanvas provides a means to render a portion of a
hypothetically infinite canvas, on which arbitrary contents can be placed.
+----------------+ |content area | | | | +----------------+ | |visible area | | | | | +----------------+ | | +----------------+
The size of the InfiniteCanvas itself determines the visible area,
i.e. it is reflected in its Node.layoutBoundsProperty(). The content area
is determined by the (visible) bounds of the getContentGroup() that
contains the content elements. These bounds can be accessed via the
contentBoundsProperty().
By default, scrollbars are shown when the content area exceeds the visible
area. They allow to navigate the scrollableBoundsProperty(), which
resembles the union of the content area and the visible area. The horizontal
and vertical scroll offsets are controlled by the
horizontalScrollOffsetProperty() and
verticalScrollOffsetProperty(). The appearance of scrollbars can be
controlled with the following properties:
- The
horizontalScrollBarPolicyProperty()determines the horizontalScrollPane.ScrollBarPolicy. - The
verticalScrollBarPolicyProperty()determines the verticalScrollPane.ScrollBarPolicy.
An arbitrary transformation can be applied to the contents that is controlled
by the contentTransformProperty(). It is unrelated to scrolling,
i.e. translating the content does not change the scroll offset.
A background grid is rendered behind the contents per default. It always covers the complete visible area and can be enabled/disabled and customized via a set of properties:
- The
showGridProperty()determines whether or not to show the background grid - The
zoomGridProperty()determines whether or not to zoom the background grid with the contents. - The
gridCellWidthProperty()determines the grid cell width. - The
gridCellHeightProperty()determines the grid cell height.
Internally, an InfiniteCanvas consists of four layers:
+--------------------------------+ |scrollbar group | +--------------------------------+ |overlay group | +--------------------------------+ |scrolled pane (with sub-layers) | +--------------------------------+ |underlay group | +--------------------------------+
- The
getUnderlayGroup()is rendered at the bottom, it is neither affected by thehorizontalScrollOffsetProperty()andverticalScrollOffsetProperty()nor by thecontentTransformProperty(). - The
getScrolledPane()is rendered above thegetUnderlayGroup()and contains sub-layers. ThegetScrolledPane()and its sub-layers are affected by thehorizontalScrollOffsetProperty()andverticalScrollOffsetProperty(). - The
getOverlayGroup()is rendered above thegetScrolledPane(). It is neither affected by thehorizontalScrollOffsetProperty()andverticalScrollOffsetProperty()nor by thecontentTransformProperty(). - The
getScrollBarGroup()is rendered above thegetOverlayGroup(). It contains the scrollbars.
getScrolledPane() internally consists of the following four
sub-layers:
+--------------------------------+ |scrolled overlay group | +--------------------------------+ |content group | +--------------------------------+ |scrolled underlay group | +--------------------------------+ |grid canvas | +--------------------------------+
- The
getGridCanvas()is rendered at the bottom of thegetScrolledPane(). - The
getScrolledUnderlayGroup()is rendered above thegetGridCanvas(). - The
getContentGroup()is rendered above thegetScrolledUnderlayGroup(). It is affected by thecontentTransformProperty(). - The
getScrolledOverlayGroup()is rendered above thegetContentGroup().
-
Property Summary
PropertiesTypePropertyDescriptionjavafx.beans.property.BooleanPropertyReturns theBooleanPropertythat determines if thisInfiniteCanvasdoes clipping, i.e. restricts its visibility to itsNode.layoutBoundsProperty().javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds>Provides the visual bounds of the content group in the local coordinate system of thisInfiniteCanvasas a (read-only) property.javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.transform.Affine>Returns the viewport transform as a (read-only) property.javafx.beans.property.IntegerPropertyReturns the grid cell height as a (writable) property.javafx.beans.property.IntegerPropertyReturns the grid cell width as a (writable) property.javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy>Returns theObjectPropertythat controls theScrollPane.ScrollBarPolicythat decides when to show a horizontal scrollbar.javafx.beans.property.DoublePropertyReturns the horizontal scroll offset as a property.javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds>Returns the bounds of the scrollable area in local coordinates of thisInfiniteCanvasas a (read-only) property.javafx.beans.property.BooleanPropertyReturns theBooleanPropertythat determines if a background grid is shown within thisInfiniteCanvas.javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy>Returns theObjectPropertythat controls theScrollPane.ScrollBarPolicythat decides when to show a vertical scrollbar.javafx.beans.property.DoublePropertyReturns the vertical scroll offset as a property.javafx.beans.property.BooleanPropertyReturns theBooleanPropertythat determines if the background grid is zoomed when the contents are zoomed.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 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default grid cell height.static final intThe default grid cell width.static final javafx.scene.paint.ColorThe defaultColorthat is used to draw grid points.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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidEnables content clipping for thisInfiniteCanvas.javafx.beans.property.BooleanPropertyReturns theBooleanPropertythat determines if thisInfiniteCanvasdoes clipping, i.e. restricts its visibility to itsNode.layoutBoundsProperty().protected double[]Computes the bounds[min-x, min-y, max-x, max-y]surrounding thecontent groupwithin the coordinate system of thisInfiniteCanvas.protected doublecomputeHv(double tx) Converts a horizontal translation distance into the corresponding horizontal scrollbar value.protected double[]Computes and returns the bounds of the scrollable area within thisInfiniteCanvas.protected doublecomputeTx(double hv) Converts a horizontal scrollbar value into the corresponding horizontal translation distance.protected doublecomputeTy(double vv) Converts a vertical scrollbar value into the corresponding vertical translation distance.protected doublecomputeVv(double ty) Converts a vertical translation distance into the corresponding vertical scrollbar value.javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds>Provides the visual bounds of the content group in the local coordinate system of thisInfiniteCanvasas a (read-only) property.javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.transform.Affine>Returns the viewport transform as a (read-only) property.protected javafx.scene.layout.RegionCreates theRegionthat renders the grid (when it is enabled).protected javafx.scene.image.ImageLocate or create anImagethat represents a single grid cell/tile.protected List<? extends javafx.scene.Node>Returns a list containing the top level layers in the visualization of thisInfiniteCanvas.protected javafx.scene.GroupCreates theGroupdesignated for holding the scrollbars and places the scrollbars in it.protected List<? extends javafx.scene.Node>Returns a list containing the scrolled layers in the visualization of thisInfiniteCanvas.voidfitToSize(double zoomMin, double zoomMax) Adjusts thehorizontalScrollOffsetProperty(), theverticalScrollOffsetProperty(), and thecontentTransformProperty(), so that thegetContentGroup()is fully visible within the bounds of thisInfiniteCanvasif possible.javafx.geometry.BoundsReturns the value of thecontentBoundsProperty().javafx.scene.GroupReturns theGroupdesignated for holding the scrolled content.javafx.scene.transform.AffineReturns the transformation that is applied to thecontent group.protected javafx.scene.layout.RegionReturns theRegionthat is used to paint the background grid.doubleReturns the value of thegridCellHeightProperty().doubleReturns the value of thegridCellWidthProperty().javafx.scene.control.ScrollBarReturns the horizontalScrollBar, ornullif the horizontalScrollBarwas not yet created.javafx.scene.control.ScrollPane.ScrollBarPolicyReturns theScrollPane.ScrollBarPolicythat is currently used to decide when to show a horizontal scrollbar.doubleReturns the current horizontal scroll offset.javafx.scene.GroupReturns the overlayGroupthat is rendered above the contents but below the scrollbars.javafx.geometry.BoundsReturns the value of thescrollableBoundsProperty().protected javafx.scene.GroupReturns theGroupdesignated for holding theScrollBars.javafx.scene.GroupReturns the scrolled overlayGroup.protected javafx.scene.layout.PaneReturns thePanewhich is translated when scrolling.javafx.scene.GroupReturns the scrolled underlayGroup.javafx.scene.GroupReturns the underlayGroup.javafx.scene.control.ScrollBarReturns the verticalScrollBar, ornullif the verticalScrollBarwas not yet created.javafx.scene.control.ScrollPane.ScrollBarPolicyReturns theScrollPane.ScrollBarPolicythat is currently used to decide when to show a vertical scrollbar.doubleReturns the current vertical scroll offset.javafx.beans.property.IntegerPropertyReturns the grid cell height as a (writable) property.javafx.beans.property.IntegerPropertyReturns the grid cell width as a (writable) property.protected voidhideGrid()Disables the background grid.javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy>Returns theObjectPropertythat controls theScrollPane.ScrollBarPolicythat decides when to show a horizontal scrollbar.javafx.beans.property.DoublePropertyReturns the horizontal scroll offset as a property.booleanReturns the value of theclipContentProperty().booleanReturns the value of theshowGridProperty().booleanReturns the value of thezoomGridProperty().protected doublelerp(double min, double max, double ratio) Linear interpolation between min and max at the given ratio.protected doublenorm(double min, double max, double value) Normalizes a given value which is in range[min;max]to range[0;1].protected voidregisterFadeInOutTransitions(javafx.scene.Node node) Registers fade in/out transitions for the givenNode.protected voidRegisters listeners on the bounds-in-local property of thegetScrolledPane()and on the bounds-in-parent property of thegetContentGroup()that will callupdateScrollBars()when one of the bounds is changed.protected voidRegisters listeners on thehorizontalScrollBarPolicyProperty()and on theverticalScrollBarPolicyProperty()that will callupdateScrollBars()when one of theScrollPane.ScrollBarPolicys changes.protected voidRegisters listeners on theRegion.widthProperty()and on theRegion.heightProperty()that will callupdateScrollBars()when the size of thisInfiniteCanvaschanges.protected voidRepaints the tile image that depends on the grid cell size only.voidreveal(javafx.scene.Node child) Ensures that the specified childNodeis visible to the user by scrolling to its position.javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds>Returns the bounds of the scrollable area in local coordinates of thisInfiniteCanvasas a (read-only) property.voidsetClipContent(boolean clipContent) Sets the value of theclipContentProperty()to the given value.voidsetContentTransform(javafx.scene.transform.Affine tx) Sets the transformation matrix of theviewport transformto the values specified by the givenAffine.voidsetGridCellHeight(int gridCellHeight) Assigns the given value to thegridCellHeightProperty().voidsetGridCellWidth(int gridCellWidth) Assigns the given value to thegridCellWidthProperty().voidsetHorizontalScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy horizontalScrollBarPolicy) Sets the value of thehorizontalScrollBarPolicyProperty()to the givenScrollPane.ScrollBarPolicy.voidsetHorizontalScrollOffset(double scrollOffsetX) Sets the horizontal scroll offset to the given value.voidsetShowGrid(boolean showGrid) Assigns the given value to theshowGridProperty().voidsetVerticalScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy verticalScrollBarPolicy) Sets the value of theverticalScrollBarPolicyProperty()to the givenScrollPane.ScrollBarPolicy.voidsetVerticalScrollOffset(double scrollOffsetY) Sets the vertical scroll offset to the given value.voidsetZoomGrid(boolean zoomGrid) Assigns the given value to theshowGridProperty().protected voidshowGrid()Enables the background grid.javafx.beans.property.BooleanPropertyReturns theBooleanPropertythat determines if a background grid is shown within thisInfiniteCanvas.protected voidDisables content clipping for thisInfiniteCanvas.protected voidUnregisters the listeners that were previously registered withinregisterUpdateScrollBarsOnBoundsChanges().protected voidDisables zooming of the background grid.protected voidupdateGridTransform(javafx.scene.transform.Affine transform) This method is called when the grid transformation should be updated to match the givenAffine.protected voidUpdates theScrollBars' visibilities, value ranges and value increments based on thecontent boundsand thescrollable bounds.javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy>Returns theObjectPropertythat controls theScrollPane.ScrollBarPolicythat decides when to show a vertical scrollbar.javafx.beans.property.DoublePropertyReturns the vertical scroll offset as a property.protected voidzoomGrid()Enables zooming of the background grid when the contents are zoomed.javafx.beans.property.BooleanPropertyReturns theBooleanPropertythat determines if the background grid is zoomed when the contents are zoomed.Methods inherited from class javafx.scene.layout.Region
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, 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, layoutChildren, 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
-
clipContent
public javafx.beans.property.BooleanProperty clipContentPropertyReturns theBooleanPropertythat determines if thisInfiniteCanvasdoes clipping, i.e. restricts its visibility to itsNode.layoutBoundsProperty().- See Also:
-
contentBounds
public javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds> contentBoundsPropertyProvides the visual bounds of the content group in the local coordinate system of thisInfiniteCanvasas a (read-only) property.- See Also:
-
contentTransform
public javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.transform.Affine> contentTransformPropertyReturns the viewport transform as a (read-only) property. -
gridCellHeight
public javafx.beans.property.IntegerProperty gridCellHeightPropertyReturns the grid cell height as a (writable) property.- See Also:
-
gridCellWidth
public javafx.beans.property.IntegerProperty gridCellWidthPropertyReturns the grid cell width as a (writable) property.- See Also:
-
horizontalScrollBarPolicy
public javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy> horizontalScrollBarPolicyPropertyReturns theObjectPropertythat controls theScrollPane.ScrollBarPolicythat decides when to show a horizontal scrollbar. -
horizontalScrollOffset
public javafx.beans.property.DoubleProperty horizontalScrollOffsetPropertyReturns the horizontal scroll offset as a property. -
scrollableBounds
public javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds> scrollableBoundsPropertyReturns the bounds of the scrollable area in local coordinates of thisInfiniteCanvasas a (read-only) property. The scrollable area corresponds to the visual bounds of the content group, which is expanded to cover at least the area of thisInfiniteCanvas(i.e. the viewport) if necessary. It is thereby also the area that can be navigated via the scroll bars.- See Also:
-
showGrid
public javafx.beans.property.BooleanProperty showGridPropertyReturns theBooleanPropertythat determines if a background grid is shown within thisInfiniteCanvas.- See Also:
-
verticalScrollBarPolicy
public javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy> verticalScrollBarPolicyPropertyReturns theObjectPropertythat controls theScrollPane.ScrollBarPolicythat decides when to show a vertical scrollbar. -
verticalScrollOffset
public javafx.beans.property.DoubleProperty verticalScrollOffsetPropertyReturns the vertical scroll offset as a property. -
zoomGrid
public javafx.beans.property.BooleanProperty zoomGridPropertyReturns theBooleanPropertythat determines if the background grid is zoomed when the contents are zoomed.- See Also:
-
-
Field Details
-
DEFAULT_GRID_POINT_COLOR
public static final javafx.scene.paint.Color DEFAULT_GRID_POINT_COLORThe defaultColorthat is used to draw grid points. -
DEFAULT_GRID_CELL_WIDTH
public static final int DEFAULT_GRID_CELL_WIDTHThe default grid cell width.- See Also:
-
DEFAULT_GRID_CELL_HEIGHT
public static final int DEFAULT_GRID_CELL_HEIGHTThe default grid cell height.- See Also:
-
-
Constructor Details
-
InfiniteCanvas
public InfiniteCanvas()Constructs a newInfiniteCanvas.
-
-
Method Details
-
clipContent
protected void clipContent()Enables content clipping for thisInfiniteCanvas. -
clipContentProperty
public javafx.beans.property.BooleanProperty clipContentProperty()Returns theBooleanPropertythat determines if thisInfiniteCanvasdoes clipping, i.e. restricts its visibility to itsNode.layoutBoundsProperty().- See Also:
-
computeContentBoundsInLocal
protected double[] computeContentBoundsInLocal()Computes the bounds[min-x, min-y, max-x, max-y]surrounding thecontent groupwithin the coordinate system of thisInfiniteCanvas.- Returns:
- The bounds
[min-x, min-y, max-x, max-y]surrounding thecontent groupwithin the coordinate system of thisInfiniteCanvas.
-
computeHv
protected double computeHv(double tx) Converts a horizontal translation distance into the corresponding horizontal scrollbar value.- Parameters:
tx- The horizontal translation distance.- Returns:
- The horizontal scrollbar value corresponding to the given translation.
-
computeScrollableBoundsInLocal
protected double[] computeScrollableBoundsInLocal()Computes and returns the bounds of the scrollable area within thisInfiniteCanvas.- Returns:
- The bounds of the scrollable area, i.e.
[minx, miny, maxx, maxy].
-
computeTx
protected double computeTx(double hv) Converts a horizontal scrollbar value into the corresponding horizontal translation distance.- Parameters:
hv- The horizontal scrollbar value.- Returns:
- The horizontal translation distance corresponding to the given scrollbar value.
-
computeTy
protected double computeTy(double vv) Converts a vertical scrollbar value into the corresponding vertical translation distance.- Parameters:
vv- The vertical scrollbar value.- Returns:
- The vertical translation distance corresponding to the given scrollbar value.
-
computeVv
protected double computeVv(double ty) Converts a vertical translation distance into the corresponding vertical scrollbar value.- Parameters:
ty- The vertical translation distance.- Returns:
- The vertical scrollbar value corresponding to the given translation.
-
contentBoundsProperty
public javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds> contentBoundsProperty()Provides the visual bounds of the content group in the local coordinate system of thisInfiniteCanvasas a (read-only) property.- See Also:
-
contentTransformProperty
public javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.transform.Affine> contentTransformProperty()Returns the viewport transform as a (read-only) property. -
createGrid
protected javafx.scene.layout.Region createGrid()Creates theRegionthat renders the grid (when it is enabled).- Returns:
- The newly created
Regionthat renders the grid.
-
createGridTile
protected javafx.scene.image.Image createGridTile()Locate or create anImagethat represents a single grid cell/tile. TheImage's dimensions is expected to match the grid cell size (width and height).- Returns:
- An
Imagethat represents a single grid cell/tile.
-
createLayers
Returns a list containing the top level layers in the visualization of thisInfiniteCanvas. Per default, the underlay group, the scrolled pane, the overlay group, and the scrollbar group are returned in that order.- Returns:
- A list containing the top level layers in the visualization of
this
InfiniteCanvas.
-
createScrollBarGroup
protected javafx.scene.Group createScrollBarGroup()Creates theGroupdesignated for holding the scrollbars and places the scrollbars in it. Furthermore, event listeners are registered to update the scroll offset upon scrollbar movement.- Returns:
- The
Groupdesignated for holding the scrollbars.
-
createScrolledLayers
Returns a list containing the scrolled layers in the visualization of thisInfiniteCanvas. Per default, the grid canvas, the scrolled underlay group, the content group, and the scrolled overlay group are returned in that order.- Returns:
- A list containing the top level layers in the visualization of
this
InfiniteCanvas.
-
fitToSize
public void fitToSize(double zoomMin, double zoomMax) Adjusts thehorizontalScrollOffsetProperty(), theverticalScrollOffsetProperty(), and thecontentTransformProperty(), so that thegetContentGroup()is fully visible within the bounds of thisInfiniteCanvasif possible. The content will be centered, but the given zoomMin and zoomMax values restrict the zoom factor, so that the content might exceed the canvas, or does not fill it completely.Note, that the
contentTransformProperty()is set to a pure scale transformation by this method.Note, that fit-to-size cannot be performed in all situations. If the content area is 0 or the canvas area is 0, then this method cannot fit the content to the canvas size, and therefore, throws an
IllegalStateException. The following condition can be used to test if fit-to-size can be performed:if (infiniteCanvas.getWidth() > 0 && infiniteCanvas.getHeight() > 0 && infiniteCanvas.getContentBounds().getWidth() > 0 && infiniteCanvas.getContentBounds().getHeight() > 0) { // save to call fit-to-size here infiniteCanvas.fitToSize(); }- Parameters:
zoomMin- The minimum zoom level.zoomMax- The maximum zoom level.- Throws:
IllegalStateException- when the content area is zero or the canvas area is zero.
-
getContentBounds
public javafx.geometry.Bounds getContentBounds()Returns the value of thecontentBoundsProperty().- Returns:
- The value of the
contentBoundsProperty().
-
getContentGroup
public javafx.scene.Group getContentGroup()Returns theGroupdesignated for holding the scrolled content.- Returns:
- The
Groupdesignated for holding the scrolled content.
-
getContentTransform
public javafx.scene.transform.Affine getContentTransform()Returns the transformation that is applied to thecontent group.- Returns:
- The transformation that is applied to the
content group.
-
getGridCanvas
protected javafx.scene.layout.Region getGridCanvas()Returns theRegionthat is used to paint the background grid.- Returns:
- The
Regionthat is used to paint the background grid.
-
getGridCellHeight
public double getGridCellHeight()Returns the value of thegridCellHeightProperty().- Returns:
- The value of the
gridCellHeightProperty().
-
getGridCellWidth
public double getGridCellWidth()Returns the value of thegridCellWidthProperty().- Returns:
- The value of the
gridCellWidthProperty().
-
getHorizontalScrollBar
public javafx.scene.control.ScrollBar getHorizontalScrollBar()Returns the horizontalScrollBar, ornullif the horizontalScrollBarwas not yet created.- Returns:
- The horizontal
ScrollBar.
-
getHorizontalScrollBarPolicy
public javafx.scene.control.ScrollPane.ScrollBarPolicy getHorizontalScrollBarPolicy()Returns theScrollPane.ScrollBarPolicythat is currently used to decide when to show a horizontal scrollbar.- Returns:
- The
ScrollPane.ScrollBarPolicythat is currently used to decide when to show a horizontal scrollbar.
-
getHorizontalScrollOffset
public double getHorizontalScrollOffset()Returns the current horizontal scroll offset.- Returns:
- The current horizontal scroll offset.
-
getOverlayGroup
public javafx.scene.Group getOverlayGroup()Returns the overlayGroupthat is rendered above the contents but below the scrollbars.- Returns:
- The overlay
Groupthat is rendered above the contents but below the scrollbars.
-
getScrollableBounds
public javafx.geometry.Bounds getScrollableBounds()Returns the value of thescrollableBoundsProperty().- Returns:
- The value of the
scrollableBoundsProperty().
-
getScrollBarGroup
protected javafx.scene.Group getScrollBarGroup()Returns theGroupdesignated for holding theScrollBars.- Returns:
- The
Groupdesignated for holding theScrollBars.
-
getScrolledOverlayGroup
public javafx.scene.Group getScrolledOverlayGroup()Returns the scrolled overlayGroup.- Returns:
- The scrolled overlay
Group.
-
getScrolledPane
protected javafx.scene.layout.Pane getScrolledPane()Returns thePanewhich is translated when scrolling. ThisPanecontains thegetContentGroup(), therefore, thegetContentTransform()does not influence the scroll offset.- Returns:
- The
Panethat is translated when scrolling.
-
getScrolledUnderlayGroup
public javafx.scene.Group getScrolledUnderlayGroup()Returns the scrolled underlayGroup.- Returns:
- The scrolled underlay
Group.
-
getUnderlayGroup
public javafx.scene.Group getUnderlayGroup()Returns the underlayGroup.- Returns:
- The underlay
Group.
-
getVerticalScrollBar
public javafx.scene.control.ScrollBar getVerticalScrollBar()Returns the verticalScrollBar, ornullif the verticalScrollBarwas not yet created.- Returns:
- The vertical
ScrollBar.
-
getVerticalScrollBarPolicy
public javafx.scene.control.ScrollPane.ScrollBarPolicy getVerticalScrollBarPolicy()Returns theScrollPane.ScrollBarPolicythat is currently used to decide when to show a vertical scrollbar.- Returns:
- The
ScrollPane.ScrollBarPolicythat is currently used to decide when to show a vertical scrollbar.
-
getVerticalScrollOffset
public double getVerticalScrollOffset()Returns the current vertical scroll offset.- Returns:
- The current vertical scroll offset.
-
gridCellHeightProperty
public javafx.beans.property.IntegerProperty gridCellHeightProperty()Returns the grid cell height as a (writable) property.- See Also:
-
gridCellWidthProperty
public javafx.beans.property.IntegerProperty gridCellWidthProperty()Returns the grid cell width as a (writable) property.- See Also:
-
hideGrid
protected void hideGrid()Disables the background grid. -
horizontalScrollBarPolicyProperty
public javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy> horizontalScrollBarPolicyProperty()Returns theObjectPropertythat controls theScrollPane.ScrollBarPolicythat decides when to show a horizontal scrollbar. -
horizontalScrollOffsetProperty
public javafx.beans.property.DoubleProperty horizontalScrollOffsetProperty()Returns the horizontal scroll offset as a property. -
isClipContent
public boolean isClipContent()Returns the value of theclipContentProperty().- Returns:
- The value of the
clipContentProperty().
-
isShowGrid
public boolean isShowGrid()Returns the value of theshowGridProperty().- Returns:
- The value of the
showGridProperty().
-
isZoomGrid
public boolean isZoomGrid()Returns the value of thezoomGridProperty().- Returns:
- The value of the
zoomGridProperty().
-
lerp
protected double lerp(double min, double max, double ratio) Linear interpolation between min and max at the given ratio. Returns the interpolated value in the interval[min;max].- Parameters:
min- The lower interval bound.max- The upper interval bound.ratio- A value in the interval[0;1].- Returns:
- The interpolated value.
-
norm
protected double norm(double min, double max, double value) Normalizes a given value which is in range[min;max]to range[0;1].- Parameters:
min- The lower bound of the range.max- The upper bound of the range.value- The value in the range.- Returns:
- The normalized value (in range
[0;1]).
-
registerFadeInOutTransitions
protected void registerFadeInOutTransitions(javafx.scene.Node node) Registers fade in/out transitions for the givenNode. The transitions are used when the mouse enters/exits the node.- Parameters:
node- TheNodeto which fade in/out transitions are added upon mouse enter/exit.
-
registerUpdateScrollBarsOnBoundsChanges
protected void registerUpdateScrollBarsOnBoundsChanges()Registers listeners on the bounds-in-local property of thegetScrolledPane()and on the bounds-in-parent property of thegetContentGroup()that will callupdateScrollBars()when one of the bounds is changed. -
registerUpdateScrollBarsOnPolicyChanges
protected void registerUpdateScrollBarsOnPolicyChanges()Registers listeners on thehorizontalScrollBarPolicyProperty()and on theverticalScrollBarPolicyProperty()that will callupdateScrollBars()when one of theScrollPane.ScrollBarPolicys changes. -
registerUpdateScrollBarsOnSizeChanges
protected void registerUpdateScrollBarsOnSizeChanges()Registers listeners on theRegion.widthProperty()and on theRegion.heightProperty()that will callupdateScrollBars()when the size of thisInfiniteCanvaschanges. -
repaintGrid
protected void repaintGrid()Repaints the tile image that depends on the grid cell size only. The tile image is repeated when repainting the grid. -
reveal
public void reveal(javafx.scene.Node child) Ensures that the specified childNodeis 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.
The top and left sides have preference over the bottom and right sides, i.e. when the top side is aligned with the viewport, the bottom side will not be aligned, and when the left side is aligned with the viewport, the right side will not be aligned.
- Parameters:
child- The childNodeto reveal.
-
scrollableBoundsProperty
public javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds> scrollableBoundsProperty()Returns the bounds of the scrollable area in local coordinates of thisInfiniteCanvasas a (read-only) property. The scrollable area corresponds to the visual bounds of the content group, which is expanded to cover at least the area of thisInfiniteCanvas(i.e. the viewport) if necessary. It is thereby also the area that can be navigated via the scroll bars.- See Also:
-
setClipContent
public void setClipContent(boolean clipContent) Sets the value of theclipContentProperty()to the given value.- Parameters:
clipContent- The new value for theclipContentProperty().
-
setContentTransform
public void setContentTransform(javafx.scene.transform.Affine tx) Sets the transformation matrix of theviewport transformto the values specified by the givenAffine.- Parameters:
tx- TheAffinedetermining the newviewport transform.
-
setGridCellHeight
public void setGridCellHeight(int gridCellHeight) Assigns the given value to thegridCellHeightProperty().- Parameters:
gridCellHeight- The grid cell height that is assigned to thegridCellHeightProperty().
-
setGridCellWidth
public void setGridCellWidth(int gridCellWidth) Assigns the given value to thegridCellWidthProperty().- Parameters:
gridCellWidth- The grid cell width that is assigned to thegridCellWidthProperty().
-
setHorizontalScrollBarPolicy
public void setHorizontalScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy horizontalScrollBarPolicy) Sets the value of thehorizontalScrollBarPolicyProperty()to the givenScrollPane.ScrollBarPolicy.- Parameters:
horizontalScrollBarPolicy- The newScrollPane.ScrollBarPolicyfor the horizontal scrollbar.
-
setHorizontalScrollOffset
public void setHorizontalScrollOffset(double scrollOffsetX) Sets the horizontal scroll offset to the given value.- Parameters:
scrollOffsetX- The new horizontal scroll offset.
-
setShowGrid
public void setShowGrid(boolean showGrid) Assigns the given value to theshowGridProperty().- Parameters:
showGrid- The new value that is assigned to theshowGridProperty().
-
setVerticalScrollBarPolicy
public void setVerticalScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy verticalScrollBarPolicy) Sets the value of theverticalScrollBarPolicyProperty()to the givenScrollPane.ScrollBarPolicy.- Parameters:
verticalScrollBarPolicy- The newScrollPane.ScrollBarPolicyfor the vertical scrollbar.
-
setVerticalScrollOffset
public void setVerticalScrollOffset(double scrollOffsetY) Sets the vertical scroll offset to the given value.- Parameters:
scrollOffsetY- The new vertical scroll offset.
-
setZoomGrid
public void setZoomGrid(boolean zoomGrid) Assigns the given value to theshowGridProperty().- Parameters:
zoomGrid- The new value that is assigned to theshowGridProperty().
-
showGrid
protected void showGrid()Enables the background grid. -
showGridProperty
public javafx.beans.property.BooleanProperty showGridProperty()Returns theBooleanPropertythat determines if a background grid is shown within thisInfiniteCanvas.- See Also:
-
unclipContent
protected void unclipContent()Disables content clipping for thisInfiniteCanvas. -
unregisterUpdateScrollBarsOnBoundsChanges
protected void unregisterUpdateScrollBarsOnBoundsChanges()Unregisters the listeners that were previously registered withinregisterUpdateScrollBarsOnBoundsChanges(). -
unzoomGrid
protected void unzoomGrid()Disables zooming of the background grid.- See Also:
-
updateGridTransform
protected void updateGridTransform(javafx.scene.transform.Affine transform) This method is called when the grid transformation should be updated to match the givenAffine. The grid transformation is- Parameters:
transform- The new transformation matrix for the grid canvas.
-
updateScrollBars
protected void updateScrollBars()Updates theScrollBars' visibilities, value ranges and value increments based on thecontent boundsand thescrollable bounds. The update is not done if any of theScrollBars is currently in use. -
verticalScrollBarPolicyProperty
public javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy> verticalScrollBarPolicyProperty()Returns theObjectPropertythat controls theScrollPane.ScrollBarPolicythat decides when to show a vertical scrollbar. -
verticalScrollOffsetProperty
public javafx.beans.property.DoubleProperty verticalScrollOffsetProperty()Returns the vertical scroll offset as a property. -
zoomGrid
protected void zoomGrid()Enables zooming of the background grid when the contents are zoomed. -
zoomGridProperty
public javafx.beans.property.BooleanProperty zoomGridProperty()Returns theBooleanPropertythat determines if the background grid is zoomed when the contents are zoomed.- See Also:
-