[API Review] RT-21094 - Styleable interface

David Grieve david.grieve at oracle.com
Tue Jan 22 13:09:15 PST 2013


There is a class in private implementation called Styleable which allows SceneBuilder to look at a Tooltip (for example) and get the info it needs for styling. What I'd like to do is make Styleable part of the public API _and_ have Node and PopupControl (there may be a couple of other controls) implement Styleable. From the CSS standpoint, Styleable contains the API that CSS needs to match selectors and set calculated values on properties.

By making Styleable public API, I can change CssMetaData from CssMetaData<N extends Node, V> to CssMetaData<N extends Styleable, V>. This is important to do now before the CSS API is fully baked so that we can, in the future, have Scene be Styleable. 

public interface Styleable { 

     * The type of this {@code Styleable} that is to be used in selector matching. 
     * This is analogous to an "element" in HTML. 
     * (<a href=" http://www.w3.org/TR/CSS2/selector.html#type-selectors">CSS Type Selector</a>). 
    String getType(); 

     * The id of this {@code Styleable}. This simple string identifier is useful for 
     * finding a specific Node within the scene graph. While the id of a Node 
     * should be unique within the scene graph, this uniqueness is not enforced. 
     * This is analogous to the "id" attribute on an HTML element 
     * (<a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">CSS ID Specification</a>). 
     * <p> 
     * For example, if a Node is given the id of "myId", then the lookup method can 
     * be used to find this node as follows: <code>scene.lookup("#myId");</code>. 
     * </p> 
    String getId(); 

     * A list of String identifiers which can be used to logically group 
     * Nodes, specifically for an external style engine. This variable is 
     * analogous to the "class" attribute on an HTML element and, as such, 
     * each element of the list is a style class to which this Node belongs. 
     * @see <a href="http://www.w3.org/TR/css3-selectors/#class-html">CSS3 class selectors</a> 
   List<String> getStyleClass(); 

     * The inline style. This is analogous to the "style" attribute of an 
     * HTML element.
   String getStyle(); 
     * Return the parent of this Styleable, or null if there is no parent. 
    Styleable getStyleableParent(); 
     * The CssMetaData of this Styleable 
    List<CssMetaData> getCssMetaData(); 

More information about the openjfx-dev mailing list