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

📄 quadcurve2d.java

📁 JAVA基本类源代码,大家可以学习学习!
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * @(#)QuadCurve2D.java	1.27 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package java.awt.geom;import java.awt.Shape;import java.awt.Rectangle;/** * The <code>QuadCurve2D</code> class defines a quadratic parametric curve * segment in (x,&nbsp;y) coordinate space. * <p> * This class is only the abstract superclass for all objects that * store a 2D quadratic curve segment. * The actual storage representation of the coordinates is left to * the subclass. * * @version 	1.27, 01/23/03 * @author	Jim Graham */public abstract class QuadCurve2D implements Shape, Cloneable {    /**     * A quadratic parametric curve segment specified with      * <code>float</code> coordinates.     */    public static class Float extends QuadCurve2D {	/**	 * The x coordinate of the start point of the quadratic curve         * segment.	 */	public float x1;	/**	 * The y coordinate of the start point of the quadratic curve         * segment.	 */	public float y1;	/**	 * The x coordinate of the control point of the quadratic curve         * segment.	 */	public float ctrlx;	/**	 * The y coordinate of the control point of the quadratic curve         * segment.	 */	public float ctrly;	/**	 * The x coordinate of the end point of the quadratic curve         * segment.	 */	public float x2;	/**	 * The y coordinate of the end point of the quadratic curve         * segment.	 */	public float y2;	/**	 * Constructs and initializes a <code>QuadCurve2D</code> with         * coordinates (0, 0, 0, 0, 0, 0).	 */	public Float() {	}	/**	 * Constructs and initializes a <code>QuadCurve2D</code> from the         * specified coordinates.         * @param x1,&nbsp;y1 the starting point coordinates         * @param ctrlx,&nbsp;ctrly the coordinates of the control point         * @param x2,&nbsp;y2 the ending point coordinates	 */	public Float(float x1, float y1,		     float ctrlx, float ctrly,		     float x2, float y2) {	    setCurve(x1, y1, ctrlx, ctrly, x2, y2);	}	/**	 * Returns the x coordinate of the start point in          * <code>double</code> precision.         * @return the x coordinate of the starting point.	 */	public double getX1() {	    return (double) x1;	}	/**	 * Returns the y coordinate of the start point in          * <code>double</code> precision.         * @return the y coordinate of the starting point.	 */	public double getY1() {	    return (double) y1;	}	/**	 * Returns the start point.         * @return a {@link Point2D} object that is the starting point         *		of this <code>QuadCurve2D</code>.	 */	public Point2D getP1() {	    return new Point2D.Float(x1, y1);	}	/**	 * Returns the x coordinate of the control point in          * <code>double</code> precision.         * @return the x coordinate of the control point.	 */	public double getCtrlX() {	    return (double) ctrlx;	}	/**	 * Returns the y coordinate of the control point in          * <code>double</code> precision.         * @return the y coordiante of the control point.	 */	public double getCtrlY() {	    return (double) ctrly;	}	/**	 * Returns the control point.         * @return a <code>Point2D</code> that is the control point of         *	this <code>QuadCurve2D</code>.	 */	public Point2D getCtrlPt() {	    return new Point2D.Float(ctrlx, ctrly);	}	/**	 * Returns the x coordinate of the end point in          * <code>double</code> precision.         * @return the x coordinate of the end point.	 */	public double getX2() {	    return (double) x2;	}	/**	 * Returns the y coordinate of the end point in          * <code>double</code> precision.         * @return the y coordiante of the end point.	 */	public double getY2() {	    return (double) y2;	}	/**	 * Returns the end point.         * @return a <code>Point2D</code> that is the end point of this         * 		<code>QuadCurve2D</code>.	 */	public Point2D getP2() {	    return new Point2D.Float(x2, y2);	}	/**	 * Sets the location of the endpoints and controlpoint of this          * <code>QuadCurve2D</code> to the specified <code>double</code>         * coordinates.         * @param x1,&nbsp;y1 the coordinates of the starting point         * @param ctrlx,&nbsp;ctrly the coordinates of the control point         * @param x2,&nbsp;y2 the coordinates of the ending point	 */	public void setCurve(double x1, double y1,			     double ctrlx, double ctrly,			     double x2, double y2) {	    this.x1    = (float) x1;	    this.y1    = (float) y1;	    this.ctrlx = (float) ctrlx;	    this.ctrly = (float) ctrly;	    this.x2    = (float) x2;	    this.y2    = (float) y2;	}	/**	 * Sets the location of the endpoints and controlpoint of this curve	 * to the specified <code>float</code> coordinates.         * @param x1,&nbsp;y1 the coordinates of the starting point         * @param ctrlx,&nbsp;ctrly the coordinates of the control point         * @param x2,&nbsp;y2 the coordinates of the ending point	 */	public void setCurve(float x1, float y1,			     float ctrlx, float ctrly,			     float x2, float y2) {	    this.x1    = x1;	    this.y1    = y1;	    this.ctrlx = ctrlx;	    this.ctrly = ctrly;	    this.x2    = x2;	    this.y2    = y2;	}	/**	 * Returns the bounding box of this <code>QuadCurve2D</code>.         * @return a {@link Rectangle2D} that is the bounding box         *		of the shape of this <code>QuadCurve2D</code>.	 */	public Rectangle2D getBounds2D() {	    float left   = Math.min(Math.min(x1, x2), ctrlx);	    float top    = Math.min(Math.min(y1, y2), ctrly);	    float right  = Math.max(Math.max(x1, x2), ctrlx);	    float bottom = Math.max(Math.max(y1, y2), ctrly);	    return new Rectangle2D.Float(left, top,					 right - left, bottom - top);	}    }    /**     * A quadratic parametric curve segment specified with      * <code>double</code> coordinates.     */    public static class Double extends QuadCurve2D {	/**	 * The x coordinate of the start point of the quadratic curve         * segment.	 */	public double x1;	/**	 * The x coordinate of the start point of the quadratic curve         * segment.	 */	public double y1;	/**	 * The x coordinate of the control point of the quadratic curve         * segment.	 */	public double ctrlx;	/**	 * The y coordinate of the control point of the quadratic curve         * segment.	 */	public double ctrly;	/**	 * The x coordinate of the end point of the quadratic curve         * segment.	 */	public double x2;	/**	 * The y coordinate of the end point of the quadratic curve         * segment.	 */	public double y2;	/**	 * Constructs and initializes a <code>QuadCurve2D</code> with         * coordinates (0, 0, 0, 0, 0, 0).	 */	public Double() {	}	/**	 * Constructs and initializes a <code>QuadCurve2D</code> from the         * specified coordinates.         * @param x1,&nbsp;y1 the coordinates of the starting point         * @param ctrlx,&nbsp;ctrly the coordinates of the control point         * @param x2,&nbsp;y2 the coordinates of the ending point	 */	public Double(double x1, double y1,		      double ctrlx, double ctrly,		      double x2, double y2) {	    setCurve(x1, y1, ctrlx, ctrly, x2, y2);	}	/**	 * Returns the x coordinate of the start point in          * <code>double</code> precision.         * @return the x coordinate of the starting point.	 */	public double getX1() {	    return x1;	}	/**	 * Returns the y coordinate of the start point in          * <code>double</code> precision.         * @return the y coordiante of the starting point.	 */	public double getY1() {	    return y1;	}	/**	 * Returns the start point.         * @return a <code>Point2D</code> that is the starting point         *		of this <code>QuadCurve2D</code>.	 */	public Point2D getP1() {	    return new Point2D.Double(x1, y1);	}	/**	 * Returns the x coordinate of the control point in          * <code>double</code> precision.         * @return the x coordinate of the control point.	 */	public double getCtrlX() {	    return ctrlx;	}	/**	 * Returns the y coordinate of the control point in          * <code>double</code> precision.         * @return the y coordiante of the control point.	 */	public double getCtrlY() {	    return ctrly;	}	/**	 * Returns the control point.         * @return a <code>Point2D</code> object that is the control         * point of this <code>QuadCurve2D</code>. 	 */	public Point2D getCtrlPt() {	    return new Point2D.Double(ctrlx, ctrly);	}	/**	 * Returns the x coordinate of the end point in          * <code>double</code> precision.         * @return the x coordiante of the end point.	 */	public double getX2() {	    return x2;	}	/**	 * Returns the y coordinate of the end point in          * <code>double</code> precision.         * @return the y coordiante of the end point.	 */	public double getY2() {	    return y2;	}	/**	 * Returns the end point.         * @return a <code>Point2D</code> that is the end point         *	of this <code>QuadCurve2D</code>.	 */	public Point2D getP2() {	    return new Point2D.Double(x2, y2);	}	/**	 * Sets the location of the endpoints and controlpoint of this curve	 * to the specified <code>double</code> coordinates.         * @param x1,&nbsp;y1 the coordinates of the starting point         * @param ctrlx,&nbsp;ctrly the coordinates of the control point         * @param x2,&nbsp;y2 the coordinates of the ending point	 */	public void setCurve(double x1, double y1,			     double ctrlx, double ctrly,			     double x2, double y2) {	    this.x1    = x1;	    this.y1    = y1;	    this.ctrlx = ctrlx;	    this.ctrly = ctrly;	    this.x2    = x2;	    this.y2    = y2;	}	/**	 * Returns the bounding box of this <code>QuadCurve2D</code>.         * @return a <code>Rectangle2D</code> that is the bounding         * 	box of the shape of this <code>QuadCurve2D</code>.	 */	public Rectangle2D getBounds2D() {	    double left   = Math.min(Math.min(x1, x2), ctrlx);	    double top    = Math.min(Math.min(y1, y2), ctrly);	    double right  = Math.max(Math.max(x1, x2), ctrlx);	    double bottom = Math.max(Math.max(y1, y2), ctrly);	    return new Rectangle2D.Double(left, top,					  right - left, bottom - top);	}    }    /**     * This is an abstract class that cannot be instantiated directly.     * Type-specific implementation subclasses are available for     * instantiation and provide a number of formats for storing     * the information necessary to satisfy the various accessor     * methods below.     *     * @see java.awt.geom.QuadCurve2D.Float     * @see java.awt.geom.QuadCurve2D.Double     */    protected QuadCurve2D() {    }    /**     * Returns the x coordinate of the start point in      * <code>double</code> in precision.     * @return the x coordinate of the start point.     */    public abstract double getX1();    /**     * Returns the y coordinate of the start point in      * <code>double</code> precision.     * @return the y coordinate of the start point.     */    public abstract double getY1();    /**     * Returns the start point.     * @return a <code>Point2D</code> that is the start point of this     * 		<code>QuadCurve2D</code>.     */

⌨️ 快捷键说明

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