//***************************************************************************** // // Beenish Chaudry, Geetika Tewari, Elif Tosun and // Ileana Streinu // // Summer 1999, Fall 1999, Spring 2000 // //***************************************************************************** // // // State.java // // //***************************************************************************** import java.awt.*; import java.awt.event.*; import java.lang.*; import java.io.*; import java.applet.*; public class State { // Mouse Click state int stateMouse; int oldStateMouse; // old state - restore edit state after setting the origin // Key State int stateKey; int oldStateKey; // current object settings, for selected and new objects PointObj defPoint; // a temporary point with default settings PointObj point; //a temporary point used to store the information while // a point is clicked on, or dragged //so that a new PointObj will not be //created every time the mouse is clicked /* // For further extensions LineObj line; //a temporary line used to store the information while // a new line is being created - clicked on, or dragged //so that a new pt will not be //created every time the mouse is clicked */ int stateAppearanceP; // whether to use default or current settings // when inserting new points int stateAppearanceL; // whether to use default or current settings // when inserting new lines // Resizing int stateResize; // Origin int stateOrigin; // Frame of Reference, Grid, Parabola // for points int stateFrameRefer; int stateGrid; int stateParabola; int stateAxes; int stateOrCoord; // Colors, various general Color background; Color grid_line_color; Color parabola_color; Color axes_color; Color frame_of_ref_color; Color or_coord_color; // Labels, Coordinates int stateLabel; // controls how the point labels are displayed, // for the whole set of points int stateCoord; // controls how the coordinates of the points are displayed int stateEquation; // controls how the equation of a line is displayed //************************* // // State Constructor // //************************* public State() { // mouse stateMouse = StateMouse.insertP; oldStateMouse = stateMouse; // key state stateKey = StateKey.inactive; oldStateKey = StateKey.inactive; // appearance defPoint = new PointObj(); point = new PointObj(); stateAppearanceP = StateAppearance.currentP; stateAppearanceL = StateAppearance.currentL; // line = new LineObj(); // later // is window resizable ? stateResize = StateResize.not; // origin stateOrigin = StateOrigin.standard; // Drawing states for windows // frame of reference, grid, parabola stateFrameRefer = StateFrameRefer.not; stateGrid = StateGrid.not; stateParabola = StateParabola.not; stateAxes = StateAxes.yes; stateOrCoord = StateOrCoord.not; // Colors for window options background = Constants.backgroundP; grid_line_color = Constants.gridC; parabola_color = Constants.paraC; axes_color = Constants.axesC; frame_of_ref_color = Constants.frameC; or_coord_color = Constants.orcoordC; // Labels stateLabel = StateLabel.insert; stateCoord = StateCoord.without; stateEquation = StateEquation.without; }// end constructor //************************* // // Reset // //************************* public void Reset() { // mouse stateMouse = StateMouse.insertP; oldStateMouse = stateMouse; // key state stateKey = StateKey.inactive; oldStateKey = StateKey.inactive; // appearance defPoint.Reset(); // theoretically, the appearance of this point // never changes, but the x y coord are used point.Reset(); stateAppearanceP = StateAppearance.currentP; stateAppearanceL = StateAppearance.currentL; // line.Reset(); // later // window resizable ? stateResize = StateResize.not; // origin stateOrigin = StateOrigin.standard; // frame of reference, grid, parabola, axes stateFrameRefer = StateFrameRefer.not; stateGrid = StateGrid.not; stateParabola = StateParabola.not; stateAxes = StateAxes.yes; stateOrCoord = StateOrCoord.not; // labels, coordinates stateLabel = StateLabel.insert; stateCoord = StateCoord.without; stateEquation = StateEquation.without; // Colors for window options background = Constants.backgroundP; grid_line_color = Constants.gridC; parabola_color = Constants.paraC; axes_color = Constants.axesC; frame_of_ref_color = Constants.frameC; or_coord_color = Constants.orcoordC; }//end Reset //************************************ // // SaveStateMouse // // save the state of the mouse // used in mouseHandler while setting the origin // //************************************ public void SaveStateMouse() { oldStateMouse = stateMouse; }//end SaveStateMouse //************************************ // // RestoreStateMouse // // restore the old state of the mouse // used in mouseHandler after setting the origin // //************************************ public void RestoreStateMouse() { stateMouse = oldStateMouse; }//end RestoreStateMouse }//end of class State