Back to index

wims  3.65+svn20090927
MetaMover.java
Go to the documentation of this file.
00001 package rene.zirkel.tools;
00002 
00003 // file: MetaMover.java
00004 
00005 import java.awt.Cursor;
00006 import java.awt.event.MouseEvent;
00007 
00008 import rene.gui.Global;
00009 import rene.zirkel.ZirkelCanvas;
00010 import rene.zirkel.constructors.*;
00011 import rene.zirkel.objects.ConstructionObject;
00012 import rene.zirkel.objects.FixedAngleObject;
00013 import rene.zirkel.objects.FixedCircleObject;
00014 import rene.zirkel.objects.MoveableObject;
00015 
00016 public class MetaMover extends MoverTool
00017 {      ObjectConstructor OC;
00018        ConstructionObject PP;
00019        
00020        public MetaMover (ObjectConstructor oc, ZirkelCanvas zc, ConstructionObject p,
00021                      MouseEvent e)
00022        {      OC=oc; PP=P=p;
00023               oc.pause(true);
00024               if (P!=null)
00025               {      P.setSelected(true);
00026                      ShowsValue=P.showValue();
00027                      ShowsName=P.showName();
00028                      zc.repaint();
00029                      showStatus(zc);
00030                      zc.setCursor(new Cursor(Cursor.MOVE_CURSOR));
00031                      if (P instanceof MoveableObject)
00032                      {      ((MoveableObject)P).startDrag(zc.x(e.getX()),zc.y(e.getY()));
00033                      }
00034                      if (ZCG!=null)
00035                      {      ZCG.dispose();
00036                             ZCG=null;
00037                      }
00038                      ZCG=zc.getGraphics();
00039               }
00040        }
00041        
00042        public void mouseReleased (MouseEvent e, ZirkelCanvas zc)
00043        {      if (P==null) return;
00044               if (ZCG!=null)
00045               {      ZCG.dispose();
00046                      ZCG=null;
00047               }             
00048               zc.setCursor(Cursor.getDefaultCursor());
00049               P.setSelected(false);
00050               P.setShowValue(ShowsValue);
00051               P.setShowName(ShowsName);
00052               if (zc.showGrid() && !Global.getParameter("grid.leftsnap",false))
00053               {      PP.snap(zc);
00054                      // PP.round();
00055                      PP.updateText();
00056               }
00057               zc.validate();
00058               if (Grab)
00059               {      zc.grab(false);
00060                      Grab=false;
00061               }
00062               if (ChangedDrawable)
00063               {      if (P instanceof FixedCircleObject)
00064                      {      ((FixedCircleObject)P).setDragable(WasDrawable);
00065                      }
00066                      else if (P instanceof FixedAngleObject)
00067                      {      ((FixedAngleObject)P).setDragable(WasDrawable);
00068                      }
00069               }
00070               zc.clearSelected();
00071               zc.repaint();
00072               P=null;
00073               V=null;
00074               Selected=false;
00075               zc.setTool(OC);
00076               OC.pause(false);
00077               zc.validate();
00078               zc.repaint();
00079        }
00080 }