de.saar.chorus.jgraph
Class GraphLayoutCursor

Object
  extended by GraphLayoutCursor
All Implemented Interfaces:
NodeCursorInterface

public class GraphLayoutCursor
extends Object

A class to determine the positions of nodes in a graph that is a tree, relative to their direct parents. These positions are stored in a given layout algorithm and converted later on by a GraphDrawingCursor. A subclass of GraphNodeCursor.

Author:
Marco Kuhlmann, Michaela Regneri

Constructor Summary
GraphLayoutCursor(DefaultGraphCell theNode, ImprovedJGraphLayout theLayout, ImprovedJGraph theGraph)
          Creates a new GraphLayoutCursor
GraphLayoutCursor(DefaultGraphCell theNode, ImprovedJGraphLayout theLayout, ImprovedJGraph theGraph, Set<DefaultGraphCell> theNodes)
          Creates a new GraphLayoutCursor
 
Method Summary
 DefaultGraphCell getCurrentNode()
          Returns the recently processed node.
 boolean mayMoveDownwards()
          Checking whether the current node has at least one child.
 boolean mayMoveSidewards()
          Checking whether the current node has a sibling on the right.
 boolean mayMoveUpwards()
          Checking whether the current node has a direct parent node.
 void moveDownwards()
          Moving to the current node's most left child (assuming that there is one).
 void moveSidewards()
          Moving to the current node's right sibling (assuming that there is one).
 void moveUpwards()
          Moving to the current node's parent node (assuming that there is one).
 void processCurrentNode()
          Computes the x- and y-coordinates of the current node, both relative to the direct parent node.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphLayoutCursor

public GraphLayoutCursor(DefaultGraphCell theNode,
                         ImprovedJGraphLayout theLayout,
                         ImprovedJGraph theGraph)
Creates a new GraphLayoutCursor

Parameters:
theNode - the graph root
theLayout - the layout algorithm to store the coordinates
theGraph - the graph to layout

GraphLayoutCursor

public GraphLayoutCursor(DefaultGraphCell theNode,
                         ImprovedJGraphLayout theLayout,
                         ImprovedJGraph theGraph,
                         Set<DefaultGraphCell> theNodes)
Creates a new GraphLayoutCursor

Parameters:
theNode - the graph root
theLayout - the layout algorithm to store the coordinates
theGraph - the graph to layout
theNodes - nodes the layout shall arrange
Method Detail

processCurrentNode

public void processCurrentNode()
Computes the x- and y-coordinates of the current node, both relative to the direct parent node.

Specified by:
processCurrentNode in interface NodeCursorInterface

getCurrentNode

public DefaultGraphCell getCurrentNode()
Returns the recently processed node.

Specified by:
getCurrentNode in interface NodeCursorInterface

mayMoveUpwards

public boolean mayMoveUpwards()
Checking whether the current node has a direct parent node.

Specified by:
mayMoveUpwards in interface NodeCursorInterface
Returns:
true if there is a parent node

moveUpwards

public void moveUpwards()
Moving to the current node's parent node (assuming that there is one).

Specified by:
moveUpwards in interface NodeCursorInterface

mayMoveDownwards

public boolean mayMoveDownwards()
Checking whether the current node has at least one child.

Specified by:
mayMoveDownwards in interface NodeCursorInterface
Returns:
true if there are one ore more children

moveDownwards

public void moveDownwards()
Moving to the current node's most left child (assuming that there is one).

Specified by:
moveDownwards in interface NodeCursorInterface

mayMoveSidewards

public boolean mayMoveSidewards()
Checking whether the current node has a sibling on the right.

Specified by:
mayMoveSidewards in interface NodeCursorInterface
Returns:
true if there is a right sibling

moveSidewards

public void moveSidewards()
Moving to the current node's right sibling (assuming that there is one).

Specified by:
moveSidewards in interface NodeCursorInterface
See Also:
JDomGraph.getRightSibling(DefaultGraphCell node)