y.layout.grouping
Class Grouping

java.lang.Object
  |
  +--y.layout.grouping.Grouping
All Implemented Interfaces:
GroupingKeys

public class Grouping
extends Object
implements GroupingKeys

Instances of this class can be used by algorithms to efficiently query the structure of such type of graphs. The grouping information is provided through DataProviders, whose keys are defined in the GroupingKeys interface.


Field Summary
 
Fields inherited from interface y.layout.grouping.GroupingKeys
GROUP_DPKEY, GROUP_NODE_INSETS_DPKEY, NODE_ID_DPKEY, PARENT_NODE_ID_DPKEY
 
Constructor Summary
Grouping(LayoutGraph graph)
          Creates a new instance of Grouping.
 
Method Summary
protected  NodeMap createInfoMap(LayoutGraph graph)
          factory method for a NodeMap
 void dispose()
          Disposes the datastructures held by this instance.
protected  void disposeInfoMap(LayoutGraph graph, NodeMap infoMap)
          factory desctructor method for a the NodeMap
 NodeList getChildren(Node parent)
          Returns the children of the given group node as a NodeList.
 NodeList getDescendants(Node parent)
          Returns all descendants of the given group node as a NodeList.
 EdgeList getEdgesGoingIn(Node groupNode)
          Convenience method that returns a list of all Edges crossing the group node boundary of the given group node in such a way, that there target is inside the group node and the source does not lie inside the groupnode.
 EdgeList getEdgesGoingOut(Node groupNode)
          Convenience method that returns a list of all Edges crossing the group node boundary of the given group node in such a way, that there target is outside the group node and the source does not lie outside the groupnode.
 LayoutGraph getLayoutGraph()
          Returns the graph instance this object provides information for.
 Node getParent(Node node)
          Returns the parent of the given node or null if the node is at the top of the hierarchy
 Node getRepresentative(Node node, Node inGroup)
          Convenience method that returns the node whica list of all Edges crossing the group node boundary of the given group node in such a way, that there target is outside the group node and the source does not lie outside the groupnode.
 Node getRoot()
          Returns a node instance that can be used as a handle to the virtual root of the node hierarchy.
protected  void init()
          Initializes internal datastructures.
static boolean isFlat(Graph graph)
          A graph is considered to be flat if it is either not grouped or there is no group node that contains child nodes present in the graph.
static boolean isGrouped(Graph graph)
          A graph is considered to be grouped if the three low-level grouping data providers GroupingKeys.GROUP_DPKEY, GroupingKeys.NODE_ID_DPKEY and GroupingKeys.PARENT_NODE_ID_DPKEY are registered.
 boolean isGroupNode(Node node)
          Determines if the given node is a group node.
 boolean isNormalEdge(Edge e)
          Determines if the given Edge is a normal edge, i.e. whether it does not cross any group node boundaries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Grouping

public Grouping(LayoutGraph graph)
Creates a new instance of Grouping. Grouping instances provide a convenient way for all kind of algorithms to traverse the node grouping hierarchy. The hierarchy is cached during the call to this constructor. It is build using the information bound to the graph using the DataProviders that are registered with the graph instance.

Method Detail

init

protected void init()
Initializes internal datastructures. The state of the graph at the moment of this method invocation will be reflected by this instance.


getLayoutGraph

public LayoutGraph getLayoutGraph()
Returns the graph instance this object provides information for.


createInfoMap

protected NodeMap createInfoMap(LayoutGraph graph)
factory method for a NodeMap


disposeInfoMap

protected void disposeInfoMap(LayoutGraph graph,
                              NodeMap infoMap)
factory desctructor method for a the NodeMap


getParent

public Node getParent(Node node)
Returns the parent of the given node or null if the node is at the top of the hierarchy


getRoot

public Node getRoot()
Returns a node instance that can be used as a handle to the virtual root of the node hierarchy. This handle can be given to the getChildren() method to obtain the nodes, that are at the top level of the hierarchy. The instance is *not* part of the graph.


getChildren

public NodeList getChildren(Node parent)
Returns the children of the given group node as a NodeList.


getDescendants

public NodeList getDescendants(Node parent)
Returns all descendants of the given group node as a NodeList.


isGroupNode

public boolean isGroupNode(Node node)
Determines if the given node is a group node. Group nodes *may* have children. Normal nodes never have children.


isNormalEdge

public boolean isNormalEdge(Edge e)
Determines if the given Edge is a normal edge, i.e. whether it does not cross any group node boundaries.


getEdgesGoingIn

public EdgeList getEdgesGoingIn(Node groupNode)
Convenience method that returns a list of all Edges crossing the group node boundary of the given group node in such a way, that there target is inside the group node and the source does not lie inside the groupnode.


getEdgesGoingOut

public EdgeList getEdgesGoingOut(Node groupNode)
Convenience method that returns a list of all Edges crossing the group node boundary of the given group node in such a way, that there target is outside the group node and the source does not lie outside the groupnode.


getRepresentative

public Node getRepresentative(Node node,
                              Node inGroup)
Convenience method that returns the node whica list of all Edges crossing the group node boundary of the given group node in such a way, that there target is outside the group node and the source does not lie outside the groupnode.


dispose

public void dispose()
Disposes the datastructures held by this instance. Calling this method renders this instance useless.


isGrouped

public static boolean isGrouped(Graph graph)
A graph is considered to be grouped if the three low-level grouping data providers GroupingKeys.GROUP_DPKEY, GroupingKeys.NODE_ID_DPKEY and GroupingKeys.PARENT_NODE_ID_DPKEY are registered.

An instance of this class requires its graph to be grouped.


isFlat

public static boolean isFlat(Graph graph)
A graph is considered to be flat if it is either not grouped or there is no group node that contains child nodes present in the graph. This method determines whether a graph is flat


© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003