Package vrml.field
Class MFColor
java.lang.Object
vrml.Field
vrml.MField
vrml.field.MFColor
- All Implemented Interfaces:
Cloneable
VRML JSAI type class containing multiple color fields.
Internally, the class stores the values as a single, flat array so that is the most efficient method to use to avoid reallocation. All methods make internal copies of the values.
- Version:
- $Revision: 1.7 $
- Author:
- Alan Hudson, Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
How much should we increment the array by when there is an add or insert request.protected float[]
The color valuesFields inherited from class vrml.MField
numElements
Fields inherited from class vrml.Field
valueChanged
-
Constructor Summary
ConstructorsConstructorDescriptionMFColor()
Construct a new default color with the value set to an empty array.MFColor
(float[] colors) Construct a new color array based on all the given values.MFColor
(float[][] colors) Construct a new color array based on all the given values.MFColor
(int size, float[] colors) Cosntruct a new colour array based on a fraction of the items supplied. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addValue
(float red, float green, float blue) Append the components as a new color value to the end of this field.void
addValue
(ConstSFColor color) Append the field as a new color value to the end of this field.void
Append the field as a new color value to the end of this field.void
clear()
Clear the field of all elementsclone()
Make a clone of this object.void
delete
(int index) Remove the element at the given position and shift any other items down.void
get1Value
(int index, float[] colors) Copy the value of the color at the given index into the user array.void
Copy the color value at the given index into the supplied field.void
getValue
(float[] colors) Returns the value of this field as a flat array.void
getValue
(float[][] colors) Copy the values from this field into the given array.void
insertValue
(int index, float red, float green, float blue) Insert the color represented by the components at the given position in the array.void
insertValue
(int index, ConstSFColor color) Insert the color represented by the given field at the given position in the array.void
insertValue
(int index, SFColor color) Insert the color represented by the given field at the given position in the array.void
set1Value
(int index, float red, float green, float blue) Set the element at the given index with the given color components.void
set1Value
(int index, ConstSFColor color) Set the element at the given index with the value from the given field.void
Set the element at the given index with the value from the given field.void
setValue
(float[] colors) Set the field to the new values.void
setValue
(float[][] colors) Set the field to the new values.void
setValue
(int size, float[] colors) Set the value of this field given limited array of colors.void
setValue
(ConstMFColor colors) Set the value of this field to the values in the given field.void
Set the value of this field based on the values in the given field.toString()
Create a string representation of the field values.
-
Field Details
-
ARRAY_INC
protected static final int ARRAY_INCHow much should we increment the array by when there is an add or insert request. This value is array items, not elements.- See Also:
-
data
protected float[] dataThe color values
-
-
Constructor Details
-
MFColor
public MFColor()Construct a new default color with the value set to an empty array. -
MFColor
public MFColor(float[][] colors) Construct a new color array based on all the given values.- Parameters:
colors
- The source colour values to use
-
MFColor
public MFColor(float[] colors) Construct a new color array based on all the given values.- Parameters:
colors
- The source colour values to use
-
MFColor
public MFColor(int size, float[] colors) Cosntruct a new colour array based on a fraction of the items supplied.- Parameters:
size
- The number of colors is size / 3.colors
- The source color values to use
-
-
Method Details
-
getValue
public void getValue(float[][] colors) Copy the values from this field into the given array.- Parameters:
colors
- The target array to copy values into
-
getValue
public void getValue(float[] colors) Returns the value of this field as a flat array. Values are arranged as [0 - 2] = Color1, [3 - 5] = Color2...- Parameters:
colors
- Color triplicates flattened
-
get1Value
public void get1Value(int index, float[] colors) Copy the value of the color at the given index into the user array.- Parameters:
index
- The index in the array of values to readcolors
- The array to copy the color value to
-
get1Value
Copy the color value at the given index into the supplied field.- Parameters:
index
- The index in the array of values to readcolor
- The field to copy the color value to
-
setValue
public void setValue(float[][] colors) Set the field to the new values.- Parameters:
colors
- The new color values to use
-
setValue
public void setValue(float[] colors) Set the field to the new values.- Parameters:
colors
- The new color values to use
-
setValue
public void setValue(int size, float[] colors) Set the value of this field given limited array of colors. Values are arranged as [0 - 2] = Color1, [3 - 5] = Color2...- Parameters:
size
- The number of colors is size / 3.colors
- Color triplicates flattened.
-
setValue
Set the value of this field based on the values in the given field.- Parameters:
colors
- The field to copy from
-
setValue
Set the value of this field to the values in the given field.- Parameters:
colors
- The field to copy from
-
set1Value
Set the element at the given index with the value from the given field.- Parameters:
index
- The index of the element to setcolor
- The field to copy the data from
-
set1Value
Set the element at the given index with the value from the given field.- Parameters:
index
- The index of the element to setcolor
- The field to copy the data from
-
set1Value
public void set1Value(int index, float red, float green, float blue) Set the element at the given index with the given color components.- Parameters:
index
- The index of the element to setred
- The red component to usegreen
- The green component to useblue
- The blue component to use
-
addValue
Append the field as a new color value to the end of this field.- Parameters:
color
- The field to append
-
addValue
Append the field as a new color value to the end of this field.- Parameters:
color
- The field to append
-
addValue
public void addValue(float red, float green, float blue) Append the components as a new color value to the end of this field.- Parameters:
red
- The red component to usegreen
- The green component to useblue
- The blue component to use
-
insertValue
Insert the color represented by the given field at the given position in the array.- Parameters:
index
- The position to insert the valuecolor
- The color field to insert
-
insertValue
Insert the color represented by the given field at the given position in the array.- Parameters:
index
- The position to insert the valuecolor
- The color field to insert
-
insertValue
public void insertValue(int index, float red, float green, float blue) Insert the color represented by the components at the given position in the array.- Parameters:
index
- The position to insert the valuered
- The red component to usegreen
- The green component to useblue
- The blue component to use
-
clear
-
delete
-
toString
-
clone
-