Example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesItemLabelPaint

List of usage examples for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesItemLabelPaint

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesItemLabelPaint.

Prototype

public void setSeriesItemLabelPaint(int series, Paint paint) 

Source Link

Document

Sets the item label paint for a series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void prepareBalanceChart(JFreeChart jfchart) {

    CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot());
    NumberAxis numberAxis = (NumberAxis) categoryPlot.getRangeAxis();
    numberAxis.setAutoRange(true);//from   w  w w.  java 2  s  .co m
    numberAxis.setAutoRangeIncludesZero(false);
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setDomainGridlinePaint(Color.WHITE);
    categoryPlot.setRangeMinorGridlinePaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) categoryPlot.getRenderer();

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);

    commonPrepareJFreeChart(renderer);

    renderer.setSeriesPaint(0, Color.black);

    renderer.setSeriesItemLabelPaint(0, Color.black);

}

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void prepareSimpleJFreeChart(JFreeChart jfchart) {

    CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot());
    categoryPlot.getRangeAxis().resizeRange(1.2);
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setDomainGridlinePaint(Color.WHITE);
    categoryPlot.setRangeMinorGridlinePaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) categoryPlot.getRenderer();

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);

    commonPrepareJFreeChart(renderer);//from   w  w  w. j  a  v a2 s . c o  m

    renderer.setSeriesPaint(0, new Color(0xB3, 0xBE, 0xFF));
    renderer.setSeriesPaint(1, new Color(0xFF, 0xB3, 0xB3));
    renderer.setSeriesPaint(2, new Color(0x61, 0x9E, 0x42));
    renderer.setSeriesPaint(3, Color.black);

    renderer.setSeriesItemLabelPaint(0, new Color(0x21, 0x21, 0xFF));
    renderer.setSeriesItemLabelPaint(1, new Color(0xFF, 0x36, 0x36));
    renderer.setSeriesItemLabelPaint(2, new Color(0x61, 0x9E, 0x42));
    renderer.setSeriesItemLabelPaint(3, Color.black);

}

From source file:com.rapidminer.gui.plotter.charts.ParetoChartPlotter.java

public void paintParetoChart(Graphics graphics) {
    prepareData();/*from  ww  w .  jav a2s . co m*/

    JFreeChart chart = createChart();

    if (chart != null) {
        // set the background color for the chart...
        chart.setBackgroundPaint(Color.white);
        chart.getPlot().setBackgroundPaint(Color.WHITE);

        // bar renderer --> own 3D effect
        CategoryPlot plot = chart.getCategoryPlot();
        BarRenderer renderer = (BarRenderer) plot.getRenderer();
        // renderer.setBarPainter(new StandardBarPainter());
        renderer.setBarPainter(new RapidBarPainter());

        renderer.setSeriesPaint(0, getColorProvider(true).getPointColor(1));

        // labels on top of bars
        Map<String, String> barItemLabels = new HashMap<>();
        Map<String, String> cumulativeItemLabels = new HashMap<>();
        int groupSum = 0;
        int totalSum = 0;
        for (Object key : totalData.getKeys()) {
            String k = (String) key;
            try {
                Number groupValue = data.getValue(k);
                Number totalValue = totalData.getValue(k);
                groupSum += groupValue.intValue();
                totalSum += totalValue.intValue();
                barItemLabels.put(k, Tools.formatIntegerIfPossible(groupValue.doubleValue()) + " / "
                        + Tools.formatIntegerIfPossible(totalValue.doubleValue()));
                cumulativeItemLabels.put(k, groupSum + " / " + totalSum);
            } catch (UnknownKeyException e) {
                // do nothing
            }
        }
        renderer.setSeriesItemLabelFont(0, LABEL_FONT);

        if (showBarLabelsFlag) {
            renderer.setSeriesItemLabelsVisible(0, true);
            renderer.setSeriesItemLabelGenerator(0, new ParetoChartItemLabelGenerator(barItemLabels));

            if (isLabelRotating()) {
                renderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                        TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -Math.PI / 2.0d));
                renderer.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                        TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -Math.PI / 2.0d));
            }
        }

        LineAndShapeRenderer renderer2 = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer(1);
        renderer2.setSeriesPaint(0, Color.GRAY.darker().darker());
        renderer2.setSeriesItemLabelFont(0, LABEL_FONT);
        renderer2.setSeriesItemLabelPaint(0, Color.BLACK);
        if (isLabelRotating()) {
            renderer2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                    TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -Math.PI / 2.0d));
            renderer2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                    TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -Math.PI / 2.0d));
        } else {
            renderer2.setSeriesPositiveItemLabelPosition(0,
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.BOTTOM_RIGHT));
            renderer2.setSeriesNegativeItemLabelPosition(0,
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.BOTTOM_RIGHT));
        }

        if (showCumulativeLabelsFlag) {
            renderer2.setSeriesItemLabelsVisible(0, true);
            renderer2.setSeriesItemLabelGenerator(0, new ParetoChartItemLabelGenerator(cumulativeItemLabels));
        }

        // draw outlines
        renderer.setDrawBarOutline(true);

        // gridline colors
        plot.setRangeGridlinePaint(Color.BLACK);

        // legend settings
        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }

        Rectangle2D drawRect = new Rectangle2D.Double(0, 0, getWidth(), getHeight());
        chart.draw((Graphics2D) graphics, drawRect);
    }
}