In addition to a single ILcdGXYPainterProvider, TLcdGXYLayer supports the use of an array of ILcdGXYPainterProvider objects. Every object contained in the ILcdModel of a TLcdGXYLayer is rendered with the ILcdGXYPainter provided by the first ILcdGXYPainterProvider in the array, then with the ILcdGXYPainter provided by the second ILcdGXYPainterProvider and so on.

A use case for an array of painter providers is the painting of a highway. Typically, a highway is represented with a wide red line and a smaller yellow line down the the middle.

Implementing an ILcdGXYPainter that paints a line like that is all it takes. However, when two of those lines cross each other, you get unwanted artifacts like the ones in the image. You can fix those by using an array of painters.

painterproviderarray
Figure 1. Painting a highway: The line data is shown on the left. Visualizing those using a single painter results in problems where the lines cross (middle image). Using an array of painters solves this (right image).

The use of an array of painters is illustrated in this code snippet:

//To have a red line with a yellow inner line, we paint two lines:
// - A wide red line
// - A smaller yellow line on top of it
//First we define both line styles
TLcdStrokeLineStyle redOuterLine = TLcdStrokeLineStyle.newBuilder().color(Color.RED).lineWidth(8f).join(ROUND).build();
TLcdStrokeLineStyle yellowInnerLine = TLcdStrokeLineStyle.newBuilder().color(Color.YELLOW).lineWidth(4f).join(ROUND).build();

//Then we create the painters configured with those styles
TLcdGXYShapePainter redLinePainter = new TLcdGXYShapePainter();
redLinePainter.setLineStyle(redOuterLine);

TLcdGXYShapePainter yellowLinePainter = new TLcdGXYShapePainter();
yellowLinePainter.setLineStyle(yellowInnerLine);

//Finally, create the layer and configure both painters on it
TLcdGXYLayer layer = TLcdGXYLayer.create(model);
layer.setGXYPainterProviderArray(new ILcdGXYPainterProvider[]{redLinePainter, yellowLinePainter});

which results in:

gxy highways

Other cases using an array of painter providers are discussed in these articles: