basicstroke.java

来自「This is a resource based on j2me embedde」· Java 代码 · 共 445 行 · 第 1/2 页

JAVA
445
字号
        if (dash != null) {            this.dash = (float []) dash.clone();        }	this.dash_phase	= dash_phase;    }    /**     * Constructs a solid <code>BasicStroke</code> with the specified      * attributes.     * @param width the width of the <code>BasicStroke</code>     * @param cap the decoration of the ends of a <code>BasicStroke</code>     * @param join the decoration applied where path segments meet     * @param miterlimit the limit to trim the miter join     * @throws IllegalArgumentException if <code>width</code> is negative     * @throws IllegalArgumentException if <code>cap</code> is not either     *         CAP_BUTT, CAP_ROUND or CAP_SQUARE     * @throws IllegalArgumentException if <code>miterlimit</code> is less     *         than 1 and <code>join</code> is JOIN_MITER     * @throws IllegalArgumentException if <code>join</code> is not     *         either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER     */    public BasicStroke(float width, int cap, int join, float miterlimit) {	this(width, cap, join, miterlimit, null, 0.0f);    }    /**     * Constructs a solid <code>BasicStroke</code> with the specified      * attributes.  The <code>miterlimit</code> parameter is      * unnecessary in cases where the default is allowable or the      * line joins are not specified as JOIN_MITER.     * @param width the width of the <code>BasicStroke</code>     * @param cap the decoration of the ends of a <code>BasicStroke</code>     * @param join the decoration applied where path segments meet     * @throws IllegalArgumentException if <code>width</code> is negative     * @throws IllegalArgumentException if <code>cap</code> is not either     *         CAP_BUTT, CAP_ROUND or CAP_SQUARE     * @throws IllegalArgumentException if <code>join</code> is not     *         either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER     */    public BasicStroke(float width, int cap, int join) {	this(width, cap, join, 10.0f, null, 0.0f);    }    /**     * Constructs a solid <code>BasicStroke</code> with the specified      * line width and with default values for the cap and join      * styles.     * @param width the width of the <code>BasicStroke</code>     * @throws IllegalArgumentException if <code>width</code> is negative     */    public BasicStroke(float width) {	this(width, CAP_SQUARE, JOIN_MITER, 10.0f, null, 0.0f);    }    /**     * Constructs a new <code>BasicStroke</code> with defaults for all      * attributes.     * The default attributes are a solid line of width 1.0, CAP_SQUARE,     * JOIN_MITER, a miter limit of 10.0.     */    public BasicStroke() {	this(1.0f, CAP_SQUARE, JOIN_MITER, 10.0f, null, 0.0f);    }//    /**//     * Returns a <code>Shape</code> whose interior defines the //     * stroked outline of a specified <code>Shape</code>.//     * @param s the <code>Shape</code> boundary be stroked//     * @return the <code>Shape</code> of the stroked outline.//     *///    public Shape createStrokedShape(Shape s) {//	return s;//    }    /**     * Returns the line width.  Line width is represented in user space,      * which is the default-coordinate space used by Java 2D.  See the     * <code>Graphics2D</code> class comments for more information on     * the user space coordinate system.     * @return the line width of this <code>BasicStroke</code>.     * @see Graphics2D     */    public float getLineWidth() {	return width;    }    /**     * Returns the end cap style.     * @return the end cap style of this <code>BasicStroke</code> as one     * of the static <code>int</code> values that define possible end cap     * styles.     */    public int getEndCap() {	return cap;    }    /**     * Returns the line join style.     * @return the line join style of the <code>BasicStroke</code> as one     * of the static <code>int</code> values that define possible line     * join styles.     */    public int getLineJoin() {	return join;    }    /**     * Returns the limit of miter joins.     * @return the limit of miter joins of the <code>BasicStroke</code>.     */    public float getMiterLimit() {	return miterlimit;    }//    /**//     * Returns the array representing the lengths of the dash segments.//     * Alternate entries in the array represent the user space lengths//     * of the opaque and transparent segments of the dashes.//     * As the pen moves along the outline of the <code>Shape</code>//     * to be stroked, the user space//     * distance that the pen travels is accumulated.  The distance//     * value is used to index into the dash array.//     * The pen is opaque when its current cumulative distance maps//     * to an even element of the dash array and transparent otherwise.//     * @return the dash array.//     *///    public float[] getDashArray() {//        if (dash == null) {//            return null;//        }////        return (float[]) dash.clone();//    }////    /**//     * Returns the current dash phase.//     * The dash phase is a distance specified in user coordinates that //     * represents an offset into the dashing pattern. In other words, the dash //     * phase defines the point in the dashing pattern that will correspond to //     * the beginning of the stroke.//     * @return the dash phase as a <code>float</code> value.//     *///    public float getDashPhase() {//	return dash_phase;//    }    /**     * Returns the hashcode for this stroke.     * @return      a hash code for this stroke.     */    public int hashCode() {	int hash = Float.floatToIntBits(width);	hash = hash * 31 + join;	hash = hash * 31 + cap;	hash = hash * 31 + Float.floatToIntBits(miterlimit);	if (dash != null) {	    hash = hash * 31 + Float.floatToIntBits(dash_phase);	    for (int i = 0; i < dash.length; i++) {		hash = hash * 31 + Float.floatToIntBits(dash[i]);	    }	}	return hash;    }    /**     * Returns true if this BasicStroke represents the same     * stroking operation as the given argument.     */   /**    * Tests if a specified object is equal to this <code>BasicStroke</code>    * by first testing if it is a <code>BasicStroke</code> and then comparing     * its width, join, cap, miter limit, dash, and dash phase attributes with     * those of this <code>BasicStroke</code>.    * @param  obj the specified object to compare to this     *              <code>BasicStroke</code>    * @return <code>true</code> if the width, join, cap, miter limit, dash, and    *            dash phase are the same for both objects;    *            <code>false</code> otherwise.    */    public boolean equals(Object obj) {        if (!(obj instanceof BasicStroke)) {            return false;        }        BasicStroke bs = (BasicStroke) obj;        if (width != bs.width) {            return false;        }        if (join != bs.join) {            return false;        }        if (cap != bs.cap) {            return false;        }        if (miterlimit != bs.miterlimit) {            return false;        }        if (dash != null) {	    if (dash_phase != bs.dash_phase) {		return false;	    }	    if (!java.util.Arrays.equals(dash, bs.dash)) {		return false;	    }        }        else if (bs.dash != null) {            return false;        }        return true;    }}

⌨️ 快捷键说明

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