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

The main frame displays a polyline chart whose appearance can be modified with several controls:

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

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

Source Files

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All rights reserved. Legal terms.