To load the style sheet, you pass the relative path to
the sample as a startup argument.
public TreeModelDemo()
{
super(new String[]{
"-title", "Tree Model Demo",
"-style", "data/tree.css",
});
}
The style sheet specifies a Tree layout in Radial mode
with various parameters, in the two rules shown in the following code
example.
SDM {
GraphLayout : "Tree" ;
}
GraphLayout {
flowDirection : "Bottom";
layoutMode : "RADIAL";
globalLinkStyle : "ORTHOGONAL_STYLE";
position : "300,200";
parentChildOffset : "10";
siblingOffset : "10";
}
The style sheet also specifies the colors of the various
objects.
Note that the
CSSclass
property
of the
TreeSDMNode
class is recognized
automatically by the CSS engine as specifying a
CSS class because of its name, and therefore the values
of this attribute can be used directly in rules. This allows you to
set colors at the level of types of object with a simple syntax, see
the following code example.
node.food {
fillColor2 : "lightgreen" ;
}
// node.treenode[userObject='food'] node.treenode {
// fillColor2 : "lightgreen" ;
// }
The comment lines show the alternative, longer way to
set the color for food objects. This longer way relies on a parent-child
construct in
CSS for Java. Note that the parent-child construct is
not supported in the Designer.