com.tensegrity.graphics
Class Pattern

java.lang.Object
  extended bycom.tensegrity.graphics.Pattern

public final class Pattern
extends java.lang.Object

The Pattern class represents a certain style that can be used for area filling. It consists of the following attributes:

The type attribute defines the type of the pattern to fill an area with. The different types of patterns that can be used to fill an area are as follows:

At the actual state of development custom patterns are not supported.

The foreground color attribute defines the color that is used to draw the pattern with. It 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 background color attribute defines the color that is used to draw the background of the pattern. It 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 raster attribute defines the pattern itself. The raster is expected as a monocrome bitmap where a pixel that is set to zero is interpreted as background pixel and a pixel that is set to one is interpreded as a pixel of the pattern.

It is not possible to create an instance of this class. In fact this class provides some predefined patterns that can be used. This predefined patterns can be gained typewise through a call to getPattern(int, int, int).

Version:
$Id: Pattern.java,v 1.14 2005/04/01 15:42:39 MichaelKegel Exp $
Author:
MichaelKegel

Field Summary
static int CHECKER
          constant that tells about a type of pattern the Pattern class supports
static int CRISSCROSS
          constant that tells about a type of pattern the Pattern class supports
static int DOWN
          constant that tells about a type of pattern the Pattern class supports
static int GREY16
          constant that tells about a type of pattern the Pattern class supports
static int GREY25
          constant that tells about a type of pattern the Pattern class supports
static int GREY50
          constant that tells about a type of pattern the Pattern class supports
static int GREY75
          constant that tells about a type of pattern the Pattern class supports
static int GREY8
          constant that tells about a type of pattern the Pattern class supports
static int GRID
          constant that tells about a type of pattern the Pattern class supports
static int HORIZONTAL
          constant that tells about a type of pattern the Pattern class supports
static int LIGHTDOWN
          constant that tells about a type of pattern the Pattern class supports
static int LIGHTHORIZONTAL
          constant that tells about a type of pattern the Pattern class supports
static int LIGHTUP
          constant that tells about a type of pattern the Pattern class supports
static int LIGHTVERTICAL
          constant that tells about a type of pattern the Pattern class supports
static Pattern PATTERN_CHECKER
          enumeration of the predefined patterns
static Pattern PATTERN_CRISSCROSS
          enumeration of the predefined patterns
static Pattern PATTERN_DOWN
          enumeration of the predefined patterns
static Pattern PATTERN_GREY16
          enumeration of the predefined patterns
static Pattern PATTERN_GREY25
          enumeration of the predefined patterns
static Pattern PATTERN_GREY50
          enumeration of the predefined patterns
static Pattern PATTERN_GREY75
          enumeration of the predefined patterns
static Pattern PATTERN_GREY8
          enumeration of the predefined patterns
static Pattern PATTERN_GRID
          enumeration of the predefined patterns
static Pattern PATTERN_HORIZONTAL
          enumeration of the predefined patterns
static Pattern PATTERN_LIGHTDOWN
          enumeration of the predefined patterns
static Pattern PATTERN_LIGHTHORIZONTAL
          enumeration of the predefined patterns
static Pattern PATTERN_LIGHTUP
          enumeration of the predefined patterns
static Pattern PATTERN_LIGHTVERTICAL
          enumeration of the predefined patterns
static int PATTERN_MAX
          constant that indicates the maximum number of predefined patterns
static Pattern PATTERN_SEMIGREY75
          enumeration of the predefined patterns
static Pattern PATTERN_SOLID
          enumeration of the predefined patterns
static Pattern PATTERN_UP
          enumeration of the predefined patterns
static Pattern PATTERN_VERTICAL
          enumeration of the predefined patterns
static int SEMIGREY75
          constant that tells about a type of pattern the Pattern class supports
static int SOLID
          constant that tells about a type of pattern the Pattern class supports
static int UP
          constant that tells about a type of pattern the Pattern class supports
static int VERTICAL
          constant that tells about a type of pattern the Pattern class supports
 
Method Summary
 boolean equals(java.lang.Object o)
           
 int get(int x, int y)
          Returns the value of the patterns raster at the position given by x and y.
 int getBackground()
          Returns the patterns background color value.
 int getBackgroundRaster()
          Returns an int representation of the set background color of the used Raster.
 int getForeground()
          Returns the patterns foreground color value.
 int getForegroundRaster()
          Returns an int representation of the set foreground color of the used Raster.
 int getHeight()
          Returns the height of the patterns raster.
static Pattern getPattern(int type, int colorback, int colorfore)
          Returns an instance of a Pattern object that belongs to the type given by type.
 int getType()
          Returns the type of the pattern.
 int getWidth()
          Returns the width of the patterns raster.
 boolean hasAlpha()
          Returns a boolean that indicates weather this pattern uses alpha values or not.
 int hashCode()
          Overridden hashcode, please see java.lang.Object why it is overridden here.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOLID

public static final int SOLID
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

GREY75

public static final int GREY75
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

GREY50

public static final int GREY50
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

GREY25

public static final int GREY25
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

GREY16

public static final int GREY16
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

GREY8

public static final int GREY8
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

DOWN

public static final int DOWN
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

UP

public static final int UP
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

CHECKER

public static final int CHECKER
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

SEMIGREY75

public static final int SEMIGREY75
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

LIGHTHORIZONTAL

public static final int LIGHTHORIZONTAL
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

LIGHTVERTICAL

public static final int LIGHTVERTICAL
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

LIGHTDOWN

public static final int LIGHTDOWN
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

LIGHTUP

public static final int LIGHTUP
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

GRID

public static final int GRID
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

CRISSCROSS

public static final int CRISSCROSS
constant that tells about a type of pattern the Pattern class supports

See Also:
Constant Field Values

PATTERN_MAX

public static final int PATTERN_MAX
constant that indicates the maximum number of predefined patterns

See Also:
Constant Field Values

PATTERN_SOLID

public static final Pattern PATTERN_SOLID
enumeration of the predefined patterns


PATTERN_GREY75

public static final Pattern PATTERN_GREY75
enumeration of the predefined patterns


PATTERN_GREY50

public static final Pattern PATTERN_GREY50
enumeration of the predefined patterns


PATTERN_GREY25

public static final Pattern PATTERN_GREY25
enumeration of the predefined patterns


PATTERN_GREY16

public static final Pattern PATTERN_GREY16
enumeration of the predefined patterns


PATTERN_GREY8

public static final Pattern PATTERN_GREY8
enumeration of the predefined patterns


PATTERN_HORIZONTAL

public static final Pattern PATTERN_HORIZONTAL
enumeration of the predefined patterns


PATTERN_VERTICAL

public static final Pattern PATTERN_VERTICAL
enumeration of the predefined patterns


PATTERN_DOWN

public static final Pattern PATTERN_DOWN
enumeration of the predefined patterns


PATTERN_UP

public static final Pattern PATTERN_UP
enumeration of the predefined patterns


PATTERN_CHECKER

public static final Pattern PATTERN_CHECKER
enumeration of the predefined patterns


PATTERN_SEMIGREY75

public static final Pattern PATTERN_SEMIGREY75
enumeration of the predefined patterns


PATTERN_LIGHTHORIZONTAL

public static final Pattern PATTERN_LIGHTHORIZONTAL
enumeration of the predefined patterns


PATTERN_LIGHTVERTICAL

public static final Pattern PATTERN_LIGHTVERTICAL
enumeration of the predefined patterns


PATTERN_LIGHTDOWN

public static final Pattern PATTERN_LIGHTDOWN
enumeration of the predefined patterns


PATTERN_LIGHTUP

public static final Pattern PATTERN_LIGHTUP
enumeration of the predefined patterns


PATTERN_GRID

public static final Pattern PATTERN_GRID
enumeration of the predefined patterns


PATTERN_CRISSCROSS

public static final Pattern PATTERN_CRISSCROSS
enumeration of the predefined patterns

Method Detail

getType

public int getType()
Returns the type of the pattern.

Returns:
int the patterns type
See Also:
SOLID, GREY75, GREY50, GREY25, GREY16, GREY8, HORIZONTAL, VERTICAL, DOWN, UP, CHECKER, SEMIGREY75, LIGHTHORIZONTAL, LIGHTVERTICAL, LIGHTDOWN, LIGHTUP, GRID, CRISSCROSS

getBackground

public int getBackground()
Returns the patterns background color value.

Returns:
the patterns background color value

getForeground

public int getForeground()
Returns the patterns foreground color value.

Returns:
the patterns foreground color value

getBackgroundRaster

public int getBackgroundRaster()
Returns an int representation of the set background color of the used Raster.

Returns:
an int representation of the set background color of the used Raster.

getForegroundRaster

public int getForegroundRaster()
Returns an int representation of the set foreground color of the used Raster.

Returns:
an int representation of the set foreground color of the used Raster.

getWidth

public int getWidth()
Returns the width of the patterns raster.

Returns:
the width of the patterns raster.

getHeight

public int getHeight()
Returns the height of the patterns raster.

Returns:
the height of the patterns raster.

get

public int get(int x,
               int y)
Returns the value of the patterns raster at the position given by x and y.

Parameters:
x - component of the position to return the value for
y - component of the position to return the value for
Returns:
the value at the given position

hasAlpha

public boolean hasAlpha()
Returns a boolean that indicates weather this pattern uses alpha values or not.

Returns:
boolean flag that indicates the useage of alpha values

hashCode

public int hashCode()
Overridden hashcode, please see java.lang.Object why it is overridden here. The contract of java.util.HashSet and java.util.HashMap requires it as well.


equals

public boolean equals(java.lang.Object o)

getPattern

public static Pattern getPattern(int type,
                                 int colorback,
                                 int colorfore)
Returns an instance of a Pattern object that belongs to the type given by type.

Parameters:
type - the type of the Pattern to return
colorback - a background color for the Pattern.
colorfore - a foreground color for the Pattern.
Returns:
a Pattern instance of the requested type.


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