Back to index

wims  3.65+svn20090927
SetAwayTool.java
Go to the documentation of this file.
00001 package rene.zirkel.tools;
00002 
00003 import java.awt.event.*;
00004 
00005 import rene.zirkel.Zirkel;
00006 import rene.zirkel.ZirkelCanvas;
00007 import rene.zirkel.constructors.*;
00008 import rene.zirkel.objects.ConstructionObject;
00009 import rene.zirkel.objects.IntersectionObject;
00010 
00016 public class SetAwayTool extends ObjectConstructor
00017 {      ObjectConstructor OC;
00018        IntersectionObject P;
00019        boolean Away;
00020        
00021        public SetAwayTool (ZirkelCanvas zc, IntersectionObject p, boolean away,
00022               ObjectConstructor oc)
00023        {      P=p; OC=oc;
00024               P.setSelected(true);
00025               Away=away;
00026               zc.repaint();
00027        }
00028        
00029        public void mousePressed (MouseEvent e, ZirkelCanvas zc)
00030        {      ConstructionObject o=zc.selectPoint(e.getX(),e.getY());
00031               if (o==null) return;
00032               if (zc.getConstruction().dependsOn(o,P))
00033               {      zc.warning(ConstructionObject.text1(Zirkel.name("error.depends"),P.getText()));
00034                      return;
00035               }
00036               P.setAway(o.getName(),Away);
00037               P.setUseAlpha(e.isShiftDown());
00038               zc.validate();
00039               reset(zc);
00040        }
00041        
00042        public void showStatus (ZirkelCanvas zc)
00043        {      if (Away) zc.showStatus(
00044                      Zirkel.name("message.setaway.away"));
00045               else zc.showStatus(
00046                      Zirkel.name("message.setaway.close"));
00047        }
00048        
00049        public void reset (ZirkelCanvas zc)
00050        {      super.reset(zc);
00051               zc.setTool(OC);
00052               zc.validate();
00053               zc.repaint();
00054        }
00055        
00056        public boolean useSmartBoard ()
00057        {      return false;
00058        }
00059 }