com.davisor.graphics
Class RenderAttributes

java.lang.Object
  extended bycom.davisor.graphics.RenderAttributes
All Implemented Interfaces:
com.davisor.core.Dupable, java.io.Serializable
Direct Known Subclasses:
AxisRenderAttributes, BackRenderAttributes, LegendRenderAttributes, LineRenderAttributes, MarkerRenderAttributes

public class RenderAttributes
extends java.lang.Object
implements com.davisor.core.Dupable, java.io.Serializable

Render attributes.

RenderAttributes represents one or more generic sets of render attributes. The attributes are stored in attribute type spesific arrays where the attributes with mutually equal array indexes form an attribute set. It is up to the programmer that uses RenderAttributes to decide how many sets there are, and to what they apply.

All of the attributes are considered immutable, including Shape and Stroke objects, which are mere interfaces. This particularly affects render attribute dupping, which uses the render attributes' shallow copy constructor.

Attributes

An attribute set contains the following attribute types:

Alignment

The alignment attribute represents the general alignment of a relevant object, like text or a graphics object. The possible alignment values defined by the corresponding constants of this class are:

Plane alignment keywords:

Diagonal alignment keywords:

In/out placement keywords:

Use getAlignment(int) and setAlignment(int,int) to access alignment values, and toAlignment(String) and toAlignment(int) to convert them to and from strings. To use the values of these three groups together, do bitwise-OR for alignment values or concatenate strings with separating hyphen ('-').

Antialias mode

While render attributes do not actually record antialias mode parameters, this class provides a tool to convert antialias mode keywords to antialias mode keycodes, and vice versa. The possible antialias mode values are:

Color

The color attribute represents a "foreground" color that is typically used to render points, lines, text and borders. Applications may, however, use the color attribute for any purpose they want. Colors are represented by Java Paint objects, because Paint objects are more general, yet compatible with Color objects.

Use getColor(int) and setColor(int,Paint) to access color values.

Composite

Composite is the draw composite operation, as defined by the Java 2D framework.

Use getComposite(int) and setComposite(int,Composite) to access composite values.

Font

Font represents text fonts.

Use getFont(int) and setFont(int,Font) to access font values.

Paint

The paint attribute represents a "background" or "fill" color that is typically used to paint shapes, rectangles and other interior areas. Applications may, however, use the paint attribute for any purpose they want.

Use getPaint(int) and setPaint(int,Paint) to access paint values.

Shape

The shape attribute represents a drawable shape.

Use getShape(int) and setShape(int,Shape) to access shape values.

Stroke

The stroke attribute represents the line width and style.

Use getStroke(int) and setStroke(int,Stroke) to access stroke values.

Default values

Render attributes may use another set of render attributes as default values. If a default set of render attributes has been defined, those default values are used whenever the actual attribute value would be null (or UNSET). However, this does not guarantee a non-null value, because the default attribute may also be null.

Like other attributes, the set of default attributes, as a whole, is immutable from the master render attribute object point of view. There is particularly no way to access the default attribute object once it is set. Even so, a direct reference to the defaults object enables for the default values to change by external means.

With the default attribute mechanism, more than two render attributes may be arranged into a chain (or even a loop) of attributes that default to each other. However, if all members in a loop have null values, the program will remain in an infinite loop.

Runtime control

In addition to the actual render attributes, there are also two runtime control attributes that define how instances of this class behave in certain typical attribute set selection situations. Sub-classes in particular may find these atributes helpfull. The runtime control attributes in question are:

defaultIndex promotes one of the render attributes indexes above others, to be used as a default index value in variety of applicable situations.

Since:
JDK1.2
See Also:
Serialized Form

Field Summary
protected static com.davisor.core.Index ANTIALIASINDEX
           
static java.lang.String[] ANTIALIASWORDS
          Antialias mode keywords.
static int AUTO
          Antialiasing control value (enabled or disabled automatically).
static int BACK
          Back alignment key.
static int CEILING
          Ceiling alignment key (UP and HORIZONTAL).
static int CENTER
          Center alignment key (LEFT and RIGHT and UP and DOWN).
static int DIAGONAL
          Diagonal alignment key (FRONT and BACK).
static int DOWN
          Down alignment key (8).
static int FLOOR
          Floor alignment key (DOWN and HORIZONTAL).
static int FRONT
          Front alignment key.
static int GRAPHICS
          Antialiasing control value (at least graphics enabled).
static int HORIZONTAL
          Horizontal alignment key (LEFT and RIGHT).
static int INSIDE
          Inside alignment key.
static int LEFT
          Left alignment key (1).
static int LEFTWALL
          Vertical left alignment key (LEFT and VERTICAL).
static java.awt.geom.Line2D LINE
          Vertical unit line.
protected  int[] M_alignment
          Alignment array (never null, but values may be UNSET).
protected  java.awt.Paint[] M_color
          Color attribute (may be null).
protected  java.awt.Composite[] M_composite
          Composite attribute (may be null).
protected  int M_defaultIndex
          Default index for searching a value (0).
protected  RenderAttributes M_defaults
          Default attributes (may be null).
protected  java.awt.Font[] M_font
          Font attribute (may be null).
protected  java.awt.Paint[] M_paint
          Paint attribute (may be null).
protected  java.awt.Shape[] M_shape
          Shape attribute (may be null).
protected  int M_size
          Array length for attributes.
protected  java.awt.Stroke[] M_stroke
          Stroke attribute (may be null).
static int NE
          North-east alignment key (UP and RIGHT).
static int NONE
          Void default index value.
static int NW
          North-west alignment key (UP and LEFT).
static int OFF
          Antialiasing control value (disabled).
static int ON
          Antialiasing control value (enabled).
static int OUTSIDE
          Outside alignment key.
static int RIGHT
          Right alignment key (2).
static int RIGHTWALL
          Vertical right alignment key (RIGHT and VERTICAL).
static int SE
          South-east alignment key (DOWN and RIGHT).
static int SW
          South-west alignment key (DOWN and LEFT).
static int TEXT
          Antialiasing control value (at least text enabled).
static int THROUGH
          Through alignment key (INSIDE and OUTSIDE).
static int UNSET
          Unset code key (0).
static int UP
          Up alignment key (4).
static int VERTICAL
          Vertical alignment key (UP and DOWN).
 
Constructor Summary
RenderAttributes(int size)
          Creates a render attribute set with the given number of elements.
RenderAttributes(int size, RenderAttributes defaults)
          Creates a render attribute set with the given defaults and number of elements.
RenderAttributes(int size, RenderAttributes defaults, int defaultIndex)
          Creates a render attribute set with the given control attributes and number of elements.
RenderAttributes(int size, RenderAttributes defaults, int defaultIndex, java.awt.Paint[] colors, java.awt.Paint[] paints, java.awt.Stroke[] strokes, java.awt.Shape[] shapes, java.awt.Font[] fonts, int[] alignments, java.awt.Composite[] composites)
          Creates a render attributes set with the given initial attribute values.
RenderAttributes(int size, RenderAttributes defaults, int defaultIndex, java.awt.Paint color, java.awt.Paint paint, java.awt.Stroke stroke, java.awt.Shape shape, java.awt.Font font, int alignment, java.awt.Composite composite)
          Creates a render attributes set with the given initial default attribute values.
RenderAttributes(RenderAttributes ra)
          Shallow copy constructor.
RenderAttributes(RenderAttributes ra, RenderAttributes defaults)
          Shallow copy constructor, with explicitly given default values.
 
Method Summary
 com.davisor.core.Dupable dup()
          Duplicates this object.
 boolean equals(java.lang.Object object)
          Test if these render attributes equal to given render attributes.
static int exchangeOrientation(int alignment)
          Exchange horizontal and vertical alignment components.
 int[] getAlignment()
          Gets all alignment attributes.
 int getAlignment(int index)
          Gets the alignment attribute.
 int getAlignment(int index, boolean useLocalDefault)
          Like getAlignment(int) but allows defining whether to use local default defined by default index or not.
 java.awt.Paint[] getColor()
          Gets all color attributes.
 java.awt.Paint getColor(int index)
          Gets the color attribute of the given index.
 java.awt.Paint getColor(int index, boolean useLocalDefault)
          Gets the color attribute if the given index.
 java.awt.Composite[] getComposite()
          Gets all composite attributes.
 java.awt.Composite getComposite(int index)
          Gets the composite attribute of the given index.
 java.awt.Composite getComposite(int index, boolean useLocalDefault)
          Like getComposite(int) but allows defining whether to use local default defined by default index or not.
 int getDefaultAlignment()
          Gets default alignment attribute.
 java.awt.Paint getDefaultColor()
          Gets default color attribute.
 java.awt.Composite getDefaultComposite()
          Gets the default composite attribute.
 java.awt.Composite getDefaultComposite(int index)
          Gets the composite attribute of the given index with a non-null default value.
 java.awt.Font getDefaultFont()
          Gets default font attribute.
 java.awt.Paint getDefaultPaint()
          Gets default paint attribute.
 int getDefaults()
          Gets the number of recursive default value objects.
 java.awt.Shape getDefaultShape()
          Gets default shape attribute.
 java.awt.Stroke getDefaultStroke()
          Gets default stroke attribute.
 float getDefaultStrokeWidth()
          Gets default stroke line width.
static int getDiagonal(int alignment)
          Gets the diagonal component in given alignment.
 java.awt.Font[] getFont()
          Gets all font attributes.
 java.awt.Font getFont(int index)
          Gets the font attribute of the given index.
 java.awt.Font getFont(int index, boolean useLocalDefault)
          Like getFont(int) but allows defining whether to use local default defined by default index or not.
static int getHorizontal(int alignment)
          Gets the horizontal component in given alignment.
 java.awt.Paint[] getPaint()
          Gets all paint attributes.
 java.awt.Paint getPaint(int index)
          Gets the paint attribute of the given index.
 java.awt.Paint getPaint(int index, boolean useLocalDefault)
          Like getPaint(int) but allows defining whether to use local default defined by default index or not.
 java.awt.Shape[] getShape()
          Gets all shape attributes.
 java.awt.Shape getShape(int index)
          Gets the shape attribute of the given index.
 java.awt.Shape getShape(int index, boolean useLocalDefault)
          Like getShape(int) but allows defining whether to use local default defined by default index or not.
 java.awt.Stroke[] getStroke()
          Gets all stroke attributes.
 java.awt.Stroke getStroke(int index)
          Gets the stroke attribute of the given index.
 java.awt.Stroke getStroke(int index, boolean useLocalDefault)
          Like getStroke(int) but allows defining whether to use local default defined by default index or not.
 float getStrokeWidth(int index)
          Gets stroke line width of the given index.
static float getStrokeWidth(java.awt.Stroke stroke)
          Measures the line width of the given stroke.
static int getVertical(int alignment)
          Gets the vertical component in given alignment.
protected  void init(int size)
          Initializes attribute value tables.
static boolean isDown(int alignment)
          Tests if given alignment contains DOWN component.
static boolean isHorizontal(int alignment)
          Tests if given alignment is horizontally aligned.
static boolean isLeft(int alignment)
          Tests if given alignment contains LEFT component.
static boolean isRight(int alignment)
          Tests if given alignment contains RIGHT component.
static boolean isUp(int alignment)
          Tests if given alignment contains UP component.
static boolean isVertical(int alignment)
          Tests if given alignment is vertically aligned.
 void next()
          Rotates all color and paint palettes.
 void setAlignment(int alignment)
          Sets the default alignment attribute.
 void setAlignment(int[] alignment)
          Sets the alignment attribute for all elements.
 void setAlignment(int index, int alignment)
          Sets the alignment attribute.
 void setAlignment(int index, java.lang.String alignment)
          Sets the alignment attribute by keyword.
 void setAlignment(java.lang.String alignment)
          Sets the default alignment attribute by keyword.
 void setColor(int index, java.awt.Paint color)
          Sets the color attribute of the given index.
 void setColor(java.awt.Paint color)
          Sets the default color attribute.
 void setColor(java.awt.Paint[] color)
          Sets the color attribute for all elements.
 void setComposite(java.awt.Composite composite)
          Sets the default composite attribute.
 void setComposite(java.awt.Composite[] composite)
          Sets the composite attribute for all elements.
 void setComposite(int index, java.awt.Composite composite)
          Sets the composite attribute of the given index.
 void setDefaults(RenderAttributes defaults)
          Sets default attributes.
 void setFont(java.awt.Font font)
          Sets the default font attribute.
 void setFont(java.awt.Font[] font)
          Sets the font attribute for all elements.
 void setFont(int index, java.awt.Font font)
          Sets the font attribute of the given index.
 void setPaint(int index, java.awt.Paint paint)
          Sets the paint attribute of the given index.
 void setPaint(java.awt.Paint paint)
          Sets the default paint attribute.
 void setPaint(java.awt.Paint[] paint)
          Sets the paint attribute for all elements.
 void setShape(int index, java.awt.Shape shape)
          Sets the shape attribute of the given index.
 void setShape(java.awt.Shape shape)
          Sets the default shape attribute.
 void setShape(java.awt.Shape[] shape)
          Sets the shape attribute for all elements.
 void setStroke(int index, java.awt.Stroke stroke)
          Sets the stroke attribute of the given index.
 void setStroke(java.awt.Stroke stroke)
          Sets the default stroke attribute.
 void setStroke(java.awt.Stroke[] stroke)
          Sets the stroke attribute for all elements.
 int size()
          Gets the number of render attributes.
static java.lang.String toAlignment(int alignment)
          Maps an alignment keycode to an alignment keyword.
static int toAlignment(java.lang.String alignment)
          Maps an alignment keyword to an alignment keycode.
static java.lang.String toAntialiasMode(int antialiasMode)
          Maps an antialias mode keycode to an antialias mode keyword.
static int toAntialiasMode(java.lang.String antialiasMode)
          Maps an antialias mode keyword to an antialias mode keycode.
 java.lang.String toString()
          Gets a string representation of the content of this object.
 java.lang.String toString(int index, java.lang.String prefix)
          Generates a set of attribute XML representations.
protected  void toString(java.lang.StringBuffer xml)
          Generate XML attributes names.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
Void default index value.

See Also:
Constant Field Values

UNSET

public static final int UNSET
Unset code key (0).

See Also:
Constant Field Values

LINE

public static final java.awt.geom.Line2D LINE
Vertical unit line.


LEFT

public static final int LEFT
Left alignment key (1). Also INSIDE.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Right alignment key (2). Also OUTSIDE.

See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
Horizontal alignment key (LEFT and RIGHT).

See Also:
Constant Field Values

UP

public static final int UP
Up alignment key (4).

See Also:
Constant Field Values

NW

public static final int NW
North-west alignment key (UP and LEFT).

See Also:
Constant Field Values

NE

public static final int NE
North-east alignment key (UP and RIGHT).

See Also:
Constant Field Values

CEILING

public static final int CEILING
Ceiling alignment key (UP and HORIZONTAL).

See Also:
Constant Field Values

DOWN

public static final int DOWN
Down alignment key (8).

See Also:
Constant Field Values

SW

public static final int SW
South-west alignment key (DOWN and LEFT).

See Also:
Constant Field Values

SE

public static final int SE
South-east alignment key (DOWN and RIGHT).

See Also:
Constant Field Values

FLOOR

public static final int FLOOR
Floor alignment key (DOWN and HORIZONTAL).

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
Vertical alignment key (UP and DOWN).

See Also:
Constant Field Values

LEFTWALL

public static final int LEFTWALL
Vertical left alignment key (LEFT and VERTICAL).

See Also:
Constant Field Values

RIGHTWALL

public static final int RIGHTWALL
Vertical right alignment key (RIGHT and VERTICAL).

See Also:
Constant Field Values

CENTER

public static final int CENTER
Center alignment key (LEFT and RIGHT and UP and DOWN).

See Also:
Constant Field Values

FRONT

public static final int FRONT
Front alignment key.

See Also:
Constant Field Values

BACK

public static final int BACK
Back alignment key.

See Also:
Constant Field Values

DIAGONAL

public static final int DIAGONAL
Diagonal alignment key (FRONT and BACK).

See Also:
Constant Field Values

INSIDE

public static final int INSIDE
Inside alignment key.

See Also:
Constant Field Values

OUTSIDE

public static final int OUTSIDE
Outside alignment key.

See Also:
Constant Field Values

THROUGH

public static final int THROUGH
Through alignment key (INSIDE and OUTSIDE).

See Also:
Constant Field Values

ON

public static final int ON
Antialiasing control value (enabled).

See Also:
Constant Field Values

OFF

public static final int OFF
Antialiasing control value (disabled).

See Also:
Constant Field Values

AUTO

public static final int AUTO
Antialiasing control value (enabled or disabled automatically).

See Also:
Constant Field Values

TEXT

public static final int TEXT
Antialiasing control value (at least text enabled).

See Also:
Constant Field Values

GRAPHICS

public static final int GRAPHICS
Antialiasing control value (at least graphics enabled).

See Also:
Constant Field Values

ANTIALIASWORDS

public static final java.lang.String[] ANTIALIASWORDS
Antialias mode keywords.


ANTIALIASINDEX

protected static final com.davisor.core.Index ANTIALIASINDEX

M_alignment

protected int[] M_alignment
Alignment array (never null, but values may be UNSET).


M_color

protected java.awt.Paint[] M_color
Color attribute (may be null).


M_composite

protected java.awt.Composite[] M_composite
Composite attribute (may be null).


M_font

protected java.awt.Font[] M_font
Font attribute (may be null).


M_paint

protected java.awt.Paint[] M_paint
Paint attribute (may be null).


M_shape

protected java.awt.Shape[] M_shape
Shape attribute (may be null).


M_stroke

protected java.awt.Stroke[] M_stroke
Stroke attribute (may be null).


M_defaultIndex

protected transient int M_defaultIndex
Default index for searching a value (0).


M_defaults

protected transient RenderAttributes M_defaults
Default attributes (may be null).


M_size

protected transient int M_size
Array length for attributes.

Constructor Detail

RenderAttributes

public RenderAttributes(RenderAttributes ra)
Shallow copy constructor.

Parameters:
ra - render attributes to be copied (may be null)
See Also:
RenderAttributes(RenderAttributes,RenderAttributes)

RenderAttributes

public RenderAttributes(RenderAttributes ra,
                        RenderAttributes defaults)
Shallow copy constructor, with explicitly given default values.

If given defaults are null, given principal render attributes defaults are used, if available. If not, default attributes remains unset. In any case, they may be later set with setDefaults(com.davisor.graphics.RenderAttributes).

If given principal render attributes source ra is null, render attributes set size is copied from given defaults, if possible. If both arguments are null, render attribute set size and defaults remain undetermined.

Parameters:
ra - render attributes to be copied (may be null)
defaults - default render attibutes (may be null)
See Also:
RenderAttributes(RenderAttributes), init(int), setDefaults(com.davisor.graphics.RenderAttributes)

RenderAttributes

public RenderAttributes(int size)
Creates a render attribute set with the given number of elements. The initial element values are all left to null (or UNSET). The default index will be NONE, and the exceptions will initially be allowed.

Parameters:
size - number of render attributes
See Also:
RenderAttributes(int,RenderAttributes)

RenderAttributes

public RenderAttributes(int size,
                        RenderAttributes defaults)
Creates a render attribute set with the given defaults and number of elements. The initial element values are all left to null (or UNSET). The default index will be NONE, and the exceptions will initially be allowed.

Parameters:
size - number of render attributes
defaults - default attribute values (may be null)
See Also:
RenderAttributes(int,RenderAttributes,int)

RenderAttributes

public RenderAttributes(int size,
                        RenderAttributes defaults,
                        int defaultIndex)
Creates a render attribute set with the given control attributes and number of elements. The initial element values are all left to null (or UNSET).

Parameters:
size - number of render attributes
defaults - default attribute values (may be null)
defaultIndex - index for the default render attribute

RenderAttributes

public RenderAttributes(int size,
                        RenderAttributes defaults,
                        int defaultIndex,
                        java.awt.Paint color,
                        java.awt.Paint paint,
                        java.awt.Stroke stroke,
                        java.awt.Shape shape,
                        java.awt.Font font,
                        int alignment,
                        java.awt.Composite composite)
Creates a render attributes set with the given initial default attribute values. The values will be installed on slot defined by default index.

Parameters:
size - number of render attributes (must be > 0)
defaults - default attribute values (may be null)
defaultIndex - index for default render attribute
color - initial color attribute values (may be null)
paint - initial paint attribute values (may be null)
stroke - initial stroke attribute values (may be null)
shape - initial shape attribute values (may be null)
font - initial font attribute values (may be null)
alignment - initial alignment attribute values (may be null)
composite - initial composite attribute values (may be null)
See Also:
RenderAttributes(int,RenderAttributes,int)

RenderAttributes

public RenderAttributes(int size,
                        RenderAttributes defaults,
                        int defaultIndex,
                        java.awt.Paint[] colors,
                        java.awt.Paint[] paints,
                        java.awt.Stroke[] strokes,
                        java.awt.Shape[] shapes,
                        java.awt.Font[] fonts,
                        int[] alignments,
                        java.awt.Composite[] composites)
Creates a render attributes set with the given initial attribute values. A null value array will leave all attributes values as null (or UNSET).

Parameters:
size - number of render attributes
defaults - default attribute values (may be null)
defaultIndex - index for default render attribute
colors - initial color attribute values (may be null)
paints - initial paint attribute values (may be null)
strokes - initial stroke attribute values (may be null)
shapes - initial shape attribute values (may be null)
fonts - initial font attribute values (may be null)
alignments - initial alignment attribute values (may be null)
composites - initial composite attribute values (may be null)
See Also:
RenderAttributes(int,RenderAttributes,int)
Method Detail

dup

public com.davisor.core.Dupable dup()
Duplicates this object.

Specified by:
dup in interface com.davisor.core.Dupable

equals

public boolean equals(java.lang.Object object)
Test if these render attributes equal to given render attributes.


toString

public java.lang.String toString()
Gets a string representation of the content of this object. The string will be an empty XML tag, with non-null render attributes enumerated as XML attribute values.

This implementation uses toString(StringBuffer) to generate XML attributes with appropriate attribute names. In particular, subclasses are encouraged to override that method with more spesific implementations that give explicit meaning and names for the different attribute sets.

See Also:
toString(StringBuffer), toString(int,String)

init

protected void init(int size)
Initializes attribute value tables.

Parameters:
size - attribute value tables size

toString

protected void toString(java.lang.StringBuffer xml)
Generate XML attributes names. In particular, this method is expected to call toString(int,String) with appropriate arguments.

Subclasses are encouraged to override this method with more spesific implementations that give explicit meaning and names for the different attribute sets.

Parameters:
xml - string buffer to write xml attributes into
See Also:
toString(), toString(int,String)

exchangeOrientation

public static int exchangeOrientation(int alignment)
Exchange horizontal and vertical alignment components. In particular, each alignment aspect set changes to another aspect as follows:

Returns:
orientationally exchanged alignment
See Also:
getHorizontal(int), getVertical(int)

getAlignment

public int[] getAlignment()
Gets all alignment attributes.

Returns:
alignment array (never null, but values may be UNSET)
See Also:
getAlignment(int), getDefaultAlignment()

getAlignment

public int getAlignment(int index)
Gets the alignment attribute. If the attribute value is UNSET and the default attributes have been set, then the corresponding default value is returned instead. The default value may also be UNSET.

If the requested index falls outside of the current range, an exception is thrown, if allowed. Otherwise, the value associated with the default index is returned. This might be UNSET, too.

Parameters:
index - alignment index
Returns:
alignment code
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is invalid
See Also:
getAlignment(), getDefaultAlignment()

getAlignment

public int getAlignment(int index,
                        boolean useLocalDefault)
Like getAlignment(int) but allows defining whether to use local default defined by default index or not.


getColor

public java.awt.Paint[] getColor()
Gets all color attributes.

See Also:
getColor(int), getDefaultColor()

getColor

public java.awt.Paint getColor(int index)
Gets the color attribute of the given index. If the attribute value is null and the default attributes have been set, then the corresponding default value is returned instead. The default value may also be null.

If the requested index falls outside of the current range, an exception is thrown, if allowed. Otherwise, the value associated with the default index is returned. This might be null, too.

See Also:
getColor(), getDefaultColor()

getColor

public java.awt.Paint getColor(int index,
                               boolean useLocalDefault)
Gets the color attribute if the given index. Allows to determine whether the "local" default defined by default index is used before passing the resolvation to the possibly linked default rendering attributes.

See Also:
getColor(int)

getComposite

public java.awt.Composite[] getComposite()
Gets all composite attributes.

See Also:
getComposite(int), getDefaultComposite(), getDefaultComposite(int)

getComposite

public java.awt.Composite getComposite(int index)
Gets the composite attribute of the given index. If the attribute value is null and the default attributes have been set, then the corresponding default value is returned instead. The default value may also be null.

If the requested index falls outside of the current range, an exception is thrown, if allowed. Otherwise, the value associated with the default index is returned. This might be null, too.

See Also:
getComposite(), getDefaultComposite(), getDefaultComposite(int)

getComposite

public java.awt.Composite getComposite(int index,
                                       boolean useLocalDefault)
Like getComposite(int) but allows defining whether to use local default defined by default index or not.


getDefaultAlignment

public int getDefaultAlignment()
Gets default alignment attribute.

See Also:
getAlignment(), getAlignment(int)

getDefaultColor

public java.awt.Paint getDefaultColor()
Gets default color attribute.

See Also:
getColor(), getColor(int)

getDefaultComposite

public java.awt.Composite getDefaultComposite()
Gets the default composite attribute.

See Also:
getComposite(), getComposite(int), getDefaultComposite(int)

getDefaultComposite

public java.awt.Composite getDefaultComposite(int index)
Gets the composite attribute of the given index with a non-null default value. If the composite value otherwise would be null, then AlphaComposite.Src is returned instead.

See Also:
getComposite(), getComposite(int), getDefaultComposite()

getDefaultFont

public java.awt.Font getDefaultFont()
Gets default font attribute.

See Also:
getFont(), getFont(int)

getDefaultPaint

public java.awt.Paint getDefaultPaint()
Gets default paint attribute.

See Also:
getPaint(), getPaint(int)

getDefaultShape

public java.awt.Shape getDefaultShape()
Gets default shape attribute.

See Also:
getShape(), getShape(int)

getDefaultStroke

public java.awt.Stroke getDefaultStroke()
Gets default stroke attribute.

See Also:
getStroke(), getStroke(int)

getDefaultStrokeWidth

public float getDefaultStrokeWidth()
Gets default stroke line width.

See Also:
getStrokeWidth(int), getStrokeWidth(Stroke)

getDefaults

public int getDefaults()
Gets the number of recursive default value objects.

Returns:
0 if there are no default values, 1 if there is, 2 if the defaults have default values, and so on.

getFont

public java.awt.Font[] getFont()
Gets all font attributes.

See Also:
getFont(int), getDefaultFont()

getFont

public java.awt.Font getFont(int index)
Gets the font attribute of the given index. If the attribute value is null and the default attributes have been set, then the corresponding default value is returned instead. The default value may also be null.

If the requested index falls outside of the current range, an exception is thrown, if allowed. Otherwise, the value associated with the default index is returned. This might be null, too.

See Also:
getFont(), getDefaultFont()

getFont

public java.awt.Font getFont(int index,
                             boolean useLocalDefault)
Like getFont(int) but allows defining whether to use local default defined by default index or not.


getHorizontal

public static int getHorizontal(int alignment)
Gets the horizontal component in given alignment.

Returns:
UNSET, LEFT, RIGHT, or HORIZONTAL
See Also:
getVertical(int), isDown(int), isLeft(int), isRight(int), isUp(int)

getPaint

public java.awt.Paint[] getPaint()
Gets all paint attributes.

See Also:
getDefaultPaint(), getPaint(int)

getPaint

public java.awt.Paint getPaint(int index)
Gets the paint attribute of the given index. If the attribute value is null and the default attributes have been set, then the corresponding default value is returned instead. The default value may also be null.

If the requested index falls outside of the current range, an exception is thrown, if allowed. Otherwise, the value associated with the default index is returned. This might be null, too.

See Also:
getDefaultPaint(), getPaint()

getPaint

public java.awt.Paint getPaint(int index,
                               boolean useLocalDefault)
Like getPaint(int) but allows defining whether to use local default defined by default index or not.


getShape

public java.awt.Shape[] getShape()
Gets all shape attributes.

See Also:
getDefaultShape(), getShape(int)

getShape

public java.awt.Shape getShape(int index)
Gets the shape attribute of the given index. If the attribute value is null and the default attributes have been set, then the corresponding default value is returned instead. The default value may also be null.

If the requested index falls outside of the current range, an exception is thrown, if allowed. Otherwise, the value associated with the default index is returned. This might be null, too.

See Also:
getDefaultShape(), getShape()

getShape

public java.awt.Shape getShape(int index,
                               boolean useLocalDefault)
Like getShape(int) but allows defining whether to use local default defined by default index or not.


getStroke

public java.awt.Stroke[] getStroke()
Gets all stroke attributes.

See Also:
getDefaultStroke(), getStroke(int)

getStroke

public java.awt.Stroke getStroke(int index)
Gets the stroke attribute of the given index. If the attribute value is null and the default attributes have been set, then the corresponding default value is returned instead. The default value may also be null.

If the requested index falls outside of the current range, an exception is thrown, if allowed. Otherwise, the value associated with the default index is returned. This might be null, too.

See Also:
getDefaultStroke(), getStroke()

getStroke

public java.awt.Stroke getStroke(int index,
                                 boolean useLocalDefault)
Like getStroke(int) but allows defining whether to use local default defined by default index or not.


getStrokeWidth

public static float getStrokeWidth(java.awt.Stroke stroke)
Measures the line width of the given stroke. If the given stroke is null, zero is returned. If the stroke is an instance of BasicStroke, the line width of it is returned. Otherwise, the stroke width is measured by drawing a vertical unit line with the given stroke, and measuring the width of the resulting shape.

Parameters:
stroke - the stroke to be measured (may be null)
Returns:
the stroke line width, expressed in device units
See Also:
getDefaultStrokeWidth(), getStrokeWidth(int)

getStrokeWidth

public float getStrokeWidth(int index)
Gets stroke line width of the given index.

See Also:
getDefaultStrokeWidth(), getStrokeWidth(Stroke)

getVertical

public static int getVertical(int alignment)
Gets the vertical component in given alignment.

Returns:
UNSET, UP, DOWN, or VERTICAL
See Also:
getHorizontal(int), isDown(int), isLeft(int), isRight(int), isUp(int)

getDiagonal

public static int getDiagonal(int alignment)
Gets the diagonal component in given alignment.

Returns:
UNSET, FRONT, BACK, or DIAGONAL
See Also:
getHorizontal(int), getVertical(int)

isDown

public static boolean isDown(int alignment)
Tests if given alignment contains DOWN component.

See Also:
isLeft(int), isRight(int), isUp(int)

isHorizontal

public static boolean isHorizontal(int alignment)
Tests if given alignment is horizontally aligned. An alignment is horizontal if it contains HORIZONTAL component, or if it contains either LEFT or RIGHT component, but no UP or DOWN components.

See Also:
isVertical(int)

isLeft

public static boolean isLeft(int alignment)
Tests if given alignment contains LEFT component.

See Also:
isDown(int), isRight(int), isUp(int)

isRight

public static boolean isRight(int alignment)
Tests if given alignment contains RIGHT component.

See Also:
isDown(int), isLeft(int), isUp(int)

isUp

public static boolean isUp(int alignment)
Tests if given alignment contains UP component.

See Also:
isDown(int), isLeft(int), isRight(int)

isVertical

public static boolean isVertical(int alignment)
Tests if given alignment is vertically aligned. An alignment is vertical if it contains VERTICAL component, or if it contains either UP or DOWN component, but no LEFT or RIGHT components.

See Also:
isHorizontal(int)

next

public void next()
Rotates all color and paint palettes. The operation iterates through all attribute sets, and fetches their current colors and paints. Each color and paint that is a BetterPaint instance is replaced with whatever paints their BetterPaint.next() method returns.

While iterating through colors and paints, this method is very carefull of not to mix explicitly defined colors and paints with their corresponding local default values. In particular, when this method operates on particular color or paint, it fetches the color or paint with getColor(int,boolean) and getPaint(int,boolean) methods with the corresponding useLocalDefaults argument set to false.

This method modifies the current object, but it never changes the state of any default render attributes linked to this object. In particular, if this attribute set does not contains a certain color or paint, but it's default attributes set does, the source color or paint is taken from the default set, but the new color or paint is stored into this set. The original default color or paint object in a default attribute set is therefore not replaced, only shadowed by a new color or paint instance.

See Also:
getColor(int,boolean), getPaint(int,boolean), setColor(int,Paint), setPaint(int,Paint), BetterPaint.next()

setAlignment

public void setAlignment(int alignment)
Sets the default alignment attribute.

Parameters:
alignment - alignment code
See Also:
setAlignment(String), setAlignment(int,String), setAlignment(int,int)

setAlignment

public void setAlignment(java.lang.String alignment)
Sets the default alignment attribute by keyword. If the keyword is not recognized, attributes become UNSET.

Parameters:
alignment - alignment keyword
See Also:
setAlignment(int), setAlignment(int,String), setAlignment(int,int)

setAlignment

public void setAlignment(int[] alignment)
Sets the alignment attribute for all elements. The new values are copied from the given array to an internal array, where the new values override correspomding old values, if any. The argument array will not be referenced later.

If given array is null or too short, all alignment values corresponding to the missing values become UNSET. If given array is too long, the extra alignment values are ignored.

Parameters:
alignment - array of alignment codes (may be null)
See Also:
setAlignment(int), setAlignment(String), setAlignment(int,String), setAlignment(int,int)

setAlignment

public void setAlignment(int index,
                         int alignment)
Sets the alignment attribute.

Parameters:
index - alignment index
alignment - alignment code
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is invalid
See Also:
setAlignment(String), setAlignment(int), setAlignment(int,String)

setAlignment

public void setAlignment(int index,
                         java.lang.String alignment)
Sets the alignment attribute by keyword. If the keyword is not recognized, the attribute becomes UNSET.

Parameters:
index - alignment index
alignment - alignment keyword
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is invalid
See Also:
setAlignment(String), setAlignment(int), setAlignment(int,int), toAlignment(String)

setColor

public void setColor(java.awt.Paint color)
Sets the default color attribute.

See Also:
setColor(int,Paint)

setColor

public void setColor(java.awt.Paint[] color)
Sets the color attribute for all elements. The new values are copied from the given array to an internal array, where the new values override correspomding old values, if any. The argument array will not be referenced later.

If given array is null or too short, all color values corresponding to the missing values become null. If given array is too long, the extra color values are ignored.

Parameters:
color - array of color codes (may be null)
See Also:
setColor(Paint), setColor(int,Paint)

setColor

public void setColor(int index,
                     java.awt.Paint color)
Sets the color attribute of the given index.

See Also:
setColor(Paint)

setComposite

public void setComposite(java.awt.Composite composite)
Sets the default composite attribute.

See Also:
setComposite(int,Composite)

setComposite

public void setComposite(java.awt.Composite[] composite)
Sets the composite attribute for all elements. The new values are copied from the given array to an internal array, where the new values override correspomding old values, if any. The argument array will not be referenced later.

If given array is null or too short, all composite values corresponding to the missing values become null. If given array is too long, the extra composite values are ignored.

Parameters:
composite - array of composite codes (may be null)
See Also:
setComposite(Composite), setComposite(int,Composite)

setComposite

public void setComposite(int index,
                         java.awt.Composite composite)
Sets the composite attribute of the given index.

See Also:
setComposite(Composite)

setDefault