com.davisor.graphics
Class BetterStroke

java.lang.Object
  extended byjava.awt.BasicStroke
      extended bycom.davisor.graphics.BetterStroke
All Implemented Interfaces:
java.awt.Stroke

public class BetterStroke
extends java.awt.BasicStroke

BetterStroke extends standard BasicStroke with functionality that was missing from it (in some implementations, at least). These extensions are:

Unfortunately, some Java implementations - most notably the Sun reference implementations - seem to treat BasicStrokes in a special way. Instead of calling the createStrokedShape method for stroke shapes, the low level graphics system operations use BasicStroke attribute access methods, in order to construct some kind of private stroke objects that do the stroking. This makes the createStrokedShape method overloading useless.

Since:
JDK1.1
See Also:
createStrokedShape(java.awt.Shape), NullStroke

Field Summary
static char DASHSEPARATOR
          Stroke dash value separator (:).
 
Fields inherited from class java.awt.BasicStroke
CAP_BUTT, CAP_ROUND, CAP_SQUARE, JOIN_BEVEL, JOIN_MITER, JOIN_ROUND
 
Constructor Summary
BetterStroke()
          Constructs a new BetterStroke with defaults for all attributes.
BetterStroke(float width)
          Constructs a solid BetterStroke with the specified line width and with default values for the cap and join styles.
BetterStroke(float width, int cap, int join)
          Constructs a solid BetterStroke with the specified attributes.
BetterStroke(float width, int cap, int join, float miterlimit)
          Constructs a solid BetterStroke with the specified attributes.
BetterStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase)
          Constructs a new BetterStroke with the specified attributes.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this stroke to other objects.
 java.awt.Shape createStrokedShape(java.awt.Shape shape)
          Returns a Shape which interior defines the stroked outline of a specified Shape.
 java.lang.String toString()
          Converts this stroke to a descriptive string.
 
Methods inherited from class java.awt.BasicStroke
equals, getDashArray, getDashPhase, getEndCap, getLineJoin, getLineWidth, getMiterLimit, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DASHSEPARATOR

public static final char DASHSEPARATOR
Stroke dash value separator (:).

See Also:
Constant Field Values
Constructor Detail

BetterStroke

public BetterStroke()
Constructs a new BetterStroke with defaults for all attributes. The default attributes are a solid line of the width 1.0, CAP_SQUARE, JOIN_MITER, the miter limit 10.0.


BetterStroke

public BetterStroke(float width)
Constructs a solid BetterStroke with the specified line width and with default values for the cap and join styles.

Parameters:
width - line width

BetterStroke

public BetterStroke(float width,
                    int cap,
                    int join)
Constructs a solid BetterStroke 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.

Parameters:
width - line width
cap - BasicStroke cap style
join - BasicStroke join style

BetterStroke

public BetterStroke(float width,
                    int cap,
                    int join,
                    float miterlimit)
Constructs a solid BetterStroke with the specified attributes.


BetterStroke

public BetterStroke(float width,
                    int cap,
                    int join,
                    float miterlimit,
                    float[] dash,
                    float dash_phase)
Constructs a new BetterStroke with the specified attributes.

Parameters:
width - line width
cap - BasicStroke cap style
join - BasicStroke join style
miterlimit - the limit to trim the miter join
dash - the array representing the dashing pattern
dash_phase - the offset to start the dashing pattern
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compares this stroke to other objects.

See Also:
BasicStroke.equals(java.lang.Object), CompareGraphics.compareTo(BasicStroke,BasicStroke)

toString

public java.lang.String toString()
Converts this stroke to a descriptive string. The format of the string is:

width-cap-join-miterlimit[-dashpatttern-dashphase]

The width, miterlimit and dashphase are floating point values. The cap style is one of:

The join style is one of:

The dash pattern is by colon (:) separated list of floating point values.


createStrokedShape

public java.awt.Shape createStrokedShape(java.awt.Shape shape)
Returns a Shape which interior defines the stroked outline of a specified Shape. However, if the stroke line width is zero, an empty shape is returned instead.

Parameters:
shape - the shape boundary to be stroked


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.