de.cau.cs.kieler.klodd.hierarchical.structures
Class LayerElement

java.lang.Object
  extended by de.cau.cs.kieler.klodd.hierarchical.structures.LayerElement

public class LayerElement
extends Object

A layer element representing a node or a long edge in the layered graph.

Rating proposed yellow
(2009-12-11) msp

Field Summary
static int UNDEF_RANK
          value to use if the rank is undefined.
 
Constructor Summary
LayerElement(KGraphElement obj, Layer thelayer, KSlimNode thekNode)
          Creates a layer element in an existing layer.
 
Method Summary
 void addOutgoing(KEdge edge, LayerElement target)
          Adds a new cross-layer connection with given target.
 void addOutgoing(KEdge edge, LayerElement target, KPort sourcePort, KPort targetPort)
          Adds a new cross-layer connection with given target.
 void applyLayout(KPoint offset, KInsets insets)
          Applies the layout of this layer element to the contained object and updates position information according to given offset values.
 void clearPortRanks()
          Clears the internal map of port ranks.
 List<Integer> getConnectionRanks(boolean forward)
          Gets a list of combined element and port ranks for all incoming or for all outgoing connections.
 Map<KPort,List<Integer>> getConnectionRanksByPort(boolean forward)
          Gets a list of combined element and port ranks of connections sorted by the port to which the connection is attached.
 int getEdgesBack()
          Gets the number of edges that are routed in the back of this element.
 int getEdgesFront()
          Gets the number of edges that are routed in front of this element.
 KGraphElement getElemObj()
          Gets the object contained in this layer element.
 List<LayerConnection> getIncomingConnections()
          Gets the list of incoming layer connections.
 KSlimNode getKNode()
          Gets the KIELER node associated with this layer element.
 Layer getLayer()
          Get the containing layer.
 LinearSegment getLinearSegment()
          Returns the linear segment.
 List<ElementLoop> getLoops()
          Gets the loops of this layer element.
 List<LayerConnection> getOutgoingConnections()
          Gets the list of outgoing connections.
 List<KSlimEdge> getOutgoingEdges()
          Gets the outgoing edges of the contained object.
 PortConstraints getPortConstraints()
          Gets the port constraints for this layer element.
 int getPortRank(KPort port, boolean forward)
          Gets the port rank for a given port.
 KPoint getPosition()
          Gets the current position of this layer element.
 KPoint getPosOffset()
          Gets the current position offset of the contained node, or null if the contained object is not a node.
 int getRank()
          Returns the rank.
 int getRanks(PortSide side)
          Returns the ranks for a specific side.
 int getRankWidth()
          Gets the rank width of this layer element.
 float getRealHeight()
          Returns the height of this layer element.
 float getRealWidth()
          Returns the width of this layer element.
 float getTotalCrosswiseDim(float minDist, boolean preSpacing)
          Gets the total crosswise dimension of this layer element with routed edges.
 float getTotalLengthwiseDim(float minDist)
          Gets the total lengthwise dimension of this layer element with routed edges.
 void placePorts()
          Determines placements for the ports of the related node, based on the internally stored order.
 void setCrosswisePos(float pos, float minDist)
          Sets the crosswise position for this layer element, considering all edges that are routed before this element.
 void setLayer(Layer newLayer)
          Set a new layer for this element.
 void setLengthwisePos(float pos, float minDist)
          Sets the lengthwise position for this layer element, considering all edges that are routed before this element.
 void setLinearSegment(LinearSegment thelinearSegment)
          Sets the linear segment.
 void setRank(int therank)
          Sets the rank.
 void setRanks(int ranks, PortSide side)
          Sets the ranks for a specific side.
 void sortPorts(Map<KPort,Double> abstractPortRanks, boolean isoutgoing)
          Sorts the ports on each side of the related node according to the given abstract ranks.
 void sortPorts(Map<KPort,Double> outgoingPortRanks, Map<KPort,Double> incomingPortRanks)
          Sorts the ports on each side of the related node according to the given abstract ranks.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDEF_RANK

public static final int UNDEF_RANK
value to use if the rank is undefined.

See Also:
Constant Field Values
Constructor Detail

LayerElement

public LayerElement(KGraphElement obj,
                    Layer thelayer,
                    KSlimNode thekNode)
Creates a layer element in an existing layer.

Parameters:
obj - the element object
thelayer - the containing layer
thekNode - the corresponding node in the acyclic KIELER graph
Method Detail

toString

public String toString()

Overrides:
toString in class Object

getLayer

public Layer getLayer()
Get the containing layer.

Returns:
the layer

setLayer

public void setLayer(Layer newLayer)
Set a new layer for this element. The element is added to the new layer.

Parameters:
newLayer - the new layer

getOutgoingEdges

public List<KSlimEdge> getOutgoingEdges()
Gets the outgoing edges of the contained object.

Returns:
the list of outgoing edges, or null if the object is an edge

addOutgoing

public void addOutgoing(KEdge edge,
                        LayerElement target)
Adds a new cross-layer connection with given target.

Parameters:
edge - the edge between the two layout nodes
target - target layer element

addOutgoing

public void addOutgoing(KEdge edge,
                        LayerElement target,
                        KPort sourcePort,
                        KPort targetPort)
Adds a new cross-layer connection with given target.

Parameters:
edge - the edge between the two layout nodes
target - target layer element
sourcePort - the source port
targetPort - the target port

applyLayout

public void applyLayout(KPoint offset,
                        KInsets insets)
Applies the layout of this layer element to the contained object and updates position information according to given offset values.

Parameters:
offset - offset to be added to this element's position
insets - insets of the containing parent layout node

getPortConstraints

public PortConstraints getPortConstraints()
Gets the port constraints for this layer element.

Returns:
the port constraints

getRankWidth

public int getRankWidth()
Gets the rank width of this layer element.

Returns:
the rank width

getIncomingConnections

public List<LayerConnection> getIncomingConnections()
Gets the list of incoming layer connections.

Returns:
the incoming connections

getOutgoingConnections

public List<LayerConnection> getOutgoingConnections()
Gets the list of outgoing connections.

Returns:
the outgoing connections

getLoops

public List<ElementLoop> getLoops()
Gets the loops of this layer element.

Returns:
list of element loops

getRealWidth

public float getRealWidth()
Returns the width of this layer element.

Returns:
the width

getRealHeight

public float getRealHeight()
Returns the height of this layer element.

Returns:
the height

setCrosswisePos

public void setCrosswisePos(float pos,
                            float minDist)
Sets the crosswise position for this layer element, considering all edges that are routed before this element.

Parameters:
pos - new crosswise position
minDist - minimal distance for routed edges

setLengthwisePos

public void setLengthwisePos(float pos,
                             float minDist)
Sets the lengthwise position for this layer element, considering all edges that are routed before this element.

Parameters:
pos - new lengthwise position
minDist - minimal distance for routed edges

getTotalCrosswiseDim

public float getTotalCrosswiseDim(float minDist,
                                  boolean preSpacing)
Gets the total crosswise dimension of this layer element with routed edges.

Parameters:
minDist - minimal distance for routed edges
preSpacing - whether the pre-spacing should be considered
Returns:
total crosswise dimension with routed edges

getTotalLengthwiseDim

public float getTotalLengthwiseDim(float minDist)
Gets the total lengthwise dimension of this layer element with routed edges.

Parameters:
minDist - minimal distance for routed edges
Returns:
total lengthwise dimension with routed edges

getPosition

public KPoint getPosition()
Gets the current position of this layer element.

Returns:
the currently set position

getPosOffset

public KPoint getPosOffset()
Gets the current position offset of the contained node, or null if the contained object is not a node.

Returns:
the position offset

getElemObj

public KGraphElement getElemObj()
Gets the object contained in this layer element.

Returns:
the element object

getKNode

public KSlimNode getKNode()
Gets the KIELER node associated with this layer element.

Returns:
the KIELER node

clearPortRanks

public void clearPortRanks()
Clears the internal map of port ranks.


getEdgesFront

public int getEdgesFront()
Gets the number of edges that are routed in front of this element.

Returns:
number of edges in front

getEdgesBack

public int getEdgesBack()
Gets the number of edges that are routed in the back of this element.

Returns:
number of edges in the back

getPortRank

public int getPortRank(KPort port,
                       boolean forward)
Gets the port rank for a given port.

Parameters:
port - port for which the rank shall be obtained
forward - if true, ranks are determined for a forward layer sweep, else for a backwards layer sweep
Returns:
port rank, or 0 if port == null

getConnectionRanks

public List<Integer> getConnectionRanks(boolean forward)
Gets a list of combined element and port ranks for all incoming or for all outgoing connections.

Parameters:
forward - if true, only incoming connections are considered, else only outgoing connections are considered
Returns:
list of ranks for the specified connections

getConnectionRanksByPort

public Map<KPort,List<Integer>> getConnectionRanksByPort(boolean forward)
Gets a list of combined element and port ranks of connections sorted by the port to which the connection is attached. This only works if the element object is a layout node. The method is expected to give at least an empty list for each port in the contained node group.

Parameters:
forward - if true, only incoming connections are considered, else only outgoing connections are considered
Returns:
list of connection ranks for each port of this layout node, or null if the contained object is not a layout node

sortPorts

public void sortPorts(Map<KPort,Double> abstractPortRanks,
                      boolean isoutgoing)
Sorts the ports on each side of the related node according to the given abstract ranks.

Parameters:
abstractPortRanks - abstract port ranks
isoutgoing - if true, the abstract ranks are assumed to be for outgoing connections, else for incoming connections

sortPorts

public void sortPorts(Map<KPort,Double> outgoingPortRanks,
                      Map<KPort,Double> incomingPortRanks)
Sorts the ports on each side of the related node according to the given abstract ranks.

Parameters:
outgoingPortRanks - ranks for ports with outgoing connections
incomingPortRanks - ranks for ports with incoming connections

placePorts

public void placePorts()
Determines placements for the ports of the related node, based on the internally stored order. This order should be compatible to the assigned rank of each port.


setRank

public void setRank(int therank)
Sets the rank.

Parameters:
therank - the rank to set

getRank

public int getRank()
Returns the rank.

Returns:
the rank

setLinearSegment

public void setLinearSegment(LinearSegment thelinearSegment)
Sets the linear segment.

Parameters:
thelinearSegment - the linear segment to set

getLinearSegment

public LinearSegment getLinearSegment()
Returns the linear segment.

Returns:
the linear segment

setRanks

public void setRanks(int ranks,
                     PortSide side)
Sets the ranks for a specific side.

Parameters:
ranks - the ranks to set
side - the side for which the ranks are set

getRanks

public int getRanks(PortSide side)
Returns the ranks for a specific side.

Parameters:
side - the side for which ranks are returned
Returns:
the ranks for the given side