org.openmali.vecmath2
Class Colorf

java.lang.Object
  extended by org.openmali.vecmath2.Colorf
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Colorf
extends java.lang.Object
implements java.io.Externalizable

A simple float-based color implementation with or without alpha channel. Inspired by Kenji Hiranabe's Color3f/Color4f implementation

See Also:
Serialized Form

Field Summary
static Colorf BLACK
          The color black.
static Colorf BLACK_TRANSPARENT
          The color black and fully transparent.
static Colorf BLUE
          The color blue.
static Colorf BROWN
          The color brown.
static Colorf CYAN
          The color cyan.
static Colorf DARK_BROWN
          The color brown.
static Colorf DARK_GRAY
          The color dark gray.
static Colorf GRAY
          The color gray.
static Colorf GRAY10
          A 10% gray.
static Colorf GRAY20
          A 20% gray.
static Colorf GRAY25
          A 25% gray.
static Colorf GRAY30
          A 30% gray.
static Colorf GRAY40
          A 40% gray.
static Colorf GRAY50
          A 50% gray.
static Colorf GRAY60
          A 60% gray.
static Colorf GRAY70
          A 70% gray.
static Colorf GRAY75
          A 75% gray.
static Colorf GRAY80
          A 80% gray.
static Colorf GRAY90
          A 90% gray.
static Colorf GREEN
          The color green.
protected  boolean hasAlpha
           
protected  boolean[] isDirty
           
static Colorf LIGHT_BROWN
          The color brown.
static Colorf LIGHT_GRAY
          The color light gray.
static Colorf MAGENTA
          The color magenta.
protected static int N
           
static Colorf ORANGE
          The color orange.
static Colorf PINK
          The color pink.
static Colorf RED
          The color red.
protected  int roTrick
           
protected  float[] values
           
static Colorf WHITE
          The color white.
static Colorf WHITE_TRANSPARENT
          The color white and fully transparent.
static Colorf YELLOW
          The color yellow.
 
Constructor Summary
  Colorf()
          Creates a new Colorf instance.
protected Colorf(boolean readOnly)
          Creates a new Colorf instance.
protected Colorf(boolean readOnly, java.awt.Color color)
          Creates a new Colorf instance.
protected Colorf(boolean readOnly, Colorf color)
          Creates a new Colorf instance.
protected Colorf(boolean readOnly, float intensity)
          Creates a new Colorf instance.
protected Colorf(boolean readOnly, float[] values, boolean[] isDirty, boolean copy)
          Creates a new Colorf instance.
protected Colorf(boolean readOnly, float r, float g, float b)
          Creates a new Colorf instance.
protected Colorf(boolean readOnly, float r, float g, float b, float a)
          Creates a new Colorf instance.
  Colorf(java.awt.Color color)
           
  Colorf(Colorf color)
          Creates a new Colorf instance.
  Colorf(Colorf rgbColor, float alpha)
          Creates a new Colorf instance.
  Colorf(float intensity)
          Creates a new Colorf instance.
  Colorf(float[] values)
          Creates a new Colorf instance.
  Colorf(float r, float g, float b)
          Creates a new Colorf instance.
  Colorf(float r, float g, float b, float a)
          Creates a new Colorf instance.
 
Method Summary
 float a()
           
 void a(float alpha)
          Sets the value of the alpha-element of this color.
 Colorf add(Colorf color2)
          Sets the value of this tuple to the vector sum of itself and tuple t1.
 Colorf add(Colorf color1, Colorf color2)
          Sets the value of this color to the vector sum of colors color1 and color2.
 Colorf add(float r, float g, float b)
          Adds the given parameters to this tuple's values.
 Colorf add(float r, float g, float b, float a)
          Adds the given parameters to this tuple's values.
 Colorf addAlpha(float v)
          Adds v to this color's alpha value.
 Colorf addBlue(float v)
          Adds v to this color's blue value.
 Colorf addGreen(float v)
          Adds v to this color's green value.
 Colorf addRed(float v)
          Adds v to this color's red value.
 Colorf asReadOnly()
           
 float b()
           
 void b(float blue)
          Sets the Blue color component.
 Colorf clamp(float min, float max)
          Clamps this tuple to the range [min, max].
 Colorf clamp(float min, float max, Colorf vec)
          Clamps the tuple parameter to the range [min, max] and places the values into this tuple.
 Colorf clampMax(float max)
          Clamps the maximum value of this tuple to the max parameter.
 Colorf clampMax(float max, Colorf vec)
          Clamps the maximum value of the tuple parameter to the max parameter and places the values into this tuple.
 Colorf clampMin(float min)
          Clamps the minimum value of this tuple to the min parameter.
 Colorf clampMin(float min, Colorf vec)
          Clamps the minimum value of the tuple parameter to the min parameter and places the values into this tuple.
 Colorf clone()
          Creates and returns a copy of this object.
static Colorf createGray(float intensity)
          Creates a gray of the given intensity.
 int deserialize(int pos, byte[] buffer)
          Deserializes this instanc'es data from the byte array.
 Colorf div(float vr, float vg, float vb)
          Divides this color's values by vr, vg, vb.
 Colorf div(float vr, float vg, float vb, float va)
          Divides this color's values by vr, vg, vb, va.
 Colorf divAlpha(float v)
          Divides this color's alpha value by v.
 Colorf divBlue(float v)
          Divides this color's blue value by v.
 Colorf divGreen(float v)
          Divides this color's green value by v.
 Colorf divRed(float v)
          Divides this color's red value by v.
 boolean epsilonEquals(Colorf color2, float epsilon)
          Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false.
 boolean equals(Colorf color2)
          Returns true if all of the data members of Tuple3f t1 are equal to the corresponding data members in this
 boolean equals(java.lang.Object o)
          Returns true if the Object t1 is of type Tuple3f and all of the data members of t1 are equal to the corresponding data members in this Tuple3f.
static Colorf fromPool()
          Allocates an Colorf instance from the pool.
static Colorf fromPool(Colorf color)
          Allocates an Colorf instance from the pool.
static Colorf fromPool(float r, float g, float b)
          Allocates an Colorf instance from the pool.
static Colorf fromPool(float r, float g, float b, float a)
          Allocates an Colorf instance from the pool.
 float g()
           
 void g(float green)
          Sets the Green color component.
 void get(Colorf buffer)
          Writes all values of this vector to the specified buffer vector.
 void get(float[] buffer)
          Writes all values of this Tuple to the specified buffer.
 void get(float[] buffer, int offset)
          Writes all values of this Tuple to the specified buffer.
 float getAlpha()
           
 byte getAlphaByte()
           
 int getAlphaInt()
           
 java.awt.Color getAWTColor()
          Gets java.awt.Color.
 float getBlue()
           
 byte getBlueByte()
           
 int getBlueInt()
           
 void getBytes(byte[] buffer)
          Writes all values of this Tuple to the specified buffer.
 float getGreen()
           
 byte getGreenByte()
           
 int getGreenInt()
           
 void getInts(int[] buffer)
          Writes all values of this Tuple to the specified buffer.
 Colorf getReadOnly()
           
 float getRed()
           
 byte getRedByte()
           
 int getRedInt()
           
 int getSize()
           
 boolean hasAlpha()
           
 int hashCode()
          Returns a hash number based on the data values in this object.
 Colorf interpolate(Colorf color1, Colorf color2, float val)
          Linearly interpolates between tuples t1 and t2 and places the result into this tuple: this = (1 - alpha) * t1 + alpha * t2.
 Colorf interpolate(Colorf color2, float val)
          Linearly interpolates between this tuple and tuple t2 and places the result into this tuple: this = (1 - alpha) * this + alpha * t1.
 boolean isDirty()
           
 boolean isReadOnly()
           
 Colorf mul(float factor)
          Sets the value of this tuple to the scalar multiplication of itself.
 Colorf mul(float vr, float vg, float vb)
          Multiplies this color's values with vr, vg, vb.
 Colorf mul(float vr, float vg, float vb, float va)
          Multiplies this color's values with vr, vg, vb, va.
 Colorf mulAlpha(float v)
          Multiplies this color's alpha value with v.
 Colorf mulBlue(float v)
          Multiplies this color's blue value with v.
 Colorf mulGreen(float v)
          Multiplies this color's green value with v.
 Colorf mulRed(float v)
          Multiplies this color's red value with v.
static Colorf newReadOnly()
          Creates a new read-only Colorf instance.
static Colorf newReadOnly(java.awt.Color color)
           
static Colorf newReadOnly(Colorf color)
          Creates a new read-only Colorf instance.
static Colorf newReadOnly(Colorf rgbColor, float alpha)
          Creates a new read-only Colorf instance.
static Colorf newReadOnly(float intensity)
          Creates a new read-only Colorf instance.
static Colorf newReadOnly(float[] values)
          Creates a new read-only Colorf instance.
static Colorf newReadOnly(float r, float g, float b)
          Creates a new read-only Colorf instance.
static Colorf newReadOnly(float r, float g, float b, float a)
          Creates a new read-only Colorf instance.
static Colorf parseColor(java.lang.String hexString)
          Parses a color-hex-String into a Colorf instance.
static Colorf parseColor(java.lang.String hexString, Colorf buffer)
          Parses a color-hex-String into the color buffer.
static Colorf parseReadOnlyColor(java.lang.String hexString)
          Parses a color-hex-String into a new Colorf instance.
 float r()
           
 void r(float red)
          Sets the Red color component.
 void readExternal(java.io.ObjectInput in)
           
 java.nio.FloatBuffer readFromBuffer(boolean forceAlpha, java.nio.FloatBuffer buffer)
          Reads the data of one tuple from a FloatBuffer.
 java.nio.FloatBuffer readFromBuffer(boolean forceAlpha, java.nio.FloatBuffer buffer, int position)
          Reads the data of one tuple from a FloatBuffer.
static java.nio.FloatBuffer readFromBuffer(Colorf[] colors, boolean forceAlpha, java.nio.FloatBuffer buffer)
          Reads the data of one tuple from a FloatBuffer.
static java.nio.FloatBuffer readFromBuffer(Colorf[] colors, boolean forceAlpha, java.nio.FloatBuffer buffer, int position)
          Reads the data of one tuple from a FloatBuffer.
static java.nio.FloatBuffer readFromBuffer(Colorf[] colors, java.nio.FloatBuffer buffer)
          Reads the data of one tuple from a FloatBuffer.
static java.nio.FloatBuffer readFromBuffer(Colorf[] colors, java.nio.FloatBuffer buffer, int position)
          Reads the data of one tuple from a FloatBuffer.
 java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer)
          Reads the data of one tuple from a FloatBuffer.
 java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer, int position)
          Reads the data of one tuple from a FloatBuffer.
 int serialize(int pos, byte[] buffer)
          Serializes this instanc'es data into the byte array.
 void set(java.awt.Color color)
          Sets color from awt.Color.
 void set(Colorf color)
          Sets all three values of this Tuple to the specified ones.
 void set(float[] values)
          Sets all values of this Tuple to the specified ones.
 void set(float[] values, boolean alpha)
          Sets all values of this Tuple to the specified ones.
 void set(float[] values, int offset, boolean alpha)
          Sets all values of this Tuple to the specified ones.
 void set(float r, float g, float b)
          Sets all values of this color to the specified ones.
 void set(float r, float g, float b, float a)
          Sets all values of this color to the specified ones.
 void setAlpha(float alpha)
          Sets the value of the alpha-element of this color.
 void setAlphaByte(byte alpha)
          Sets the Alpha value component.
 void setAlphaInt(int alpha)
          Sets the Alpha value component.
 void setBlue(float blue)
          Sets the Blue color component.
 void setBlueByte(byte blue)
          Sets the Blue color component.
 void setBlueInt(int blue)
          Sets the Blue color component.
 void setBytes(byte[] values)
          Sets all values of this Tuple to the specified ones.
 boolean setClean()
          Marks this tuple non-dirty.
 void setGreen(float green)
          Sets the Green color component.
 void setGreenByte(byte green)
          Sets the Green color component.
 void setGreenInt(int green)
          Sets the Green color component.
 void setInts(int[] values)
          Sets all values of this Tuple to the specified ones.
 void setRed(float red)
          Sets the Red color component.
 void setRedByte(byte red)
          Sets the Red color component.
 void setRedInt(int red)
          Sets the Red color component.
 Colorf setZero()
          Sets all components to zero.
 Colorf sub(Colorf color2)
          Sets the value of this color to the vector difference of itself and color2 (this = this - color2).
 Colorf sub(Colorf color1, Colorf color2)
          Sets the value of this color to the vector difference of color color1 and color2 (this = color1 - color2).
 Colorf sub(float r, float g, float b)
          Subtracts the given parameters from this tuple's values.
 Colorf sub(float r, float g, float b, float a)
          Subtracts the given parameters from this tuple's values.
 Colorf subAlpha(float v)
          Subtracts v from this color's alpha value.
 Colorf subBlue(float v)
          Subtracts v from this color's blue value.
 Colorf subGreen(float v)
          Subtracts v from this color's green value.
 Colorf subRed(float v)
          Subtracts v from this color's red value.
 java.lang.String toHexString()
           
static void toPool(Colorf o)
          Stores the given Colorf instance in the pool.
 java.lang.String toString()
          Returns a string that contains the values of this Colorf.
 void writeExternal(java.io.ObjectOutput out)
           
 java.nio.FloatBuffer writeToBuffer(boolean forceAlpha, java.nio.FloatBuffer buffer, boolean clear, boolean flip)
          Writes the contents of this tuple to a FloatBuffer.
 java.nio.FloatBuffer writeToBuffer(boolean forceAlpha, java.nio.FloatBuffer buffer, int position, boolean clear, boolean flip)
          Writes the contents of this tuple to a FloatBuffer.
static java.nio.FloatBuffer writeToBuffer(Colorf[] colors, boolean forceAlpha, java.nio.FloatBuffer buffer, boolean clear, boolean flip)
          Writes the contents of this tuple to a FloatBuffer.
static java.nio.FloatBuffer writeToBuffer(Colorf[] colors, boolean forceAlpha, java.nio.FloatBuffer buffer, int position, boolean clear, boolean flip)
          Writes the contents of this tuple to a FloatBuffer.
static java.nio.FloatBuffer writeToBuffer(Colorf[] colors, java.nio.FloatBuffer buffer, boolean clear, boolean flip)
          Writes the contents of the colors to a FloatBuffer.
static java.nio.FloatBuffer writeToBuffer(Colorf[] colors, java.nio.FloatBuffer buffer, int position, boolean clear, boolean flip)
          Writes the contents of the colors to a FloatBuffer.
 java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer, boolean clear, boolean flip)
          Writes the contents of this tuple to a FloatBuffer.
 java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer, int position, boolean clear, boolean flip)
          Writes the contents of this tuple to a FloatBuffer.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

N

protected static final int N
See Also:
Constant Field Values

values

protected final float[] values

hasAlpha

protected boolean hasAlpha

roTrick

protected final int roTrick

isDirty

protected final boolean[] isDirty

WHITE

public static final Colorf WHITE
The color white. In the default sRGB space.


WHITE_TRANSPARENT

public static final Colorf WHITE_TRANSPARENT
The color white and fully transparent. In the default RGBA space.


LIGHT_GRAY

public static final Colorf LIGHT_GRAY
The color light gray. In the default sRGB space.


GRAY10

public static final Colorf GRAY10
A 10% gray. In the default sRGB space.


GRAY20

public static final Colorf GRAY20
A 20% gray. In the default sRGB space.


GRAY25

public static final Colorf GRAY25
A 25% gray. In the default sRGB space.


GRAY30

public static final Colorf GRAY30
A 30% gray. In the default sRGB space.


GRAY40

public static final Colorf GRAY40
A 40% gray. In the default sRGB space.


GRAY50

public static final Colorf GRAY50
A 50% gray. In the default sRGB space.


GRAY60

public static final Colorf GRAY60
A 60% gray. In the default sRGB space.


GRAY70

public static final Colorf GRAY70
A 70% gray. In the default sRGB space.


GRAY75

public static final Colorf GRAY75
A 75% gray. In the default sRGB space.


GRAY80

public static final Colorf GRAY80
A 80% gray. In the default sRGB space.


GRAY90

public static final Colorf GRAY90
A 90% gray. In the default sRGB space.


GRAY

public static final Colorf GRAY
The color gray. In the default sRGB space.


DARK_GRAY

public static final Colorf DARK_GRAY
The color dark gray. In the default sRGB space.


BLACK

public static final Colorf BLACK
The color black. In the default sRGB space.


BLACK_TRANSPARENT

public static final Colorf BLACK_TRANSPARENT
The color black and fully transparent. In the default RGBA space.


BROWN

public static final Colorf BROWN
The color brown. In the default sRGB space.


LIGHT_BROWN

public static final Colorf LIGHT_BROWN
The color brown. In the default sRGB space.


DARK_BROWN

public static final Colorf DARK_BROWN
The color brown. In the default sRGB space.


RED

public static final Colorf RED
The color red. In the default sRGB space.


PINK

public static final Colorf PINK
The color pink. In the default sRGB space.


ORANGE

public static final Colorf ORANGE
The color orange. In the default sRGB space.


YELLOW

public static final Colorf YELLOW
The color yellow. In the default sRGB space.


GREEN

public static final Colorf GREEN
The color green. In the default sRGB space.


MAGENTA

public static final Colorf MAGENTA
The color magenta. In the default sRGB space.


CYAN

public static final Colorf CYAN
The color cyan. In the default sRGB space.


BLUE

public static final Colorf BLUE
The color blue. In the default sRGB space.

Constructor Detail

Colorf

protected Colorf(boolean readOnly,
                 float r,
                 float g,
                 float b,
                 float a)
Creates a new Colorf instance.

Parameters:
readOnly -
r - the red element to use
g - the green element to use
b - the blue element to use
a - the alpha channel to use

Colorf

protected Colorf(boolean readOnly,
                 float r,
                 float g,
                 float b)
Creates a new Colorf instance.

Parameters:
readOnly -
r - the red element to use
g - the green element to use
b - the blue element to use

Colorf

protected Colorf(boolean readOnly,
                 float intensity)
Creates a new Colorf instance.

Parameters:
readOnly -
intensity - the gray intensity (used for all three r,g,b values

Colorf

protected Colorf(boolean readOnly,
                 float[] values,
                 boolean[] isDirty,
                 boolean copy)
Creates a new Colorf instance.

Parameters:
readOnly -
values - the values array (must be at least size 3)
isDirty -
copy -

Colorf

protected Colorf(boolean readOnly,
                 Colorf color)
Creates a new Colorf instance.

Parameters:
readOnly -
color - the Colorf to copy the values from

Colorf

protected Colorf(boolean readOnly)
Creates a new Colorf instance.

Parameters:
readOnly -

Colorf

protected Colorf(boolean readOnly,
                 java.awt.Color color)
Creates a new Colorf instance.

Parameters:
readOnly -
color - the Color to copy the values from

Colorf

public Colorf(float r,
              float g,
              float b,
              float a)
Creates a new Colorf instance.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use
a - the alpha channel to use

Colorf

public Colorf(float r,
              float g,
              float b)
Creates a new Colorf instance.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use

Colorf

public Colorf(float intensity)
Creates a new Colorf instance.

Parameters:
intensity - the gray intensity (used for all three r,g,b values

Colorf

public Colorf(float[] values)
Creates a new Colorf instance.

Parameters:
values - the values array (must be at least size 3)

Colorf

public Colorf(Colorf color)
Creates a new Colorf instance.

Parameters:
color - the Colorf to copy the values from

Colorf

public Colorf(Colorf rgbColor,
              float alpha)
Creates a new Colorf instance.

Parameters:
rgbColor - the Colorf to copy the RGB-values from
alpha - the value for the alpha channel

Colorf

public Colorf()
Creates a new Colorf instance.


Colorf

public Colorf(java.awt.Color color)
Method Detail

isReadOnly

public final boolean isReadOnly()
Returns:
Is this tuple a read-only one?

setClean

public final boolean setClean()
Marks this tuple non-dirty. Any value-manipulation will mark it dirty again.

Returns:
the old value

isDirty

public final boolean isDirty()
Returns:
This tuple's dirty-flag

createGray

public static Colorf createGray(float intensity)
Creates a gray of the given intensity.
This is euqal to new Color3f(intensity, intensity, intensity);

Parameters:
intensity - the gray's intensity to be applied to all three components.
Returns:
the new gray color

getSize

public final int getSize()
Returns:
this Vector's size().

hasAlpha

public final boolean hasAlpha()
Returns:
if this Colorf has an alpha channel.

set

public final void set(java.awt.Color color)
Sets color from awt.Color.

Parameters:
color - awt color

set

public final void set(float[] values,
                      int offset,
                      boolean alpha)
Sets all values of this Tuple to the specified ones.

Parameters:
values - the values array (must be at least size 4 for with-alpha else 3)
offset - the offset in the (source) values array
alpha -

set

public final void set(float[] values,
                      boolean alpha)
Sets all values of this Tuple to the specified ones.

Parameters:
values - the values array (must be at least size 4 for with-alpha else 3)
alpha -

set

public final void set(float[] values)
Sets all values of this Tuple to the specified ones.

Parameters:
values - the values array (must be at least size 3)

setBytes

public final void setBytes(byte[] values)
Sets all values of this Tuple to the specified ones.

Parameters:
values - the values array (must be at least size 4)

setInts

public final void setInts(int[] values)
Sets all values of this Tuple to the specified ones.

Parameters:
values - the values array (must be at least size 4)

set

public final void set(Colorf color)
Sets all three values of this Tuple to the specified ones.

Parameters:
color - the tuple to be copied

set

public final void set(float r,
                      float g,
                      float b,
                      float a)
Sets all values of this color to the specified ones.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use
a - the alpha element to use

set

public final void set(float r,
                      float g,
                      float b)
Sets all values of this color to the specified ones.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use

getAWTColor

public final java.awt.Color getAWTColor()
Gets java.awt.Color.

Returns:
AWT color

get

public final void get(float[] buffer,
                      int offset)
Writes all values of this Tuple to the specified buffer.

Parameters:
buffer - the buffer array to write the values to
offset - the offset in the (target) buffer array

get

public final void get(float[] buffer)
Writes all values of this Tuple to the specified buffer.

Parameters:
buffer - the buffer array to write the values to

getBytes

public final void getBytes(byte[] buffer)
Writes all values of this Tuple to the specified buffer.

Parameters:
buffer - the buffer array to write the values to

getInts

public final void getInts(int[] buffer)
Writes all values of this Tuple to the specified buffer.

Parameters:
buffer - the buffer array to write the values to

get

public final void get(Colorf buffer)
Writes all values of this vector to the specified buffer vector.

Parameters:
buffer - the buffer vector to write the values to

writeToBuffer

public final java.nio.FloatBuffer writeToBuffer(boolean forceAlpha,
                                                java.nio.FloatBuffer buffer,
                                                boolean clear,
                                                boolean flip)
Writes the contents of this tuple to a FloatBuffer.

Parameters:
forceAlpha - if true, an alpha value is written to the buffer regardless of this color having an alpha value of not.
buffer -
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public final java.nio.FloatBuffer writeToBuffer(boolean forceAlpha,
                                                java.nio.FloatBuffer buffer,
                                                int position,
                                                boolean clear,
                                                boolean flip)
Writes the contents of this tuple to a FloatBuffer.

Parameters:
forceAlpha - if true, an alpha value is written to the buffer regardless of this color having an alpha value of not.
buffer -
position - position in the buffer
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public final java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer,
                                                boolean clear,
                                                boolean flip)
Writes the contents of this tuple to a FloatBuffer.

Parameters:
buffer -
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public final java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer,
                                                int position,
                                                boolean clear,
                                                boolean flip)
Writes the contents of this tuple to a FloatBuffer.

Parameters:
buffer -
position - position in the buffer
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public static final java.nio.FloatBuffer writeToBuffer(Colorf[] colors,
                                                       boolean forceAlpha,
                                                       java.nio.FloatBuffer buffer,
                                                       boolean clear,
                                                       boolean flip)
Writes the contents of this tuple to a FloatBuffer.

Parameters:
colors -
forceAlpha - if true, an alpha value is written to the buffer regardless of this color having an alpha value of not.
buffer -
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public static final java.nio.FloatBuffer writeToBuffer(Colorf[] colors,
                                                       boolean forceAlpha,
                                                       java.nio.FloatBuffer buffer,
                                                       int position,
                                                       boolean clear,
                                                       boolean flip)
Writes the contents of this tuple to a FloatBuffer.

Parameters:
colors -
forceAlpha - if true, an alpha value is written to the buffer regardless of this color having an alpha value of not.
buffer -
position - position in the buffer
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public static final java.nio.FloatBuffer writeToBuffer(Colorf[] colors,
                                                       java.nio.FloatBuffer buffer,
                                                       boolean clear,
                                                       boolean flip)
Writes the contents of the colors to a FloatBuffer.

Parameters:
colors -
buffer -
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public static final java.nio.FloatBuffer writeToBuffer(Colorf[] colors,
                                                       java.nio.FloatBuffer buffer,
                                                       int position,
                                                       boolean clear,
                                                       boolean flip)
Writes the contents of the colors to a FloatBuffer.

Parameters:
colors -
buffer -
position - position in the buffer
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

readFromBuffer

public final java.nio.FloatBuffer readFromBuffer(boolean forceAlpha,
                                                 java.nio.FloatBuffer buffer)
Reads the data of one tuple from a FloatBuffer.

Parameters:
buffer -
forceAlpha - if true, an alpha value is read from the buffer regardless of this color having an alpha value of not.

readFromBuffer

public final java.nio.FloatBuffer readFromBuffer(boolean forceAlpha,
                                                 java.nio.FloatBuffer buffer,
                                                 int position)
Reads the data of one tuple from a FloatBuffer.

Parameters:
forceAlpha - if true, an alpha value is read from the buffer regardless of this color having an alpha value of not.
buffer -
position - position in the buffer

readFromBuffer

public final java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer)
Reads the data of one tuple from a FloatBuffer.

Parameters:
buffer -

readFromBuffer

public final java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer,
                                                 int position)
Reads the data of one tuple from a FloatBuffer.

Parameters:
buffer -
position - position in the buffer

readFromBuffer

public static final java.nio.FloatBuffer readFromBuffer(Colorf[] colors,
                                                        boolean forceAlpha,
                                                        java.nio.FloatBuffer buffer)
Reads the data of one tuple from a FloatBuffer.

Parameters:
colors -
forceAlpha - if true, an alpha value is written to the buffer regardless of this color having an alpha value of not.
buffer -

readFromBuffer

public static final java.nio.FloatBuffer readFromBuffer(Colorf[] colors,
                                                        boolean forceAlpha,
                                                        java.nio.FloatBuffer buffer,
                                                        int position)
Reads the data of one tuple from a FloatBuffer.

Parameters:
colors -
forceAlpha - if true, an alpha value is written to the buffer regardless of this color having an alpha value of not.
buffer -
position - position in the buffer

readFromBuffer

public static final java.nio.FloatBuffer readFromBuffer(Colorf[] colors,
                                                        java.nio.FloatBuffer buffer)
Reads the data of one tuple from a FloatBuffer.

Parameters:
colors -
buffer -

readFromBuffer

public static final java.nio.FloatBuffer readFromBuffer(Colorf[] colors,
                                                        java.nio.FloatBuffer buffer,
                                                        int position)
Reads the data of one tuple from a FloatBuffer.

Parameters:
colors -
buffer -
position - position in the buffer

setRed

public final void setRed(float red)
Sets the Red color component.


getRed

public final float getRed()
Returns:
the Red color component.

r

public final void r(float red)
Sets the Red color component.


r

public final float r()
Returns:
the Red color component.

setRedByte

public final void setRedByte(byte red)
Sets the Red color component.


getRedByte

public final byte getRedByte()
Returns:
the Red color component.

setRedInt

public final void setRedInt(int red)
Sets the Red color component.


getRedInt

public final int getRedInt()
Returns:
the Red color component.

setGreen

public final void setGreen(float green)
Sets the Green color component.


getGreen

public final float getGreen()
Returns:
the Green color component.

g

public final void g(float green)
Sets the Green color component.


g

public final float g()
Returns:
the Green color component.

setGreenByte

public final void setGreenByte(byte green)
Sets the Green color component.


getGreenByte

public final byte getGreenByte()
Returns:
the Green color component.

setGreenInt

public final void setGreenInt(int green)
Sets the Green color component.


getGreenInt

public final int getGreenInt()
Returns:
the Green color component.

setBlue

public final void setBlue(float blue)
Sets the Blue color component.


getBlue

public final float getBlue()
Returns:
the Blue color component.

b

public final void b(float blue)
Sets the Blue color component.


b

public final float b()
Returns:
the Blue color component.

setBlueByte

public final void setBlueByte(byte blue)
Sets the Blue color component.


getBlueByte

public final byte getBlueByte()
Returns:
the Blue color component.

setBlueInt

public final void setBlueInt(int blue)
Sets the Blue color component.


getBlueInt

public final int getBlueInt()
Returns:
the Blue color component.

setAlpha

public final void setAlpha(float alpha)
Sets the value of the alpha-element of this color.

Parameters:
alpha -

getAlpha

public final float getAlpha()
Returns:
the value of the alpha-element of this color.

a

public final void a(float alpha)
Sets the value of the alpha-element of this color.

Parameters:
alpha -

a

public final float a()
Returns:
the value of the alpha-element of this color.

setAlphaByte

public final void setAlphaByte(byte alpha)
Sets the Alpha value component.


getAlphaByte

public final byte getAlphaByte()
Returns:
the Alhpa value component.

setAlphaInt

public final void setAlphaInt(int alpha)
Sets the Alpha value component.


getAlphaInt

public final int getAlphaInt()
Returns:
the Alhpa value component.

setZero

public final Colorf setZero()
Sets all components to zero.

Returns:
itself

addRed

public final Colorf addRed(float v)
Adds v to this color's red value.

Parameters:
v -
Returns:
itself

addGreen

public final Colorf addGreen(float v)
Adds v to this color's green value.

Parameters:
v -
Returns:
itself

addBlue

public final Colorf addBlue(float v)
Adds v to this color's blue value.

Parameters:
v -
Returns:
itself

addAlpha

public final Colorf addAlpha(float v)
Adds v to this color's alpha value.

Parameters:
v -
Returns:
itself

subRed

public final Colorf subRed(float v)
Subtracts v from this color's red value.

Parameters:
v -
Returns:
itself

subGreen

public final Colorf subGreen(float v)
Subtracts v from this color's green value.

Parameters:
v -
Returns:
itself

subBlue

public final Colorf subBlue(float v)
Subtracts v from this color's blue value.

Parameters:
v -
Returns:
itself

subAlpha

public final Colorf subAlpha(float v)
Subtracts v from this color's alpha value.

Parameters:
v -
Returns:
itself

mulRed

public final Colorf mulRed(float v)
Multiplies this color's red value with v.

Parameters:
v -
Returns:
itself

mulGreen

public final Colorf mulGreen(float v)
Multiplies this color's green value with v.

Parameters:
v -
Returns:
itself

mulBlue

public final Colorf mulBlue(float v)
Multiplies this color's blue value with v.

Parameters:
v -
Returns:
itself

mulAlpha

public final Colorf mulAlpha(float v)
Multiplies this color's alpha value with v.

Parameters:
v -
Returns:
itself

mul

public final Colorf mul(float vr,
                        float vg,
                        float vb,
                        float va)
Multiplies this color's values with vr, vg, vb, va.

Parameters:
vr -
vg -
vb -
va -
Returns:
itself

mul

public final Colorf mul(float vr,
                        float vg,
                        float vb)
Multiplies this color's values with vr, vg, vb.

Parameters:
vr -
vg -
vb -
Returns:
itself

mul

public final Colorf mul(float factor)
Sets the value of this tuple to the scalar multiplication of itself.

Parameters:
factor - the scalar value
Returns:
itself

divRed

public final Colorf divRed(float v)
Divides this color's red value by v.

Parameters:
v -
Returns:
itself

divGreen

public final Colorf divGreen(float v)
Divides this color's green value by v.

Parameters:
v -
Returns:
itself

divBlue

public final Colorf divBlue(float v)
Divides this color's blue value by v.

Parameters:
v -
Returns:
itself

divAlpha

public final Colorf divAlpha(float v)
Divides this color's alpha value by v.

Parameters:
v -
Returns:
itself

div

public final Colorf div(float vr,
                        float vg,
                        float vb,
                        float va)
Divides this color's values by vr, vg, vb, va.

Parameters:
vr -
vg -
vb -
va -
Returns:
itself

div

public final Colorf div(float vr,
                        float vg,
                        float vb)
Divides this color's values by vr, vg, vb.

Parameters:
vr -
vg -
vb -
Returns:
itself

add

public final Colorf add(Colorf color1,
                        Colorf color2)
Sets the value of this color to the vector sum of colors color1 and color2.

Parameters:
color1 - the first color
color2 - the second color
Returns:
itself

add

public final Colorf add(Colorf color2)
Sets the value of this tuple to the vector sum of itself and tuple t1.

Parameters:
color2 - the other tuple
Returns:
itself

add

public final Colorf add(float r,
                        float g,
                        float b,
                        float a)
Adds the given parameters to this tuple's values.

Parameters:
r -
g -
b -
a -
Returns:
itself

add

public final Colorf add(float r,
                        float g,
                        float b)
Adds the given parameters to this tuple's values.

Parameters:
r -
g -
b -
Returns:
itself

sub

public final Colorf sub(Colorf color1,
                        Colorf color2)
Sets the value of this color to the vector difference of color color1 and color2 (this = color1 - color2).

Parameters:
color1 - the first color
color2 - the second color
Returns:
itself

sub

public final Colorf sub(Colorf color2)
Sets the value of this color to the vector difference of itself and color2 (this = this - color2).

Parameters:
color2 - the other color
Returns:
itself

sub

public final Colorf sub(float r,
                        float g,
                        float b,
                        float a)
Subtracts the given parameters from this tuple's values.

Parameters:
r -
g -
b -
a -
Returns:
itself

sub

public final Colorf sub(float r,
                        float g,
                        float b)
Subtracts the given parameters from this tuple's values.

Parameters:
r -
g -
b -
Returns:
itself

clampMin

public final Colorf clampMin(float min)
Clamps the minimum value of this tuple to the min parameter.

Parameters:
min - the lowest value in this tuple after clamping
Returns:
itself

clampMax

public final Colorf clampMax(float max)
Clamps the maximum value of this tuple to the max parameter.

Parameters:
max - the highest value in the tuple after clamping
Returns:
itself

clamp

public final Colorf clamp(float min,
                          float max)
Clamps this tuple to the range [min, max].

Parameters:
min - the lowest value in this tuple after clamping
max - the highest value in this tuple after clamping
Returns:
itself

clamp

public final Colorf clamp(float min,
                          float max,
                          Colorf vec)
Clamps the tuple parameter to the range [min, max] and places the values into this tuple.

Parameters:
min - the lowest value in the tuple after clamping
max - the highest value in the tuple after clamping
vec - the source tuple, which will not be modified
Returns:
itself

clampMin

public final Colorf clampMin(float min,
                             Colorf vec)
Clamps the minimum value of the tuple parameter to the min parameter and places the values into this tuple.

Parameters:
min - the lowest value in the tuple after clamping
vec - the source tuple, which will not be modified
Returns:
itself

clampMax

public final Colorf clampMax(float max,
                             Colorf vec)
Clamps the maximum value of the tuple parameter to the max parameter and places the values into this tuple.

Parameters:
max - the highest value in the tuple after clamping
vec - the source tuple, which will not be modified
Returns:
itself

interpolate

public final Colorf interpolate(Colorf color2,
                                float val)
Linearly interpolates between this tuple and tuple t2 and places the result into this tuple: this = (1 - alpha) * this + alpha * t1.

Parameters:
color2 - the first tuple
val - the alpha interpolation parameter
Returns:
itself

interpolate

public final Colorf interpolate(Colorf color1,
                                Colorf color2,
                                float val)
Linearly interpolates between tuples t1 and t2 and places the result into this tuple: this = (1 - alpha) * t1 + alpha * t2.

Parameters:
color1 - the first tuple
color2 - the second tuple
val - the interpolation parameter
Returns:
itself

asReadOnly

public Colorf asReadOnly()
Returns:
a new instance sharing the values array with this instance. The new instance is read-only. Changes to this instance will be reflected in the new read-only-instance.
See Also:
getReadOnly()

getReadOnly

public Colorf getReadOnly()
Returns:
a single instance sharing the values array with this instance (one unique instance per 'master-instance'). The instance is read-only. Changes to this instance will be reflected in the read-only-instance.
See Also:
asReadOnly()

hashCode

public int hashCode()
Returns a hash number based on the data values in this object. Two different Tuple3f objects with identical data values (ie, returns true for equals(Tuple3f) ) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(Colorf color2)
Returns true if all of the data members of Tuple3f t1 are equal to the corresponding data members in this

Parameters:
color2 - the color with which the comparison is made.

equals

public boolean equals(java.lang.Object o)
Returns true if the Object t1 is of type Tuple3f and all of the data members of t1 are equal to the corresponding data members in this Tuple3f.

Overrides:
equals in class java.lang.Object
Parameters:
o - the Object with which the comparison is made
Returns:
true or false

epsilonEquals

public boolean epsilonEquals(Colorf color2,
                             float epsilon)
Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2)].

Parameters:
color2 - the color to be compared to this color
epsilon - the threshold value

toHexString

public final java.lang.String toHexString()
Returns:
a hex-String represending the RGB-values of this color.

toString

public java.lang.String toString()
Returns a string that contains the values of this Colorf. The form is ( red = f, green = f, blue = f, alpha = f ).

Overrides:
toString in class java.lang.Object
Returns:
the String representation

clone

public Colorf clone()
Creates and returns a copy of this object.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
java.lang.OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

serialize

public int serialize(int pos,
                     byte[] buffer)
Serializes this instanc'es data into the byte array.

Parameters:
pos -
buffer -
Returns:
the incremented position

deserialize

public int deserialize(int pos,
                       byte[] buffer)
Deserializes this instanc'es data from the byte array.

Parameters:
pos -
buffer -
Returns:
the incremented position

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

newReadOnly

public static Colorf newReadOnly(float r,
                                 float g,
                                 float b,
                                 float a)
Creates a new read-only Colorf instance.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use
a - the alpha channel to use

newReadOnly

public static Colorf newReadOnly(float r,
                                 float g,
                                 float b)
Creates a new read-only Colorf instance.

Parameters:
r - the red element to use
g - the green element to use
b - the blue element to use

newReadOnly

public static Colorf newReadOnly(float intensity)
Creates a new read-only Colorf instance.

Parameters:
intensity - the gray intensity (used for all three r,g,b values

newReadOnly

public static Colorf newReadOnly(float[] values)
Creates a new read-only Colorf instance.

Parameters:
values - the values array (must be at least size 3)

newReadOnly

public static Colorf newReadOnly(Colorf color)
Creates a new read-only Colorf instance.

Parameters:
color - the Colorf to copy the values from

newReadOnly

public static Colorf newReadOnly(Colorf rgbColor,
                                 float alpha)
Creates a new read-only Colorf instance.

Parameters:
rgbColor - the Colorf to copy the RGB-values from
alpha - the value for the alpha channel

newReadOnly

public static Colorf newReadOnly()
Creates a new read-only Colorf instance.


newReadOnly

public static Colorf newReadOnly(java.awt.Color color)

parseColor

public static Colorf parseColor(java.lang.String hexString,
                                Colorf buffer)
Parses a color-hex-String into the color buffer.
The color must be of the form "#XXXXXX" or "XXXXXX", where the Xes must be hex chars.

Parameters:
hexString -
buffer -
Returns:
the color back again

parseColor

public static Colorf parseColor(java.lang.String hexString)
Parses a color-hex-String into a Colorf instance.
The color must be of the form "#RRGGBB" or "RRGGBB" or "#RRGGBBAA" or "RRGGBBAA", where the letters must be hex chars.

Parameters:
hexString -
Returns:
the new Colorf instance

parseReadOnlyColor

public static Colorf parseReadOnlyColor(java.lang.String hexString)
Parses a color-hex-String into a new Colorf instance.
The color must be of the form "#RRGGBB" or "RRGGBB" or "#RRGGBBAA" or "RRGGBBAA", where the letters must be hex chars.

Parameters:
hexString -
Returns:
the new Colorf instance

fromPool

public static Colorf fromPool()
Allocates an Colorf instance from the pool.


fromPool

public static Colorf fromPool(float r,
                              float g,
                              float b,
                              float a)
Allocates an Colorf instance from the pool.


fromPool

public static Colorf fromPool(float r,
                              float g,
                              float b)
Allocates an Colorf instance from the pool.


fromPool

public static Colorf fromPool(Colorf color)
Allocates an Colorf instance from the pool.


toPool

public static void toPool(Colorf o)
Stores the given Colorf instance in the pool.

Parameters:
o -