JMSL Chart
Programmer's Guide
3D: Drawing to the Canvas  Previous Page  Contents  Next Page

3D: Drawing to the Canvas

It is possible to draw to the canvas using Java 2D methods using a class which implements Canvas3DChart.Paint. This interface defines a single method public void paint(java.awt.Graphics g).

The object passed to the paint method is actually a java.awt.Graphics2D object. Graphics is used for consistency with standard Java usage. This method is called each time the 3D chart is redrawn.

An object which implements Canvas3DChart.Paint can be registered with Canvas3DChart using either addPreRenderPaint or addPostRenderPaint. The former method causes the 2D drawing to appear beneath the 3D drawing, the later method the 2D drawing to appears on top of the 3D drawing.

Since the 3D chart is redrawn many times a minute, redrawing the 2D chart each time can add quite a bit of overhead. If the 2D drawing is not dynamic, the class BufferedPaint can be used to capture the 2D drawing into an image that can be quickly redrawn for each 3D redrawing. For example, the ColormapLegend class is implemented using BufferedPaint.



©  Visual Numerics, Inc.  All rights reserved.  Previous Page  Contents  Next Page