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

java.lang.Object
  extended by de.cau.cs.kieler.klay.layered.Util

public final class Util
extends Object

Contains utility methods used throughout KLay Layered.

Rating red

Method Summary
static void centerPoint(KVector point, KVector boundary, PortSide side)
          Center the given point on one side of a boundary.
static LinkedList<LNode> getChildren(LNode node)
          Get the given node's children list.
static String getDebugOutputFileBaseName(LayeredGraph graph)
          Returns the beginning of the file name used for debug output graphs while layouting the given layered graph.
static String getDebugOutputPath()
          Returns the path for debug output graphs.
static LGraphElement getParent(LNode child)
          Finds and returns the given node's parent's representative in the LayeredGraph.
static LNode getRelatedCompoundNode(LNode node, LayeredGraph layeredGraph)
          Get the compound node an LNode belongs to.
static boolean isDescendant(LNode child, LNode parent)
          Determines whether the given child node is a descendant of the parent node.
static void propagatePair(LinkedList<LNode> sourceTargetList, HashMap<KGraphElement,LGraphElement> elemMap)
          Finds for a pair of LNodes the pair of ancestors with a common parent that is highest in depth in the inclusion tree.
static LPort provideCollectorPort(LNode node, PortType type, PortSide side)
          Return a collector port of given type, creating it if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

centerPoint

public static void centerPoint(KVector point,
                               KVector boundary,
                               PortSide side)
Center the given point on one side of a boundary.

Parameters:
point - a point to change
boundary - the boundary to use for centering
side - the side of the boundary

provideCollectorPort

public static LPort provideCollectorPort(LNode node,
                                         PortType type,
                                         PortSide side)
Return a collector port of given type, creating it if necessary. A collector port is used to merge all incident edges that originally had no ports.

Parameters:
node - a node
type - if INPUT, an input collector port is returned; if OUTPUT, an output collector port is returned
side - the side to set for a newly created port
Returns:
a collector port

getDebugOutputPath

public static String getDebugOutputPath()
Returns the path for debug output graphs.

Returns:
the path for debug output graphs, without trailing separator.

getDebugOutputFileBaseName

public static String getDebugOutputFileBaseName(LayeredGraph graph)
Returns the beginning of the file name used for debug output graphs while layouting the given layered graph. This will look something like "143293-".

Parameters:
graph - the graph to return the base debug file name for.
Returns:
the base debug file name for the given graph.

isDescendant

public static boolean isDescendant(LNode child,
                                   LNode parent)
Determines whether the given child node is a descendant of the parent node.

Parameters:
child - a child node
parent - a parent node
Returns:
true if child is a direct or indirect child of parent

getParent

public static LGraphElement getParent(LNode child)
Finds and returns the given node's parent's representative in the LayeredGraph.

Parameters:
child - the node for which the parent representative is to be found.
Returns:
returns the LGraphElement representing the parent of the given node in the original graph. Returned element can be instance of LayeredGraph (in case the given Node is of depth level one, that is directly contained by the layered graph) or LNode (any other case).

getChildren

public static LinkedList<LNode> getChildren(LNode node)
Get the given node's children list. If the node is not of NodeType NORMAL oder UPPER_COMPOUND_BORDER and therefore directly representing a node of the original graph, get the children-list of the related compound border dummy.

Parameters:
node - the LNode, for which the children are to be returned
Returns:
the list of the representatives of the represented node's children.

getRelatedCompoundNode

public static LNode getRelatedCompoundNode(LNode node,
                                           LayeredGraph layeredGraph)
Get the compound node an LNode belongs to.

Parameters:
node - The LNode for which the corresponding compound node is to be returned.
layeredGraph - The layered Graph, which is to be laid out.
Returns:
Returns: A. The parent node for a leave node, if it is not a node of the uppermost hierarchy level- in that case, null will be returned. B. The compound node of which's representation the node is part of for compound dummies. C. The node enclosing the represented LGraphElement for dummies of another kind. Null, if represented LGraphElement is of depth 1. D. null in default case.

propagatePair

public static void propagatePair(LinkedList<LNode> sourceTargetList,
                                 HashMap<KGraphElement,LGraphElement> elemMap)
Finds for a pair of LNodes the pair of ancestors with a common parent that is highest in depth in the inclusion tree. Each of the ancestors may be the given node itself.

Parameters:
sourceTargetList - The pair of nodes is handed over as a List. The pair of ancestors will be stored in the same list.
elemMap - The element map that maps the original KGraphElements to the LGraphElements.