Top Description Inners Fields Constructors Methods
impl.org.controlsfx.skin

public Class SnapshotViewSkin

extends SkinBase<SnapshotView>
Class Inheritance
Imports
impl.org.controlsfx.tools.rectangle.CoordinatePosition, .CoordinatePositions, .Rectangles2D, impl.org.controlsfx.tools.rectangle.change.*, javafx.beans.binding.Bindings, .BooleanBinding, javafx.beans.property.ReadOnlyBooleanProperty, javafx.beans.value.ChangeListener, .ObservableValue, javafx.event.EventType, javafx.geometry.Bounds, .Point2D, .Pos, .Rectangle2D, javafx.scene.Cursor, .Node, javafx.scene.control.SkinBase, javafx.scene.input.MouseButton, .MouseEvent, javafx.scene.layout.GridPane, javafx.scene.paint.Color, javafx.scene.shape.Rectangle, .StrokeType, org.controlsfx.control.SnapshotView, .SnapshotView.Boundary, java.util.Objects, java.util.function.Consumer

View for the SnapshotView. It displays the node and the selection and manages their positioning. Mouse events are used to change the selection.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SnapshotViewSkin.Clipper

Clips the unselected area to the unselectedAreaBoundary.

private static class
SnapshotViewSkin.NoSelectionChange

Implementation of SnapshotViewSkin.SelectionChange which does not actually change anything.

private static interface
SnapshotViewSkin.SelectionChange

Handles the actual change of a selection when the mouse is pressed, dragged and released.

private static class
private static class
SnapshotViewSkin.SelectionEvent

A selection event encapsulates a MouseEvent and adds some additional information like the coordinates relative to the node's preferred size and its position relative to a selection.

Field Summary

Modifier and TypeField and Description
private final GridPane
gridPane

The pane displaying the node.

private final Node
mouseNode

The node capturing mouse events.

private Node
node

The currently displayed node; when the node property changes updateNode will set the new one.

private static final double
RELATIVE_EDGE_TOLERANCE

The percentage of the control's node's width/height used as a tolerance for determining whether the cursor is on an edge of the selection.

private final Rectangle
selectedArea

The (mutable) rectangle which represents the selected area.

private SnapshotViewSkin.SelectionChange
selectionChange

The current selection change; might be null.

private final Consumer<Boolean>
setSelectionChanging

A function which sets the selectionChanging property to the given value.

private final Rectangle
unselectedArea

The rectangle whose stroke represents the unselected area.

Constructor Summary

AccessConstructor and Description
public
SnapshotViewSkin(SnapshotView
the SnapshotView this skin will display
snapshotView
)

Creates a new skin for the specified SnapshotView.

Method Summary

Modifier and TypeMethod and Description
private void
bindAreaCoordinatesTogether()

Binds the position and size of unselectedArea to selectedArea.

private void
bindAreaVisibilityToSelection()

Binds the visibility of selectedArea and unselectedArea to the SnapshotView 's selectionActive and selectionValid properties.

private void
buildSceneGraph()

Builds this skin's scene graph.

private CoordinatePosition

Returns:

the CoordinatePosition the event's point has relative to the control's current selection; if the selection is inactive this always returns CoordinatePosition#OUT_OF_RECTANGLE.
computePosition
(Point2D
the point (in the node's preferred coordinates) whose position will be computed
point
)

Returns the position of the specified point relative to a possible selection.

private static CoordinatePosition

Returns:

the CoordinatePosition the event's point has relative to the control's current selection; if the selection is inactive this always returns CoordinatePosition#OUT_OF_RECTANGLE.
computePosition
(Rectangle2D
the selection relative to which the point's position will be computed; as a Rectangle2D
selection
,
Point2D
the Point2D whose position will be computed
point
,
double
the absolute tolerance used to determine whether the point is on an edge
tolerance
)

Returns the position of the specified point relative to the specified selection with the specified tolerance.

private double

Returns:

the absolute tolerance
computeTolerance
()

Computes the tolerance which is used to determine whether the cursor is on an edge.

private Rectangle2D

Returns:

the bounds as a Rectangle2D
createBoundsForCurrentBoundary
()

Returns the bounds according to the current selectionAreaBoundary.

private static GridPane

Returns:

a GridPane
createGridPane
()

Creates the grid pane which will contain the node.

private Node

Returns:

a Node
createMouseNode
()

Creates the node which will be used to capture mouse events.

private SnapshotViewSkin.SelectionEvent

Returns:

the SnapshotViewSkin.SelectionEvent for the specified mouse event
createSelectionEvent
(MouseEvent
the MouseEvent for which the selection event will be created
mouseEvent
)

Creates a selection event for the specified mouse event

private Consumer<Boolean>

Returns:

a Boolean Consumer
createSetSelectionChanging
()

Creates a function which sets the applied boolean to SnapshotView#selectionChangingProperty().

private Rectangle2DChangeStrategy

Returns:

the Rectangle2DChangeStrategy which will be executed based on the selection event
getChangeStrategy
(SnapshotViewSkin.SelectionEvent
the SnapshotViewSkin.SelectionEvent which will be checked
selectionEvent
)

Returns the selection change strategy based on the specified selection event, which must be a MOUSE_PRESSED event.

private double
getControlHeight()

The control's height.

private double
getControlWidth()

The control's width.

private Cursor

Returns:

the Cursor which will be used for the event
getCursor
(SnapshotViewSkin.SelectionEvent selectionEvent)

Returns the cursor which will be used for the specified selection event.

private Cursor
getRegularCursor()

Returns: the cursor from the control's current cursor

private Rectangle2D
getSelection()

The current selection.

private double
getSelectionRatio()

The current selection's fixed ratio.

private Node
getSnapshotNode()

The currently displayed node.

private Cursor

Returns:

the cursor which will be used while the selection changes
handleMouseDraggedEvent
(SnapshotViewSkin.SelectionEvent selectionEvent)

Handles MouseEvent#MOUSE_DRAGGED events by continuing the current selectionChange.

private void
handleMouseEvent(MouseEvent
the MouseEvent to handle
event
)

Handles mouse events.

private Cursor

Returns:

the cursor which will be used for this event
handleMouseEventImpl
(MouseEvent
the handled MouseEvent; must not be null
mouseEvent
)

Handles the specified mouse event (possibly by creating/changing/removing a selection) and returns the matching cursor.

private Cursor

Returns:

the cursor which will be used while the selection changes
handleMousePressedEvent
(SnapshotViewSkin.SelectionEvent selectionEvent)

Handles MouseEvent#MOUSE_PRESSED events by creating a new selectionChange and beginning the change.

private Cursor

Returns:

the cursor which will be used after the selection change ends
handleMouseReleasedEvent
(SnapshotViewSkin.SelectionEvent selectionEvent)

Handles MouseEvent#MOUSE_RELEASED events by ending the current selectionChange and setting it to null.

private void
initializeAreas()

Initializes the selectedArea and the unselectedArea.

private boolean
isSelectionRatioFixed()

Indicates whether the current selection has a fixed ratio.

private void
setSelection(double
the new x coordinate of the upper left corner
x
,
double
the new y coordinate of the upper left corner
y
,
double
the new width
width
,
double
the new height
height
)

Updates the position and size of selectedArea (and by binding that of unselectedArea) to the specified arguments.

private void
styleAreas()

Styles the selected and unselected area.

private void
updateNode()

Displays the current node.

private void
updateSelection()

Updates the position and size of selectedArea (and by binding that of unselectedArea) to a changed selection.

private static boolean

Returns:

true if the selection event is such that the selection will be deactivated if the mouse is only clicked
willDeactivateSelectionIfClick
(SnapshotViewSkin.SelectionEvent
the selection event which will be checked
selectionEvent
)

Checks whether the selection will be deactivated if the mouse is clicked at the SnapshotViewSkin.SelectionEvent.

Inherited from javafx.scene.control.SkinBase:
computeBaselineOffsetcomputeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthconsumeMouseEventsdisposeexecuteAccessibleActiongetChildrengetClassCssMetaDatagetCssMetaDatagetNodegetSkinnablelayoutChildrenlayoutInArealayoutInArealayoutInAreapositionInAreapositionInAreapseudoClassStateChangedqueryAccessibleAttributeregisterChangeListenerregisterInvalidationListenerregisterListChangeListenersnappedBottomInsetsnappedLeftInsetsnappedRightInsetsnappedTopInsetsnapPositionsnapPositionXsnapPositionYsnapSizesnapSizeXsnapSizeYsnapSpacesnapSpaceXsnapSpaceYunregisterChangeListenersunregisterInvalidationListenersunregisterListChangeListeners