import java.awt.Graphics; /** This class represents a command on the construction panel.*/ public class CP_Command extends CP_Item { /** A reference to the connected command. */ private Command command; /** A reference to a connection object that will be created when a connection is added to this object. */ private CP_Connection conn = null; /** The constructor. */ public CP_Command(Command _command) { type = 2; command = _command; w = 80; h = 30; } /** Returns the x-position of the connection port. _port is not used here but we need it for compatibilty. */ public int getPortX(int _port) { return x-w/2-3; } /** Returns the y-position of the connection port. _port is not used here but we need it for compatibilty. */ public int getPortY(int _port) { return y; } /** Returns the reference to the connected command. */ public Command getCommand() { return command; } /** Sets the connection to another object. _port is not used here but we need it for compatibilty. */ public void setConnection(int _port, CP_Connection _conn) { conn = _conn; } /** Gets the connection to another object. _port is not used here but we need it for compatibilty. */ public CP_Connection getConnection(int _port) { return conn; } /** Draws the object. */ public void draw(Graphics g) { g.drawRect(x-w/2, y-h/2, w, h); g.drawArc(x-w/2-6,y-3,6,6,0,360); g.drawString("Command:",x-w/2+5,y); g.drawString(name,x-w/2+5,y+10); } }