gov.sandia.ccaffeine.dc.user_iface.gui
Class Connection

java.lang.Object
  extended by gov.sandia.ccaffeine.dc.user_iface.gui.Connection

public class Connection
extends java.lang.Object

This class represents a link between two ComponentInstances. It holds data fields representing: the source ComponentInstance, the target ComponentInstance , and the Ports on each which are connected.


Constructor Summary
Connection(ComponentInstance src, Port srcPort, ComponentInstance trg, Port trgPort, GlobalData global)
          Creates an instance of Connection.
 
Method Summary
 void drawPath(java.awt.Graphics g)
          Paints a path between the source and the target.
 boolean equals(java.lang.Object cobj)
           
 ComponentInstance getSource()
          Returns the ComponentInstance which is the source of this Connection.
 Port getSourcePort()
          Returns the Port which is the source-port of this Connection.
 ComponentInstance getTarget()
          Returns the ComponentInstance which is the target of this Connection.
 Port getTargetPort()
          Returns the Port which is the target-port of this Connection.
 void setPoints()
          Recreates path to reflect source and target positions.
 void setValidToDraw(boolean tf)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connection

public Connection(ComponentInstance src,
                  Port srcPort,
                  ComponentInstance trg,
                  Port trgPort,
                  GlobalData global)
Creates an instance of Connection. The Connection connects the specified souceport on the specified source to the specified targetport on the specified target. The refearence to Builder provides access to global variables.

Method Detail

equals

public boolean equals(java.lang.Object cobj)
Overrides:
equals in class java.lang.Object

setPoints

public void setPoints()
Recreates path to reflect source and target positions. Looks at the positions of the target and source and makes a right-angle path between the two ports. Called by Arena whenever an ComponentInstance is moved.


setValidToDraw

public void setValidToDraw(boolean tf)

drawPath

public void drawPath(java.awt.Graphics g)
Paints a path between the source and the target. Takes the coordinates created by SetPoints() and connects them with colored lines to create a path. The path is drawn on the Arena's Graphics object. The path is drawn in blue, except for the line-segment extending from the source-port which is red.


getSource

public ComponentInstance getSource()
Returns the ComponentInstance which is the source of this Connection.

Returns:
an ComponentInstance

getTarget

public ComponentInstance getTarget()
Returns the ComponentInstance which is the target of this Connection.

Returns:
an ComponentInstance

getSourcePort

public Port getSourcePort()
Returns the Port which is the source-port of this Connection.

Returns:
a Port

getTargetPort

public Port getTargetPort()
Returns the Port which is the target-port of this Connection.

Returns:
a Port