Color.toWeb & Color.toHexString

Pavel Safrata pavel.safrata at oracle.com
Tue Jul 10 07:50:12 PDT 2012


Hello,
based on Jira issue
http://javafx-jira.kenai.com/browse/RT-22400
I propose the following new methods to Color class (targeting Lombard):


public String toWeb()

This method will return the simplest string representation of the color 
using one of the following notations:

#rrggbb
rgb(r, g, b)
rgba(r, g, b, a)

The resulting string, when passed to Color.toWeb(), will produce an 
eqivalent color.


public String toHexString()

This method will return a string rrggbb without the leading hash. It 
will ignore opacity and will round the values to the nearest color that 
can be represented with such string. An example of use is displaying a 
web-based color value in a color picker.

Regards,
Pavel


More information about the openjfx-dev mailing list