Example usage for org.jfree.chart.plot PiePlot3D setBackgroundPaint

List of usage examples for org.jfree.chart.plot PiePlot3D setBackgroundPaint

Introduction

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

Prototype

public void setBackgroundPaint(Paint paint) 

Source Link

Document

Sets the background color of the plot area and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.cyberoam.iview.charts.CustomToolTipGeneratorForDiskUsage.java

/**
 * This method generates JFreeChart instance for 3D Pie chart with iView customization.
 * @param reportID specifies that for which report Chart is being prepared.
 * @param rsw specifies data set which would be used for the Chart
 * @param requeest used for Hyperlink generation from uri.
 * @return jfreechart instance with iView Customization.
 *//*  w  w w  .  j  a  v a  2  s.com*/
public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) {
    boolean xFlag = false;
    ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID);
    JFreeChart chart = null;
    try {
        ReportColumnBean reportColumnBean, reportColumnBeanX = null;
        GraphBean graphBean = null;
        DataLinkBean dataLinkBean = null;
        DefaultPieDataset dataset = new DefaultPieDataset();
        graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean
        reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getXColumnId());//getting ReportColumnBean For X Axis
        //   String xColumnDBname = reportColumnBeanX.getDbColumnName();

        if (reportColumnBeanX.getDataLinkId() != -1) {
            dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBeanX.getDataLinkId());
        }
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getZColumnId());
        rsw.beforeFirst();
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getYColumnId());
        String yColumnName = reportColumnBean.getColumnName();
        if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) {
            dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId());
        }
        String xData = null;
        while (rsw.next()) {
            xData = rsw.getString(reportColumnBeanX.getDbColumnName());
            if (xData == null || "".equalsIgnoreCase(xData) || "null".equalsIgnoreCase(xData)) {
                xData = "N/A";
            } else if (reportColumnBeanX.getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING
                    && xData.indexOf(':') != -1) {
                String data = data = ProtocolBean.getProtocolNameById(Integer.parseInt(
                        rsw.getString(reportColumnBeanX.getDbColumnName()).substring(0, xData.indexOf(':'))));
                xData = data + rsw.getString(reportColumnBeanX.getDbColumnName()).substring(xData.indexOf(':'),
                        xData.length());
            }
            dataset.setValue(xData, new Long(rsw.getLong(reportColumnBean.getDbColumnName())));
        }
        chart = ChartFactory.createPieChart3D("", // chart title
                dataset, // data
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
        /*
         *Setting additional customization to the chart. 
         */
        //Set the background color for the chart...
        chart.setBackgroundPaint(Color.white);

        //Get a reference to the plot for further customisation...
        PiePlot3D plot = (PiePlot3D) chart.getPlot();
        plot.setBackgroundPaint(Color.white);
        plot.setBackgroundAlpha(0.0f);
        plot.setSectionOutlinesVisible(false);
        plot.setOutlineVisible(false);
        plot.setStartAngle(290);
        plot.setDepthFactor(0.1);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setNoDataMessage("No data to display");
        plot.setSectionOutlinesVisible(false);
        plot.setSectionOutlinePaint(Color.white);
        plot.setOutlineVisible(false);
        plot.setExplodePercent(dataset.getKey(0), 0.3);

        plot.setLabelLinkPaint(Color.gray);
        plot.setLabelBackgroundPaint(Color.white);
        plot.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10));
        plot.setLabelOutlinePaint(Color.white);
        plot.setLabelShadowPaint(Color.white);

        LegendTitle legend = chart.getLegend();
        legend.setItemFont(new Font("Arial", Font.CENTER_BASELINE, 10));
        legend.setMargin(0, 0, 2, 0);
        legend.setHorizontalAlignment(HorizontalAlignment.CENTER);

        plot.setToolTipGenerator(new CustomToolTipGeneratorForPie3D("{0}: ({1} " + yColumnName + ", {2})"));
        //Setting Color 
        try {
            plot.setSectionPaint(dataset.getKey(0), new Color(0, 0, 254));
            plot.setSectionPaint(dataset.getKey(1), new Color(255, 0, 254));
            plot.setSectionPaint(dataset.getKey(2), new Color(176, 176, 255));
            plot.setSectionPaint(dataset.getKey(3), new Color(255, 170, 255));
            plot.setSectionPaint(dataset.getKey(4), new Color(69, 153, 204));
        } catch (Exception e) {
        }

    } catch (Exception e) {
        CyberoamLogger.appLog.debug("Pie3D.e:" + e, e);
    }
    return chart;
}

From source file:org.cyberoam.iview.charts.CustomToolTipGeneratorForPie3D.java

/**
 * This method generates JFreeChart instance for 3D Pie chart with iView customization.
 * @param reportID specifies that for which report Chart is being prepared.
 * @param rsw specifies data set which would be used for the Chart
 * @param requeest used for Hyperlink generation from uri.
 * @return jfreechart instance with iView Customization.
 *///from w ww .j a  va  2s  . c o m
public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) {
    boolean xFlag = false;
    ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID);
    JFreeChart chart = null;
    try {
        ReportColumnBean reportColumnBean, reportColumnBeanX = null;
        GraphBean graphBean = null;
        DataLinkBean dataLinkBean = null;
        DefaultPieDataset dataset = new DefaultPieDataset();
        graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean
        reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getXColumnId());//getting ReportColumnBean For X Axis
        //   String xColumnDBname = reportColumnBeanX.getDbColumnName();

        if (reportColumnBeanX.getDataLinkId() != -1) {
            dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBeanX.getDataLinkId());
        }
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getZColumnId());
        rsw.beforeFirst();
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getYColumnId());
        String yColumnName = reportColumnBean.getColumnName();
        if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) {
            dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId());
        }
        String xData = null;
        while (rsw.next()) {
            xData = rsw.getString(reportColumnBeanX.getDbColumnName());
            if (xData == null || "".equalsIgnoreCase(xData) || "null".equalsIgnoreCase(xData)) {
                xData = "N/A";
            } else if (reportColumnBeanX.getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING
                    && xData.indexOf(':') != -1) {
                String data = data = ProtocolBean.getProtocolNameById(Integer.parseInt(
                        rsw.getString(reportColumnBeanX.getDbColumnName()).substring(0, xData.indexOf(':'))));
                xData = data + rsw.getString(reportColumnBeanX.getDbColumnName()).substring(xData.indexOf(':'),
                        xData.length());
            }
            dataset.setValue(xData, new Long(rsw.getLong(reportColumnBean.getDbColumnName())));
        }
        chart = ChartFactory.createPieChart3D("", // chart title
                dataset, // data
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
        /*
         *Setting additional customization to the chart. 
         */
        //Set the background color for the chart...
        chart.setBackgroundPaint(Color.white);

        //Get a reference to the plot for further customisation...
        PiePlot3D plot = (PiePlot3D) chart.getPlot();
        plot.setBackgroundPaint(Color.white);
        plot.setBackgroundAlpha(0.0f);
        plot.setSectionOutlinesVisible(false);
        plot.setOutlineVisible(false);
        plot.setStartAngle(290);
        plot.setDepthFactor(0.1);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setNoDataMessage("No data to display");
        plot.setSectionOutlinesVisible(false);
        plot.setSectionOutlinePaint(Color.white);
        plot.setOutlineVisible(false);
        plot.setExplodePercent(dataset.getKey(0), 0.3);

        plot.setLabelLinkPaint(Color.gray);
        plot.setLabelBackgroundPaint(Color.white);
        plot.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10));
        plot.setLabelOutlinePaint(Color.white);
        plot.setLabelShadowPaint(Color.white);

        LegendTitle legend = chart.getLegend();
        legend.setItemFont(new Font("Arial", Font.CENTER_BASELINE, 10));
        legend.setMargin(0, 0, 2, 0);
        legend.setHorizontalAlignment(HorizontalAlignment.CENTER);

        plot.setToolTipGenerator(new CustomToolTipGeneratorForPie3D("{0}: ({1} " + yColumnName + ", {2})"));
        //Setting Color 
        try {
            plot.setSectionPaint(dataset.getKey(0), Pie3D.pieSections[0]);
            plot.setSectionPaint(dataset.getKey(1), Pie3D.pieSections[1]);
            plot.setSectionPaint(dataset.getKey(2), Pie3D.pieSections[2]);
            plot.setSectionPaint(dataset.getKey(3), Pie3D.pieSections[3]);
            plot.setSectionPaint(dataset.getKey(4), Pie3D.pieSections[4]);
        } catch (Exception e) {
        }

    } catch (Exception e) {
        CyberoamLogger.appLog.debug("Pie3D.e:" + e, e);
    }
    return chart;
}

From source file:de.aidger.view.utils.Charts.java

/**
 * Creates a 3D pie chart./*w ww.ja  v  a  2  s . co m*/
 * 
 * @param title
 *            the diagram title
 * @param dataset
 *            the dataset.
 * @param width
 *            the width of the chart as image
 * @param height
 *            the height of the chart as image
 * 
 * @return the 3D pie chart as image
 */
public static ImageIcon createPieChart3D(String title, PieDataset dataset, int width, int height) {
    JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false);

    Font titleFont = UIManager.getFont("TitledBorder.font");

    chart.setBackgroundPaint(null);
    chart.getLegend().setBackgroundPaint(null);
    chart.getTitle().setFont(new Font(titleFont.getName(), titleFont.getStyle(), 14));
    chart.getTitle().setPaint(UIManager.getColor("TitledBorder.titleColor"));
    chart.setBorderPaint(null);
    chart.getLegend().setBorder(0, 0, 0, 0);

    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setForegroundAlpha(0.9f);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setNoDataMessage(_("No data to display."));
    plot.setLabelGenerator(null);
    plot.setInsets(new RectangleInsets(10, 1, 5, 1));
    plot.setBackgroundPaint(null);
    plot.setOutlineVisible(false);
    plot.setDarkerSides(true);

    return new ImageIcon(chart.createBufferedImage(width, height));
}

From source file:com.tonbeller.jpivot.chart.ChartFactory.java

/**
 * Creates a sample dataset for the demo.
 * // ww w.ja v  a 2s . c om
 * @return A sample dataset.
 */
public static JFreeChart create3DPieChart(String title, java.awt.Font titleFont, CategoryDataset data,
        TableOrder order, boolean legend, boolean tooltips, boolean urls, PieURLGenerator urlGenerator) {

    MultiplePiePlot plot = new MultiplePiePlot(data);
    plot.setDataExtractOrder(order);

    //plot.setOutlineStroke(null);

    JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
    pieChart.setBackgroundPaint(null);
    plot.setPieChart(pieChart);

    PiePlot3D pp = (PiePlot3D) plot.getPieChart().getPlot();
    pp.setBackgroundPaint(null);
    //pp.setInsets(new Insets(0, 5, 5, 5));

    // no outline around each piechart
    pp.setOutlineStroke(null);

    PieToolTipGenerator tooltipGenerator = null;
    if (tooltips) {
        tooltipGenerator = new StandardPieToolTipGenerator();
    }

    if (!urls) {
        urlGenerator = null;
    }

    pp.setToolTipGenerator(tooltipGenerator);
    pp.setLabelGenerator(null);
    pp.setURLGenerator(urlGenerator);
    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;

}

From source file:com.ewcms.plugin.report.generate.service.chart.ChartGenerationService.java

/**
 * 3D//from w  w  w  .j av  a2  s .c  o m
 *
 * @param title 
 * @param titleFont 
 * @param data ??
 * @param order
 * @param legend 
 * @param tooltips ????
 * @param urls ??URL
 * @param urlGenerator
 *
 * @return 
 */
public static JFreeChart create3DPieChart(String title, java.awt.Font titleFont, CategoryDataset data,
        TableOrder order, boolean legend, boolean tooltips, boolean urls, PieURLGenerator urlGenerator) {

    MultiplePiePlot plot = new MultiplePiePlot(data);
    plot.setDataExtractOrder(order);

    // plot.setOutlineStroke(null);

    JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
    pieChart.setBackgroundPaint(null);
    plot.setPieChart(pieChart);

    PiePlot3D pp = (PiePlot3D) plot.getPieChart().getPlot();
    pp.setBackgroundPaint(null);
    // pp.setInsets(new Insets(0, 5, 5, 5));

    pp.setOutlineStroke(null);

    PieToolTipGenerator tooltipGenerator = null;
    if (tooltips) {
        tooltipGenerator = new StandardPieToolTipGenerator();
    }

    if (!urls) {
        urlGenerator = null;
    }

    pp.setToolTipGenerator(tooltipGenerator);
    pp.setLabelGenerator(null);
    pp.setURLGenerator(urlGenerator);
    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;
}

From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java

@Override
protected JFreeChart createChart() {
    // create the chart...
    pieDataSet = createDataset();//from w w w. ja  va2  s  . c o m
    final JFreeChart chart = ChartFactory.createPieChart3D("", // chart
            // title
            pieDataSet, // data
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.getTitle().setPaint(new Color(0x5E5E5E));
    chart.setBorderVisible(false);
    // set the background color for the chart...
    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setOutlineVisible(false);
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setStartAngle(290);
    plot.setBackgroundPaint(Color.white);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data to display");
    plot.setLabelGenerator(new JFreeChartLabelCustom());

    final List keys = pieDataSet.getKeys();
    for (int i = 0; i < keys.size(); i++) {
        final Comparable key = (Comparable) keys.get(i);
        plot.setSectionPaint(key, Color.decode(
                "0x" + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length]));
    }
    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
}

From source file:com.esofthead.mycollab.ui.chart.PieChartWrapper.java

@Override
protected JFreeChart createChart() {
    // create the chart...
    pieDataSet = createDataset();//w  w  w .  j a  v  a2 s  . co  m
    final JFreeChart chart = ChartFactory.createPieChart3D("", // chart
            // title
            pieDataSet, // data
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.getTitle().setPaint(new Color(0x5E5E5E));
    chart.setBorderVisible(false);
    // set the background color for the chart...
    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setOutlineVisible(false);
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setStartAngle(290);
    plot.setBackgroundPaint(Color.white);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data to display");
    plot.setLabelGenerator(new JFreeChartLabelCustom());

    final List keys = pieDataSet.getKeys();
    for (int i = 0; i < keys.size(); i++) {
        final Comparable key = (Comparable) keys.get(i);
        int colorIndex = i % CHART_COLOR_STR.size();
        plot.setSectionPaint(key, Color.decode("0x" + CHART_COLOR_STR.get(colorIndex)));
    }
    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
}

From source file:loansystem.visual.panel.StartPage.java

private void graficoPorEstado() {
    ArrayList<GraficoEntidad> graficos;
    graficos = gDao.obtenerPrestamosPorEstado();
    DefaultPieDataset data = new DefaultPieDataset();

    if (graficos.size() > 0) {

        for (GraficoEntidad result : graficos) {
            //datos.setValue(result.getValor(), result.getSerie(), result.getValorEje());
            data.setValue(result.getValorEje(), result.getValor());
        }//from  www .  j av  a2 s  .co  m

        //dibujarGrafico(datos, BAR, "Otorgado vs Recuperado", "Moneda", "Monto",PlotOrientation.VERTICAL,pnelOtorgadoRecuperado);

        // Creando el Grafico
        /*JFreeChart grafica = ChartFactory.createPieChart(
         "Prstamos por Estado", 
         data, 
         true, 
         true, 
         false);*/

        JFreeChart grafica = ChartFactory.createPieChart3D("Prstamos por Estado", data, true, true, false);
        grafica.setBackgroundPaint(Color.white);
        PiePlot3D plot = (PiePlot3D) grafica.getPlot();
        plot.setForegroundAlpha(0.6f);
        plot.setCircular(true);
        plot.setLabelGap(0.01);
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {1} ({2})"));
        plot.setBackgroundPaint(null);

        // Mostrar Grafico
        ChartPanel panel = new ChartPanel(grafica);
        pnelPorEstado.add(panel);
        pnelPorEstado.revalidate();
        pnelPorEstado.repaint();

    }

}

From source file:org.gvsig.symbology.fmap.symbols.PieChart3DSymbol.java

protected Plot getMapPlot() {
    if (mapPlot == null) {
        PiePlot3D myMapPlot;
        try {/*  ww w.jav a 2  s . c  o m*/
            myMapPlot = (PiePlot3D) getOutlinePlot().clone();
        } catch (CloneNotSupportedException e) {
            Logger.getLogger(getClass()).error("Error cloning the PieChartSymbol's plot, check consistency");
            myMapPlot = new PiePlot3D();
        }

        myMapPlot.setBackgroundPaint(null);
        myMapPlot.setOutlinePaint(null);
        myMapPlot.setLabelBackgroundPaint(null);
        myMapPlot.setLabelGenerator(null);
        myMapPlot.setLabelLinksVisible(false);
        mapPlot = myMapPlot;
    }
    return mapPlot;
}

From source file:net.nosleep.superanalyzer.analysis.views.EncodingKindView.java

private void createChart() {

    _chart = ChartFactory.createPieChart3D(Misc.getString("KINDS_OF_MUSIC_FILES"), _dataset, false, true,
            false);//from   w w  w  . j a v  a2s.  c om

    PiePlot3D plot = (PiePlot3D) _chart.getPlot();
    plot.setDarkerSides(true);
    plot.setStartAngle(PieRotator.angle);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data to display");
    plot.setInsets(new RectangleInsets(10, 10, 10, 10));
    plot.setOutlineVisible(false);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("KINDS_OF_MUSIC_FILES_SUBTITLE")));

    ChartUtilities.applyCurrentTheme(_chart);
    plot.setBackgroundPaint(Color.white);
    _chart.setBorderVisible(false);

    plot.setIgnoreZeroValues(true);

    // plot.setAutoPopulateSectionPaint(false);

    // Misc.formatChart(plot);
}