|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object facets.util.shade.Shade
public final class Shade
Named abstract colour.
Shade
defines an immutable 24-bit RGB colour that is guaranteed to
have a human-readable name. Methods mostly return properties in RGB and HSB terms,
and new shades of the colour.
Field Summary | |
---|---|
static int |
B
Index into values array. |
static double |
FACTOR_B
Brightening/darkening factor. |
static int |
G
Index into values array. |
static int |
H
Index into values array. |
static int |
R
Index into values array. |
static int |
S
Index into values array. |
static double |
THRESHOLD_B
HSB threshold value |
static double |
THRESHOLD_S
HSB threshold value |
static java.lang.String |
TITLE_CUSTOM
Default title for custom shades. |
Constructor Summary | |
---|---|
Shade(double[] hsb,
java.lang.String title)
Convenience constructor accepting HSB values. |
|
Shade(int rgb,
java.lang.String title)
Core constructor. |
Method Summary | |
---|---|
Shade |
brighter()
Creates a brighter version of the shade. |
int |
compareTo(java.lang.Object o)
Compares the rgb values of two shades. |
Shade |
darker()
Creates a darker version of the shade. |
boolean |
equals(java.lang.Object o)
Checks the rgb values of two shades. |
int |
hashCode()
Returns the rgb value. |
java.lang.Object |
identity()
Return an object that is as far as possible unique for the implementation. |
boolean |
isBright()
True if HSB brightness is higher than THRESHOLD_B . |
boolean |
isSaturated()
True if HSB saturation is higher than THRESHOLD_S . |
Shade |
resaturated(boolean saturated)
Creates a new version of the shade with HSB saturation of either 1.0 or below THRESHOLD_S . |
int |
rgb()
The 24-bit RGB value for the shade. |
void |
setTitle(java.lang.String title)
|
int |
snapRGB(int bitLength)
The RGB color value to a specified reduced accuracy. |
java.lang.String |
title()
The title passed to the constructor. |
java.lang.String |
toString()
|
double[] |
valuesHSB()
The HSB description of the shade. |
int[] |
valuesRGB()
The RGB components of the shade. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int H
public static final int S
public static final int B
public static final int R
public static final int G
public static final java.lang.String TITLE_CUSTOM
public static final double FACTOR_B
public static final double THRESHOLD_S
public static final double THRESHOLD_B
Constructor Detail |
---|
public Shade(double[] hsb, java.lang.String title)
hsb
- is converted to RGB equivalenttitle
- is passed to core constructorpublic Shade(int rgb, java.lang.String title)
rgb
- is interpreted as a 24-bit RGB color value.title
- must be non-null
and conform to the contract of
Titled
.Method Detail |
---|
public int rgb()
public java.lang.String title()
If the shade was created using a newXXXed method, the title will be
TITLE_CUSTOM
(which can be used for any 'anonymous' shade).
Note that the title does not form part of the shade's identity. Different shades
can share a title (especially TITLE_CUSTOM
); different titles may be
returned by shades for which equals
returns true
.
title
in interface Titled
null
, non-empty string with no structural whitespacepublic boolean isBright()
THRESHOLD_B
.
public Shade brighter()
HSB brightness will be higher than the source shade by FACTOR_B
,
up to a maximum of 1.0.
Title will be TITLE_CUSTOM
).
public Shade darker()
HSB brightness will be lower than the source shade by 1/FACTOR_B
.
Title will be TITLE_CUSTOM
).
public boolean isSaturated()
THRESHOLD_S
.
public Shade resaturated(boolean saturated)
THRESHOLD_S
.
saturated
- switches saturation on if true
public int[] valuesRGB()
Returned as an int[3]
with values in range 0 to 255.
public double[] valuesHSB()
Returned as a double[3]
with values in range 0.0 to 1.0.
public int snapRGB(int bitLength)
Components are truncated to fit the complete value
within bitLength
. So-called because its intended use is to
determine whether one shade can reasonably be 'snapped' to another.
bitLength
- the bit length to be used; must be divisible by 3public int compareTo(java.lang.Object o)
rgb
values of two shades.
Note that title
is ignored.
compareTo
in interface java.lang.Comparable
public boolean equals(java.lang.Object o)
rgb
values of two shades.
Note that title
is ignored.
equals
in class java.lang.Object
public int hashCode()
rgb
value.
Note that title
is ignored.
hashCode
in class java.lang.Object
public java.lang.Object identity()
Identified
This will usually be a class instance counter.
identity
in interface Identified
public java.lang.String toString()
toString
in class java.lang.Object
public final void setTitle(java.lang.String title)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |