3 Replies Latest reply: Dec 27, 2007 10:32 AM by 807601 RSS

    Re: cannot find symbol constructor Arc2D

    800584
      hi

      The subject might suggest this is should be posted in java2d forum but I believe this is related to basic programmming knowledge. So please take a look at it.

      I am trying to create a subclass to the Arc2D abstract class. Although it works fine when I change the superclass to Arc2D.Double. Could some body point the mistakes.

      I greatly appreciate any help.

      here is the error.
      symbol  : constructor Arc2D()
      location: class java.awt.geom.Arc2D
          public Arc(Graphics2D g2, int x0, int y0, int mdptx, int mdpty, int x1, int y1,int clickCount){
      1 error
      BUILD FAILED (total time: 0 seconds)
      here is the code in the class.


      package Drawing2d;
      
      import java.awt.BasicStroke;
      import java.awt.Color;
      import java.awt.Graphics2D;
      import java.awt.Shape;
      import java.awt.geom.Arc2D;
      import java.awt.geom.Point2D;
      import java.awt.geom.Rectangle2D;
      
      public class Arc extends Arc2D implements Shape{
      
          Circle aeli;
          SketchEnvironment SE;    
          int[] coord = new int[4];
          double width;
          double startAngle,endAngle, extent;
          float[] dashPattern = { 5, 2, 2, 2 };
          double x0,y0;
          Arc2D.Double ar;
          Point2D.Double pts[] = new Point2D.Double[3];
              
          public Arc(Graphics2D g2, int x0, int y0, int mdptx, int mdpty, int x1, int y1,int clickCount){
              
              ar = new Arc2D.Double();
              if(clickCount == 1){
              g2.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10,
                                        dashPattern, 0));       
              //aeli.mainColor = Color.GREEN;                    
              width =  java.lang.Math.sqrt(java.lang.Math.pow((x1- x0),2) 
                      + java.lang.Math.pow((y1 - y0) ,2));
              g2.setColor(Color.GREEN);
              g2.drawOval((int)(x0 - width), (int)(y0 - width),(int) (2*width), (int)(2*width));        
              }
              else if(clickCount == 2 || clickCount == 3){            
              
                  startAngle = Math.toDegrees(Math.atan2((mdpty - y0),(mdptx - x0)));
                  endAngle = Math.toDegrees(Math.atan2((y1 - y0),(x1 - x0)));
                  double extent = getExtent(startAngle, endAngle);   
         
                  width = java.lang.Math.sqrt(java.lang.Math.pow((mdptx- x0),2) 
                      + java.lang.Math.pow((mdpty - y0) ,2));
                  
                  g2.setColor(Color.WHITE);
                  ar.setArc(x0-width,y0-width,2*width,2*width,-startAngle,
                          extent,java.awt.geom.Arc2D.OPEN);
      //            ar = new Arc2D.Double(x0-width,y0-width,2*width,2*width,-startAngle,
      //                    extent,java.awt.geom.Arc2D.OPEN);
         
                  g2.draw(ar);
              }
          }
      
          /**
           * One area of difficulty is that java measures angles
           * positive clockwise from zero at 3 o'clock and arcs
           * measure angles positive anti-clockwise from the
           * beginning of the arc segment.
           * Contributed by CRWood from sun's java2d forum**/
          
          private double getExtent(double start, double end) {
              double extenti = (360-end) - (360-start);
              if(extenti < 0)
                  extenti += 360;
              return extenti;
          }
      
          public double getAngleStart() {
              return startAngle;
          }
      
          public double getAngleExtent() {
              return endAngle;
          }
      
          public void setArc(double x, double y, double w, double h, double angSt, double angExt, int closure) {
              this.setArc(x, y, w, h, angSt, angExt, closure);
          }
      
          public void setAngleStart(double angSt) {
              startAngle = angSt;
          }
      
          public void setAngleExtent(double angExt) {
              this.extent = angExt;
          }
          
      
          @Override
          public double getX() {
              return x0 - width;
          }
      
          public double getY() {
              return y0 - width;
          }
      
          public double getWidth() {
              return width;
          }
      
          public double getHeight() {
              return width;
          }
      
          public boolean isEmpty() {
              return this.isEmpty();
          }
      
          protected Rectangle2D makeBounds(double x, double y, double w, double h) {
              this.makeBounds(x, y, w, h);
          }
          
      }