Back to index

wims  3.65+svn20090927
PointObject.java
Go to the documentation of this file.
00001 package rene.zirkel.objects;
00002 
00003 // file: PointObject.java
00004 
00005 import java.awt.*;
00006 import java.awt.event.*;
00007 import java.util.*;
00008 
00009 import rene.gui.*;
00010 import rene.dialogs.*;
00011 
00012 import rene.util.xml.*;
00013 import rene.zirkel.*;
00014 import rene.zirkel.construction.*;
00015 import rene.zirkel.dialogs.*;
00016 import rene.zirkel.expression.*;
00017 import rene.zirkel.graphics.*;
00018 
00019 class PointEditDialog extends ObjectEditDialog
00020 {      
00021        // jm.evers
00022        public String xaxis_variable;
00023        public String yaxis_variable;
00024        // end jm.evers
00025        TextFieldAction X,Y;
00026        MyTextField Away,Bound,Increment;
00027        Checkbox Fixed,Close,Restricted,Alternate,Inside;
00028        IconBar TypeIB;
00029        ZirkelCanvas ZC;
00030        
00031        public PointEditDialog (Frame f, PointObject o)
00032        {      super(f,Zirkel.name("edit.point.title"),o);
00033        }
00034        public PointEditDialog (ZirkelCanvas zc, PointObject o)
00035        {      this(zc.getFrame(),o);
00036               ZC=zc;
00037        }
00038        
00039        public void addFirst (Panel P)
00040        {
00041            // jm.evers
00042               xaxis_variable=ZirkelApplet.xaxis_variable;
00043               yaxis_variable=ZirkelApplet.yaxis_variable;
00044               PointObject p=(PointObject)O;
00045               X=new TextFieldAction(this,xaxis_variable,""+p.round(p.getX()),30);
00046               P.add(new MyLabel(""+xaxis_variable+"")); P.add(X);
00047               Y=new TextFieldAction(this,yaxis_variable,""+p.round(p.getY()),30);
00048               P.add(new MyLabel(""+yaxis_variable+"")); P.add(Y);
00049            // end jm.evers
00050 /*
00051               X=new TextFieldAction(this,"X",""+p.round(p.getX()),30);
00052               P.add(new MyLabel(Zirkel.name("edit.point.x"))); P.add(X);
00053               Y=new TextFieldAction(this,"Y",""+p.round(p.getY()),30);
00054               P.add(new MyLabel(Zirkel.name("edit.point.y"))); P.add(Y);
00055 */
00056               if (p.moveablePoint())
00057               {      Fixed=new Checkbox("");
00058                      Fixed.setState(p.fixed());
00059                      P.add(new MyLabel(Zirkel.name("edit.fixed")));
00060                      P.add(Fixed);
00061                      if (p.fixed())
00062                      {      X.setText(p.getEX());
00063                             Y.setText(p.getEY());
00064                      }
00065                      P.add(new MyLabel(Zirkel.name("edit.point.increment")));
00066                      P.add(Increment=new MyTextField(""+p.round(p.getIncrement())));
00067               }
00068               else
00069               {      X.setEditable(false);
00070                      Y.setEditable(false);
00071               }
00072 
00073               if ((p instanceof IntersectionObject &&
00074                      ((IntersectionObject)p).isSwitchable()))
00075               {      Away=new MyTextField("",5);
00076                      Away.setText(((IntersectionObject)p).away());
00077                      Close=new CheckboxAction(this,Zirkel.name("edit.point.close"));
00078                      Close.setState(!((IntersectionObject)p).stayAway());
00079                      P.add(new MyLabel(Zirkel.name("edit.point.intersection")));
00080                      Panel ap=new MyPanel();
00081                      ap.setLayout(new GridLayout(1,2));
00082                      ap.add(Away);
00083                      ap.add(Close);
00084                      P.add(ap);
00085               }
00086               
00087               if (p instanceof IntersectionObject)
00088               {      P.add(new MyLabel(Zirkel.name("edit.plumb.restricted")));
00089                      Restricted=new CheckboxAction(this,"","Restricted");
00090                      Restricted.setState(((IntersectionObject)p).isRestricted());
00091                      P.add(Restricted);
00092                      if (((IntersectionObject)p).canAlternate())
00093                      {      P.add(new MyLabel(Zirkel.name("edit.intersection.alternate")));
00094                             Alternate=new CheckboxAction(this,"","Alternate");
00095                             Alternate.setState(((IntersectionObject)p).isAlternate());
00096                             P.add(Alternate);
00097                      }
00098               }
00099 
00100               if (p.isPointOn())
00101               {      P.add(new MyLabel(Zirkel.name("edit.point.bound")));
00102                      P.add(Bound=new MyTextField(p.getBound().getName()));
00103                      Bound.setEditable(false);
00104                      if (p.getBound() instanceof InsideObject)
00105                      {      P.add(new MyLabel(Zirkel.name("edit.point.inside")));
00106                             P.add(Inside=new CheckboxAction(this,"","Inside"));
00107                             Inside.setState(p.isInside());
00108                      }
00109                      if (Fixed!=null) Fixed.setState(p.useAlpha());
00110               }
00111               
00112        }
00113        
00114        Button BoundButton;
00115        
00116        public void addButton (Panel P)
00117        {      PointObject p=(PointObject)O;
00118               if (p.moveablePoint())
00119               {      if (p.isPointOn())
00120                             BoundButton=new ButtonAction(this,
00121                                    Zirkel.name("bound.release"),"Release");
00122                      else
00123                             BoundButton=new ButtonAction(this,
00124                                    Zirkel.name("bound.bind"),"Bind");
00125                      P.add(BoundButton);
00126                      P.add(new MyLabel(" "));
00127               }
00128               else if (p instanceof IntersectionObject  &&
00129                             ((IntersectionObject)p).isSwitchable())
00130               {      P.add(new ButtonAction(this,Zirkel.name("edit.point.away"),
00131                             "SetAway"));
00132                      P.add(new ButtonAction(this,Zirkel.name("edit.point.close"),
00133                             "SetClose"));
00134                      if (!((IntersectionObject)p).away().equals(""))
00135                      P.add(new ButtonAction(this,Zirkel.name("edit.point.free"),
00136                             "SetFree"));
00137                      P.add(new MyLabel(" "));
00138               }
00139        }
00140        
00141        public void addSecond (Panel P)
00142        {      PointObject p=(PointObject)O;
00143        
00144               TypeIB=new IconBar(F);
00145               TypeIB.addToggleGroupLeft("type",6);
00146               TypeIB.toggle("type",p.getType());
00147               P.add(new MyLabel("")); P.add(TypeIB);
00148        }
00149 
00150        public void doAction (String o)
00151        {
00152               //jm.evers probably does nothing...
00153               if ((o.equals(xaxis_variable) || o.equals(yaxis_variable)) && Fixed!=null)
00154               {      Fixed.setState(true);
00155                      super.doAction("OK");
00156               }
00157               //end jm.evers
00158               if ((o.equals("Y") || o.equals("X")) && Fixed!=null)
00159               {      Fixed.setState(true);
00160                      super.doAction("OK");
00161               }
00162               else if (o.equals("Release"))
00163               {      ((PointObject)O).setBound("");
00164                      O.getConstruction().updateCircleDep();
00165                      if (Fixed!=null) Fixed.setState(false);
00166                      super.doAction("OK");
00167               }
00168               else if (o.equals("Bind"))
00169               {      ZC.bind((PointObject)O);
00170                      super.doAction("OK");
00171               }
00172               else if (o.equals("SetAway"))
00173               {      ZC.setAway((IntersectionObject)O,true);
00174                      super.doAction("OK");
00175               }
00176               else if (o.equals("SetClose"))
00177               {      ZC.setAway((IntersectionObject)O,false);
00178                      super.doAction("OK");
00179               }
00180               else if (o.equals("SetFree"))
00181               {      ((IntersectionObject)O).setAway("");
00182                      Away=null;
00183                      super.doAction("OK");
00184               }
00185               else if (o.equals("OK"))
00186               {      if (Fixed!=null && X.isChanged() || Y.isChanged())
00187                             Fixed.setState(true);
00188                      super.doAction("OK");
00189               }
00190               else super.doAction(o);
00191        }
00192 
00193        public void setAction ()
00194        {      PointObject p=(PointObject)O;
00195               
00196               if ((X.isChanged() || Y.isChanged()) && p.isPointOn())
00197               {      try
00198                      {      double x=new Expression(X.getText(),
00199                                    p.getConstruction(),p).getValue();
00200                             double y=new Expression(Y.getText(),
00201                                    p.getConstruction(),p).getValue();
00202                             p.move(x,y);
00203                             p.validate();
00204                      }
00205                      catch (Exception e) {}
00206               }
00207               
00208               if (Fixed!=null && Fixed.getState()==true)
00209               {      if (p.isPointOn()) p.setUseAlpha(true);
00210                      else p.setFixed(X.getText(),Y.getText());
00211               }
00212               else
00213               {      try
00214                      {      double x=new Expression(X.getText(),
00215                                    p.getConstruction(),p).getValue();
00216                             double y=new Expression(Y.getText(),
00217                                    p.getConstruction(),p).getValue();
00218                             if (p.moveable()) p.move(x,y);
00219                      }
00220                      catch (Exception e) {}
00221               }
00222               if (Fixed!=null && Fixed.getState()==false)
00223               {      if (p.isPointOn()) p.setUseAlpha(false);
00224                      else p.setFixed(false);
00225               }
00226               
00227               if (Away!=null)
00228               {      if (!((IntersectionObject)p).setAway(Away.getText(),!Close.getState()))
00229                      {      Warning w=new Warning(F,Zirkel.name("bound.error"),
00230                                    Zirkel.name("warning"));
00231                             w.center(F);
00232                             w.setVisible(true);
00233                      }
00234               }
00235               if (Restricted!=null)
00236               {      ((IntersectionObject)p).setRestricted(Restricted.getState());
00237               }
00238               if (Alternate!=null)
00239               {      ((IntersectionObject)p).setAlternate(Alternate.getState());
00240               }
00241               if (Increment!=null)
00242               {      try
00243                      {      p.setIncrement(new Expression(Increment.getText(),
00244                                    p.getConstruction(),p).getValue());
00245                      }
00246                      catch (Exception e) {}
00247               }
00248               p.setType(TypeIB.getToggleState("type"));
00249               if (Inside!=null)
00250               {      p.setInside(Inside.getState());
00251               }
00252        }
00253 
00254        public void focusGained (FocusEvent e)
00255        {      if (Fixed!=null && Fixed.getState()) X.requestFocus();
00256               else super.focusGained(e);
00257        }
00258 }
00259 
00260 public class PointObject extends ConstructionObject
00261        implements MoveableObject
00262 {      protected double X,Y;
00263        protected double Alpha; // parameter relative zu object
00264        protected boolean AlphaValid=false; // Alpha is valid
00265        protected boolean UseAlpha=false; // Use Alpha at all
00266        protected boolean Moveable,Fixed;
00267        private static Count N=new Count();
00268        protected int Type=0;
00269        public final static int SQUARE=0,DIAMOND=1,CIRCLE=2,DOT=3,CROSS=4,DCROSS=5;
00270        public static int MaxType=3;
00271        protected Expression EX,EY;
00272        private ConstructionObject Bound=null; // point is on a line etc.
00273        private boolean Later; // bound is later in construction
00274        private String LaterBind="";
00275        private boolean KeepInside; // keep point inside bound
00276        private boolean DontUpdate=false;
00277        private double Increment=0; // increment to keep on grid 
00278               
00279        protected ConstructionObject MovedBy;
00280               // The object that may have moved this point
00281        
00282        public PointObject (Construction c, double x, double y)
00283        {      super(c);
00284               X=x; Y=y;
00285               Moveable=true; Fixed=false;
00286               setColor(ColorIndex);
00287               updateText();
00288               Type=0;
00289        }
00290        public PointObject (Construction c, double x, double y,
00291               ConstructionObject bound)
00292        {      this(c,x,y);
00293               Bound=bound;
00294        }
00295        public PointObject (Construction c, String name)
00296        {      super(c,name);
00297               X=0; Y=0;
00298               Moveable=true; Fixed=false;
00299               setColor(ColorIndex);
00300               updateText();
00301               Type=0;
00302        }
00303        
00304        public String getTag ()
00305        {      if (Bound==null) return "Point"; 
00306               else return "PointOn";
00307        }
00308        public int getN () { return N.next(); }
00309        
00310        public void setDefaults ()
00311        {      super.setDefaults();
00312               Type=Cn.DefaultType;
00313        }
00314        
00315        private double Delta;
00316        
00317        public double changedBy ()
00318        {      return Delta;
00319        }
00320        
00321        public void validate ()
00322        {      if (DontUpdate) return;
00323               MovedBy=null;
00324               Delta=0.0;
00325               Valid=true;
00326               if (Bound!=null && !Bound.isInConstruction()) Bound=null;
00327               if (Bound!=null && !Bound.valid())
00328               {      Valid=false;
00329                      return;
00330               }
00331               if (Increment>1e-4)
00332               {      X=Math.floor(X/Increment+0.5)*Increment;
00333                      Y=Math.floor(Y/Increment+0.5)*Increment;
00334               }
00335               if (Bound!=null)
00336               {      double x=X,y=Y;
00337                      if (KeepInside && Bound instanceof InsideObject)
00338                      {      ((InsideObject)Bound).keepInside(this);
00339                      }
00340                      else if (!KeepInside && Bound instanceof PointonObject)
00341                      {      if (!AlphaValid || !UseAlpha) project(Bound);
00342                             else project(Bound,Alpha);
00343                      }
00344                      if (Later) Delta=Math.sqrt((x-X)*(x-X)+(y-Y)*(y-Y));
00345               }
00346               if (Fixed && EX!=null && EX.isValid())
00347               {      try
00348                      {      X=EX.getValue();
00349                      }
00350                      catch (Exception e)
00351                      {      Valid=false; return;
00352                      }
00353               }
00354               if (Fixed && EY!=null && EY.isValid())
00355               {      try
00356                      {      Y=EY.getValue();
00357                      }
00358                      catch (Exception e)
00359                      {      Valid=false; return;
00360                      }
00361               }
00362        }
00363        
00364        public void updateText ()
00365        {      if (Bound!=null)
00366                      setText(text1(Zirkel.name("text.boundedpoint"),Bound.getName()));
00367               else if (EX!=null && EY!=null)
00368                      setText(text2(Zirkel.name("text.point"),"\""+EX+"\"","\""+EY+"\""));
00369               else
00370                      setText(text2(Zirkel.name("text.point"),""+round(X),""+round(Y)));                  
00371        }
00372        
00373        static double x[]=new double[4],y[]=new double[4];
00374        
00375        public void paint (MyGraphics g, ZirkelCanvas zc)
00376        {      DisplaysText=false;
00377               if (!Valid || mustHide(zc)) return;
00378               double size=drawPoint(g,zc,this,X,Y,Type);
00379               String s=AngleObject.translateToUnicode(getDisplayText());
00380               if (!s.equals(""))
00381               {      g.setLabelColor(this);
00382                      DisplaysText=true;
00383                      setFont(g);
00384                      double d=Math.sqrt(XcOffset*XcOffset+YcOffset*YcOffset);
00385                      if (!KeepClose || d<1e-10)
00386                      {      TX1=zc.col(X+XcOffset)+2*size;
00387                             TY1=zc.row(Y+YcOffset)+2*size;
00388                             drawLabel(g,s);
00389                      }
00390                      else
00391                      {      drawPointLabel(g,s,zc,X,Y,YcOffset/d,-XcOffset/d,0,0);
00392                      }
00393               }
00394        }
00395        
00396        static public double drawPoint (MyGraphics g, ZirkelCanvas zc, 
00397                      ConstructionObject o, double X, double Y, int type)
00398        {      double size=zc.pointSize();
00399               double r=zc.col(X),c=zc.row(Y);
00400               if (size<1) size=1;
00401               if (o.visible(zc))
00402               {      if (o.isStrongSelected() && g instanceof MyGraphics13)
00403                      {      ((MyGraphics13)g).drawMarkerLine(r,c,r,c);
00404                      }
00405                      g.setColor(o);
00406                      switch (type)
00407                      {      case SQUARE :
00408                                    if (o.getColorType()==THICK)
00409                                    {      size-=1;
00410                                           g.fillRect(r-size,c-size,2*size,2*size,true,false,o);
00411                                    }
00412                                    else
00413                                           g.drawRect(r-size,c-size,2*size,2*size);
00414                                    break;
00415                             case DIAMOND : 
00416                                    size+=1;
00417                                    if (o.getColorType()==THICK)
00418                                    {      size+=1;
00419                                           x[0]=r-size; x[1]=r; x[2]=r+size; x[3]=r;
00420                                           y[0]=c; y[1]=c-size; y[2]=c; y[3]=c+size;
00421                                           g.fillPolygon(x,y,4,false,false,o);
00422                                    }
00423                                    else
00424                                    {      g.drawLine(r-size,c,r,c+size);
00425                                           g.drawLine(r-size,c,r,c-size);
00426                                           g.drawLine(r+size,c,r,c+size);
00427                                           g.drawLine(r+size,c,r,c-size);
00428                                    }
00429                                    break;
00430                             case CIRCLE :
00431                                    if (o.getColorType()==THICK)
00432                                           g.fillOval(r-size-1,c-size-1,2*size+2,2*size+2,true,false,o);
00433                                    else
00434                                           g.drawOval(r-size,c-size,2*size,2*size);
00435                                    break;
00436                             case DOT :
00437                                    if (o.getColorType()==THICK) g.fillRect(r,c,1,1,true,false,o);
00438                                    else g.drawLine(r,c,r,c);
00439                                    break;
00440                             case CROSS :
00441                                    if (o.getColorType()==THICK)
00442                                    {      g.drawThickLine(r-size,c,r+size,c);
00443                                           g.drawThickLine(r,c-size,r,c+size);
00444                                    }
00445                                    else
00446                                    {      g.drawLine(r-size,c,r+size,c);
00447                                           g.drawLine(r,c-size,r,c+size);
00448                                    }
00449                                    break;
00450                             case DCROSS :
00451                                    if (o.getColorType()==THICK)
00452                                    {      g.drawThickLine(r-size,c-size,r+size,c+size);
00453                                           g.drawThickLine(r+size,c-size,r-size,c+size);
00454                                    }
00455                                    else
00456                                    {      g.drawLine(r-size,c-size,r+size,c+size);
00457                                           g.drawLine(r+size,c-size,r-size,c+size);
00458                                    }
00459                                    break;
00460                      }
00461               }
00462               return size;
00463        }
00464        
00465        public String getDisplayValue ()
00466        {      return "("+roundDisplay(X)+
00467                      (Global.getParameter("options.germanpoints",false)?"|":",")
00468                      +roundDisplay(Y)+")";
00469        }
00470        
00471        public boolean nearto (int x, int y, ZirkelCanvas zc)
00472        {      if (!displays(zc)) return false;
00473               double c=zc.col(X),r=zc.row(Y);
00474               int size=(int)zc.selectionSize();
00475               Value=Math.abs(x-c)+Math.abs(y-r);
00476               return Value<=size*3/2;
00477        }
00478        
00479        public boolean nearto (PointObject p)
00480        {      if (!Valid) return false;
00481               double dx=p.X-X,dy=p.Y-Y;
00482               return Math.sqrt(dx*dx+dy*dy)<1e-9;
00483        }
00484        
00485        public double distanceTo (int x, int y, ZirkelCanvas zc)
00486        {      double dx=x-zc.col(X),dy=y-zc.row(Y);
00487               return Math.sqrt(dx*dx+dy*dy);
00488        }
00489        
00490        public double getX () { return X; }
00491        public double getY () { return Y; }
00492        
00493        public boolean moveable ()
00494        {      boolean fixed=Fixed;
00495               if (dependsOnItselfOnly()) fixed=false;
00496               return Moveable && !fixed && !Keep; 
00497        }
00498        
00504        public boolean dependsOnItselfOnly ()
00505        {      boolean res=false;
00506               Enumeration e=depending();
00507               while (e.hasMoreElements())
00508               {      if ((ConstructionObject)e.nextElement()==this)
00509                      {      res=true;
00510                             break;
00511                      }
00512               }
00513               e=depending();
00514               while (e.hasMoreElements())
00515               {      if ((ConstructionObject)e.nextElement()!=this)
00516                      {      res=false;
00517                             break;
00518                      }
00519               }
00520               return res;
00521        }
00522        
00523        public boolean dependsOnParametersOnly ()
00524        {      Enumeration e=depending();
00525               while (e.hasMoreElements())
00526               {      if (!((ConstructionObject)e.nextElement()).isParameter())
00527                             return false;
00528               }
00529               return true;
00530        }
00531        
00535        public boolean moveableBy (ConstructionObject o)
00536        {      if (Bound!=null) return false;
00537               return moveable() && (MovedBy==null || MovedBy==o); 
00538        }
00539        
00540        public boolean moveablePoint ()
00541        {      if (Bound!=null) return true;
00542               return Moveable && !Keep; 
00543        }
00544 
00545        public boolean setBound (String name)
00546        {      if (name.equals(""))
00547               {      Bound=null;
00548                      setFixed(false);
00549                      Later=false;
00550                      return true;  
00551               }
00552               try
00553               {      Bound=null;
00554                      ConstructionObject o=Cn.find(name);
00555                      if (o instanceof PointonObject)
00556                      {      Bound=o;
00557                             Moveable=true;
00558                             Fixed=false;
00559                             KeepInside=false;
00560                      }
00561                      else if (o instanceof InsideObject)
00562                      {      Bound=o;
00563                             Moveable=true;
00564                             Fixed=false;
00565                             KeepInside=true;
00566                      }
00567                      else { return false; }
00568               }
00569               catch (Exception e) { return false; }
00570               if (Cn.before(this,Bound))
00571               {      Cn.needsOrdering();
00572                      Cn.dovalidate();
00573               }
00574               updateText();
00575               return true;
00576        }      
00577        
00578        public void setBound (ConstructionObject bound)
00579        {      Bound=bound;
00580        }
00581        
00582        public ConstructionObject getBound () { return Bound; }
00583 
00584        public void setMoveable (boolean flag) { Moveable=flag; }
00585        public boolean fixed () { return Fixed; }
00586 
00587        public void setFixed (boolean flag)
00588        {      Fixed=flag; 
00589               if (!Fixed) EX=EY=null;
00590               updateText();
00591        }
00592        
00593        public void setFixed (String x, String y)
00594        {      Fixed=true;
00595               EX=new Expression(x,getConstruction(),this);
00596               EY=new Expression(y,getConstruction(),this);
00597               updateText();
00598        }
00599        
00600        public void move (double x, double y)
00601        {      X=x; Y=y;
00602               AlphaValid=false;
00603        }
00604        
00605        public void setXY (double x, double y)
00606        {      X=x; Y=y;
00607        }
00608        
00609        public void setA (double alpha)
00610        {      Alpha=alpha;
00611        }
00612        
00613        public void project (ConstructionObject o)
00614        {      if (!(o instanceof PointonObject)) return;
00615               ((PointonObject)o).project(this);
00616               if (UseAlpha) AlphaValid=true;
00617        }
00618        
00619        public void project (ConstructionObject o, double alpha)
00620        {      ((PointonObject)o).project(this,alpha);
00621        }
00622        
00623        public void edit (ZirkelCanvas zc)
00624        {      ObjectEditDialog d=new PointEditDialog(zc,this);
00625               d.setVisible(true);
00626               zc.repaint();
00627               if ((EX!=null && !EX.isValid()))
00628               {      Frame F=zc.getFrame();
00629                      Warning w=new Warning(F,EX.getErrorText(),
00630                             Zirkel.name("warning"),true);
00631                      w.center(F);
00632                      w.setVisible(true);
00633               }
00634               else if ((EY!=null && !EY.isValid()))
00635               {      Frame F=zc.getFrame();
00636                      Warning w=new Warning(F,EY.getErrorText(),
00637                             Zirkel.name("warning"),true);
00638                      w.center(F);
00639                      w.setVisible(true);
00640               }
00641               validate();
00642               if (d.wantsMore())
00643               {      new EditConditionals(zc.getFrame(),this);
00644                      validate();
00645               }
00646        }
00647 
00648        public void printArgs (XmlWriter xml)
00649        {      updateText();
00650               if (Bound!=null) 
00651               {      xml.printArg("on",Bound.getName());
00652                      if (KeepInside) xml.printArg("inside","true");
00653               }
00654               if (Fixed && EX!=null) 
00655               {      xml.printArg("x",EX.toString());
00656                      xml.printArg("actx",""+X);
00657               }
00658               else
00659               {      if (Bound!=null && AlphaValid && UseAlpha)
00660                             xml.printArg("alpha",""+Alpha);
00661                      xml.printArg("x",""+X);
00662               }
00663               if (Fixed && EY!=null)
00664               {      xml.printArg("y",EY.toString());
00665                      xml.printArg("acty",""+Y);
00666               }
00667               else
00668                      xml.printArg("y",""+Y);
00669               printType(xml);
00670               if (Fixed) xml.printArg("fixed","true");
00671               if (Increment>1e-4) xml.printArg("increment",""+getIncrement());
00672        }
00673        
00674        public void printType (XmlWriter xml)
00675        {      if (Type!=0)
00676               {      switch (Type)
00677                      {      case DIAMOND : xml.printArg("shape","diamond"); break;
00678                             case CIRCLE : xml.printArg("shape","circle"); break;
00679                             case DOT : xml.printArg("shape","dot"); break;
00680                             case CROSS : xml.printArg("shape","cross"); break;
00681                             case DCROSS : xml.printArg("shape","dcross"); break;
00682                      }
00683               }
00684 
00685        }
00686        
00687        public int getType () { return Type; }
00688        public void setType (int type) { Type=type; }
00689        
00690        public void movedBy (ConstructionObject o)
00691        {      MovedBy=o;
00692        }
00693 
00694        public boolean equals (ConstructionObject o)
00695        {      if (!(o instanceof PointObject) || !o.valid()) return false;
00696               PointObject p=(PointObject)o;
00697               return equals(X,p.X) && equals(Y,p.Y);
00698        }
00699        
00700        public String getEX ()
00701        {      if (EX!=null) return EX.toString();
00702               else return ""+round(X);
00703        }
00704 
00705 
00706        public String getEY ()
00707        {      if (EY!=null) return EY.toString();
00708               else return ""+round(Y);
00709        }
00710        
00711        public boolean isOn (ConstructionObject o)
00712        {      if (Bound!=null) return o==Bound;
00713               return o.contains(this);
00714        }
00715 
00716        public void translate ()
00717        {      if (Bound!=null) Bound=Bound.getTranslation();
00718               else if (Fixed)
00719               {      try
00720                      {      setFixed(EX.toString(),EY.toString());
00721                             EX.translate(); EY.translate();
00722                      }
00723                      catch (Exception e) {}
00724               }
00725        }
00726        
00727        public Enumeration depending ()
00728        {      super.depending();
00729               if (Bound!=null)
00730               {      DL.add(Bound);
00731               }
00732               if (Fixed)
00733               {      if (EX!=null) EX.addDep(this);
00734                      if (EY!=null) EY.addDep(this);
00735               }
00736               return DL.elements();
00737               
00738        }
00739        
00740        public void snap (ZirkelCanvas zc)
00741        {      double d=zc.getGridSize()/2;
00742               X=Math.round(X/d)*d;
00743               Y=Math.round(Y/d)*d;
00744               updateText();
00745        }
00746 
00747        public void updateCircleDep ()
00748        {      if (Bound!=null && Bound instanceof PrimitiveCircleObject)
00749               {      ((PrimitiveCircleObject)Bound).addDep(this);
00750               }
00751               if (Bound!=null && Bound instanceof PrimitiveLineObject)
00752               {      ((PrimitiveLineObject)Bound).addDep(this);
00753               }
00754        }
00755 
00756        public boolean isPointOn ()
00757        {      return Bound!=null;
00758        }
00759        
00760        public void setLaterBind (String s)
00761        {      LaterBind=s;
00762        }
00763        
00764        public void setInside (boolean flag)
00765        {      KeepInside=flag;
00766        }
00767        
00768        public boolean isInside ()
00769        {      return KeepInside;
00770        }
00771        
00772        public void laterBind (Construction c)
00773        {      if (LaterBind.equals("")) return;
00774               ConstructionObject o=c.find(LaterBind);
00775               if (o!=null && ((o instanceof PointonObject) || (o instanceof InsideObject)))
00776               {      Bound=o;
00777                      updateText();
00778                      validate();
00779               }
00780               LaterBind="";
00781        }
00782        
00783        public void setAlpha (double alpha)
00784        {      Alpha=alpha; AlphaValid=true;
00785        }
00786        
00787        public void setUseAlpha (boolean flag)
00788        {      UseAlpha=flag;
00789        }
00790        
00791        public boolean useAlpha ()
00792        {      return UseAlpha;
00793        }
00794        
00795        public double getAlpha ()
00796        {      return Alpha; 
00797        }
00798        
00799        public void round ()
00800        {      move(round(X,ZirkelCanvas.LengthsFactor),
00801                      round(Y,ZirkelCanvas.LengthsFactor));
00802        }
00803        
00807        public void setKeepClose (double x, double y)
00808        {      KeepClose=true;
00809               XcOffset=x-X; YcOffset=y-Y;
00810        }
00811        public boolean canKeepClose ()
00812        {      return true;
00813        }
00814 
00815        public boolean dontUpdate () { return DontUpdate; }
00816        public void dontUpdate (boolean flag) { DontUpdate=flag; }
00817 
00821        public void setTargetDefaults ()
00822        {      super.setTargetDefaults();
00823               Type=Cn.DefaultType;
00824        }
00825        
00826        public void startDrag(double x, double y) 
00827        {}
00828        
00829        public void dragTo (double x, double y) 
00830        {      move(x,y);
00831        }
00832        
00833        public void setIncrement (double inc)
00834        {      Increment=inc;
00835        }
00836        
00837        public double getIncrement ()
00838        {      return Increment;
00839        }
00840 }