|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmapss.dif.graph.hierarchy.Hierarchy
public class Hierarchy
Hierarchy class is a wrapper around a mocgraph.Graph
object
for implementing hierarchical features. These features include defining ports
for connecting a graph as a subgraph and defining connections between a
parent (super) graph and a child (sub) graph.
For more information about how to use this class refer to the package documentation.
Graph
Field Summary | |
---|---|
protected mocgraph.Graph |
_graph
Underlying graph of this hierarchy. |
protected java.lang.String |
_hierarchyName
Name of the hierarchy. |
protected Hierarchy |
_parent
Parent of this graph (if it is set as a sub-graph of another hierarchy). |
protected PortList |
_ports
Ports of this hierarchy. |
protected SuperNodeMap |
_superNodes
Maps super nodes (type: Node) to sub-graphs (type: Hierarchy). |
Constructor Summary | |
---|---|
Hierarchy(mocgraph.Graph graph)
Construct a hierarchy object with the name "_hierarchy". |
|
Hierarchy(mocgraph.Graph graph,
java.lang.String name)
Construct a hierarchy object with a name. |
Method Summary | |
---|---|
protected mocgraph.Edge |
_copyEdge(mocgraph.Edge edge,
mocgraph.Node source,
mocgraph.Node sink)
Returns a copy of the edge with the given source and sink nodes as well as adding the new edge to the underlying graph. |
protected mocgraph.Graph |
_graphType()
Returns an empty graph of the most general type that this object can use as its backing graph. |
protected mocgraph.analysis.strategy.MirrorTransformerStrategy |
_mirrorGraph(mocgraph.Graph graph)
Returns a mirror transformation for the backing graph, which will be used in the mirror(boolean) function. |
protected void |
_putSuperNode(mocgraph.Node node,
Hierarchy hierarchy)
Put supernode to sub-hierarchy mapping in superNodeMap without disconnecting sub-hierarchy. |
protected void |
_removeSuperNode(mocgraph.Node node)
Remove supernode to sub-hierarchy mapping in superNodeMap without disconnecting sub-hierarchy. |
void |
addSuperNode(mocgraph.Node node,
Hierarchy hierarchy)
Converts a node to a super node. |
boolean |
deepFlatten()
Flattens this hierarchy all the way down to its bottom. |
java.util.List |
deepPurge()
Runs purge() deep into the bottom of this hierarchy. |
void |
disconnect()
Disconnects this hierarchy from its super hierarchy. |
void |
disconnectSuperNode(mocgraph.Node node)
Disconnects a sub-hierarchy from this hierarchy. |
boolean |
flatten()
Flattens all the super nodes on this level of the hierarchy. |
Hierarchy |
flatten(mocgraph.Node superNode)
Flattens a super node by merging its sub-graph to this graph. |
mocgraph.Graph |
getGraph()
Returns the graph object that backs this hierarchy. |
java.lang.String |
getName()
Returns the name of this hierarchy. |
Hierarchy |
getParent()
Returns the hierarchy in which this hierarchy is defined as a sub-hierarchy. |
PortList |
getPorts()
Returns the list of ports in this hierarchy. |
SuperNodeMap |
getSuperNodes()
Returns a map of nodes that are defined as super nodes. |
mocgraph.DirectedAcyclicGraph |
hierarchyGraph()
Returns a DAG representation of the hierarchy structure (i.e. |
boolean |
isDirected()
Returns true if the hierarchy contains at least one directed port. |
Hierarchy |
mirror(boolean cloneWeights)
Mirrors a hierarchy without copying the information about its parent so it can be connected to another parent. |
java.util.List |
purge()
Checks if all super nodes in this hierarchy can be flattened. |
java.lang.String |
setName(java.lang.String name)
Sets the name of the hierarchy to a new string. |
java.lang.String |
toString()
Returns the basic information about this hierarchy. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected mocgraph.Graph _graph
protected java.lang.String _hierarchyName
protected PortList _ports
protected SuperNodeMap _superNodes
protected Hierarchy _parent
Constructor Detail |
---|
public Hierarchy(mocgraph.Graph graph)
graph
- The graph object that backs the hierarchy.public Hierarchy(mocgraph.Graph graph, java.lang.String name)
graph
- The graph object that backs the hierarchy.name
- Name of the hierarchy.
HierarchyException
- If
Conventions.labelConvention(java.lang.String)
returns an error.Method Detail |
---|
public void addSuperNode(mocgraph.Node node, Hierarchy hierarchy)
node
- Super node.hierarchy
- Sub-hierarchy to be associated with the node.
HierarchyException
- If
HierarchyException.checkSuperNode(mapss.dif.graph.hierarchy.Hierarchy, mapss.dif.graph.hierarchy.Hierarchy)
returns an exception.
CyclicHierarchyException
- If a cycle is detected in the
hierarchy structure.
(Checked by CyclicHierarchyException.checkCycle(mapss.dif.graph.hierarchy.Hierarchy, mapss.dif.graph.hierarchy.Hierarchy)
)public boolean deepFlatten()
HierarchyException
- If any of the individual flatten
operations throw an exception.deepPurge()
public java.util.List deepPurge()
purge()
deep into the bottom of this hierarchy. After this
operation deepFlatten()
can be called with no exceptions.
public void disconnect()
parent.disconnectSuperNode(node)
in which node is
the super node of this hierarchy. It does nothing if this hierarchy has
no super hierarchy.
public void disconnectSuperNode(mocgraph.Node node)
child.disconnect()
. It does nothing if the node is
not a super node.
node
- A super node in this hierarchy.public boolean flatten()
HierarchyException
- If any of the individual flatten
operations throw an exception.purge()
public Hierarchy flatten(mocgraph.Node superNode)
superNode
- A super node in this hierarchy.
HierarchyException
- If an exception is returned
by HierarchyException.checkFlatten(mapss.dif.graph.hierarchy.Hierarchy, mocgraph.Node)
.public mocgraph.Graph getGraph()
public java.lang.String getName()
public Hierarchy getParent()
public PortList getPorts()
public SuperNodeMap getSuperNodes()
public mocgraph.DirectedAcyclicGraph hierarchyGraph()
node(A)
to node(B)
) starting from this graph.
HierarchyToDot.hierarchyGraphToDot(mapss.dif.graph.hierarchy.Hierarchy)
public boolean isDirected()
public Hierarchy mirror(boolean cloneWeights)
The backing graph is mirrored using
MirrorTransformerStrategy
.
Necessary edge and node conversions are done using
transformedVersionOf
of the transformer object.
All ports are mirrored
using Port.mirror(mapss.dif.graph.hierarchy.Hierarchy, mocgraph.analysis.strategy.MirrorTransformerStrategy)
.
cloneWeights
- Weights of the nodes and edges will be cloned if
true.
public java.util.List purge()
flatten()
can be called with no exceptions.
HierarchyException.checkFlatten(mapss.dif.graph.hierarchy.Hierarchy, mocgraph.Node)
public java.lang.String setName(java.lang.String name)
name
- New name.
HierarchyException
- If this is a sub-hierarchy and its parent
already has another hierarchy with the same name. This check is
performed
using SuperNodeMap.isDefined(java.lang.String)
.public java.lang.String toString()
toString
in class java.lang.Object
protected mocgraph.Edge _copyEdge(mocgraph.Edge edge, mocgraph.Node source, mocgraph.Node sink)
edge
- Original edge.source
- New source node.sink
- New sink node.
protected mocgraph.Graph _graphType()
Graph
.protected mocgraph.analysis.strategy.MirrorTransformerStrategy _mirrorGraph(mocgraph.Graph graph)
mirror(boolean)
function. This implementation returns a
MirrorTransformerStrategy
object. In case that a special type of graph backs an extension
of the Hierarchy class, this method can be overridden to return the
transformer of that class.
graph
- The graph to be mirrored.
protected void _putSuperNode(mocgraph.Node node, Hierarchy hierarchy)
addSuperNode(mocgraph.Node, mapss.dif.graph.hierarchy.Hierarchy)
instead.
node
- Super node.hierarchy
- Sub-hierarchy to be associated with the node.
HierarchyException
- If
HierarchyException.checkSuperNode(mapss.dif.graph.hierarchy.Hierarchy, mapss.dif.graph.hierarchy.Hierarchy)
returns an exception.
CyclicHierarchyException
- If a cycle is detected in the
hierarchy structure.
(Checked by CyclicHierarchyException.checkCycle(mapss.dif.graph.hierarchy.Hierarchy, mapss.dif.graph.hierarchy.Hierarchy)
)protected void _removeSuperNode(mocgraph.Node node)
disconnectSuperNode(mocgraph.Node)
instead.
node
- A super node in this hierarchy.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |