Example usage for org.jfree.chart JFreeChart setBackgroundPaint

List of usage examples for org.jfree.chart JFreeChart setBackgroundPaint

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart setBackgroundPaint.

Prototype

public void setBackgroundPaint(Paint paint) 

Source Link

Document

Sets the paint used to fill the chart background and sends a ChartChangeEvent to all registered listeners.

Usage

From source file:UI.MainViewPanel.java

public ChartPanel getPanel5(Metric5 m5) {
    int totalRiskCount = m5.totalCriticalCount + m5.totalHighCount + m5.totalLowCount + m5.totalMediumCount;
    String[][] risks = new String[totalRiskCount][3];
    BarChart barChart = new BarChart(m5.totalCriticalCount, m5.totalHighCount, m5.totalMediumCount,
            m5.totalLowCount, 0, "", risks);

    ChartPanel thisChart = barChart.drawBarChart();
    thisChart.setBackground(Color.white);

    JFreeChart chart = thisChart.getChart();
    chart.setBackgroundPaint(new Color(0, 0, 0, 0));

    Plot plot = chart.getPlot();//from ww  w  . j  a  va2  s.co  m
    plot.setBackgroundPaint(chartBackgroundColor);
    return thisChart;
}

From source file:UI.MainViewPanel.java

public ChartPanel getPanel1(Metric1 m1) {

    int totalRiskCount = m1.totalCriticalCount + m1.totalHighCount + m1.totalLowCount + m1.totalMediumCount;
    String[][] risks = new String[totalRiskCount][3];
    PieChart pieChart = new PieChart(m1.totalCriticalCount, m1.totalHighCount, m1.totalMediumCount,
            m1.totalLowCount, "", risks, true);

    ChartPanel thisChart = pieChart.drawPieChart();
    thisChart.setBackground(Color.white);

    JFreeChart chart = thisChart.getChart();
    chart.setBackgroundPaint(new Color(0, 0, 0, 0));

    Plot plot = chart.getPlot();//from  w w  w .j  a  va 2s .c o m
    plot.setBackgroundPaint(chartBackgroundColor);
    return thisChart;
}

From source file:UI.MainViewPanel.java

public ChartPanel getPanel3(Metric3 m3) {

    int totalRiskCount = m3.totalCriticalCount + m3.totalLowCount;
    String[][] risks = new String[totalRiskCount][3];
    RingChart ringChart = new RingChart(m3.totalCriticalCount, m3.totalHighCount, m3.totalMediumCount,
            m3.totalLowCount, "", risks);

    ChartPanel thisChart = ringChart.drawRingChart();
    thisChart.setBackground(Color.white);

    JFreeChart chart = thisChart.getChart();
    chart.setBackgroundPaint(Color.white);

    Plot plot = chart.getPlot();/*from   w  ww. jav a  2s  .  c  o m*/
    plot.setBackgroundPaint(chartBackgroundColor);
    return thisChart;
}

From source file:UI.MainViewPanel.java

public ChartPanel getPanel4(Metric4 m4) {

    int totalRiskCount = m4.totalCriticalCount + m4.totalHighCount + m4.totalLowCount + m4.totalMediumCount;
    String[][] risks = new String[totalRiskCount][3];
    PieChart pieChart = new PieChart(m4.totalCriticalCount, m4.totalHighCount, m4.totalMediumCount,
            m4.totalLowCount, "", risks, true);

    ChartPanel thisChart = pieChart.drawPieChart();
    thisChart.setBackground(Color.white);

    JFreeChart chart = thisChart.getChart();
    chart.setBackgroundPaint(new Color(0, 0, 0, 0));

    Plot plot = chart.getPlot();/*  w ww  .ja  v  a 2s .co  m*/
    plot.setBackgroundPaint(chartBackgroundColor);
    return thisChart;
}

From source file:UI.MainViewPanel.java

public ChartPanel getPanel2(Metric2 m2) {

    int totalRiskCount = m2.totalCriticalCount + m2.totalHighCount + m2.totalLowCount + m2.totalMediumCount;
    String[][] risks = new String[totalRiskCount][3];
    BarChart barChart = new BarChart(m2.totalCriticalCount, m2.totalHighCount, m2.totalMediumCount,
            m2.totalLowCount, 0, "", risks);

    ChartPanel thisChart = barChart.drawBarChart();
    thisChart.setBackground(Color.white);

    JFreeChart chart = thisChart.getChart();
    chart.setBackgroundPaint(new Color(0, 0, 0, 0));

    Plot plot = chart.getPlot();/*from w w w.java2 s  . c  o m*/
    plot.setBackgroundPaint(chartBackgroundColor);

    return thisChart;
}

From source file:UI.MainViewPanel.java

public ChartPanel getPanel6(Metric6 m6) {

    int totalRiskCount = m6.totalCriticalCount + m6.totalHighCount + m6.totalLowCount + m6.totalMediumCount;
    String[][] risks = new String[totalRiskCount][3];
    RingChart ringChart = new RingChart(m6.totalCriticalCount, m6.totalHighCount, m6.totalMediumCount,
            m6.totalLowCount, "", risks);

    ringChart.lowValue = ("Low (" + m6.totalLowCount + ")");
    ChartPanel thisChart = ringChart.drawRingChart();
    thisChart.setBackground(Color.white);

    JFreeChart chart = thisChart.getChart();
    chart.setBackgroundPaint(new Color(0, 0, 0, 0));

    Plot plot = chart.getPlot();//from w ww.j  a  v  a 2 s. co m
    plot.setBackgroundPaint(chartBackgroundColor);
    return thisChart;
}

From source file:UI.MainViewPanel.java

public ChartPanel getPanel8(Metric8 m8) {

    int totalRiskCount = m8.totalCriticalCount + m8.totalHighCount + m8.totalLowCount + m8.totalMediumCount;
    String[][] risks = new String[totalRiskCount][3];
    BarChart barChart = new BarChart(m8.totalCriticalCount, m8.totalHighCount, m8.totalMediumCount,
            m8.totalLowCount, m8.totalOtherCount, "", risks);

    ChartPanel thisChart = barChart.drawBarChart();
    thisChart.setBackground(Color.white);

    JFreeChart chart = thisChart.getChart();
    chart.setBackgroundPaint(new Color(0, 0, 0, 0));

    Plot plot = chart.getPlot();//  ww w  .j a v  a  2s  .  com
    plot.setBackgroundPaint(chartBackgroundColor);

    return thisChart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo1.java

/**
 * Creates a sample chart.//www  .j a  v a2s .c om
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(BoxAndWhiskerCategoryDataset dataset) {

    CategoryAxis domainAxis = new CategoryAxis(null);
    NumberAxis rangeAxis = new NumberAxis(rangeLabel);
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
    JFreeChart chart = new JFreeChart(chartTitle, plot);

    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    renderer.setLegendItemLabelGenerator(
            new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT));

    //RowCount -- serie count
    if (dataset.getColumnCount() * dataset.getRowCount() < 5) {

        domainAxis.setLowerMargin(0.2);
        domainAxis.setUpperMargin(0.2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(0.5);
        //   domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2);
        /*         
        System.out.println("1lowerMargin="+domainAxis.getLowerMargin());
        System.out.println("ItemMargin="+renderer.getItemMargin());
        System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/

    }

    else if (dataset.getColumnCount() * dataset.getRowCount() < 10) {
        domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2);
        domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(renderer.getItemMargin() * 2);
        else
            domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2);

        /*System.out.println("2lowerMargin="+domainAxis.getLowerMargin());
        System.out.println("ItemMargin="+renderer.getItemMargin());
        System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/

    }

    if (legendPanelOn)
        chart.removeLegend();
    return chart;

}

From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsGroupChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);/*from  www  .  j  a  v a 2 s.co  m*/
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    renderer2.setSeriesItemLabelsVisible(0, true);
    renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    plot.setDataset(0, this.dataset);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f));
    renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a"));
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:org.wsm.database.tools.editor.ui.GraphPane.java

/**
 * Invoked when an action occurs.//from   ww w .j  a  va2  s.co  m
 */
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == viewBarGraph) {
        JFreeChart chart = getChart(CHART_TYPE_BAR_3D);
        chart.setBackgroundPaint(Color.white);
        cp.setChart(chart);
    }
    if (e.getSource() == viewLineGraph) {
        JFreeChart chart = getChart(CHART_TYPE_LINE_3D);
        chart.setBackgroundPaint(Color.white);
        cp.setChart(chart);
    }

}