ptolemy.vergil.actor
Class PortTerminal

java.lang.Object
  extended by diva.canvas.AbstractFigure
      extended by diva.canvas.connector.TerminalFigure
          extended by ptolemy.vergil.actor.PortTerminal
All Implemented Interfaces:
CanvasComponent, Terminal, Figure, VisibleComponent, UserObjectContainer

public class PortTerminal
extends TerminalFigure

A terminal figure for ports that supports multiports. In particular, this figure provides a method to determine the "order index" of a link to the port. When multiple relations are linked to a port, the order in which they are linked matters. The provided method returns the position within that order.

When this is constructed, a figure is specified for the port, and properties of this figure, such as its bounds, whether it intersects other objects, etc., are determined by that figure. The extra decorations added to support multiple connections are not treated as part of the figure.

Since:
Ptolemy II 5.2
Version:
$Id: PortTerminal.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
PortSite
Accepted Rating:
Red (eal)
Proposed Rating:
Yellow (eal)

Field Summary
private  boolean _inside
          True if the terminal is an external port, and connections represent inside connections.
private  IOPort _port
          The port that owns this terminal.
 
Fields inherited from class diva.canvas.connector.TerminalFigure
_connectSite
 
Constructor Summary
PortTerminal(IOPort port, Figure figure, double normal, boolean inside)
          Construct a port terminal with the specified figure as the port figure.
 
Method Summary
 int getNumberOfLinks()
          Return the number of links to relations that this port has.
 int getOrderIndex(LinkManhattanConnector connector)
          Return the order index of the connection represented by the specified connector.
 IOPort getPort()
          Return the port specified in the constructor.
 
Methods inherited from class diva.canvas.connector.TerminalFigure
contains, getAttachSite, getBounds, getConnectSite, getFigure, getInteractor, getLayer, getOrigin, getParent, getShape, getToolTipText, getTransformContext, getUserObject, hit, intersects, isVisible, paint, paint, relocate, repaint, repaint, setAttachSite, setInteractor, setParent, setToolTipText, setUserObject, setVisible, transform, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_inside

private boolean _inside
True if the terminal is an external port, and connections represent inside connections.


_port

private IOPort _port
The port that owns this terminal.

Constructor Detail

PortTerminal

public PortTerminal(IOPort port,
                    Figure figure,
                    double normal,
                    boolean inside)
Construct a port terminal with the specified figure as the port figure.

Parameters:
port - The port.
figure - The associated figure.
normal - The normal direction.
inside - True if this is external port and the terminal represents inside connections.
Method Detail

getNumberOfLinks

public int getNumberOfLinks()
Return the number of links to relations that this port has.

Returns:
The size of the inside or outside relations list of the port.

getOrderIndex

public int getOrderIndex(LinkManhattanConnector connector)
Return the order index of the connection represented by the specified connector. That is, return 0 if it is the first connection, 1 if it is the second, etc. If the connector is not known, then return -1.

Parameters:
connector - The connector.
Returns:
The order index of the connection.

getPort

public IOPort getPort()
Return the port specified in the constructor.

Returns:
The port for which this is a terminal.