java.lang.Object
org.snapfx.floating.DockFloatingWindow
Represents an external floating window that can host a full dock-layout subtree.
Floating windows support dock-node interactions similar to the main host: split/tab drops, context actions, optional snapping, and attach-back workflows.
Programmatic example:
DockFloatingWindow floating = new DockFloatingWindow(node, dragService);
floating.setOnAttachRequested(() -> snapFX.attachFloatingWindow(floating));
floating.show(primaryStage);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordImmutable floating drop-target resolution result. -
Constructor Summary
ConstructorsConstructorDescriptionDockFloatingWindow(DockElement floatingRoot, String titlePrefix, DockDragService dragService) Creates a floating window from an existing layout subtree with custom title prefix.DockFloatingWindow(DockElement floatingRoot, DockDragService dragService) Creates a floating window from an existing layout subtree.DockFloatingWindow(DockNode dockNode) Creates a floating window from one dock node using default title prefix and drag service.DockFloatingWindow(DockNode dockNode, String titlePrefix) Creates a floating window from one dock node and custom title prefix.DockFloatingWindow(DockNode dockNode, String titlePrefix, DockDragService dragService) Creates a floating window from one dock node and custom wiring.DockFloatingWindow(DockNode dockNode, DockDragService dragService) Creates a floating window from one dock node using default title prefix. -
Method Summary
Modifier and TypeMethodDescriptionvoidCaptures current stage bounds into preferred restore values.voidHides floating-window drop preview visuals.voidclose()Requests closing this floating window, respecting lock and close callbacks.voidCloses this floating window without emitting close notifications.booleancontainsNode(DockNode node) Returns whether the provided node is part of this floating window.booleancontainsScreenPoint(double screenX, double screenY) Returns whether the given screen-space point hits this floating window content.voiddockNode(DockNode node, DockElement target, DockPosition position, Integer tabIndex) Docks a node into this floating graph.Returns the dock graph hosted by this floating window.Returns the representative dock node used for title/icon fallbacks.Returns all dock nodes currently contained in this floating window.getDockNodeView(DockNode node) Returns the rendered view for a dock node in this floating layout.getId()Returns the stable floating-window ID.Returns the pin-button visibility mode.Returns the lock-mode behavior used for the pin button.doubleReturns the preferred floating height.doubleReturns the preferred floating width.Returns the preferred screen x-coordinate.Returns the preferred screen y-coordinate.javafx.scene.ScenegetScene()Returns the current scene of this floating window, ornullwhen not shown.doubleReturns the snap distance in pixels.Returns the configured snap targets.booleanReturns whether the window is currently configured as always-on-top.booleanisEmpty()Returns whether this floating window has no layout root.booleanReturns whether users may toggle always-on-top from the title bar.booleanReturns whether the underlying stage is currently visible.booleanReturns whether drag snapping is enabled.voidmoveNode(DockNode node, DockElement target, DockPosition position, Integer tabIndex) Moves a node within this floating graph.booleanownsScene(javafx.scene.Scene scene) Returns whether the given scene belongs to this floating window.voidrequestFloatForNode(DockNode node) Routes an inner-node float request through the floating-window callback flow.resolveDropTarget(double screenX, double screenY, DockNode draggedNode) Resolves the best drop target in this floating window for the given pointer position.voidsetAlwaysOnTop(boolean value) Sets always-on-top and marks the change as API-driven.voidsetAlwaysOnTop(boolean value, DockFloatingPinSource source) Sets always-on-top with an explicit change source.voidsetOnAlwaysOnTopChanged(BiConsumer<Boolean, DockFloatingPinSource> onAlwaysOnTopChanged) Sets a callback that is invoked when always-on-top changes.voidsetOnAttachRequested(Runnable onAttachRequested) Sets the callback invoked when the user requests "attach to layout".voidsetOnCloseRequested(BooleanSupplier onCloseRequested) Sets the callback used to veto or allow floating-window close requests.voidsetOnNodeCloseRequest(BiConsumer<DockNode, DockCloseSource> onNodeCloseRequest) Sets the callback for close requests initiated by inner dock nodes.voidsetOnNodeFloatRequest(Consumer<DockNode> onNodeFloatRequest) Sets the callback for float requests initiated by inner dock nodes.voidsetOnNodePinToSideBarRequest(BiConsumer<DockNode, javafx.geometry.Side> onNodePinToSideBarRequest) Sets a callback used by inner dock-node context menus to move nodes into a SnapFX sidebar.voidsetOnWindowActivated(Runnable onWindowActivated) Sets the callback invoked when this floating window becomes active.voidsetOnWindowClosed(Consumer<DockFloatingWindow> onWindowClosed) Sets the callback invoked when this floating window is closed.voidSets the pin-button visibility mode.voidSets how the pin button behaves while the layout is locked.voidsetPinToggleEnabled(boolean enabled) Enables or disables title-bar pin toggling.voidsetPreferredPosition(Double screenX, Double screenY) Updates the preferred screen position used for initial show/restore.voidsetPreferredSize(double width, double height) Updates the preferred floating window size.voidsetSnapDistance(double pixels) Sets the snap distance in pixels.voidsetSnapPeerWindowsSupplier(Supplier<List<DockFloatingWindow>> supplier) Sets the supplier used to resolve other floating windows for snapping.voidsetSnappingEnabled(boolean enabled) Enables or disables snapping while dragging the floating window title bar.voidsetSnapTargets(Set<DockFloatingSnapTarget> targets) Configures which snap targets are considered during drag.voidshow(javafx.stage.Stage ownerStage) Shows this floating window and rebuilds its layout.voidtoFront()Brings this floating window to the foreground.voidundockNode(DockNode node) Removes a node from this floating graph.voidupdateDropPreview(DockNode draggedNode, double screenX, double screenY, DockDropVisualizationMode visualizationMode) Updates floating-window drop preview visuals for the given pointer position.
-
Constructor Details
-
DockFloatingWindow
Creates a floating window from one dock node using default title prefix and drag service.- Parameters:
dockNode- initial dock node shown in the floating window
-
DockFloatingWindow
Creates a floating window from one dock node using default title prefix.- Parameters:
dockNode- initial dock node shown in the floating windowdragService- drag service used for floating-scene drag and drop interactions
-
DockFloatingWindow
Creates a floating window from one dock node and custom title prefix.- Parameters:
dockNode- initial dock node shown in the floating windowtitlePrefix- title prefix used for generated floating-window titles
-
DockFloatingWindow
Creates a floating window from one dock node and custom wiring.- Parameters:
dockNode- initial dock node shown in the floating windowtitlePrefix- title prefix used for generated floating-window titlesdragService- drag service used for floating-scene drag and drop interactions
-
DockFloatingWindow
Creates a floating window from an existing layout subtree.- Parameters:
floatingRoot- layout subtree used as floating rootdragService- drag service used for floating-scene drag and drop interactions
-
DockFloatingWindow
public DockFloatingWindow(DockElement floatingRoot, String titlePrefix, DockDragService dragService) Creates a floating window from an existing layout subtree with custom title prefix.- Parameters:
floatingRoot- layout subtree used as floating roottitlePrefix- title prefix used for generated floating-window titlesdragService- drag service used for floating-scene drag and drop interactions
-
-
Method Details
-
getId
Returns the stable floating-window ID.- Returns:
- floating-window ID
-
getDockNode
Returns the representative dock node used for title/icon fallbacks.- Returns:
- representative dock node
-
getDockGraph
Returns the dock graph hosted by this floating window.- Returns:
- floating dock graph
-
getDockNodes
Returns all dock nodes currently contained in this floating window.- Returns:
- contained dock nodes
-
containsNode
Returns whether the provided node is part of this floating window.- Parameters:
node- node to check- Returns:
truewhen the node is contained
-
isEmpty
public boolean isEmpty()Returns whether this floating window has no layout root.- Returns:
truewhen the floating graph root isnull
-
isShowing
public boolean isShowing()Returns whether the underlying stage is currently visible.- Returns:
truewhen the floating stage is showing
-
getScene
public javafx.scene.Scene getScene()Returns the current scene of this floating window, ornullwhen not shown.- Returns:
- floating window scene, or
null
-
ownsScene
public boolean ownsScene(javafx.scene.Scene scene) Returns whether the given scene belongs to this floating window.- Parameters:
scene- scene to check- Returns:
truewhen the scene belongs to this floating window
-
containsScreenPoint
public boolean containsScreenPoint(double screenX, double screenY) Returns whether the given screen-space point hits this floating window content.- Parameters:
screenX- screen x-coordinatescreenY- screen y-coordinate- Returns:
truewhen the point is inside this floating scene
-
toFront
public void toFront()Brings this floating window to the foreground. -
setPreferredPosition
Updates the preferred screen position used for initial show/restore.- Parameters:
screenX- preferred screen x-coordinate, ornullscreenY- preferred screen y-coordinate, ornull
-
setPreferredSize
public void setPreferredSize(double width, double height) Updates the preferred floating window size.- Parameters:
width- preferred width (applied when> 0)height- preferred height (applied when> 0)
-
getPreferredX
Returns the preferred screen x-coordinate.- Returns:
- preferred screen x-coordinate, or
null
-
getPreferredY
Returns the preferred screen y-coordinate.- Returns:
- preferred screen y-coordinate, or
null
-
getPreferredWidth
public double getPreferredWidth()Returns the preferred floating width.- Returns:
- preferred width in pixels
-
getPreferredHeight
public double getPreferredHeight()Returns the preferred floating height.- Returns:
- preferred height in pixels
-
captureCurrentBounds
public void captureCurrentBounds()Captures current stage bounds into preferred restore values. -
show
public void show(javafx.stage.Stage ownerStage) Shows this floating window and rebuilds its layout.- Parameters:
ownerStage- optional owner stage
-
close
public void close()Requests closing this floating window, respecting lock and close callbacks. -
closeWithoutNotification
public void closeWithoutNotification()Closes this floating window without emitting close notifications. -
setOnAttachRequested
Sets the callback invoked when the user requests "attach to layout".- Parameters:
onAttachRequested- attach callback, ornull
-
setOnWindowClosed
Sets the callback invoked when this floating window is closed.- Parameters:
onWindowClosed- close callback, ornull
-
setOnWindowActivated
Sets the callback invoked when this floating window becomes active.- Parameters:
onWindowActivated- activation callback, ornull
-
setOnCloseRequested
Sets the callback used to veto or allow floating-window close requests.- Parameters:
onCloseRequested- callback returning close permission, ornull
-
setOnNodeCloseRequest
Sets the callback for close requests initiated by inner dock nodes.- Parameters:
onNodeCloseRequest- callback receiving node + close source, ornull
-
setOnNodeFloatRequest
Sets the callback for float requests initiated by inner dock nodes.- Parameters:
onNodeFloatRequest- callback receiving the requested node, ornull
-
setOnNodePinToSideBarRequest
public void setOnNodePinToSideBarRequest(BiConsumer<DockNode, javafx.geometry.Side> onNodePinToSideBarRequest) Sets a callback used by inner dock-node context menus to move nodes into a SnapFX sidebar.- Parameters:
onNodePinToSideBarRequest- callback receiving node and target side, ornull
-
setSnappingEnabled
public void setSnappingEnabled(boolean enabled) Enables or disables snapping while dragging the floating window title bar.- Parameters:
enabled-trueto enable snapping
-
isSnappingEnabled
public boolean isSnappingEnabled()Returns whether drag snapping is enabled.- Returns:
truewhen snapping is enabled
-
setSnapDistance
public void setSnapDistance(double pixels) Sets the snap distance in pixels.- Parameters:
pixels- snap tolerance in pixels (must be finite and >= 0)
-
getSnapDistance
public double getSnapDistance()Returns the snap distance in pixels.- Returns:
- snap tolerance in pixels
-
setSnapTargets
Configures which snap targets are considered during drag.- Parameters:
targets- configured snap targets,nullclears all targets
-
getSnapTargets
Returns the configured snap targets.- Returns:
- immutable snapshot of configured snap targets
-
setSnapPeerWindowsSupplier
Sets the supplier used to resolve other floating windows for snapping.- Parameters:
supplier- supplier returning candidate peer floating windows, ornull
-
isAlwaysOnTop
public boolean isAlwaysOnTop()Returns whether the window is currently configured as always-on-top.- Returns:
truewhen always-on-top is enabled
-
setAlwaysOnTop
public void setAlwaysOnTop(boolean value) Sets always-on-top and marks the change as API-driven.- Parameters:
value- target always-on-top state
-
setAlwaysOnTop
Sets always-on-top with an explicit change source.- Parameters:
value- target always-on-top statesource- source of the state change, defaults toDockFloatingPinSource.APIwhennull
-
getPinButtonMode
Returns the pin-button visibility mode.- Returns:
- configured pin-button mode
-
setPinButtonMode
Sets the pin-button visibility mode.- Parameters:
mode- pin-button mode, defaults toDockFloatingPinButtonMode.AUTOwhennull
-
isPinToggleEnabled
public boolean isPinToggleEnabled()Returns whether users may toggle always-on-top from the title bar.- Returns:
truewhen user pin toggling is enabled
-
setPinToggleEnabled
public void setPinToggleEnabled(boolean enabled) Enables or disables title-bar pin toggling.- Parameters:
enabled-trueto allow user pin toggling
-
getPinLockedBehavior
Returns the lock-mode behavior used for the pin button.- Returns:
- configured locked-mode pin behavior
-
setPinLockedBehavior
Sets how the pin button behaves while the layout is locked.- Parameters:
behavior- locked-mode behavior, defaults toDockFloatingPinLockedBehavior.ALLOWwhennull
-
setOnAlwaysOnTopChanged
Sets a callback that is invoked when always-on-top changes.- Parameters:
onAlwaysOnTopChanged- callback receiving state + change source, ornull
-
undockNode
Removes a node from this floating graph.- Parameters:
node- node to remove
-
dockNode
Docks a node into this floating graph.- Parameters:
node- node to docktarget- target elementposition- target dock positiontabIndex- tab insert index for tab drops, ornull
-
moveNode
Moves a node within this floating graph.- Parameters:
node- node to movetarget- target elementposition- target dock positiontabIndex- tab insert index for tab drops, ornull
-
requestFloatForNode
Routes an inner-node float request through the floating-window callback flow.- Parameters:
node- node that requested floating
-
getDockNodeView
Returns the rendered view for a dock node in this floating layout.- Parameters:
node- node whose view should be resolved- Returns:
- rendered node view, or
null
-
resolveDropTarget
public DockFloatingWindow.DropTarget resolveDropTarget(double screenX, double screenY, DockNode draggedNode) Resolves the best drop target in this floating window for the given pointer position.- Parameters:
screenX- pointer x-coordinate in screen spacescreenY- pointer y-coordinate in screen spacedraggedNode- node currently being dragged- Returns:
- resolved drop target, or
nullwhen none matches
-
updateDropPreview
public void updateDropPreview(DockNode draggedNode, double screenX, double screenY, DockDropVisualizationMode visualizationMode) Updates floating-window drop preview visuals for the given pointer position.- Parameters:
draggedNode- node currently being draggedscreenX- pointer x-coordinate in screen spacescreenY- pointer y-coordinate in screen spacevisualizationMode- drop visualization mode to apply
-
clearDropPreview
public void clearDropPreview()Hides floating-window drop preview visuals.
-