Module org.snapfx

Class DockLayoutEngine

java.lang.Object
org.snapfx.view.DockLayoutEngine

public class DockLayoutEngine extends Object
Layout engine that converts the logical DockGraph into a visual scene graph. Keeps model and view in sync.
  • Field Details

  • Constructor Details

    • DockLayoutEngine

      public DockLayoutEngine(DockGraph dockGraph, DockDragService dragService)
      Creates a layout engine for one dock graph.
      Parameters:
      dockGraph - source dock graph
      dragService - 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

      public DockElement findElementAt(double sceneX, double sceneY)
      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 scene
      sceneY - Y coordinate in scene
      Returns:
      The best matching DockElement or null
    • collectDropZones

      public List<DockDropZone> collectDropZones()
      Collects drop zones for all elements in the current graph.
      Returns:
      resolved drop zones in scene space
    • findBestDropZone

      public DockDropZone findBestDropZone(List<DockDropZone> zones, double sceneX, double sceneY)
      Selects the best drop zone for the given scene coordinates.
      Parameters:
      zones - candidate drop zones
      sceneX - pointer x-coordinate in scene space
      sceneY - 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

      public void setOnNodeCloseRequest(BiConsumer<DockNode,DockCloseSource> onNodeCloseRequest)
      Sets the action to be performed when a node close is requested.
      Parameters:
      onNodeCloseRequest - The action to set
    • setOnNodeFloatRequest

      public void setOnNodeFloatRequest(Consumer<DockNode> onNodeFloatRequest)
      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

      public void setCanFloatNodePredicate(Predicate<DockNode> canFloatNodePredicate)
      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

      public DockCloseButtonMode getCloseButtonMode()
      Returns the active close-button rendering mode.
      Returns:
      close-button mode
    • setCloseButtonMode

      public void setCloseButtonMode(DockCloseButtonMode closeButtonMode)
      Sets the close-button rendering mode for node/tab controls.
      Parameters:
      closeButtonMode - close-button mode, ignored when null
    • getTitleBarMode

      public DockTitleBarMode getTitleBarMode()
      Returns the active dock-node title-bar rendering mode.
      Returns:
      title-bar mode
    • setTitleBarMode

      public void setTitleBarMode(DockTitleBarMode titleBarMode)
      Sets the title-bar rendering mode for dock nodes.
      Parameters:
      titleBarMode - title-bar mode, ignored when null
    • getViewForElement

      public javafx.scene.Node getViewForElement(DockElement element)
      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

      public DockNodeView getDockNodeView(DockNode node)
      Returns the DockNodeView for a given DockNode, or null if not found.
      Parameters:
      node - dock node to resolve
      Returns:
      cached DockNodeView, or null