|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.graphics.StrokeFormat
The StrokeFormat class represents a format for lines. This format
consists of the following attributes:
The style attribute defines the pattern the line is drawn with.
The different styles StrokeFormat provides are as follows:
The weight attribute defines the thickness the line is drawn with. It can be
freely chosen and is given in device units. The weight is used for each of
the different styles the StrokeFormat provides.
The color attribute defines the color the line is drawn with. The color is
represented by an int that defines the values for the red, green
and blue components as illustrated by the following hexadecimal pattern:
0x00rrggbb
where rr stands for the red component, gg stands for the green component and
bb stands for the blue component of the color.
The custom pattern attribute defines the pattern of the stroke by setting the length of the segments that should be drawn or skipped.
Since the StrokeFormat is an object that is frequently used
within the graphics framework and all frameworks that use the
graphics framework StrokeFormats are subject of
pooling. The pooling of the StrokeFormat instances is being done
by the FormatPool. To get more informations about this class
take a look at the documentation about the FormatPool.
In order to pool a StrokeFormat it has to be immutable because
maybe many objects have a reference on the same StrokeFormat and
modifying the StrokeFormat will affect all these objects.
For the pooling also an unique expression is needed so that a
StrokeFormat can be surely identified. The unique expression is
called the canonical description. This canonical description is made up of
the attributes a StrokeFormat consists of and it can be gained
by Format.getCanonicalDescription().
An instance of class StrokeFormat can only be created by using the
FormatPool.parseStrokeFormat(String) method to
ensure a correct pooling behavior. You can obtain the canonical description
by calling the on of the static methods called getCanonicalDescription().
A StrokeFormat is usually applied to a Primitive
by calling the Primitive.setStroke(StrokeFormat) method.
| Field Summary | |
protected static java.lang.String |
CANONIC_DESCRIPTION_DELIMITER
constant needed as delimitier for the canonical description |
static StrokeFormat |
DEFAULT_STROKE_FORMAT
constant for a default stroke format |
static StrokeFormat |
NULL_STROKE_FORMAT
constant for an invisible stroke format |
protected static java.lang.String |
PATTERN_DESCRIPTION_DELIMITER
constant needed as delimitier for the canonical description |
static int |
STYLE_CONTINUOUS
constant that tells about a style StrokeFormat provides |
static int |
STYLE_CUSTOM
constant that tells about a style StrokeFormat provides |
static int |
STYLE_DASH
constant that tells about a style StrokeFormat provides |
static int |
STYLE_DASHDOT
constant that tells about a style StrokeFormat provides |
static int |
STYLE_DASHDOTDOT
constant that tells about a style StrokeFormat provides |
static int |
STYLE_DOT
constant that tells about a style StrokeFormat provides |
static int |
STYLE_INVISIBLE
constant that tells about a style StrokeFormat provides |
static int |
STYLE_MAX
constant that indicates the maximum number of predefined styles |
protected static java.lang.String |
TOKEN_COLOR
constant that tells about a token of the canonical description |
protected static java.lang.String |
TOKEN_PATTERN
constant that tells about a token of the canonical description |
protected static java.lang.String |
TOKEN_STYLE
constant that tells about a token of the canonical description |
protected static java.lang.String |
TOKEN_WEIGHT
constant that tells about a token of the canonical description |
static int |
WEIGHT_HAIRLINE
constant that tells about a weight StrokeFormat provides |
| Method Summary | |
static double[] |
createPattern(int style,
int weight,
double[] customPattern)
Creates a pattern representing the given style. |
boolean |
equals(java.lang.Object o)
|
java.lang.String |
getCanonicalDescription()
Returns the canonical description of a StrokeFormat. |
static java.lang.String |
getCanonicalDescription(int style,
int weight,
int color)
Returns the canonical description of a StrokeFormat. |
static java.lang.String |
getCanonicalDescription(int style,
int weight,
int color,
double[] pattern)
Returns the canonical description of a StrokeFormat. |
static java.lang.String |
getCanonicalDescription(java.lang.String style,
java.lang.String weight,
java.lang.String color,
java.lang.String pattern)
Returns the canonical description of a StrokeFormat. |
int |
getColor()
Returns the color that is used to draw a line. |
double[] |
getCustomPattern()
Returns the pattern as a double array. |
java.lang.String |
getCustomPatternString()
Returns the string representation of the pattern of this instance. |
static double[] |
getDefaultPattern()
Returns the default pattern as a double array. |
java.lang.Object[] |
getFormatData()
Returns an array filled with the attributes of the StrokeFormat. |
double[] |
getPattern()
Returns the pattern that should be used for drawing. |
int |
getStyle()
Returns the style of the StrokeFormat. |
int |
getWeight()
Returns the weight of the StrokeFormat. |
int |
hashCode()
|
boolean |
isVisible()
Returns a boolean that indicates whether is format defines a
visible line or not. |
static java.lang.String |
patternToString(double[] pattern)
Converts a given double array of segment lengths to the string representation of a pattern. |
static double[] |
stringToPattern(java.lang.String tokenPattern)
Converts a given string representation of a pattern to the double array of segment lengths. |
java.lang.String |
toString()
Returns a String that represent the
StrokeFormat and all of the attributes of it. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int STYLE_INVISIBLE
StrokeFormat provides
public static final int STYLE_CONTINUOUS
StrokeFormat provides
public static final int STYLE_DASH
StrokeFormat provides
public static final int STYLE_DASHDOT
StrokeFormat provides
public static final int STYLE_DASHDOTDOT
StrokeFormat provides
public static final int STYLE_DOT
StrokeFormat provides
public static final int STYLE_CUSTOM
StrokeFormat provides
public static final int STYLE_MAX
public static final int WEIGHT_HAIRLINE
StrokeFormat provides
protected static final java.lang.String CANONIC_DESCRIPTION_DELIMITER
protected static final java.lang.String PATTERN_DESCRIPTION_DELIMITER
protected static final java.lang.String TOKEN_STYLE
protected static final java.lang.String TOKEN_WEIGHT
protected static final java.lang.String TOKEN_COLOR
protected static final java.lang.String TOKEN_PATTERN
public static final StrokeFormat DEFAULT_STROKE_FORMAT
public static final StrokeFormat NULL_STROKE_FORMAT
| Method Detail |
public int getStyle()
StrokeFormat. The possible styles
are given by the style constants defined in this class.
StrokeFormatpublic double[] getCustomPattern()
public double[] getPattern()
public java.lang.String getCustomPatternString()
public int getWeight()
StrokeFormat. The returned value
is either WEIGHT_HAIRLINE that defines a thickness of one pixel
or an int value greater than zero that defines the tickness
of the line in device units.
int value greater than
zero that defines the thickness of the linepublic int getColor()
int that defines the values for the red, green and
blue components as illustrated by the following hexadecimal pattern:
public boolean isVisible()
boolean that indicates whether is format defines a
visible line or not.
public java.lang.Object[] getFormatData()
StrokeFormat. The indices of the attributes are given by
constants defined in this class. This array is used by
Renderers and Devices. To get more information
about this objects take a look at the documentation of
Renderer and
Device
StrokeFormatpublic java.lang.String getCanonicalDescription()
StrokeFormat. For
instance this description is used for the pooling of
StrokeFormats. It can also be used to compare two instances
of a StrokeFormat.
getCanonicalDescription in interface Formatpublic java.lang.String toString()
String that represent the
StrokeFormat and all of the attributes of it. For instance
this representation can be used for tracing purposes and such.
toString in interface FormatStrokeFormat.public int hashCode()
public boolean equals(java.lang.Object o)
public static final java.lang.String getCanonicalDescription(int style,
int weight,
int color)
StrokeFormat. For
instance this description is used for the pooling of
StrokeFormats. It can also be used to compare two instances
of a StrokeFormat.
style - the style of a StrokeFormatweight - the weight of a StrokeFormatcolor - the color of a StrokeFormat
StrokeFormat.
public static final java.lang.String getCanonicalDescription(int style,
int weight,
int color,
double[] pattern)
StrokeFormat. For
instance this description is used for the pooling of
StrokeFormats. It can also be used to compare two instances
of a StrokeFormat.
style - the style of a StrokeFormatweight - the weight of a StrokeFormatcolor - the color of a StrokeFormatpattern - the pattern to use for custom style
StrokeFormat.
public static final java.lang.String getCanonicalDescription(java.lang.String style,
java.lang.String weight,
java.lang.String color,
java.lang.String pattern)
StrokeFormat. For
instance this description is used for the pooling of
StrokeFormats. It can also be used to compare two instances
of a StrokeFormat.
style - the style of a StrokeFormatweight - the weight of a StrokeFormatcolor - the color of a StrokeFormatpattern - the pattern to use, use patternToString() to obtain
this string representation
StrokeFormatpublic static double[] stringToPattern(java.lang.String tokenPattern)
tokenPattern - The string representation of a pattern
public static java.lang.String patternToString(double[] pattern)
pattern - The double array with segment lengths
public static final double[] getDefaultPattern()
public static final double[] createPattern(int style,
int weight,
double[] customPattern)
style - the style of the strokeweight - the weight of the strokecustomPattern - the pattern to use for custom style
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||