de.cau.cs.kieler.klay.layered.graph
Class LNode

java.lang.Object
  extended by de.cau.cs.kieler.core.properties.MapPropertyHolder
      extended by de.cau.cs.kieler.klay.layered.graph.LGraphElement
          extended by de.cau.cs.kieler.klay.layered.graph.LSizedGraphElement
              extended by de.cau.cs.kieler.klay.layered.graph.LNode
All Implemented Interfaces:
IPropertyHolder, Comparable<LGraphElement>

public class LNode
extends LSizedGraphElement

A node in a layered graph.

Rating red

Field Summary
 
Fields inherited from class de.cau.cs.kieler.klay.layered.graph.LGraphElement
id
 
Constructor Summary
LNode()
           
 
Method Summary
 Iterable<LEdge> getConnectedEdges()
          Returns an iterable for all connected edges, both incoming and outgoing.
 Iterable<LEdge> getIncomingEdges()
          Returns an iterable for all inomcing edges.
 int getIndex()
          Returns the index of the node in the containing layer's list of nodes.
 LLabel getLabel()
          Returns this node's label, if any.
 Layer getLayer()
          Returns the layer that owns this node.
 Insets.Double getMargin()
          Returns the node's margin.
 String getName()
          Returns the name of the node.
 Iterable<LEdge> getOutgoingEdges()
          Returns an iterable for all outgoing edges.
 List<LPort> getPorts()
          Returns the list of ports of this node.
 Iterable<LPort> getPorts(PortSide side)
          Returns an iterable for all ports of given side.
 Iterable<LPort> getPorts(PortType portType)
          Returns an iterable for all ports of given type.
 Iterable<LPort> getPorts(PortType portType, PortSide side)
          Returns an iterable for all ports of a given type and side.
 void setLabel(LLabel label)
          Sets this node's label.
 void setLayer(int index, Layer layer)
          Sets the owning layer and adds itself to the layer's list of nodes at the specified position.
 void setLayer(Layer layer)
          Sets the owning layer and adds itself to the layer's list of nodes.
 void sortPorts(float[] position)
          Sort the ports of this node using relative position values.
 String toString()
          
 
Methods inherited from class de.cau.cs.kieler.klay.layered.graph.LSizedGraphElement
getPosition, getSize
 
Methods inherited from class de.cau.cs.kieler.klay.layered.graph.LGraphElement
compareTo
 
Methods inherited from class de.cau.cs.kieler.core.properties.MapPropertyHolder
checkProperties, copyProperties, getAllProperties, getProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LNode

public LNode()
Method Detail

toString

public String toString()

Overrides:
toString in class Object

getName

public String getName()
Returns the name of the node.

Returns:
the name, or null

getLayer

public Layer getLayer()
Returns the layer that owns this node.

Returns:
the owning layer

setLayer

public void setLayer(Layer layer)
Sets the owning layer and adds itself to the layer's list of nodes. If the node was previously in another layer, it is removed from that layer's list of nodes. Be careful not to use this method while iterating through the nodes list of the old layer nor of the new layer, since that could lead to ConcurrentModificationExceptions.

Parameters:
layer - the owner to set

setLayer

public void setLayer(int index,
                     Layer layer)
Sets the owning layer and adds itself to the layer's list of nodes at the specified position. If the node was previously in another layer, it is removed from that layer's list of nodes. Be careful not to use this method while iterating through the nodes list of the old layer nor of the new layer, since that could lead to ConcurrentModificationExceptions.

Parameters:
index - where the node should be inserted in the layer. Must be >= 0 and <= layer.getNodes().size().
layer - the owner to set.

getPorts

public List<LPort> getPorts()
Returns the list of ports of this node. The order of ports in this list corresponds to the order in which they are drawn, assuming clockwise order, starting with the north side. That order is potentially affected during the crossing minimization phase.

Returns:
the ports

getPorts

public Iterable<LPort> getPorts(PortType portType)
Returns an iterable for all ports of given type.

Parameters:
portType - a port type
Returns:
an iterable for the ports of given type

getPorts

public Iterable<LPort> getPorts(PortSide side)
Returns an iterable for all ports of given side.

Parameters:
side - a port side
Returns:
an iterable for the ports of given side

getPorts

public Iterable<LPort> getPorts(PortType portType,
                                PortSide side)
Returns an iterable for all ports of a given type and side.

Parameters:
portType - a port type.
side - a port side.
Returns:
an iterable for the ports of the given type and side.

getIncomingEdges

public Iterable<LEdge> getIncomingEdges()
Returns an iterable for all inomcing edges.

Returns:
an iterable for all incoming edges.

getOutgoingEdges

public Iterable<LEdge> getOutgoingEdges()
Returns an iterable for all outgoing edges.

Returns:
an iterable for all outgoing edges.

getConnectedEdges

public Iterable<LEdge> getConnectedEdges()
Returns an iterable for all connected edges, both incoming and outgoing.

Returns:
an iterable for all connected edges.

setLabel

public void setLabel(LLabel label)
Sets this node's label.

Parameters:
label - the new label. May be null.

getLabel

public LLabel getLabel()
Returns this node's label, if any.

Returns:
this node's label.

getMargin

public Insets.Double getMargin()
Returns the node's margin. The margin is the space around the node that is to be reserved for ports and labels.

The margin is not automatically updated. Rather, the margin has to be calculated once the port and label positions are fixed. Usually this is right before the node placement starts.

Returns:
the node's margin. May be modified.

getIndex

public int getIndex()
Returns the index of the node in the containing layer's list of nodes. Note that this method has linear running time in the number of nodes, so use it with caution.

Returns:
the index of this node, or -1 if the node has no owner

sortPorts

public void sortPorts(float[] position)
Sort the ports of this node using relative position values.

Parameters:
position - an array of position values; the identifier of each port of this node must be inside the range of the position array, since it is used as index