Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx.util

public Class ResizingBehaviour

extends Object
Class Inheritance
Imports
javafx.beans.property.BooleanProperty, .DoubleProperty, .ListProperty, .ObjectProperty, .SimpleBooleanProperty, .SimpleDoubleProperty, .SimpleListProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ObservableList, javafx.event.EventHandler, javafx.scene.Cursor, javafx.scene.input.MouseEvent, javafx.scene.layout.Region, java.util.Objects, java.util.function.BiConsumer

This class implements interactive resizing behavior for a Region. It allows the user to resize the region by pressed and dragging the region's edges. The resizing behavior can be attached to any Region, modifying its preferred width and height as well as its layout coordinates based on user interactions.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private final EventHandler<MouseEvent>
private final EventHandler<MouseEvent>
private final EventHandler<MouseEvent>
private final EventHandler<MouseEvent>
private DoubleProperty
private ObjectProperty<BiConsumer<Double, Double>>
private ResizingBehaviour.Operation
private final Region
private BooleanProperty
private static final String
private double
private double
private final ListProperty<ResizingBehaviour.Operation>

Constructor Summary

AccessConstructor and Description
private
ResizingBehaviour(Region region)

Constructs a new pane with the given children.

Method Summary

Modifier and TypeMethod and Description
public final double
public final BiConsumer<Double, Double>
public final ObservableList<ResizingBehaviour.Operation>
public static ResizingBehaviour

Returns:

the installed behaviour
install
(Region
the region to support resizing
region
)

Installs the resizing behaviour on the given region.

public static boolean

Returns:

true if the behavior is installed, false otherwise
isInstalled
(Region
the region to check for installation
region
)

Checks if a ResizingBehaviour is installed on the provided region.

public boolean

Returns:

true if installed, false otherwise
isInstalled
()

Returns true if this ResizingBehaviour is installed on the region.

public final boolean
public final DoubleProperty
offsetProperty()

The offset from the edges in pixels where the user will be able to perform a press and drag to resize the pane.

private void
private void
private void
public final ObjectProperty<BiConsumer<Double, Double>>

Returns:

the onResize callback
onResizeProperty
()

A callback that will be invoked whenever the region is resized.

public final BooleanProperty

Returns:

true if the pane is resizable
resizableProperty
()

Determines if the pane can currently be resized or not.

private void
public final void
setOffset(double offset)

public final void
private void
public final void
setResizable(boolean resizable)

public final void
public final ListProperty<ResizingBehaviour.Operation>

Returns:

the list of supported operations
supportedOperationsProperty
()

The list of supported operations for resizing the region.

public void
uninstall()

Uninstalls this ResizingBehaviour from the region, cleaning up all event handlers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mouseDraggedHandlerback to summary
private final EventHandler<MouseEvent> mouseDraggedHandler
mouseMovedHandlerback to summary
private final EventHandler<MouseEvent> mouseMovedHandler
mousePressedHandlerback to summary
private final EventHandler<MouseEvent> mousePressedHandler
mouseReleasedHandlerback to summary
private final EventHandler<MouseEvent> mouseReleasedHandler
offsetback to summary
private DoubleProperty offset
onResizeback to summary
private ObjectProperty<BiConsumer<Double, Double>> onResize
operationback to summary
private ResizingBehaviour.Operation operation
regionback to summary
private final Region region
resizableback to summary
private BooleanProperty resizable
RESIZE_BEHAVIOUR_INSTALLEDback to summary
private static final String RESIZE_BEHAVIOUR_INSTALLED
startXback to summary
private double startX
startYback to summary
private double startY
supportedOperationsback to summary
private final ListProperty<ResizingBehaviour.Operation> supportedOperations

Constructor Detail

ResizingBehaviourback to summary
private ResizingBehaviour(Region region)

Constructs a new pane with the given children.

Method Detail

getOffsetback to summary
public final double getOffset()
getOnResizeback to summary
public final BiConsumer<Double, Double> getOnResize()
getSupportedOperationsback to summary
public final ObservableList<ResizingBehaviour.Operation> getSupportedOperations()
installback to summary
public static ResizingBehaviour install(Region region)

Installs the resizing behaviour on the given region. Once installed the user will be able to resize the given region (depending on the container the region lives in and the layout algorithms used by that container).

Parameters
region:Region

the region to support resizing

Returns:ResizingBehaviour

the installed behaviour

isInstalledback to summary
public static boolean isInstalled(Region region)

Checks if a ResizingBehaviour is installed on the provided region.

Parameters
region:Region

the region to check for installation

Returns:boolean

true if the behavior is installed, false otherwise

isInstalledback to summary
public boolean isInstalled()

Returns true if this ResizingBehaviour is installed on the region.

Returns:boolean

true if installed, false otherwise

isResizableback to summary
public final boolean isResizable()
offsetPropertyback to summary
public final DoubleProperty offsetProperty()

The offset from the edges in pixels where the user will be able to perform a press and drag to resize the pane. Default is 5.

onMouseDraggedback to summary
private void onMouseDragged(MouseEvent evt)
onMouseMoveback to summary
private void onMouseMove(MouseEvent evt)
onMousePressedback to summary
private void onMousePressed(MouseEvent evt)
onResizePropertyback to summary
public final ObjectProperty<BiConsumer<Double, Double>> onResizeProperty()

A callback that will be invoked whenever the region is resized.

Returns:ObjectProperty<BiConsumer<Double, Double>>

the onResize callback

resizablePropertyback to summary
public final BooleanProperty resizableProperty()

Determines if the pane can currently be resized or not.

Default is true.

Returns:BooleanProperty

true if the pane is resizable

setCursorIfOperationSupportedback to summary
private void setCursorIfOperationSupported(ResizingBehaviour.Operation operation, Cursor cursor)
setOffsetback to summary
public final void setOffset(double offset)
setOnResizeback to summary
public final void setOnResize(BiConsumer<Double, Double> onResize)
setOperationIfSupportedback to summary
private void setOperationIfSupported(ResizingBehaviour.Operation resizeNw)
setResizableback to summary
public final void setResizable(boolean resizable)
setSupportedOperationsback to summary
public final void setSupportedOperations(ObservableList<ResizingBehaviour.Operation> supportedOperations)
supportedOperationsPropertyback to summary
public final ListProperty<ResizingBehaviour.Operation> supportedOperationsProperty()

The list of supported operations for resizing the region.

By default, all operations are supported.

Returns:ListProperty<ResizingBehaviour.Operation>

the list of supported operations

uninstallback to summary
public void uninstall()

Uninstalls this ResizingBehaviour from the region, cleaning up all event handlers.

com.dlsc.gemsfx.util back to summary

public final Enum ResizingBehaviour.Operation

extends Enum<ResizingBehaviour.Operation>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ResizingBehaviour.Operation
public static final ResizingBehaviour.Operation
public static final ResizingBehaviour.Operation
public static final ResizingBehaviour.Operation
public static final ResizingBehaviour.Operation
public static final ResizingBehaviour.Operation
public static final ResizingBehaviour.Operation
public static final ResizingBehaviour.Operation

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ResizingBehaviour.Operation
public static ResizingBehaviour.Operation[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

RESIZE_Eback to summary
public static final ResizingBehaviour.Operation RESIZE_E
RESIZE_Nback to summary
public static final ResizingBehaviour.Operation RESIZE_N
RESIZE_NEback to summary
public static final ResizingBehaviour.Operation RESIZE_NE
RESIZE_NWback to summary
public static final ResizingBehaviour.Operation RESIZE_NW
RESIZE_Sback to summary
public static final ResizingBehaviour.Operation RESIZE_S
RESIZE_SEback to summary
public static final ResizingBehaviour.Operation RESIZE_SE
RESIZE_SWback to summary
public static final ResizingBehaviour.Operation RESIZE_SW
RESIZE_Wback to summary
public static final ResizingBehaviour.Operation RESIZE_W

Constructor Detail

Operationback to summary
private Operation()

Method Detail

valueOfback to summary
public static ResizingBehaviour.Operation valueOf(String name)
valuesback to summary
public static ResizingBehaviour.Operation[] values()