Search this API

y.io.graphml.layout
Class GroupingBasedHierarchySupport

java.lang.Object
  extended by y.io.graphml.layout.GroupingBasedHierarchySupport
All Implemented Interfaces:
HierarchySupport

public class GroupingBasedHierarchySupport
extends java.lang.Object
implements HierarchySupport

Accesses nesting information stored in Grouping instances for GraphML serialization.

Note, this class only supports group nodes and normal nodes. Folder nodes are not supported

 

Constructor Summary
GroupingBasedHierarchySupport(Grouping grouping)
          Initializes a new GroupingBasedHierarchySupport instance.
 
Method Summary
 NodeList getChildren(GraphMLWriteContext context, Node n)
          Returns the child nodes of the given group node.
 Node getNearestCommonAncestor(GraphMLWriteContext context, Node n1, Node n2)
          Returns the nearest common ancestor node of the two given nodes.
 Node getParent(GraphMLWriteContext context, Node n)
          Returns the parent node of the given node.
 Node getRoot(GraphMLWriteContext context)
          Returns null.
 Node getSourceNode(GraphMLWriteContext context, Edge edge)
          Returns the source node of the given edge.
 Graph getSubgraph(GraphMLWriteContext context, Node n)
          Returns the subgraph that is represented by the given node.
 EdgeList getSubgraphEdges(GraphMLWriteContext context, Graph g)
          Returns all edges that lie completely in the given graph.
 Node getTargetNode(GraphMLWriteContext context, Edge edge)
          Returns the target node of the given edge.
 boolean isLeafNode(GraphMLWriteContext context, Node n)
          Determines whether or not the given node is a normal node.
static GroupingBasedHierarchySupport newInstance(Graph graph)
          Creates a new instance of GroupingBasedHierarchySupport for the given graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupingBasedHierarchySupport

public GroupingBasedHierarchySupport(Grouping grouping)
Initializes a new GroupingBasedHierarchySupport instance.

Parameters:
grouping - the nesting information.
Method Detail

isLeafNode

public boolean isLeafNode(GraphMLWriteContext context,
                          Node n)
Determines whether or not the given node is a normal node.

Specified by:
isLeafNode in interface HierarchySupport
Parameters:
context - The current write context.
n - The node to test.
Returns:
true if the given node is a normal node and false otherwise.

getChildren

public NodeList getChildren(GraphMLWriteContext context,
                            Node n)
Returns the child nodes of the given group node.

Specified by:
getChildren in interface HierarchySupport
Parameters:
context - The current write context.
n - The node to query.
Returns:
a list of all child nodes of the given group node.

getRoot

public Node getRoot(GraphMLWriteContext context)
Returns null.

Specified by:
getRoot in interface HierarchySupport
Parameters:
context - The current write context.
Returns:
null.

getParent

public Node getParent(GraphMLWriteContext context,
                      Node n)
Returns the parent node of the given node.

Specified by:
getParent in interface HierarchySupport
Parameters:
context - The current write context.
n - The node to query.
Returns:
the parent node of the given node or null if the given node is a top-level node.

getNearestCommonAncestor

public Node getNearestCommonAncestor(GraphMLWriteContext context,
                                     Node n1,
                                     Node n2)
Returns the nearest common ancestor node of the two given nodes.

Specified by:
getNearestCommonAncestor in interface HierarchySupport
Parameters:
context - The current write context.
n1 - The first node.
n2 - The second node.
Returns:
the nearest common ancestor node of the two given nodes.

getSubgraphEdges

public EdgeList getSubgraphEdges(GraphMLWriteContext context,
                                 Graph g)
Returns all edges that lie completely in the given graph.

Specified by:
getSubgraphEdges in interface HierarchySupport
Parameters:
context - The current write context.
g - The graph object to query.
Returns:
a list of all edges in the given graph.

getSubgraph

public Graph getSubgraph(GraphMLWriteContext context,
                         Node n)
Returns the subgraph that is represented by the given node.

Specified by:
getSubgraph in interface HierarchySupport
Parameters:
context - The current write context.
n - The node to query.
Returns:
the subgraph that is represented by the given node.

getSourceNode

public Node getSourceNode(GraphMLWriteContext context,
                          Edge edge)
Returns the source node of the given edge.

Specified by:
getSourceNode in interface HierarchySupport
Parameters:
context - The current write context.
edge - The edge to test.
Returns:
the source node of the given edge.

getTargetNode

public Node getTargetNode(GraphMLWriteContext context,
                          Edge edge)
Returns the target node of the given edge.

Specified by:
getTargetNode in interface HierarchySupport
Parameters:
context - The current write context.
edge - The edge to test.
Returns:
the target node of the given edge.

newInstance

public static GroupingBasedHierarchySupport newInstance(Graph graph)
Creates a new instance of GroupingBasedHierarchySupport for the given graph. This method requires GroupingKeys that define the graph's nesting structure.

Parameters:
graph - The graph whose nesting structure is defined by GroupingKeys.
Returns:
a new instance of GroupingBasedHierarchySupport or null if the given graph has no associated GroupingKeys.
See Also:
Grouping.isGrouped(y.base.Graph)

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