Class InfiniteCanvas

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
org.eclipse.gef.fx.nodes.InfiniteCanvas
All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget

public class InfiniteCanvas extends javafx.scene.layout.Region
An 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:

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:

Internally, an InfiniteCanvas consists of four layers:

 +--------------------------------+
 |scrollbar group                 |
 +--------------------------------+
 |overlay group                   |
 +--------------------------------+
 |scrolled pane (with sub-layers) |
 +--------------------------------+
 |underlay group                  |
 +--------------------------------+
 
The getScrolledPane() internally consists of the following four sub-layers:
 +--------------------------------+
 |scrolled overlay group          |
 +--------------------------------+
 |content group                   |
 +--------------------------------+
 |scrolled underlay group         |
 +--------------------------------+
 |grid canvas                     |
 +--------------------------------+
 
  • Property Summary

    Properties
    Type
    Property
    Description
    javafx.beans.property.BooleanProperty
    Returns the BooleanProperty that determines if this InfiniteCanvas does clipping, i.e. restricts its visibility to its Node.layoutBoundsProperty().
    javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds>
    Provides the visual bounds of the content group in the local coordinate system of this InfiniteCanvas as a (read-only) property.
    javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.transform.Affine>
    Returns the viewport transform as a (read-only) property.
    javafx.beans.property.IntegerProperty
    Returns the grid cell height as a (writable) property.
    javafx.beans.property.IntegerProperty
    Returns the grid cell width as a (writable) property.
    javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy>
    Returns the ObjectProperty that controls the ScrollPane.ScrollBarPolicy that decides when to show a horizontal scrollbar.
    javafx.beans.property.DoubleProperty
    Returns 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 this InfiniteCanvas as a (read-only) property.
    javafx.beans.property.BooleanProperty
    Returns the BooleanProperty that determines if a background grid is shown within this InfiniteCanvas.
    javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy>
    Returns the ObjectProperty that controls the ScrollPane.ScrollBarPolicy that decides when to show a vertical scrollbar.
    javafx.beans.property.DoubleProperty
    Returns the vertical scroll offset as a property.
    javafx.beans.property.BooleanProperty
    Returns the BooleanProperty that 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, 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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default grid cell height.
    static final int
    The default grid cell width.
    static final javafx.scene.paint.Color
    The default Color that is used to draw grid points.

    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

    Constructors
    Constructor
    Description
    Constructs a new InfiniteCanvas.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Enables content clipping for this InfiniteCanvas.
    javafx.beans.property.BooleanProperty
    Returns the BooleanProperty that determines if this InfiniteCanvas does clipping, i.e. restricts its visibility to its Node.layoutBoundsProperty().
    protected double[]
    Computes the bounds [min-x, min-y, max-x, max-y] surrounding the content group within the coordinate system of this InfiniteCanvas.
    protected double
    computeHv(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 this InfiniteCanvas.
    protected double
    computeTx(double hv)
    Converts a horizontal scrollbar value into the corresponding horizontal translation distance.
    protected double
    computeTy(double vv)
    Converts a vertical scrollbar value into the corresponding vertical translation distance.
    protected double
    computeVv(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 this InfiniteCanvas as 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.Region
    Creates the Region that renders the grid (when it is enabled).
    protected javafx.scene.image.Image
    Locate or create an Image that represents a single grid cell/tile.
    protected List<? extends javafx.scene.Node>
    Returns a list containing the top level layers in the visualization of this InfiniteCanvas.
    protected javafx.scene.Group
    Creates the Group designated 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 this InfiniteCanvas.
    void
    fitToSize(double zoomMin, double zoomMax)
    Adjusts the horizontalScrollOffsetProperty(), the verticalScrollOffsetProperty(), and the contentTransformProperty(), so that the getContentGroup() is fully visible within the bounds of this InfiniteCanvas if possible.
    javafx.geometry.Bounds
    Returns the value of the contentBoundsProperty().
    javafx.scene.Group
    Returns the Group designated for holding the scrolled content.
    javafx.scene.transform.Affine
    Returns the transformation that is applied to the content group.
    protected javafx.scene.layout.Region
    Returns the Region that is used to paint the background grid.
    double
    Returns the value of the gridCellHeightProperty().
    double
    Returns the value of the gridCellWidthProperty().
    javafx.scene.control.ScrollBar
    Returns the horizontal ScrollBar, or null if the horizontal ScrollBar was not yet created.
    javafx.scene.control.ScrollPane.ScrollBarPolicy
    Returns the ScrollPane.ScrollBarPolicy that is currently used to decide when to show a horizontal scrollbar.
    double
    Returns the current horizontal scroll offset.
    javafx.scene.Group
    Returns the overlay Group that is rendered above the contents but below the scrollbars.
    javafx.geometry.Bounds
    Returns the value of the scrollableBoundsProperty().
    protected javafx.scene.Group
    Returns the Group designated for holding the ScrollBars.
    javafx.scene.Group
    Returns the scrolled overlay Group.
    protected javafx.scene.layout.Pane
    Returns the Pane which is translated when scrolling.
    javafx.scene.Group
    Returns the scrolled underlay Group.
    javafx.scene.Group
    Returns the underlay Group.
    javafx.scene.control.ScrollBar
    Returns the vertical ScrollBar, or null if the vertical ScrollBar was not yet created.
    javafx.scene.control.ScrollPane.ScrollBarPolicy
    Returns the ScrollPane.ScrollBarPolicy that is currently used to decide when to show a vertical scrollbar.
    double
    Returns the current vertical scroll offset.
    javafx.beans.property.IntegerProperty
    Returns the grid cell height as a (writable) property.
    javafx.beans.property.IntegerProperty
    Returns the grid cell width as a (writable) property.
    protected void
    Disables the background grid.
    javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy>
    Returns the ObjectProperty that controls the ScrollPane.ScrollBarPolicy that decides when to show a horizontal scrollbar.
    javafx.beans.property.DoubleProperty
    Returns the horizontal scroll offset as a property.
    boolean
    Returns the value of the clipContentProperty().
    boolean
    Returns the value of the showGridProperty().
    boolean
    Returns the value of the zoomGridProperty().
    protected double
    lerp(double min, double max, double ratio)
    Linear interpolation between min and max at the given ratio.
    protected double
    norm(double min, double max, double value)
    Normalizes a given value which is in range [min;max] to range [0;1].
    protected void
    registerFadeInOutTransitions(javafx.scene.Node node)
    Registers fade in/out transitions for the given Node.
    protected void
    Registers listeners on the bounds-in-local property of the getScrolledPane() and on the bounds-in-parent property of the getContentGroup() that will call updateScrollBars() when one of the bounds is changed.
    protected void
    Registers listeners on the horizontalScrollBarPolicyProperty() and on the verticalScrollBarPolicyProperty() that will call updateScrollBars() when one of the ScrollPane.ScrollBarPolicys changes.
    protected void
    Registers listeners on the Region.widthProperty() and on the Region.heightProperty() that will call updateScrollBars() when the size of this InfiniteCanvas changes.
    protected void
    Repaints the tile image that depends on the grid cell size only.
    void
    reveal(javafx.scene.Node child)
    Ensures that the specified child Node is 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 this InfiniteCanvas as a (read-only) property.
    void
    setClipContent(boolean clipContent)
    Sets the value of the clipContentProperty() to the given value.
    void
    setContentTransform(javafx.scene.transform.Affine tx)
    Sets the transformation matrix of the viewport transform to the values specified by the given Affine.
    void
    setGridCellHeight(int gridCellHeight)
    Assigns the given value to the gridCellHeightProperty().
    void
    setGridCellWidth(int gridCellWidth)
    Assigns the given value to the gridCellWidthProperty().
    void
    setHorizontalScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy horizontalScrollBarPolicy)
    Sets the value of the horizontalScrollBarPolicyProperty() to the given ScrollPane.ScrollBarPolicy.
    void
    setHorizontalScrollOffset(double scrollOffsetX)
    Sets the horizontal scroll offset to the given value.
    void
    setShowGrid(boolean showGrid)
    Assigns the given value to the showGridProperty().
    void
    setVerticalScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy verticalScrollBarPolicy)
    Sets the value of the verticalScrollBarPolicyProperty() to the given ScrollPane.ScrollBarPolicy.
    void
    setVerticalScrollOffset(double scrollOffsetY)
    Sets the vertical scroll offset to the given value.
    void
    setZoomGrid(boolean zoomGrid)
    Assigns the given value to the showGridProperty().
    protected void
    Enables the background grid.
    javafx.beans.property.BooleanProperty
    Returns the BooleanProperty that determines if a background grid is shown within this InfiniteCanvas.
    protected void
    Disables content clipping for this InfiniteCanvas.
    protected void
    Unregisters the listeners that were previously registered within registerUpdateScrollBarsOnBoundsChanges().
    protected void
    Disables zooming of the background grid.
    protected void
    updateGridTransform(javafx.scene.transform.Affine transform)
    This method is called when the grid transformation should be updated to match the given Affine.
    protected void
    Updates the ScrollBars' visibilities, value ranges and value increments based on the content bounds and the scrollable bounds.
    javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy>
    Returns the ObjectProperty that controls the ScrollPane.ScrollBarPolicy that decides when to show a vertical scrollbar.
    javafx.beans.property.DoubleProperty
    Returns the vertical scroll offset as a property.
    protected void
    Enables zooming of the background grid when the contents are zoomed.
    javafx.beans.property.BooleanProperty
    Returns the BooleanProperty that 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, widthProperty

    Methods inherited from class javafx.scene.Parent

    getBaselineOffset, getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, layoutChildren, 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

    • clipContent

      public javafx.beans.property.BooleanProperty clipContentProperty
      Returns the BooleanProperty that determines if this InfiniteCanvas does clipping, i.e. restricts its visibility to its Node.layoutBoundsProperty().
      See Also:
    • contentBounds

      public javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds> contentBoundsProperty
      Provides the visual bounds of the content group in the local coordinate system of this InfiniteCanvas as a (read-only) property.
      See Also:
    • contentTransform

      public javafx.beans.property.ReadOnlyObjectProperty<javafx.scene.transform.Affine> contentTransformProperty
      Returns the viewport transform as a (read-only) property.
      See Also:
    • gridCellHeight

      public javafx.beans.property.IntegerProperty gridCellHeightProperty
      Returns the grid cell height as a (writable) property.
      See Also:
    • gridCellWidth

      public javafx.beans.property.IntegerProperty gridCellWidthProperty
      Returns the grid cell width as a (writable) property.
      See Also:
    • horizontalScrollBarPolicy

      public javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy> horizontalScrollBarPolicyProperty
      Returns the ObjectProperty that controls the ScrollPane.ScrollBarPolicy that decides when to show a horizontal scrollbar.
      See Also:
    • horizontalScrollOffset

      public javafx.beans.property.DoubleProperty horizontalScrollOffsetProperty
      Returns the horizontal scroll offset as a property.
      See Also:
    • scrollableBounds

      public javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds> scrollableBoundsProperty
      Returns the bounds of the scrollable area in local coordinates of this InfiniteCanvas as 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 this InfiniteCanvas (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 showGridProperty
      Returns the BooleanProperty that determines if a background grid is shown within this InfiniteCanvas.
      See Also:
    • verticalScrollBarPolicy

      public javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy> verticalScrollBarPolicyProperty
      Returns the ObjectProperty that controls the ScrollPane.ScrollBarPolicy that decides when to show a vertical scrollbar.
      See Also:
    • verticalScrollOffset

      public javafx.beans.property.DoubleProperty verticalScrollOffsetProperty
      Returns the vertical scroll offset as a property.
      See Also:
    • zoomGrid

      public javafx.beans.property.BooleanProperty zoomGridProperty
      Returns the BooleanProperty that 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_COLOR
      The default Color that is used to draw grid points.
    • DEFAULT_GRID_CELL_WIDTH

      public static final int DEFAULT_GRID_CELL_WIDTH
      The default grid cell width.
      See Also:
    • DEFAULT_GRID_CELL_HEIGHT

      public static final int DEFAULT_GRID_CELL_HEIGHT
      The default grid cell height.
      See Also:
  • Constructor Details

    • InfiniteCanvas

      public InfiniteCanvas()
      Constructs a new InfiniteCanvas.
  • Method Details

    • clipContent

      protected void clipContent()
      Enables content clipping for this InfiniteCanvas.
    • clipContentProperty

      public javafx.beans.property.BooleanProperty clipContentProperty()
      Returns the BooleanProperty that determines if this InfiniteCanvas does clipping, i.e. restricts its visibility to its Node.layoutBoundsProperty().
      See Also:
    • computeContentBoundsInLocal

      protected double[] computeContentBoundsInLocal()
      Computes the bounds [min-x, min-y, max-x, max-y] surrounding the content group within the coordinate system of this InfiniteCanvas.
      Returns:
      The bounds [min-x, min-y, max-x, max-y] surrounding the content group within the coordinate system of this InfiniteCanvas.
    • 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 this InfiniteCanvas.
      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 this InfiniteCanvas as 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.
      See Also:
    • createGrid

      protected javafx.scene.layout.Region createGrid()
      Creates the Region that renders the grid (when it is enabled).
      Returns:
      The newly created Region that renders the grid.
    • createGridTile

      protected javafx.scene.image.Image createGridTile()
      Locate or create an Image that represents a single grid cell/tile. The Image's dimensions is expected to match the grid cell size (width and height).
      Returns:
      An Image that represents a single grid cell/tile.
    • createLayers

      protected List<? extends javafx.scene.Node> createLayers()
      Returns a list containing the top level layers in the visualization of this InfiniteCanvas. 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 the 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.
      Returns:
      The Group designated for holding the scrollbars.
    • createScrolledLayers

      protected List<? extends javafx.scene.Node> createScrolledLayers()
      Returns a list containing the scrolled layers in the visualization of this InfiniteCanvas. 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 the horizontalScrollOffsetProperty(), the verticalScrollOffsetProperty(), and the contentTransformProperty(), so that the getContentGroup() is fully visible within the bounds of this InfiniteCanvas if 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 the contentBoundsProperty().
      Returns:
      The value of the contentBoundsProperty().
    • getContentGroup

      public javafx.scene.Group getContentGroup()
      Returns the Group designated for holding the scrolled content.
      Returns:
      The Group designated for holding the scrolled content.
    • getContentTransform

      public javafx.scene.transform.Affine getContentTransform()
      Returns the transformation that is applied to the content group.
      Returns:
      The transformation that is applied to the content group.
    • getGridCanvas

      protected javafx.scene.layout.Region getGridCanvas()
      Returns the Region that is used to paint the background grid.
      Returns:
      The Region that is used to paint the background grid.
    • getGridCellHeight

      public double getGridCellHeight()
      Returns the value of the gridCellHeightProperty().
      Returns:
      The value of the gridCellHeightProperty().
    • getGridCellWidth

      public double getGridCellWidth()
      Returns the value of the gridCellWidthProperty().
      Returns:
      The value of the gridCellWidthProperty().
    • getHorizontalScrollBar

      public javafx.scene.control.ScrollBar getHorizontalScrollBar()
      Returns the horizontal ScrollBar, or null if the horizontal ScrollBar was not yet created.
      Returns:
      The horizontal ScrollBar.
    • getHorizontalScrollBarPolicy

      public javafx.scene.control.ScrollPane.ScrollBarPolicy getHorizontalScrollBarPolicy()
      Returns the ScrollPane.ScrollBarPolicy that is currently used to decide when to show a horizontal scrollbar.
      Returns:
      The ScrollPane.ScrollBarPolicy that 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 overlay Group that is rendered above the contents but below the scrollbars.
      Returns:
      The overlay Group that is rendered above the contents but below the scrollbars.
    • getScrollableBounds

      public javafx.geometry.Bounds getScrollableBounds()
      Returns the value of the scrollableBoundsProperty().
      Returns:
      The value of the scrollableBoundsProperty().
    • getScrollBarGroup

      protected javafx.scene.Group getScrollBarGroup()
      Returns the Group designated for holding the ScrollBars.
      Returns:
      The Group designated for holding the ScrollBars.
    • getScrolledOverlayGroup

      public javafx.scene.Group getScrolledOverlayGroup()
      Returns the scrolled overlay Group.
      Returns:
      The scrolled overlay Group.
    • getScrolledPane

      protected javafx.scene.layout.Pane getScrolledPane()
      Returns the Pane which is translated when scrolling. This Pane contains the getContentGroup(), therefore, the getContentTransform() does not influence the scroll offset.
      Returns:
      The Pane that is translated when scrolling.
    • getScrolledUnderlayGroup

      public javafx.scene.Group getScrolledUnderlayGroup()
      Returns the scrolled underlay Group.
      Returns:
      The scrolled underlay Group.
    • getUnderlayGroup

      public javafx.scene.Group getUnderlayGroup()
      Returns the underlay Group.
      Returns:
      The underlay Group.
    • getVerticalScrollBar

      public javafx.scene.control.ScrollBar getVerticalScrollBar()
      Returns the vertical ScrollBar, or null if the vertical ScrollBar was not yet created.
      Returns:
      The vertical ScrollBar.
    • getVerticalScrollBarPolicy

      public javafx.scene.control.ScrollPane.ScrollBarPolicy getVerticalScrollBarPolicy()
      Returns the ScrollPane.ScrollBarPolicy that is currently used to decide when to show a vertical scrollbar.
      Returns:
      The ScrollPane.ScrollBarPolicy that 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 the ObjectProperty that controls the ScrollPane.ScrollBarPolicy that decides when to show a horizontal scrollbar.
      See Also:
    • horizontalScrollOffsetProperty

      public javafx.beans.property.DoubleProperty horizontalScrollOffsetProperty()
      Returns the horizontal scroll offset as a property.
      See Also:
    • isClipContent

      public boolean isClipContent()
      Returns the value of the clipContentProperty().
      Returns:
      The value of the clipContentProperty().
    • isShowGrid

      public boolean isShowGrid()
      Returns the value of the showGridProperty().
      Returns:
      The value of the showGridProperty().
    • isZoomGrid

      public boolean isZoomGrid()
      Returns the value of the zoomGridProperty().
      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 given Node. The transitions are used when the mouse enters/exits the node.
      Parameters:
      node - The Node to which fade in/out transitions are added upon mouse enter/exit.
    • registerUpdateScrollBarsOnBoundsChanges

      protected void registerUpdateScrollBarsOnBoundsChanges()
      Registers listeners on the bounds-in-local property of the getScrolledPane() and on the bounds-in-parent property of the getContentGroup() that will call updateScrollBars() when one of the bounds is changed.
    • registerUpdateScrollBarsOnPolicyChanges

      protected void registerUpdateScrollBarsOnPolicyChanges()
      Registers listeners on the horizontalScrollBarPolicyProperty() and on the verticalScrollBarPolicyProperty() that will call updateScrollBars() when one of the ScrollPane.ScrollBarPolicys changes.
    • registerUpdateScrollBarsOnSizeChanges

      protected void registerUpdateScrollBarsOnSizeChanges()
      Registers listeners on the Region.widthProperty() and on the Region.heightProperty() that will call updateScrollBars() when the size of this InfiniteCanvas changes.
    • 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 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.

      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 child Node to reveal.
    • scrollableBoundsProperty

      public javafx.beans.property.ReadOnlyObjectProperty<javafx.geometry.Bounds> scrollableBoundsProperty()
      Returns the bounds of the scrollable area in local coordinates of this InfiniteCanvas as 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 this InfiniteCanvas (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 the clipContentProperty() to the given value.
      Parameters:
      clipContent - The new value for the clipContentProperty().
    • setContentTransform

      public void setContentTransform(javafx.scene.transform.Affine tx)
      Sets the transformation matrix of the viewport transform to the values specified by the given Affine.
      Parameters:
      tx - The Affine determining the new viewport transform.
    • setGridCellHeight

      public void setGridCellHeight(int gridCellHeight)
      Assigns the given value to the gridCellHeightProperty().
      Parameters:
      gridCellHeight - The grid cell height that is assigned to the gridCellHeightProperty().
    • setGridCellWidth

      public void setGridCellWidth(int gridCellWidth)
      Assigns the given value to the gridCellWidthProperty().
      Parameters:
      gridCellWidth - The grid cell width that is assigned to the gridCellWidthProperty().
    • setHorizontalScrollBarPolicy

      public void setHorizontalScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy horizontalScrollBarPolicy)
      Sets the value of the horizontalScrollBarPolicyProperty() to the given ScrollPane.ScrollBarPolicy.
      Parameters:
      horizontalScrollBarPolicy - The new ScrollPane.ScrollBarPolicy for 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 the showGridProperty().
      Parameters:
      showGrid - The new value that is assigned to the showGridProperty().
    • setVerticalScrollBarPolicy

      public void setVerticalScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy verticalScrollBarPolicy)
      Sets the value of the verticalScrollBarPolicyProperty() to the given ScrollPane.ScrollBarPolicy.
      Parameters:
      verticalScrollBarPolicy - The new ScrollPane.ScrollBarPolicy for 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 the showGridProperty().
      Parameters:
      zoomGrid - The new value that is assigned to the showGridProperty().
    • showGrid

      protected void showGrid()
      Enables the background grid.
    • showGridProperty

      public javafx.beans.property.BooleanProperty showGridProperty()
      Returns the BooleanProperty that determines if a background grid is shown within this InfiniteCanvas.
      See Also:
    • unclipContent

      protected void unclipContent()
      Disables content clipping for this InfiniteCanvas.
    • unregisterUpdateScrollBarsOnBoundsChanges

      protected void unregisterUpdateScrollBarsOnBoundsChanges()
      Unregisters the listeners that were previously registered within registerUpdateScrollBarsOnBoundsChanges().
    • 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 given Affine. The grid transformation is
      Parameters:
      transform - The new transformation matrix for the grid canvas.
    • updateScrollBars

      protected void updateScrollBars()
      Updates the ScrollBars' visibilities, value ranges and value increments based on the content bounds and the scrollable bounds. The update is not done if any of the ScrollBars is currently in use.
    • verticalScrollBarPolicyProperty

      public javafx.beans.property.ObjectProperty<javafx.scene.control.ScrollPane.ScrollBarPolicy> verticalScrollBarPolicyProperty()
      Returns the ObjectProperty that controls the ScrollPane.ScrollBarPolicy that decides when to show a vertical scrollbar.
      See Also:
    • verticalScrollOffsetProperty

      public javafx.beans.property.DoubleProperty verticalScrollOffsetProperty()
      Returns the vertical scroll offset as a property.
      See Also:
    • zoomGrid

      protected void zoomGrid()
      Enables zooming of the background grid when the contents are zoomed.
    • zoomGridProperty

      public javafx.beans.property.BooleanProperty zoomGridProperty()
      Returns the BooleanProperty that determines if the background grid is zoomed when the contents are zoomed.
      See Also: