The view

The tree view is responsible for displaying the graphic objects (tree nodes) and as such corresponds to the visible part of the architecture.
You can customize the representation of tree nodes by:
These ways are provided in addition to the CSS-based customization of the default tree renderer as explained in Customizing the rendering of tree nodes.

Using your own graphic representation

You can create an IlvGraphic or a JComponent directly by declaring the class property and setting it in a CSS file.
The class property name is a reserved keyword that indicates the class name of the generated graphic object. JViews TGO provides a predefined representation for the objects in all graphic components, which means that the class property is optional. It can be used when you want to replace the predefined representation.
object {
    class: ilog.views.sdm.graphic.IlvGeneralNode;
    foreground: red;
}
IlpTreeCellRenderer takes the information present in the CSS files to define how a tree node is rendered. If the property class is specified, it defines the IlvGraphic or JComponent that will be used to render the tree node.
To use a cascading style sheet class property in a tree view, do the following:
  1. Implement your own graphic object or use an existing one, either as an IlvGraphic or as a JComponent .
  2. Configure the properties of the objects or classes you want to represent with this property using CSS.
  3. Load this CSS file in the tree component as illustrated in How to load a CSS file in a tree component.
For example, the sample <installdir> /samples/tree/customClasses shows how to use an IlvGraphic to render tree nodes. In this sample, the tree nodes are rendered as Rogue Wave JViews composite graphics where the label color changes from black to red when the object is selected.
object."Workstation" {
  class: 'ilog.views.graphic.composite.IlvCompositeGraphic';
  layout: @+attachmentLayout;
  children[0]: @+wsBase;
  children[1]: @+wsLabel;
  constraints[1]: @+wsLabelConstraint;
}

Subobject#attachmentLayout {
  class: 'ilog.views.graphic.composite.layout.IlvAttachmentLayout';
}
Subobject#wsBase {
  class: 'ilog.views.graphic.IlvIcon';
  image: '@|image("workstation.png")';
}
Subobject#wsLabel { 
  class: 'ilog.views.graphic.IlvText';
  label: @name;
  foreground: black;
  font: 'arial-bold-12';
}
Subobject#wsLabel:selected { 
  foreground: red;
}
Subobject#wsLabelConstraint {
  class: 'ilog.views.graphic.composite.layout.IlvAttachmentConstraint';
  hotSpot: Left;
  anchor: Right;
  offset: 3,0;
}

Using an arbitrary TreeCellRenderer

The renderer used by an IlpTreeView is an IlpTreeCellRenderer. You can replace it with you own renderer, using the IlpTreeView.setCellRenderer() method. This renderer must implement the TreeCellRenderer interface.
To write your own renderer, do the following:
  1. Implement the javax.swing.tree.TreeCellRenderer interface.
  2. Configure your tree component to use your renderer.
    The following code extract shows how to configure an IlpTreeView to use the MyTreeCellRenderer class to render all tree nodes:
    IlpTreeView view = //...
    view.setCellRenderer(new MyTreeCellRenderer());