Back to index

wims  3.65+svn20090927
PolygonDrawer.java
Go to the documentation of this file.
00001 /*
00002  * Created on 02.06.2004
00003  *
00004  */
00005 package rene.zirkel.graphics;
00006 
00007 import rene.zirkel.objects.ConstructionObject;
00008 
00013 public class PolygonDrawer
00014 {      MyGraphics G;
00015        ConstructionObject O;
00016        double C,R;
00017        double C1,R1;
00018        boolean HaveToFinish;
00019        public static int step=9;
00020        public boolean Marker=false;
00021        public boolean Started;
00022        boolean Solid;
00023        
00024        public PolygonDrawer (MyGraphics g, ConstructionObject o)
00025        {      G=g; O=o;
00026               Started=false;
00027        }
00028        
00029        public void startPolygon (double c, double r)
00030        {      C=c; R=r;
00031               HaveToFinish=false;
00032               Started=true;
00033        }
00034        
00035        public void drawTo (double c, double r, boolean dodraw)
00036        {      if (!Started)
00037               {      startPolygon(c,r);
00038                      return;
00039               }
00040               if (dodraw || (c-C)*(c-C)+(r-R)*(r-R)>step)
00041               {      if (Marker) ((MyGraphics13)G).drawMarkerLine(C,R,c,r);
00042                      else G.drawLine(C,R,c,r,O);
00043                      C=c; R=r;
00044                      HaveToFinish=false;
00045               }
00046               else
00047               {      C1=c; R1=r;
00048                      HaveToFinish=true;
00049               }
00050        }
00051        
00052        public void drawTo (double c, double r)
00053        {      drawTo(c,r,false);
00054        }
00055        
00056        public void finishPolygon ()
00057        {      if (HaveToFinish)
00058               {      if (Marker) ((MyGraphics13)G).drawMarkerLine(C,R,C1,R1);
00059                      else G.drawLine(C,R,C1,R1,O);
00060                      HaveToFinish=false;
00061               }      
00062               Started=false;
00063        }
00064 
00065        public boolean hasStarted ()
00066        {      return Started;
00067        }
00068        
00069        public double c()
00070        {      return C;
00071        }
00072        
00073        public double r()
00074        {      return R;
00075        }
00076 
00077        public void useAsMarker ()
00078        {      Marker=true;
00079               step=18;
00080        }
00081 }