Hello,
I'm trying to adapt the code shown previously which overrides SetRenderer for a LineAndShapeRender. Any suggestions on how to apply to an XYBoxAndWhiskerRenderer? I'm able to get it to change the color for the entire series, but not specific individual items.
Thanks for the help.
Different colours on a line between 2 data points
Re:
Is it possible to elaborate on this example to create and return a GradiantPaint ?jfreeuser2006 wrote:you could do something like this:
Code: Select all
plot.setRenderer(new LineAndShapeRenderer() { public Paint getItemPaint(int row, int item) { double temp = plot.getDataset().getValue(row, item).doubleValue(); if (temp >= limit) { return Color.RED; } return Color.BLUE; } public Shape getItemShape(int row, int item) { return ShapeUtilities.createDiamond(2.0f); } });
Right now I have tried this:
Code: Select all
public class MyRenderer extends XYLineAndShapeRenderer {
private Color[] myColors = new Color[] {
new Color(0xFF0000), new Color(0xFFBF00), new Color(0x00AA54), new Color(0x3F00BF) };
@Override
public Paint getItemPaint(final int row, final int column) {
int x1 = 0, x2 = 0; // How to compute good values for x and y ???
int y1 = 10, y2 = 10;
return new GradientPaint(x1, y1, getMyColor(column), x2, y2, getMyColor(column+1), false);
}
public Color getMyColor(final int i) {
return myColors[i % myColors.length];
}
}
ZC