Back to index

wims  3.65+svn20090927
LabelMover.java
Go to the documentation of this file.
00001 package rene.zirkel.tools;
00002 
00003 // file: MoveConstructor.java
00004 
00005 import java.awt.event.*;
00006 
00007 import rene.zirkel.Zirkel;
00008 import rene.zirkel.ZirkelCanvas;
00009 import rene.zirkel.constructors.*;
00010 import rene.zirkel.objects.*;
00011 
00012 public class LabelMover extends ObjectConstructor
00013 {      ConstructionObject P;
00014        ObjectConstructor OC;
00015        int X,Y;
00016        double OX,OY;
00017        public LabelMover (ObjectConstructor oc, ZirkelCanvas zc, 
00018               int x, int y, ConstructionObject p, boolean shift)
00019        {      OC=oc; P=p; 
00020               if (shift || !P.canKeepClose())
00021               {      X=x; Y=y; 
00022                      P.setKeepClose(false);
00023                      OX=P.xcOffset(); OY=P.ycOffset();
00024               }
00025               else
00026               {      P.setKeepClose(zc.x(x),zc.y(y));
00027               }
00028               if (P!=null)
00029               {      P.setLabelSelected(true);
00030                      zc.repaint();
00031                      showStatus(zc);
00032               }
00033        }
00034        public void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
00035        {
00036        }
00037 
00038        public void mouseDragged (MouseEvent e, ZirkelCanvas zc)
00039        {      if (P==null) return;
00040               if (P.isKeepClose())
00041               {      P.setKeepClose(zc.x(e.getX()),zc.y(e.getY()));
00042               }
00043               else
00044               {      P.setcOffset(OX+zc.dx(e.getX()-X),OY+zc.dy(Y-e.getY()));
00045               }
00046               zc.validate(); zc.repaint();
00047        }
00048        public void mouseReleased (MouseEvent e, ZirkelCanvas zc)
00049        {      if (P==null) return;
00050               P.setLabelSelected(false);
00051               zc.repaint();
00052               P=null;
00053               showStatus(zc);
00054               zc.setTool(OC);
00055        }
00056        
00057        public void reset (ZirkelCanvas zc)
00058        {      zc.clearSelected(); P.setLabelSelected(false); zc.repaint();
00059        }
00060        
00061        public void resetPoint ()
00062        {      if (P!=null)
00063               {      P.setKeepClose(false);
00064                      P.setcOffset(0,0);
00065               }
00066        }
00067        
00068        public void showStatus (ZirkelCanvas zc)
00069        {      if (P==null) zc.showStatus(
00070                      Zirkel.name("message.label.select","Move Label: Select a label"));
00071               else zc.showStatus(
00072                      Zirkel.name("message.label.move","Move Label: Move the label"));
00073        }
00074        
00075        public boolean useSmartBoard ()
00076        {      return false;
00077        }
00078 }