Module imp2d

Class Layout.Algorithm

java.lang.Object
de.grogra.imp2d.layout.Layout.Algorithm
Direct Known Subclasses:
ForceBasedLayout.FBAlgorithm, ForceBasedLayout2.FBAlgorithm2, HierarchyLayout.HAlgorithm
Enclosing class:
Layout

public abstract class Layout.Algorithm extends Object
An Algorithm is created by a Layout in order to perform the actual layout task. It may use the fields of the layout instance as algorithm parameters.
Author:
Ole Kniemeyer
  • Field Details

    • state

      protected GraphState state
    • graph

      protected Graph graph
    • finalGraph

      protected Graph finalGraph
    • view

      protected View2D view
  • Constructor Details

    • Algorithm

      public Algorithm()
  • Method Details

    • layout

      protected abstract void layout(Node nodes)
      This method has to be implemented to perform the layout.
      Parameters:
      nodes - the first node of the linked list of all nodes
      See Also:
    • acceptNode

      protected boolean acceptNode(Object node)
      Determines whether a given node of the original graph is to be included in the layout graph.
      Parameters:
      node - a node of the original graph
      Returns:
      true iff the node is to be included in layout
    • invokeLayout

      public final void invokeLayout(Layout layout, Node nodes)
      Delegates layouting to another layout. This method initializes an algorithm created by layout with the current context and graph information and invokes layout(Node) on the created algorithm. This method may only be invoked by an active algorithm, i.e., only within layout(Node).
      Parameters:
      layout - another layout to be used
      nodes - the linked list of layout nodes
    • setProgress

      protected void setProgress(float progress, String text)
      This method sets the status bar of the UI.
      Parameters:
      progress - a value indicating the progress of the algorithm
      text - a text to show in the status bar
    • getGlobalMaxBounds

      protected Vector2d getGlobalMaxBounds(Node nodes)
      Getting the highest value (absolute) of height and width of the nodes
      Parameters:
      nodes -
      Returns:
    • getGlobalMaxDistances

      protected Vector2d getGlobalMaxDistances(Node nodes)
      Getting the longest distance (absolute) from nodes of the graph
      Parameters:
      nodes -
      Returns:
    • getGlobalMaxCoordinates

      protected Vector2d getGlobalMaxCoordinates(Node nodes)
      Getting the most differing x- and y-coordinates from point (0,0)
      Parameters:
      nodes -
      Returns:
    • getGlobalMaxCoordinates

      protected Vector2d getGlobalMaxCoordinates(Node nodes, Node rootNode)
      Getting the most differing x- and y-coordinates (absolute) from rootNode
      Parameters:
      nodes -
      Returns:
    • fitLayoutToWindow

      protected void fitLayoutToWindow(Node nodes, int param)
      rotates and scales a graph to fit in the drawing window possibility for choosing the param: 0 -> the first node will be arranged in the centre of the drawing window, then zooming else -> calculating the max distance in the graph, then zooming
      Parameters:
      nodes -
      param -
    • getCommandName

      public String getCommandName()