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
| Modifier and Type | Class and Description |
|---|---|
| public static enum | SnapshotView.
The |
| private static class | SnapshotView.
The class which holds this control's |
| private class | SnapshotView.
Updates the size of the |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | DEFAULT_STYLE_CLASS
The name of the style class used in CSS for instances of this class. |
| private final DoubleProperty | |
| private final BooleanProperty | |
| public static final double | MAX_SELECTION_RATIO_DIVERGENCE
The maximal divergence between a selection's ratio and the |
| private final ObjectProperty | |
| private final ObjectProperty | |
| public static final String | SELECTION_CHANGING_PROPERTY_KEY
The key of the |
| private final BooleanProperty | |
| private final BooleanProperty | |
| private final ObjectProperty | |
| private final ObjectProperty | |
| private final ObjectProperty | |
| private final DoubleProperty | |
| private final BooleanProperty | |
| private final BooleanProperty | |
| private final BooleanProperty | |
| private final ObjectProperty | |
| private final ObjectProperty |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SnapshotView(Node
the node to show after construction node)Creates a new SnapshotView using the specified node. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private static <S extends Styleable, T> CssMetaData | Returns: an instance ofCssMetaDataa function from the getProperty, String Styleable which owns the styled property to the property styled by the
returned CssMetaDatathe name by which the styled property is referenced in CSS files cssPropertyName, StyleConverter<?, T> the styleConverter)StyleConverter used to convert the CSS parsed value to a Java objectCreates an instance of |
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public WritableImage | Returns: theWritableImage that holds the rendered selectionCreates a snapshot of the selected area of the node. |
| public WritableImage | Returns: theWritableImage that holds the rendered viewportthe parameters)SnapshotParameters used for the snapshot (must not be null); the viewport will be
interpreted relative to this control (like the selection)Creates a snapshot of the node with the specified parameters. |
| private static StyleableDoubleProperty | Returns: aStyleableDoublePropertythe bean, String bean the created property belongs tothe property's name, double namethe property's initial value initialValue, CssMetaData<? extends Styleable, Number> the cssMetaData)CssMetaData for the created propertyCreates a |
| private static <T> StyleableObjectProperty | Returns: aStyleableObjectPropertythe bean, String bean the created property belongs tothe property's name, T namethe property's initial value initialValue, CssMetaData<? extends Styleable, T> the cssMetaData)CssMetaData for the created propertyCreates a |
| public final DoubleProperty | Returns: a property containing the fixed selection ratioThe value to which the selection ratio is fixed. |
| private void | |
| public static List | Returns: theCssMetaData associated with this class, which includes the CssMetaData of its super
classesHides javafx. Gets the |
| public List | getControlCssMetaData()
Overrides javafx. Gets the unmodifiable list of the control's CSS-styleable properties. |
| public final double | getFixedSelectionRatio()
Returns: the fixedSelectionRatio, which will always be a strictly positive value |
| public final Node | |
| public final Rectangle2D | |
| public final SnapshotView. | |
| public final Paint | |
| public final Paint | |
| public final double | |
| private Rectangle2D | getSelectionBounds()
Returns: the bounds of the current selection according to the |
| public final SnapshotView. | |
| public final Paint | |
| public String | getUserAgentStylesheet()
Overrides javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. |
| private boolean | Returns: true if the selection has the correct ratio.the selection to check as a selection)Rectangle2DIndicates whether the specified selection has the correct ratio (which depends on whether the ratio is even
|
| public final boolean | |
| public final ReadOnlyBooleanProperty | Returns: a property indicating whether there currently is a selectionIndicates whether there currently is a selection. |
| private boolean | Returns: true if the selection is fully contained in the bounds; otherwise falsethe non-null and non-empty selection as a selection)Rectangle2DIndicates whether the specified selection is inside the bounds determined by the
|
| private static boolean | Returns: true if the selection is fully contained in the bounds; otherwise falsethe selection as a selection, Bounds Rectangle2Dthe bounds)Bounds to check the selection againstIndicates whether the specified selection is inside the specified bounds. |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| private boolean | Returns: true if the selection is valid; false otherwisethe selection to check as a selection)Rectangle2DChecks whether the specified selection is valid. |
| private static <T> void | listenToProperty(ObservableMap<Object, Object>
the properties, Object ObservableMap which contains the properties; typically Control#getProperties()the key for whose value is listened key, Consumer<T> the processValue)Consumer for the new valueListens to the specified properties. |
| public final ObjectProperty | Returns: the property holding the displayed nodeThe |
| public final BooleanProperty | Returns: the property indicating whether the selection is activeIndicates whether the selection is currently active. |
| public final BooleanProperty | Returns: the property indicating whether the value of theselectionActive
property is managed by this controlIndicates whether the value of the |
| public final ObjectProperty | Returns: the property indicating theBoundary for the area the user can selectIndicates which |
| public final ObjectProperty | Returns: the property holding thePaint of the selected areaDetermines the visualization of the selected area. |
| public final ObjectProperty | Returns: the property holding thePaint of the selection borderDetermines the visualization of the selection's border. |
| public final DoubleProperty | Returns: the property defining the selection border's widthDetermines the width of the selection's border. |
| public final ReadOnlyBooleanProperty | Returns: a property indicating whether the selection is changing by user interactionIndicates whether the |
| public final BooleanProperty | Returns: the property indicating whether the selection is mouse transparentIndicates whether the overlay which displays the selection is mouse transparent. |
| public final ObjectProperty | Returns: the property holding the current selectionThe current selection as a |
| public final BooleanProperty | Returns: the property indicating whether the selection ratio is fixedIndicates whether the ratio of the |
| public final void | |
| public final void | |
| public final void | |
| public final void | setSelection(double
the x coordinate of the selection's upper left point upperLeftX, double the y coordinate of the selection's upper left point upperLeftY, double the selection's width width, double the selection's height height)Creates a new |
| public final void | |
| public final void | setSelectionActivityManaged(boolean
whether the selection activity will be managed by this control selectionActivityManaged)
|
| public final void | setSelectionAreaBoundary(SnapshotView.
the new selectionAreaBoundaryBoundary for the area the user can select
|
| public final void | |
| public final void | |
| public final void | |
| public final void | setSelectionMouseTransparent(boolean
whether the selection will be mouse transparent selectionMouseTransparent)
|
| public final void | |
| public final void | setUnselectedAreaBoundary(SnapshotView.
the new unselectedAreaBoundaryBoundary for the unselected area
|
| public final void | |
| public Rectangle2D | Returns: aRectangle2D which expresses the selection in the node's coordinatesTransforms the |
| public Rectangle2D | Returns: aRectangle2D with the same width and height as the specified area but with coordinates
which are relative to the current nodethe area)Rectangle2D which will be transformed (must not be null); its coordinates will be
interpreted relative to the control (like the selection)Transforms the specified area's coordinates to coordinates relative to the node. |
| public final ObjectProperty | Returns: the property defining theBoundary of the unselected areaIndicates which |
| public final ObjectProperty | Returns: the property holding thePaint of the area outside of the selectionDetermines the visualization of the area outside of the selection. |
| private void | updateSelectionActivityState()
Updates the |
| private static boolean | Returns: true if the selection has only finite values.the selection as a selection)Rectangle2DIndicates whether the specified selection has only finite values (e.g. width and height). |