Divergences from CSS2

Java™ objects are not HTML documents. The CSS2 syntax remains, so that a CSS editor can still be used to create the style sheet. However, the differences lead to adaptations of the CSS mechanism so that its power can be fully exploited and to some specific behavior.

Cascading

Cascading is explicit: the API offers a means of cascading style sheets. However, the !important and inherit tags are not supported for the sake of simplicity.

Pseudo-classes and pseudo-elements

The pseudo-class construct is fully implemented and used to represent renderer-specific states or GUI items. The list of predefined pseudo-classes and where they are used is as follows:
  • init (is automatically enabled at creation time only. :init rules are not used if the bean is customized only)
  • selected (any renderer)
  • collapsed or expanded ( expandCollapseRenderer )
  • <renderer_name> , for example, legendRenderer (to specify that the rule applies only to rendering properties and not graphic object properties)
  • renderer (to specify a property belonging to a renderer, as opposed to one with the same name belonging to the graphic object)
  • tree (Workflow Modeler)
  • table ( Workflow Modeler)
You can add custom pseudo-classes with the method IlvSDMEngine:setPseudoClasses .
The CSS2 predefined pseudo-elements and pseudo-classes ( :link , :hover , and so forth) are not implemented because they have no meaning in Java.

Attribute matching

The attribute pattern in CSS2 makes the following checks for strings: presence [ att ], equality [ att= val], and inclusion [ att~= val] . The |= operator is disabled.
For Java objects, there are the following numeric comparators > , >= , <> , <= , < , with the usual semantics.
There are also equal and not-equal comparators which make the distinction between string comparison and numerical comparison:
  • Equal: "A==B" is true if and only if A and B are numerically equal (for example, 10 == 10.0); use "=" to test the equality of two Strings.
  • Not-equal: "A~B" is true if and only if A and B are two different Strings (for example, "10" ~ "10.0"); use "<>" to test the inequality of two numbers.
Operators available in the attribute selectors
Operator
Meaning
Applicable To
A
present
strings
A=val
equals
strings
A~val
not equals
strings
A~=val
contains the word
strings
A==val
equals
numbers
A<>val
not equals
numbers
A<val
less than
numbers
A<=val
less than or equals
numbers
A>val
greater than
numbers
A>=val
greater than or equals
numbers

Syntax enhancement

CSS for Java requires the use of quotation marks when a token contains special characters, such as dot (.), colon (:), at sign (@), number sign (also known as hash sign, #), space (  ), and so on.
Quotes can be used almost everywhere, in particular to delimit a declaration value, an element type, or a CSS class with reserved characters.
The closing “;” is optional.

Null value

Sometimes it makes sense to specify a null value in a declaration. By convention, null is a zero-length string '' or "" . For example:
node.not-handled {
  class : '' ;
}
When a null class name is specified, no object is created at all, and no error is reported as it would be for a malformed class name.
The notation '' is also used to denote a null array for properties expecting an array of values.

Empty string

The null syntax does not allow you to specify an empty string in the style sheet. Instead, you can create an empty string, as shown in the following code example.
node {
  label : @#emptyString ;
}

Subobject#emptyString {
  class : 'java.lang.String';
}
Better still, you can use the sharing mechanism to avoid the creation of several strings. The @= construct will create the empty string the first time only and will then reuse the same instance for all other occurrences of @#emptyString , see Sharing an empty string .
Sharing an empty string
node {
  label : @=emptyString ;
}

Subobject#emptyString {
  class : 'java.lang.String';
}