Back to index

wims  3.65+svn20090927
Public Member Functions | Protected Attributes | Package Attributes
rene.zirkel.tools.AnimatorTool Class Reference

Animator is a class to animate a point along a sequence of segments and/or circles. More...

Inheritance diagram for rene.zirkel.tools.AnimatorTool:
Inheritance graph
[legend]
Collaboration diagram for rene.zirkel.tools.AnimatorTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 AnimatorTool ()
 AnimatorTool (PointObject p, Vector v, ZirkelCanvas zc, boolean negative, boolean original, String delay)
void setInteractive (boolean flag)
boolean isAdmissible (ZirkelCanvas zc, ConstructionObject o)
void mousePressed (MouseEvent e, ZirkelCanvas zc)
void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
synchronized void reset (ZirkelCanvas zc)
void showStatus (ZirkelCanvas zc)
void save (XmlWriter xml)
void run ()
synchronized void invalidate (ZirkelCanvas zc)
boolean useSmartBoard ()
void increaseSpeed ()
void decreaseSpeed ()
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)
boolean construct (XmlTree tree, Construction c) throws ConstructionException
void construct (Construction c, String name, String params[], int nparams) throws ConstructionException
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)
String getTag ()
void pause (boolean flag)
boolean isAdmissible (ZirkelCanvas zc, ConstructionObject o)

Protected Attributes

boolean Dragging = false

Package Attributes

PointObject P
Vector V
ZirkelCanvas ZC
boolean Running = false
boolean Interactive = true
boolean Complete = false
boolean Negative = false
boolean Original = false
double Delay = 50
boolean Stopped = false

Detailed Description

Animator is a class to animate a point along a sequence of segments and/or circles.

The animation may either go back and forth or always in the same direction. Shift-Click schaltet während der Animation um.

Author:
Rene

Definition at line 22 of file AnimatorTool.java.


Constructor & Destructor Documentation

Definition at line 32 of file AnimatorTool.java.

       {      V=new Vector(); 
              P=null; 
       }
rene.zirkel.tools.AnimatorTool.AnimatorTool ( PointObject  p,
Vector  v,
ZirkelCanvas  zc,
boolean  negative,
boolean  original,
String  delay 
) [inline]

Definition at line 37 of file AnimatorTool.java.

       {      P=p; 
              if (!P.moveable()) return; 
              V=new Vector(); 
              Enumeration e=v.elements(); 
              while (e.hasMoreElements())
              {      ConstructionObject o=zc.getConstruction().find(
                     (String)e.nextElement()); 
                     if (!(o instanceof SegmentObject ||
                            o instanceof PrimitiveCircleObject ||
                            o instanceof PointObject
                            ))
                            return; 
                     V.addElement(o); 
              }
              Stopped=false; 
              ZC=zc; 
              Complete=true; 
              Negative=negative; 
              Original=original;
              try
              {      Delay=50;
                     Delay=new Double(delay).doubleValue();
              }
              catch (Exception ex) {}
              
              new Thread(this).start(); 
       }

Here is the call graph for this function:


Member Function Documentation

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

Definition at line 309 of file AnimatorTool.java.

       {      if (Delay<500) Delay=Delay*1.5;
       }
void rene.zirkel.constructors.ObjectConstructor.finishConstruction ( MouseEvent  e,
ZirkelCanvas  zc 
) [inline, inherited]
String rene.zirkel.constructors.ObjectConstructor.getTag ( ) [inline, inherited]

Definition at line 305 of file AnimatorTool.java.

       {      if (Delay>1) Delay=Delay/1.5;
       }
synchronized void rene.zirkel.tools.AnimatorTool.invalidate ( ZirkelCanvas  zc) [inline]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 297 of file AnimatorTool.java.

       {      Stopped=true; 
       }
boolean rene.zirkel.construction.Selector.isAdmissible ( ZirkelCanvas  zc,
ConstructionObject  o 
) [inherited]

Definition at line 71 of file AnimatorTool.java.

       {      if ((o instanceof CircleObject) && 
                     ((CircleObject)o).getP2()==P) return true;
              if (zc.depends(o,P)) return false;
              return true;
       }

Here is the call graph for this function:

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

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 133 of file AnimatorTool.java.

       {      if (Complete || !Interactive) return; 
              if (P==null)
                     zc.indicatePointObjects(e.getX(),e.getY()); 
              else
                     zc.indicateObjects(e.getX(),e.getY()); 
       }

Here is the call graph for this function:

void rene.zirkel.tools.AnimatorTool.mousePressed ( MouseEvent  e,
ZirkelCanvas  zc 
) [inline]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 78 of file AnimatorTool.java.

       {      double x=zc.x(e.getX()),y=zc.y(e.getY()); 
              if (P==null)
              {      P=zc.selectPoint(e.getX(),e.getY()); 
                     Complete=false; 
                     if (P!=null && P.moveable())
                     {      P.setSelected(true); 
                            zc.repaint(); 
                            showStatus(zc); 
                     }
              }
              else
              {      if (!Complete && Interactive)
                     {      ConstructionObject o=zc.selectWithSelector(e.getX(),e.getY(),this); 
                            if (o==null) return; 
                            boolean Have=(o==P); 
                            if (!Have)
                            {      Enumeration en=V.elements(); 
                                   while (en.hasMoreElements())
                                   {      if (o==en.nextElement())
                                          {      Have=true; break; 
                                          }
                                   }
                            }
                            if (!Have)
                            {      if (!((o instanceof SegmentObject) ||
                                   (o instanceof PrimitiveCircleObject) ||
                                          (o instanceof PointObject)
                                          ))
                                          return; 
                                   o.setSelected(true); 
                                   V.addElement(o); 
                                   zc.repaint(); 
                                   showStatus(zc); 
                                   return; 
                            }
                     }
                     if (!Running)
                     {      Stopped=false; 
                            ZC=zc;
                            zc.clearSelected(); 
                            Complete=true; 
                            zc.clearIndicated(); 
                            showStatus(zc);
                            new Thread(this).start(); 
                     }
                     else if (e.isShiftDown())
                     {      Negative=!Negative; 
                     }
                     else
                     {      Stopped=true; 
                     }
              }
       }

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:

synchronized void rene.zirkel.tools.AnimatorTool.reset ( ZirkelCanvas  zc) [inline]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 141 of file AnimatorTool.java.

       {      Stopped=true; Complete=false;
              super.reset(zc); 
              P=null; 
              Delay=50;
              V=new Vector(); showStatus(zc); zc.repaint(); 
       }

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 176 of file AnimatorTool.java.

       {      ZC.resetSum();
              if (Original) ZC.getConstruction().setOriginalOrder(true);
              Running=true; 
              showStatus(ZC); 
              Enumeration e=V.elements(); 
              double x=0.001; 
              boolean full=true; 
              ConstructionObject o=null; 
              long time=System.currentTimeMillis(); 
              long stoptime=time; 
              double end=2*Math.PI;
              boolean back=false;
              while (true)
              {      if (Stopped) break; 
                     try
                     {      long t=System.currentTimeMillis(); 
                            int h=(int)(t-time); 
                            if (h<0) h=0; 
                            if (h>Delay) h=(int)Delay; 
                            Thread.sleep((int)(Delay-h)); 
                            time=System.currentTimeMillis(); 
                     }
                     catch (Exception ex) {      }
                     if (Stopped) break; 
                     if (ZC.I==null) continue; 
                     synchronized (this)
                     {      if (full)
                            {      if (!e.hasMoreElements())
                                   {      e=V.elements(); 
                                   }
                                   o=(ConstructionObject)e.nextElement(); 
                                   full=false; 
                                   x=0.0001; 
                                   if (o instanceof SegmentObject)
                                          x=0.001*((SegmentObject)o).getLength(); 
                                   else if (o instanceof PrimitiveCircleObject)
                                   {      PrimitiveCircleObject c=(PrimitiveCircleObject)o;
                                          if (c.hasRange())
                                          {      c.computeA1A2();
                                                 x=c.getA1();
                                                 end=c.getA2();
                                                 if (end<x) end=end+2*Math.PI;
                                                 back=false;
                                          }
                                          else 
                                                 x=0.0001*c.getR(); 
                                   }
                                   else if (o instanceof PointObject)
                                   {      PointObject p=(PointObject)o; 
                                          synchronized (ZC)
                                          {      P.move(p.getX(),p.getY()); 
                                                 ZC.dovalidate(); 
                                          }
                                          ZC.repaint(); 
                                          stoptime=System.currentTimeMillis(); 
                                   }
                            }
                            if (o instanceof SegmentObject)
                            {      SegmentObject s=(SegmentObject)o;
                                   synchronized (ZC) 
                                   {      if (back)
                                                 P.move(s.getP1().getX()+(s.getLength()-x)*s.getDX(),
                                                        s.getP1().getY()+(s.getLength()-x)*s.getDY()); 
                                          else
                                                 P.move(s.getP1().getX()+x*s.getDX(),
                                                        s.getP1().getY()+x*s.getDY()); 
                                          ZC.dovalidate(); 
                                   }
                                   ZC.repaint(); 
                                   x+=ZC.dx(2); 
                                   if (x>0.99*s.getLength()) 
                                   {      if (Negative && !back)
                                          {      x=0.00001; back=true;
                                          }
                                          else
                                          {      back=false; full=true; 
                                          }
                                   }
                            }
                            else if (o instanceof PrimitiveCircleObject)
                            {      PrimitiveCircleObject c=(PrimitiveCircleObject)o; 
                                   if (c.getR()<1e-10)
                                   {      full=true; 
                                   }
                                   else
                                   {      synchronized (ZC)
                                          {      if (Negative && !c.hasRange())
                                                        P.move(c.getP1().getX()+Math.cos(x)*c.getR(),
                                                               c.getP1().getY()-Math.sin(x)*c.getR()); 
                                                 else
                                                        P.move(c.getP1().getX()+Math.cos(x)*c.getR(),
                                                               c.getP1().getY()+Math.sin(x)*c.getR()); 
                                                 ZC.dovalidate(); 
                                          }
                                          ZC.repaint(); 
                                          if (back) x-=ZC.dx(2)/c.getR(); 
                                          else x+=ZC.dx(2)/c.getR(); 
                                          if (x>end && !back)
                                          {      if (!Negative || back || !c.hasRange())
                                                 {      full=true; back=false;
                                                 }
                                                 else
                                                 {      back=true; end=c.getA1();
                                                 }
                                          } 
                                          if (back && x<end)
                                          {      full=true; back=false;
                                          }
                                   }
                            }
                            else if (o instanceof PointObject)
                            {      if (System.currentTimeMillis()-stoptime>5000)
                                   full=true; 
                            }
                     }
              }
              Running=false; 
              if (Original) ZC.getConstruction().setOriginalOrder(false);
       }

Here is the call graph for this function:

Definition at line 158 of file AnimatorTool.java.

       {      if (P==null) return; 
              xml.startTagStart("Animate"); 
              xml.printArg("animate",P.getName()); 
              int k=0; 
              Enumeration e=V.elements(); 
              while (e.hasMoreElements())
              {      String s=((ConstructionObject)e.nextElement()).getName(); 
                     xml.printArg("via"+k,s); 
                     k++; 
              }
              if (Negative) xml.printArg("negative","true"); 
              if (Delay!=50) xml.printArg("delay",""+Delay);
              xml.finishTagNewLine(); 
       }

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

       {      Interactive=flag; 
       }

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 149 of file AnimatorTool.java.

       {      if (P==null) zc.showStatus(
                     Zirkel.name("message.animator.point")); 
              else if (!Complete) zc.showStatus(
                     Zirkel.name("message.animator.segment")); 
              else zc.showStatus(
                     Zirkel.name("message.animator.running")); 
       }

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 301 of file AnimatorTool.java.

       {      return false; 
       }

Member Data Documentation

Definition at line 27 of file AnimatorTool.java.

double rene.zirkel.tools.AnimatorTool.Delay = 50 [package]

Definition at line 30 of file AnimatorTool.java.

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

Definition at line 15 of file ObjectConstructor.java.

Definition at line 27 of file AnimatorTool.java.

Definition at line 28 of file AnimatorTool.java.

Definition at line 29 of file AnimatorTool.java.

Definition at line 24 of file AnimatorTool.java.

Definition at line 27 of file AnimatorTool.java.

Definition at line 174 of file AnimatorTool.java.

Definition at line 25 of file AnimatorTool.java.

Definition at line 26 of file AnimatorTool.java.


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