java.lang.Object
org.bzdev.obnaming.misc.BasicStrokeParm
- Direct Known Subclasses:
BasicStrokeParm.FOUR
,BasicStrokeParm.NULL_WHEN_ZERO
,BasicStrokeParm.ONE
,BasicStrokeParm.THREE
,BasicStrokeParm.TWO
,BasicStrokeParm.ZERO
Obnaming factory support class for java.awt.BasicStroke.
Parameter names will be compound names, typically using a period as a separator. When this class is used, multiple parameter-name components will be defined, and the last component of the parameter name will be the following:
- "cap" - an enumeration constant specified by
the enumeration
BasicStrokeParm.Cap
whose values areBUTT
,ROUND
, andSQUARE
- "join" - an enumeration constant specified by
the enumeration
BasicStrokeParm.Join
whose values areBEVEL
,MITER
, andROUND
. - "width" - the line width.
- "miterLimit" - the limit such that a line join is trimmed when the ratio of miter length to stroke width is greater than this value. The miter length is the diagonal length of the miter, which is the distance between the inside corner and the outside corner of the intersection. The smaller the angle formed by two line segments, the longer the miter length and the sharper the angle of intersection. The default miterlimit value of 10.0 causes all angles less than 11 degrees to be trimmed. Trimming miters converts the decoration of the line join to a bevel. This value applies only to a line join that has a MITER join decoration and must be larger than or equal to 1.0
- "dashPhase" - the offset to start the dashing pattern.
- "dashIncrement" - the length corresponding to a space ' ' or minus sign '-' in a dash pattern.
- "dashPattern" - the dash pattern, represented by a string. If the string has a length of zero, the line is solid. Otherwise the pattern should be represented by a sequence of "-" or " " giving the length of dashes or empty space respectively as multiples of the value of dashIncrement. Each "-" and each " " represents a component of a segment whose length is dashIncrement. Thus, if dashIncrement is 10.0, then the pattern "-- - " will consist of a dash of length 20.0, a space of length 10.0, a dash of length 10.0, and a space of length 10.0, with the pattern repeating as needed. Unless the string is empty, it must start with a "-". Note that a dash phase can be used to make it look like the pattern started with a blank: spaces may appear at the end of the string.
- "gcsMode" - a boolean that, when true, indicates that the width, dashPhase, and dashIncrement are provided in graph coordinate space, not user space. The default is 'false'.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
End cap class.static final class
A BasicStrokeParm configured so that, unless the stroke is modified,createBasicStroke()
will return a stroke whose width is 4.0.static enum
Class specifying enumation constants defining how lines are joined.static final class
A BasicStrokeParm configured so that, unless the stroke is modified,createBasicStroke()
will return null (for a zero-width stroke).static final class
A BasicStrokeParm configured so that, unless the stroke is modified,createBasicStroke()
will return a stroke whose width is 1.0.static final class
A BasicStrokeParm configured so that, unless the stroke is modified,createBasicStroke()
will return a stroke whose width is 3.0.static final class
A BasicStrokeParm configured so that, unless the stroke is modified,createBasicStroke()
will return a stroke whose width is 2.0.static final class
A BasicStrokeParm configured so that, unless the stroke is modified,createBasicStroke()
will return a stroke whose width is zero. -
Field Summary
FieldsModifier and TypeFieldDescriptionSpecification for how lines or line segments are capped.double
The length corresponding to a "-" or " " in a dashPattern.The dash pattern.double
The offset to start the dashing pattern.boolean
Flag to indicate if widths or lengths are provided in graph-coordinate-space units.Specification for how lines or line segments are joined.double
The limit so that line joins are trimmed when the ratio of miter length to stroke width is greater than this value.double
The line width. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.BasicStrokeParm
(boolean zeroWidth) Construct specifying handling of zero width strokes.BasicStrokeParm
(double width) Constructor given a line width. -
Method Summary
Modifier and TypeMethodDescriptionCreate a basic stroke.static float[]
getDashArray
(String dashPattern, double dashIncrement) Get an array that represents a dash pattern.boolean
Indicate if widths or lengths are provided in graph-coordinate-space units.
-
Field Details
-
cap
Specification for how lines or line segments are capped.- See Also:
-
width
public double widthThe line width. -
join
Specification for how lines or line segments are joined.- See Also:
-
miterLimit
public double miterLimitThe limit so that line joins are trimmed when the ratio of miter length to stroke width is greater than this value. The miter length is the diagonal length of the miter, which is the distance between the inside corner and the outside corner of the intersection. The smaller the angle formed by two line segments, the longer the miter length and the sharper the angle of intersection. The default miterlimit value of 10.0 causes all angles less than 11 degrees to be trimmed. Trimming miters converts the decoration of the line join to a bevel. This values applies only to a line join that has a MITER join decoration. The miter limit, if provided, must have a value no smaller than or equal to 1.0.- See Also:
-
dashPhase
public double dashPhaseThe offset to start the dashing pattern. -
dashIncrement
public double dashIncrementThe length corresponding to a "-" or " " in a dashPattern. -
dashPattern
The dash pattern. If null or of zero length, the line is solid. Otherwise the pattern should be represented by a sequence of "-" or " " giving the length of dashes or empty space respectively as multiples of the value of dashIncrement. Each "-
" and each "-- -
" will consist of a dash of length 20.0, a space of length 20.0, a dash of length 10.0, and a space of length 10.0, with the pattern repeating as needed. -
gcsMode
public boolean gcsModeFlag to indicate if widths or lengths are provided in graph-coordinate-space units. If true, the stroke created should be used for a graphic context that includes a transform from graph coordinate space to user space.
-
-
Constructor Details
-
BasicStrokeParm
public BasicStrokeParm()Constructor. The default stroke width is 1.0. -
BasicStrokeParm
public BasicStrokeParm(boolean zeroWidth) Construct specifying handling of zero width strokes.- Parameters:
zeroWidth
- true if the width should be zero and ifcreateBasicStroke()
should return null for zero-width strokes; false otherwise, in which case the width will have an initial value of 1.0
-
BasicStrokeParm
public BasicStrokeParm(double width) Constructor given a line width.- Parameters:
width
- the line width
-
-
Method Details
-
getGcsMode
public boolean getGcsMode()Indicate if widths or lengths are provided in graph-coordinate-space units. If true, the stroke created should be used for a graphic context that includes a transform from graph coordinate space to user space.- Returns:
- true if the basic stroke created is intended for graph coordinate space; false if it is intended for user space
-
getDashArray
public static float[] getDashArray(String dashPattern, double dashIncrement) throws IllegalArgumentException Get an array that represents a dash pattern. A dash pattern consists of a string whose characters are either a minus sign ("-") or a space (" "), starting with a "-". An empty string, a string of zero length, or a string containing only "-" characters is ignored and a null value will be returned. Otherwise a dash pattern must start with a '-' and end with a space. A pattern ending with a '-' is not necessary as the dashPhase parameter can be used to create the same effect. A sequence of "-" characters represents a dash whose length is the number of characters in that sequence multiplied by the dash increment. Similarly, a sequence of " " characters represents a gap whose length is the number of characters in that sequence multiplied by the dash increment. The array returned provides the pattern of alternating opaque and transparent segments used by classes such asBasicStroke
.- Parameters:
dashPattern
- the dash patterndashIncrement
- the length corresponding to a character in a dash pattern- Returns:
- an array representing a dash pattern
- Throws:
IllegalArgumentException
- the dashInrement argument was not positive or the dashPattern argument was illegal
-
createBasicStroke
Create a basic stroke. The basic stroke will use the parameters defined by the fieldswidth
,cap
,join
,miterLimit
,dashPhase
,dashIncrement
, anddashPattern
.- Returns:
- the stroke; null if the width is 0.0 and this class is configured to return null in that case
-