⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arc2d.java

📁 this gcc-g++-3.3.1.tar.gz is a source file of gcc, you can learn more about gcc through this codes f
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    throw new Error("not implemented");  }  /**   * Construct a bounding box in a precision appropriate for the subclass.   *   * @param x the x coordinate   * @param y the y coordinate   * @param w the width   * @param h the height   * @return the rectangle for use in getBounds2D   */  protected abstract Rectangle2D makeBounds(double x, double y,                                            double w, double h);  /**   * Tests if the given angle, in degrees, is included in the arc.   *   * XXX Does this normalize all angles to -180 - 180 first?   *   * @param a the angle to test   * @return true if it is contained   */  public boolean containsAngle(double a)  {    // XXX Implement.    throw new Error("not implemented");  }  /**   * Determines if the arc contains the given point. If the bounding box   * is empty, then this will return false.   *   * @param x the x coordinate to test   * @param y the y coordinate to test   * @return true if the point is inside the arc   */  public boolean contains(double x, double y)  {    double w = getWidth();    double h = getHeight();    if (w <= 0 || h <= 0)      return false;    // XXX Finish implementing.    throw new Error("not implemented");  }  /**   * Tests if a given rectangle intersects the area of the arc.   *   * @param x the x coordinate of the rectangle   * @param y the y coordinate of the rectangle   * @param w the width of the rectangle   * @param h the height of the rectangle   * @return true if the two shapes share common points   */  public boolean intersects(double x, double y, double w, double h)  {    double mw = getWidth();    double mh = getHeight();    if (mw <= 0 || mh <= 0 || w <= 0 || h <= 0)      return false;    // XXX Finish implementing.    throw new Error("not implemented");  }  /**   * Tests if a given rectangle is contained in the area of the arc.   *   * @param x the x coordinate of the rectangle   * @param y the y coordinate of the rectangle   * @param w the width of the rectangle   * @param h the height of the rectangle   * @return true if the arc contains the rectangle   */  public boolean contains(double x, double y, double w, double h)  {    double mw = getWidth();    double mh = getHeight();    if (mw <= 0 || mh <= 0 || w <= 0 || h <= 0)      return false;    // XXX Finish implementing.    throw new Error("not implemented");  }  /**   * Tests if a given rectangle is contained in the area of the arc.   *   * @param r the rectangle   * @return true if the arc contains the rectangle   */  public boolean contains(Rectangle2D r)  {    return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());  }  /**   * Returns an iterator over this arc, with an optional transformation.   * This iterator is threadsafe, so future modifications to the arc do not   * affect the iteration.   *   * @param at the transformation, or null   * @return a path iterator   */  public PathIterator getPathIterator(AffineTransform at)  {    return new ArcIterator(this, at);  }  /**   * This class is used to iterate over an arc. Since ellipses are a subclass   * of arcs, this is used by Ellipse2D as well.   *   * @author Eric Blake <ebb9@email.byu.edu>   */  static final class ArcIterator implements PathIterator  {    /** The current iteration. */    private int current;    /** The last iteration. */    private final int limit;    /** The optional transformation. */    private final AffineTransform xform;    /** The x coordinate of the bounding box. */    private final double x;    /** The y coordinate of the bounding box. */    private final double y;    /** The width of the bounding box. */    private final double w;    /** The height of the bounding box. */    private final double h;    /** The start angle, in radians (not degrees). */    private final double start;    /** The extent angle, in radians (not degrees). */    private final double extent;    /** The arc closure type. */    private final int type;    /**     * Construct a new iterator over an arc.     *     * @param a the arc     * @param xform the transform     */    ArcIterator(Arc2D a, AffineTransform xform)    {      this.xform = xform;      x = a.getX();      y = a.getY();      w = a.getWidth();      h = a.getHeight();      start = a.getAngleStart() * (Math.PI / 180);      extent = a.getAngleExtent() * (Math.PI / 180);      type = a.type;      double e = extent < 0 ? -extent : extent;      if (w < 0 || h < 0)        limit = -1;      else if (e == 0)        limit = type;      else if (e <= 90)        limit = type + 1;      else if (e <= 180)        limit = type + 2;      else if (e <= 270)        limit = type + 3;      else        limit = type + 4;    }    /**     * Construct a new iterator over an ellipse.     *     * @param e the ellipse     * @param xform the transform     */    ArcIterator(Ellipse2D e, AffineTransform xform)    {      this.xform = xform;      x = e.getX();      y = e.getY();      w = e.getWidth();      h = e.getHeight();      start = 0;      extent = -2 * Math.PI;      type = CHORD;      limit = (w < 0 || h < 0) ? -1 : 5;    }    /**     * Return the winding rule.     *     * @return {@link PathIterator#WIND_NON_ZERO}     */    public int getWindingRule()    {      return WIND_NON_ZERO;    }    /**     * Test if the iteration is complete.     *     * @return true if more segments exist     */    public boolean isDone()    {      return current > limit;    }    /**     * Advance the iterator.     */    public void next()    {      current++;    }    /**     * Put the current segment into the array, and return the segment type.     *     * @param coords an array of 6 elements     * @return the segment type     * @throws NullPointerException if coords is null     * @throws ArrayIndexOutOfBoundsException if coords is too small     */    public int currentSegment(float[] coords)    {      if (current > limit)        throw new NoSuchElementException("arc iterator out of bounds");      if (current == 0)        {          coords[0] = (float) (Math.cos(start) * w + x) / 2;          coords[1] = (float) (Math.sin(start) * h + y) / 2;          if (xform != null)            xform.transform(coords, 0, coords, 0, 1);          return SEG_MOVETO;        }      if (type != OPEN && current == limit)        return SEG_CLOSE;      if (type == PIE && current == limit - 1)        {          coords[0] = (float) (x + w / 2);          coords[1] = (float) (y + h / 2);          if (xform != null)            xform.transform(coords, 0, coords, 0, 1);          return SEG_LINETO;        }      // XXX Fill coords with 2 control points and next quarter point      coords[0] = (float) 0;      coords[1] = (float) 0;      coords[2] = (float) 0;      coords[3] = (float) 0;      coords[4] = (float) 0;      coords[5] = (float) 0;      if (xform != null)        xform.transform(coords, 0, coords, 0, 3);      return SEG_CUBICTO;    }    /**     * Put the current segment into the array, and return the segment type.     *     * @param coords an array of 6 elements     * @return the segment type     * @throws NullPointerException if coords is null     * @throws ArrayIndexOutOfBoundsException if coords is too small     */    public int currentSegment(double[] coords)    {      if (current > limit)        throw new NoSuchElementException("arc iterator out of bounds");      if (current == 0)        {          coords[0] = (Math.cos(start) * w + x) / 2;          coords[1] = (Math.sin(start) * h + y) / 2;          if (xform != null)            xform.transform(coords, 0, coords, 0, 1);          return SEG_MOVETO;        }      if (type != OPEN && current == limit)        return SEG_CLOSE;      if (type == PIE && current == limit - 1)        {          coords[0] = (float) (x + w / 2);          coords[1] = (float) (y + h / 2);          if (xform != null)            xform.transform(coords, 0, coords, 0, 1);          return SEG_LINETO;        }      // XXX Fill coords with 2 control points and next quarter point      coords[0] = 0;      coords[1] = 0;      coords[2] = 0;      coords[3] = 0;      coords[4] = 0;      coords[5] = 0;      if (xform != null)        xform.transform(coords, 0, coords, 0, 3);      return SEG_CUBICTO;    }  } // class ArcIterator  /**   * This class implements an arc in double precision.   *   * @author Eric Blake <ebb9@email.byu.edu   * @since 1.2   */  public static class Double extends Arc2D  {    /** The x coordinate of the box bounding the ellipse of this arc. */    public double x;    /** The y coordinate of the box bounding the ellipse of this arc. */    public double y;    /** The width of the box bounding the ellipse of this arc. */    public double width;    /** The height of the box bounding the ellipse of this arc. */    public double height;    /** The start angle of this arc, in degrees. */    public double start;    /** The extent angle of this arc, in degrees. */    public double extent;    /**     * Create a new, open arc at (0,0) with 0 extent.     */    public Double()    {      super(OPEN);    }    /**     * Create a new arc of the given type at (0,0) with 0 extent.     *     * @param type the arc type: {@link #OPEN}, {@link #CHORD}, or {@link #PIE}     * @throws IllegalArgumentException if type is invalid     */    public Double(int type)    {      super(type);    }    /**     * Create a new arc with the given dimensions.     *     * @param x the x coordinate     * @param y the y coordinate     * @param w the width     * @param h the height     * @param start the start angle, in degrees     * @param extent the extent, in degrees     * @param type the arc type: {@link #OPEN}, {@link #CHORD}, or {@link #PIE}     * @throws IllegalArgumentException if type is invalid     */    public Double(double x, double y, double w, double h,                  double start, double extent, int type)    {      super(type);      this.x = x;      this.y = y;      width = w;      height = h;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -