The Color Class

The Color class provides methods for specifying the color of an object.

Member Objects: Static Member Variables

These member variables do not require an object. They are prefixed by the Color class name.

Table 1. Member Objects (Static Member Variables)
Name Description
BLACK Specifies a Color object having the color BLACK
BLUE Specifies a Color object having the color BLUE
CYAN Specifies a Color object having the color CYAN
DARK_GRAY Specifies a Color object having the color DARK_GRAY
GRAY Specifies a Color object having the color GRAY
GREEN Specifies a Color object having the color GREEN
LIGHT_GRAY Specifies a Color object having the color LIGHT_GRAY
MAGENTA Specifies a Color object having the color MAGENTA
ORANGE Specifies a Color object having the color ORANGE
PINK Specifies a Color object having the color PINK
RED Specifies a Color object having the color RED
WHITE Specifies a Color object having the color WHITE
YELLOW Specifies a Color object having the color YELLOW

Usage

With RTL classes, it is not possible to create and subclass objects. The new keyword is not supported.

The default color for a report item, such as a Layout Node, is black. You can change the color of the item by entering a value for the color or bgColor property in the Properties View. These properties are of type Color; Instead of selecting a color from the Edit Expressions color palette, you can use the members of this class in an expression that returns a Color object.

Member Objects Usage

These objects are static member variables that do not require an object instance. The variables are prefixed with the Color class name and the '.' character.

This example displays red text if balance is below zero, and otherwise displays black text:
balance<0?Color.RED:Color.BLACK

Class Methods

Class methods do not require a Color object instance. When you invoke a class method, it is prefixed with the Color class name and the '.' character.

Table 2. Class Methods (Static Member Methods)
Name Description
Color fromHSBA(Numeric h, Numeric s, Numeric b [, Numeric a])
Returns a Color object based on the specified values of hue, saturation, brightness, and (optionally) alpha for the HSB color model.
Color fromRGBA(Numeric r, Numeric g, Numeric b [, Numeric a])
Returns an sRGB Color object with the specified red, green, blue, and (optionally) alpha values.

Object Methods

Color object methods are called on a Color object instance. Object methods require an object reference. When you invoke the method, it is prefixed with the object instance name and the "." character.

Table 3. Object Methods
Name Description
Color  brighter()
Brightens the Color object.
Color  darker()
Darkens the Color object.
Numeric getAlpha()
Returns the alpha component in the range 0-255.
Numeric getBlue()
Returns the blue component in the range 0-255 in the default sRGB space.
Numeric getBrightness()
Returns the brightness value of the value in the HSB color model.
Numeric getGreen()
Returns the green component in the range 0-255 in the default sRGB space.
Numeric getHue()
Returns the hue value of the value in the HSB color model.
Numeric getRed()
Returns the red component in the range 0-255 in the default sRGB space.
Numeric getRGBA()
Returns the RGB value representing the color in the default sRGB color model.
Numeric getSaturation()
Returns the saturation value of the value in the HSB color model.
String toCharSequence()
Returns a string representation in the form "#argb".