ptolemy.vergil.basic.layout.kieler
Class KielerLayout

java.lang.Object
  extended by diva.graph.layout.AbstractGlobalLayout
      extended by ptolemy.vergil.basic.layout.kieler.KielerLayout
All Implemented Interfaces:
GlobalLayout

public class KielerLayout
extends AbstractGlobalLayout

Ptolemy Layouter that uses the KIELER layout algorithm from an external library to layout a given ptolemy model.

See http://www.informatik.uni-kiel.de/rtsys/kieler/ for more information about KIELER.

KIELER - Kiel Integrated Environment for Layout for the Eclipse RichClientPlatform

The KIELER project tries to enhance graphical modeling pragmatics. Next to higher level solutions (meta layout, structure based editing...) developed for Eclipse models, it also implements custom layout algorithms.

This class interfaces a standalone KIELER layout algorithm for actor oriented port based graphical diagrams with a Ptolemy diagram.

While KIELER is mainly developed for an Eclipse environment, most algorithms are also available standalone and can be used in a non Eclipse environment. This class is a try to leverage this to apply KIELER algorithms with Ptolemy. No Eclipse is required with that. Only one standalone external library.

Calling the layout() method will create a new Kieler graph datastructure, run Kieler layout algorithms on it and augment it with resulting layout information (locations and sizes of nodes, bendoints of connections). Then this layout gets applied to the Ptolemy model. Moving of nodes in Ptolemy is done via adding or changing location attributes.

Setting bendpoints is not yet supported in Ptolemy. Ptolemy's built-in connection routing does not consider obstacle avoidance, hence overlappings with other nodes and connections might appear. This class tries to gap that hole by the option to add new relations with vertices into the Ptolemy model. The vertices are placed at the bend point positions such that a certain routing is forced.

In order to avoid cluttering of the diagram with new clumsy vertices, there are methods available to remove or just hide unnecessary relation vertices. That are those vertices, just put in for routing and that have no semantic relevance.

It uses location attributes of actors and attributes to place items and corresponding for relation vertices.

Since:
Ptolemy II 8.0
Version:
$Id: KielerLayout.java 59203 2010-09-23 21:41:27Z cxh $
Author:
Hauke Fuhrmann,
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Field Summary
private  CompositeActor _compositeActor
          The top level Ptolemy composite actor that contains the diagram that is to be laid out.
private  boolean _debug
          Debug flag that will trigger output of additional information during layout run.
private  java.util.Map<java.lang.Object,java.lang.Object> _divaEdgeSource
          Storage of actual sources of diva edges corresponding to data flow.
private  java.util.Map<java.lang.Object,java.lang.Object> _divaEdgeTarget
          Storage of actual targets of diva edges corresponding to data flow.
private  boolean _doApplyEdgeLayout
          Flag to indicate whether edge routing shall be applied by insertion of new relation vertices or not.
private  boolean _doBoxLayout
          Flag to indicate whether all nodes should be placed including unconnected nodes such as attributes (e.g. director, text annotations,...).
private  java.util.Map<de.cau.cs.kieler.core.kgraph.KEdge,java.lang.Object> _kieler2PtolemyDivaEdges
          Map Kieler KEdges to Ptolemy Diva Edges.
private  java.util.Map<de.cau.cs.kieler.core.kgraph.KNode,java.lang.Object> _kieler2ptolemyDivaNodes
          Map Kieler nodes to Diva Nodes.
private  java.util.Map<de.cau.cs.kieler.core.kgraph.KNode,NamedObj> _kieler2ptolemyEntityNodes
          Map Kieler Nodes to Ptolemy Nodes.
private  java.util.Map<de.cau.cs.kieler.core.kgraph.KPort,Port> _kieler2PtolemyPorts
          Map Kieler ports to Ptolemy ports.
private  java.util.Map<java.lang.Object,de.cau.cs.kieler.core.kgraph.KNode> _ptolemy2KielerNodes
          Map Diva nodes to Kieler Nodes.
private  java.util.Map<Port,java.util.List<de.cau.cs.kieler.core.kgraph.KPort>> _ptolemy2KielerPorts
          Map Ptolemy ports to Kieler ports.
private  java.util.Map<java.lang.Object,de.cau.cs.kieler.core.kgraph.KEdge> _ptolemyDiva2KielerEdges
          Map Ptolemy links (= Edges in Diva) to Edges in Kieler
private  PtolemyModelUtil _ptolemyModelUtil
          Helper class to manipulate Ptolemy models.
private  long _time
          Variable to store time for statistics.
private  Top _top
          Pointer to Top in order to report the current status.
private static float DEFAULT_PORT_SIZE
          Default size of a port that will be used in Kieler layout if no explicit size (e.g. copied from Ptolemy port) is given.
private static float INNER_PORT_HEIGHT_OFFSET
          The offset height used by Kieler for inner ports to correct connection anchor.
private static float MIN_SPACING
          Minimal distance between nodes.
private static float MULTIPORT_BOTTOM
          Offset between bottom of Multiport to the first Kieler KPort
private static float MULTIPORT_OFFSET
          Offset between Kieler KPorts corresponding to a Ptolemy multiport.
private static int NO_RANK
          Identify that no rank is given to a port.
 
Constructor Summary
KielerLayout(LayoutTarget target)
          Construct an instance taking a LayoutTarget for specifying some methods for layout handling as given by the standard Ptolemy AbstractGlobalLayout.
KielerLayout(LayoutTarget target, CompositeActor ptolemyContainer)
          Construct an instance setting the LayoutTarget as requested by the AbstractGlobalLayout and the containing Ptolemy model.
 
Method Summary
private  Relation _applyEdgeLayout(de.cau.cs.kieler.core.kgraph.KEdge kEdge)
          Apply precomputed routing of edges to the Ptolemy model by insertion of new relation vertices.
private  void _applyLayout(de.cau.cs.kieler.core.kgraph.KNode kgraph)
          Traverse a composite KNode containing corresponding Kieler nodes, ports and edges for the Ptolemy model and apply all layout information contained by it back to the Ptolemy model.
private  void _createGraph(java.lang.Object composite, de.cau.cs.kieler.core.kgraph.KNode hierarchicalLayoutNode, de.cau.cs.kieler.core.kgraph.KNode boxLayoutNode)
          Creates a graph for the KIELER API from a ptolemy model.
private  void _createKEdge(java.lang.Object divaEdge)
          Create a Kieler KEdge for a Ptolemy Diva edge object.
private  de.cau.cs.kieler.core.kgraph.KNode _createKNode(java.lang.Object node, java.lang.Object semanticNode)
          Create a new Kieler KNode corresponding to a Ptolemy diva node and its Ptolemy semantic object (e.g. an Actor).
private  de.cau.cs.kieler.core.kgraph.KNode _createKNodeForPort(java.lang.Object divaLocation, Port port)
          Create a Kieler KNode for a Ptolemy inner port.
private  de.cau.cs.kieler.core.kgraph.KNode _createKNodeForVertex(Vertex vertex)
          Create a Kieler KNode for a Ptolemy Vertex.
private  void _createKPort(de.cau.cs.kieler.core.kgraph.KNode knode, de.cau.cs.kieler.core.kgraph.KPortType portType, Port port, int rank, int index, int maxIndex, float size)
          Create a Kieler KPort corresponding to a Ptolemy Port.
private  void _createKPorts(de.cau.cs.kieler.core.kgraph.KNode knode, java.util.List<Port> ports, de.cau.cs.kieler.core.kgraph.KPortType portType)
          Create Kieler ports (KPort) for a Kieler node (KNode) given a list of Ptolemy Port objects and a port type (incoming, outgoing).
private  de.cau.cs.kieler.core.kgraph.KPort _getPort(java.lang.Object ptolemyObject, de.cau.cs.kieler.core.kgraph.KPortType type, Relation rel)
          Get a Kieler KPort for a corresponding Ptolemy object, i.e. a Port or a relation Vertex.
private  void _kNode2Ptolemy(de.cau.cs.kieler.kiml.layout.klayoutdata.KShapeLayout kshapeLayout, de.cau.cs.kieler.core.kgraph.KNode referenceNode)
          Transform a location from a Kieler node from Kieler coordinate system to ptolemy coordinate system.
private  NamedObj _replaceRelation(de.cau.cs.kieler.core.kgraph.KPort kPort, de.cau.cs.kieler.core.kgraph.KNode kNode, java.lang.String newRelationName, Relation oldRelation)
          Replace a relation connected to a port of a node with a new relation by unlinking the old one and linking the new one.
private  void _report(java.lang.String message)
          Report a message to the top window status handler if it is available.
private  void _storeEndpoints()
          Determine the direction of dataflow of all edges and store it in the local maps.
 void layout(java.lang.Object composite)
          Layout the given composite.
 void setApplyEdgeLayout(boolean flag)
          Configure whether the layout should only place nodes or additionally route edges.
 void setBoxLayout(boolean flag)
          Configure whether all unconnected nodes should also be placed by the layouter with a simple box layout heuristic.
 void setModel(CompositeActor model)
          Set the Ptolemy Model that contains the graph that is to be layouted.
 void setTop(Top top)
          Set the Top window to enable status reports on the status bar.
 
Methods inherited from class diva.graph.layout.AbstractGlobalLayout
getLayoutTarget, setLayoutTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT_SIZE

private static final float DEFAULT_PORT_SIZE
Default size of a port that will be used in Kieler layout if no explicit size (e.g. copied from Ptolemy port) is given.

See Also:
Constant Field Values

INNER_PORT_HEIGHT_OFFSET

private static final float INNER_PORT_HEIGHT_OFFSET
The offset height used by Kieler for inner ports to correct connection anchor.

See Also:
Constant Field Values

MIN_SPACING

private static final float MIN_SPACING
Minimal distance between nodes. Changing this value will decrease the overall horizontal space consumed by the diagram.

See Also:
Constant Field Values

MULTIPORT_OFFSET

private static final float MULTIPORT_OFFSET
Offset between Kieler KPorts corresponding to a Ptolemy multiport. I.e. the distance between multiple single KPorts.

See Also:
Constant Field Values

MULTIPORT_BOTTOM

private static final float MULTIPORT_BOTTOM
Offset between bottom of Multiport to the first Kieler KPort

See Also:
Constant Field Values

NO_RANK

private static final int NO_RANK
Identify that no rank is given to a port.

See Also:
Constant Field Values

_compositeActor

private CompositeActor _compositeActor
The top level Ptolemy composite actor that contains the diagram that is to be laid out.


_debug

private boolean _debug
Debug flag that will trigger output of additional information during layout run. With the flag set to true especially the Kieler graph structure will be written to a file on harddisk in order to review the graph later on.


_divaEdgeSource

private java.util.Map<java.lang.Object,java.lang.Object> _divaEdgeSource
Storage of actual sources of diva edges corresponding to data flow.


_divaEdgeTarget

private java.util.Map<java.lang.Object,java.lang.Object> _divaEdgeTarget
Storage of actual targets of diva edges corresponding to data flow.


_doApplyEdgeLayout

private boolean _doApplyEdgeLayout
Flag to indicate whether edge routing shall be applied by insertion of new relation vertices or not.


_doBoxLayout

private boolean _doBoxLayout
Flag to indicate whether all nodes should be placed including unconnected nodes such as attributes (e.g. director, text annotations,...).


_kieler2PtolemyDivaEdges

private java.util.Map<de.cau.cs.kieler.core.kgraph.KEdge,java.lang.Object> _kieler2PtolemyDivaEdges
Map Kieler KEdges to Ptolemy Diva Edges.


_kieler2ptolemyDivaNodes

private java.util.Map<de.cau.cs.kieler.core.kgraph.KNode,java.lang.Object> _kieler2ptolemyDivaNodes
Map Kieler nodes to Diva Nodes. Opposite of _ptolemy2KielerNodes


_kieler2ptolemyEntityNodes

private java.util.Map<de.cau.cs.kieler.core.kgraph.KNode,NamedObj> _kieler2ptolemyEntityNodes
Map Kieler Nodes to Ptolemy Nodes.


_kieler2PtolemyPorts

private java.util.Map<de.cau.cs.kieler.core.kgraph.KPort,Port> _kieler2PtolemyPorts
Map Kieler ports to Ptolemy ports.


_ptolemy2KielerNodes

private java.util.Map<java.lang.Object,de.cau.cs.kieler.core.kgraph.KNode> _ptolemy2KielerNodes
Map Diva nodes to Kieler Nodes.


_ptolemy2KielerPorts

private java.util.Map<Port,java.util.List<de.cau.cs.kieler.core.kgraph.KPort>> _ptolemy2KielerPorts
Map Ptolemy ports to Kieler ports. A Ptolemy multiport could correspond to multiple single Kieler ports. Hence it's a mapping to a List of KPorts.


_ptolemyDiva2KielerEdges

private java.util.Map<java.lang.Object,de.cau.cs.kieler.core.kgraph.KEdge> _ptolemyDiva2KielerEdges
Map Ptolemy links (= Edges in Diva) to Edges in Kieler


_ptolemyModelUtil

private PtolemyModelUtil _ptolemyModelUtil
Helper class to manipulate Ptolemy models. Especially for sending MoMLChangeRequests. Instance is required to buffer multiple requests for better performance.


_time

private long _time
Variable to store time for statistics.


_top

private Top _top
Pointer to Top in order to report the current status.

Constructor Detail

KielerLayout

public KielerLayout(LayoutTarget target)
Construct an instance taking a LayoutTarget for specifying some methods for layout handling as given by the standard Ptolemy AbstractGlobalLayout. The KielerLayout will need access to the top level Ptolemy model, so either use corresponding constructor or call setModel() prior to layout invocation.

Parameters:
target - The LayoutTarget on which layout will be performed

KielerLayout

public KielerLayout(LayoutTarget target,
                    CompositeActor ptolemyContainer)
Construct an instance setting the LayoutTarget as requested by the AbstractGlobalLayout and the containing Ptolemy model. Preferred constructor.

Parameters:
target - The LayoutTarget on which layout will be performed
ptolemyContainer - The composite actor that contains all elements to be layouted
Method Detail

layout

public void layout(java.lang.Object composite)
Layout the given composite. Main entry point for the layout action. Create a Kieler KGraph datastructure corresponding to the Ptolemy model, instanciate a Kieler layout algorithm (AbstractLayoutProvider) and run its doLayout() method on the KGraph. The KGraph gets augmented with layout information (position and sizes of objects and bendpoints for connections). This information is then reapplied to the ptolemy model by stating MoMLChangeRequests with location attributes for nodes. So far setting connection bendpoints in Ptolemy is not supported. Hence the bendpoint information of KIELER is discarded, which may result in suboptimal results as the Ptolemy connection router does not consider obstacle avoidance.

Specified by:
layout in interface GlobalLayout
Specified by:
layout in class AbstractGlobalLayout
Parameters:
composite - the container of the diagram in terms of an GraphModel.

setApplyEdgeLayout

public void setApplyEdgeLayout(boolean flag)
Configure whether the layout should only place nodes or additionally route edges. Edge routing would be done by insertion of new relation vertices which is a real manipulation of a model. Routing is only supported for standard actor based frames with relations. Different arrow styles like in Modal Models are not yet supported for routing.

Parameters:
flag - True iff edge routing shall be applied by insertion of relation vertices.

setBoxLayout

public void setBoxLayout(boolean flag)
Configure whether all unconnected nodes should also be placed by the layouter with a simple box layout heuristic. Either only connected nodes (e.g. actors connected by relations) get placed or all nodes including unconnected nodes get placed. The rationale behind not placing unconnected items is that the user might want to manually place text annotations or parameters at some special locations, e.g. to document specific parts of the model. In that case the bounding box of all connected nodes will be located with its upper left corner at the same position as before.

Parameters:
flag - If true, apply layout to all nodes, including unconnected ones. Otherwise, apply layout only to connected nodes.

setModel

public void setModel(CompositeActor model)
Set the Ptolemy Model that contains the graph that is to be layouted. The layouter will require access to the Ptolemy model because the lower level Diva abstraction does not consider certain properties required by the Kieler layouter such as port positions.

Parameters:
model - The parent composite actor which internal diagram shall be layouted.

setTop

public void setTop(Top top)
Set the Top window to enable status reports on the status bar.

Parameters:
top - The Top window

_applyEdgeLayout

private Relation _applyEdgeLayout(de.cau.cs.kieler.core.kgraph.KEdge kEdge)
                           throws IllegalActionException
Apply precomputed routing of edges to the Ptolemy model by insertion of new relation vertices. Take a Kieler KEdge with layout information (bend point positions) and create a new relation with a vertex for each bend point and interconnect them. Then replace the original relation with the new relation set. Return the original relation if it is safe to delete it.

Parameters:
kEdge - The Kieler KEdge that hold the precomupted layout information, i.e. bend point positions
Returns:
The old Relation if it is safe to delete it.
Throws:
IllegalActionException - Exception will be thrown if replacing of original relation is not possible, i.e. if unlink() or link() methods fail.

_applyLayout

private void _applyLayout(de.cau.cs.kieler.core.kgraph.KNode kgraph)
                   throws IllegalActionException
Traverse a composite KNode containing corresponding Kieler nodes, ports and edges for the Ptolemy model and apply all layout information contained by it back to the Ptolemy model. Do most changes to the Ptolemy model via MoMLChangeRequests. Set location attributes for all visible Ptolemy nodes. So far Ptolemy does not support setting of connection bendpoints explicitly. The Ptolemy connection router does not consider obstruction avoidance so there are likely to be connection overlappings in the diagram.

Optionally route edges explicitly by inserting new relation vertices for each bend point.

Parameters:
kgraph - The Kieler graph object containing all layout information to apply to the Ptolemy model
Throws:
IllegalActionException - Exception can be thrown if routing of edges fails due to not allowed unlinking or linking of new relations.
See Also:
setApplyEdgeLayout(boolean)

_createGraph

private void _createGraph(java.lang.Object composite,
                          de.cau.cs.kieler.core.kgraph.KNode hierarchicalLayoutNode,
                          de.cau.cs.kieler.core.kgraph.KNode boxLayoutNode)
Creates a graph for the KIELER API from a ptolemy model. Will traverse the low level GraphModel given by the composite and record all found elements in the mapping fields of this object that keep a mapping between Ptolemy/Diva objects and Kieler objects. New Kieler objects (KEdge, KNode, KPort) get created for their respective Ptolemy counterparts and initialized with the initial sizes and positions and are put in a composite KNode (the graph Kieler will perform the layout on later). To obtain the right mappings, multiple abstraction levels of Ptolemy are considered here: Diva, as this was the intended original way to do automatic layout (e.g. by GlobalAbstractLayout) and Ptolemy, as Diva lacks certain concepts that are relevant for a proper layout, as for example exact port locations for considering port constraints in the model, supported by Kieler.

Parameters:
composite - The GraphModel composite object to retrieve the model information from
boxLayoutNode - Kieler subgraph to receive all unconnected model elements
hierarchicalLayoutNode - Kieler subgraph to receive all connected model elements

_createKEdge

private void _createKEdge(java.lang.Object divaEdge)
Create a Kieler KEdge for a Ptolemy Diva edge object. The KEdge will be setup between either two ports or relation vertices or mixed. Hence the KEdge corresponds more likely a Ptolemy link than a relation. Diva edges have no direction related to the flow of data in Ptolemy. However, Kieler uses a directed graph to perform layout and so a meaningful direction should be set in the KEdge. This direction will be approximated by doing a tree search beginning on both end points of the diva edge. Whenever either of the endpoints is connected to a source port, this will be the source of the KEdge and determine its direction. The newly created edge is stored with the corresponding diva edge in the global maps _ptolemyDiva2KielerEdges, _kieler2PtolemyDivaEdges, such that the _applyLayout(KNode) method will be able to reapply the layout.

Parameters:
divaEdge - The Ptolemy diva edge object for which to create a new KEdge.

_createKNode

private de.cau.cs.kieler.core.kgraph.KNode _createKNode(java.lang.Object node,
                                                        java.lang.Object semanticNode)
Create a new Kieler KNode corresponding to a Ptolemy diva node and its Ptolemy semantic object (e.g. an Actor). The newly created node is stored with the corresponding diva and ptolemy nodes in the global maps _ptolemy2KielerNodes, _kieler2ptolemyDivaNodes, _kieler2ptolemyEntityNodes, such that * the _applyLayout(KNode) method will be able to reapply the layout.

Parameters:
node - The Diva node object.
semanticNode - The corresponding Ptolemy semantic object, e.g. an Actor or TextAttribute
Returns:
The initialized Kieler KNode

_createKNodeForPort

private de.cau.cs.kieler.core.kgraph.KNode _createKNodeForPort(java.lang.Object divaLocation,
                                                               Port port)
Create a Kieler KNode for a Ptolemy inner port. That is the graphical representation for a port of a CompositeActor if you see the contents of this CompositeActor. It is represented by a node where the connection may touch the node corresponding to its type (input, output, both) on the right, left or top. For now this results a crude approximation of the node, because the figure of the original Ptolemy port cannot be obtained by the layout target. Hence we cannot ask the port for its original bounds.

Parameters:
divaLocation - Diva Representation of an inner port
port - The Ptolemy inner port.
Returns:
A new Kieler KNode corresponding to the Ptolemy inner port.

_createKNodeForVertex

private de.cau.cs.kieler.core.kgraph.KNode _createKNodeForVertex(Vertex vertex)
Create a Kieler KNode for a Ptolemy Vertex. Vertices of Ptolemy can be handles as usual KNodes in Kieler (an alternative would be to handle them as connection bendpoints). As Kieler does not support KNodes without port constraints (as in usual graphs without ports), the corresponding KNode will contain one input port and one output port. Size of the node and positions of the ports are all set to zero.

Parameters:
vertex - The Ptolemy vertex for which to create a KNode
Returns:
An initialized KNode with one input and one output port

_createKPort

private void _createKPort(de.cau.cs.kieler.core.kgraph.KNode knode,
                          de.cau.cs.kieler.core.kgraph.KPortType portType,
                          Port port,
                          int rank,
                          int index,
                          int maxIndex,
                          float size)
Create a Kieler KPort corresponding to a Ptolemy Port. Set the size and position (relative to parent) and the direction of the port in the KPort layout information. As Kieler does not explicitly support multiports as Ptolemy, this gets emulated by creating multiple distinct ports with a little offset each. Create only one node. For multiports call this method multiple times with changed parameters. The newly created port is stored with the corresponding ptolemy port in the global maps _kieler2PtolemyPorts, _ptolemy2KielerPorts, such that the _applyLayout(KNode) method will be able to reapply the layout.

Parameters:
knode - The parent KNode of the new port
portType - The port Type, either input or output
port - The corresponding Ptolemy port (might be a multiport)
rank - The rank of the new port which is an ordering index. If this is not set, Kieler will try to infer the ranks automatically from the port's position.
index - Index of the KPort corresponding to a multiport
maxIndex - Width of the multiport, i.e. the number of connected edges to that port.
size - Custom size (same for width and height) for a port that will be used instead of the real Ptolemy port size. If this value is negative, the original Ptolemy sizes are used.

_createKPorts

private void _createKPorts(de.cau.cs.kieler.core.kgraph.KNode knode,
                           java.util.List<Port> ports,
                           de.cau.cs.kieler.core.kgraph.KPortType portType)
Create Kieler ports (KPort) for a Kieler node (KNode) given a list of Ptolemy Port objects and a port type (incoming, outgoing). The new KPorts get initialized in terms of size and position from the Ptolemy counterparts and attached to the corresponding KNode and registered in the mapping fields of this object. For Ptolemy multiports with multiple connections, multiple Kieler KPorts are created with slightly offsetted location. Hence the layouter can also here consider the location for connection crossing minimization. Hence one Ptolemy port may correspond to multiple Kieler KPorts.

Parameters:
knode - The KNode to create Kieler ports for.
ports - The Ptolemy ports counterparts for which to create Kieler ports.
portType - Type of port, input or output. This is relevant for some Kieler layout algorithms.

_getPort

private de.cau.cs.kieler.core.kgraph.KPort _getPort(java.lang.Object ptolemyObject,
                                                    de.cau.cs.kieler.core.kgraph.KPortType type,
                                                    Relation rel)
Get a Kieler KPort for a corresponding Ptolemy object, i.e. a Port or a relation Vertex. If the input is a Vertex, it is determined which of the two KPorts of the corresponding KNode is returned (as in Kieler a Vertex is represented by one node with one input and one output port). If the input object is a Ptolemy Port, the KPort counterpart is searched in the global maps. If additionally the Port is a multiport with multiple connection, the given relation is used to determine which KPort corresponds to the Port/Relation combination. In Kieler multiports are represented by multiple KPorts with slightly offsetted locations.

Parameters:
ptolemyObject - The corresponding Ptolemy object, either a Vertex or a Port
type - The type of the port, incoming or outgoing
rel - The relation that is connected to the Ptolemy multiport
Returns:
The port found or null if no port was found.

_kNode2Ptolemy

private void _kNode2Ptolemy(de.cau.cs.kieler.kiml.layout.klayoutdata.KShapeLayout kshapeLayout,
                            de.cau.cs.kieler.core.kgraph.KNode referenceNode)
Transform a location from a Kieler node from Kieler coordinate system to ptolemy coordinate system. That is Kieler gives locations to be the upper left corner of an item and Ptolemy as the center point of the item. If the original location is not within the bounds of the referenceNode at all, the location is not updated. (e.g. important distinction between nodes and vertices).

Parameters:
kshapeLayout - Layout of KNode kieler graphical node that contains bounds with location and size. This object will be altered to fit the new location.
referenceNode - The parent reference node giving the bounds to calculate with.

_replaceRelation

private NamedObj _replaceRelation(de.cau.cs.kieler.core.kgraph.KPort kPort,
                                  de.cau.cs.kieler.core.kgraph.KNode kNode,
                                  java.lang.String newRelationName,
                                  Relation oldRelation)
                           throws IllegalActionException
Replace a relation connected to a port of a node with a new relation by unlinking the old one and linking the new one. Properly handle the index to what the new relation is inserted for multiports, i.e. the channel index of the new relation should be the same as before for the old relation.

Parameters:
kPort - Kieler KPort the relation is connected to. Might be null or invalid if the port is an inner port within the composite actor.
kNode - Kieler KNode the port belongs to or---if it is an inner port--- the inner port itself.
newRelationName - The new relation that should be connected.
oldRelation - The old relation that should be replaced. It does not get deleted at this point.
Returns:
the NamedObj to which a link was removed, i.e. either a port or a relation
Throws:
IllegalActionException - Exception may be thrown if unlinking or linking of a relation fails.

_report

private void _report(java.lang.String message)
Report a message to the top window status handler if it is available.

Parameters:
message - The message to be reported.

_storeEndpoints

private void _storeEndpoints()
Determine the direction of dataflow of all edges and store it in the local maps. Iterate all edges and try to deduce the type of each edge's endpoints, i.e. whether it is an source or target. Do this in multiple iterations by first getting clear information from input and output ports and then propagate this information to the adjacent edges. Work only on the local maps, i.e. get the list of all edges of the _ptolemyDiva2KielerEdges map and store the source and target information in _divaEdgeSource resp. _divaEdgeTarget.