JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

NOTE: this definition, while correct, contains a lot of information which is irrelevant to most developers. We should get to the basic definition and usage patterns sooner.

The Color class is used to encapsulate colors in the default sRGB color space. Every color has an implicit alpha value of 1.0 or an explicit one provided in the constructor. The alpha value defines the transparency of a color and can be represented by a float value in the range 0.0-1.0 or 0-255. An alpha value of 1.0 or 255 means that the color is completely opaque and an alpha value of 0 or 0.0 means that the color is completely transparent. When constructing a Color with an explicit alpha or getting the color/alpha components of a Color, the color components are never premultiplied by the alpha component.

Colors can be created with the constructor or with one of several static utility methods. The following lines of code all create the same blue color:


 var c = Color.BLUE;   //use the blue constant
 var c = Color { red: 0 green: 0 blue: 1.0 }; // standard constructor

 var c = Color.color(0,0,1.0); //use 0->1.0 values. implicit alpha of 1.0
 var c = Color.color(0,0,1.0,1.0); //use 0->1.0 values, explicit alpha of 1.0

 var c = Color.rgb(0,0,255); //use 0->255 integers, implict alpha of 1.0
 var c = Color.rgb(0,0,255,1.0); //use 0->255 integers, explict alpha of 1.0
 //NOTE, shouldn't Color.rgb use 0->255 for the alpha?

 var c = Color.hsb(270,1.0,1.0); //hue = 270, saturation & value = 1.0. inplict alpha of 1.0
 var c = Color.hsb(270,1.0,1.0,1.0); //hue = 270, saturation & value = 1.0, explict alpha of 1.0

 var c = Color.web("0x0000FF",1.0);// blue as a hex web value, explict alpha
 var c = Color.web("0x0000FF");// blue as a hex web value, implict alpha
 var c = Color.web("#0000FF",1.0);// blue as a hex web value, explict alpha
 var c = Color.web("#0000FF");// blue as a hex web value, implict alpha
 var c = Color.web("0000FF",1.0);// blue as a hex web value, explict alpha
 var c = Color.web("0000FF");// blue as a hex web value, implict alpha

 var c = Color.fromAWTColor(java.awt.Color.BLUE }; //convert from an AWT color

 
 
 
Note. Once created the attributes of a color should never be modified.

Profile: common

This comment needs review.

Attribute Summary

nametypedescription
Public
ALICEBLUEColor More: [+]
ANTIQUEWHITEColor More: [+]
AQUAColor More: [+]
AQUAMARINEColor More: [+]
AZUREColor More: [+]
BEIGEColor More: [+]
BISQUEColor More: [+]
BLACKColor More: [+]
BLANCHEDALMONDColor More: [+]
blueNumber

Defines the color blue in the default sRGB space.

More: [+]

Defines the color blue in the default sRGB space. This attribute should not be modifed once set in the constructor.

Note: this attribute can only be set once. Any changes after the constructor is called will be ignored.

Profile: common

This comment needs review.

BLUEColor More: [+]
BLUEVIOLETColor More: [+]
BROWNColor More: [+]
BURLYWOODColor More: [+]
CADETBLUEColor More: [+]
CHARTREUSEColor More: [+]
CHOCOLATEColor More: [+]
CORALColor More: [+]
CORNFLOWERBLUEColor More: [+]
CORNSILKColor More: [+]
CRIMSONColor More: [+]
CYANColor More: [+]
DARKBLUEColor More: [+]
DARKCYANColor More: [+]
DARKGOLDENRODColor More: [+]
DARKGRAYColor More: [+]
DARKGREENColor More: [+]
DARKGREYColor More: [+]
DARKKHAKIColor More: [+]
DARKMAGENTAColor More: [+]
DARKOLIVEGREENColor More: [+]
DARKORANGEColor More: [+]
DARKORCHIDColor More: [+]
DARKREDColor More: [+]
DARKSALMONColor More: [+]
DARKSEAGREENColor More: [+]
DARKSLATEBLUEColor More: [+]
DARKSLATEGRAYColor More: [+]
DARKSLATEGREYColor More: [+]
DARKTURQUOISEColor More: [+]
DARKVIOLETColor More: [+]
DEEPPINKColor More: [+]
DEEPSKYBLUEColor More: [+]
DIMGRAYColor More: [+]
DIMGREYColor More: [+]
DODGERBLUEColor More: [+]
FIREBRICKColor More: [+]
FLORALWHITEColor More: [+]
FORESTGREENColor More: [+]
FUCHSIAColor More: [+]
GAINSBOROColor More: [+]
GHOSTWHITEColor More: [+]
GOLDColor More: [+]
GOLDENRODColor More: [+]
GRAYColor More: [+]
greenNumber

Defines the color green in the default sRGB space.

More: [+]

Defines the color green in the default sRGB space. This attribute should not be modifed once set in the constructor.

Note: this attribute can only be set once. Any changes after the constructor is called will be ignored.

Profile: common

This comment needs review.

GREENColor More: [+]
GREENYELLOWColor More: [+]
GREYColor More: [+]
HONEYDEWColor More: [+]
HOTPINKColor More: [+]
INDIANREDColor More: [+]
INDIGOColor More: [+]
IVORYColor More: [+]
KHAKIColor More: [+]
LAVENDERColor More: [+]
LAVENDERBLUSHColor More: [+]
LAWNGREENColor More: [+]
LEMONCHIFFONColor More: [+]
LIGHTBLUEColor More: [+]
LIGHTCORALColor More: [+]
LIGHTCYANColor More: [+]
LIGHTGOLDENRODYELLOWColor More: [+]
LIGHTGRAYColor More: [+]
LIGHTGREENColor More: [+]
LIGHTGREYColor More: [+]
LIGHTPINKColor More: [+]
LIGHTSALMONColor More: [+]
LIGHTSEAGREENColor More: [+]
LIGHTSKYBLUEColor More: [+]
LIGHTSLATEGRAYColor More: [+]
LIGHTSLATEGREYColor More: [+]
LIGHTSTEELBLUEColor More: [+]
LIGHTYELLOWColor More: [+]
LIMEColor More: [+]
LIMEGREENColor More: [+]
LINENColor More: [+]
MAGENTAColor More: [+]
MAROONColor More: [+]
MEDIUMAQUAMARINEColor More: [+]
MEDIUMBLUEColor More: [+]
MEDIUMORCHIDColor More: [+]
MEDIUMPURPLEColor More: [+]
MEDIUMSEAGREENColor More: [+]
MEDIUMSLATEBLUEColor More: [+]
MEDIUMSPRINGGREENColor More: [+]
MEDIUMTURQUOISEColor More: [+]
MEDIUMVIOLETREDColor More: [+]
MIDNIGHTBLUEColor More: [+]
MINTCREAMColor More: [+]
MISTYROSEColor More: [+]
MOCCASINColor More: [+]
NAVAJOWHITEColor More: [+]
NAVYColor More: [+]
OLDLACEColor More: [+]
OLIVEColor More: [+]
OLIVEDRABColor More: [+]
opacityNumber

Defines the opacity for this color.

More: [+]

Defines the opacity for this color. The default value is 1.0. This attribute should not be modifed once set in the constructor.

Note: this attribute can only be set once. Any changes after the constructor is called will be ignored.

Profile: common

This comment needs review.

ORANGEColor More: [+]
ORANGEREDColor More: [+]
ORCHIDColor More: [+]
PALEGOLDENRODColor More: [+]
PALEGREENColor More: [+]
PALETURQUOISEColor More: [+]
PALEVIOLETREDColor More: [+]
PAPAYAWHIPColor More: [+]
PEACHPUFFColor More: [+]
PERUColor More: [+]
PINKColor More: [+]
PLUMColor More: [+]
POWDERBLUEColor More: [+]
PURPLEColor More: [+]
redNumber

Defines the color red in the default sRGB space.

More: [+]

Defines the color red in the default sRGB space. This attribute should not be modifed once set in the constructor.

Note: this attribute can only be set once. Any changes after the constructor is called will be ignored.

Profile: common

This comment needs review.

REDColor More: [+]
ROSYBROWNColor More: [+]
ROYALBLUEColor More: [+]
SADDLEBROWNColor More: [+]
SALMONColor More: [+]
SANDYBROWNColor More: [+]
SEAGREENColor More: [+]
SEASHELLColor More: [+]
SIENNAColor More: [+]
SILVERColor More: [+]
SKYBLUEColor More: [+]
SLATEBLUEColor More: [+]
SLATEGRAYColor More: [+]
SLATEGREYColor More: [+]
SNOWColor More: [+]
SPRINGGREENColor More: [+]
STEELBLUEColor More: [+]
TANColor More: [+]
TEALColor More: [+]
THISTLEColor More: [+]
TOMATOColor More: [+]
TRANSPARENTColor

Predefined Color constants.

More: [+]

Predefined Color constants.

Profile: common

TURQUOISEColor More: [+]
VIOLETColor More: [+]
WHEATColor More: [+]
WHITEColor More: [+]
WHITESMOKEColor More: [+]
YELLOWColor More: [+]
YELLOWGREENColor More: [+]
Protected

Inherited Attributes

Function Summary

public static color(red: Number, green: Number, blue: Number, opacity: Number) : Color

Creates an sRGB color with the specified red, green, blue, and opacity values in the range (0.0 - 1.0).

More: [+]

Creates an sRGB color with the specified red, green, blue, and opacity values in the range (0.0 - 1.0). The actual color used in rendering depends on finding the best match given the color space available for a particular output device.

This comment needs review.

Parameters
red
the red component, 0->1.0
green
the green component, 0 -> 1.0
blue
the blue component, 0 -> 1.0
opacity
the opacity component, 0 -> 1.0
Returns
Color

Profile: common

public static color(red: Number, green: Number, blue: Number) : Color

Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0).

More: [+]

Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0). Opacity is defaulted to 1.0. The actual color used in rendering depends on finding the best match given the color space available for a particular output device.

This comment needs review.

Parameters
red
the red component, 0->1.0
green
the green component, 0 -> 1.0
blue
the blue component, 0 -> 1.0
Returns
Color

Profile: common

public static fromAWTColor(c: java.awt.Color) : Color

Creates a Color instance derived from the provided java.awt.Color.

More: [+]

Creates a Color instance derived from the provided java.awt.Color.

This comment needs review.

Parameters
c
Returns
Color
public getAWTColor() : java.awt.Color

Returns the java.awt.Color delegate for this Color.

More: [+]

Returns the java.awt.Color delegate for this Color.

This method should not be public. It is an implementation detail.

This comment needs review.

Returns
Color
public getAWTPaint() : java.awt.Paint

Returns the java.awt.Paint delegate for this Color.

More: [+]

Returns the java.awt.Paint delegate for this Color.

This method should not be public. It is an implementation detail.

This comment needs review.

Returns
Paint
public static hsb(hue: Number, saturation: Number, brightness: Number, opacity: Number) : Color

NOTE, the description of the H component is confusing.

More: [+]

NOTE, the description of the H component is confusing. Why can't the hue simply be from 0->360 (with wrapping. The devleoper shouldn't have to understand how it is calculated.

Creates a Color object based on the specified values for the HSB color model. The saturation, brightness, and opacity components should be floating-point values between zero and one (numbers in the range 0.0 - 1.0). The hue component can be any floating-point number. The floor of this number is subtracted from it to create a fraction between 0 and 1. This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model.

This comment needs review.

Parameters
hue
the hue component, 0->1.0 (wraps)
saturation
the saturation of the color, 0->1.0
brightness
the brightness of the color, 0->1.0
opacity
the opacity component, 0->1.0
Returns
Color

Profile: common

public static hsb(hue: Number, saturation: Number, brightness: Number) : Color

Creates a Color object based on the specified values for the HSB color model.

More: [+]

Creates a Color object based on the specified values for the HSB color model. The saturation and brightness components should be floating-point values between zero and one (numbers in the range 0.0-1.0). The hue component can be any floating-point number. The floor of this number is subtracted from it to create a fraction between 0 and 1. This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model.

This comment needs review.

Parameters
hue
the hue component, 0->1.0 (wraps)
saturation
the saturation of the color, 0->1.0
brightness
the brightness of the color, 0->1.0
Returns
Color

Profile: common

public ofTheWay(endVal: java.lang.Object, t: Number) : java.lang.Object

More: [+]

Parameters
endVal
t
Returns
Object
public static rgb(red: Integer, green: Integer, blue: Integer, opacity: Number) : Color

Creates an sRGB color with the specified red, green, blue values in the range (0 - 255) and opacity value in the range (0.0 - 1.0).

More: [+]

Creates an sRGB color with the specified red, green, blue values in the range (0 - 255) and opacity value in the range (0.0 - 1.0).

Parameters
red
the red component, 0->255
green
the green component, 0->255
blue
the blue component, 0->255
opacity
the opacity component, 0->1.0
Returns
Color

Profile: common

public static rgb(red: Integer, green: Integer, blue: Integer) : Color

Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255).

More: [+]

Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255). The actual color used in rendering depends on finding the best match given the color space available for a given output device. Opacity is defaulted to 255.

This comment needs review.

Parameters
red
the red component, 0->255
green
the green component, 0->255
blue
the blue component, 0->255
Returns
Color

Profile: common

public toString() : java.lang.String

Returns a string representation of this Color.

More: [+]

Returns a string representation of this Color. This method is intended to be used only for debugging purposes. The content and format of the returned string might vary between implementations. The returned string might be empty but cannot be null.

Returns
String

Profile: common

public static web(color: java.lang.String, opacity: Number) : Color

Creates an RGB color specified with the hexadecimal notation.

More: [+]

Creates an RGB color specified with the hexadecimal notation. Opacity is in the range 0.0-1.0. ex:


 var c = Color.web("0xff6688",1.0);
 var c = Color.web("#ff6688",1.0);
 var c = Color.web("ff6688",1.0);
 

This comment needs review.

Parameters
color
the hexadecimal string to identify the RGB color
opacity
the opacity component
Returns
Color

Profile: common

public static web(color: java.lang.String) : Color

Creates an RGB color specified with the hexadecimal notation.

More: [+]

Creates an RGB color specified with the hexadecimal notation. Opacity is set to 1.0. ex:


 var c = Color.web("0xff6688");
 var c = Color.web("#ff6688");
 var c = Color.web("ff6688");
 

This comment needs review.

Parameters
color
the hexadecimal string to identify the RGB color
Returns
Color

Profile: common

Inherited Functions

javafx.scene.paint.Paint

public abstract getAWTPaint() : java.awt.Paint

Creates and returns a paint context used to generate the color pattern.

More: [+]

Creates and returns a paint context used to generate the color pattern.

Returns
Paint
the paint context for generating color patterns

javafx.animation.Interpolatable

public abstract ofTheWay(endVal: java.lang.Object, t: Number) : java.lang.Object

More: [+]

Parameters
endVal
t
Returns
Object