Back to index

wims  3.65+svn20090927
SetFixedAngle.java
Go to the documentation of this file.
00001 package rene.zirkel.tools;
00002 
00003 // file: SetRange.java
00004 
00005 import java.awt.event.MouseEvent;
00006 
00007 import rene.zirkel.Zirkel;
00008 import rene.zirkel.ZirkelCanvas;
00009 import rene.zirkel.construction.Selector;
00010 import rene.zirkel.constructors.*;
00011 import rene.zirkel.objects.*;
00012 
00013 public class SetFixedAngle extends ObjectConstructor
00014        implements Selector
00015 {      ObjectConstructor OC;
00016        FixedAngleObject A;
00017        PointObject P1,P2,P3;
00018        public SetFixedAngle (ZirkelCanvas zc, FixedAngleObject a,
00019                      ObjectConstructor oc)
00020        {      A=a; OC=oc;
00021               a.setSelected(true);
00022               zc.repaint();
00023        }
00024        public void mousePressed (MouseEvent e, ZirkelCanvas zc)
00025        {      if (P1==null)
00026               {      ConstructionObject o=
00027                             zc.selectWithSelector(e.getX(),e.getY(),this);
00028                      if (o==null) return;
00029                      if (o instanceof PointObject)
00030                      {      P1=(PointObject)o;
00031                             P1.setSelected(true);
00032                             showStatus(zc);
00033                             zc.repaint();
00034                      }
00035                      else if (o instanceof AngleObject || o instanceof FixedAngleObject
00036                                    || o instanceof ExpressionObject)
00037                      {      A.setFixed(o.getName());
00038                             A.setDragable(false);
00039                             A.updateText();
00040                             reset(zc);
00041                      }
00042               }
00043               else if (P2==null)
00044               {      P2=zc.selectPoint(e.getX(),e.getY());
00045                      if (P2!=null)
00046                      {      P2.setSelected(true);
00047                             showStatus(zc);
00048                             zc.repaint();
00049                      }
00050               }
00051               else
00052               {      P3=zc.selectPoint(e.getX(),e.getY());
00053                      if (P3==null) return;
00054                      A.setFixed("a("+P1.getName()+","+P2.getName()+","+P3.getName()+")");
00055                      reset(zc);
00056               }
00057        }
00058        public void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
00059        {      zc.indicateWithSelector(e.getX(),e.getY(),this);
00060        }
00061        public void showStatus (ZirkelCanvas zc)
00062        {      if (P1==null) zc.showStatus(
00063                      Zirkel.name("message.setfixedangle.first"));
00064               else if (P2==null) zc.showStatus(
00065                      Zirkel.name("message.setfixedangle.second"));
00066               else zc.showStatus(
00067                      Zirkel.name("message.setfixedangle.third"));
00068        }
00069        public void reset (ZirkelCanvas zc)
00070        {      super.reset(zc);
00071               zc.setTool(OC);
00072               zc.validate();
00073               zc.repaint();
00074               zc.check();
00075        }
00076        public boolean useSmartBoard ()
00077        {      return P2!=null;
00078        }
00079        public boolean isAdmissible(ZirkelCanvas zc, ConstructionObject o)
00080        {      if ((o instanceof PointObject || o instanceof AngleObject 
00081                      || o instanceof FixedAngleObject || o instanceof ExpressionObject) &&
00082                      !zc.getConstruction().dependsOn(o,A)) 
00083                             return true;
00084               return false;
00085        }
00086 }