It is possible to draw 2D colours in such a way that it inverts colours behind it, like in the screenshot below:
This can be done by enabling “XOR Colour mode” and by using…
…this is because white has an RGB value of 255,255,255, and XOR’ing these values will cause the alternating effect.
The following code example shows this:
graphics.setXORMode(Color.WHITE); graphics.drawLine(x, delegate.getXAxisHeight(), x, delegate.getDiagramRect().height + delegate.getXAxisHeight()); graphics.setColor(Color.BLACK);
Don’t forget to save the previous colour (using graphics.getColor())and then reset it after drawing this alternative-coloured line.