Back to index

wims  3.65+svn20090927
BinderTool.java
Go to the documentation of this file.
00001 package rene.zirkel.tools;
00002 
00003 // file: Binder.java
00004 
00005 import java.awt.event.*;
00006 
00007 import rene.zirkel.Zirkel;
00008 import rene.zirkel.ZirkelCanvas;
00009 import rene.zirkel.construction.*;
00010 import rene.zirkel.constructors.*;
00011 import rene.zirkel.objects.*;
00012 
00013 public class BinderTool extends ObjectConstructor
00014        implements Selector
00015 {      ObjectConstructor OC;
00016        PointObject P;
00017        
00018        public BinderTool (ZirkelCanvas zc, PointObject p, ObjectConstructor oc)
00019        {      P=p; OC=oc;
00020               P.setSelected(true);
00021               zc.repaint();
00022        }
00023 
00024        boolean Control;
00025        
00026        public void mousePressed (MouseEvent e, ZirkelCanvas zc)
00027        {      Control=e.isControlDown();
00028               ConstructionObject o=zc.selectWithSelector(e.getX(),e.getY(),this);
00029               if (o==null) return;
00030               if (Control && !(o instanceof InsideObject)) return;
00031               if (zc.getConstruction().dependsOn(o,P)) return;
00032               P.setBound(o.getName());
00033               if (o instanceof InsideObject)
00034               {      if (Control || !(o instanceof PointonObject)) P.setInside(true);
00035               }
00036               else P.setUseAlpha(!e.isShiftDown());
00037               zc.getConstruction().updateCircleDep();
00038               zc.repaint();
00039               reset(zc);
00040        }
00041        
00042        public void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
00043        {      Control=e.isControlDown();
00044               zc.indicateWithSelector(e.getX(),e.getY(),this);
00045        }
00046 
00047        public boolean isAdmissible (ZirkelCanvas zc, ConstructionObject o) 
00048        {      if ((o instanceof InsideObject || o instanceof PointonObject) && 
00049                      !zc.getConstruction().dependsOn(o,P)) return true;
00050               return false;
00051        }
00052        
00053        public void showStatus (ZirkelCanvas zc)
00054        {      zc.showStatus(
00055                      Zirkel.name("message.bindpoint"));
00056        }
00057        public void reset (ZirkelCanvas zc)
00058        {      super.reset(zc);
00059               zc.setTool(OC);
00060               zc.validate();
00061               zc.repaint();
00062        }
00063        public boolean useSmartBoard ()
00064        {      return false;
00065        }
00066 }