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

📄 roundrectangle2d.java

📁 JAVA基本类源代码,大家可以学习学习!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * @(#)RoundRectangle2D.java	1.17 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package java.awt.geom;/** * The <code>RoundRectangle2D</code> class defines a rectangle with * rounded corners defined by a location (x,&nbsp;y), a * dimension (w&nbsp;x&nbsp;h), and the width and height of an arc  * with which to round the corners. * <p> * This class is the abstract superclass for all objects that * store a 2D rounded rectangle. * The actual storage representation of the coordinates is left to * the subclass. * * @version 1.17, 01/23/03 * @author	Jim Graham */public abstract class RoundRectangle2D extends RectangularShape {    /**     * The <code>Float</code> class defines a rectangle with rounded     * corners all specified in <code>float</code> coordinates.     */    public static class Float extends RoundRectangle2D {	/**	 * The X coordinate of this <code>RoundRectangle2D</code>.	 */	public float x;	/**         * The Y coordinate of this <code>RoundRectangle2D</code>.	 */	public float y;	/**         * The width of this <code>RoundRectangle2D</code>.	 */	public float width;	/**         * The height of this <code>RoundRectangle2D</code>.	 */	public float height;	/**	 * The width of the arc that rounds off the corners.	 */	public float arcwidth;	/**	 * The height of the arc that rounds off the corners.	 */	public float archeight;	/**	 * Constructs a new <code>RoundRectangle2D</code>, initialized to         * location (0.0,&nbsp;0), size (0.0,&nbsp;0.0), and corner arcs         * of radius 0.0.	 */	public Float() {	}	/**	 * Constructs and initializes a <code>RoundRectangle2D</code>          * from the specified coordinates.	 * @param x,&nbsp;y the coordinates to which to set the newly         * constructed <code>RoundRectangle2D</code>	 * @param w the width to which to set the newly         * constructed <code>RoundRectangle2D</code>	 * @param h the height to which to set the newly         * constructed <code>RoundRectangle2D</code>         * @param arcw the width of the arc to use to round off the         * corners of the newly constructed <code>RoundRectangle2D</code>         * @param arch the height of the arc to use to round off the         * corners of the newly constructed <code>RoundRectangle2D</code>	 */	public Float(float x, float y, float w, float h,				   float arcw, float arch) {	    setRoundRect(x, y, w, h, arcw, arch);	}	/**	 * Returns the X coordinate of this <code>RoundRectangle2D</code>         * in <code>double</code> precision.         * @return the X coordinate of this <code>RoundRectangle2D</code>.	 */	public double getX() {	    return (double) x;	}	/**	 * Returns the Y coordinate of this <code>RoundRectangle2D</code>         * in <code>double</code> precision.         * @return the Y coordinate of this <code>RoundRectangle2D</code>.         */		public double getY() {	    return (double) y;	}	/**	 * Returns the width of this <code>RoundRectangle2D</code>         * in <code>double</code> precision.         * @return the width of this <code>RoundRectangle2D</code>.         */		public double getWidth() {	    return (double) width;	}	/**         * Returns the height of this <code>RoundRectangle2D</code>          * in <code>double</code> precision.         * @return the height of this <code>RoundRectangle2D</code>.          */	public double getHeight() {	    return (double) height;	}	/**	 * Returns the width of the arc that rounds off the corners.         * @return the width of the arc that rounds off the corners         * of this <code>RoundRectangle2D</code>.	 */	public double getArcWidth() {	    return (double) arcwidth;	}	/**         * Returns the height of the arc that rounds off the corners.         * @return the height of the arc that rounds off the corners         * of this <code>RoundRectangle2D</code>.          */	public double getArcHeight() {	    return (double) archeight;	}	/**	 * Determines whether or not this <code>RoundRectangle2D</code>         * is empty.         * @return <code>true</code> if this <code>RoundRectangle2D</code>         * is empty; <code>false</code> othwerwise.	 */	public boolean isEmpty() {	    return (width <= 0.0f) || (height <= 0.0f);	}	/**	 * Sets the location, size, and arc radii of this          * <code>RoundRectangle2D</code> to the	 * specified <code>float</code> values.         * @param x,&nbsp;y the coordinates to which to set the         * location of this <code>RoundRectangle2D</code>         * @param w the width to which to set this         * <code>RoundRectangle2D</code>         * @param h the height to which to set this         * <code>RoundRectangle2D</code>         * @param arcw the width to which to set the arc of this         * <code>RoundRectangle2D</code>         * @param arch the height to which to set the arc of this         * <code>RoundRectangle2D</code>	 */	public void setRoundRect(float x, float y, float w, float h,				 float arcw, float arch) {	    this.x = x;	    this.y = y;	    this.width = w;	    this.height = h;	    this.arcwidth = arcw;	    this.archeight = arch;	}	/**	 * Sets the location, size, and arc radii of this          * <code>RoundRectangle2D</code> to the	 * specified <code>double</code> values.         * @param x,&nbsp;y the coordinates to which to set the         * location of this <code>RoundRectangle2D</code>         * @param w the width to which to set this         * <code>RoundRectangle2D</code>         * @param h the height to which to set this         * <code>RoundRectangle2D</code>         * @param arcw the width to which to set the arc of this         * <code>RoundRectangle2D</code>         * @param arch the height to which to set the arc of this         * <code>RoundRectangle2D</code>	         */	public void setRoundRect(double x, double y, double w, double h,				 double arcw, double arch) {	    this.x = (float) x;	    this.y = (float) y;	    this.width = (float) w;	    this.height = (float) h;	    this.arcwidth = (float) arcw;	    this.archeight = (float) arch;	}	/**	 * Sets this <code>RoundRectangle2D</code> to be the same as the         * specified <code>RoundRectangle2D</code>.         * @param rr the specified <code>RoundRectangle2D</code>	 */	public void setRoundRect(RoundRectangle2D rr) {	    this.x = (float) rr.getX();	    this.y = (float) rr.getY();	    this.width = (float) rr.getWidth();	    this.height = (float) rr.getHeight();	    this.arcwidth = (float) rr.getArcWidth();	    this.archeight = (float) rr.getArcHeight();	}	/**	 * Returns the high precision bounding box of this         * <code>RoundRectangle2D</code>.         * @return a {@link Rectangle2D} that is the bounding         * box of this <code>RoundRectangle2D</code>.	 */	public Rectangle2D getBounds2D() {	    return new Rectangle2D.Float(x, y, width, height);	}    }    /**     * The <code>Double</code> class defines a rectangle with rounded     * corners all specified in <code>double</code> coordinates.     */    public static class Double extends RoundRectangle2D {	/**         * The X coordinate of this <code>RoundRectangle2D</code>.          */	public double x;	/**         * The Y coordinate of this <code>RoundRectangle2D</code>.          */	public double y;	/**         * The width of this <code>RoundRectangle2D</code>.	 */	public double width;	/**         * The height of this <code>RoundRectangle2D</code>.	 */	public double height;	/**         * The width of the arc that rounds off the corners.	 */	public double arcwidth;	/**         * The height of the arc that rounds off the corners.	 */	public double archeight;	/**         * Constructs a new <code>RoundRectangle2D</code>, initialized to         * location (0.0,&nbsp;0), size (0.0,&nbsp;0.0), and corner arcs         * of radius 0.0.         */	public Double() {	}	/**         * Constructs and initializes a <code>RoundRectangle2D</code>         * from the specified coordinates.         * @param x,&nbsp;y the coordinates to which to set the newly         * constructed <code>RoundRectangle2D</code>         * @param w the width to which to set the newly         * constructed <code>RoundRectangle2D</code>         * @param h the height to which to set the newly         * constructed <code>RoundRectangle2D</code>         * @param arcw the width of the arc to use to round off the         * corners of the newly constructed <code>RoundRectangle2D</code>         * @param arch the height of the arc to use to round off the          * corners of the newly constructed <code>RoundRectangle2D</code>         */	public Double(double x, double y, double w, double h,		      double arcw, double arch) {	    setRoundRect(x, y, w, h, arcw, arch);	}	/**         * Returns the X coordinate of this <code>RoundRectangle2D</code>         * in <code>double</code> precision.         * @return the X coordinate of this <code>RoundRectangle2D</code>.         */	public double getX() {	    return x;	}	/**         * Returns the Y coordinate of this <code>RoundRectangle2D</code>         * in <code>double</code> precision.         * @return the Y coordinate of this <code>RoundRectangle2D</code>.         */	public double getY() {	    return y;	}	/**         * Returns the width of this <code>RoundRectangle2D</code>         * in <code>double</code> precision.

⌨️ 快捷键说明

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