Class LayoutContext


  • public class LayoutContext
    extends java.lang.Object
    The LayoutContext provides the context in which to layout a Graph. It maintains an ILayoutAlgorithm that can be applied, supports the handling and execution of pre and post Runnables, and filtering of layout objects using ILayoutFilter.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String LAYOUT_ALGORITHM_PROPERTY
      An LayoutContext notifies registered listeners about changes to the layout algorithm using this property name.
    • Constructor Summary

      Constructors 
      Constructor Description
      LayoutContext()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLayoutFilter​(ILayoutFilter layoutFilter)
      Adds the given ILayoutFilter to this LayoutContext.
      void applyLayout​(boolean clear)
      Applies the layout algorithm of this LayoutContext.
      org.eclipse.gef.graph.Edge[] getEdges()
      Returns all the connections between nodes that should be laid out.
      org.eclipse.gef.graph.Graph getGraph()
      Returns the graph that is to be layouted.
      ILayoutAlgorithm getLayoutAlgorithm()
      Returns the static layout algorithm used to layout a newly initialized graph or after heavy changes to it.
      org.eclipse.gef.graph.Node[] getNodes()
      Returns all the nodes that should be laid out.
      boolean isLayoutIrrelevant​(org.eclipse.gef.graph.Edge edge)
      Returns true when the given Edge is not relevant for layout according to the configured layout filters.
      boolean isLayoutIrrelevant​(org.eclipse.gef.graph.Node nodeLayout)
      Returns true when the given Node is not relevant for layout according to the configured layout filters.
      javafx.beans.property.ObjectProperty<ILayoutAlgorithm> layoutAlgorithmProperty()
      A property representing the layout algorithm used by this LayoutContext.
      void postLayout()
      Initiated by the context or by an ILayoutAlgorithm to perform steps that are scheduled to be run after the layout pass.
      void preLayout()
      Initiated by the context or by an ILayoutAlgorithm to perform steps that are scheduled to be run before the layout pass.
      void removeLayoutFilter​(ILayoutFilter layoutFilter)
      Removes the given ILayoutFilter from this LayoutContext.
      void schedulePostLayoutPass​(java.lang.Runnable runnable)
      Adds the given Runnable to the list of runnables which are called when this LayoutContext is asked to apply all changes made to its elements to the display.
      void schedulePreLayoutPass​(java.lang.Runnable runnable)
      Adds the given Runnable to the list of Runnables which are executed before applying a layout, i.e. before applyLayout(boolean).
      void setGraph​(org.eclipse.gef.graph.Graph graph)
      Sets the graph that is to be layouted by this context.
      void setLayoutAlgorithm​(ILayoutAlgorithm algorithm)
      Sets the layout algorithm for this context.
      void unschedulePostLayoutPass​(java.lang.Runnable runnable)
      Removes the given Runnable from the list of runnables which are called when this LayoutContext is asked to apply all changes made to its elements to the display.
      void unschedulePreLayoutPass​(java.lang.Runnable runnable)
      Removes the given Runnable from the list of Runnables which are executed before applying a layout, i.e. before applyLayout(boolean).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LAYOUT_ALGORITHM_PROPERTY

        public static final java.lang.String LAYOUT_ALGORITHM_PROPERTY
        An LayoutContext notifies registered listeners about changes to the layout algorithm using this property name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LayoutContext

        public LayoutContext()
    • Method Detail

      • addLayoutFilter

        public void addLayoutFilter​(ILayoutFilter layoutFilter)
        Adds the given ILayoutFilter to this LayoutContext.
        Parameters:
        layoutFilter - The ILayoutFilter to add to this context.
      • applyLayout

        public void applyLayout​(boolean clear)
        Applies the layout algorithm of this LayoutContext. The clean flag is passed-in to the layout algorithm to indicate whether the context changed significantly since the last layout pass.
        Parameters:
        clear - true to indicate that the algorithm has to fully re-compute the layout, otherwise false.
      • postLayout

        public void postLayout()
        Initiated by the context or by an ILayoutAlgorithm to perform steps that are scheduled to be run after the layout pass. Should not be called by clients.
      • preLayout

        public void preLayout()
        Initiated by the context or by an ILayoutAlgorithm to perform steps that are scheduled to be run before the layout pass. Should not be called by clients.
      • getGraph

        public org.eclipse.gef.graph.Graph getGraph()
        Returns the graph that is to be layouted.
        Returns:
        The Graph that is to be layouted.
      • setGraph

        public void setGraph​(org.eclipse.gef.graph.Graph graph)
        Sets the graph that is to be layouted by this context.
        Parameters:
        graph - The Graph to layout.
      • getNodes

        public org.eclipse.gef.graph.Node[] getNodes()
        Returns all the nodes that should be laid out. Replacing elements in the returned array does not affect this context.
        Returns:
        array of nodes to lay out
      • getEdges

        public org.eclipse.gef.graph.Edge[] getEdges()
        Returns all the connections between nodes that should be laid out. Replacing elements in the returned array does not affect this context.
        Returns:
        array of connections between nodes
      • getLayoutAlgorithm

        public ILayoutAlgorithm getLayoutAlgorithm()
        Returns the static layout algorithm used to layout a newly initialized graph or after heavy changes to it.
        Returns:
        The layout algorithm that is used by this LayoutContext.
      • isLayoutIrrelevant

        public boolean isLayoutIrrelevant​(org.eclipse.gef.graph.Edge edge)
        Returns true when the given Edge is not relevant for layout according to the configured layout filters. Otherwise returns false.
        Parameters:
        edge - The Edge in question.
        Returns:
        true when the given Edge is not relevant for layout according to the configure layout filters, otherwise false.
      • isLayoutIrrelevant

        public boolean isLayoutIrrelevant​(org.eclipse.gef.graph.Node nodeLayout)
        Returns true when the given Node is not relevant for layout according to the configured layout filters. Otherwise returns false.
        Parameters:
        nodeLayout - The Node in question.
        Returns:
        true when the given Node is not relevant for layout according to the configure layout filters, otherwise false.
      • removeLayoutFilter

        public void removeLayoutFilter​(ILayoutFilter layoutFilter)
        Removes the given ILayoutFilter from this LayoutContext.
        Parameters:
        layoutFilter - The ILayoutFilter to remove to this context.
      • schedulePostLayoutPass

        public void schedulePostLayoutPass​(java.lang.Runnable runnable)
        Adds the given Runnable to the list of runnables which are called when this LayoutContext is asked to apply all changes made to its elements to the display.
        Parameters:
        runnable - A Runnable called whenever this context is asked to apply all changes made to its elements to the display.
      • schedulePreLayoutPass

        public void schedulePreLayoutPass​(java.lang.Runnable runnable)
        Adds the given Runnable to the list of Runnables which are executed before applying a layout, i.e. before applyLayout(boolean).
        Parameters:
        runnable - The Runnable to add to the list of Runnables which are executed before applying a layout.
      • unschedulePostLayoutPass

        public void unschedulePostLayoutPass​(java.lang.Runnable runnable)
        Removes the given Runnable from the list of runnables which are called when this LayoutContext is asked to apply all changes made to its elements to the display.
        Parameters:
        runnable - The Runnable that should no longer get called when flushing changes.
      • unschedulePreLayoutPass

        public void unschedulePreLayoutPass​(java.lang.Runnable runnable)
        Removes the given Runnable from the list of Runnables which are executed before applying a layout, i.e. before applyLayout(boolean).
        Parameters:
        runnable - The Runnable to remove from the list of Runnables which are executed before applying a layout.