package jsetool.gui; import java.awt.Cursor; import java.awt.event.MouseEvent; /** * * @author Mike Lawson * * @since Nov 2, 2004 * * This is the state that the drawing pane will be in when the user is * adding a state object to the drawing. * */ class DrawingAStateObjectState extends FSMDrawingState { protected Cursor drawingStateCursor = new Cursor(Cursor.CROSSHAIR_CURSOR); protected int stateNumber = 1; /** * Constructs a new state for drawing state objects * @param pane */ public DrawingAStateObjectState(FSMDrawingPane pane) { super(pane); } /** * Entering this state results in the cursor being set * to the one associated with adding a state, and dragging * is disabled. */ public void enter() { getPane().setCursor(drawingStateCursor); getPane().setIsDragging(false); } /** * When the mouse is clicked, the user is prompted for the * name of the state. A new LabeledState is added to the drawing. * @param e * @throws Exception */ public void mouseClicked(MouseEvent e) throws Exception { String stateLabel = "" + stateNumber; stateNumber++; LabeledState state = new LabeledState(stateLabel); state.setFrame(e.getX(), e.getY(), 50, 50); pane.addDrawingObject(state); pane.drawingNormalOpsSelected(); } /** * Sets the state number * @param i */ public void setStateNumber(int i) { stateNumber = i; } /** * Gets the state number * @return int */ public int getStateNumber() { return stateNumber; } public void mouseDragged(MouseEvent e) throws Exception { // nada for this state } public void mousePressed(MouseEvent e) throws Exception { // nada for this state } public void mouseReleased(MouseEvent e) throws Exception { // nada for this state } }