Perforce JViews Diagrammer Code Example: Flag Renderer
Description
This sample shows how to extend the SDM renderers to set a decoration on a node.
How to Use the Code Example
- Select a node in the diagram component.
- In the property sheet, double-click the state property to modify its value.
- Setting the state property to error adds a new decoration to the graphic representation.
How to Run the Code Example as an Application
This code example can
be run as an application.
The installation directory contains
an executable JAR file,
diagrammer-flag-renderer.jar
,
that allows you to execute the code example with a double click from a
file browser. Note that if you are using Internet Explorer, you can
open the installation directory
and execute the JAR file from the browser. This
technique may not work in other Web browsers.
Alternatively, you
can run the code example application from the command line.
First check that the Ant utility is properly configured. If not, see the
instructions on how to configure Ant for Perforce JViews.
Then, go to the installation directory
of the code example and type:
ant run
Topics Covered
- Create a basic Swing application using a diagram component.
- Load a Perforce JViews Diagrammer project file containing the description of a diagram.
- Create a new renderer to set a new decoration to a node.
- Display a property sheet which allows editing of selected nodes.
Detailed Description
This sample addresses a typical graphical need that can be answered with an SDM renderer. The need is to set a decoration on a node that will always be visible, for example, if the state of a model object changes and it needs to catch the user's attention. The renderer must display a flag on the node such that the flag remains visible even if the object is hidden by another graphic object.
In this sample, the state property is used to indicate when a new decoration should be added to the node representation. When the value of the property is normal, the representation is simply a shape and a label. If the value of the state property is changed to error or warning, a new decoration is added on top of the object to catch the user's attention. You can modify the value of this property by selecting a node, and editing the property using the property sheet.
Installation Directory
The Flag Renderer code example is installed here.
Classes Involved
-
ilog.views.diagrammer.IlvDiagrammer
The main class of the diagram component.
-
ilog.views.diagrammer.application.IlvDiagrammerPropertySheet
A component to view and edit the properties of the selected object in a diagram component.
-
ilog.views.sdm.renderer.IlvFilterSDMRenderer
The renderer base class that allows you to extend the existing behavior of SDM.
Source Files
-
FlagRendererDemo
The entry point of the sample.
-
FlagRenderer
The new SDM renderer that adds a decoration to a node.