Back to index

wims  3.65+svn20090927
ParallelObject.java
Go to the documentation of this file.
00001 package rene.zirkel.objects;
00002 
00003 // file: ParallelObject.java
00004 
00005 import java.util.Enumeration;
00006 
00007 import rene.util.xml.XmlWriter;
00008 import rene.zirkel.*;
00009 import rene.zirkel.construction.*;
00010 
00011 public class ParallelObject extends PrimitiveLineObject
00012        implements MoveableObject
00013 {      protected PrimitiveLineObject L;
00014        static Count N=new Count();
00015        public ParallelObject (Construction c, PrimitiveLineObject l, PointObject p)
00016        {      super(c);
00017               P1=p; L=l;
00018               validate();
00019               updateText();
00020        }
00021        public String getTag () { return "Parallel"; }
00022        public int getN () { return N.next(); }
00023        
00024        public void updateText ()
00025        {      setText(text2(Zirkel.name("text.parallel"),P1.getName(),L.getName()));
00026        }
00027        public void validate ()
00028        {      if (!P1.valid() || !L.valid()) Valid=false;
00029               else if (L instanceof SegmentObject &&
00030                             ((SegmentObject)L).getLength()==0)
00031               {      Valid=false;
00032               }
00033               else
00034               {      Valid=true;
00035                      X1=P1.getX(); Y1=P1.getY();
00036                      DX=L.getDX(); DY=L.getDY();
00037               }
00038        }
00039        public void printArgs (XmlWriter xml)
00040        {      xml.printArg("point",P1.getName());
00041               xml.printArg("line",L.getName());
00042               super.printArgs(xml);
00043        }      
00044        
00045        public Enumeration depending ()
00046        {      super.depending();
00047               return depset(P1,L);
00048        }
00049 
00050        public void translate ()
00051        {      P1=(PointObject)P1.getTranslation();
00052               L=(PrimitiveLineObject)L.getTranslation();
00053        }
00054 
00055        public boolean contains (PointObject p)
00056        {      return p==P1;
00057        }
00058 
00059        public boolean hasUnit ()
00060        {      return false;
00061        }
00062 
00063        public void dragTo (double x, double y) 
00064        {      P1.move(x1+(x-x3),y1+(y-y3));
00065        }
00066 
00067        public void move (double x, double y) 
00068        {
00069        }
00070 
00071        public boolean moveable () 
00072        {      if (P1.moveable()) return true;
00073               return false;
00074        }
00075 
00076        double x1,y1,x2,y2,x3,y3;
00077        
00078        public void startDrag (double x, double y) 
00079        {      x1=P1.getX(); y1=P1.getY();
00080               x3=x; y3=y;
00081        }
00082 
00083        public void snap (ZirkelCanvas zc)
00084        {      if (moveable())
00085               {      P1.snap(zc);
00086               }
00087        }
00088 }