Perforce JViews Charts Sample: Using the Java SDK
Description
This sample shows how you can define a custom style to render pretty line charts.
How to Use the Sample
- A color chooser lets you modify the color of the renderer. In order to specify a color, simply click on the appropriate cell.
- A slider lets you change the line width of the renderer.
- A check box lets you toggle the drawing of the shadow.
How to Run the Sample as an Application
This sample can
be run as an application.
The installation directory contains
an executable JAR file,
style.jar
,
that allows you to execute the sample 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 sample 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 sample and type:
ant run
Topics Covered
- Extending the
IlvStyle
class to implement custom rendering.
Detailed Description
In this sample, we show how the IlvStyle
class can be extended
to change the way shapes and polylines are drawn. In the
CustomStyle
subclass,we build an array of colors derived from
the original stroke color of the rendering style.
The size of this array depends on the line width of the stroke, which must
be an instance of java.awt.BasicStroke
. The drawing primitives
are then split into several drawing orders, each of them filling a stroked
shape of decreasing thickness. The custom style can optionally draw a
shadow beneath the shape outline.
Note that the CustomStyle
class remains immutable, which
means that modifying the properties of the style (stroke, stroke paint,
and so on) actually creates and returns a new style.
Installation Directory
The Using the Java SDK sample is installed here.
Classes Involved
- ilog.views.chart.IlvStyle
- ilog.views.chart.renderer.IlvSinglePolylineRenderer
- ilog.views.chart.interactor.IlvChartEditPointInteractor