Back to index

wims  3.65+svn20090927
PlumbConstructor.java
Go to the documentation of this file.
00001 package rene.zirkel.constructors;
00002 
00003 // file: PlumbConstructor.java
00004 
00005 import rene.util.xml.XmlTag;
00006 import rene.util.xml.XmlTree;
00007 import rene.zirkel.*;
00008 import rene.zirkel.construction.*;
00009 import rene.zirkel.objects.*;
00010 
00011 public class PlumbConstructor extends ParallelConstructor
00012 {      public PrimitiveLineObject create (Construction c, PrimitiveLineObject l, PointObject p)
00013        {      return new PlumbObject(c,l,p);
00014        }
00015        public void showStatus (ZirkelCanvas zc)
00016        {      if (L==null) zc.showStatus(
00017                      Zirkel.name("message.plumb.first","Plumb Line: Choose a line!"));
00018               else zc.showStatus(
00019                      Zirkel.name("message.plumb.second","Plumb Line: Choose a Point!"));
00020        }
00021        public boolean construct (XmlTree tree, Construction c)
00022               throws ConstructionException
00023        {      if (!testTree(tree,"Plumb")) return false;
00024               XmlTag tag=tree.getTag();
00025               if (!tag.hasParam("point") || !tag.hasParam("line"))
00026                      throw new ConstructionException("Plumb parameters missing!");
00027               try
00028               {      PointObject p1=(PointObject)c.find(tag.getValue("point"));
00029                      PrimitiveLineObject p2=(PrimitiveLineObject)c.find(tag.getValue("line"));
00030                      PlumbObject o=new PlumbObject(c,p2,p1);
00031                      if (tag.hasParam("valid"))
00032                                    o.setRestricted(false);
00033                      setName(tag,o);
00034                      set(tree,o);
00035                      if (tag.hasParam("partial")) o.setPartial(true);
00036                      c.add(o);
00037                      setConditionals(tree,c,o);
00038               }
00039               catch (ConstructionException e)
00040               {      throw e;
00041               }
00042               catch (Exception e)
00043               {      throw new ConstructionException("Plumb parameters illegal!");
00044               }
00045               return true;
00046        }
00047        public String getPrompt ()
00048        {      return Zirkel.name("prompt.plumb");
00049        }
00050 
00051        public String getTag () { return "Plumb"; }
00052        public void construct (Construction c, 
00053               String name, String params[], int nparams)
00054               throws ConstructionException
00055        {      if (nparams!=2)
00056                      throw new ConstructionException(Zirkel.name("exception.nparams"));
00057               ConstructionObject
00058                      P1=c.find(params[0]);
00059               if (P1==null)
00060                      throw new ConstructionException(Zirkel.name("exception.notfound")+" "+
00061                             params[0]);
00062               ConstructionObject
00063                      P2=c.find(params[1]);
00064               if (P2==null)
00065                      throw new ConstructionException(Zirkel.name("exception.notfound")+" "+
00066                             params[1]);
00067               if (!(P1 instanceof PrimitiveLineObject))
00068                      throw new ConstructionException(Zirkel.name("exception.type")+" "+
00069                             params[0]);
00070               if (!(P2 instanceof PointObject))
00071                      throw new ConstructionException(Zirkel.name("exception.type")+" "+
00072                             params[1]);
00073               PlumbObject s=new PlumbObject(c,
00074                      (PrimitiveLineObject)P1,(PointObject)P2);
00075               if (!name.equals("")) s.setNameCheck(name);
00076               c.add(s);
00077               s.setDefaults();
00078        }
00079 
00080 }