Search this API

y.io.graphml.graph2d
Class HierarchyManagerBasedHierarchySupport

java.lang.Object
  extended by y.io.graphml.graph2d.HierarchyManagerBasedHierarchySupport
All Implemented Interfaces:
HierarchySupport

public class HierarchyManagerBasedHierarchySupport
extends java.lang.Object
implements HierarchySupport

Implementation of HierarchySupport that uses a HierarchyManager instance to retrieve the hierarchy information.

 
Your browser does not support SVG content.

Constructor Summary
HierarchyManagerBasedHierarchySupport(HierarchyManager hierarchyManager)
          Create a new instance which is backed up by hierarchyManager.
HierarchyManagerBasedHierarchySupport(HierarchyManager hierarchyManager, Graph root)
          Initializes a new instance of HierarchyManagerBasedHierarchySupport.
 
Method Summary
 NodeList getChildren(GraphMLWriteContext context, Node parent)
          Returns the child nodes of a group/folder nodes.
 Node getNearestCommonAncestor(GraphMLWriteContext context, Node node, Node node1)
          Returns the nearest common ancestor node of n1 and n2.
 Node getParent(GraphMLWriteContext context, Node n)
          Gets the parent node of n.
 Node getRoot(GraphMLWriteContext context)
          Gets the root node of a hierarchy.
 Node getSourceNode(GraphMLWriteContext context, Edge edge)
          Returns the source node of edge.
 Graph getSubgraph(GraphMLWriteContext context, Node n)
          Gets the subgraph object that is represented by the node n.
 EdgeList getSubgraphEdges(GraphMLWriteContext context, Graph g)
          Returns all edges that lie completely in g.
 Node getTargetNode(GraphMLWriteContext context, Edge edge)
          Returns the target node of edge.
 boolean isLeafNode(GraphMLWriteContext context, Node n)
          Returns whether n is a leaf node or a group/folder node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HierarchyManagerBasedHierarchySupport

public HierarchyManagerBasedHierarchySupport(HierarchyManager hierarchyManager)
Create a new instance which is backed up by hierarchyManager.

Invoking this constructor is equivalent to:

new HierarchyManagerBasedHierarchySupport(hierarchyManager, hierarchyManager.getRootGraph())

Parameters:
hierarchyManager - The HierarchyManager that provides the hierarchy data.

HierarchyManagerBasedHierarchySupport

public HierarchyManagerBasedHierarchySupport(HierarchyManager hierarchyManager,
                                             Graph root)
Initializes a new instance of HierarchyManagerBasedHierarchySupport.

Parameters:
hierarchyManager - the hierarchy information.
root - the graph to be used as root for the graph hierarchy. Must be a graph that is contained in the given hierarchy.
Method Detail

isLeafNode

public boolean isLeafNode(GraphMLWriteContext context,
                          Node n)
Description copied from interface: HierarchySupport
Returns whether n is a leaf node or a group/folder node.

Specified by:
isLeafNode in interface HierarchySupport
Parameters:
context - The current write context.
n - The node to test.
Returns:
true iff n is a leaf node, false if it's a group or folder node.

getChildren

public NodeList getChildren(GraphMLWriteContext context,
                            Node parent)
Description copied from interface: HierarchySupport
Returns the child nodes of a group/folder nodes.

If n is not a group node, the result is undefined.

Specified by:
getChildren in interface HierarchySupport
Parameters:
context - The current write context.
parent - The node to query.
Returns:
The child nodes of n.

getRoot

public Node getRoot(GraphMLWriteContext context)
Description copied from interface: HierarchySupport
Gets the root node of a hierarchy.

This may be null depending on the actual implementation and therefore should be used only as a handle for further queries on the hierarchy.

Specified by:
getRoot in interface HierarchySupport
Parameters:
context - The current write context.
Returns:
The root node of a hierarchy.

getParent

public Node getParent(GraphMLWriteContext context,
                      Node n)
Description copied from interface: HierarchySupport
Gets the parent node of n.

The result is guaranteed to be either group or folder node, or the root of the hierarchy as returned by HierarchySupport.getRoot(GraphMLWriteContext)

Specified by:
getParent in interface HierarchySupport
Parameters:
context - The current write context.
n - The node to query.
Returns:
The parent node of n.

getNearestCommonAncestor

public Node getNearestCommonAncestor(GraphMLWriteContext context,
                                     Node node,
                                     Node node1)
Description copied from interface: HierarchySupport
Returns the nearest common ancestor node of n1 and n2.

This method always returns parent nodes of n1 and n2, even if n1 is a child of n2 or the other way round.

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

getSubgraphEdges

public EdgeList getSubgraphEdges(GraphMLWriteContext context,
                                 Graph g)
Description copied from interface: HierarchySupport
Returns all edges that lie completely in g.

Specified by:
getSubgraphEdges in interface HierarchySupport
Parameters:
context - The current write context.
g - The graph object to query.
Returns:
All edges that lie completely in g.

getSubgraph

public Graph getSubgraph(GraphMLWriteContext context,
                         Node n)
Description copied from interface: HierarchySupport
Gets the subgraph object that is represented by the node n.

This instance is only meaningful for containment queries like Graph.contains(y.base.Node) and should not be used by code outside the core writing process.

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

getSourceNode

public Node getSourceNode(GraphMLWriteContext context,
                          Edge edge)
Description copied from interface: HierarchySupport
Returns the source node of edge.

In case of folder nodes, this is the real source node.

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

getTargetNode

public Node getTargetNode(GraphMLWriteContext context,
                          Edge edge)
Description copied from interface: HierarchySupport
Returns the target node of edge.

In case of folder nodes, this is the real target node.

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

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