//***************************************************************************** // // Beenish Chaudry, Geetika Tewari, Elif Tosun and // Ileana Streinu // // Summer 1999, Fall 1999, Spring 2000 // //***************************************************************************** // // MenuBarPoint.java // //***************************************************************************** import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.lang.*; import java.net.*; public class MenuBarPoint extends MenuBar implements ActionListener, ItemListener { FramePoint bf; // parent frame window //****************************************************************** // // Menu variables // //****************************************************************** Menu mfile, // file medit, // edit mappearance, // edit appearance mshape, mfill, mfillcolor, mcontour, mcontourcolor, mlabel, mcoord, mvisib, mwindow, mbackground, // window mgrid, mgline, mframe, mgframe, morcoord, mgorcoord, mpara, mgpara, maxes, mgaxes, mresetsize, msop, // set of Points minterpret, morigin, morient, munitL, mmanipulate, mzoom, // mtranslate, mview, mvline, mvinfo; // Views MenuItem // File menu fnewps, freset, fquit, // Edit menu, select options eselectall, //Selects all the points edeselectall, //Selects all selected points // Edit Menu, default settings edefault, //if user opts for the default settings of PointObj ecurrentset, //if the user wants to maintain the current settings // Set of points, Interpretation, Origin menu oother, oabs, ocenter, // Set of points, Interpretation, Unit Length uLreset, //reset the denom. and numerator of UnitL to 1, 1 uLup, //increases the value of the unit length uLdown, //decreases the value of the unit length // Set of points, manipulation, zoom and translate zin, zout, mtranslate; CheckboxMenuItem //----------------- // Edit menu //----------------- einsert, // Edit Menu emove, edelete, eselect, eelabel, // edit label emoveLabel, emoveCoord, chcontour, // Edit Menu, Edit Appearance, Set Contour chnocontour, chfill, chnofill, cblack, cred, cblue, // Edit Menu, Edit Appearance, Contour Color fred, fcyan, fmagenta, fblack, // Edit Menu, Edit Appearance, Fill Color sscircle, slcircle, ssquare, // Edit Menu, Edit Appearance, Set shape chvisible, // Edit Menu, Edit Appearance, Visible chinvisible, lwithout, // Edit Menu, Edit Appearance, Display Label luser, linsert, lxcoord, cowithout, // Edit Menu, Edit Appearance, Coordinates coabsolute, corelative, chFrameColor, // show FrameColor chnoFrameColor, // without FrameColor //------------ // window menu //------------ chnotresize, // Window Menu, Resize chbasic, chaspect, // Window menu, Reset resetBasic, // resets size with Basic option resetAspect, // reset size of window preserving Aspect Ration // Window menu, Background color bpink, byellow, bgreen, bwhite, borange, chgrid, // Window Menu. Grid, Parabola and Frame of Reference chnogrid, chparabola, chnoparabola, chframeofref, chnoframeofref, chaxes, chnoaxes, chorigin, chnoorigin, // Window Menu, grid etc colors lblack, lblue, lred, // grid line color frblack, frblue, frred, // frame of reference color orblack, orblue, orred, // origin of coordinates color pablack, pablue, pared, // parabola color axblack, axblue, axred, // axes color //-------------------- // set of points menu //-------------------- orientYup, // Set of Points, Interpretation, Unit Length orientYdown, //-------------- // views menu //------------- vlopen, // View Menu, Line Frame and InfoFrame open and close vlclose, viopen, viclose; //****************************************************************** // // MenuBarPoint constructor // //****************************************************************** public MenuBarPoint(FramePoint bff) { super(); bf = bff; //*********** // // File Menu // //*********** mfile = new Menu("File"); freset = new MenuItem("Reset"); fnewps = new MenuItem("New Set of Points"); fquit = new MenuItem("Quit"); mfile.add(fnewps); mfile.add(freset); mfile.add(fquit); fnewps.addActionListener(this); freset.addActionListener(this); fquit.addActionListener(this); add(mfile); //*********** // //Edit Menu // //*********** medit = new Menu("Edit"); einsert = new CheckboxMenuItem("Insert Point"); emove = new CheckboxMenuItem("Move Point"); edelete = new CheckboxMenuItem("Delete Point"); eselect = new CheckboxMenuItem("Select Point"); eelabel = new CheckboxMenuItem("Edit Point User Label"); emoveLabel = new CheckboxMenuItem("Move Point Label"); emoveCoord = new CheckboxMenuItem("Move Point Coordinates"); eselectall= new MenuItem("Select All Points"); edeselectall = new MenuItem("Deselect All Points"); mappearance = new Menu("Edit Point Appearance"); chFrameColor = new CheckboxMenuItem("Show Color Panel"); chnoFrameColor= new CheckboxMenuItem("Hide Color Panel"); edefault = new MenuItem("Default Settings for New Points"); //----------------------------------- // Edit/ Edit Point Appearance Menu //----------------------------------- mshape = new Menu("Point Shape"); mlabel = new Menu("Point Label"); mcoord = new Menu("Point Coordinates"); mfill = new Menu("Point Fill"); mcontour = new Menu("Point Contour"); mvisib = new Menu("Point Visibility"); //-------------------- // Shape //-------------------- sscircle = new CheckboxMenuItem("Small Circle"); slcircle = new CheckboxMenuItem("Large Circle"); ssquare = new CheckboxMenuItem("Square"); mshape.add(sscircle); mshape.add(slcircle); mshape.add(ssquare); sscircle.addItemListener(this); slcircle.addItemListener(this); ssquare.addItemListener(this); //--------------- // Label //-------------- lwithout = new CheckboxMenuItem("No Label"); luser = new CheckboxMenuItem("User Label"); linsert = new CheckboxMenuItem("Insert Order"); lxcoord = new CheckboxMenuItem("x-coordinate Order"); mlabel.add(lwithout); mlabel.add(luser); mlabel.add(linsert); mlabel.add(lxcoord); lwithout.addItemListener(this); luser.addItemListener(this); linsert.addItemListener(this); lxcoord.addItemListener(this); //---------------- // Coordinates //---------------- cowithout = new CheckboxMenuItem("No Coordinates"); coabsolute = new CheckboxMenuItem("Absolute"); corelative = new CheckboxMenuItem("Relative"); mcoord.add(cowithout); mcoord.add(coabsolute); mcoord.add(corelative); cowithout.addItemListener(this); coabsolute.addItemListener(this); corelative.addItemListener(this); //------------------------------- //Edit/Edit Appearance/Fill Menu //------------------------------- chfill = new CheckboxMenuItem("Fill"); chnofill = new CheckboxMenuItem("No Fill"); mfillcolor = new Menu("Fill Color"); fred = new CheckboxMenuItem("Red"); fcyan = new CheckboxMenuItem("Cyan"); fmagenta = new CheckboxMenuItem("Magenta"); fblack = new CheckboxMenuItem("Black"); mfillcolor.add(fred); mfillcolor.add(fcyan); mfillcolor.add(fmagenta); mfillcolor.add(fblack); mfill.add(chfill); mfill.add(chnofill); mfill.add(mfillcolor); fred.addItemListener(this); fcyan.addItemListener(this); fmagenta.addItemListener(this); fblack.addItemListener(this); chfill.addItemListener(this); chnofill.addItemListener(this); //------------- // Contour //------------- mcontourcolor = new Menu("Contour Color"); chcontour = new CheckboxMenuItem("Contour"); chnocontour = new CheckboxMenuItem("No Contour"); cblack = new CheckboxMenuItem("Black"); cred = new CheckboxMenuItem("Red"); cblue = new CheckboxMenuItem("Blue"); mcontour.add(chcontour); mcontour.add(chnocontour); mcontourcolor.add(cblack); mcontourcolor.add(cred); mcontourcolor.add(cblue); mcontour.add(mcontourcolor); cblack.addItemListener(this); cred.addItemListener(this); cblue.addItemListener(this); chcontour.addItemListener(this); chnocontour.addItemListener(this); //------------- // Visibilily //------------- chvisible = new CheckboxMenuItem("Visible"); chinvisible = new CheckboxMenuItem("Invisible"); mvisib.add(chvisible); mvisib.add(chinvisible); chvisible.addItemListener(this); chinvisible.addItemListener(this); //-------------------- mappearance.add(mshape); mappearance.add(mlabel); mappearance.add(mcoord); mappearance.add(mfill); mappearance.add(mcontour); mappearance.add(mvisib); //------------------------- // end of Edit appearance //-------------------------- //------------------ // Default settings //------------------ //... // set up edit menu medit.add(einsert); medit.add(emove); medit.add(edelete); medit.add(eselect); medit.add(eelabel); medit.add(emoveLabel); medit.add(emoveCoord); medit.addSeparator(); //draws the horizontal divider in the menu medit.add(eselectall); medit.add(edeselectall); medit.addSeparator(); //draws the horizontal divider in the menu medit.add(mappearance); medit.add(chFrameColor); medit.add(chnoFrameColor); medit.addSeparator(); medit.add(edefault); // add listeners einsert.addItemListener(this); emove.addItemListener(this); edelete.addItemListener(this); eselect.addItemListener(this); eelabel.addItemListener(this); emoveLabel.addItemListener(this); emoveCoord.addItemListener(this); eselectall.addActionListener(this); edeselectall.addActionListener(this); chFrameColor.addItemListener(this); chnoFrameColor.addItemListener(this); edefault.addActionListener(this); add(medit); //************** // //Window Menu // //************** mwindow = new Menu("Window"); mresetsize = new Menu("Reset Size"); chnotresize = new CheckboxMenuItem("Not Resizable"); chbasic = new CheckboxMenuItem("Basic"); chaspect = new CheckboxMenuItem("Aspect Ratio"); mbackground = new Menu("Background"); mgrid = new Menu("Grid"); mframe = new Menu("Frame of Reference"); morcoord = new Menu("Origin Coordinates"); mpara = new Menu("Parabola"); maxes = new Menu("Axes"); //------------- // Reset Size //------------- resetBasic= new CheckboxMenuItem("Basic"); resetAspect = new CheckboxMenuItem("With Aspect Ratio"); mresetsize.add(resetBasic); mresetsize.add(resetAspect); resetBasic.addItemListener(this); resetAspect.addItemListener(this); //----------- // Resize options //----------- chnotresize.addItemListener(this); chbasic.addItemListener(this); chaspect.addItemListener(this); //--------------- // background //--------------- bpink = new CheckboxMenuItem("Pink"); byellow = new CheckboxMenuItem("Yellow"); bgreen = new CheckboxMenuItem("Green"); bwhite = new CheckboxMenuItem("White"); borange = new CheckboxMenuItem("Orange"); mbackground.add(bpink); mbackground.add(byellow); mbackground.add(bgreen); mbackground.add(bwhite); mbackground.add(borange); bpink.addItemListener(this); byellow.addItemListener(this); bgreen.addItemListener(this); bwhite.addItemListener(this); borange.addItemListener(this); //------------------------------------------------------ // Window options: grid, parabola, frame, origin, axes //------------------------------------------------------ //------ grid ------- chgrid = new CheckboxMenuItem("Grid"); chnogrid = new CheckboxMenuItem("No Grid"); mgline = new Menu("Grid Color"); lblack = new CheckboxMenuItem("Black"); lblue = new CheckboxMenuItem("Blue"); lred = new CheckboxMenuItem("Red"); mgline.add(lblack); mgline.add(lblue); mgline.add(lred); mgrid.add(chgrid); mgrid.add(chnogrid); mgrid.add(mgline); chgrid.addItemListener(this); chnogrid.addItemListener(this); lblack.addItemListener(this); lblue.addItemListener(this); lred.addItemListener(this); //-------------------- // frame of reference //--------------------- chframeofref = new CheckboxMenuItem("Frame of Reference"); chnoframeofref = new CheckboxMenuItem("No Frame of Reference"); mgframe = new Menu("Color"); frblack = new CheckboxMenuItem("Black"); frblue = new CheckboxMenuItem("Blue"); frred = new CheckboxMenuItem("Red"); mgframe.add(frblack); mgframe.add(frblue); mgframe.add(frred); mframe.add(chframeofref); mframe.add(chnoframeofref); mframe.add(mgframe); chframeofref.addItemListener(this); chnoframeofref.addItemListener(this); frblack.addItemListener(this); frblue.addItemListener(this); frred.addItemListener(this); //------------------------- // origin coordinates //------------------------- chorigin = new CheckboxMenuItem("Origin Coordinates"); chnoorigin = new CheckboxMenuItem("No Origin Coordinates"); mgorcoord = new Menu("Color"); orblack = new CheckboxMenuItem("Black"); orblue = new CheckboxMenuItem("Blue"); orred = new CheckboxMenuItem("Red"); mgorcoord.add(orblack); mgorcoord.add(orblue); mgorcoord.add(orred); morcoord.add(chorigin); morcoord.add(chnoorigin); morcoord.add(mgorcoord); chorigin.addItemListener(this); chnoorigin.addItemListener(this); orblack.addItemListener(this); orblue.addItemListener(this); orred.addItemListener(this); //--------------- // parabola //--------------- chparabola = new CheckboxMenuItem("Parabola"); chnoparabola = new CheckboxMenuItem("No Parabola"); mgpara = new Menu("Color"); pablack = new CheckboxMenuItem("Black"); pablue = new CheckboxMenuItem("Blue"); pared = new CheckboxMenuItem("Red"); mgpara.add(pablack); mgpara.add(pablue); mgpara.add(pared); mpara.add(chparabola); mpara.add(chnoparabola); mpara.add(mgpara); chparabola.addItemListener(this); chnoparabola.addItemListener(this); pablack.addItemListener(this); pablue.addItemListener(this); pared.addItemListener(this); //---------------- // axes //--------------- chaxes = new CheckboxMenuItem("Axes"); chnoaxes = new CheckboxMenuItem("No Axes"); mgaxes = new Menu("Color"); axblack = new CheckboxMenuItem("Black"); axblue = new CheckboxMenuItem("Blue"); axred = new CheckboxMenuItem("Red"); mgaxes.add(axblack); mgaxes.add(axblue); mgaxes.add(axred); maxes.add(chaxes); maxes.add(chnoaxes); maxes.add(mgaxes); chaxes.addItemListener(this); chnoaxes.addItemListener(this); axblack.addItemListener(this); axblue.addItemListener(this); axred.addItemListener(this); //----------------- // end window menu //----------------- mwindow.add(mresetsize); mwindow.addSeparator(); mwindow.add(chnotresize); mwindow.add(chbasic); mwindow.add(chaspect); mwindow.addSeparator(); mwindow.add(mbackground); mwindow.add(mframe); mwindow.add(mgrid); mwindow.add(morcoord); mwindow.add(mpara); mwindow.add(maxes); add(mwindow); //************** // //Set of Points // //************** msop = new Menu("Set Of Points"); minterpret = new Menu("Interpretation"); //-------------- //Interpretation //------------ morigin = new Menu("Set Origin"); ocenter = new MenuItem("At Center"); oother = new MenuItem("Click to Set"); oabs = new MenuItem("Absolute location"); morient = new Menu("Orientation"); orientYup = new CheckboxMenuItem("Y Up"); orientYdown = new CheckboxMenuItem("Y Down"); munitL = new Menu("Unit Length"); uLreset = new MenuItem("Reset to (1,1)"); uLup = new MenuItem("Up by 2"); uLdown = new MenuItem("Down by 2"); ocenter.addActionListener(this); oother.addActionListener(this); oabs.addActionListener(this); orientYup.addItemListener(this); orientYdown.addItemListener(this); uLreset.addActionListener(this); uLup.addActionListener(this); uLdown.addActionListener(this); morigin.add(oabs); morigin.add(ocenter); morigin.add(oother); morient.add(orientYup); morient.add(orientYdown); munitL.add(uLreset); munitL.add(uLup); munitL.add(uLdown); minterpret.add(morigin); minterpret.add(morient); minterpret.add(munitL); //--------------------------------- //Set of Points/ Manipulation menu //--------------------------------- mmanipulate = new Menu("Manipulation"); // Zoom Menu mzoom = new Menu("Zoom (scaling)"); zin = new MenuItem("In"); zout = new MenuItem("Out"); mzoom.add(zin); mzoom.add(zout); zin.addActionListener(this); zout.addActionListener(this); mmanipulate.add(mzoom); //Translate Menu mtranslate = new MenuItem("Translate"); mtranslate.addActionListener(this); mmanipulate.add(mtranslate); //-------------------------- // end set of points menu //-------------------------- msop.add(minterpret); msop.add(mmanipulate); //***************** // //View Menu // //***************** mview = new Menu("Views"); mvline = new Menu("Line Frame"); //submenus mvinfo = new Menu("Information Window"); vlopen = new CheckboxMenuItem("Open"); //checkbox menu items for lineframe vlclose = new CheckboxMenuItem("Close"); viopen = new CheckboxMenuItem("Open"); //checkbox menu items for infoframe viclose = new CheckboxMenuItem("Close"); mvline.add(vlopen); mvline.add(vlclose); mvinfo.add(viopen); mvinfo.add(viclose); vlopen.addItemListener(this); vlclose.addItemListener(this); viopen.addItemListener(this); viclose.addItemListener(this); mview.add(mvline); mview.add(mvinfo); //---------------------- // end menu bar //--------------------- add(msop); add(mview); SetMenuState(); }//end of MenuBarPoint constructor //****************************************************************** //****************************************************************** //****************************************************************** // // ActionPerformed // //****************************************************************** //****************************************************************** //****************************************************************** public void actionPerformed(ActionEvent e) { //************ // // File Menu // //************ if (e.getSource()== fquit) { bf.ap.QuitFramePoint(); } if (e.getSource() == fnewps) { bf.ps.Reset(); // reset the set of points } if (e.getSource() == freset) { //reseting the states of various menuitems ResetMenuState(); //Resetting various other variables in FramePoint bf.Reset(); } //------------------------------- // select/deselect all //------------------------------- if(e.getSource() == edeselectall) { bf.ps.DeselectAll(); } if(e.getSource() == eselectall) { bf.ps.SelectAll(); } //------------------------------------------------------- // Edit/Default settings and current settings for Points //------------------------------------------------------- if(e.getSource() == edefault) { bf.state.stateAppearanceP = StateAppearance.defaultP; medit.remove(edefault); ecurrentset = new MenuItem("Current Settings for New Points"); medit.add(ecurrentset); ecurrentset.addActionListener(this); } if(e.getSource() == ecurrentset) { bf.state.stateAppearanceP = StateAppearance.currentP; medit.remove(ecurrentset); edefault = new MenuItem("Default Settings for New Points"); medit.add(edefault); edefault.addActionListener(this); } //*************** // //Window Menu // //*************** //--------------------- // Windows/ Reset Size //--------------------- if(e.getSource() == resetBasic) { bf.width = Constants.wFP; bf.height = Constants.hFP; bf.setSize(bf.width, bf.height); } if(e.getSource() == resetAspect) { bf.width = Constants.wFP; bf.height = Constants.hFP; bf.setSize(bf.width, bf.height); //if origin is in center, leave width and height as it is //if origin is not the center, preserves the aspect ratio if(bf.state.stateOrigin == StateOrigin.arbitrary) { bf.ps.ChangeOrAfterIncrease(); bf.ps.ChangeArrayAfterIncrease(); } } //******************** // // Set of Points Menu // //******************** //------------------------------------ // Set of Points/Interpretation/Origin //------------------------------------ if (e.getSource() == oother) { bf.state.SaveStateMouse(); // set origin at mouse click bf.state.stateMouse = StateMouse.originP; } if (e.getSource() == ocenter) { bf.state.stateOrigin = StateOrigin.center; Point pCenter = new Point(); pCenter.x = bf.getSize().width/2 - Constants.adjustw; pCenter.y = bf.getSize().height/2 - Constants.adjusth; // to get the actual height of the canvas // "adjust" is the height of the menubar bf.ps.changeOrigin(pCenter); if(bf.lf != null) bf.lf.lc.repaint(); } if (e.getSource() == oabs) { bf.state.stateOrigin = StateOrigin.arbitrary; Point pAbs = new Point(0,0); bf.ps.changeOrigin(pAbs); bf.pc.repaint(); if (bf.lf != null) bf.lf.lc.repaint(); } //----------------------------------------- // Set of Points/Interpretation/Unit Length //----------------------------------------- if(e.getSource() == uLreset) { bf.ps.changeUnitL(new Rational(1,1)); } if(e.getSource() == uLup) { bf.ps.changeUnitLup(); } if(e.getSource() == uLdown) { bf.ps.changeUnitLdown(); } bf.pc.repaint(); }//end of actionPerformed method //****************************************************************** // // itemStateChanged // //****************************************************************** public void itemStateChanged (ItemEvent e) { //*********** // // Edit Menu // //*********** //------------- // insert //------------ if (e.getSource() == einsert) { // tell how to interpret mouse clicks: insert new points bf.state.stateMouse = StateMouse.insertP; // synchronize the states of the Edit menu items einsert.setState(true); emove.setState(false); edelete.setState(false); eselect.setState(false); eelabel.setState(false); emoveLabel.setState(false); emoveCoord.setState(false); }// end if insert //-------------- // move //-------------- else if (e.getSource() == emove) { // tell how to interpret mouse clicks: move points bf.state.stateMouse = StateMouse.moveP; // deselect all // bf.ps.DeselectAll(); // decide if I want to do this, or move all points simultaneously // synchronize the states of the Edit menu items emove.setState(true); edelete.setState(false); einsert.setState(false); eselect.setState(false); eelabel.setState(false); emoveLabel.setState(false); emoveCoord.setState(false); } //-------------- // delete //-------------- else if (e.getSource() == edelete) { // tell how to interpret mouse clicks: delete points bf.state.stateMouse = StateMouse.deleteP; // synchronize the states of the Edit menu items edelete.setState(true); emove.setState(false); einsert.setState(false); eselect.setState(false); eelabel.setState(false); emoveLabel.setState(false); emoveCoord.setState(false); }// end if delete //------------------------------- // select //------------------------------- else if (e.getSource() == eselect) { bf.state.stateMouse = StateMouse.selectP; einsert.setState(false); emove.setState(false); edelete.setState(false); eselect.setState(true); eelabel.setState(false); emoveLabel.setState(false); emoveCoord.setState(false); } //------------------------------- // edit user label //------------------------------- else if (e.getSource() == eelabel) { bf.state.stateMouse = StateMouse.elabelP; bf.state.stateKey = StateKey.labeleditP; einsert.setState(false); emove.setState(false); edelete.setState(false); eselect.setState(false); eelabel.setState(true); emoveLabel.setState(false); emoveCoord.setState(false); // pop up a LabelEdit Dialog Box System.out.println("In labeledit mode, pop-up FrameText"); //String s = bf.ft.EditText(..., bf.current point label???) // this function does not change directly the label of the point // but returns the new label as a string // set current point label to this s // when done, reset the state of the Key // if (bf.state.stateKey == StateKey.labeleditP) // bf.state.stateKey = bf.state.oldStateKey; System.out.println("Done with key in labeledit mode"); }// end eelabel //-------------- // moveLabel //-------------- else if (e.getSource() == emoveLabel) { // tell how to interpret mouse clicks: move labels of points bf.state.stateMouse = StateMouse.moveLP; // synchronize the states of the Edit menu items emove.setState(false); edelete.setState(false); einsert.setState(false); eselect.setState(false); eelabel.setState(false); emoveLabel.setState(true); emoveCoord.setState(false); } //-------------- // moveCoord //-------------- else if (e.getSource() == emoveCoord) { // tell how to interpret mouse clicks: move coordinates of points bf.state.stateMouse = StateMouse.moveCP; // synchronize the states of the Edit menu items emove.setState(false); edelete.setState(false); einsert.setState(false); eselect.setState(false); eelabel.setState(false); emoveLabel.setState(false); emoveCoord.setState(true); } // end Edit menu items //************************** // // Edit/Edit Appearance // //************************** //------------------------------- // edit appearance panel //------------------------------- //---------------------------- // FrameColor - show or hide //---------------------------- if (e.getSource() == chFrameColor) { chFrameColor.setState(true); chnoFrameColor.setState(false); bf.cf.setVisible(true); } if (e.getSource() == chnoFrameColor) { chFrameColor.setState(false); chnoFrameColor.setState(true); bf.cf.setVisible(false); } //------------------------------- // Edit/Edit Appearance/ Shape //------------------------------- if(e.getSource() == sscircle) { bf.state.point.appearanceP.shape = StateShape.scircle; bf.ps.SetShapeSelected(StateShape.scircle); sscircle.setState(true); slcircle.setState(false); ssquare.setState(false); } if(e.getSource() == slcircle) { bf.state.point.appearanceP.shape = StateShape.lcircle; bf.ps.SetShapeSelected(StateShape.lcircle); sscircle.setState(false); slcircle.setState(true); ssquare.setState(false); } if(e.getSource() == ssquare) { bf.state.point.appearanceP.shape = StateShape.square; bf.ps.SetShapeSelected(StateShape.square); sscircle.setState(false); slcircle.setState(false); ssquare.setState(true); } //---------------------------- // Fill //---------------------------- if (e.getSource() == chfill) { chfill.setState(true); chnofill.setState(false); bf.state.point.appearanceP.fill = StateFill.fill; bf.ps.SetFillSelected(StateFill.fill); } if (e.getSource() == chnofill) { chfill.setState(false); chnofill.setState(true); bf.state.point.appearanceP.fill = StateFill.nofill; bf.ps.SetFillSelected(StateFill.nofill); } //---------------------------- // Edit/Appearance/Fill Color //---------------------------- if(e.getSource() == fred) { bf.state.point.appearanceP.fillcolor = Color.red; bf.ps.SetFillColorSelected(Color.red); fred.setState(true); fcyan.setState(false); fmagenta.setState(false); fblack.setState(false); } if(e.getSource() == fcyan) { bf.state.point.appearanceP.fillcolor = Color.cyan; bf.ps.SetFillColorSelected(Color.cyan); fred.setState(false); fcyan.setState(true); fmagenta.setState(false); fblack.setState(false); } if(e.getSource() == fmagenta) { bf.state.point.appearanceP.fillcolor = Color.magenta; bf.ps.SetFillColorSelected(Color.magenta); fred.setState(false); fcyan.setState(false); fmagenta.setState(true); fblack.setState(false); } if(e.getSource() == fblack) { bf.state.point.appearanceP.fillcolor = Color.black; bf.ps.SetFillColorSelected(Color.black); fred.setState(false); fcyan.setState(false); fmagenta.setState(false); fblack.setState(true); } //---------------------------- // Contour //---------------------------- if (e.getSource() == chcontour) { chcontour.setState(true); chnocontour.setState(false); bf.state.point.appearanceP.contour = StateContour.contour; bf.ps.SetContourSelected(StateContour.contour); } if (e.getSource() == chnocontour) { chcontour.setState(false); chnocontour.setState(true); bf.state.point.appearanceP.contour = StateContour.nocontour; bf.ps.SetContourSelected(StateContour.nocontour); } //------------------------------- // Edit/Appearance/Contour Color //------------------------------- if (e.getSource() == cblack) { bf.state.point.appearanceP.contcolor=Color.black; bf.ps.SetContourColorSelected(Color.black); cblack.setState(true); cred.setState(false); cblue.setState(false); } else if (e.getSource() == cred ) { bf.state.point.appearanceP.contcolor=Color.red; bf.ps.SetContourColorSelected(Color.red); cblack.setState(false); cred.setState(true); cblue.setState(false); } else if (e.getSource() == cblue) { bf.state.point.appearanceP.contcolor=Color.blue; bf.ps.SetContourColorSelected(Color.blue); cblack.setState(false); cred.setState(false); cblue.setState(true); } //------------------------------- // Edit/Appearance/Visibility //------------------------------- if (e.getSource() == chvisible) { chvisible.setState(true); chinvisible.setState(false); bf.state.point.appearanceP.visible = StateVisible.visible; bf.ps.SetVisibleSelected(StateVisible.visible); } if (e.getSource() == chinvisible) { chvisible.setState(false); chinvisible.setState(true); bf.state.point.appearanceP.visible = StateVisible.invisible; bf.ps.SetVisibleSelected(StateVisible.invisible); } //------------------------------- // Edit/Appearance/Label //------------------------------- if (e.getSource() == lwithout) { bf.state.stateLabel = StateLabel.without; luser.setState(false); lwithout.setState(true); linsert.setState(false); lxcoord.setState(false); } else if (e.getSource() == luser) { bf.state.stateLabel = StateLabel.user; luser.setState(true); lwithout.setState(false); linsert.setState(false); lxcoord.setState(false); } else if (e.getSource() == linsert) { bf.state.stateLabel = StateLabel.insert; luser.setState(false); lwithout.setState(false); linsert.setState(true); lxcoord.setState(false); } else if (e.getSource() == lxcoord) { bf.state.stateLabel = StateLabel.xcoord; luser.setState(false); lwithout.setState(false); linsert.setState(false); lxcoord.setState(true); } //------------------------------- // Edit/Appearance/Coordinates //------------------------------- if (e.getSource() == cowithout) { bf.state.stateCoord = StateCoord.without; cowithout.setState(true); coabsolute.setState(false); corelative.setState(false); bf.ps.SetCoordSelected(StateCoord.without); } else if (e.getSource() == coabsolute) { bf.state.stateCoord = StateCoord.absolute; cowithout.setState(false); coabsolute.setState(true); corelative.setState(false); bf.ps.SetCoordSelected(StateCoord.absolute); } else if (e.getSource() == corelative) { bf.state.stateCoord = StateCoord.relative; cowithout.setState(false); coabsolute.setState(false); corelative.setState(true); bf.ps.SetCoordSelected(StateCoord.relative); } //*********** // // Window // //*********** //--------------------- // Windows/ Reset Size //--------------------- if(e.getSource() == resetBasic) { resetBasic.setState(true); resetAspect.setState(false); chnotresize.setState(false); chbasic.setState(false); chaspect.setState(false); bf.width = Constants.wFP; bf.height = Constants.hFP; bf.setSize(bf.width, bf.height); } if(e.getSource() == resetAspect) { resetBasic.setState(false); resetAspect.setState(true); chnotresize.setState(false); chbasic.setState(false); chaspect.setState(false); bf.width = Constants.wFP; bf.height = Constants.hFP; bf.setSize(bf.width, bf.height); //if origin is in center, leave width and height as it is //if origin is not the center, preserves the aspect ratio if(bf.state.stateOrigin == StateOrigin.arbitrary) { bf.ps.ChangeOrAfterIncrease(); bf.ps.ChangeArrayAfterIncrease(); } } //------------- // resize //------------- if(e.getSource() == chnotresize) { resetBasic.setState(false); resetAspect.setState(false); chnotresize.setState(true); chbasic.setState(false); chaspect.setState(false); bf.state.stateResize = StateResize.not; bf.setResizable(false); } if(e.getSource() == chbasic) { resetBasic.setState(false); resetAspect.setState(false); chnotresize.setState(false); chbasic.setState(true); chaspect.setState(false); bf.state.stateResize = StateResize.basic; bf.setResizable(true); } if(e.getSource() == chaspect) { resetBasic.setState(false); resetAspect.setState(false); chnotresize.setState(false); chbasic.setState(false); chaspect.setState(true); bf.state.stateResize = StateResize.aspect; bf.setResizable(true); } //------------------------- // Window/ Background menu //------------------------- if (e.getSource() == bpink) { bpink.setState(true); byellow.setState(false); bgreen.setState(false); bwhite.setState(false); borange.setState(false); bf.pc.setBackground(Color.pink); } if (e.getSource() == byellow) { bpink.setState(false); byellow.setState(true); bgreen.setState(false); bwhite.setState(false); borange.setState(false); bf.pc.setBackground(Color.yellow); } if (e.getSource() == bgreen) { bpink.setState(false); byellow.setState(false); bgreen.setState(true); bwhite.setState(false); borange.setState(false); bf.pc.setBackground(Color.green); } if (e.getSource() == bwhite) { bpink.setState(false); byellow.setState(false); bgreen.setState(false); bwhite.setState(true); borange.setState(false); bf.pc.setBackground(Color.white); } if (e.getSource() == borange) { bpink.setState(false); byellow.setState(false); bgreen.setState(false); bwhite.setState(false); borange.setState(true); bf.pc.setBackground(Color.orange); } //---------------------- // Window/ Grid Colors //---------------------- if(e.getSource() == lblack) { lblack.setState(true); lblue.setState(false); lred.setState(false); bf.state.grid_line_color = Color.black; } if(e.getSource() == lblue) { lblack.setState(false); lblue.setState(true); lred.setState(false); bf.state.grid_line_color = Color.blue; } if(e.getSource() == lred) { lblack.setState(false); lblue.setState(false); lred.setState(true); bf.state.grid_line_color = Color.red; } //------------------------------------ // Window/ Frame of Reference colors //------------------------------------ if(e.getSource() == frblack) { frblack.setState(true); frblue.setState(false); frred.setState(false); bf.state.frame_of_ref_color = Color.black; } if(e.getSource() == frblue) { frblack.setState(true); frblue.setState(false); frred.setState(false); bf.state.frame_of_ref_color = Color.blue; } if(e.getSource() == frred) { frblack.setState(true); frblue.setState(false); frred.setState(false); bf.state.frame_of_ref_color = Color.red; } //------------------------------------ // Window/ Origin Coordinates colors //------------------------------------ if(e.getSource() == orblack) { orblack.setState(true); orblue.setState(false); orred.setState(false); bf.state.or_coord_color = Color.black; } if(e.getSource() == orblue) { orblack.setState(false); orblue.setState(true); orred.setState(false); bf.state.or_coord_color = Color.blue; } if(e.getSource() == orred) { orblack.setState(false); orblue.setState(false); orred.setState(true); bf.state.or_coord_color = Color.red; } //------------------------------------ // Window/ Parabola colors //------------------------------------ if(e.getSource() == pablack) { pablack.setState(true); pablue.setState(false); pared.setState(false); bf.state.parabola_color = Color.black; } if(e.getSource() == pablue) { pablack.setState(false); pablue.setState(true); pared.setState(false); bf.state.parabola_color = Color.blue; } if(e.getSource() == pared) { pablack.setState(false); pablue.setState(false); pared.setState(true); bf.state.parabola_color = Color.red; } //------------------------------------ // Window/ Axes colors //------------------------------------ if(e.getSource() == axblack) { axblack.setState(true); axblue.setState(false); axred.setState(false); bf.state.axes_color = Color.black; } if(e.getSource() == axblue) { axblack.setState(true); axblue.setState(false); axred.setState(false); bf.state.axes_color = Color.blue; } if(e.getSource() == axred) { axblack.setState(true); axblue.setState(false); axred.setState(false); bf.state.axes_color = Color.red; } //-------------- // Window/ Grid //-------------- if (e.getSource() == chgrid) { chgrid.setState(true); chnogrid.setState(false); bf.state.stateGrid = StateGrid.yes; } if (e.getSource() == chnogrid) { chgrid.setState(false); chnogrid.setState(true); bf.state.stateGrid = StateGrid.not; } //-------------------- // Window/Axes //-------------------- if (e.getSource() == chaxes) { chaxes.setState(true); chnoaxes.setState(false); bf.state.stateAxes = StateAxes.yes; } if (e.getSource() == chnoaxes) { chaxes.setState(false); chnoaxes.setState(true); bf.state.stateAxes = StateAxes.not; } //-------------------- // Window/Origin Coordinates //-------------------- if (e.getSource() == chorigin) { chorigin.setState(true); chnoorigin.setState(false); bf.state.stateOrCoord = StateOrCoord.yes; } if (e.getSource() == chnoorigin) { chorigin.setState(false); chnoorigin.setState(true); bf.state.stateOrCoord = StateOrCoord.not; } //-------------------- // Window/Parabola //-------------------- if (e.getSource() == chparabola) { chparabola.setState(true); chnoparabola.setState(false); bf.state.stateParabola = StateParabola.yes; } if (e.getSource() == chnoparabola) { chparabola.setState(false); chnoparabola.setState(true); bf.state.stateParabola = StateParabola.not; } //----------------------------- // Window/ Frame of Reference //----------------------------- if (e.getSource() == chframeofref) { chframeofref.setState(true); chnoframeofref.setState(false); bf.state.stateFrameRefer = StateFrameRefer.yes; } if (e.getSource() == chnoframeofref) { chframeofref.setState(false); chnoframeofref.setState(true); bf.state.stateFrameRefer = StateFrameRefer.not; } //******************** // // Set of Points // //******************** //orient menu items if (e.getSource() == orientYup) { orientYup.setState(true); orientYdown.setState(false); bf.state.stateOrigin = StateOrigin.standard; bf.ps.changeOrient(true); } else if (e.getSource() == orientYdown) { orientYdown.setState(true); orientYup.setState(false); bf.state.stateOrigin = StateOrigin.standard; bf.ps.changeOrient(false); } //************ // View Menu // //************ if (e.getSource() == vlopen) { if (bf.lf != null) bf.lf.setVisible(true); vlopen.setState(true); vlclose.setState(false); } else if (e.getSource() == vlclose) { if (bf.lf != null) bf.lf.setVisible(false); vlclose.setState(true); vlopen.setState(false); } if (e.getSource() == viopen){ if (bf.iw != null) bf.iw.setVisible(true); viopen.setState(true); viclose.setState(false); } else if (e.getSource() == viclose){ if (bf.iw != null) bf.iw.setVisible(false); viclose.setState(true); viopen.setState(false); } bf.pc.repaint(); }//end of itemStateChanged //******************************************************************* //********************************************* // // SetMenuState // Set the states of the MenuBarPoint // //********************************************* public void SetMenuState() { //****************** // // edit // //****************** einsert.setState(true); emove.setState(false); edelete.setState(false); eselect.setState(false); eelabel.setState(false); emoveLabel.setState(false); emoveCoord.setState(false); chFrameColor.setState(true); chnoFrameColor.setState(false); //----------- // shape //----------- sscircle.setState(true); slcircle.setState(false); ssquare.setState(false); //------------ // label //------------ lwithout.setState(false); luser.setState(false); linsert.setState(true); lxcoord.setState(false); //--------------- // coordinates //--------------- cowithout.setState(true); coabsolute.setState(false); corelative.setState(false); //--------------- // fill //--------------- chfill.setState(true); chnofill.setState(false); fred.setState(true); fcyan.setState(false); fmagenta.setState(false); fblack.setState(false); //--------------- // contour //--------------- chcontour.setState(true); chnocontour.setState(false); cred.setState(false); cblack.setState(true); cblue.setState(false); //--------------- // visible //--------------- chvisible.setState(true); chinvisible.setState(false); //******************* // // Window // //******************* //--------------------- // Window/Not Resizable //--------------------- chnotresize.setState(true); chbasic.setState(false); chaspect.setState(false); //----------------- // background color //----------------- bpink.setState(false); byellow.setState(false); bgreen.setState(false); bwhite.setState(true); borange.setState(false); //-------------------------------------------------- // grid, frame of reference, origin, parabola, axes //-------------------------------------------------- chgrid.setState(false); chnogrid.setState(true); chframeofref.setState(false); chnoframeofref.setState(true); chorigin.setState(false); chnoorigin.setState(true); chparabola.setState(false); chnoparabola.setState(true); chaxes.setState(true); chnoaxes.setState(false); lblack.setState(true); lblue.setState(false); lred.setState(false); frblack.setState(false); frblue.setState(true); frred.setState(false); orblack.setState(false); orblue.setState(true); orred.setState(false); pablack.setState(true); pablue.setState(false); pared.setState(false); axblack.setState(false); axblue.setState(false); axred.setState(true); //******************* // // Set Of Points // //******************* orientYdown.setState(true); orientYup.setState(false); //******************* // // Views // //******************* vlopen.setState(Constants.lineFrameStart); viopen.setState(Constants.infoFrameStart); vlclose.setState(!Constants.lineFrameStart); viclose.setState(!Constants.infoFrameStart); }// end SetMenuState //***************************************** // // Reset the state of the MenuBarPoint // //***************************************** public void ResetMenuState() { //****************** // // edit // //****************** einsert.setState(true); emove.setState(false); edelete.setState(false); eselect.setState(false); eelabel.setState(false); emoveLabel.setState(false); emoveCoord.setState(false); chFrameColor.setState(true); chnoFrameColor.setState(false); //------------ // label //------------ lwithout.setState(false); luser.setState(false); linsert.setState(true); lxcoord.setState(false); //--------------- // coordinates //--------------- cowithout.setState(true); coabsolute.setState(false); corelative.setState(false); //--------------- // fill //--------------- chfill.setState(true); chnofill.setState(false); //--------------- // contour //--------------- chcontour.setState(true); chnocontour.setState(false); //--------------- // visible //--------------- chvisible.setState(true); chinvisible.setState(false); //******************* // // Window // //******************* //--------------------- // Window/Not Resizable //--------------------- chnotresize.setState(true); chbasic.setState(false); chaspect.setState(false); //----------------- // background color //----------------- bpink.setState(false); byellow.setState(false); bgreen.setState(false); bwhite.setState(true); borange.setState(false); //-------------------------------------------------- // grid, frame of reference, origin, parabola, axes //-------------------------------------------------- chgrid.setState(false); chnogrid.setState(true); chframeofref.setState(false); chnoframeofref.setState(true); chorigin.setState(false); chnoorigin.setState(true); chparabola.setState(false); chnoparabola.setState(true); chaxes.setState(true); chnoaxes.setState(false); lblack.setState(true); lblue.setState(false); lred.setState(false); frblack.setState(false); frblue.setState(true); frred.setState(false); orblack.setState(false); orblue.setState(true); orred.setState(false); pablack.setState(true); pablue.setState(false); pared.setState(false); axblack.setState(false); axblue.setState(false); axred.setState(true); //******************* // // Set Of Points // //******************* orientYup.setState(false); orientYdown.setState(true); //******************* // // Views // //******************* vlopen.setState(Constants.lineFrameStart); viopen.setState(Constants.infoFrameStart); vlclose.setState(!Constants.lineFrameStart); viclose.setState(!Constants.infoFrameStart); }// end ResetMenuState }// end class MenuBarPoint