Back to index

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

List of all members.

Public Member Functions

 Tracker (ConstructionObject p, ConstructionObject po[])
 Tracker ()
void mousePressed (MouseEvent e, ZirkelCanvas zc)
void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
void mouseDragged (MouseEvent e, ZirkelCanvas zc)
void mouseReleased (MouseEvent e, ZirkelCanvas zc)
void reset (ZirkelCanvas zc)
void showStatus (ZirkelCanvas zc)
void track (ZirkelCanvas zc)
Enumeration elements ()
void paint (MyGraphics g, ZirkelCanvas zc)
void validate (ZirkelCanvas zc)
void save (XmlWriter xml)
boolean useSmartBoard ()
void finishConstruction (MouseEvent e, ZirkelCanvas zc)
boolean waitForLastPoint ()
boolean waitForPoint ()
void resetFirstTime (ZirkelCanvas zc)
void invalidate (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)

Protected Attributes

boolean Dragging = false

Package Attributes

ConstructionObject PM
int PMax = 8
int PN
ConstructionObject P
ConstructionObject PO [] = new ConstructionObject[PMax]
Vector V = new Vector()
Vector VO [] = new Vector[PMax]
double X
double Y
double DX
double DY
double XO [] = new double[PMax]
double YO [] = new double[PMax]
double DXO [] = new double[PMax]
double DYO [] = new double[PMax]
boolean Started
boolean StartedO [] = new boolean[PMax]
boolean Other

Detailed Description

Definition at line 17 of file Tracker.java.


Constructor & Destructor Documentation

Definition at line 32 of file Tracker.java.

       {      super();
              P=p;
              PN=0;
              for (int i=0; i<po.length; i++)
              {      if (i>=PMax || po[i]==null) break;
                     PO[PN]=po[i];
                     VO[i]=new Vector();
                     PN++;
              }
       }

Definition at line 44 of file Tracker.java.

       {      super();
       }

Member Function Documentation

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

Definition at line 180 of file Tracker.java.

       {      return V.elements();
       }
void rene.zirkel.constructors.ObjectConstructor.finishConstruction ( MouseEvent  e,
ZirkelCanvas  zc 
) [inline, inherited]
String rene.zirkel.constructors.ObjectConstructor.getTag ( ) [inline, inherited]
void rene.zirkel.tools.Tracker.mouseDragged ( MouseEvent  e,
ZirkelCanvas  zc 
) [inline]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 96 of file Tracker.java.

       {      if (PM==null) return;
              ((MoveableObject)PM).dragTo(zc.x(e.getX()),zc.y(e.getY()));
              zc.validate(); track(zc); zc.repaint();
       }

Here is the call graph for this function:

void rene.zirkel.tools.Tracker.mouseMoved ( MouseEvent  e,
ZirkelCanvas  zc,
boolean  simple 
) [inline]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 87 of file Tracker.java.

       {      if (P==null || Other)
                     zc.indicatePointsOrLines(e.getX(),e.getY());
              else if (PM==null)
                     zc.indicateMoveableObjects(e.getX(),e.getY());
              else
                     zc.clearIndicated();
       }

Here is the call graph for this function:

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

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 48 of file Tracker.java.

       {      double x=zc.x(e.getX()),y=zc.y(e.getY());
              if (P==null)
              {      P=zc.selectPoint(e.getX(),e.getY());
                     if (P==null) P=zc.selectLine(e.getX(),e.getY());
                     if (P==null) return;
                     P.setSelected(true);
                     zc.repaint();
                     if (e.isShiftDown()) Other=true;
                     else Other=false;
                     showStatus(zc);
              }
              else if (Other)
              {      ConstructionObject P=zc.selectPoint(e.getX(),e.getY());
                     if (P==null) P=zc.selectLine(e.getX(),e.getY());
                     if (P!=null)
                     {      P.setSelected(true);
                            zc.repaint();
                            PO[PN]=P;
                            VO[PN]=new Vector();
                            PN++;
                     }
                     if (!e.isShiftDown() || PN>=PMax) Other=false;
                     showStatus(zc);
              }             
              else
              {      ConstructionObject pm=zc.selectMoveableObject(e.getX(),e.getY());
                     PM=pm;
                     if (PM!=null)
                     {      zc.clearSelected();
                            PM.setSelected(true);
                            ((MoveableObject)PM).startDrag(x,y);
                            zc.repaint();
                            showStatus(zc);
                     }
                     Started=false;
              }
       }

Here is the call graph for this function:

void rene.zirkel.tools.Tracker.mouseReleased ( MouseEvent  e,
ZirkelCanvas  zc 
) [inline]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 102 of file Tracker.java.

       {      if (PM==null) return;
              PM.setSelected(false);
              PM=null;
              zc.repaint();
              showStatus(zc);
       }

Here is the call graph for this function:

void rene.zirkel.tools.Tracker.paint ( MyGraphics  g,
ZirkelCanvas  zc 
) [inline]

Definition at line 184 of file Tracker.java.

       {      if (P==null) return;
              Coordinates C;
              Enumeration e=V.elements();
              g.setColor(P);
              double c0,r0,c,r;
              int maxd=zc.width()/20;
              if (e.hasMoreElements())
              {      C=(Coordinates)e.nextElement();
                     c0=zc.col(C.X); r0=zc.row(C.Y);
                     while (e.hasMoreElements())
                     {      C=(Coordinates)e.nextElement();
                            c=zc.col(C.X); r=zc.row(C.Y);
                            if (Math.abs(c0-c)<maxd && Math.abs(r0-r)<maxd)
                                   g.drawLine(c0,r0,c,r,P);
                            else
                                   g.drawLine(c0,r0,c0,r0,P);
                            c0=c; r0=r;
                     }
              }
              for (int i=0; i<PN; i++)
              {      if (PO[i]==null) continue;
                     g.setColor(PO[i]);
                     e=VO[i].elements();
                     if (e.hasMoreElements())
                     {      C=(Coordinates)e.nextElement();
                            c0=zc.col(C.X); r0=zc.row(C.Y);
                            while (e.hasMoreElements())
                            {      C=(Coordinates)e.nextElement();
                                   c=zc.col(C.X); r=zc.row(C.Y);
                                   if (Math.abs(c0-c)<maxd && Math.abs(r0-r)<maxd)
                                          g.drawLine(c0,r0,c,r,PO[i]);
                                   else
                                          g.drawLine(c0,r0,c0,r0,PO[i]);
                                   c0=c; r0=r;
                            }
                     }
              }
       }

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 110 of file Tracker.java.

       {      zc.clearSelected();
              P=PM=null; PN=0;
              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:

void rene.zirkel.tools.Tracker.save ( XmlWriter  xml) [inline]

Definition at line 227 of file Tracker.java.

       {      if (P==null) return;
              xml.startTagStart("Track");
              xml.printArg("track",P.getName());
              for (int i=0; i<PN; i++)
              {      xml.printArg("track"+i,PO[i].getName());
              }
              if (PM!=null) xml.printArg("move",PM.getName());
              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 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 117 of file Tracker.java.

       {      if (P==null || Other) zc.showStatus(
                     Zirkel.name("message.tracker.select"));
              else if (PM==null) zc.showStatus(
                     Zirkel.name("message.tracker.selectpoint"));
              else zc.showStatus(
                     Zirkel.name("message.tracker.move"));
       }

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:

Definition at line 126 of file Tracker.java.

       {      if (P==null) return;
              if (P instanceof PointObject)
              {      PointObject p=(PointObject)P;
                     if (p.valid())
                            V.addElement(new Coordinates(p.getX(),p.getY()));
              }
              else if (P instanceof PrimitiveLineObject)
              {      PrimitiveLineObject L=(PrimitiveLineObject)P;
                     if (L.valid())
                     {      if (!Started)
                            {      X=L.getX(); Y=L.getY(); DX=L.getDX(); DY=L.getDY();
                                   Started=true;
                            }
                            else
                            {      double x,y,dx,dy;
                                   x=L.getX(); y=L.getY(); dx=L.getDX(); dy=L.getDY();
                                   double det=dx*DY-dy*DX;
                                   if (Math.sqrt(Math.abs(det))>1e-9)
                                   {      double a=(-(X-x)*DY+DX*(Y-y))/(-det);
                                          V.addElement(new Coordinates(x+a*dx,y+a*dy));
                                   }
                                   X=x; Y=y; DX=dx; DY=dy;
                            }
                     }
              }
              for (int i=0; i<PN; i++)
              {      if (PO[i]==null || !PO[i].valid()) continue;
                     if (PO[i] instanceof PointObject)
                     {      PointObject p=(PointObject)PO[i];
                            VO[i].addElement(new Coordinates(p.getX(),p.getY()));
                     }
                     else if (PO[i] instanceof PrimitiveLineObject)
                     {      PrimitiveLineObject L=(PrimitiveLineObject)PO[i];
                            if (!StartedO[i])
                            {      XO[i]=L.getX(); YO[i]=L.getY();
                                   DXO[i]=L.getDX(); DYO[i]=L.getDY();
                                   StartedO[i]=true;
                            }
                            else
                            {      double x,y,dx,dy;
                                   x=L.getX(); y=L.getY(); dx=L.getDX(); dy=L.getDY();
                                   double det=dx*DYO[i]-dy*DXO[i];
                                   if (Math.sqrt(Math.abs(det))>1e-9)
                                   {      double a=(-(XO[i]-x)*DYO[i]+
                                                 DXO[i]*(YO[i]-y))/(-det);
                                          VO[i].addElement(new Coordinates(x+a*dx,y+a*dy));
                                   }
                                   XO[i]=x; YO[i]=y; DXO[i]=dx; DYO[i]=dy;
                            }
                     }
              }
       }

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 238 of file Tracker.java.

       {      return false;
       }

Definition at line 223 of file Tracker.java.

       {
       }

Member Data Documentation

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

Definition at line 15 of file ObjectConstructor.java.

double rene.zirkel.tools.Tracker.DX [package]

Definition at line 25 of file Tracker.java.

double rene.zirkel.tools.Tracker.DXO[] = new double[PMax] [package]

Definition at line 27 of file Tracker.java.

double rene.zirkel.tools.Tracker.DY [package]

Definition at line 25 of file Tracker.java.

double rene.zirkel.tools.Tracker.DYO[] = new double[PMax] [package]

Definition at line 27 of file Tracker.java.

Definition at line 30 of file Tracker.java.

Definition at line 21 of file Tracker.java.

Definition at line 19 of file Tracker.java.

int rene.zirkel.tools.Tracker.PMax = 8 [package]

Definition at line 20 of file Tracker.java.

Definition at line 20 of file Tracker.java.

Definition at line 22 of file Tracker.java.

Definition at line 28 of file Tracker.java.

Definition at line 29 of file Tracker.java.

Vector rene.zirkel.tools.Tracker.V = new Vector() [package]

Definition at line 23 of file Tracker.java.

Vector rene.zirkel.tools.Tracker.VO[] = new Vector[PMax] [package]

Definition at line 24 of file Tracker.java.

double rene.zirkel.tools.Tracker.X [package]

Definition at line 25 of file Tracker.java.

double rene.zirkel.tools.Tracker.XO[] = new double[PMax] [package]

Definition at line 26 of file Tracker.java.

double rene.zirkel.tools.Tracker.Y [package]

Definition at line 25 of file Tracker.java.

double rene.zirkel.tools.Tracker.YO[] = new double[PMax] [package]

Definition at line 26 of file Tracker.java.


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