|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.foray.fotree.value.Expr
org.foray.fotree.value.ExprAdditive
org.foray.fotree.value.ExprMultiplicative
org.foray.fotree.value.ExprUnary
org.foray.fotree.value.ExprPrimary
org.foray.fotree.value.Datatype
org.foray.fotree.value.DtColor
public final class DtColor
A "color" property datatype in XSL-FO. See XSL-FO Std. 1.0, Sec. 5.11.
To prevent creation of multiple instances for the same underlying color,
the constructor is private.
To obtain an instance, use one of the following static methods instead:
makeDtColor(String)
, makeDtColor(Color)
, or
makeDtColor(float, float, float, float)
.
Field Summary | |
---|---|
static Color |
COLOR_RGB_TRANSPARENT
A standard transparent color. |
static byte |
SRGB_ALPHA_COMPONENT
Constant indicating the index to the Alpha component in the sRGB color space. |
static byte |
SRGB_BLUE_COMPONENT
Constant indicating the index to the Blue component in the sRGB color space. |
static byte |
SRGB_COMPONENTS
Constant indicating the number of components in the sRGB color space. |
static byte |
SRGB_GREEN_COMPONENT
Constant indicating the index to the Green component in the sRGB color space. |
static byte |
SRGB_RED_COMPONENT
Constant indicating the index to the Red component in the sRGB color space. |
Fields inherited from class org.foray.fotree.value.Expr |
---|
OPERATION_ADD, OPERATION_DIVIDE, OPERATION_MOD, OPERATION_MULTIPLY, OPERATION_NEGATION, OPERATION_SUBTRACT, UNIT_POWER_AREA, UNIT_POWER_LENGTH, UNIT_POWER_NON_NUMERIC, UNIT_POWER_NUMERIC |
Method Summary | |
---|---|
boolean |
canEvalColor()
Indicates whether this property value has the ability to express itself as a Color. |
boolean |
canEvalInteger()
Indicates whether this property value has the ability to express itself as an integer Numeric item. |
boolean |
canEvalKeyword()
Indicates whether this property value can evaluate to a keyword. |
boolean |
canEvalLength()
Indicates whether this expression can be evaluated to a unit power = 1 (length) or not. |
boolean |
canEvalNumeric()
Indicates whether this property value has the ability to express itself as a Numeric item. |
boolean |
canEvalPercentage()
Indicates whether this property value can evaluate to a percentage. |
Color |
evalColor()
Returns the encapsulated Color. |
int |
evalInteger()
Return this value as an int. |
PvKeyword |
evalKeyword()
Returns the keyword value of this property value. |
int |
evalLength(int pointSize)
Evaluates the expression to a unit power of 1 (length). |
double |
evalNumeric()
Return the raw numeric value of "this", without regard to unit power. |
float |
evalPercentage()
Returns the percentage value of this property value. |
byte |
getUnitPower()
Each numeric has a "unit power". |
Color |
getValue()
Returns the color value. |
boolean |
lengthRequiresFontSize()
Indicates whether the computation of the length will require an accurate font-size parameter. |
static DtColor |
makeDtColor(Color color)
Factory method that creates or retrieves a DtColor instance for
a given color. |
static DtColor |
makeDtColor(float red,
float green,
float blue,
float alpha)
Factory method that creates or retrieves a DtColor instance
for a set of color components. |
static DtColor |
makeDtColor(String input)
Factory method which converts a named color into a ColorDT instance. |
static DtColor |
mapNameToColorRGB(String colorName)
Returns a standard XSL-FO color from its name. |
static DtColor |
mapSecondaryNameToColorRGB(String colorName)
Returns a color from its name, including standard XSL-FO named colors and the additional ones supplied by FOray. |
static DtColor |
parseColorDescription(String inputValue)
Converts a String color description to a DtColor instance. |
static float |
parseShortRGBColor(String colorString,
int componentIndex,
boolean longFormat)
Parses a specific color value out of a String in the form of #RGB (short format), or #RRGGBB (long format), returning the color value in the range 0 thru 1. |
Methods inherited from class org.foray.fotree.value.Datatype |
---|
convertValueToFoValue |
Methods inherited from class org.foray.fotree.value.Expr |
---|
evalColorException, evalIntegerException, evalKeywordException, evalLengthException, evalNumericException, evalPercentageException |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Color COLOR_RGB_TRANSPARENT
public static final byte SRGB_COMPONENTS
public static final byte SRGB_RED_COMPONENT
public static final byte SRGB_GREEN_COMPONENT
public static final byte SRGB_BLUE_COMPONENT
public static final byte SRGB_ALPHA_COMPONENT
Method Detail |
---|
public Color getValue()
public boolean canEvalColor()
public Color evalColor()
public static DtColor makeDtColor(String input)
input
- The named color (for example, "blue" or "teal") to be
converted.
public static DtColor makeDtColor(Color color)
DtColor
instance for
a given color.
color
- The color to wrap.
public static DtColor makeDtColor(float red, float green, float blue, float alpha)
DtColor
instance
for a set of color components.
red
- The red value of the color to wrap (0 thru 1).green
- The green value of the color to wrap (0 thru 1).blue
- The blue value of the color to wrap (0 thru 1).alpha
- The alpha value of the color to wrap (0 thru 1).
public static DtColor mapNameToColorRGB(String colorName)
colorName
- The name of the color to be returned.
public static DtColor mapSecondaryNameToColorRGB(String colorName)
colorName
- The name of the color to be returned.
public static DtColor parseColorDescription(String inputValue) throws PropertyException
inputValue
- The color description in one of the following formats:
1) a color name, 2) an #RGB description, or 3) an #RRGGBB description.
PropertyException
- If the input value is not valid.public static float parseShortRGBColor(String colorString, int componentIndex, boolean longFormat)
colorString
- The String containing the color descriptor, in the
format #RGB (short format), or #RRGGBB (long format).componentIndex
- The index to the component to be parsed, one of
SRGB_RED_COMPONENT
,
SRGB_GREEN_COMPONENT
, or
SRGB_BLUE_COMPONENT
.longFormat
- Set to true if the input is in long format, false if
it is in short format.
public boolean canEvalNumeric()
PropertyValue
public double evalNumeric()
PropertyValue
public boolean canEvalLength()
PropertyValue
public byte getUnitPower()
PropertyValue
Expr.UNIT_POWER_NUMERIC
or Expr.UNIT_POWER_LENGTH
.public int evalLength(int pointSize)
PropertyValue
pointSize
- The point size, in millipoints, of the font.
This is used in calculations that are relative to the point size.
In cases where the computation of the font-size is expensive, check
PropertyValue.lengthRequiresFontSize()
first.
If that method returns false, zero or some other constant can safely
be passed, as it will be ignored anyway.
Integer.MIN_VALUE
otherwise.
The value is expressed in millipoints.public boolean lengthRequiresFontSize()
PropertyValue
public boolean canEvalInteger()
PropertyValue
public int evalInteger()
PropertyValue
PropertyValue.canEvalInteger()
returns true.
Doing so on other instances may result in an
IllegalStateException
.
public boolean canEvalKeyword()
PropertyValue
public PvKeyword evalKeyword()
PropertyValue
PropertyValue.canEvalKeyword()
returns true.
Doing so on other instances may result in an
IllegalStateException
.
public boolean canEvalPercentage()
PropertyValue
public float evalPercentage()
PropertyValue
PropertyValue.canEvalPercentage()
returns true.
Doing so on other instances may result in an
IllegalStateException
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |