import java.awt.Graphics; /** This class represents a connection on the construction panel.*/ public class CP_Connection { /** References to the objects that take part in the connection. */ private CP_Item src, dest; /** The number of the ports of the objects that take part in the connection. */ private int srcPort, destPort; /** The constructor. */ public CP_Connection(CP_Item _src, int _sp, CP_Item _dest, int _dp) { src = _src; srcPort = _sp; dest = _dest; destPort = _dp; } /** Sets the source of the connection. */ public void setSrc(CP_Item _src, int _port) { src = _src; srcPort = _port; } /** Sets the destination of the connection. */ public void setDest(CP_Item _dest, int _port) { dest = _dest; destPort = _port; } /** Returns the source object of the connection. */ public CP_Item getSrc() { return src; } /** Returns the source port of the connection. */ public int getSrcPort() { return srcPort; } /** Returns the destination object of the connection. */ public CP_Item getDest() { return dest; } /** Returns the destination port of the connection. */ public int getDestPort() { return destPort; } /** Draws the connection. */ public void draw(Graphics g) { g.drawLine(src.getPortX(srcPort),src.getPortY(srcPort), dest.getPortX(destPort),dest.getPortY(destPort)); } }