de.cau.cs.kieler.klay.layered
Class KGraphImporter

java.lang.Object
  extended by de.cau.cs.kieler.klay.layered.AbstractGraphImporter<KNode>
      extended by de.cau.cs.kieler.klay.layered.KGraphImporter
All Implemented Interfaces:
IGraphImporter<KNode>
Direct Known Subclasses:
CompoundKGraphImporter

public class KGraphImporter
extends AbstractGraphImporter<KNode>

Manages the transformation of KGraphs to LayeredGraphs. Sets the Properties.GRAPH_PROPERTIES property on imported graphs.

Rating red

Constructor Summary
KGraphImporter()
           
 
Method Summary
 void applyLayout(LayeredGraph layeredGraph)
          Apply the computed layout of the given layered graph to the original input graph.
protected  void clip(KVector endpoint, KVector portSize, KVector next)
          KLay Layered aligns ports at their center.
 LayeredGraph importGraph(KNode kgraph)
          Create a layered graph from the given graph.
protected  void transformEdge(KEdge kedge, KNode graph, Map<KGraphElement,LGraphElement> elemMap, MapPropertyHolder layeredGraph)
          Transforms the given edge.
protected  void transformNode(KNode node, List<LNode> layeredNodes, Map<KGraphElement,LGraphElement> elemMap, Set<GraphProperties> graphProperties, Direction direction)
          Transforms the given node.
 
Methods inherited from class de.cau.cs.kieler.klay.layered.AbstractGraphImporter
createExternalPortDummy, getExternalPortPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KGraphImporter

public KGraphImporter()
Method Detail

importGraph

public LayeredGraph importGraph(KNode kgraph)
Create a layered graph from the given graph.

Parameters:
kgraph - the graph to turn into a layered graph.
Returns:
a layered graph, or null if the input was not recognized

transformNode

protected void transformNode(KNode node,
                             List<LNode> layeredNodes,
                             Map<KGraphElement,LGraphElement> elemMap,
                             Set<GraphProperties> graphProperties,
                             Direction direction)
Transforms the given node.

Parameters:
node - the node to transform.
layeredNodes - the list of nodes to add the transformed node to.
elemMap - the element map that maps the original KGraph elements to the transformed LGraph elements.
graphProperties - graph properties updated during the transformation.
direction - the overall layout direction

transformEdge

protected void transformEdge(KEdge kedge,
                             KNode graph,
                             Map<KGraphElement,LGraphElement> elemMap,
                             MapPropertyHolder layeredGraph)
Transforms the given edge.

Parameters:
kedge - the edge to transform.
graph - the original graph.
elemMap - the element map that maps the original KGraph elements to the transformed LGraph elements.
layeredGraph - the layeredGraph.

applyLayout

public void applyLayout(LayeredGraph layeredGraph)
Apply the computed layout of the given layered graph to the original input graph.
Precondition:
the graph has all its dummy nodes and edges removed; edges that were reversed during layout have been restored to their original orientation
Postcondition:
none

Parameters:
layeredGraph - a graph for which layout is applied

clip

protected void clip(KVector endpoint,
                    KVector portSize,
                    KVector next)
KLay Layered aligns ports at their center. Incident edges must be clipped on the port's border.

Parameters:
endpoint - an endpoint of an edge
portSize - the size of the corresponding port
next - the next point on the edge's path