public class SnapshotView
extends javafx.scene.control.Control
SnapshotView is a control which allows the user to select an area of a node in the typical manner used by
picture editors and crate snapshots of the selection.
While holding the left mouse key down, a rectangular selection can be drawn. This selection can be moved, resized in eight cardinal directions and removed. Additionally, the selection's ratio can be fixed in which case the user's resizing will be limited such that the ratio is always upheld.
The area where the selection is possible is either this entire control or limited to the displayed node.

ImageView controlsFxView = new ImageView(
"http://cache.fxexperience.com/wp-content/uploads/2013/05/ControlsFX.png");
SnapshotView snapshotView = new SnapshotView(controlsFxView);
snapshotView.setSelection(33, 50, 100, 100);
snapshotView.setFixedSelectionRatio(1); // (this is actually the default value)
snapshotView.setSelectionRatioFixed(true);
node property.
selection property
hasSelection property indicates whether a selection exists
selectionActive property indicates whether the current selection is active
(it is only displayed if it is); by default this property is updated by this control which is determined by the
selectionActivityManaged property
selectionChanging property
selectionAreaBoundary property
selectionMouseTransparent property the control can be made
mouse transparent so the user can interact with the displayed node
selectionRatioFixed and the fixedSelectionRatio properties
selectionAreaFill property for the selected area's paint
selectionBorderPaint property for the selection border's paint
selectionBorderWidth property for the selection border's width
unselectedAreaFill property for the area outside of the selection
unselectedAreaBoundary property which defined what the unselected area
covers
| Type | Property and Description |
|---|---|
javafx.beans.property.DoubleProperty |
fixedSelectionRatio
The value to which the selection ratio is fixed.
|
javafx.beans.property.ReadOnlyBooleanProperty |
hasSelection
Indicates whether there currently is a selection.
|
javafx.beans.property.ObjectProperty<javafx.scene.Node> |
node
The
Node which will be displayed in the center of this control. |
javafx.beans.property.BooleanProperty |
selectionActive
Indicates whether the selection is currently active.
|
javafx.beans.property.BooleanProperty |
selectionActivityManaged
Indicates whether the value of the
selectionActive property is managed by this
control. |
javafx.beans.property.ObjectProperty<SnapshotView.Boundary> |
selectionAreaBoundary
Indicates which
SnapshotView.Boundary is set for the area the user can select. |
javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> |
selectionAreaFill
Determines the visualization of the selected area.
|
javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> |
selectionBorderPaint
Determines the visualization of the selection's border.
|
javafx.beans.property.DoubleProperty |
selectionBorderWidth
Determines the width of the selection's border.
|
javafx.beans.property.ReadOnlyBooleanProperty |
selectionChanging
Indicates whether the
selection is currently changing due to user interaction with
the control. |
javafx.beans.property.BooleanProperty |
selectionMouseTransparent
Indicates whether the overlay which displays the selection is mouse transparent.
|
javafx.beans.property.ObjectProperty<javafx.geometry.Rectangle2D> |
selection
The current selection as a
Rectangle2D. |
javafx.beans.property.BooleanProperty |
selectionRatioFixed
Indicates whether the ratio of the
selection is fixed. |
javafx.beans.property.ObjectProperty<SnapshotView.Boundary> |
unselectedAreaBoundary
Indicates which
SnapshotView.Boundary is set for the visualization of the unselected area (i.e. |
javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> |
unselectedAreaFill
Determines the visualization of the area outside of the selection.
|
contextMenu, skinClassName, skin, tooltipbackground, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthaccessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, impl_showMnemonics, impl_treeVisible, 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, visible| Modifier and Type | Class and Description |
|---|---|
static class |
SnapshotView.Boundary
The
selectionArea, in which the user can create a selection,
and the unselectedArea, in which the unselected area is
visualized, are limited to a certain area of the control. |
| Modifier and Type | Field and Description |
|---|---|
static double |
MAX_SELECTION_RATIO_DIVERGENCE
The maximal divergence between a selection's ratio and the
fixedselectionRatio for the selection to still have the correct ratio (see hasCorrectRatio). |
static java.lang.String |
SELECTION_CHANGING_PROPERTY_KEY
The key of the
property which is used to update selectionChanging. |
| Constructor and Description |
|---|
SnapshotView()
Creates a new SnapshotView.
|
SnapshotView(javafx.scene.Node node)
Creates a new SnapshotView using the specified node.
|
| Modifier and Type | Method and Description |
|---|---|
protected javafx.scene.control.Skin<?> |
createDefaultSkin() |
javafx.scene.image.WritableImage |
createSnapshot()
Creates a snapshot of the selected area of the node.
|
javafx.scene.image.WritableImage |
createSnapshot(javafx.scene.SnapshotParameters parameters)
Creates a snapshot of the node with the specified parameters.
|
javafx.beans.property.DoubleProperty |
fixedSelectionRatioProperty()
The value to which the selection ratio is fixed.
|
static java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,?>> |
getClassCssMetaData() |
java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,?>> |
getControlCssMetaData() |
double |
getFixedSelectionRatio() |
javafx.scene.Node |
getNode() |
javafx.geometry.Rectangle2D |
getSelection() |
SnapshotView.Boundary |
getSelectionAreaBoundary() |
javafx.scene.paint.Paint |
getSelectionAreaFill() |
javafx.scene.paint.Paint |
getSelectionBorderPaint() |
double |
getSelectionBorderWidth() |
SnapshotView.Boundary |
getUnselectedAreaBoundary() |
javafx.scene.paint.Paint |
getUnselectedAreaFill() |
java.lang.String |
getUserAgentStylesheet() |
protected java.lang.String |
getUserAgentStylesheet(java.lang.Class<?> clazz,
java.lang.String fileName)
A helper method that ensures that the resource based lookup of the user
agent stylesheet only happens once.
|
boolean |
hasSelection() |
javafx.beans.property.ReadOnlyBooleanProperty |
hasSelectionProperty()
Indicates whether there currently is a selection.
|
boolean |
isSelectionActive() |
boolean |
isSelectionActivityManaged() |
boolean |
isSelectionChanging() |
boolean |
isSelectionMouseTransparent() |
boolean |
isSelectionRatioFixed() |
javafx.beans.property.ObjectProperty<javafx.scene.Node> |
nodeProperty()
The
Node which will be displayed in the center of this control. |
javafx.beans.property.BooleanProperty |
selectionActiveProperty()
Indicates whether the selection is currently active.
|
javafx.beans.property.BooleanProperty |
selectionActivityManagedProperty()
Indicates whether the value of the
selectionActive property is managed by this
control. |
javafx.beans.property.ObjectProperty<SnapshotView.Boundary> |
selectionAreaBoundaryProperty()
Indicates which
SnapshotView.Boundary is set for the area the user can select. |
javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> |
selectionAreaFillProperty()
Determines the visualization of the selected area.
|
javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> |
selectionBorderPaintProperty()
Determines the visualization of the selection's border.
|
javafx.beans.property.DoubleProperty |
selectionBorderWidthProperty()
Determines the width of the selection's border.
|
javafx.beans.property.ReadOnlyBooleanProperty |
selectionChangingProperty()
Indicates whether the
selection is currently changing due to user interaction with
the control. |
javafx.beans.property.BooleanProperty |
selectionMouseTransparentProperty()
Indicates whether the overlay which displays the selection is mouse transparent.
|
javafx.beans.property.ObjectProperty<javafx.geometry.Rectangle2D> |
selectionProperty()
The current selection as a
Rectangle2D. |
javafx.beans.property.BooleanProperty |
selectionRatioFixedProperty()
Indicates whether the ratio of the
selection is fixed. |
void |
setFixedSelectionRatio(double fixedSelectionRatio) |
void |
setNode(javafx.scene.Node node) |
void |
setSelection(double upperLeftX,
double upperLeftY,
double width,
double height)
Creates a new
Rectangle2D from the specified arguments and sets it as the new
selection. |
void |
setSelection(javafx.geometry.Rectangle2D selection) |
void |
setSelectionActive(boolean selectionActive) |
void |
setSelectionActivityManaged(boolean selectionActivityManaged) |
void |
setSelectionAreaBoundary(SnapshotView.Boundary selectionAreaBoundary) |
void |
setSelectionAreaFill(javafx.scene.paint.Paint selectionAreaFill) |
void |
setSelectionBorderPaint(javafx.scene.paint.Paint selectionBorderPaint) |
void |
setSelectionBorderWidth(double selectionBorderWidth) |
void |
setSelectionMouseTransparent(boolean selectionMouseTransparent) |
void |
setSelectionRatioFixed(boolean selectionRatioFixed) |
void |
setUnselectedAreaBoundary(SnapshotView.Boundary unselectedAreaBoundary) |
void |
setUnselectedAreaFill(javafx.scene.paint.Paint unselectedAreaFill) |
javafx.geometry.Rectangle2D |
transformSelectionToNodeCoordinates()
Transforms the
selection to node coordinates by calling
transformToNodeCoordinates. |
javafx.geometry.Rectangle2D |
transformToNodeCoordinates(javafx.geometry.Rectangle2D area)
Transforms the specified area's coordinates to coordinates relative to the node.
|
javafx.beans.property.ObjectProperty<SnapshotView.Boundary> |
unselectedAreaBoundaryProperty()
Indicates which
SnapshotView.Boundary is set for the visualization of the unselected area (i.e. |
javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> |
unselectedAreaFillProperty()
Determines the visualization of the area outside of the selection.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getCssMetaData, getSkin, getTooltip, impl_cssGetFocusTraversableInitialValue, impl_processCSS, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipPropertybackgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, insetsProperty, isCacheShape, isCenterShape, 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, widthPropertygetChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBoundsaccessibleHelpProperty, 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, 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_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, visiblePropertypublic final javafx.beans.property.ObjectProperty<javafx.scene.Node> nodeProperty
Node which will be displayed in the center of this control.
The node's boundsInParent show its relative position inside this control.
Since the selection property also uses this control as its reference coordinate
system, the bounds can be used to compute which area of the node is selected.
If this control or the node behaves strangely when resized, try embedding the original node in a Pane and
setting the pane here.
public final javafx.beans.property.ObjectProperty<javafx.geometry.Rectangle2D> selectionProperty
Rectangle2D. As such an instance is immutable a new one must be set to chane
the selection.
The rectangle's coordinates are interpreted relative to this control. The top left corner is the origin (0, 0)
and the lower right corner is (width, height). It is
guaranteed that the selection always lies within these bounds. If the control is resized, so is the selection. If
a selection which violates these bounds is set, an IllegalArgumentException is thrown.
The same is true if the selectionAreaBoundary is set to NODE but
with the stricter condition that the selection must lie within the node's
boundsInParent.
If the selection ratio is fixed, any new selection must have the
fixedSelectionRatio. Otherwise, an IllegalArgumentException is
thrown.
An IllegalArgumentException is also thrown if not all of the selection's values (e.g. width and height)
are finite.
The selection might be null or Rectangle2D.EMPTY in which case no selection is displayed and
hasSelection is false.
hasSelectionProperty()public final javafx.beans.property.ReadOnlyBooleanProperty hasSelectionProperty
false if the selection property holds null or Rectangle2D.EMPTY .public final javafx.beans.property.BooleanProperty selectionActiveProperty
See selectionActivityManaged for documentation on how this property
might be changed by this control.
public final javafx.beans.property.ReadOnlyBooleanProperty selectionChangingProperty
selection is currently changing due to user interaction with
the control. It will be set to true when changing the selection begins and set to false when it
ends.
If a selection is set by the code using this control (e.g. by calling setSelection) this property does not change its value.
public final javafx.beans.property.BooleanProperty selectionRatioFixedProperty
selection is fixed.
By default this property is false and the user interacting with this control can make arbitrary
selections with any ratio of width to height. If it is true, the user is limited to making selections
with the ratio defined by the fixedSelectionRatio property. If the ratio
is fixed and a selection with a different ratio is set, an IllegalArgumentException is thrown.
If a selection exists and this property is set to true, the selection is immediately resized to the
currently set ratio.
falsepublic final javafx.beans.property.DoubleProperty fixedSelectionRatioProperty
width / height and its value
must be strictly positive.
If selectionRatioFixed is true, this ratio will be upheld by all
changes made by user interaction with this control. If the ratio is fixed and a selection is set by code (e.g. by
calling setSelection), this ratio is checked and if violated an
IllegalArgumentException is thrown.
If a selection exists and selectionRatioFixed is set to true, the selection is immediately
resized to this ratio. Similarly, if a selection exists and its ratio is fixed, setting a new value resizes the
selection to the new ratio.
public final javafx.beans.property.ObjectProperty<SnapshotView.Boundary> selectionAreaBoundaryProperty
SnapshotView.Boundary is set for the area the user can select.
By default the user can select any area of the control. If this should be limited to the area over the displayed
node instead, this property can be set to NODE. If the value is changed from
CONTROL to NODE a possibly existing selection is resized accordingly.
If the boundary is set to NODE, this is also respected when a new selection
is set. This means the condition for the new selection's coordinates is made stricter and setting a selection out
of the node's bounds (instead of only out of the control's bounds) throws an IllegalArgumentException.
Note that this does not change the reference coordinate system! The selection's coordinates are still
interpreted relative to the node's boundsInParent.
CONTROLSnapshotView.Boundary for the area the user can selectpublic final javafx.beans.property.BooleanProperty selectionActivityManagedProperty
selectionActive property is managed by this
control.
If this property is set to true (which is the default) this control will update the
selectionActive property immediately after a new selection is set: if the new selection is null
or Rectangle2D.EMPTY, it will be set to false; otherwise to true.
If this property is false this control will never change selectionActive's value. In this case it
must be managed by the using code but it is possible to unidirectionally bind it to another property without this
control interfering.
trueselectionActive
property is managed by this controlpublic final javafx.beans.property.BooleanProperty selectionMouseTransparentProperty
By default all mouse events are captured by this control and used to interact with the selection. If this
property is set to true, this behavior changes and the user is able to interact with the displayed
node.
falsepublic final javafx.beans.property.ObjectProperty<SnapshotView.Boundary> unselectedAreaBoundaryProperty
SnapshotView.Boundary is set for the visualization of the unselected area (i.e. the area outside of
the selection rectangle).
If it is set to CONTROL (which is the default), the unselected area covers the whole
control.
If it is set to NODE, the area only covers the displayed node. In
most cases this only makes sense if the selectionAreaBoundary is also
set to NODE.
SnapshotView.Boundary.CONTROLSnapshotView.Boundary of the unselected areapublic final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> selectionBorderPaintProperty
Color.WHITESMOKEPaint of the selection borderselectionBorderWidthProperty()public final javafx.beans.property.DoubleProperty selectionBorderWidthProperty
selectionBorderPaintProperty(),
Shape.strokeWidthProperty()public final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> selectionAreaFillProperty
Color.TRANSPARENTPaint of the selected areapublic final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> unselectedAreaFillProperty
black with opacity 0.5Paint of the area outside of the selectionpublic static final double MAX_SELECTION_RATIO_DIVERGENCE
fixedselectionRatio for the selection to still have the correct ratio (see hasCorrectRatio).
The divergence is expressed relative to the fixedselectionRatio.
public static final java.lang.String SELECTION_CHANGING_PROPERTY_KEY
property which is used to update selectionChanging.public SnapshotView()
public SnapshotView(javafx.scene.Node node)
node - the node to show after constructionpublic javafx.geometry.Rectangle2D transformSelectionToNodeCoordinates()
selection to node coordinates by calling
transformToNodeCoordinates.Rectangle2D which expresses the selection in the node's coordinatesjava.lang.IllegalStateException - if node is null or hasSelection is
falsetransformToNodeCoordinates(Rectangle2D)public javafx.geometry.Rectangle2D transformToNodeCoordinates(javafx.geometry.Rectangle2D area)
throws java.lang.IllegalStateException
area - the Rectangle2D which will be transformed (must not be null); its coordinates will be
interpreted relative to the control (like the selection)Rectangle2D with the same width and height as the specified area but with coordinates
which are relative to the current nodejava.lang.IllegalStateException - if node is nullpublic javafx.scene.image.WritableImage createSnapshot()
throws java.lang.IllegalStateException
WritableImage that holds the rendered selectionjava.lang.IllegalStateException - if node is null or hasSelection is
falseNode.snapshot(javafx.scene.SnapshotParameters, javafx.scene.image.WritableImage)public javafx.scene.image.WritableImage createSnapshot(javafx.scene.SnapshotParameters parameters)
throws java.lang.IllegalStateException
parameters - the SnapshotParameters used for the snapshot (must not be null); the viewport will be
interpreted relative to this control (like the selection)WritableImage that holds the rendered viewportjava.lang.IllegalStateException - if node is nullNode.snapshot(javafx.scene.SnapshotParameters, javafx.scene.image.WritableImage)public java.lang.String getUserAgentStylesheet()
getUserAgentStylesheet in class javafx.scene.layout.Regionpublic static java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,?>> getClassCssMetaData()
CssMetaData associated with this class, which includes the CssMetaData of its super
classespublic java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,?>> getControlCssMetaData()
getControlCssMetaData in class javafx.scene.control.Controlprotected javafx.scene.control.Skin<?> createDefaultSkin()
createDefaultSkin in class javafx.scene.control.Controlpublic final javafx.beans.property.ObjectProperty<javafx.scene.Node> nodeProperty()
Node which will be displayed in the center of this control.
The node's boundsInParent show its relative position inside this control.
Since the selection property also uses this control as its reference coordinate
system, the bounds can be used to compute which area of the node is selected.
If this control or the node behaves strangely when resized, try embedding the original node in a Pane and
setting the pane here.
public final javafx.scene.Node getNode()
nodeProperty()public final void setNode(javafx.scene.Node node)
node - the node to displaynodeProperty()public final javafx.beans.property.ObjectProperty<javafx.geometry.Rectangle2D> selectionProperty()
Rectangle2D. As such an instance is immutable a new one must be set to chane
the selection.
The rectangle's coordinates are interpreted relative to this control. The top left corner is the origin (0, 0)
and the lower right corner is (width, height). It is
guaranteed that the selection always lies within these bounds. If the control is resized, so is the selection. If
a selection which violates these bounds is set, an IllegalArgumentException is thrown.
The same is true if the selectionAreaBoundary is set to NODE but
with the stricter condition that the selection must lie within the node's
boundsInParent.
If the selection ratio is fixed, any new selection must have the
fixedSelectionRatio. Otherwise, an IllegalArgumentException is
thrown.
An IllegalArgumentException is also thrown if not all of the selection's values (e.g. width and height)
are finite.
The selection might be null or Rectangle2D.EMPTY in which case no selection is displayed and
hasSelection is false.
hasSelectionProperty()public final javafx.geometry.Rectangle2D getSelection()
selectionProperty()public final void setSelection(javafx.geometry.Rectangle2D selection)
selection - the new selectionjava.lang.IllegalArgumentException - if the selection is out of the bounds defined by the selectionAreaBoundary or the selection ratio is fixed and the
new selection does not have the fixedSelectionRatio.selectionProperty()public final void setSelection(double upperLeftX,
double upperLeftY,
double width,
double height)
Rectangle2D from the specified arguments and sets it as the new
selection. It will have (upperLeftX, upperLeftY) as its upper left
point and span width to the right and height down.upperLeftX - the x coordinate of the selection's upper left pointupperLeftY - the y coordinate of the selection's upper left pointwidth - the selection's widthheight - the selection's heightjava.lang.IllegalArgumentException - if the selection is out of the bounds defined by the selectionAreaBoundary or the selection ratio is fixed and the
new selection does not have the fixedSelectionRatio.selectionProperty()public final javafx.beans.property.ReadOnlyBooleanProperty hasSelectionProperty()
false if the selection property holds null or Rectangle2D.EMPTY .public final boolean hasSelection()
hasSelectionProperty()public final javafx.beans.property.BooleanProperty selectionActiveProperty()
See selectionActivityManaged for documentation on how this property
might be changed by this control.
public final boolean isSelectionActive()
selectionActiveProperty()public final void setSelectionActive(boolean selectionActive)
selectionActive - the new selection active statusselectionActiveProperty()public final javafx.beans.property.ReadOnlyBooleanProperty selectionChangingProperty()
selection is currently changing due to user interaction with
the control. It will be set to true when changing the selection begins and set to false when it
ends.
If a selection is set by the code using this control (e.g. by calling setSelection) this property does not change its value.
public final boolean isSelectionChanging()
selectionChangingProperty()public final javafx.beans.property.BooleanProperty selectionRatioFixedProperty()
selection is fixed.
By default this property is false and the user interacting with this control can make arbitrary
selections with any ratio of width to height. If it is true, the user is limited to making selections
with the ratio defined by the fixedSelectionRatio property. If the ratio
is fixed and a selection with a different ratio is set, an IllegalArgumentException is thrown.
If a selection exists and this property is set to true, the selection is immediately resized to the
currently set ratio.
falsepublic final boolean isSelectionRatioFixed()
selectionRatioFixedProperty()public final void setSelectionRatioFixed(boolean selectionRatioFixed)
selectionRatioFixed - whether the selection ratio will be fixedselectionRatioFixedProperty()public final javafx.beans.property.DoubleProperty fixedSelectionRatioProperty()
width / height and its value
must be strictly positive.
If selectionRatioFixed is true, this ratio will be upheld by all
changes made by user interaction with this control. If the ratio is fixed and a selection is set by code (e.g. by
calling setSelection), this ratio is checked and if violated an
IllegalArgumentException is thrown.
If a selection exists and selectionRatioFixed is set to true, the selection is immediately
resized to this ratio. Similarly, if a selection exists and its ratio is fixed, setting a new value resizes the
selection to the new ratio.
public final double getFixedSelectionRatio()
fixedSelectionRatioProperty()public final void setFixedSelectionRatio(double fixedSelectionRatio)
fixedSelectionRatio - the fixed selection ratio to setjava.lang.IllegalArgumentException - if fixedSelectionRatio is not strictly positivefixedSelectionRatioProperty()public final javafx.beans.property.ObjectProperty<SnapshotView.Boundary> selectionAreaBoundaryProperty()
SnapshotView.Boundary is set for the area the user can select.
By default the user can select any area of the control. If this should be limited to the area over the displayed
node instead, this property can be set to NODE. If the value is changed from
CONTROL to NODE a possibly existing selection is resized accordingly.
If the boundary is set to NODE, this is also respected when a new selection
is set. This means the condition for the new selection's coordinates is made stricter and setting a selection out
of the node's bounds (instead of only out of the control's bounds) throws an IllegalArgumentException.
Note that this does not change the reference coordinate system! The selection's coordinates are still
interpreted relative to the node's boundsInParent.
CONTROLSnapshotView.Boundary for the area the user can selectpublic final SnapshotView.Boundary getSelectionAreaBoundary()
SnapshotView.Boundary for the area the user can selectpublic final void setSelectionAreaBoundary(SnapshotView.Boundary selectionAreaBoundary)
selectionAreaBoundary - the new SnapshotView.Boundary for the area the user can selectpublic final javafx.beans.property.BooleanProperty selectionActivityManagedProperty()
selectionActive property is managed by this
control.
If this property is set to true (which is the default) this control will update the
selectionActive property immediately after a new selection is set: if the new selection is null
or Rectangle2D.EMPTY, it will be set to false; otherwise to true.
If this property is false this control will never change selectionActive's value. In this case it
must be managed by the using code but it is possible to unidirectionally bind it to another property without this
control interfering.
trueselectionActive
property is managed by this controlpublic final boolean isSelectionActivityManaged()
selectionActivityManagedProperty()public final void setSelectionActivityManaged(boolean selectionActivityManaged)
selectionActivityManaged - whether the selection activity will be managed by this controlselectionActivityManagedProperty()public final javafx.beans.property.BooleanProperty selectionMouseTransparentProperty()
By default all mouse events are captured by this control and used to interact with the selection. If this
property is set to true, this behavior changes and the user is able to interact with the displayed
node.
falsepublic final boolean isSelectionMouseTransparent()
selectionMouseTransparentProperty()public final void setSelectionMouseTransparent(boolean selectionMouseTransparent)
selectionMouseTransparent - whether the selection will be mouse transparentselectionMouseTransparentProperty()public final javafx.beans.property.ObjectProperty<SnapshotView.Boundary> unselectedAreaBoundaryProperty()
SnapshotView.Boundary is set for the visualization of the unselected area (i.e. the area outside of
the selection rectangle).
If it is set to CONTROL (which is the default), the unselected area covers the whole
control.
If it is set to NODE, the area only covers the displayed node. In
most cases this only makes sense if the selectionAreaBoundary is also
set to NODE.
SnapshotView.Boundary.CONTROLSnapshotView.Boundary of the unselected areapublic final SnapshotView.Boundary getUnselectedAreaBoundary()
SnapshotView.Boundary for the unselected areaunselectedAreaBoundaryProperty()public final void setUnselectedAreaBoundary(SnapshotView.Boundary unselectedAreaBoundary)
unselectedAreaBoundary - the new SnapshotView.Boundary for the unselected areaunselectedAreaBoundaryProperty()public final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> selectionBorderPaintProperty()
Color.WHITESMOKEPaint of the selection borderselectionBorderWidthProperty()public final javafx.scene.paint.Paint getSelectionBorderPaint()
Paint of the selection borderselectionBorderPaintProperty()public final void setSelectionBorderPaint(javafx.scene.paint.Paint selectionBorderPaint)
selectionBorderPaint - the new Paint of the selection borderselectionBorderPaintProperty()public final javafx.beans.property.DoubleProperty selectionBorderWidthProperty()
selectionBorderPaintProperty(),
Shape.strokeWidthProperty()public final double getSelectionBorderWidth()
selectionBorderWidthProperty()public final void setSelectionBorderWidth(double selectionBorderWidth)
selectionBorderWidth - the selection border width to setselectionBorderWidthProperty()public final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> selectionAreaFillProperty()
Color.TRANSPARENTPaint of the selected areapublic final javafx.scene.paint.Paint getSelectionAreaFill()
Paint of the selected areaselectionAreaFillProperty()public final void setSelectionAreaFill(javafx.scene.paint.Paint selectionAreaFill)
selectionAreaFill - the new Paint of the selected areaselectionAreaFillProperty()public final javafx.beans.property.ObjectProperty<javafx.scene.paint.Paint> unselectedAreaFillProperty()
black with opacity 0.5Paint of the area outside of the selectionpublic final javafx.scene.paint.Paint getUnselectedAreaFill()
Paint of the area outside of the selectionunselectedAreaFillProperty()public final void setUnselectedAreaFill(javafx.scene.paint.Paint unselectedAreaFill)
unselectedAreaFill - the new Paint of the area outside of the selectionunselectedAreaFillProperty()protected final java.lang.String getUserAgentStylesheet(java.lang.Class<?> clazz,
java.lang.String fileName)
clazz - the class used for the resource lookupfileName - the name of the user agent stylesheet