Skip to content

How to control the color scheme

Luca edited this page Apr 27, 2023 · 3 revisions

How to control the color scheme

CoordSysRenderer ColorScheme support

The CoordsysRenderer in JPlotter supports the ColorScheme API introduced in version 0.6.0.
This enables custom coloring of many of the visual elements of the CoordsysRenderer. Each ColorScheme contains 6 (possibly) different colors (color1, color2, color3, color4, colorText & colorBackground), which are applied to different elements.

By default there are two color schemes included: Light and Dark by the DefaultColorScheme.

A visual example of both of the color schemes:

Light: Dark:

API Usage

The ColorScheme of the CoordSysRenderer can be set by using one of the default color schemes as follows:

coordsys.setColorScheme(DefaultColorScheme.DARK.get());
coordsys.setColorScheme(DefaultColorScheme.LIGHT.get());

Custom color schemes are also supported. To use a custom color scheme, a ColorScheme object has to be passed:

coordsys.setColorScheme(new ColorScheme(Color.BLACK, Color.DARK_GRAY, Color.LIGHT_GRAY, Color.WHITE, Color.RED));

Support for other renderers

Currently only the CoordSysRenderer supports the ColorScheme API, but other upcoming renderers that are similar to the CoordSysRenderer will also support the ColorScheme. This Wiki entry will then be updated.