com.tensegrity.graphics
Class PaintFormat

java.lang.Object
  extended bycom.tensegrity.graphics.PaintFormat
All Implemented Interfaces:
Format

public final class PaintFormat
extends java.lang.Object
implements Format

PaintFormat represents a format for area fillings. This format consists of the following attributes:

The style attribute defines the fashion the area is filled out. The different styles PaintFormat provides are as follows.

The background color attribute defines the background color for the area filling. It is used with the following styles.

ConstantDescription
FILL_SOLID the color the area is filled with
FILL_GRADIENT the first color used to render the gradient
FILL_PATTERN the background color for the pattern
The background 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 foreground color attribute defines the foreground color for the area filling. It is used with the following styles:

ConstantDescription
FILL_GRADIENT the second color used to render the gradient
FILL_PATTERN the color used for the pattern
The foreground 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 gradient type attribute defines the type of the gradient the area is filled with. To get more informations about gradients and what types of gradients are selectable see the documentation of the Gradient class. Notice that the gradient type attribute is only used when the style of the PaintFormat is set to FILL_GRADIENT.

The pattern type attribute defines the type of the pattern the area is filled with. To get more informations about patterns and what types of pattern are selectable see the documentation of the Pattern class. Notice that the pattern type attribute is only used when the style of the PaintFormat is set to FILL_PATTERN.

The transparent flag indicates whether the filling of the area should be transparent or not.

The transparency value attribute defines the value of transparency for the area filling. This value is given in percent where zero percent means that the filling is not transparent and one hundred percent means that the filling is completely transparent.

Since the PaintFormat is an object that is frequently used within the graphics framework and all frameworks that use the graphics framework PaintFormats are subject of pooling. The pooling of the PaintFormat instances is being done by the FormatPool. To get more information about this class take a look at the documentation about the FormatPool.

In order to pool a PaintFormat it has to be immutable because maybe many objects have a reference on the same PaintFormat and modifying the PaintFormat will affect all these objects.

For the pooling also an unique expression is needed so that a PaintFormat can be surely identified. The unique expression is called the canonical description. This canonical description is made up of the attributes a PaintFormat consists of and it can be gained by Format.getCanonicalDescription().

A PaintFormat can only be created by using the FormatPool.parsePaintFormat(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 PaintFormat is usually applied to a Primitive by calling the Primitive.setPaint(PaintFormat) method.

A PaintFormat provides the following attributes:

Version:
$Id: PaintFormat.java,v 1.58 2006/06/08 12:14:53 MichaelKegel Exp $
Author:
M. Kegel

Field Summary
protected static java.lang.String CANONIC_DESCRIPTION_DELIMITER
          constant needed as delimitier for the canonical description
static PaintFormat DEFAULT_PAINT_FORMAT_BLACK
          constant for a default paint format
static PaintFormat DEFAULT_PAINT_FORMAT_NULL
          constant for a default paint format
static PaintFormat DEFAULT_PAINT_FORMAT_TEXTRETOUCHING
          constant for a default paint format
static PaintFormat DEFAULT_PAINT_FORMAT_WHITE
          constant for a default paint format
static int FILL_GRADIENT
          A gradient is used for area fills.
static int FILL_INVISIBLE
          Areas are left empty.
static int FILL_PATTERN
          A pattern is used for area fills..
static int FILL_SOLID
          Areas get filled with one color.
static int FILL_TEXTURE
          Areas are left empty.
static int STYLE_MAX
          constant that indicates the maximum number of predefined styles
static java.lang.String TEXTURE_NONE
          Constant for the texture attribute when no texture is assigned
protected static java.lang.String TOKEN_COLORBACK
          enumeration that tells about the canonical description tokens
protected static java.lang.String TOKEN_COLORFORE
          enumeration that tells about the canonical description tokens
protected static java.lang.String TOKEN_GRADIENTTYPE
          enumeration that tells about the canonical description tokens
protected static java.lang.String TOKEN_PATTERNTYPE
          enumeration that tells about the canonical description tokens
protected static java.lang.String TOKEN_STYLE
          enumeration that tells about the canonical description tokens
protected static java.lang.String TOKEN_TEXTURERASTERKEY
          enumeration that tells about the canonical description tokens
protected static java.lang.String TOKEN_TRANSPARENCY
          enumeration that tells about the canonical description tokens
protected static java.lang.String TOKEN_TRANSPARENT
          enumeration that tells about the canonical description tokens
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.String getCanonicalDescription()
          Returns the canonical description of a PaintFormat.
static java.lang.String getCanonicalDescription(int style, int colorback, int colorfore, int gradienttype, int patterntype, int transparency, boolean transparent)
          Returns the canonical description of a PaintFormat.
static java.lang.String getCanonicalDescription(int style, int colorback, int colorfore, int gradienttype, int patterntype, java.lang.String texturerasterkey, int transparency, boolean transparent)
          Returns the canonical description of a PaintFormat.
static java.lang.String getCanonicalDescription(java.lang.String style, java.lang.String colorback, java.lang.String colorfore, java.lang.String gradienttype, java.lang.String patterntype, java.lang.String texturerasterkey, java.lang.String transparency, java.lang.String transparent)
          Returns the canonical description of a PaintFormat.
 int getColor()
          Returns the background color of the PaintFormat.
 int getColorFore()
          Returns the foreground color of the PaintFormat.
 java.lang.Object[] getFormatData()
          Returns an array filled with the attributes of the PaintFormat.
 int getGradientType()
          Return the gradient type of the PaintFormat.
 int getPatternType()
          Returns the pattern type of the PaintFormat.
 int getStyle()
          Returns the style of the PaintFormat.
 java.lang.String getTextureRasterKey()
          Returns the key used within the ImagePool of the texture raster if a texture is used or TEXTURE_NONE if no texture is used.
static java.lang.String getTextureRasterKey(Texture texture)
          Returns the key for the Texture given by texture that is used within the ImagePool to pool the raster of the given Texture.
 int getTransparency()
          Returns the transparency value of the PaintFormat.
 boolean getTransparent()
          Returns a boolean that indicates whether the transparency is turned of or off.
 int hashCode()
           
 boolean isVisible()
          Returns a boolean that indicates whether the PaintFormat is visible or not.
 java.lang.String toString()
          Returns a String that represent the PaintFormat and all of the attributes of it.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FILL_INVISIBLE

public static final int FILL_INVISIBLE
Areas are left empty.

See Also:
Constant Field Values

FILL_SOLID

public static final int FILL_SOLID
Areas get filled with one color.

See Also:
Constant Field Values

FILL_GRADIENT

public static final int FILL_GRADIENT
A gradient is used for area fills.

See Also:
Constant Field Values

FILL_PATTERN

public static final int FILL_PATTERN
A pattern is used for area fills..

See Also:
Constant Field Values

FILL_TEXTURE

public static final int FILL_TEXTURE
Areas are left empty.

See Also:
Constant Field Values

TEXTURE_NONE

public static final java.lang.String TEXTURE_NONE
Constant for the texture attribute when no texture is assigned

See Also:
Constant Field Values

STYLE_MAX

public static final int STYLE_MAX
constant that indicates the maximum number of predefined styles

See Also:
Constant Field Values

DEFAULT_PAINT_FORMAT_WHITE

public static final PaintFormat DEFAULT_PAINT_FORMAT_WHITE
constant for a default paint format


DEFAULT_PAINT_FORMAT_BLACK

public static final PaintFormat DEFAULT_PAINT_FORMAT_BLACK
constant for a default paint format


DEFAULT_PAINT_FORMAT_NULL

public static final PaintFormat DEFAULT_PAINT_FORMAT_NULL
constant for a default paint format


DEFAULT_PAINT_FORMAT_TEXTRETOUCHING

public static final PaintFormat DEFAULT_PAINT_FORMAT_TEXTRETOUCHING
constant for a default paint format


CANONIC_DESCRIPTION_DELIMITER

protected static final java.lang.String CANONIC_DESCRIPTION_DELIMITER
constant needed as delimitier for the canonical description

See Also:
Constant Field Values

TOKEN_STYLE

protected static final java.lang.String TOKEN_STYLE
enumeration that tells about the canonical description tokens

See Also:
Constant Field Values

TOKEN_COLORBACK

protected static final java.lang.String TOKEN_COLORBACK
enumeration that tells about the canonical description tokens

See Also:
Constant Field Values

TOKEN_COLORFORE

protected static final java.lang.String TOKEN_COLORFORE
enumeration that tells about the canonical description tokens

See Also:
Constant Field Values

TOKEN_GRADIENTTYPE

protected static final java.lang.String TOKEN_GRADIENTTYPE
enumeration that tells about the canonical description tokens

See Also:
Constant Field Values

TOKEN_PATTERNTYPE

protected static final java.lang.String TOKEN_PATTERNTYPE
enumeration that tells about the canonical description tokens

See Also:
Constant Field Values

TOKEN_TEXTURERASTERKEY

protected static final java.lang.String TOKEN_TEXTURERASTERKEY
enumeration that tells about the canonical description tokens

See Also:
Constant Field Values

TOKEN_TRANSPARENCY

protected static final java.lang.String TOKEN_TRANSPARENCY
enumeration that tells about the canonical description tokens

See Also:
Constant Field Values

TOKEN_TRANSPARENT

protected static final java.lang.String TOKEN_TRANSPARENT
enumeration that tells about the canonical description tokens

See Also:
Constant Field Values
Method Detail

getStyle

public int getStyle()
Returns the style of the PaintFormat. The possible styles are given by the style constants defined in this class.

Returns:
the style of the PaintFormat

getColor

public int getColor()
Returns the background color of the PaintFormat.

Returns:
the background color used for filling an area.

getColorFore

public int getColorFore()
Returns the foreground color of the PaintFormat.

Returns:
the foreground color used for filling an area.

getGradientType

public int getGradientType()
Return the gradient type of the PaintFormat.

Returns:
the type of the gradient

getPatternType

public int getPatternType()
Returns the pattern type of the PaintFormat.

Returns:
the type of the gradient

getTextureRasterKey

public java.lang.String getTextureRasterKey()
Returns the key used within the ImagePool of the texture raster if a texture is used or TEXTURE_NONE if no texture is used.

Returns:
String the key of the textures raster used within the ImagePool or TEXTURE_NONE if no texture is used

getTransparency

public int getTransparency()
Returns the transparency value of the PaintFormat.

Returns:
the transparency used for filling an area

getTransparent

public boolean getTransparent()
Returns a boolean that indicates whether the transparency is turned of or off.

Returns:
a boolean that indicates whether the transparency is turned of or off

isVisible

public boolean isVisible()
Returns a boolean that indicates whether the PaintFormat is visible or not.

Returns:
a boolean that indicates if the area filling is visible or not.

getFormatData

public java.lang.Object[] getFormatData()
Returns an array filled with the attributes of the PaintFormat. 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

Returns:
a array with the attributes if the PaintFormat.

getCanonicalDescription

public java.lang.String getCanonicalDescription()
Returns the canonical description of a PaintFormat. For instance this description is used for the pooling of PaintFormats. It can also be used to compare two instances of a PaintFormat.

Specified by:
getCanonicalDescription in interface Format
Returns:
the canonical description of a PaintFormat

toString

public java.lang.String toString()
Returns a String that represent the PaintFormat and all of the attributes of it. For instance this representation can be used for tracing purposes and such.

Specified by:
toString in interface Format
Returns:
String the textual representation of the PaintFormat

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object o)

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(int style,
                                                             int colorback,
                                                             int colorfore,
                                                             int gradienttype,
                                                             int patterntype,
                                                             int transparency,
                                                             boolean transparent)
Returns the canonical description of a PaintFormat. For instance this description is used for the pooling of PaintFormats. It can also be used to compare two instances of a PaintFormat.

Parameters:
style - the style of a PaintFormat
colorback - the background colorback of a PaintFormat
colorfore - the foreground colorback of a PaintFormat
gradienttype - the gradient type of a PaintFormat
patterntype - the pattern type of a PaintFormat
transparency - the transparency of a PaintFormat
transparent - flag that indicates weather transparency of a PaintFormat is turned on or off.
Returns:
the canonical description of a PaintFormat

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(int style,
                                                             int colorback,
                                                             int colorfore,
                                                             int gradienttype,
                                                             int patterntype,
                                                             java.lang.String texturerasterkey,
                                                             int transparency,
                                                             boolean transparent)
Returns the canonical description of a PaintFormat. For instance this description is used for the pooling of PaintFormats. It can also be used to compare two instances of a PaintFormat.

Parameters:
style - the style of a PaintFormat
colorback - the background colorback of a PaintFormat
colorfore - the foreground colorback of a PaintFormat
gradienttype - the gradient type of a PaintFormat
patterntype - the pattern type of a PaintFormat
texturerasterkey - the key used within the ImagePool for the raster of the texture or null if no texture is used
transparency - the transparency of a PaintFormat
transparent - flag that indicates weather transparency of a PaintFormat is turned on or off.
Returns:
the canonical description of a PaintFormat

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(java.lang.String style,
                                                             java.lang.String colorback,
                                                             java.lang.String colorfore,
                                                             java.lang.String gradienttype,
                                                             java.lang.String patterntype,
                                                             java.lang.String texturerasterkey,
                                                             java.lang.String transparency,
                                                             java.lang.String transparent)
Returns the canonical description of a PaintFormat. For instance this description is used for the pooling of PaintFormats. It can also be used to compare two instances of a PaintFormat.

Parameters:
style - the style of a PaintFormat
colorback - the background colorback of a PaintFormat
colorfore - the foreground colorback of a PaintFormat
gradienttype - the gradient type of a PaintFormat
patterntype - the pattern type of a PaintFormat
texturerasterkey - the key used within the ImagePool for the raster of the texture or null if no texture is used
transparency - the transparency of a PaintFormat
transparent - flag that indicates weather transparency of a PaintFormat is turned on or off.
Returns:
the canonical description of a PaintFormat

getTextureRasterKey

public static final java.lang.String getTextureRasterKey(Texture texture)
Returns the key for the Texture given by texture that is used within the ImagePool to pool the raster of the given Texture.

Parameters:
texture - the Texture instance to return the key for
Returns:
the key for the given Texture instance


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.