|
|||||||||
| Home >> All >> java >> [ awt overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.awt
Class BasicStroke

java.lang.Objectjava.awt.BasicStroke
- All Implemented Interfaces:
- Stroke
- public class BasicStroke
- extends java.lang.Object
- implements Stroke
- extends java.lang.Object
A general purpose Stroke implementation that can represent a wide variety of line styles for use with subclasses of Graphics2D.
The line cap and join styles can be set using the options illustrated here:
A dash array can be used to specify lines with alternating opaque and transparent sections.
| Field Summary | |
private int |
cap
The line cap style. |
static int |
CAP_BUTT
Indicates a flat line cap style. |
static int |
CAP_ROUND
Indicates a rounded line cap style. |
static int |
CAP_SQUARE
Indicates a square line cap style. |
private float[] |
dash
The dash array. |
private gnu.java.awt.java2d.Segment |
end
|
private int |
join
The line join style. |
static int |
JOIN_BEVEL
Indicates a bevelled line join style. |
static int |
JOIN_MITER
Indicates a mitered line join style. |
static int |
JOIN_ROUND
Indicates a rounded line join style. |
private float |
limit
The miter limit. |
private float |
phase
The dash phase. |
private gnu.java.awt.java2d.Segment |
start
|
private float |
width
The stroke width. |
| Constructor Summary | |
BasicStroke()
Creates a new BasicStroke instance. |
|
BasicStroke(float width)
Creates a new BasicStroke instance with the given line
width. |
|
BasicStroke(float width,
int cap,
int join)
Creates a new BasicStroke instance with the given attributes. |
|
BasicStroke(float width,
int cap,
int join,
float miterlimit)
Creates a new BasicStroke instance with the given attributes. |
|
BasicStroke(float width,
int cap,
int join,
float miterlimit,
float[] dash,
float dashPhase)
Creates a new BasicStroke instance with the given attributes. |
|
| Method Summary | |
private void |
addSegments(gnu.java.awt.java2d.Segment[] segments)
Add to segments to start and end, joining the outer pair and |
private void |
capEnd(gnu.java.awt.java2d.Segment a,
gnu.java.awt.java2d.Segment b)
Make a cap between a and b segments, where a-->b is the direction of iteration. |
private void |
capEnds()
Cap the ends of the path (joining the start and end list of segments) |
private void |
convertPath(java.awt.geom.GeneralPath p,
gnu.java.awt.java2d.Segment s)
Convert and add the linked list of Segments in s to a GeneralPath p. |
Shape |
createStrokedShape(Shape s)
Creates a shape representing the stroked outline of the given shape. |
private Shape |
dashedStroke(java.awt.geom.PathIterator pi)
|
boolean |
equals(java.lang.Object o)
Compares this BasicStroke for equality with an arbitrary
object. |
float[] |
getDashArray()
Returns the dash array, which defines the length of alternate opaque and transparent sections in lines drawn with this stroke. |
float |
getDashPhase()
Returns the dash phase for the stroke. |
int |
getEndCap()
Returns a code indicating the line cap style (one of CAP_BUTT 55 ,
CAP_ROUND 55 , CAP_SQUARE 55 ). |
int |
getLineJoin()
Returns a code indicating the line join style (one of JOIN_BEVEL 55 ,
JOIN_MITER 55 or JOIN_ROUND 55 ). |
float |
getLineWidth()
Returns the line width. |
float |
getMiterLimit()
Returns the miter limit. |
int |
hashCode()
Returns the hash code for this object. |
private void |
joinSegments(gnu.java.awt.java2d.Segment a,
gnu.java.awt.java2d.Segment b,
java.awt.geom.Point2D insideP)
Join a and b segments, where a-->b is the direction of iteration. |
private java.awt.geom.Point2D |
lineIntersection(double X1,
double Y1,
double X2,
double Y2,
double X3,
double Y3,
double X4,
double Y4,
boolean infinite)
Returns the intersection of two lines, or null if there isn't one. |
private Shape |
solidStroke(java.awt.geom.PathIterator pi)
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
JOIN_MITER
public static final int JOIN_MITER
- Indicates a mitered line join style. See the class overview for an
illustration.
- See Also:
- Constant Field Values
JOIN_ROUND
public static final int JOIN_ROUND
- Indicates a rounded line join style. See the class overview for an
illustration.
- See Also:
- Constant Field Values
JOIN_BEVEL
public static final int JOIN_BEVEL
- Indicates a bevelled line join style. See the class overview for an
illustration.
- See Also:
- Constant Field Values
CAP_BUTT
public static final int CAP_BUTT
- Indicates a flat line cap style. See the class overview for an
illustration.
- See Also:
- Constant Field Values
CAP_ROUND
public static final int CAP_ROUND
- Indicates a rounded line cap style. See the class overview for an
illustration.
- See Also:
- Constant Field Values
CAP_SQUARE
public static final int CAP_SQUARE
- Indicates a square line cap style. See the class overview for an
illustration.
- See Also:
- Constant Field Values
width
private final float width
- The stroke width.
cap
private final int cap
- The line cap style.
join
private final int join
- The line join style.
limit
private final float limit
- The miter limit.
dash
private final float[] dash
- The dash array.
phase
private final float phase
- The dash phase.
start
private gnu.java.awt.java2d.Segment start
end
private gnu.java.awt.java2d.Segment end
| Constructor Detail |
BasicStroke
public BasicStroke(float width,
int cap,
int join,
float miterlimit,
float[] dash,
float dashPhase)
- Creates a new
BasicStrokeinstance with the given attributes.
BasicStroke
public BasicStroke(float width,
int cap,
int join,
float miterlimit)
- Creates a new
BasicStrokeinstance with the given attributes.
BasicStroke
public BasicStroke(float width,
int cap,
int join)
- Creates a new
BasicStrokeinstance with the given attributes. The miter limit defaults to10.0.
BasicStroke
public BasicStroke(float width)
- Creates a new
BasicStrokeinstance with the given line width. The default values are:- line cap style:
CAP_SQUARE55 ; - line join style:
JOIN_MITER55 ; - miter limit:
10.0f.
- line cap style:
BasicStroke
public BasicStroke()
- Creates a new
BasicStrokeinstance. The default values are:- line width:
1.0f; - line cap style:
CAP_SQUARE55 ; - line join style:
JOIN_MITER55 ; - miter limit:
10.0f.
- line width:
| Method Detail |
createStrokedShape
public Shape createStrokedShape(Shape s)
- Creates a shape representing the stroked outline of the given shape.
THIS METHOD IS NOT YET IMPLEMENTED.
- Specified by:
createStrokedShapein interfaceStroke
getLineWidth
public float getLineWidth()
- Returns the line width.
getEndCap
public int getEndCap()
- Returns a code indicating the line cap style (one of
CAP_BUTT55 ,CAP_ROUND55 ,CAP_SQUARE55 ).
getLineJoin
public int getLineJoin()
- Returns a code indicating the line join style (one of
JOIN_BEVEL55 ,JOIN_MITER55 orJOIN_ROUND55 ).
getMiterLimit
public float getMiterLimit()
- Returns the miter limit.
getDashArray
public float[] getDashArray()
- Returns the dash array, which defines the length of alternate opaque and
transparent sections in lines drawn with this stroke. If
null, a continuous line will be drawn.
getDashPhase
public float getDashPhase()
- Returns the dash phase for the stroke. This is the offset from the start
of a path at which the pattern defined by
getDashArray()55 is rendered.
hashCode
public int hashCode()
- Returns the hash code for this object. The hash is calculated by
xoring the hash, cap, join, limit, dash array and phase values
(converted to
intfirst withFloat.floatToIntBits()if the value is afloat).
equals
public boolean equals(java.lang.Object o)
- Compares this
BasicStrokefor equality with an arbitrary object. This method returnstrueif and only if:ois an instanceofBasicStroke;- this object has the same width, line cap style, line join style,
miter limit, dash array and dash phase as
o.
solidStroke
private Shape solidStroke(java.awt.geom.PathIterator pi)
dashedStroke
private Shape dashedStroke(java.awt.geom.PathIterator pi)
capEnds
private void capEnds()
- Cap the ends of the path (joining the start and end list of segments)
convertPath
private void convertPath(java.awt.geom.GeneralPath p, gnu.java.awt.java2d.Segment s)
- Convert and add the linked list of Segments in s to a GeneralPath p.
addSegments
private void addSegments(gnu.java.awt.java2d.Segment[] segments)
- Add to segments to start and end, joining the outer pair and
capEnd
private void capEnd(gnu.java.awt.java2d.Segment a, gnu.java.awt.java2d.Segment b)
- Make a cap between a and b segments,
where a-->b is the direction of iteration.
lineIntersection
private java.awt.geom.Point2D lineIntersection(double X1, double Y1, double X2, double Y2, double X3, double Y3, double X4, double Y4, boolean infinite)
- Returns the intersection of two lines, or null if there isn't one.
joinSegments
private void joinSegments(gnu.java.awt.java2d.Segment a, gnu.java.awt.java2d.Segment b, java.awt.geom.Point2D insideP)
- Join a and b segments, where a-->b is the direction of iteration.
insideP is the inside intersection point of the join, needed for
calculating miter lengths.
|
|||||||||
| Home >> All >> java >> [ awt overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
java.awt.BasicStroke