Back to index

wims  3.65+svn20090927
MidpointObject.java
Go to the documentation of this file.
00001 package rene.zirkel.objects;
00002 
00003 // file: MidpointObject.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 MidpointObject extends PointObject
00012 {      PointObject P1,P2;
00013        static Count N=new Count();
00014        
00015        public MidpointObject (Construction c, PointObject p1, PointObject p2)
00016        {      super(c,0,0);
00017               P1=p1; P2=p2;
00018               Moveable=false;
00019               validate();
00020               updateText();
00021        }
00022 
00023        public String getTag () { return "Midpoint"; }
00024        public int getN () { return N.next(); }
00025        
00026        public void updateText ()
00027        {      try
00028               {      setText(text2(Zirkel.name("text.midpoint"),P1.getName(),P2.getName()));
00029               }
00030               catch (Exception e) {}
00031        }
00032        public void validate ()
00033        {      if (!P1.valid() || !P2.valid()) Valid=false;
00034               else
00035               {      Valid=true;
00036                      X=(P1.getX()+P2.getX())/2;
00037                      Y=(P1.getY()+P2.getY())/2;
00038               }
00039        }
00040        public void printArgs (XmlWriter xml)
00041        {      xml.printArg("first",P1.getName());
00042               xml.printArg("second",P2.getName());
00043               printType(xml);
00044        }
00045 
00046        public Enumeration depending ()
00047        {      super.depending();
00048               DL.add(P1); DL.add(P2);
00049               return DL.elements();
00050        }
00051 
00052        public void translate ()
00053        {      P1=(PointObject)P1.getTranslation();
00054               P2=(PointObject)P2.getTranslation();
00055        }
00056 
00057 }