|
JavaView® v2.12 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--jv.object.PsObject
|
+--jv.number.PdColor
RGBA color class with info panel and update functionality.
The class is derived from PsObject rather than java.awt.Color since the focus of this class is the update functionality and handling of an info panel for interactive modifications. The class PdColor allows interactive modification of a color similar to the class PuDouble and PuInteger allow for double and integer numbers. Also, java.awt.Color cannot be modified after construction.
TODO: Subclassing of PsObject will be replaced by implementing interface PsUpdateIf and some methods currently inherited from PsObject.
PdColor,
PdColor_Dialog, Serialized Form| Fields inherited from class jv.object.PsObject |
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, NUM_TAGS |
| Constructor Summary | |
PdColor()
Constructor of color in RGB mode with alpha disabled. |
|
PdColor(int size,
boolean bAlpha)
Constructor of color in RGB mode with number of color components and possible alpha channel. |
|
PdColor(java.lang.String aName,
PsUpdateIf aParent)
Constructor of color in RGB mode with alpha disabled. |
|
| Method Summary | |
static java.awt.Color |
blend(double a,
java.awt.Color v,
double b,
java.awt.Color w)
Interpolate between two colors with given weights. |
void |
blend(double a,
PdColor v,
double b,
PdColor w)
Interpolate between two colors with given weights. |
void |
blendBase(PdColor v,
double b,
PdColor w)
Interpolate between two colors with given weights. |
java.lang.Object |
clone()
Duplicate color and data array. |
static boolean |
copy(java.awt.Color[] dataDest,
int destInd,
java.awt.Color[] dataSrc,
int srcInd,
int size)
Assign some colors of a given array of colors to an existing destination array. |
void |
copy(double[] anArray,
int aSize)
Copy color components excluding alpha. |
void |
copy(int[] anArray,
int aSize)
Copy color components excluding alpha. |
void |
copy(PdColor v)
Copy color components including alpha. |
static boolean |
copy(PdColor[] dataDest,
int destInd,
PdColor[] dataSrc,
int srcInd,
int size)
Copies some colors of a given array of colors into an existing destination array. |
static PdColor |
copyNew(PdColor v)
Create a new color as clone of argument color. |
static PdColor[] |
copyNew(PdColor[] data)
Create an new array with copies of all colors of a given array of colors. |
static PdColor[] |
copyNew(PdColor[] data,
int size)
Create an new array with copies of the first 'size' colors of a given array of colors. |
void |
enableAlpha(boolean aValue)
Enable or disable alpha channel. |
boolean |
equals(java.awt.Color col)
Determines whether another color is equal to this color. |
boolean |
equals(PdColor col)
Determines whether another color is equal to this color. |
int |
getAlpha()
Get alpha component if alpha is enabled, otherwise result is 0. |
int |
getBlue()
Get blue color component if size==3, otherwise result is 0. |
java.awt.Color |
getColor()
Convert color components in a java.awt.Color instance. |
static java.awt.Color |
getDimmedColor(java.awt.Color col,
double dim)
Get a color whose components are dimmed by a factor. |
static java.awt.Color |
getDimmedColor(java.awt.Color col,
double dim,
double offset)
Get a color whose components are dimmed by a factor and shifted by an offset. |
int |
getEntry(int ind)
Get a color component with given index. |
int |
getGreen()
Get green color component if size==3, otherwise result is 0. |
int |
getGrey()
Get grey color if size==1, otherwise result is 0. |
int |
getRed()
Get red color component if size==3, otherwise result is 0. |
int |
getSize()
Return number of components excluding alpha. |
boolean |
hasAlpha()
Check whether alpha channel is used. |
static java.awt.Color |
hsl2rgb(int hi,
int li,
int si)
|
static java.awt.Color |
hsv2rgb(java.awt.Color hsv)
Conversion of color spaces. |
static java.awt.Color |
hsv2rgb(int h,
int s,
int v)
Conversion of color spaces. |
static void |
hsv2rgb(PdColor rgb,
PdColor hsv)
Conversion of color spaces. |
int |
indexOfMax()
Find component in color with maximal value. |
int |
indexOfMin()
Find component in color with minimal value. |
void |
init()
Initialize and reset components to 0. |
boolean |
isEnabled()
Check whether color dialog is enabled or disabled. |
int |
max()
Find maximal value of component in color. |
int |
min()
Find minimal value of component in color. |
static java.awt.Color |
parseColor(java.lang.String colorString)
Parse rgb color from a given string where each component is integer in the range 0..255 and blank or comma separated. |
static java.awt.Color[] |
realloc(java.awt.Color[] data,
int arraySize)
Allocate an array of Java colors and assign default color black. |
static PdColor[] |
realloc(PdColor[] data,
int arraySize,
int colorSize)
Allocate an array of colors, where all colors have the same dimension. |
static PdColor[] |
realloc(PdColor[] data,
int arraySize,
int colorSize,
boolean bAlpha)
Allocate an array of colors, where all colors have the same dimension. |
static java.awt.Color |
rgb2hsl(int ri,
int gi,
int bi)
|
static void |
rgb2hsv(PdColor hsv,
PdColor rgb)
Conversion of color spaces. |
static java.awt.Color |
rgb2yiq(int ri,
int gi,
int bi)
|
void |
set(double grey)
Set grey component of this color using double arguments in [0., 1.]. |
void |
set(double red,
double green,
double blue)
Set components of this color using double arguments in [0., 1.]. |
void |
set(double red,
double green,
double blue,
double alpha)
Set components of this color using double arguments in [0., 1.]. |
void |
set(int grey)
Set grey component of this color using integer argument in [0, 255]. |
void |
set(int red,
int green,
int blue)
Set components of this color using integer argument in [0, 255]. |
void |
set(int red,
int green,
int blue,
int alpha)
Set components of this color using double arguments in [0, 255]. |
void |
setAlpha(double x)
Set alpha component of this color using double argument in [0., 1.]. |
void |
setAlpha(int x)
Set alpha component of this color using integer argument in [0, 255]. |
void |
setColor(java.awt.Color aColor)
Set color components to components of argument color. |
void |
setConstant(int val)
Set all color components including alpha to the same value. |
void |
setEnabled(boolean flag)
Enable or disable the color dialog for interactive use. |
void |
setEntry(int ind,
int value)
Set a color component with given index to value. |
void |
setSize(int aSize)
Set number of components of color excluding alpha. |
static java.awt.Color |
yiq2rgb(int yi,
int ii,
int qi)
|
| Methods inherited from class jv.object.PsObject |
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, update, updatePanels |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public PdColor()
public PdColor(int size,
boolean bAlpha)
size - number of color components excluding alphabAlpha - true to enable alpha channel
public PdColor(java.lang.String aName,
PsUpdateIf aParent)
aName - name of color, e.g. used as header in info panelaParent - parent receives update events, e.g. when color changes through info panel| Method Detail |
public void init()
init in class PsObjectpublic boolean isEnabled()
public void setEnabled(boolean flag)
setValue(double), and the color dialog
is always updated.public int getSize()
public void setSize(int aSize)
aSize - number of color components, e.g. 3 in rgb mode.public boolean equals(java.awt.Color col)
true if both colors have same color components
excluding alpha. Result is also true
if argument color is null and this color has no entries.
Alpha is not compared since Java1.1 does not support alpha in java.awt.Color.
col - the color to compare withtrue if the color component are the same; false otherwise.public boolean equals(PdColor col)
true if both colors have same size and
equal components including alpha. Result is also true
if argument color is null and this color has no entries.col - the color to compare withtrue if the objects are the same; false otherwise.public int getGrey()
size==1, otherwise result is 0.public int getRed()
size==3, otherwise result is 0.public int getGreen()
size==3, otherwise result is 0.public int getBlue()
size==3, otherwise result is 0.public int getAlpha()
public static java.awt.Color getDimmedColor(java.awt.Color col,
double dim)
col - color to modify.dim - factor to be multiplied to all color components.
public static java.awt.Color getDimmedColor(java.awt.Color col,
double dim,
double offset)
col - color to modify.dim - factor to be multiplied to all color components.offset - constant to be added to all color components after dimming.public java.awt.Color getColor()
null if less than 3 components available.public void setColor(java.awt.Color aColor)
public boolean hasAlpha()
true of alpha channel is used; false otherwise.enableAlpha(boolean)public void enableAlpha(boolean aValue)
true - to enable alpha channel.setSize(int)public int getEntry(int ind)
ind - index of requested color component
public void setEntry(int ind,
int value)
ind - index of color component to be modifiedval - value in [0,255] for all components of colorpublic void setConstant(int val)
val - value in [0,255] for all components of colorpublic void setAlpha(int x)
alpha - new alpha component in [0, 255]public void setAlpha(double x)
alpha - new alpha component in [0., 1.]public void set(int grey)
size == 1 excluding alpha.
If this color has too few components then a warning is issued without changes.grey - new grey component in [0, 255]
public void set(int red,
int green,
int blue)
size == 3 excluding alpha.
If this color has too few components then a warning is issued without changes.red, - green, blue new color components in [0, 255]
public void set(int red,
int green,
int blue,
int alpha)
red, - green, blue new color components in [0, 255]alpha - new alpha components in [0, 255]public void set(double grey)
size == 1 excluding alpha.
If this color has too few components then a warning is issued without changes.grey - new grey component in [0., 1.]
public void set(double red,
double green,
double blue)
red, - green, blue new color components in [0., 1.]
public void set(double red,
double green,
double blue,
double alpha)
red, - green, blue new color components in [0., 1.]alpha - new alpha components in [0., 1.]public java.lang.Object clone()
copyNew(PdColor).clone in class PsObjectcopyNew(PdColor)public static PdColor copyNew(PdColor v)
v - source color to clonepublic void copy(PdColor v)
v - source color to copy
public void copy(int[] anArray,
int aSize)
anArray - new color components in [0, 255]
public void copy(double[] anArray,
int aSize)
anArray - new color components in [0., 1.]public int max()
min(),
indexOfMax()public int min()
min(),
indexOfMax()public int indexOfMax()
public int indexOfMin()
public static java.awt.Color blend(double a,
java.awt.Color v,
double b,
java.awt.Color w)
this = v*a + w*b including alpha component.
If result color 'this' is empty then its size is set to size if color v,
otherwise no interpolation is performed.v - first colora - weight of color vw - second colorb - weight of color wblend(double, PdColor, double, PdColor)
public void blend(double a,
PdColor v,
double b,
PdColor w)
this = v*a + w*b including alpha component.
If result color 'this' is empty then its size is set to size if color v,
otherwise no interpolation is performed.v - first colora - weight of color vw - second colorb - weight of color wblendBase(PdColor, double, PdColor)
public void blendBase(PdColor v,
double b,
PdColor w)
this = v + w*b including alpha component.
If result color 'this' is empty then its size is set to size if color v,
otherwise no interpolation is performed.v - first colorw - second colorb - weight of color wblend(double, PdColor, double, PdColor)
public static java.awt.Color[] realloc(java.awt.Color[] data,
int arraySize)
data!=null then as most as possible of the content of
existing colors is copied into (possibly reused) colors of the
reallocated array.
Assignment of default color does not waist memory since assignment is
made to a static class.
If requested array size is 0 then method returns an array of length 0.
data - possibly empty array of colorsarraySize - number of colors in new array
public static PdColor[] realloc(PdColor[] data,
int arraySize,
int colorSize)
data!=null then as most as possible of the content of
existing colors is copied into (possibly reused) colors of the
reallocated array. Colors have no alpha channel.data - possibly empty array of colorsarraySize - number of colors in new arraycolorSize - dimension of colors in new array
public static PdColor[] realloc(PdColor[] data,
int arraySize,
int colorSize,
boolean bAlpha)
data!=null then as most as possible of the content of
existing colors is copied into (possibly reused) colors of the
reallocated array.data - possibly empty array of colorsarraySize - number of colors in new arraycolorSize - dimension of colors in new arraybAlpha - flag whether alpha is enabledpublic static PdColor[] copyNew(PdColor[] data)
data - array of colorscopyNew(PdColor [], int),
copy(PdColor [], int, PdColor [], int, int)
public static PdColor[] copyNew(PdColor[] data,
int size)
data - array of colorssize - number of copied colors of arraycopyNew(PdColor []),
copy(PdColor [], int, PdColor [], int, int)
public static boolean copy(java.awt.Color[] dataDest,
int destInd,
java.awt.Color[] dataSrc,
int srcInd,
int size)
for (int i=0; iDestination array must be large enough, i.e. dataDest.length >= destInd+size.
- Parameters:
dataDest- destination array of colorsdestInd- index of first destination color in dataDestdataSrc- source array of colorssrcInd- index of first source color in dataSrc used for copyingsize- number of assigned colors of array- Returns:
trueif destination array is large enough- See Also:
copy(PdColor)
public static boolean copy(PdColor[] dataDest,
int destInd,
PdColor[] dataSrc,
int srcInd,
int size)
for (int i=0; iDestination array must be large enough, i.e. dataDest.length >= destInd+size.
- Parameters:
dataDest- destination array of colorsdestInd- index of first destination color in dataDestdataSrc- source array of colorssrcInd- index of first source color in dataSrc used for copyingsize- number of copied colors of array- Returns:
trueif destination array is large enough- See Also:
copy(PdColor)
public static void rgb2hsv(PdColor hsv,
PdColor rgb)
public static void hsv2rgb(PdColor rgb,
PdColor hsv)
public static java.awt.Color hsv2rgb(java.awt.Color hsv)
public static java.awt.Color hsv2rgb(int h,
int s,
int v)
public static java.awt.Color hsl2rgb(int hi,
int li,
int si)
public static java.awt.Color rgb2hsl(int ri,
int gi,
int bi)
public static java.awt.Color yiq2rgb(int yi,
int ii,
int qi)
public static java.awt.Color rgb2yiq(int ri,
int gi,
int bi)
public static java.awt.Color parseColor(java.lang.String colorString)
colorString - string with integer color componentsnull if less than 3 components available.
|
JavaView® v2.12 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||