Code: Select all
public class LineChartItemLabelCustomizer implements JRChartCustomizer {
static Color jtsBlue = new Color(0, 125, 193);
static class CustomRenderer extends LineAndShapeRenderer {
private static final long serialVersionUID = -2378925128764898991L;
public CustomRenderer() {
this.setBaseItemLabelsVisible(Boolean.TRUE);
this.setBaseFillPaint(jtsBlue);
Shape shape = new Ellipse2D.Double(-3, -3, 5, 5);
this.setSeriesShape(0, shape);
DecimalFormat format = new DecimalFormat("##0.00");
this.setBaseItemLabelGenerator((CategoryItemLabelGenerator) new StandardCategoryItemLabelGenerator("{2}", format, format));
Font font = new Font("JTSOpenSans", Font.PLAIN, 8);
this.setBaseItemLabelFont(font);
}
@Override
public Paint getItemPaint(int series, int category) {
if (((String)this.getPlot().getDataset().getColumnKey(category)).contains("WAL"))
return Color.black;
else
return jtsBlue;
}
@Override
public Shape getItemShape(int series, int category) {
if (((String)this.getPlot().getDataset().getColumnKey(category)).contains("WAL"))
return ShapeUtilities.createDiamond(3);
else
return super.getItemShape(series, category);
}
}
@Override
public void customize(JFreeChart jfc, JRChart jasperChart)
{
CategoryPlot jfcPlot;
jfcPlot = (CategoryPlot) jfc.getPlot();
jfcPlot.setDomainGridlinesVisible(true);
jfcPlot.getDomainAxis().setLowerMargin(.01);
jfcPlot.getDomainAxis().setUpperMargin(.01);
jfcPlot.setRenderer(new CustomRenderer());
}
}