Back to index

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

List of all members.

Public Member Functions

 MetaMover (ObjectConstructor oc, ZirkelCanvas zc, ConstructionObject p, MouseEvent e)
void mouseReleased (MouseEvent e, ZirkelCanvas zc)
void mousePressed (MouseEvent e, ZirkelCanvas zc)
void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
void mouseDragged (MouseEvent e, ZirkelCanvas zc)
 Drag a point in a new location and recompute the construction.
void mouseReleased (MouseEvent e, ZirkelCanvas zc, boolean rightmouse)
 Release the mouse after dragging.
void reset (ZirkelCanvas zc)
void resetFirstTime (ZirkelCanvas zc)
void showStatus (ZirkelCanvas zc)
boolean useSmartBoard ()
void finishConstruction (MouseEvent e, ZirkelCanvas zc)
boolean waitForLastPoint ()
boolean waitForPoint ()
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

ObjectConstructor OC
ConstructionObject PP
ConstructionObject P
boolean Selected = false
boolean ShowsValue
boolean ShowsName
boolean Grab
boolean WasDrawable
boolean ChangedDrawable
MyVector V = null
double OldX
double OldY
Graphics ZCG
boolean IntersectionBecameInvalid = false

Detailed Description

Definition at line 16 of file MetaMover.java.


Constructor & Destructor Documentation

Definition at line 20 of file MetaMover.java.

       {      OC=oc; PP=P=p;
              oc.pause(true);
              if (P!=null)
              {      P.setSelected(true);
                     ShowsValue=P.showValue();
                     ShowsName=P.showName();
                     zc.repaint();
                     showStatus(zc);
                     zc.setCursor(new Cursor(Cursor.MOVE_CURSOR));
                     if (P instanceof MoveableObject)
                     {      ((MoveableObject)P).startDrag(zc.x(e.getX()),zc.y(e.getY()));
                     }
                     if (ZCG!=null)
                     {      ZCG.dispose();
                            ZCG=null;
                     }
                     ZCG=zc.getGraphics();
              }
       }

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]
void rene.zirkel.constructors.ObjectConstructor.finishConstruction ( MouseEvent  e,
ZirkelCanvas  zc 
) [inline, inherited]
String rene.zirkel.constructors.ObjectConstructor.getTag ( ) [inline, inherited]
void rene.zirkel.tools.MoverTool.mouseDragged ( MouseEvent  e,
ZirkelCanvas  zc 
) [inline, inherited]

Drag a point in a new location and recompute the construction.

Can show the name and the value of the object to be dragged. Take care not to move the point while ZirkelCanvas.paint is active. ZirkelCanvas.paint is synchronized!

See also:
rene.zirkel.ObjectConstructor::mouseDragged(java.awt.event.MouseEvent, rene.zirkel.ZirkelCanvas)

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 130 of file MoverTool.java.

       {      if (P==null) return;
              // System.out.println("dragging "+P.getName());
              zc.getConstruction().haveChanged();
              zc.getConstruction().dontAlternate(false);
              synchronized (zc)
              {      double oldx=0,oldy=0;
                     if ((Global.getParameter("restrictedmove",false) || e.isShiftDown()) 
                                   && P instanceof PointObject)
                     {      if (IntersectionBecameInvalid)
                            {      zc.getConstruction().dontAlternate(true);
                                   IntersectionBecameInvalid=false;
                            }
                            oldx=((PointObject)P).getX(); oldy=((PointObject)P).getY();
                     }
                     ((MoveableObject)P).dragTo(zc.x(e.getX()),zc.y(e.getY()));
                     if ((Global.getParameter("options.movename",false) && !P.isFixed())
                            ||
                            (Global.getParameter("options.movefixname",true) && P.isFixed()))
                     {      P.setShowValue(true);
                            P.setShowName(true);
                     }
                     P.updateText();
                     if (V!=null && (P instanceof PointObject))
                     {      double dx=((PointObject)P).getX()-OldX,dy=((PointObject)P).getY()-OldY;
                            Enumeration en=V.elements();
                            while (en.hasMoreElements())
                            {      PointObject p=(PointObject)en.nextElement();
                                   p.move(p.getX()+dx,p.getY()+dy);
                                   p.updateText();
                            }
                            OldX=((PointObject)P).getX(); OldY=((PointObject)P).getY();
                     }
                     if (P instanceof PointObject)
                     {      PointObject Po=(PointObject)P;
                            if (Po.dependsOnItselfOnly())
                            {      Po.dontUpdate(true);
                                   zc.dovalidate();
                                   Po.dontUpdate(false);
                            }
                     }
                     zc.validate();
                     if ((Global.getParameter("restrictedmove",false) || e.isShiftDown()) 
                                   && P instanceof PointObject 
                                   && zc.getConstruction().intersectionBecameInvalid())
                     {      ((PointObject)P).dragTo(oldx,oldy);
                            IntersectionBecameInvalid=true;
                            zc.validate();
                     }
              }
              if (ZCG==null) ZCG=zc.getGraphics();
              zc.paint(ZCG);
       }

Here is the call graph for this function:

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

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 117 of file MoverTool.java.

       {      zc.indicateMoveableObjects(e.getX(),e.getY(),e.isControlDown());
       }

Here is the call graph for this function:

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

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 28 of file MoverTool.java.

       {      if (!Selected && V!=null) zc.clearSelected();
              if (e.isControlDown() && V==null)
                     // force a fixed angle or fixed circle to become drawable!
              {      P=zc.selectObject(e.getX(),e.getY());
                     ChangedDrawable=false;
                     if (P instanceof FixedCircleObject &&
                            ((FixedCircleObject)P).fixedByNumber())
                     {      WasDrawable=((FixedCircleObject)P).isDragable();
                            ChangedDrawable=true;
                            ((FixedCircleObject)P).setDragable(true);
                     }
                     else if (P instanceof FixedAngleObject &&
                            ((FixedAngleObject)P).fixedByNumber())
                     {      WasDrawable=((FixedAngleObject)P).isDragable();
                            ChangedDrawable=true;
                            ((FixedAngleObject)P).setDragable(true);
                     }
                     else P=null;
              }
              if (P==null) // no forced moveable fixed circle or angle
              {      if (V!=null) // try to select another point 
                            P=zc.selectMoveablePoint(e.getX(),e.getY());
                     else // try to select any moveable object 
                            P=zc.selectMoveableObject(e.getX(),e.getY());
              }
              if (P!=null && V!=null) 
                     // Check, if we have that point already:
              {      Enumeration en=V.elements();
                     while (en.hasMoreElements())
                     {      if (P==en.nextElement()) // point found
                            {      if (e.isShiftDown()) P=null; 
                                          // selected a point twice, but want still more points 
                                   else V.removeElement(P);
                                          // remove the point from the list and start dragging
                                   break;
                            }
                     }
              }                    
              if (P!=null) // point is selected for movement
              {      P.setSelected(true);
                     ShowsName=P.showName();
                     ShowsValue=P.showValue();
                     zc.setCursor(new Cursor(Cursor.MOVE_CURSOR));
              }
              else // point was chosen from a list of objects
              {      Selected=(zc.findSelectedObject()!=null);
              }
              // Highlight all selected points:
              if (V!=null)
              {      Enumeration en=V.elements();
                     while (en.hasMoreElements())
                     {      ((PointObject)en.nextElement()).setSelected(true);
                     }
              }
              if (P!=null)
              {      if (P instanceof PointObject)
                     {      if (e.isShiftDown()) // want more points!
                            {      if (V==null) V=new MyVector();
                                   if (P!=null) V.addElement(P);
                                   P=null;
                            }
                            else if (e.isControlDown())
                                   // show current construction while moving
                            {      zc.grab(true);
                                   Grab=true;
                            }
                            else
                                   // remember old point position 
                            {      OldX=((PointObject)P).getX(); OldY=((PointObject)P).getY();
                            }
                     }
                     else if (P instanceof MoveableObject)
                            // call startDrag method of the object
                     {      ((MoveableObject)P).startDrag(
                                   zc.x(e.getX()),zc.y(e.getY()));
                            // System.out.println("start dragging "+P.getName());
                            V=null;
                     }
                     if (ZCG!=null)
                     {      ZCG.dispose();
                            ZCG=null;
                     }
                     ZCG=zc.getGraphics();
              }
              zc.repaint();
              showStatus(zc);
       }

Here is the call graph for this function:

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

Reimplemented from rene.zirkel.tools.MoverTool.

Definition at line 42 of file MetaMover.java.

       {      if (P==null) return;
              if (ZCG!=null)
              {      ZCG.dispose();
                     ZCG=null;
              }             
              zc.setCursor(Cursor.getDefaultCursor());
              P.setSelected(false);
              P.setShowValue(ShowsValue);
              P.setShowName(ShowsName);
              if (zc.showGrid() && !Global.getParameter("grid.leftsnap",false))
              {      PP.snap(zc);
                     // PP.round();
                     PP.updateText();
              }
              zc.validate();
              if (Grab)
              {      zc.grab(false);
                     Grab=false;
              }
              if (ChangedDrawable)
              {      if (P instanceof FixedCircleObject)
                     {      ((FixedCircleObject)P).setDragable(WasDrawable);
                     }
                     else if (P instanceof FixedAngleObject)
                     {      ((FixedAngleObject)P).setDragable(WasDrawable);
                     }
              }
              zc.clearSelected();
              zc.repaint();
              P=null;
              V=null;
              Selected=false;
              zc.setTool(OC);
              OC.pause(false);
              zc.validate();
              zc.repaint();
       }

Here is the call graph for this function:

void rene.zirkel.tools.MoverTool.mouseReleased ( MouseEvent  e,
ZirkelCanvas  zc,
boolean  rightmouse 
) [inline, inherited]

Release the mouse after dragging.

Parameters:
e
zc
rightmouseCall comes from a right mouse drag!

Definition at line 190 of file MoverTool.java.

       {      if (P==null) return;
              if (ZCG!=null)
              {      ZCG.dispose();
                     ZCG=null;
              }      
              zc.setCursor(Cursor.getDefaultCursor());
              P.setSelected(false);
              P.setShowValue(ShowsValue);
              P.setShowName(ShowsName);
              if (zc.showGrid() && !rightmouse && 
                            Global.getParameter("grid.leftsnap",false))
              {      if (P instanceof PointObject && V!=null)
                     {      double dx=((PointObject)P).getX(),dy=((PointObject)P).getY();
                            P.snap(zc);
                            dx=((PointObject)P).getX()-dx; 
                            dy=((PointObject)P).getY()-dy;
                            P.round();
                            P.updateText();
                            Enumeration en=V.elements();
                            while (en.hasMoreElements())
                            {      PointObject p=(PointObject)en.nextElement();
                                   p.move(p.getX()+dx,p.getY()+dy);
                                   p.updateText();
                            }
                     }
                     else
                     {      P.snap(zc);
                            P.round();
                            P.updateText();
                     }
              }
              zc.validate();
              if (Grab)
              {      zc.grab(false);
                     Grab=false;
              }
              if (ChangedDrawable)
              {      if (P instanceof FixedCircleObject)
                     {      ((FixedCircleObject)P).setDragable(WasDrawable);
                     }
                     else if (P instanceof FixedAngleObject)
                     {      ((FixedAngleObject)P).setDragable(WasDrawable);
                     }
              }
              zc.clearSelected();
              zc.repaint();
              P=null;
              V=null;
              Selected=false;
              showStatus(zc);
       }

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:

void rene.zirkel.tools.MoverTool.reset ( ZirkelCanvas  zc) [inline, inherited]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 247 of file MoverTool.java.

       {      V=null;
              P=null;
              zc.clearSelected();
              zc.repaint(); 
              Selected=false;
       }

Here is the call graph for this function:

void rene.zirkel.tools.MoverTool.resetFirstTime ( ZirkelCanvas  zc) [inline, inherited]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 255 of file MoverTool.java.

       {      if (V!=null) V.removeAllElements();
              zc.clearSelected();
              zc.selectAllMoveableVisibleObjects();
              Graphics g=zc.getGraphics();
              if (g!=null)
              {      zc.paint(g);
                     g.dispose();
                     try
                     {      Thread.sleep(400);
                     }
                     catch (Exception e) {}
                     zc.clearSelected();
              }
              zc.repaint(); 
              Selected=false;
              P=null;
              V=null;
       }

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:

void rene.zirkel.tools.MoverTool.showStatus ( ZirkelCanvas  zc) [inline, inherited]

Reimplemented from rene.zirkel.constructors.ObjectConstructor.

Definition at line 275 of file MoverTool.java.

       {      if (P==null && !Selected) zc.showStatus(
                     Zirkel.name("message.move.select","Move: Select a point"));
              else if (Selected) 
                     zc.showStatus(
                     Zirkel.name("message.move.move","Move: Move the point"));
              else zc.showStatus(
                     Zirkel.name("message.move.move","Move: Move the point")+
                     " ("+P.getName()+")");
       }

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 286 of file MoverTool.java.

       {      return false;
       }

Member Data Documentation

Definition at line 23 of file MoverTool.java.

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

Definition at line 15 of file ObjectConstructor.java.

Definition at line 22 of file MoverTool.java.

Definition at line 121 of file MoverTool.java.

Definition at line 17 of file MetaMover.java.

double rene.zirkel.tools.MoverTool.OldX [package, inherited]

Definition at line 25 of file MoverTool.java.

double rene.zirkel.tools.MoverTool.OldY [package, inherited]

Definition at line 25 of file MoverTool.java.

Definition at line 19 of file MoverTool.java.

Definition at line 18 of file MetaMover.java.

Definition at line 20 of file MoverTool.java.

Definition at line 21 of file MoverTool.java.

Definition at line 21 of file MoverTool.java.

MyVector rene.zirkel.tools.MoverTool.V = null [package, inherited]

Definition at line 24 of file MoverTool.java.

Definition at line 23 of file MoverTool.java.

Graphics rene.zirkel.tools.MoverTool.ZCG [package, inherited]

Definition at line 26 of file MoverTool.java.


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