ptolemy.vergil.basic.layout.kieler
Class KielerGraphUtil

java.lang.Object
  extended by ptolemy.vergil.basic.layout.kieler.KielerGraphUtil

public class KielerGraphUtil
extends java.lang.Object

Static helper class to work with KIELER graph datastructures.

Since:
Ptolemy II 8.0
Version:
$Id: KielerGraphUtil.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Hauke Fuhrmann,
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Constructor Summary
KielerGraphUtil()
           
 
Method Summary
protected static de.cau.cs.kieler.kiml.layout.klayoutdata.KPoint _getAbsoluteKPoint(de.cau.cs.kieler.kiml.layout.klayoutdata.KPoint relativeKPoint, de.cau.cs.kieler.core.kgraph.KNode parentNode)
          Get the absolute position of a point, i.e. the absolute position instead of relative to the top left corner of the parent node.
protected static de.cau.cs.kieler.kiml.layout.klayoutdata.KShapeLayout _getAbsoluteLayout(de.cau.cs.kieler.core.kgraph.KNode node)
          Get the absolute layout of a Kieler KNode, i.e. a layout containing an absolute position of the top left corner of the node instead of something relative to only its parent node.
protected static de.cau.cs.kieler.core.kgraph.KNode _getParent(de.cau.cs.kieler.core.kgraph.KEdge edge)
          Get the parent node of an Kieler KEdge.
protected static de.cau.cs.kieler.kiml.layout.klayoutdata.KPoint _getUpperLeftCorner(de.cau.cs.kieler.core.kgraph.KNode parent)
          Get the upper left corner of the real bounding box of the contents of a given Kieler KNode.
protected static java.awt.geom.Point2D _shrinkCoordinates(java.awt.geom.Rectangle2D originalBounds, java.awt.geom.Rectangle2D shrunkBounds, int direction, float offset)
          Reposition a small object in a big object according to a given direction (NORTH, EAST, SOUTH, WEST).
protected static java.lang.String _toString(de.cau.cs.kieler.core.kgraph.KEdge edge)
          Debug output a KEdge to a String, i.e. will represent all bendpoints in the String.
protected static java.lang.String _toString(de.cau.cs.kieler.core.kgraph.KNode knode)
          Debug output a KNode to a String, i.e. will represent the whole subgraph starting with this node recursively and also present all outgoing edges of all nodes.
protected static java.lang.String _toString(de.cau.cs.kieler.core.kgraph.KNode knode, int level)
          Debug output a KNode to a String, i.e. will represent the whole subgraph starting with this node recursively and also present all outgoing edges of all nodes.
protected static void _writeToFile(de.cau.cs.kieler.core.kgraph.KNode kgraph)
          Write a KGraph (Kieler graph datastructure) to a file in its XMI representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KielerGraphUtil

public KielerGraphUtil()
Method Detail

_getAbsoluteLayout

protected static de.cau.cs.kieler.kiml.layout.klayoutdata.KShapeLayout _getAbsoluteLayout(de.cau.cs.kieler.core.kgraph.KNode node)
Get the absolute layout of a Kieler KNode, i.e. a layout containing an absolute position of the top left corner of the node instead of something relative to only its parent node.

Parameters:
node - The KNode of which to retrieve the absolute layout.
Returns:
A shape layout containing the original size of the node and its location in absolute coordinates (not relative to its parent)

_getAbsoluteKPoint

protected static de.cau.cs.kieler.kiml.layout.klayoutdata.KPoint _getAbsoluteKPoint(de.cau.cs.kieler.kiml.layout.klayoutdata.KPoint relativeKPoint,
                                                                                    de.cau.cs.kieler.core.kgraph.KNode parentNode)
Get the absolute position of a point, i.e. the absolute position instead of relative to the top left corner of the parent node.

Parameters:
relativeKPoint - Point with coordinates relative to its parent node.
parentNode - Parent node of the point coordinates.
Returns:
Kieler KPoint with the absolute coordinates.

_getParent

protected static de.cau.cs.kieler.core.kgraph.KNode _getParent(de.cau.cs.kieler.core.kgraph.KEdge edge)
Get the parent node of an Kieler KEdge. That is the Kieler KNode that graphically contains the edge. In particular that is the parent node of the source node of the edge. If the source node is null, then the result is also null.

Parameters:
edge - The Kieler KEdge to determine the parent node.
Returns:
The parent Kieler KNode of the given edge or null if the source of the edge is undefined.

_getUpperLeftCorner

protected static de.cau.cs.kieler.kiml.layout.klayoutdata.KPoint _getUpperLeftCorner(de.cau.cs.kieler.core.kgraph.KNode parent)
Get the upper left corner of the real bounding box of the contents of a given Kieler KNode. Calculate the minimal x and y coordinates of all nodes contained in the given node.

Parameters:
parent - The composite Kieler KNode that contains other nodes.
Returns:
The minimal x and y coordinates of all contained nodes. Might be Float.MAX_VALUE, if the parent does not contain any children.

_shrinkCoordinates

protected static java.awt.geom.Point2D _shrinkCoordinates(java.awt.geom.Rectangle2D originalBounds,
                                                          java.awt.geom.Rectangle2D shrunkBounds,
                                                          int direction,
                                                          float offset)
Reposition a small object in a big object according to a given direction (NORTH, EAST, SOUTH, WEST). The small object will be aligned to the big object's direction side and centered on the other coordinate.

Parameters:
originalBounds - Big object's bounds
shrunkBounds - Small object's bounds
direction - Direction of the small object within the big object given by a SwingConstants direction constant
offset - Offset of the lower bound of the port
Returns:
New location of the small object.

_toString

protected static java.lang.String _toString(de.cau.cs.kieler.core.kgraph.KEdge edge)
Debug output a KEdge to a String, i.e. will represent all bendpoints in the String.

Parameters:
edge - The edge to be toStringed
Returns:
A String representing the KEdge

_toString

protected static java.lang.String _toString(de.cau.cs.kieler.core.kgraph.KNode knode)
Debug output a KNode to a String, i.e. will represent the whole subgraph starting with this node recursively and also present all outgoing edges of all nodes.

Parameters:
knode - The node to be toStringed
Returns:
A String representing the KNode

_toString

protected static java.lang.String _toString(de.cau.cs.kieler.core.kgraph.KNode knode,
                                            int level)
Debug output a KNode to a String, i.e. will represent the whole subgraph starting with this node recursively and also present all outgoing edges of all nodes.

Parameters:
knode - The node to be toStringed
level - Tree level of the currently processed element. Used for recursive operation.
Returns:
A String representing the KNode

_writeToFile

protected static void _writeToFile(de.cau.cs.kieler.core.kgraph.KNode kgraph)
Write a KGraph (Kieler graph datastructure) to a file in its XMI representation. Can be used for debugging (manually look at it) or loading it elsewhere, e.g. a KIELER Graph viewer. The default filename is kgraph.xmi and will be written to the current working directory.

Parameters:
kgraph - The Kieler Graph datastructure given by its root KNode.