Back to index

wims  3.65+svn20090927
SetFixedCircle.java
Go to the documentation of this file.
00001 package rene.zirkel.tools;
00002 
00003 // file: SetFixedCircle.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 SetFixedCircle extends ObjectConstructor
00014        implements Selector
00015 {      ObjectConstructor OC;
00016        FixedCircleObject C;
00017        PointObject P1,P2;
00018        public SetFixedCircle (ZirkelCanvas zc, FixedCircleObject c,
00019                      ObjectConstructor oc)
00020        {      C=c; OC=oc;
00021               c.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                             return;
00035                      }
00036                      C.setFixed(o.getName());
00037                      C.setDragable(false);
00038                      C.updateText();
00039                      reset(zc);
00040               }
00041               else
00042               {      P2=zc.selectPoint(e.getX(),e.getY());
00043                      if (P2==null) return;
00044                      C.setFixed("d("+P1.getName()+","+P2.getName()+")");
00045                      reset(zc);
00046               }
00047        }
00048        public void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
00049        {      zc.indicateWithSelector(e.getX(),e.getY(),this);
00050        }
00051        public void showStatus (ZirkelCanvas zc)
00052        {      if (P1==null) zc.showStatus(
00053                      Zirkel.name("message.setfixedcircle.first"));
00054               else zc.showStatus(
00055                      Zirkel.name("message.setfixedcircle.second"));
00056        }
00057        public void reset (ZirkelCanvas zc)
00058        {      super.reset(zc);
00059               zc.setTool(OC);
00060               zc.validate();
00061               showStatus(zc);
00062               zc.repaint();
00063               zc.check();
00064        }
00065        public boolean useSmartBoard ()
00066        {      return P1!=null;
00067        }
00068        public boolean isAdmissible(ZirkelCanvas zc, ConstructionObject o)
00069        {      if ((o instanceof PointObject || o instanceof SegmentObject 
00070                      || o instanceof FixedCircleObject ||
00071                      o instanceof CircleObject || o instanceof ExpressionObject) &&
00072                      !zc.getConstruction().dependsOn(o,C)) return true;
00073               return false;
00074        }
00075 }