Example usage for org.jfree.chart.renderer.category BarRenderer setSeriesFillPaint

List of usage examples for org.jfree.chart.renderer.category BarRenderer setSeriesFillPaint

Introduction

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

Prototype

public void setSeriesFillPaint(int series, Paint paint) 

Source Link

Document

Sets the paint used for a series fill and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.jreserve.dummy.plot.charts.AbstractBarChart.java

private void formatRenderer(BarRenderer renderer) {
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setDrawBarOutline(true);//from  w  ww  .j av  a  2s . co m

    int count = ((CategoryDataset) dataset).getRowCount();
    ColorGenerator colors = format.getColors();
    for (int i = 0; i < count; i++) {
        Color color = colors.nextColor();
        renderer.setSeriesPaint(i, color);
        renderer.setSeriesFillPaint(i, color);
    }
}

From source file:org.jreserve.gui.plot.charts.AbstractBarChart.java

private void formatRenderer(BarRenderer renderer) {
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setDrawBarOutline(true);/*from   w  ww . ja  v  a  2  s  . c  o  m*/

    int count = ((CategoryDataset) dataset).getRowCount();
    ColorGenerator colors = format.getColors();
    for (int i = 0; i < count; i++) {
        Paint color = colors.nextColor();
        renderer.setSeriesPaint(i, color);
        renderer.setSeriesFillPaint(i, color);
    }
}

From source file:com.rapidminer.gui.plotter.DistributionPlotter.java

private JFreeChart createNominalChart() {
    JFreeChart chart;/*from  w  ww.j  av a2 s  . c  om*/
    CategoryDataset dataset = createNominalDataSet();
    // create the chart...
    chart = ChartFactory.createBarChart(null, // chart title
            "value", // x axis label
            "density", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BarRenderer renderer = new BarRenderer();
    if (dataset.getRowCount() == 1) {
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesFillPaint(0, Color.RED);
    } else {
        for (int i = 0; i < dataset.getRowCount(); i++) {
            Color color = getPointColor((double) i / (double) (dataset.getRowCount() - 1));
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesFillPaint(i, color);
        }
    }
    plot.setRenderer(renderer);

    return chart;
}

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

private JFreeChart createNominalChart() {
    JFreeChart chart;/*from  w  w  w. j  a  va 2s.co  m*/
    CategoryDataset dataset = createNominalDataSet();

    // create the chart...
    String domainName = dataTable == null ? MODEL_DOMAIN_AXIS_NAME : dataTable.getColumnName(plotColumn);
    chart = ChartFactory.createBarChart(null, // chart title
            domainName, // x axis label
            RANGE_AXIS_NAME, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    CategoryPlot plot = chart.getCategoryPlot();

    BarRenderer renderer = new BarRenderer();
    if (dataset.getRowCount() == 1) {
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesFillPaint(0, Color.RED);
    } else {
        for (int i = 0; i < dataset.getRowCount(); i++) {
            Color color = getColorProvider(true)
                    .getPointColor((double) i / (double) (dataset.getRowCount() - 1));
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesFillPaint(i, color);
        }
    }
    renderer.setBarPainter(new RapidBarPainter());
    renderer.setDrawBarOutline(true);
    plot.setRenderer(renderer);

    // rotate labels
    if (isLabelRotating()) {
        plot.getDomainAxis().setTickLabelsVisible(true);
        plot.getDomainAxis().setCategoryLabelPositions(
                CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
    }

    return chart;
}

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

@Override
protected void updatePlotter() {
    prepareData();/*from w w w .j  a v  a2s  .c  o m*/

    String maxClassesProperty = ParameterService
            .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
    int maxClasses = 20;
    try {
        if (maxClassesProperty != null) {
            maxClasses = Integer.parseInt(maxClassesProperty);
        }
    } catch (NumberFormatException e) {
        // LogService.getGlobal().log("Deviation plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
        // LogService.WARNING);
        LogService.getRoot().log(Level.WARNING,
                "com.rapidminer.gui.plotter.charts.HistogramColorChart.parsing_property_error");
    }

    JFreeChart chart = null;
    if (nominal) {
        // ** nominal **
        int categoryCount = this.categoryDataset.getRowCount();
        boolean createLegend = categoryCount > 0 && categoryCount < maxClasses && this.drawLegend;

        String domainName = valueColumn >= 0 ? this.dataTable.getColumnName(valueColumn) : "Value";

        chart = ChartFactory.createBarChart(null, // title
                domainName, "Frequency", categoryDataset, PlotOrientation.VERTICAL, createLegend, true, // tooltips
                false); // urls

        CategoryPlot plot = chart.getCategoryPlot();
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setBackgroundPaint(Color.WHITE);
        plot.setForegroundAlpha(this.opaqueness);

        BarRenderer renderer = new BarRenderer();
        if (categoryDataset.getRowCount() == 1) {
            renderer.setSeriesPaint(0, Color.RED);
            renderer.setSeriesFillPaint(0, Color.RED);
        } else {
            for (int i = 0; i < categoryDataset.getRowCount(); i++) {
                Color color = getColorProvider(true)
                        .getPointColor((double) i / (double) (categoryDataset.getRowCount() - 1));
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesFillPaint(i, color);
            }
        }
        renderer.setBarPainter(new RapidBarPainter());
        renderer.setDrawBarOutline(true);
        plot.setRenderer(renderer);

        plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

        plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

        // rotate labels
        if (isLabelRotating()) {
            plot.getDomainAxis().setTickLabelsVisible(true);
            plot.getDomainAxis().setCategoryLabelPositions(
                    CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
        }
    } else {
        // ** numerical **
        int categoryCount = this.histogramDataset.getSeriesCount();
        boolean createLegend = categoryCount > 0 && categoryCount < maxClasses && this.drawLegend;

        String domainName = valueColumn >= 0 ? this.dataTable.getColumnName(valueColumn) : "Value";
        chart = ChartFactory.createHistogram(null, // title
                domainName, "Frequency", histogramDataset, PlotOrientation.VERTICAL, createLegend, true, // tooltips
                false); // urls

        XYPlot plot = chart.getXYPlot();
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setBackgroundPaint(Color.WHITE);
        plot.setForegroundAlpha(this.opaqueness);

        XYBarRenderer renderer = new XYBarRenderer();
        if (histogramDataset.getSeriesCount() == 1) {
            renderer.setSeriesPaint(0, Color.RED);
            renderer.setSeriesFillPaint(0, Color.RED);
        } else {
            for (int i = 0; i < histogramDataset.getSeriesCount(); i++) {
                Color color = getColorProvider(true)
                        .getPointColor((double) i / (double) (histogramDataset.getSeriesCount() - 1));
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesFillPaint(i, color);
            }
        }
        renderer.setBarPainter(new RapidXYBarPainter());
        renderer.setDrawBarOutline(true);
        plot.setRenderer(renderer);

        plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

        plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

        // Correctly displays dates on x-axis
        if (datetime) {
            DateAxis dateAxis = new DateAxis();
            dateAxis.setDateFormatOverride(Tools.DATE_TIME_FORMAT.get());
            plot.setDomainAxis(dateAxis);
        }

        // range axis
        Range range = getRangeForDimension(valueColumn);
        if (range != null) {
            plot.getDomainAxis().setRange(range);
        }

        // rotate labels
        if (isLabelRotating()) {
            plot.getDomainAxis().setTickLabelsVisible(true);
            plot.getDomainAxis().setVerticalTickLabels(true);
        }

        if (histogramDataset.getSeriesCount() == 1) {
            String key = histogramDataset.getSeriesKey(0).toString();
            int index = this.dataTable.getColumnIndex(key);
            if (index >= 0) {
                if (this.dataTable.isNominal(index)) {
                    String[] values = new String[dataTable.getNumberOfValues(index)];
                    for (int i = 0; i < values.length; i++) {
                        values[i] = dataTable.mapIndex(index, i);
                    }
                    plot.setDomainAxis(new SymbolAxis(key, values));

                    // rotate labels
                    if (isLabelRotating()) {
                        plot.getDomainAxis().setTickLabelsVisible(true);
                        plot.getDomainAxis().setVerticalTickLabels(true);
                    }
                }
            }
        }
    }

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // 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);
    }

    AbstractChartPanel panel = getPlotterPanel();
    if (panel == null) {
        panel = createPanel(chart);
    } else {
        panel.setChart(chart);
    }

    // Disable zooming for Histogram-Charts
    panel.setRangeZoomable(false);
    panel.setDomainZoomable(false);

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}

From source file:net.sqs2.omr.result.export.chart.ChartImageWriter.java

private void setSectionPaint(DefaultCategoryDataset dataSet, CategoryPlot plot) {

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);/*from w ww.  j a  va  2 s  . c  o m*/
    renderer.setItemLabelAnchorOffset(10);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    if (this.itemBackgroundImages != null && 0 < this.itemBackgroundImages.length) {
        int index = 0;
        Paint outlinePaint = Color.BLACK;
        Stroke outlineStroke = new BasicStroke(1.0f);
        for (@SuppressWarnings("unused")
        Object key : dataSet.getColumnKeys()) {
            int imageIndex = index % this.itemBackgroundImages.length;
            BufferedImage texture = this.itemBackgroundImages[imageIndex];
            Rectangle2D anchor = new Rectangle2D.Double(0, 0, texture.getWidth(), texture.getHeight());
            TexturePaint fillPaint = new TexturePaint(texture, anchor);
            renderer.setSeriesFillPaint(index, fillPaint);
            renderer.setSeriesPaint(index, fillPaint);
            renderer.setSeriesOutlinePaint(index, outlinePaint);
            renderer.setSeriesOutlineStroke(index, outlineStroke);

            // renderer.setBasePaint(fillPaint);
            // renderer.setBaseOutlineStroke(outlineStroke);
            // renderer.setBaseOutlinePaint(outlinePaint);
        }

    }
}