Chapter 1 : Charts

Main components

A Chart is a convenient object gathering what you need to plot and control 3d content easily:

  • a Scene, backed by a scene Graph, that stores Drawable objects.
  • a View, that handles the scene layout and annotations: axes, tooltips, post renderers, background image, etc. The default View has children classes that are also able to manage several image sources (Open GL scene, Java 2D colorbars, etc) to be laid out in a single Canvas.


To add drawable elements to the chart, simply call:


To get the view and customize the chart appearance, call:

View view = chart.getView();


The chart’s Quality let you configure the tradeoff between the performance and the quality of your chart. Chart’s Quality is configured in its constructor and can’t be changed at runtime. Four quality modes are available:

  • Fastest: No transparency, no color shading, just uses the depth buffer.
  • Intermediate: Fastest + Color shading, usefull for interpolated colors on polygons.
  • Advanced: Intermediate + Transparency (Alpha blending + polygon ordering in scene graph). Note: depth buffer is desactivated.
  • Nicest: Advanced + Anti aliasing on lines and polygons’ wireframe.

Quality is also used to define wether the chart should render continuously or on demand. One can disable the default continuous rendering by calling: quality.setAnimated(false); ` One can trigger rendering manually using any of the following method which are equivalent:

  • chart.render();
  • chart.getView().shoot();
  • chart.getCanvas().forceRepaint();

Running charts

Chart initialization let you define its Quality and the target windowing toolkit of its canvas. Windowing toolkits may either be awt, swing, newt, or offscreen. To setup your desired mode, simply build the chart as follow:

Chart chart = new AWTChartFactory().newChart(quality);

As it name suggests, the SwingChartFactory delivers charts for Swing.

Other factories deliver charts with dedicated components, such as ContourChartFactory, using a custom ContourAxeBox able to draw contour level on its ground face. See chapter Component Injection for more information on factories.

The utility class ChartLauncher provides static methods to open a ready to use chart window with configured controllers:

  • openChart(…): opens a chart frame with enabled mouse, keyboard and thread controller.
  • openStaticChart(…): open a chart frame with no controller.
  • configureControllers(…) : enables controllers on a chart.
  • screenshot(…) : save a screenshot to the given file.
  • frame(…) : create a Swing or AWT frame according to the chart.
  • openLightEditors(…) : opens light editor for a chart using lights. However, you will most probably wish to integrate your chart in an existing application and select appropriate controllers. See dedicated chapters “Controllers and Integrate the chart in your application.

Destroying charts

To safely destroy all resources that may be held by a chart, it is recommended to call the dispose() method of the chart that will in turn call the dispose() method of all its children. This ensures all listeners get unregistered, and all OpenGL or other native resource get destroyed.

Next section will discuss how to add basic drawable objects to the chart. If you want to immediately draw surface, scatter, or bar charts, then you may go to chapters Drawable for charts.