Back to index

wims  3.65+svn20090927
Circle3Object.java
Go to the documentation of this file.
00001 package rene.zirkel.objects;
00002 
00003 // file: Circle3Object.java
00004 
00005 import java.util.*;
00006 
00007 import rene.util.xml.*;
00008 import rene.zirkel.Zirkel;
00009 import rene.zirkel.construction.Construction;
00010 import rene.zirkel.construction.ConstructionException;
00011 import rene.zirkel.expression.InvalidException;
00012 
00013 public class Circle3Object extends PrimitiveCircleObject
00014 {      protected PointObject P1,P2;
00015        public Circle3Object (Construction c, 
00016               PointObject p1, PointObject p2, PointObject p3)
00017        {      super(c,p3);
00018               P1=p1; P2=p2;
00019               validate();
00020               updateText();
00021        }
00022 
00023        public String getTag () { return "Circle3"; }
00024        
00025        public void updateText ()
00026        {      setText(text3(Zirkel.name("text.circle3"),
00027                      M.getName(),P1.getName(),P2.getName()));
00028        }
00029        public void validate ()
00030        {      super.validate();
00031               if (!M.valid() || !P1.valid() || !P2.valid()) { Valid=false; return; }
00032               else
00033               {      Valid=true;
00034                      X=M.getX(); Y=M.getY();
00035                      // compute normalized vector in the direction of the line:
00036                      double DX=P2.getX()-P1.getX(),DY=P2.getY()-P1.getY(); 
00037                      R=Math.sqrt(DX*DX+DY*DY);
00038                      if (R<0) { R=0; }
00039               }
00040        }
00041        public void printArgs (XmlWriter xml)
00042        {      xml.printArg("from",P1.getName());
00043               xml.printArg("to",P2.getName());
00044               super.printArgs(xml);
00045        }      
00046 
00047        public double getValue ()
00048               throws ConstructionException
00049        {      if (!Valid) throw new InvalidException("exception.invalid");
00050               else return R;
00051        }
00052 
00053        public Enumeration depending ()
00054        {      super.depending();
00055               return depset(P1,P2);
00056        }
00057        
00058        public void translate ()
00059        {      P1=(PointObject)P1.getTranslation();
00060               P2=(PointObject)P2.getTranslation();
00061               super.translate();
00062        }
00063 
00064 }