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:
Implement your own graphic object or use an existing one,
either as an
IlvGraphic
or as a
JComponent
.
Configure
the properties of the objects or classes you want to represent
with this property using CSS.
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;
}