> Why are there no setter methods on the BasicStroke class for
> setting the lineWdith etc ?

The BasicStroke was meant to be an immutable attribute object.  The
Graphics2D does not clone stroke objects when accepting or returning
them so it makes sense to provide implementations that are immutable
to satisfy the law of least astonishment.  Also, stroke definitions
tend not to be the type of thing that most graphics programs need
to store many variants of.

A large number of applications define a small selection of constant
stroke patterns that are used and shared repeatedly throughout the
graphical output.

There are a number of other applications which rely on arbitrary
inputs to define the line widths and sharing is not possible due to
the unpredictable nature of the input data.  In many cases, the
input data might actually be predictable in some way and a very
simple caching scheme might be possible but in any case, the BasicStroke
object is so lightweight that it should not be a big issue to create
them on the fly as needed to render and when the final parameters are
known.  Such an application should not need to store any of these
objects longer than it takes to pass them into a setStroke() method
on a graphics object.  Resource utilization is only about 24 bytes
per object.

                                ...jim

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 2D Home Page: http://java.sun.com/products/java-media/2D/

Reply via email to