| Developing with the SDK > Using and Writing Data Models > NonJavaBeans Example: Abstract Model Variant > Loading the Data Model and Style Sheet into the Diagram Component |
Loading the Data Model and Style Sheet into the Diagram Component |
INDEX
PREVIOUS
NEXT
|
The Tree Model sample is a subclass of IlvDiagrammerApplication. It therefore has the full application facilities as described in Customizing the Predefined Application.
To load the TreeSDMModel object, the sample overrides the createDiagrammer method to perform extra operations, see Code Sample 2.30.
The sample creates an instance of TreeSDMModel, giving it a default tree model as a parameter, see Code Sample 2.31.
// Create the Tree -> SDM model adapter. // TreeSDMModel sdmModel = new TreeSDMModel(treeModel); |
The sample then gets the SDM engine for the IlvDiagrammer instance and sets the data model to the TreeSDMModel instance, as shown in Code Sample 2.32.
// Tell the IlvDiagrammer to use this model: // diagrammer.getEngine().setModel(sdmModel); return diagrammer; } |
The style sheet used to display the tree model is located in <installdir>/jviews-diagrammer81/codefragments/datamodel/treemodel/data/tree.css.
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 Code Sample 2.34.
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 Code Sample 2.35.
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.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |