Back to index

wims  3.65+svn20090927
Public Member Functions | Protected Attributes | Package Attributes
rene.zirkel.constructors.CircleConstructor Class Reference
Inheritance diagram for rene.zirkel.constructors.CircleConstructor:
Inheritance graph
[legend]
Collaboration diagram for rene.zirkel.constructors.CircleConstructor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CircleConstructor (boolean fixed)
 CircleConstructor ()
void mousePressed (MouseEvent e, ZirkelCanvas zc)
boolean waitForLastPoint ()
void finishConstruction (MouseEvent e, ZirkelCanvas zc)
boolean waitForPoint ()
void mouseDragged (MouseEvent e, ZirkelCanvas zc)
void mouseReleased (MouseEvent e, ZirkelCanvas zc)
PointObject select (int x, int y, ZirkelCanvas zc)
void reset (ZirkelCanvas zc)
void showStatus (ZirkelCanvas zc)
boolean construct (XmlTree tree, Construction c) throws ConstructionException
String getTag ()
void construct (Construction c, String name, String params[], int nparams) throws ConstructionException
void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
void resetFirstTime (ZirkelCanvas zc)
void invalidate (ZirkelCanvas zc)
boolean testTree (XmlTree t, String tag)
void setName (XmlTag tag, ConstructionObject o)
void set (XmlTree tree, ConstructionObject o) throws ConstructionException
void setConditionals (XmlTree tree, Construction c, ConstructionObject o)
void pause (boolean flag)
boolean useSmartBoard ()

Protected Attributes

boolean Dragging = false

Package Attributes

PointObject P1 = null
PointObject P2 = null
boolean Fixed = false
FixedCircleObject C
ConstructionObject O
boolean ShowsValue
boolean ShowsName
int Moved

Detailed Description

Definition at line 15 of file CircleConstructor.java.


Constructor & Destructor Documentation

Definition at line 18 of file CircleConstructor.java.

       {      Fixed=fixed;
       }

Definition at line 21 of file CircleConstructor.java.

       {      this(false);
       }

Member Function Documentation

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 183 of file CircleConstructor.java.

       {      if (!testTree(tree,"Circle")) return false;
              XmlTag tag=tree.getTag();
              try
              {      if (!tag.hasParam("midpoint"))
                                   throw new ConstructionException("Circle parameters missing!");
                     if (!tag.hasParam("through"))
                     {      if (tag.hasParam("fixed"))
                            {      PointObject p1=(PointObject)c.find(tag.getValue("midpoint")); 
                                   FixedCircleObject o=new FixedCircleObject(c,p1,0,0);
                                   c.add(o);
                                   setConditionals(tree,c,o);
                                   setName(tag,o);
                                   set(tree,o);
                                   if (tag.hasParam("partial")) o.setPartial(true);
                                   if (tag.hasParam("filled")) o.setFilled(true);
                                   if (tag.hasTrueParam("dragable")) o.setDragable(true);
                                   if (tag.hasTrueParam("drawable")) o.setDragable(true); // downward compatibility
                                   o.setFixed(tag.getValue("fixed"));
                                   if (tag.hasParam("start") && tag.hasParam("end"))
                                          o.setRange(tag.getValue("start"),tag.getValue("end"));
                                   if (tag.hasParam("acute")) o.setObtuse(false);
                                   if (tag.hasParam("chord")) o.setArc(false);
                            }
                            else
                            {      if (!(c instanceof Macro))
                                          throw new ConstructionException("Circle parameters missing!");
                                   PointObject p1=(PointObject)c.find(tag.getValue("midpoint")); 
                                   PrimitiveCircleObject o=new PrimitiveCircleObject(c,p1);
                                   setName(tag,o);
                                   set(tree,o);
                                   c.add(o);
                                   setConditionals(tree,c,o);
                            }
                     }
                     else
                     {      PointObject p1=(PointObject)c.find(tag.getValue("midpoint")); 
                            PointObject p2=(PointObject)c.find(tag.getValue("through"));
                            CircleObject o=new CircleObject(c,p1,p2);
                            setName(tag,o);
                            set(tree,o);
                            c.add(o);
                            setConditionals(tree,c,o);
                            if (tag.hasParam("partial")) o.setPartial(true);
                            if (tag.hasParam("filled")) o.setFilled(true);
                            if (tag.hasParam("start") && tag.hasParam("end"))
                                   o.setRange(tag.getValue("start"),tag.getValue("end"));
                            if (tag.hasParam("acute")) o.setObtuse(false);
                            if (tag.hasParam("chord")) o.setArc(false);
                            if (tag.hasParam("fixed"))
                            {      try
                                   {      o.setFixed(true,tag.getValue("fixed"));
                                   }
                                   catch (Exception e)
                                   {      throw new ConstructionException("Fixed value illegal!");
                                   }
                            }
                     }
              }
              catch (ConstructionException e)
              {      throw e;
              }
              catch (Exception e)
              {      throw new ConstructionException("Circle parameters illegal!");
              }
              return true;
       }

Here is the call graph for this function:

void rene.zirkel.constructors.CircleConstructor.construct ( Construction  c,
String  name,
String  params[],
int  nparams 
) throws ConstructionException [inline]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 253 of file CircleConstructor.java.

       {      if (nparams>3 || nparams==0)
                     throw new ConstructionException(Zirkel.name("exception.nparams"));
              ConstructionObject
                     P1=c.find(params[0]);
              if (P1==null)
                     throw new ConstructionException(Zirkel.name("exception.notfound")+" "+
                            params[0]);
              if (!(P1 instanceof PointObject))
                     throw new ConstructionException(Zirkel.name("exception.type")+" "+
                            params[0]);
              if (nparams==1)
              {      PrimitiveCircleObject s=new PrimitiveCircleObject(c,(PointObject)P1);
                     c.add(s);
                     s.setDefaults();
                     if (!name.equals("")) s.setNameCheck(name);
                     return;
              }             
              ConstructionObject
                     P2=c.find(params[1]);
              if (P2==null)
              {      Expression ex=new Expression(params[1],c,null);
                     if (!ex.isValid())
                            throw new ConstructionException(Zirkel.name("exception.expression"));
                     FixedCircleObject s=new FixedCircleObject(c,(PointObject)P1,0,0);
                     c.add(s);
                     s.setDefaults();
                     s.setFixed(params[1]);
                     s.validate();
                     if (!name.equals("")) s.setNameCheck(name);
                     return;
              }
              if (P2 instanceof SegmentObject)
              {      Circle3Object s=new Circle3Object(c,
                            ((SegmentObject)P2).getP1(),
                            ((SegmentObject)P2).getP2(),
                            (PointObject)P1);
                     c.add(s);
                     s.setDefaults();
                     if (!name.equals("")) s.setNameCheck(name);
                     return;
              }
              if (!(P2 instanceof PointObject))
                     throw new ConstructionException(Zirkel.name("exception.type")+" "+
                            params[1]);
              if (nparams==3)
              {      ConstructionObject P3=c.find(params[2]);
                     if (P3==null || !(P3 instanceof PointObject))
                     {      CircleObject s=new CircleObject(c,(PointObject)P1,(PointObject)P2);
                            if (!s.canFix())
                                   throw new ConstructionException(Zirkel.name("exception.canfix"));
                            s.setFixed(true,params[2]);
                            if (!s.isValidFix())
                                   throw new ConstructionException(Zirkel.name("exception.fix")+" "+
                                          params[2]);
                            c.add(s);
                            s.validate();
                            if (!name.equals("")) s.setNameCheck(name);
                            s.setDefaults();
                            return;
                     }
                     else
                     {      Circle3Object cr=new Circle3Object(c,(PointObject)P2,(PointObject)P3,
                                   (PointObject)P1);
                            c.add(cr);
                            cr.setDefaults();
                            if (!name.equals("")) cr.setNameCheck(name);
                            return;
                     }             
              }
              CircleObject s=new CircleObject(c,(PointObject)P1,(PointObject)P2);
              c.add(s);
              s.setDefaults();
              if (!name.equals("")) s.setName(name);
       }

Here is the call graph for this function:

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 92 of file CircleConstructor.java.

       {      P2=select(e.getX(),e.getY(),zc);
              if (P2!=null)
              {      CircleObject c=new CircleObject(zc.getConstruction(),P1,P2);
                     zc.addObject(c);
                     c.setDefaults();
                     c.validate();
                     zc.repaint();
              }
              P2=null;
       }

Here is the call graph for this function:

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 252 of file CircleConstructor.java.

{ return "Circle"; }

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 108 of file CircleConstructor.java.

       {      if (!Dragging) return;
              Moved++;
              if (P2==null)
              {      C.init(zc.getConstruction(),zc.x(e.getX()),zc.y(e.getY()));
                     if (C instanceof FixedCircleObject)
                            ((FixedCircleObject)C).setDragable(Moved>5);
              }
              else
              {      P2.move(zc.x(e.getX()),zc.y(e.getY()));
                     zc.validate();
              }
              zc.repaint();
       }

Here is the call graph for this function:

void rene.zirkel.constructors.ObjectConstructor.mouseMoved ( MouseEvent  e,
ZirkelCanvas  zc,
boolean  simple 
) [inline, inherited]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 28 of file CircleConstructor.java.

       {      if (!zc.Visual) return;
              if (P1==null)
              {      P1=select(e.getX(),e.getY(),zc);
                     if (P1!=null)
                     {      P1.setSelected(true);
                            zc.repaint();
                     }
                     showStatus(zc);
              }
              else
              {      if (e.isShiftDown() || Fixed)
                     {      FixedCircleObject c=new FixedCircleObject(zc.getConstruction(),
                                   P1,zc.x(e.getX()),zc.y(e.getY()));
                            zc.addObject(c);
                            c.setDefaults();
                            zc.repaint();
                            O=C=c;
                            ShowsValue=c.showValue();
                            ShowsName=c.showName();
                            if (Global.getParameter("options.movefixname",true))
                            {      C.setShowValue(true);
                                   C.setShowName(true);
                            }
                            Dragging=true;
                            Moved=0;
                            P2=null;
                     }
                     else
                     {      P2=select(e.getX(),e.getY(),zc);
                            if (P2!=null)
                            {      if (P2==P1)
                                   {      P2=null; return;
                                   }
                                   CircleObject c=new CircleObject(zc.getConstruction(),P1,P2);
                                   zc.addObject(c);
                                   c.setDefaults();
                                   c.validate();
                                   zc.repaint();
                                   if (P2.moveable() && !P2.isPointOn() && zc.isNewPoint())
                                   {      ShowsValue=c.showValue();
                                          ShowsName=c.showName();
                                          if (Global.getParameter("options.movename",false))
                                          {      c.setShowValue(true);
                                                 c.setShowName(true);
                                          }
                                          O=c;
                                          Dragging=true;
                                          Moved=0;
                                   }
                                   else
                                   {      P1.setSelected(false);
                                          P1=P2=null;
                                          showStatus(zc);
                                   }
                            }
                     }
              }
       }

Here is the call graph for this function:

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 123 of file CircleConstructor.java.

       {      if (!Dragging) return;
              Dragging=false;
              O.setShowValue(ShowsValue);
              O.setShowName(ShowsName);
              zc.repaint();
              if (P2==null)
              {      P1.setSelected(false);
                     P1=null;
                     C.round();
                     if (Moved<=5)
                     {      C.edit(zc);
                            if (C instanceof FixedCircleObject &&
                                   ((FixedCircleObject)C).isEditAborted())
                            {      zc.delete(C);
                                   zc.repaint();
                                   reset(zc);
                            }
                     }
                     C.validate();
                     zc.check();
              }
              else
              {      P1.setSelected(false);
                     P2.updateText();
                     P1=P2=null;
              }
              O.updateCircleDep();
              zc.repaint();
              zc.showStatus();     
       }

Here is the call graph for this function:

void rene.zirkel.constructors.ObjectConstructor.pause ( boolean  flag) [inline, inherited]

Reimplemented in rene.zirkel.tools.ObjectTracker.

Definition at line 216 of file ObjectConstructor.java.

       {
       }

Here is the caller graph for this function:

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 159 of file CircleConstructor.java.

       {      super.reset(zc);
              if (zc.Visual)
              {      P1=P2=null;
                     showStatus(zc);
              }
              else
              {      zc.setPrompt(Zirkel.name("prompt.circle"));
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in rene.zirkel.tools.MoverTool.

Definition at line 56 of file ObjectConstructor.java.

       {      reset(zc);
       }

Here is the call graph for this function:

Definition at line 155 of file CircleConstructor.java.

       {      return zc.selectCreatePoint(x,y);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 76 of file ObjectConstructor.java.

       {      XmlTag tag=tree.getTag();
              if (tag.hasParam("n"))
              {      try
                     {      o.setNCount(new Integer(tag.getValue("n")).intValue());
                            o.setGotNCount(true);
                     }
                     catch (Exception ex)
                     {      throw new ConstructionException("Illegal count!");
                     }
              }
              if (tag.hasParam("hidden"))
              {      if (tag.getValue("hidden").equals("super")) o.setSuperHidden(true);
                     else o.setHidden(true);
              }
              if (tag.hasTrueParam("showvalue"))
              {      o.setShowValue(true);
              }
              if (tag.hasTrueParam("showname"))
              {      o.setShowName(true);
              }
              if (tag.hasTrueParam("background"))
              {      o.setBack(true);
              }
              else o.setBack(false);
              if (tag.hasTrueParam("parameter"))
              {      o.setParameter();
              }
              if (tag.hasTrueParam("mainparameter"))
              {      o.setMainParameter();
              }
              if (tag.hasTrueParam("target"))
              {      o.setTarget(true);
              }
              if (tag.hasTrueParam("break"))
              {      o.setBreak(true);
              }
              if (tag.hasTrueParam("hidebreak"))
              {      o.setHideBreak(true);
              }
              if (tag.hasTrueParam("solid"))
              {      o.setSolid(true);
              }
              if (tag.hasTrueParam("bold"))
              {      o.setBold(true);
              }
              if (tag.hasTrueParam("large"))
              {      o.setLarge(true);
              }
              if (tag.hasParam("xoffset") || tag.hasParam("yoffset"))
              {      int x=0,y=0;
                     try
                     {      if (tag.hasParam("xoffset"))
                                   x=Integer.parseInt(tag.getValue("xoffset"));
                            if (tag.hasParam("yoffset"))
                                   y=Integer.parseInt(tag.getValue("yoffset"));
                            o.setOffset(x,y);
                     }
                     catch (Exception e)
                     {      throw new ConstructionException("Illegal offset value");
                     }
              }
              if (tag.hasTrueParam("keepclose"))
              {      o.setKeepClose(true);
              }
              if (tag.hasParam("xcoffset") || tag.hasParam("ycoffset"))
              {      double x=0,y=0;
                     try
                     {      if (tag.hasParam("xcoffset"))
                                   x=new Double(tag.getValue("xcoffset")).doubleValue();
                            if (tag.hasParam("ycoffset"))
                                   y=new Double(tag.getValue("ycoffset")).doubleValue();
                            o.setcOffset(x,y);
                     }
                     catch (Exception e)
                     {      throw new ConstructionException("Illegal offset value");
                     }
              }
              if (tag.hasParam("color"))
              {      try
                     {      String s=tag.getValue("color");
                            int n=-1;
                            for (int i=0; i<ZirkelFrame.ColorStrings.length; i++)
                            {      if (s.equals(ZirkelFrame.ColorStrings[i]))
                                   {      o.setColor(i); n=i; break;
                                   }
                            }
                            if (n<0)
                            {      n=Integer.parseInt(s);
                                   if (n<0 || n>=ZirkelFrame.Colors.length)
                                          throw new Exception("");
                                   o.setColor(n);
                            }
                     }
                     catch (Exception ex)
                     {      throw new ConstructionException("Illegal color index (1-"+
                                   (ZirkelFrame.Colors.length-1)+")");
                     }
              }
              if (tag.hasParam("type"))
              {      String type=tag.getValue("type");
                     if (type.equals("thick")) o.setColorType(ConstructionObject.THICK);
                     if (type.equals("thin")) o.setColorType(ConstructionObject.THIN);
                     if (type.equals("invisible")) o.setColorType(ConstructionObject.INVISIBLE);
              }
              if (tag.hasParam("unit"))
                     o.setUnit(tag.getValue("unit"));
              else
                     o.setUnit("");
              Enumeration e=tree.getContent();
              while (e.hasMoreElements())
              {      tree=(XmlTree)e.nextElement();
                     if (tree.getTag() instanceof XmlTagText)
                     {      o.setText(((XmlTagText)tree.getTag()).getContent(),true);
                     }
              }
       }

Here is the call graph for this function:

Definition at line 194 of file ObjectConstructor.java.

       {      o.clearConditionals();
              int i=0;
              XmlTag tag=tree.getTag();
              while (tag.hasParam("ctag"+i) && tag.hasParam("cexpr"+i))
              {      String t=tag.getValue("ctag"+i);
                     String e=tag.getValue("cexpr"+i);
                     Expression ex=new Expression(e,c,o);
                     o.addConditional(t,ex);
                     i++;
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 68 of file ObjectConstructor.java.

       {      if (tag.hasParam("name"))
              {      o.setName(tag.getValue("name"));
              }
              if (tag.hasParam("alias"))
              {      o.setAlias(tag.getValue("alias"));
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 169 of file CircleConstructor.java.

       {      if (Fixed)
              {      if (P1==null) zc.showStatus(
                            Zirkel.name("message.fixedcircle.midpoint"));
                     else zc.showStatus(
                            Zirkel.name("message.fixedcircle.radius"));
              }
              else
              {      if (P1==null) zc.showStatus(
                            Zirkel.name("message.circle.midpoint"));
                     else zc.showStatus(
                            Zirkel.name("message.circle.radius"));
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean rene.zirkel.constructors.ObjectConstructor.testTree ( XmlTree  t,
String  tag 
) [inline, inherited]

Definition at line 65 of file ObjectConstructor.java.

       {      return t.getTag().name().equals(tag);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 88 of file CircleConstructor.java.

       {      return P1!=null && P2==null;
       }

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 104 of file CircleConstructor.java.

       {      return P1==null || !Fixed;
       }

Member Data Documentation

FixedCircleObject rene.zirkel.constructors.CircleConstructor.C [package]

Definition at line 24 of file CircleConstructor.java.

Reimplemented in rene.zirkel.tools.ZoomerTool, and rene.zirkel.tools.DrawerTool.

Definition at line 15 of file ObjectConstructor.java.

Definition at line 17 of file CircleConstructor.java.

Definition at line 27 of file CircleConstructor.java.

Definition at line 25 of file CircleConstructor.java.

Definition at line 16 of file CircleConstructor.java.

Definition at line 16 of file CircleConstructor.java.

Definition at line 26 of file CircleConstructor.java.

Definition at line 26 of file CircleConstructor.java.


The documentation for this class was generated from the following file: