java.lang.Object
org.snapfx.view.DockLayoutEngine
Layout engine that converts the logical DockGraph into a visual scene graph.
Keeps model and view in sync.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDockLayoutEngine(DockGraph dockGraph, DockDragService dragService) Creates a layout engine for one dock graph. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.scene.NodeBuilds the visual representation of the DockGraph.voidClears the entire view cache.Collects drop zones for all elements in the current graph.findBestDropZone(List<DockDropZone> zones, double sceneX, double sceneY) Selects the best drop zone for the given scene coordinates.findElementAt(double sceneX, double sceneY) Finds the model element (DockElement) at the given scene coordinates.Returns the active close-button rendering mode.getDockNodeView(DockNode node) Returns the DockNodeView for a given DockNode, or null if not found.Returns the active dock-node title-bar rendering mode.javafx.scene.NodegetViewForElement(DockElement element) Returns the Node view for a given DockElement, or null if not found.voidsetCanFloatNodePredicate(Predicate<DockNode> canFloatNodePredicate) Sets a predicate controlling whether float actions are available for a node.voidsetCloseButtonMode(DockCloseButtonMode closeButtonMode) Sets the close-button rendering mode for node/tab controls.voidsetOnNodeCloseRequest(BiConsumer<DockNode, DockCloseSource> onNodeCloseRequest) Sets the action to be performed when a node close is requested.voidsetOnNodeFloatRequest(Consumer<DockNode> onNodeFloatRequest) Sets the action to be performed when a node float is requested.voidsetOnNodePinToSideBarRequest(BiConsumer<DockNode, javafx.geometry.Side> onNodePinToSideBarRequest) Sets the action to be performed when a node should be moved to a sidebar.voidsetTitleBarMode(DockTitleBarMode titleBarMode) Sets the title-bar rendering mode for dock nodes.
-
Field Details
-
TAB_DOCK_NODE_KEY
User-data key used on JavaFX tabs to map back to theirDockNode.- See Also:
-
-
Constructor Details
-
DockLayoutEngine
Creates a layout engine for one dock graph.- Parameters:
dockGraph- source dock graphdragService- drag service used for node interactions
-
-
Method Details
-
buildSceneGraph
public javafx.scene.Node buildSceneGraph()Builds the visual representation of the DockGraph.- Returns:
- root JavaFX node representing the current dock layout
-
findElementAt
Finds the model element (DockElement) at the given scene coordinates. Uses intelligent target selection: prefers smaller/more specific targets when mouse is near center, and larger/parent targets when mouse is near edges.- Parameters:
sceneX- X coordinate in scenesceneY- Y coordinate in scene- Returns:
- The best matching DockElement or null
-
collectDropZones
Collects drop zones for all elements in the current graph.- Returns:
- resolved drop zones in scene space
-
findBestDropZone
Selects the best drop zone for the given scene coordinates.- Parameters:
zones- candidate drop zonessceneX- pointer x-coordinate in scene spacesceneY- pointer y-coordinate in scene space- Returns:
- best matching drop zone, or
null
-
clearCache
public void clearCache()Clears the entire view cache. This is called before a new scene graph is built to ensure no stale views are used. -
setOnNodeCloseRequest
Sets the action to be performed when a node close is requested.- Parameters:
onNodeCloseRequest- The action to set
-
setOnNodeFloatRequest
Sets the action to be performed when a node float is requested.- Parameters:
onNodeFloatRequest- The action to set
-
setOnNodePinToSideBarRequest
public void setOnNodePinToSideBarRequest(BiConsumer<DockNode, javafx.geometry.Side> onNodePinToSideBarRequest) Sets the action to be performed when a node should be moved to a sidebar.- Parameters:
onNodePinToSideBarRequest- The action to set
-
setCanFloatNodePredicate
Sets a predicate controlling whether float actions are available for a node. This affects tab/header context menus and float-action callbacks.- Parameters:
canFloatNodePredicate- predicate deciding float availability per node
-
getCloseButtonMode
Returns the active close-button rendering mode.- Returns:
- close-button mode
-
setCloseButtonMode
Sets the close-button rendering mode for node/tab controls.- Parameters:
closeButtonMode- close-button mode, ignored whennull
-
getTitleBarMode
Returns the active dock-node title-bar rendering mode.- Returns:
- title-bar mode
-
setTitleBarMode
Sets the title-bar rendering mode for dock nodes.- Parameters:
titleBarMode- title-bar mode, ignored whennull
-
getViewForElement
Returns the Node view for a given DockElement, or null if not found.- Parameters:
element- dock element to resolve- Returns:
- cached JavaFX node, or
null
-
getDockNodeView
Returns the DockNodeView for a given DockNode, or null if not found.- Parameters:
node- dock node to resolve- Returns:
- cached
DockNodeView, ornull
-