...
CSS is an integral part of JavaFX but heretofore has been implemented exclusively in private API within, primarily, the com.sun.javafx.css package. Adding a styleable property or pseudo-class state in JavaFX is fairly straight-forward and exposing certain elements of the internal API will facilitate the development of custom UI controls in the open source environment. This document outlines this public API.
Use Case
Say a contributor wished to develop a Watermark control which could overlay a region and present a widget for obtaining copyright information. The Watermark API has a StringProperty cornerProperty that controls which corner of the region the widget is to be displayed. The contributor wishes to make this cornerProperty styleable through CSS.
Design Goals
The primary goal is to create an API that allows CSS styling to be applied to a JavaFX property. The API should support the following javafx.beans.property types: BooleanProperty, FloatProperty, DoubleProperty, IntegerProperty, LongProperty, and StringProperty. Support for ObjectProperty is desired but would, possibly, require additional hooks into the parser or public API to convert a parsed value to the parameterized type which may not be feasible at this time. However, the ability to style an ObjectProperty with a parameterized type such as Insets or Paint is essential.
...
The current implementation of CSS in JavaFX is only a small portion of the W3C standards and is only partially compliant with those standards. It is beyond the scope of this API implementation to rectify differences between the W3C standards and the current JavaFX implementation.
Use Case
Say a contributor wished to develop a Watermark control which could overlay a region and present a widget for obtaining copyright information. The Watermark API has a StringProperty cornerProperty that controls which corner of the region the widget is to be displayed. The contributor wishes to make this cornerProperty styleable through CSS.
Architecture
There are two main pieces to the architecture. First is a StyleablePropertyMetaData whose value can be represented syntactically in a .css file. A StyleablePropertyMetaData encapsulates the CSS property name, the type into which the string value is converted, and the default value of the property. Second is the JavaFX property to which the parsed StyleablePropertyMetaData value applies. Any JavaFX property that supports this styling is a StyleableProperty. A StyleableProperty also incorporates additional logic to ensure that values set by the user through calls to set methods are not overridden by styles in a user agent stylesheet.
...