Back to index

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

List of all members.

Public Member Functions

void mousePressed (MouseEvent e, ZirkelCanvas zc)
void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
ConstructionObject select (int x, int y, ZirkelCanvas zc)
void reset (ZirkelCanvas zc)
void showStatus (ZirkelCanvas zc)
boolean construct (XmlTree tree, Construction c) throws ConstructionException
boolean constructOther (XmlTree tree, Construction c) throws ConstructionException
String getTag ()
void construct (Construction c, String name, String params[], int nparams) throws ConstructionException
void mouseReleased (MouseEvent e, ZirkelCanvas zc)
void mouseDragged (MouseEvent e, ZirkelCanvas zc)
void finishConstruction (MouseEvent e, ZirkelCanvas zc)
boolean waitForLastPoint ()
boolean waitForPoint ()
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 ()

Static Public Member Functions

static IntersectionObject[] construct (ConstructionObject P1, ConstructionObject P2, Construction c)

Protected Attributes

boolean Dragging = false

Package Attributes

ConstructionObject P1 = null
ConstructionObject P2 = null

Detailed Description

Definition at line 22 of file IntersectionConstructor.java.


Member Function Documentation

Definition at line 89 of file IntersectionConstructor.java.

       {      IntersectionObject o[]=null;
              if (P1 instanceof PrimitiveLineObject)
              {      if (P2 instanceof PrimitiveLineObject)
                     {      o=new IntersectionObject[1];
                            o[0]=new LineIntersectionObject(c,
                                          (PrimitiveLineObject)P1,(PrimitiveLineObject)P2);
                     }
                     else if (P2 instanceof PrimitiveCircleObject)
                     {      o=new IntersectionObject[2];
                            o[0]=new LineCircleIntersectionObject(c,
                                          (PrimitiveLineObject)P1,(PrimitiveCircleObject)P2,
                                          true);
                            o[1]=new LineCircleIntersectionObject(c,
                                          (PrimitiveLineObject)P1,(PrimitiveCircleObject)P2,
                                          false);
                     }
                     else return construct(P2,P1,c);
              }
              else if (P1 instanceof PrimitiveCircleObject)
              {      if (P2 instanceof PrimitiveCircleObject)
                     {      o=new IntersectionObject[2];
                            o[0]=new CircleIntersectionObject(c,
                                          (PrimitiveCircleObject)P1,(PrimitiveCircleObject)P2,
                                          true);
                            o[1]=new CircleIntersectionObject(c,
                                          (PrimitiveCircleObject)P1,(PrimitiveCircleObject)P2,
                                          false);
                     }
                     else if (P2 instanceof PrimitiveLineObject)
                     {      o=new IntersectionObject[2];
                            o[0]=new LineCircleIntersectionObject(c,
                                          (PrimitiveLineObject)P2,(PrimitiveCircleObject)P1,
                                          true);
                            o[1]=new LineCircleIntersectionObject(c,
                                          (PrimitiveLineObject)P2,(PrimitiveCircleObject)P1,
                                          false);
                     }
                     else return construct(P2,P1,c);
              }
              else
              {      o=new PointonObjectIntersectionObject[1];
                     o[0]=new PointonObjectIntersectionObject(c,P1,P2);
              }
              return o;
       }

Here is the caller graph for this function:

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 161 of file IntersectionConstructor.java.

       {      if (!testTree(tree,"Intersection")) return constructOther(tree,c);
              XmlTag tag=tree.getTag();
              if (!tag.hasParam("first") || !tag.hasParam("second"))
                     throw new ConstructionException("Intersection parameters missing!");
              try
              {      ConstructionObject o1=c.find(tag.getValue("first")); 
                     ConstructionObject o2=c.find(tag.getValue("second"));
                     IntersectionObject o[]=construct(o1,o2,c);
                     if (o==null) throw new Exception("");
                     String name="",nameOther="";
                     if (tag.hasParam("name")) name=tag.getValue("name");
                     if (tag.hasParam("other")) nameOther=tag.getValue("other");
                     if (o.length>1)
                     {      if (tag.hasParam("which"))
                            {      IntersectionObject oo;
                                   if (tag.getValue("which").equals("second")) oo=o[1];
                                   else oo=o[0];
                                   if (!name.equals("")) oo.setName(name);
                                   PointConstructor.setType(tag,oo);
                                   setName(tag,oo);
                                   set(tree,oo);
                                   c.add(oo);
                                   setConditionals(tree,c,oo);
                                   if (tag.hasParam("awayfrom"))
                                          oo.setAway(tag.getValue("awayfrom"),true);
                                   else if (tag.hasParam("closeto"))
                                          oo.setAway(tag.getValue("closeto"),false);
                                   if (tag.hasParam("valid")) oo.setRestricted(false);
                                   if (tag.hasParam("alternate")) oo.setAlternate(true);
                            }
                            else if (tag.hasParam("other"))
                            {      if (!name.equals("")) o[0].setName(name);
                                   if (!nameOther.equals("")) o[1].setName(nameOther);
                                   if (tag.hasParam("awayfrom"))
                                   {      o[0].setAway(tag.getValue("awayfrom"),true);
                                          o[1].setAway(tag.getValue("awayfrom"),false);
                                   }
                                   else if (tag.hasParam("closeto"))
                                   {      o[1].setAway(tag.getValue("awayfrom"),true);
                                          o[0].setAway(tag.getValue("awayfrom"),false);
                                   }
                                   for (int i=0; i<o.length; i++)
                                   {      if (o[i]==null) continue;
                                          PointConstructor.setType(tag,o[i]);
                                          set(tree,o[i]);
                                          c.add(o[i]);
                                          setConditionals(tree,c,o[i]);
                                   }                                  
                            }
                     }
                     else
                     {      if (!name.equals("")) o[0].setName(name);
                            PointConstructor.setType(tag,o[0]);
                            setName(tag,o[0]);
                            set(tree,o[0]);
                            c.add(o[0]);
                            setConditionals(tree,c,o[0]);
                            if (tag.hasParam("valid")) o[0].setRestricted(false);
                            try
                            {      double x=new Double(tag.getValue("x")).doubleValue();
                                   double y=new Double(tag.getValue("y")).doubleValue();
                                   o[0].setXY(x,y);
                            }
                            catch (Exception e) {}
                     }
              }
              catch (ConstructionException e)
              {      throw e;
              }
              catch (Exception e)
              {      e.printStackTrace();
                     throw new ConstructionException("Intersection parameters illegal!");
              }
              return true;
       }

Here is the call graph for this function:

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

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 274 of file IntersectionConstructor.java.

       {      if (nparams!=2 && nparams!=3)
                     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]);
              ConstructionObject
                     P2=c.find(params[1]);
              if (P2==null)
                     throw new ConstructionException(Zirkel.name("exception.notfound")+" "+
                            params[0]);
              IntersectionObject o[]=construct(P1,P2,c);
              if (o==null)
                     throw new ConstructionException(Zirkel.name("exception.type"));
              if (o.length==1)
              {      c.add(o[0]);
                     o[0].setDefaults();
                     if (!name.equals("")) o[0].setName(name);
              }
              else
              {      if (name.equals(""))
                     {      for (int i=0; i<o.length; i++)
                            {      c.add(o[i]);
                                   o[i].setDefaults();
                            }
                     }
                     else
                     {      String names[]=new String[2];
                            int n;
                            if ((n=name.indexOf(','))>=0)
                            {      names[0]=name.substring(n+1).trim();
                                   names[1]=name.substring(0,n).trim();
                            }
                            else
                            {      names[0]=name;
                                   names[1]="";
                            }
                            for (int i=0; i<o.length; i++)
                            {      if (names[i].equals("")) continue;
                                   c.add(o[i]);
                                   o[i].setDefaults();
                                   o[i].setName(names[i]);
                            }
                     }
              }
       }

Here is the call graph for this function:

Definition at line 239 of file IntersectionConstructor.java.

       {      if (!testTree(tree,"OtherIntersection")) return false;
              XmlTag tag=tree.getTag();
              if (tag.hasParam("name"))
              {      ConstructionObject o=c.find(tag.getValue("name"));      
                     if (o==null || !(o instanceof IntersectionObject))
                            throw new ConstructionException("OtherIntersection not found!");
                     IntersectionObject oo=(IntersectionObject)o;
                     PointConstructor.setType(tag,oo);
                     o.setDefaults();
                     set(tree,o);
                     ConstructionObject ol=c.lastButOne();
                     if (tag.hasParam("awayfrom"))
                     {      oo.setAway(tag.getValue("awayfrom"),true);
                            if (ol!=null && (ol instanceof IntersectionObject))
                                   ((IntersectionObject)ol).setAway(tag.getValue("awayfrom"),
                                          false);
                     }
                     else if (tag.hasParam("closeto"))
                     {      oo.setAway(tag.getValue("closeto"),false);
                            if (ol!=null && (ol instanceof IntersectionObject))
                                   ((IntersectionObject)ol).setAway(tag.getValue("awayfrom"),
                                          true);
                     }
                     if (tag.hasParam("valid"))
                     {      oo.setRestricted(false);
                     }
              }
              else
                     throw new ConstructionException("OtherIntersection must have a name!");                    
              return true;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 273 of file IntersectionConstructor.java.

{ return "Intersection"; }
void rene.zirkel.constructors.ObjectConstructor.mouseDragged ( MouseEvent  e,
ZirkelCanvas  zc 
) [inline, inherited]
void rene.zirkel.constructors.IntersectionConstructor.mouseMoved ( MouseEvent  e,
ZirkelCanvas  zc,
boolean  simple 
) [inline]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 85 of file IntersectionConstructor.java.

       {      zc.indicateIntersectedObjects(e.getX(),e.getY());
       }

Here is the call graph for this function:

See, if the other intersection is visible and already a point of both objects.

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 25 of file IntersectionConstructor.java.

       {      if (!zc.Visual) return;
              boolean immediate=false;
              if (P1==null)
              {      MyVector v=zc.selectPointonObjects(e.getX(),e.getY());
                     if (v.size()==2)
                     {      P1=(ConstructionObject)v.elementAt(0);
                            P2=(ConstructionObject)v.elementAt(1);
                            if (P1.equals(P2) ||
                                   (P1.isFilled() && P2.isFilled()))
                            {      P1=P2=null;
                            }
                            else immediate=true;
                     }
              }
              if (P1==null)
              {      P1=select(e.getX(),e.getY(),zc);
                     if (P1!=null)
                     {      P1.setSelected(true);
                            zc.repaint();
                            showStatus(zc);
                     }
              }
              else
              {      if (P2==null) P2=select(e.getX(),e.getY(),zc);
                     if (P2!=null)
                     {      if (P2==P1)
                            {      P2=null; return;
                            }
                            IntersectionObject o[]=construct(P1,P2,zc.getConstruction());
                            if (o!=null)
                            {      IntersectionObject oc=null;
                                   if (immediate && o.length>1)
                                   {      if (o[1].nearto(e.getX(),e.getY(),zc))
                                          {      o[0]=null; oc=o[1];
                                          }
                                          else
                                          {      o[1]=null; oc=o[0];
                                          }
                                   }
                                   for (int i=0; i<o.length; i++)
                                   {      if (o[i]!=null)
                                          {      o[i].setDefaults();
                                                 zc.addObject(o[i]);
                                                 o[i].validate(zc.x(e.getX()),zc.y(e.getY()));
                                          }
                                   }
                                   if (oc!=null) oc.autoAway();
                            }
                            P1=P2=null;
                            zc.clearSelected();
                            showStatus(zc);
                     }
              }
       }

Here is the call graph for this function:

void rene.zirkel.constructors.ObjectConstructor.mouseReleased ( MouseEvent  e,
ZirkelCanvas  zc 
) [inline, inherited]
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 143 of file IntersectionConstructor.java.

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

Here is the call 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 138 of file IntersectionConstructor.java.

       {      return zc.selectPointonObject(x,y,false);
       }

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 154 of file IntersectionConstructor.java.

       {      if (P1==null) zc.showStatus(
                     Zirkel.name("message.intersection.first","Intersection: Select first object!"));
              else zc.showStatus(
                     Zirkel.name("message.intersection.second","Intersection: Select second object!"));
       }

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:


Member Data Documentation

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

Definition at line 15 of file ObjectConstructor.java.

Definition at line 23 of file IntersectionConstructor.java.

Definition at line 23 of file IntersectionConstructor.java.


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