public class BasicStroke extends Object implements Stroke
BasicStroke class defines a basic set of rendering
 attributes for the outlines of graphics primitives, which are rendered
 with a Graphics2D object that has its Stroke attribute set to
 this BasicStroke.
 The rendering attributes defined by BasicStroke describe
 the shape of the mark made by a pen drawn along the outline of a
 Shape and the decorations applied at the ends and joins of
 path segments of the Shape.
 These rendering attributes include:
 SEG_CLOSE
 for more information on the CLOSE segment.
 The three different decorations are: CAP_BUTT,
 CAP_ROUND, and CAP_SQUARE.
 SEG_CLOSE.
 The three different decorations are: JOIN_BEVEL,
 JOIN_MITER, and JOIN_ROUND.
 Shape
 argument.  When a Graphics2D object uses a
 Stroke object to redefine a path during the execution
 of one of its draw methods, the geometry is supplied
 in its original form before the Graphics2D transform
 attribute is applied.  Therefore, attributes such as the pen width
 are interpreted in the user space coordinate system of the
 Graphics2D object and are subject to the scaling and
 shearing effects of the user-space-to-device-space transform in that
 particular Graphics2D.
 For example, the width of a rendered shape's outline is determined
 not only by the width attribute of this BasicStroke,
 but also by the transform attribute of the
 Graphics2D object.  Consider this code:
 // sets the Graphics2D object's Transform attribute g2d.scale(10, 10); // sets the Graphics2D object's Stroke attribute g2d.setStroke(new BasicStroke(1.5f));Assuming there are no other scaling transforms added to the
Graphics2D object, the resulting line
 will be approximately 15 pixels wide.
 As the example code demonstrates, a floating-point line
 offers better precision, especially when large transforms are
 used with a Graphics2D object.
 When a line is diagonal, the exact width depends on how the
 rendering pipeline chooses which pixels to fill as it traces the
 theoretical widened outline.  The choice of which pixels to turn
 on is affected by the antialiasing attribute because the
 antialiasing rendering pipeline can choose to color
 partially-covered pixels.
 
 For more information on the user space coordinate system and the
 rendering process, see the Graphics2D class comments.
Graphics2D| Modifier and Type | Field and Description | 
|---|---|
| static int | CAP_BUTTEnds unclosed subpaths and dash segments with no added
 decoration. | 
| static int | CAP_ROUNDEnds unclosed subpaths and dash segments with a round
 decoration that has a radius equal to half of the width
 of the pen. | 
| static int | CAP_SQUAREEnds unclosed subpaths and dash segments with a square
 projection that extends beyond the end of the segment
 to a distance equal to half of the line width. | 
| static int | JOIN_BEVELJoins path segments by connecting the outer corners of their
 wide outlines with a straight segment. | 
| static int | JOIN_MITERJoins path segments by extending their outside edges until
 they meet. | 
| static int | JOIN_ROUNDJoins path segments by rounding off the corner at a radius
 of half the line width. | 
| Constructor and Description | 
|---|
| BasicStroke()Constructs a new  BasicStrokewith defaults for all
 attributes. | 
| BasicStroke(float width)Constructs a solid  BasicStrokewith the specified
 line width and with default values for the cap and join
 styles. | 
| BasicStroke(float width,
           int cap,
           int join)Constructs a solid  BasicStrokewith the specified
 attributes. | 
| BasicStroke(float width,
           int cap,
           int join,
           float miterlimit)Constructs a solid  BasicStrokewith the specified
 attributes. | 
| BasicStroke(float width,
           int cap,
           int join,
           float miterlimit,
           float[] dash,
           float dash_phase)Constructs a new  BasicStrokewith the specified
 attributes. | 
| Modifier and Type | Method and Description | 
|---|---|
| Shape | createStrokedShape(Shape s)Returns a  Shapewhose interior defines the
 stroked outline of a specifiedShape. | 
| boolean | equals(Object obj)Tests if a specified object is equal to this  BasicStrokeby first testing if it is aBasicStrokeand then comparing
 its width, join, cap, miter limit, dash, and dash phase attributes with
 those of thisBasicStroke. | 
| float[] | getDashArray()Returns the array representing the lengths of the dash segments. | 
| float | getDashPhase()Returns the current dash phase. | 
| int | getEndCap()Returns the end cap style. | 
| int | getLineJoin()Returns the line join style. | 
| float | getLineWidth()Returns the line width. | 
| float | getMiterLimit()Returns the limit of miter joins. | 
| int | hashCode()Returns the hashcode for this stroke. | 
@Native public static final int JOIN_MITER
@Native public static final int JOIN_ROUND
@Native public static final int JOIN_BEVEL
@Native public static final int CAP_BUTT
@Native public static final int CAP_ROUND
@Native public static final int CAP_SQUARE
@ConstructorProperties(value={"lineWidth","endCap","lineJoin","miterLimit","dashArray","dashPhase"}) public BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase)
BasicStroke with the specified
 attributes.width - the width of this BasicStroke.  The
         width must be greater than or equal to 0.0f.  If width is
         set to 0.0f, the stroke is rendered as the thinnest
         possible line for the target device and the antialias
         hint setting.cap - the decoration of the ends of a BasicStrokejoin - the decoration applied where path segments meetmiterlimit - the limit to trim the miter join.  The miterlimit
        must be greater than or equal to 1.0f.dash - the array representing the dashing patterndash_phase - the offset to start the dashing patternIllegalArgumentException - if width is negativeIllegalArgumentException - if cap is not either
         CAP_BUTT, CAP_ROUND or CAP_SQUAREIllegalArgumentException - if miterlimit is less
         than 1 and join is JOIN_MITERIllegalArgumentException - if join is not
         either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITERIllegalArgumentException - if dash_phase
         is negative and dash is not nullIllegalArgumentException - if the length of
         dash is zeroIllegalArgumentException - if dash lengths are all zero.public BasicStroke(float width,
                   int cap,
                   int join,
                   float miterlimit)
BasicStroke with the specified
 attributes.width - the width of the BasicStrokecap - the decoration of the ends of a BasicStrokejoin - the decoration applied where path segments meetmiterlimit - the limit to trim the miter joinIllegalArgumentException - if width is negativeIllegalArgumentException - if cap is not either
         CAP_BUTT, CAP_ROUND or CAP_SQUAREIllegalArgumentException - if miterlimit is less
         than 1 and join is JOIN_MITERIllegalArgumentException - if join is not
         either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITERpublic BasicStroke(float width,
                   int cap,
                   int join)
BasicStroke with the specified
 attributes.  The miterlimit parameter is
 unnecessary in cases where the default is allowable or the
 line joins are not specified as JOIN_MITER.width - the width of the BasicStrokecap - the decoration of the ends of a BasicStrokejoin - the decoration applied where path segments meetIllegalArgumentException - if width is negativeIllegalArgumentException - if cap is not either
         CAP_BUTT, CAP_ROUND or CAP_SQUAREIllegalArgumentException - if join is not
         either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITERpublic BasicStroke(float width)
BasicStroke with the specified
 line width and with default values for the cap and join
 styles.width - the width of the BasicStrokeIllegalArgumentException - if width is negativepublic BasicStroke()
BasicStroke 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 Shape createStrokedShape(Shape s)
Shape whose interior defines the
 stroked outline of a specified Shape.createStrokedShape in interface Strokes - the Shape boundary be strokedShape of the stroked outline.public float getLineWidth()
Graphics2D class comments for more information on
 the user space coordinate system.BasicStroke.Graphics2Dpublic int getEndCap()
BasicStroke as one
 of the static int values that define possible end cap
 styles.public int getLineJoin()
BasicStroke as one
 of the static int values that define possible line
 join styles.public float getMiterLimit()
BasicStroke.public float[] getDashArray()
Shape
 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.public float getDashPhase()
float value.public int hashCode()
hashCode in class ObjectObject.equals(java.lang.Object), 
System.identityHashCode(java.lang.Object)public boolean equals(Object obj)
BasicStroke
 by first testing if it is a BasicStroke and then comparing
 its width, join, cap, miter limit, dash, and dash phase attributes with
 those of this BasicStroke.equals in class Objectobj - the specified object to compare to this
              BasicStroketrue if the width, join, cap, miter limit, dash, and
            dash phase are the same for both objects;
            false otherwise.Object.hashCode(), 
HashMap Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2015, Oracle and/or its affiliates.  All rights reserved.