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

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

Introduction

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

Prototype

public void setDirection(Rotation direction) 

Source Link

Document

Sets the direction in which the pie sections are drawn and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:edu.coeia.charts.PieChartPanel.java

private static JFreeChart createChart(final PieDataset dataset, String str) {
    final JFreeChart chart = ChartFactory.createPieChart3D(str, // chart title
            dataset, // data
            true, // include legend
            true, false);// w ww. ja  v a 2  s.  co  m

    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    StandardPieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{0} {2}");
    plot.setLabelGenerator(labelGenerator);
    plot.setNoDataMessage("No data to display");
    return chart;
}

From source file:org.jw.service.factory.StatisticsChartFactory.java

public static JFreeChart createPieChart3D(PieDataset dataset, String title) {
    JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, true);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setForegroundAlpha(0.5f);/*from   www . ja v a2 s .  com*/
    plot.setDirection(Rotation.CLOCKWISE);
    return chart;
}

From source file:cz.zcu.kiv.eegdatabase.wui.components.utils.ChartUtils.java

public static BufferedImage gererateChartForTopDownloadHistory(ChoiceHistory choiceHistory,
        boolean generateEmptyGraph, List<DownloadStatistic> topDownloadedFilesList, long countOfFilesHistory) {

    long countFile = 0;

    DefaultPieDataset dataset = new DefaultPieDataset();
    if (!generateEmptyGraph && topDownloadedFilesList != null) {
        for (int i = 0; i < topDownloadedFilesList.size(); i++) {
            dataset.setValue(topDownloadedFilesList.get(i).getFileName(),
                    new Long(topDownloadedFilesList.get(i).getCount()));
            countFile = countFile + topDownloadedFilesList.get(i).getCount();
        }/*w  w w  .  jav a  2s  .  c om*/

        if (countOfFilesHistory > countFile) {
            dataset.setValue("Other", countOfFilesHistory - countFile);
        }
    }

    String chartTitle = ResourceUtils.getString("title.dailyStatistic");
    if (choiceHistory == ChoiceHistory.WEEKLY) {
        chartTitle = ResourceUtils.getString("title.weeklyStatistic");

    } else if (choiceHistory == ChoiceHistory.MONTHLY) {
        chartTitle = ResourceUtils.getString("title.monthlyStatistic");
    }

    JFreeChart chart = ChartFactory.createPieChart3D(chartTitle, // chart
            // title
            dataset, // data
            true, // include legend
            true, false);

    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage(ResourceUtils.getString("label.noDataMessage"));

    return chart.createBufferedImage(600, 400);
}

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

/**
 * Creates a 3D pie chart.//w  w  w  .java 2 s . c  om
 * 
 * @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:graphic.Grafico.java

private static javax.swing.JPanel pizza3D(ArrayList nome, ArrayList valor, String tituloGrafico,
        float transparencia, String tipo) {
    DefaultPieDataset data = new DefaultPieDataset();

    for (int i = 0; i < nome.toArray().length; i++) {
        data.setValue("" + nome.get(i).toString(), new Double(valor.get(i).toString()));
    }//w  w  w . ja  va2 s.c  om

    JFreeChart chart = ChartFactory.createPieChart3D(tituloGrafico, data, true, true, true);

    java.awt.Color cor = new java.awt.Color(200, 200, 200);
    chart.setBackgroundPaint(cor);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setLabelLinksVisible(true);
    plot.setNoDataMessage("No existem dados para serem exibidos no grfico");

    plot.setStartAngle(90);
    plot.setDirection(Rotation.CLOCKWISE);

    plot.setForegroundAlpha(transparencia);
    plot.setInteriorGap(0.20);

    ChartPanel chartPanel = new ChartPanel(chart);

    return chartPanel;
}

From source file:br.com.ifpb.models.Grafico.java

/**
 * //from  w w w .  j a v  a2  s. co m
 * @param nome
 * @param valor
 * @param tituloGrafico
 * @param transparencia
 * @param tipo
 * @return 
 */
private static javax.swing.JPanel pizza3D(ArrayList nome, ArrayList valor, String tituloGrafico,
        float transparencia, String tipo) {

    DefaultPieDataset data = new DefaultPieDataset();

    for (int i = 0; i < nome.toArray().length; i++) {
        data.setValue("" + nome.get(i).toString(), new Double(valor.get(i).toString()));
    }

    JFreeChart chart = ChartFactory.createPieChart3D(tituloGrafico, data, true, true, true);
    java.awt.Color cor = new java.awt.Color(200, 200, 200);
    chart.setBackgroundPaint(cor);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setLabelLinksVisible(true);
    plot.setNoDataMessage("No existem dados para serem exibidos ");

    plot.setStartAngle(90);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(transparencia);
    plot.setInteriorGap(0.20);

    ChartPanel chartPanel = new ChartPanel(chart);

    return chartPanel;
}

From source file:userInterface.StateAdminRole.DecisionChartJPanel.java

private static JFreeChart createChart(PieDataset piedataset) {
    JFreeChart jfreechart = ChartFactory.createPieChart3D("Top 5 Vaccines", piedataset, true, false, false);
    PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot();
    pieplot3d.setStartAngle(270D);/*from   w ww  . ja va 2s .c om*/
    pieplot3d.setDirection(Rotation.ANTICLOCKWISE);
    pieplot3d.setForegroundAlpha(0.6F);
    return jfreechart;
}

From source file:org.jfree.chart.demo.ThumbnailDemo1.java

private static JFreeChart createChart2(PieDataset piedataset) {
    JFreeChart jfreechart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1", piedataset, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot();
    pieplot3d.setDarkerSides(true);/*from w  ww .  j  a  va 2 s. c  o  m*/
    pieplot3d.setStartAngle(290D);
    pieplot3d.setDirection(Rotation.CLOCKWISE);
    pieplot3d.setForegroundAlpha(0.5F);
    pieplot3d.setOutlinePaint(null);
    pieplot3d.setNoDataMessage("No data to display");
    return jfreechart;
}

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.
 */// ww w  .j a va 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  w w  .java2  s .  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;
}