3schools.com/css/selector.gif" />
As it is commonly used in CSS stylesheets, the engine supports:
+ Nested selectors, like ".parent .child {...}"
+ Groups of selectors, like ".class1, .class2, .class3 {...}"
How can I use the engine?
The engine is built around 3 kinds of components: {@link Property properties}, {@link Function functions}, and {@link DeclarationSetProcessor processors}, and you will need to register these components to the engine, since it comes as naked as possible.
Important: remember that the engine is completely naked, this means that it comes without any registered property, function, or processor. You first need to register these entities to the engine to let it understand how to parse CSS stylesheets and apply them to your targets. Some already made entities (for Swing UIs for instance) can be found at the project website.
1.
Properties: a property defines a style attribute, like "margin", "border" or "color" in common CSS syntax. A property is always associated with a value in declarations, like "color: #FFF", and this value can be made of one or more parameters. Actually, a property can support different sets of parameters. For instance, the common "margin" CSS property can be called with either 1, 2 or 4 parameters, defining the margin insets.
2.
Functions: a function, or a "functional notation", is used to produce a value for a parameter of a declaration value. It takes one or more parameters (which can be functions too), processes them and returns an object.
3.
Processors: a declarations processor is responsible for applying a group of declarations to a target object. These declarations are retrieved from the stylesheet and correspond to the rules which selectors were walidated by the target object.
Examples
For examples on how to create custom properties, functions and processors, please see the proposed implementation for Swing, at the
project website.
Simple rule: this rule will by applied to every JButton of the application (if using the Swing backend for properties/functions/processors of course):
javax-swing-JButton { -swing-foreground: #000; -swing-background: #FFF; }
Nested seelctors: this rule will be applied to every object registered with the ".redLabel" classname, but only if it is a child of a toolbar:
javax-swing-JToolBar .redLabel { -swing-foreground: #F00; }
Grouped selectors: this rule will be applied to every object registered with either the ".redLabel" classname, or the ".importantLabel" classname:
.redLabel, .importantLabel { -swing-foreground: #F00; }
@author Aurelien Ribon | http://www.aurelienribon.com/