2965N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * The <code>BasicStroke</code> class defines a basic set of rendering 0N/A * attributes for the outlines of graphics primitives, which are rendered 0N/A * with a {@link Graphics2D} object that has its Stroke attribute set to 0N/A * this <code>BasicStroke</code>. 0N/A * The rendering attributes defined by <code>BasicStroke</code> describe 0N/A * the shape of the mark made by a pen drawn along the outline of a 0N/A * {@link Shape} and the decorations applied at the ends and joins of 0N/A * path segments of the <code>Shape</code>. 0N/A * These rendering attributes include: 0N/A * <dd>The pen width, measured perpendicularly to the pen trajectory. 0N/A * <dt><i>end caps</i> 0N/A * <dd>The decoration applied to the ends of unclosed subpaths and 0N/A * dash segments. Subpaths that start and end on the same point are 0N/A * still considered unclosed if they do not have a CLOSE segment. 0N/A * See {@link java.awt.geom.PathIterator#SEG_CLOSE SEG_CLOSE} 0N/A * for more information on the CLOSE segment. 0N/A * The three different decorations are: {@link #CAP_BUTT}, 0N/A * {@link #CAP_ROUND}, and {@link #CAP_SQUARE}. 0N/A * <dt><i>line joins</i> 0N/A * <dd>The decoration applied at the intersection of two path segments 0N/A * and at the intersection of the endpoints of a subpath that is closed 0N/A * using {@link java.awt.geom.PathIterator#SEG_CLOSE SEG_CLOSE}. 0N/A * The three different decorations are: {@link #JOIN_BEVEL}, 0N/A * {@link #JOIN_MITER}, and {@link #JOIN_ROUND}. 0N/A * <dt><i>miter limit</i> 0N/A * <dd>The limit to trim a line join that has a JOIN_MITER decoration. 0N/A * A line join is trimmed when the ratio of miter length to stroke 0N/A * width is greater than the miterlimit value. The miter length is 0N/A * the diagonal length of the miter, which is the distance between 0N/A * the inside corner and the outside corner of the intersection. 0N/A * The smaller the angle formed by two line segments, the longer 0N/A * the miter length and the sharper the angle of intersection. The 0N/A * default miterlimit value of 10.0f causes all angles less than 0N/A * 11 degrees to be trimmed. Trimming miters converts 0N/A * the decoration of the line join to bevel. 0N/A * <dt><i>dash attributes</i> 0N/A * <dd>The definition of how to make a dash pattern by alternating 0N/A * between opaque and transparent sections. 0N/A * All attributes that specify measurements and distances controlling 0N/A * the shape of the returned outline are measured in the same 0N/A * coordinate system as the original unstroked <code>Shape</code> 0N/A * argument. When a <code>Graphics2D</code> object uses a 0N/A * <code>Stroke</code> object to redefine a path during the execution 0N/A * of one of its <code>draw</code> methods, the geometry is supplied 0N/A * in its original form before the <code>Graphics2D</code> transform 0N/A * attribute is applied. Therefore, attributes such as the pen width 0N/A * are interpreted in the user space coordinate system of the 0N/A * <code>Graphics2D</code> object and are subject to the scaling and 0N/A * shearing effects of the user-space-to-device-space transform in that 0N/A * particular <code>Graphics2D</code>. 0N/A * For example, the width of a rendered shape's outline is determined 0N/A * not only by the width attribute of this <code>BasicStroke</code>, 0N/A * but also by the transform attribute of the 0N/A * <code>Graphics2D</code> object. Consider this code: 0N/A * // sets the Graphics2D object's Tranform attribute 0N/A * g2d.scale(10, 10); 0N/A * // sets the Graphics2D object's Stroke attribute 0N/A * g2d.setStroke(new BasicStroke(1.5f)); 0N/A * </tt></blockquote> 0N/A * Assuming there are no other scaling transforms added to the 0N/A * <code>Graphics2D</code> object, the resulting line 0N/A * will be approximately 15 pixels wide. 0N/A * As the example code demonstrates, a floating-point line 0N/A * offers better precision, especially when large transforms are 0N/A * used with a <code>Graphics2D</code> object. 0N/A * When a line is diagonal, the exact width depends on how the 0N/A * rendering pipeline chooses which pixels to fill as it traces the 0N/A * theoretical widened outline. The choice of which pixels to turn 0N/A * on is affected by the antialiasing attribute because the 0N/A * antialiasing rendering pipeline can choose to color 0N/A * partially-covered pixels. 0N/A * For more information on the user space coordinate system and the 0N/A * rendering process, see the <code>Graphics2D</code> class comments. 0N/A * @author Jim Graham 0N/A * Joins path segments by extending their outside edges until 0N/A * Joins path segments by rounding off the corner at a radius 0N/A * of half the line width. 0N/A * Joins path segments by connecting the outer corners of their 0N/A * wide outlines with a straight segment. 0N/A * Ends unclosed subpaths and dash segments with no added 0N/A * Ends unclosed subpaths and dash segments with a round 0N/A * decoration that has a radius equal to half of the width 0N/A * Ends unclosed subpaths and dash segments with a square 0N/A * projection that extends beyond the end of the segment 0N/A * to a distance equal to half of the line width. 0N/A * Constructs a new <code>BasicStroke</code> with the specified 0N/A * @param width the width of this <code>BasicStroke</code>. The 0N/A * width must be greater than or equal to 0.0f. If width is 0N/A * set to 0.0f, the stroke is rendered as the thinnest 0N/A * possible line for the target device and the antialias 0N/A * @param cap the decoration of the ends of a <code>BasicStroke</code> 0N/A * @param join the decoration applied where path segments meet 0N/A * @param miterlimit the limit to trim the miter join. The miterlimit 0N/A * must be greater than or equal to 1.0f. 0N/A * @param dash the array representing the dashing pattern 0N/A * @param dash_phase the offset to start the dashing pattern 0N/A * @throws IllegalArgumentException if <code>width</code> is negative 0N/A * @throws IllegalArgumentException if <code>cap</code> is not either 0N/A * CAP_BUTT, CAP_ROUND or CAP_SQUARE 0N/A * @throws IllegalArgumentException if <code>miterlimit</code> is less 0N/A * than 1 and <code>join</code> is JOIN_MITER 0N/A * @throws IllegalArgumentException if <code>join</code> is not 0N/A * either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER 0N/A * @throws IllegalArgumentException if <code>dash_phase</code> 0N/A * is negative and <code>dash</code> is not <code>null</code> 0N/A * @throws IllegalArgumentException if the length of 0N/A * <code>dash</code> is zero 0N/A * @throws IllegalArgumentException if dash lengths are all zero. 0N/A }
else if (d <
0.0) {
0N/A * Constructs a solid <code>BasicStroke</code> with the specified 0N/A * @param width the width of the <code>BasicStroke</code> 0N/A * @param cap the decoration of the ends of a <code>BasicStroke</code> 0N/A * @param join the decoration applied where path segments meet 0N/A * @param miterlimit the limit to trim the miter join 0N/A * @throws IllegalArgumentException if <code>width</code> is negative 0N/A * @throws IllegalArgumentException if <code>cap</code> is not either 0N/A * CAP_BUTT, CAP_ROUND or CAP_SQUARE 0N/A * @throws IllegalArgumentException if <code>miterlimit</code> is less 0N/A * than 1 and <code>join</code> is JOIN_MITER 0N/A * @throws IllegalArgumentException if <code>join</code> is not 0N/A * either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER 0N/A * Constructs a solid <code>BasicStroke</code> with the specified 0N/A * attributes. The <code>miterlimit</code> parameter is 0N/A * unnecessary in cases where the default is allowable or the 0N/A * line joins are not specified as JOIN_MITER. 0N/A * @param width the width of the <code>BasicStroke</code> 0N/A * @param cap the decoration of the ends of a <code>BasicStroke</code> 0N/A * @param join the decoration applied where path segments meet 0N/A * @throws IllegalArgumentException if <code>width</code> is negative 0N/A * @throws IllegalArgumentException if <code>cap</code> is not either 0N/A * CAP_BUTT, CAP_ROUND or CAP_SQUARE 0N/A * @throws IllegalArgumentException if <code>join</code> is not 0N/A * either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER 0N/A * Constructs a solid <code>BasicStroke</code> with the specified 0N/A * line width and with default values for the cap and join 0N/A * @param width the width of the <code>BasicStroke</code> 0N/A * @throws IllegalArgumentException if <code>width</code> is negative 0N/A * Constructs a new <code>BasicStroke</code> with defaults for all 0N/A * The default attributes are a solid line of width 1.0, CAP_SQUARE, 0N/A * JOIN_MITER, a miter limit of 10.0. 0N/A * Returns a <code>Shape</code> whose interior defines the 0N/A * stroked outline of a specified <code>Shape</code>. 0N/A * @param s the <code>Shape</code> boundary be stroked 0N/A * @return the <code>Shape</code> of the stroked outline. 0N/A * Returns the line width. Line width is represented in user space, 0N/A * which is the default-coordinate space used by Java 2D. See the 0N/A * <code>Graphics2D</code> class comments for more information on 0N/A * the user space coordinate system. 0N/A * @return the line width of this <code>BasicStroke</code>. 0N/A * Returns the end cap style. 0N/A * @return the end cap style of this <code>BasicStroke</code> as one 0N/A * of the static <code>int</code> values that define possible end cap 0N/A * Returns the line join style. 0N/A * @return the line join style of the <code>BasicStroke</code> as one 0N/A * of the static <code>int</code> values that define possible line 0N/A * Returns the limit of miter joins. 0N/A * @return the limit of miter joins of the <code>BasicStroke</code>. 0N/A * Returns the array representing the lengths of the dash segments. 0N/A * Alternate entries in the array represent the user space lengths 0N/A * of the opaque and transparent segments of the dashes. 0N/A * As the pen moves along the outline of the <code>Shape</code> 0N/A * to be stroked, the user space 0N/A * distance that the pen travels is accumulated. The distance 0N/A * value is used to index into the dash array. 0N/A * The pen is opaque when its current cumulative distance maps 0N/A * to an even element of the dash array and transparent otherwise. 0N/A * @return the dash array. 0N/A * Returns the current dash phase. 0N/A * The dash phase is a distance specified in user coordinates that 0N/A * represents an offset into the dashing pattern. In other words, the dash 0N/A * phase defines the point in the dashing pattern that will correspond to 0N/A * the beginning of the stroke. 0N/A * @return the dash phase as a <code>float</code> value. 0N/A * Returns the hashcode for this stroke. 0N/A * @return a hash code for this stroke. 0N/A * Returns true if this BasicStroke represents the same 0N/A * stroking operation as the given argument. 0N/A * Tests if a specified object is equal to this <code>BasicStroke</code> 0N/A * by first testing if it is a <code>BasicStroke</code> and then comparing 0N/A * its width, join, cap, miter limit, dash, and dash phase attributes with 0N/A * those of this <code>BasicStroke</code>. 0N/A * @param obj the specified object to compare to this 0N/A * <code>BasicStroke</code> 0N/A * @return <code>true</code> if the width, join, cap, miter limit, dash, and 0N/A * dash phase are the same for both objects; 0N/A * <code>false</code> otherwise.