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.LShape
              extended by de.cau.cs.kieler.klay.layered.graph.LNode
All Implemented Interfaces:
IPropertyHolder, Comparable<LGraphElement>

public class LNode
extends LShape

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
 void borderToContentAreaCoordinates(boolean horizontal, boolean vertical)
          Converts the position of this node from coordinates relative to the hierarchical node border to coordinates relative to that node's content area.
 KVector getAnchorPointPosition(LayeredGraph graph)
          Returns the position of this node's anchor point.
 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.
 List<LLabel> getLabels()
          Returns this node's labels.
 Layer getLayer()
          Returns the layer that owns this node.
 LInsets.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 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.
 String toString()
          
 
Methods inherited from class de.cau.cs.kieler.klay.layered.graph.LShape
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, 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.

getLabels

public List<LLabel> getLabels()
Returns this node's labels.

Returns:
this node's labels.

getMargin

public LInsets.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

borderToContentAreaCoordinates

public void borderToContentAreaCoordinates(boolean horizontal,
                                           boolean vertical)
Converts the position of this node from coordinates relative to the hierarchical node border to coordinates relative to that node's content area. The content area is the hierarchical node minus insets minus border spacing minus offset.

Parameters:
horizontal - if true, the x coordinate will be translated.
vertical - if true, the y coordinate will be translated.
Throws:
IllegalStateException - if the node is not assigned to a layer in a layered graph.

getAnchorPointPosition

public KVector getAnchorPointPosition(LayeredGraph graph)
Returns the position of this node's anchor point. This position depends on the graph's Properties.INTERACTIVE_LAYOUT_ANCHOR property.

Parameters:
graph - the layered graph.
Returns:
the anchor point position.