public abstract class IlvSDMRenderer
extends java.lang.Object
IlvSDMRenderer
is the base class
for the renderers used in an SDM engine.
The purpose of a renderer is to implement a particular policy for rendering the objects of an SDM data model as Perforce JViews graphic objects in a Perforce JViews grapher.
The renderers attached
to an SDM engine form a chained list. The first element of this list
is set using the method setRenderer
.
All but the last element of the list are instances of
IlvFilterSDMRenderer
. The next element
in the list is defined by the method
setFilteredRenderer
.
The last element of the list is usually an instance of
IlvStyleSheetRenderer
.
Style Sheet Renderer
The main renderer is the IlvStyleSheetRenderer
.
The style sheet renderer reads a file in the CSS syntax,
and creates and customizes JViews graphic objects according
to the CSS rules. For example, the following rule states that
all nodes of the SDM data model shall be represented by JViews
IlvRectangle
objects, and the rectangles shall be green.
node { class : "ilog.views.graphic.IlvRectangle"; foreground : "green"; }
Filtering Renderers
Other renderers can be combined with the style sheet renderer
to modify the look or the behavior of the graphic objects.
This combination of renderers is implemented by way of
"filtering" renderers (see IlvFilterSDMRenderer
).
Several filtering renderers can be added in front of the
style sheet renderer to add different aspects to the rendering
process. For example, the IlvHalfZoomingRenderer
prevents
nodes from zooming or unzooming too much. Another example is the
IlvExpandCollapseRenderer
that shows
sub-graphs of the data model as special expandable and collapsible nodes.
Rendering Properties
Renderers usually require information to know how to create and customize graphic objects. This information can be specified in the style sheet file, just like the plain properties of graphic objects. For example, if a half-zooming renderer is used, you could add the following declaration to say that the nodes must not zoom beyond a zoom level of 4:
node { class : "ilog.views.graphic.IlvRectangle"; foreground : "green"; MaxZoomLevel : "4.0"; }
These special rendering properties are fetched through the method
IlvRendererUtil.getGraphicProperty(ilog.views.sdm.IlvSDMEngine, java.lang.Object, java.lang.String, java.lang.String[], java.lang.Class<?>)
, or one of its variants
that convert the property value to an appropriate type.
Note that, by convention, the rendering properties are capitalized
to distinguish them from plain properties of IlvGraphic
objects.
Pseudo classes
Pseudo classes are strings that can be used to mark data objects. The purpose of pseudo classes is to allow renderers to give feedback to the user on the state of an object by displaying it in a different way.
The style sheet can contain rules that apply only when the object has a particular pseudo class.
For example, the SDM engine adds the pseudo class "selected"
to selected objects. The following style sheet rule says that
selected objects are red:
node:selected { foreground : "red"; }
The pseudo classes of a data object are passed along to several
methods of IlvSDMRenderer
to let any renderer decide what
it should do depending on the object pseudo classes.
The class IlvSDMRenderer
is abstract: subclasses need to define
at least the methods #createNodeGraphic
and #createLinkGraphic
.
CSS example:
This class cannot be instantiated because it is an abstract class.
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.