Back to index

wims  3.65+svn20090927
SetRangeTool.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.constructors.*;
00010 import rene.zirkel.objects.PointObject;
00011 import rene.zirkel.objects.PrimitiveCircleObject;
00012 
00013 public class SetRangeTool extends ObjectConstructor
00014 {      ObjectConstructor OC;
00015        PrimitiveCircleObject C;
00016        PointObject P1,P2;
00017        public SetRangeTool (ZirkelCanvas zc, PrimitiveCircleObject c,
00018                      ObjectConstructor oc)
00019        {      C=c; OC=oc;
00020               C.setSelected(true);
00021               zc.repaint();
00022        }
00023        public void mousePressed (MouseEvent e, ZirkelCanvas zc)
00024        {      if (P1==null)
00025               {      P1=zc.selectPoint(e.getX(),e.getY());
00026                      if (P1!=null)
00027                      {      P1.setSelected(true);
00028                             showStatus(zc);
00029                             zc.repaint();
00030                      }
00031               }
00032               else
00033               {      P2=zc.selectPoint(e.getX(),e.getY());
00034                      if (P2==null) return;
00035                      C.setRange(P1.getName(),P2.getName());
00036                      reset(zc);
00037               }
00038        }
00039        public void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
00040        {      zc.indicatePointObjects(e.getX(),e.getY());
00041        }
00042        public void showStatus (ZirkelCanvas zc)
00043        {      if (P1==null) zc.showStatus(
00044                      Zirkel.name("message.range.first"));
00045               else zc.showStatus(
00046                      Zirkel.name("message.range.second"));
00047        }
00048        public void reset (ZirkelCanvas zc)
00049        {      super.reset(zc);
00050               zc.setTool(OC);
00051               zc.validate();
00052               zc.repaint();
00053        }
00054 }