Back to index

wims  3.65+svn20090927
Ruler.java
Go to the documentation of this file.
00001 package rene.zirkel.tools;
00002 
00003 /*
00004  * Created on 18.06.2004
00005  *
00006  */
00007 
00008 import java.awt.event.*;
00009 import java.util.*;
00010 
00011 import rene.zirkel.Zirkel;
00012 import rene.zirkel.ZirkelCanvas;
00013 import rene.zirkel.constructors.*;
00014 import rene.zirkel.dialogs.*;
00015 import rene.zirkel.objects.*;
00016 
00017 public class Ruler extends ObjectConstructor
00018 {      boolean Other;
00019        Vector V;
00020        
00021        public void mousePressed (MouseEvent e, ConstructionObject o, 
00022               ZirkelCanvas zc)
00023        {      double x=zc.x(e.getX()),y=zc.y(e.getY());
00024               Other=(e.isShiftDown() && o==null);
00025               if (o==null)
00026               {      o=zc.selectObject(e.getX(),e.getY());
00027                      if (o==null) return;
00028               }
00029               if (o.isKeep()) return;
00030               if (Other)
00031               {      if (V==null) V=new Vector();
00032                      V.addElement(o);
00033                      o.setSelected(true);
00034                      zc.repaint();
00035                      return;
00036               }
00037               if (V!=null)
00038               {      V.addElement(o);
00039                      o.setSelected(true);
00040                      ObjectsEditDialog d=new ObjectsEditDialog(zc.getFrame(),V);
00041                      zc.clearSelected();
00042                      d.setVisible(true);
00043               }
00044               else
00045               {      String oldname=o.getName();
00046                      o.edit(zc);
00047                      if (!oldname.equals(o.getName())) zc.updateTexts(o,oldname);
00048               }
00049               V=null; Other=false;
00050               zc.validate();
00051               zc.repaint();
00052        }
00053        
00054        public void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
00055        {      zc.indicateObjects(e.getX(),e.getY(),true);
00056        }
00057 
00058        public void mousePressed (MouseEvent e, ZirkelCanvas zc)
00059        {      mousePressed(e,null,zc);
00060        }
00061        
00062        public void showStatus (ZirkelCanvas zc)
00063        {      zc.showStatus(Zirkel.name("message.edit"));
00064        }
00065        
00066        public void reset (ZirkelCanvas zc)
00067        {      zc.clearSelected();
00068               V=null; Other=false;
00069        }
00070 }