ptolemy.vergil.actor
Class PortConnectSite

java.lang.Object
  extended by diva.canvas.AbstractSite
      extended by ptolemy.vergil.actor.PortConnectSite
All Implemented Interfaces:
Site

public class PortConnectSite
extends AbstractSite

A site for instances of PortTerminal. For non-muiltiports, a PortTerminal will have exactly one of these sites, and it will be the connect site for the terminal. Multiports, however, will generate distinct site for each connection to the multiport.

The normal for this site (the direction in which connections are made to it) is fixed when the site is constructed, and cannot be changed after that.

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

Field Summary
private  int _id
          The ID.
private  Figure _parentFigure
          The parent figure.
private  PortTerminal _terminal
          The port terminal.
 
Fields inherited from class diva.canvas.AbstractSite
_hasNormal, _normal
 
Constructor Summary
PortConnectSite(Figure figure, PortTerminal terminal, int id, double normal)
          Create a port connect site for the specified figure and id.
 
Method Summary
 Figure getFigure()
          Return the parent figure specified in the constructor.
 int getID()
          Return the ID specified in the constructor.
 java.awt.geom.Point2D getPoint(double normal)
          Get the position of this site.
 PortTerminal getTerminal()
          Get the terminal to which this site belongs.
 double getX()
          Get the horizontal position of this site with the normal that was set up by the constructor.
 double getY()
          Get the vertical position of this site with the normal that was set up by the constructor.
 void setNormal(double normal)
          Do nothing.
 java.lang.String toString()
          Return a string representation of this connect site.
 
Methods inherited from class diva.canvas.AbstractSite
getNormal, getPoint, getPoint, getPoint, getTransformContext, hasNormal, isNormal, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_id

private int _id
The ID.


_parentFigure

private Figure _parentFigure
The parent figure.


_terminal

private PortTerminal _terminal
The port terminal.

Constructor Detail

PortConnectSite

public PortConnectSite(Figure figure,
                       PortTerminal terminal,
                       int id,
                       double normal)
Create a port connect site for the specified figure and id. An id of zero is the default site at the port icon. Larger ids are reserved for sites that are used to distinguish multiple connections to a multiport.

Parameters:
figure - The parent figure.
terminal - The port terminal.
id - The ID.
normal - The normal for this connect site.
Method Detail

getFigure

public Figure getFigure()
Return the parent figure specified in the constructor.

Specified by:
getFigure in interface Site
Specified by:
getFigure in class AbstractSite
Returns:
The parent figure.

getID

public int getID()
Return the ID specified in the constructor. The default ID is zero. When additional instances of this site are associated with an instance of PortTerminal, they each get a unique ID starting with 1 and increasing by 1. The ID determines the position of the site relative to the port.

Specified by:
getID in interface Site
Specified by:
getID in class AbstractSite
Returns:
The ID of the site.

getPoint

public java.awt.geom.Point2D getPoint(double normal)
Get the position of this site.

Specified by:
getPoint in interface Site
Overrides:
getPoint in class AbstractSite
Parameters:
normal - The normal.
Returns:
The position of this site.

getTerminal

public PortTerminal getTerminal()
Get the terminal to which this site belongs.

Returns:
The terminal to which this site belongs.

getX

public double getX()
Get the horizontal position of this site with the normal that was set up by the constructor.

Specified by:
getX in interface Site
Specified by:
getX in class AbstractSite
Returns:
The horizontal position of this site.

getY

public double getY()
Get the vertical position of this site with the normal that was set up by the constructor.

Specified by:
getY in interface Site
Specified by:
getY in class AbstractSite
Returns:
The vertical position of this site.

setNormal

public void setNormal(double normal)
Do nothing. The normal is fixed at the time this is constructed.

Specified by:
setNormal in interface Site
Overrides:
setNormal in class AbstractSite
Parameters:
normal - The normal.

toString

public java.lang.String toString()
Return a string representation of this connect site.

Overrides:
toString in class java.lang.Object
Returns:
The name of the port and the ID.