Back to index

wims  3.65+svn20090927
TextConstructor.java
Go to the documentation of this file.
00001 package rene.zirkel.constructors;
00002 
00003 // file: PointConstructor.java
00004 
00005 import java.awt.event.*;
00006 
00007 import rene.util.xml.*;
00008 import rene.zirkel.*;
00009 import rene.zirkel.construction.*;
00010 import rene.zirkel.expression.*;
00011 import rene.zirkel.objects.*;
00012 
00013 public class TextConstructor extends ObjectConstructor
00014 {      public void mousePressed (MouseEvent e, ZirkelCanvas zc)
00015        {      double x=zc.x(e.getX()),y=zc.y(e.getY());
00016               TextObject p=new TextObject(zc.getConstruction(),x,y);
00017               zc.addObject(p);
00018               p.setDefaults();
00019               p.edit(zc);
00020               zc.repaint();
00021        }
00022        
00023        public boolean waitForPoint ()
00024        {      return false;
00025        }
00026        
00027        public void showStatus (ZirkelCanvas zc)
00028        {      zc.showStatus(Zirkel.name("message.text"));
00029        }
00030        
00031        public boolean construct (XmlTree tree, Construction c)
00032               throws ConstructionException
00033        {      if (!testTree(tree,"Text")) return false;
00034               XmlTag tag=tree.getTag();
00035               if (!tag.hasParam("x") || !tag.hasParam("y"))
00036                      throw new ConstructionException("Point coordinates missing!");
00037               TextObject p=new TextObject(c,0,0);
00038               double x,y;
00039               try
00040               {      x=new Expression(tag.getValue("x"),c,p).getValue();
00041                      y=new Expression(tag.getValue("y"),c,p).getValue();
00042                      p.move(x,y);
00043               }
00044               catch (Exception e) {}
00045               setName(tag,p);
00046               set(tree,p);
00047               c.add(p);
00048               setConditionals(tree,c,p);
00049               p.setLines(p.getText());
00050               if (tag.hasParam("fixed"))
00051               {      p.setFixed(tag.getValue("x"),tag.getValue("y"));
00052               }
00053               return true;
00054        }
00055 
00056 
00057        public void reset (ZirkelCanvas zc)
00058        {      super.reset(zc);
00059               showStatus(zc);
00060        }
00061 }