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

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.LPort
All Implemented Interfaces:
IPropertyHolder, Comparable<LGraphElement>

public class LPort
extends LShape

A port in a layered graph. The position of the port is relative to the upper left corner of the containing node. Contrary to the usual customs, a port's position denotes its center point, not its upper left corner. A port has only one list of incident edges; for input ports this list must only contain incoming edges, while for output ports it must only contain outgoing edges. Usually all ports are required to be either input ports or output ports.

Port must be used even if the original graph does not reveal them. In this case each edge has dedicated source and target ports, which are used to determine the points where the edge touches the source and target nodes.

Rating red

Nested Class Summary
static class LPort.SideCondition
          A condition that checks the side of ports.
static class LPort.TypeCondition
          A condition that checks the type of ports.
 
Field Summary
 
Fields inherited from class de.cau.cs.kieler.klay.layered.graph.LGraphElement
id
 
Constructor Summary
LPort()
           
 
Method Summary
 Iterable<LEdge> getConnectedEdges()
          Returns an iterable over all connected edges, both incoming and outgoing.
 Iterable<LPort> getConnectedPorts()
          Returns an iterable over all connected ports, both predecessors and successors.
 int getDegree()
          Returns this port's degree, that is, the number of edges connected to it.
 List<LEdge> getIncomingEdges()
          Returns the list of edges going into this port.
 int getIndex()
          Returns the index of the port in the containing node's list of ports.
 List<LLabel> getLabels()
          Returns this port's labels.
 String getName()
          Returns the name of the port.
 int getNetFlow()
          Returns the number of incoming edges minus the number of outgoing edges.
 LNode getNode()
          Returns the node that owns this port.
 List<LEdge> getOutgoingEdges()
          Returns the list of edges going out of this port.
 Iterable<LPort> getPredecessorPorts()
          Returns an iterable over all the port's predecessor ports.
 PortSide getSide()
          Returns the node side on which the port is drawn.
 Iterable<LPort> getSuccessorPorts()
          Returns an iterable over all the port's successor ports.
 void setNode(LNode node)
          Sets the owning node and adds itself to the node's list of ports.
 void setSide(PortSide theside)
          Sets the node side on which the port is drawn.
 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

LPort

public LPort()
Method Detail

toString

public String toString()

Overrides:
toString in class Object

getNode

public LNode getNode()
Returns the node that owns this port.

Returns:
the owning node

setNode

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

Parameters:
node - the owner to set

getSide

public PortSide getSide()
Returns the node side on which the port is drawn.

Returns:
the side

setSide

public void setSide(PortSide theside)
Sets the node side on which the port is drawn.

Parameters:
theside - the side to set

getLabels

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

Returns:
this port's labels.

getName

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

Returns:
the name, or null

getDegree

public int getDegree()
Returns this port's degree, that is, the number of edges connected to it.

Returns:
the number of edges connected to this port.

getNetFlow

public int getNetFlow()
Returns the number of incoming edges minus the number of outgoing edges. This is the net flow of the port.

Returns:
the port's net flow.

getIncomingEdges

public List<LEdge> getIncomingEdges()
Returns the list of edges going into this port.

Returns:
the incoming edges

getOutgoingEdges

public List<LEdge> getOutgoingEdges()
Returns the list of edges going out of this port.

Returns:
the outgoing edges

getConnectedEdges

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

Returns:
an iterable over all connected edges.

getPredecessorPorts

public Iterable<LPort> getPredecessorPorts()
Returns an iterable over all the port's predecessor ports.

Returns:
an iterable over all predecessor ports.

getSuccessorPorts

public Iterable<LPort> getSuccessorPorts()
Returns an iterable over all the port's successor ports.

Returns:
an iterable over all successor ports.

getConnectedPorts

public Iterable<LPort> getConnectedPorts()
Returns an iterable over all connected ports, both predecessors and successors.

Returns:
an iterable over the connected ports

getIndex

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

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