import java.awt.Graphics; /** This class represents a macro-command on the construction panel.*/ public class CP_MacroCommand extends CP_Item { /** A reference to the connected macro. */ private MacroCommand macro; /** A reference to a connection object that will be created when a connection is added to this object. */ private CP_Connection conn[] = new CP_Connection[4]; /** The constructor. */ public CP_MacroCommand(MacroCommand _macro) { type = 3; macro = _macro; w = 60; h = 60; for (int i=0;i<4;i++) conn[i] = null; } /** Returns the x-position of the connection port nr. "_port". */ public int getPortX(int _port) { switch(_port) { case 0: return x-w/2-3; default: return x+w/2+3; } } /** Returns the y-position of the connection port. nr. "_port". */ public int getPortY(int _port) { switch(_port) { case 1: return y-15; case 3: return y+15; default: return y; } } /** Returns the reference to the connected macro. */ public MacroCommand getMacroCommand() { return macro; } /** Sets the connection from port nr. "_port" to another object. */ public void setConnection(int _port, CP_Connection _conn) { conn[_port] = _conn; } /** Gets the connection from port nr. "_port" to another object. */ public CP_Connection getConnection(int _port) { return conn[_port]; } /** 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.drawArc(x+w/2,y-18,6,6,0,360); g.drawArc(x+w/2,y-3,6,6,0,360); g.drawArc(x+w/2,y+12,6,6,0,360); g.drawString("Macro:",x-w/2+5,y); g.drawString(name,x-w/2+5,y+10); } }