Back to index

wims  3.65+svn20090927
TwoPointLineObject.java
Go to the documentation of this file.
00001 package rene.zirkel.objects;
00002 
00003 // file: SegmentObject.java
00004 
00005 import java.util.Enumeration;
00006 
00007 import rene.zirkel.ZirkelCanvas;
00008 import rene.zirkel.construction.Construction;
00009 
00010 
00011 public class TwoPointLineObject extends PrimitiveLineObject
00012        implements MoveableObject
00013 {      protected PointObject P2;
00014        double X2,Y2,R;
00015 
00016        public TwoPointLineObject (Construction c, PointObject p1, PointObject p2)
00017        {      super(c);
00018               P1=p1; P2=p2;
00019        }
00020        
00021        public PointObject getP2 () { return P2; }
00022 
00023        public Enumeration depending ()
00024        {      super.depending();
00025               return depset(P1,P2);
00026        }
00027        
00028        public double getLength () { return R; }
00029 
00030        public void translate ()
00031        {      P1=(PointObject)P1.getTranslation();
00032               P2=(PointObject)P2.getTranslation();
00033        }
00034        
00035        public boolean contains (PointObject p)
00036        {      return P1==p || P2==p;
00037        }
00038 
00039        public Enumeration secondaryParams ()
00040        {      DL.reset();
00041               return depset(P1,P2);
00042        }
00043 
00044        public void dragTo (double x, double y) 
00045        {      P1.move(x1+(x-x3),y1+(y-y3));
00046               P2.move(x2+(x-x3),y2+(y-y3));
00047        }
00048 
00049        public void move (double x, double y) 
00050        {
00051        }
00052 
00053        public boolean moveable () 
00054        {      if (P1.moveable() && P2.moveable()) return true;
00055               return false;
00056        }
00057 
00058        double x1,y1,x2,y2,x3,y3;
00059        
00060        public void startDrag (double x, double y) 
00061        {      x1=P1.getX(); y1=P1.getY();
00062               x2=P2.getX(); y2=P2.getY();
00063               x3=x; y3=y;
00064        }
00065 
00066        public void snap (ZirkelCanvas zc)
00067        {      if (moveable())
00068               {      P1.snap(zc); P2.snap(zc);
00069               }
00070        }
00071 }