Java Platform 1.2
Beta 4

Class java.awt.BasicStroke

java.lang.Object
  |
  +--java.awt.BasicStroke

public class BasicStroke
extends Object
implements Stroke
Defines a basic set of rendering attributes for stroked graphics primitives. These attributes describe the shape of a pen drawn along the trajectory of the path and the decorations applied where path segments are joined and where they begin and end. These attributes include:
width
The width of the pen measured perpendicular to its trajectory.
end caps
The decoration of the path where line segments begin and end.
line joins
The decoration of the path between connected line segments.
dash attributes
The definition of how to make a dash pattern along the trajectory of the path by creating new segments which alternate between opaque and transparent sections.


Field Summary
static int CAP_BUTT
          End unclosed subpaths and dash segments with no added decoration.
static int CAP_ROUND
          End unclosed subpaths and dash segments with a round decoration with radius equal to half of the line width.
static int CAP_SQUARE
          End 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_BEVEL
          Join line segments by connecting the outer corners of their wide outlines with a straight segment.
static int JOIN_MITER
          Join line segments by extending their outside edges until they meet.
static int JOIN_ROUND
          Join line segments by rounding off the corner at a radius of half the line width.
 
Constructor Summary
BasicStroke()
          Construct a new stroke with defaults for all attributes.
BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase)
          Construct a new stroke with the specified attributes.
BasicStroke(float width, int cap, int join, float miterlimit)
          Construct a new stroke with the specified attributes, but no dashing.
BasicStroke(float width, int cap, int join)
          Construct a new stroke with the specified attributes, but no dashing.
BasicStroke(float width)
          Construct a new stroke with the specified line width, and with default values for the cap and join styles and no dashing.
 
Method Summary
 Shape createStrokedShape(Shape s)
          Returns a shape whose interior defines the stroked outline of a given shape.
 boolean equals(Object obj)
           
 float[] getDashArray()
          Return the array representing the lengths of the dash segments.
 float getDashPhase()
          Returns the 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.
 
Methods inherited from class java.lang.Object
clone , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Field Detail

JOIN_MITER

public static final int JOIN_MITER
Join line segments by extending their outside edges until they meet.

JOIN_ROUND

public static final int JOIN_ROUND
Join line segments by rounding off the corner at a radius of half the line width.

JOIN_BEVEL

public static final int JOIN_BEVEL
Join line segments by connecting the outer corners of their wide outlines with a straight segment.

CAP_BUTT

public static final int CAP_BUTT
End unclosed subpaths and dash segments with no added decoration.

CAP_ROUND

public static final int CAP_ROUND
End unclosed subpaths and dash segments with a round decoration with radius equal to half of the line width.

CAP_SQUARE

public static final int CAP_SQUARE
End 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.
Constructor Detail

BasicStroke

public BasicStroke(float width,
                   int cap,
                   int join,
                   float miterlimit,
                   float[] dash,
                   float dash_phase)
Construct a new stroke with the specified attributes.
Parameters:
width - The width of the stroke.
cap - The style of the ends of a stroke.
join - The style to join strokes together.
miterlimit - The limit to trim the miter join.
dash - The array representing the dashing pattern.
dash_phase - The offset to start the dashing pattern.

BasicStroke

public BasicStroke(float width,
                   int cap,
                   int join,
                   float miterlimit)
Construct a new stroke with the specified attributes, but no dashing.
Parameters:
width - The width of the stroke.
cap - The style of the ends of a stroke.
join - The style to join strokes together.
miterlimit - The limit to trim the miter join.

BasicStroke

public BasicStroke(float width,
                   int cap,
                   int join)
Construct a new stroke with the specified attributes, but no dashing. The miter limit parameter is unnecessary in cases where the default is allowable or the line joins are not specified as JOIN_MITER.
Parameters:
width - The width of the stroke.
cap - The style of the ends of a stroke.
join - The style to join strokes together.

BasicStroke

public BasicStroke(float width)
Construct a new stroke with the specified line width, and with default values for the cap and join styles and no dashing.
Parameters:
width - The width of the stroke.

BasicStroke

public BasicStroke()
Construct a new stroke with defaults for all attributes. The default attributes are a line width of 1.0, CAP_SQUARE, JOIN_MITER, a miter limit of 10.0, and no dashing.
Method Detail

createStrokedShape

public Shape createStrokedShape(Shape s)
Returns a shape whose interior defines the stroked outline of a given shape.
Specified by:
createStrokedShape in interface Stroke
Parameters:
s - The shape whose boundary should be stroked.
Returns:
The shape of the stroked outline.
See Also:
Stroke.createStrokedShape(java.awt.Shape)

getLineWidth

public float getLineWidth()
Returns the line width. Line width is represented in user space.
Returns:
The line width of the stroke.

getEndCap

public int getEndCap()
Returns the end cap style.
Returns:
The end cap style of the stroke.

getLineJoin

public int getLineJoin()
Returns the line join style.
Returns:
The line join style of the stroke.

getMiterLimit

public float getMiterLimit()
Returns the limit of miter joins.
Returns:
The limit of miter joins.

getDashArray

public float[] getDashArray()
Return 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 path to be stroked, the user space distance that the pen travels will be accumulated to index into the dash array. The pen will be opaque when its current cumulative distance maps to an odd element of the dash array and transparent otherwise.
Returns:
The dash array.

getDashPhase

public float getDashPhase()
Returns the dash phase. The dash phase is a user space distance that is used to initialize the path distance accumulation variable before the first segment of the first subpath is stroked.
Returns:
the dash phase.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.