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

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

Introduction

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

Prototype

public void setStartAngle(double angle) 

Source Link

Document

Sets the starting angle 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.
 *///from  w ww .  ja v  a 2 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), 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.ja va 2 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;
}

From source file:userInterface.cdcRole.DecisionChartJPanel.java

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

From source file:userInterface.cdcRole.DecisionChartJPanel.java

private static JFreeChart createChart1(PieDataset piedataset) {
    JFreeChart jfreechart = ChartFactory.createPieChart3D("Top 5 Hospitals (For Orders Placed)", piedataset,
            true, false, false);/*from   w ww.j  av  a2s.c o  m*/
    PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot();
    pieplot3d.setStartAngle(270D);
    pieplot3d.setDirection(Rotation.ANTICLOCKWISE);
    pieplot3d.setForegroundAlpha(0.6F);
    return jfreechart;
}

From source file:edu.wpi.cs.wpisuitetng.modules.requirementmanager.view.requirements.NewPieChartPanel.java

/**
 * @param dataset// w  w w. j  av  a  2  s . co  m
 *            the data to be displayed by the pie chart
 * @param title
 *            the title of the chart @return the pie chart to be displayed
 */
private static JFreeChart createChart(PieDataset dataset, String title) {

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

    PiePlot3D plot = (PiePlot3D) chart.getPlot();// 3D pie chart. the cats
                                                 // are going to love
                                                 // this.
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(true);
    plot.setLabelGap(0.02);
    plot.setStartAngle(270);
    plot.setDirection(Rotation.ANTICLOCKWISE);
    //Rotator rotator = new Rotator(plot);
    //rotator.start();
    return chart;

}

From source file:userInterface.cdcRole.DecisionChartJPanel.java

private static JFreeChart createChart(PieDataset piedataset) {
    // System.out.println("1");
    JFreeChart jfreechart = ChartFactory.createPieChart3D("Top 5 States (For Vaccinations)", piedataset, true,
            false, false);/*from  w  w w. java 2  s .  c om*/
    PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot();
    pieplot3d.setDrawingSupplier(new ChartDrawingSupplier());
    pieplot3d.setStartAngle(270D);
    pieplot3d.setDirection(Rotation.ANTICLOCKWISE);
    pieplot3d.setForegroundAlpha(0.6F);
    return jfreechart;
}

From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java

public static JFreeChart createChartWithPieDataSet(ChartData chartData) {
    PieDataset dataset = (PieDataset) chartData.getDatasource();
    String type = chartData.getType();
    boolean legend = chartData.isLegend();
    JFreeChart chart = null;//from   w w w. j a  va2 s .  c  o m

    if (type.equalsIgnoreCase("pie")) {
        if (chartData.isChart3d()) {
            chart = ChartFactory.createPieChart3D("", dataset, legend, true, false);
            PiePlot3D plot = (PiePlot3D) chart.getPlot();
            plot.setDepthFactor((float) chartData.getDepth() / 100);
        } else {
            chart = ChartFactory.createPieChart("", dataset, legend, true, false);
        }
    } else if (type.equalsIgnoreCase("ring")) {
        chart = ChartFactory.createRingChart("", dataset, legend, true, false);
    }

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setStartAngle((float) chartData.getStartAngle());
    if (chartData.getGenerateMap() != null)
        plot.setURLGenerator(new StandardPieURLGenerator(""));

    setPieSectionColors(chart, chartData);

    return chart;
}

From source file:de.xirp.chart.ChartManager.java

/**
 * Returns a pie chart. The chart is generated from the given
 * {@link de.xirp.db.Record} and key array. The flag
 * <code>relative</code> indicated whether or not relative
 * values should be used.//w ww .j a  v  a 2s. co m
 * 
 * @param record
 *            The record containing the data.
 * @param keys
 *            The keys to use.
 * @param relative
 *            Flag indicating if relative values should be used.
 * @return A pie chart.
 * @see org.jfree.chart.JFreeChart
 * @see de.xirp.db.Record
 */
private static JFreeChart createPieChart(Record record, String[] keys, boolean relative) {
    String chartTitle = (relative ? I18n.getString("ChartManager.text.relative") //$NON-NLS-1$
            : I18n.getString("ChartManager.text.absolute")) //$NON-NLS-1$
            + I18n.getString("ChartManager.text.occurencesOfKey") + record.getName() + ": "; //$NON-NLS-1$ //$NON-NLS-2$

    DefaultPieDataset dataset = new DefaultPieDataset();

    Map<String, Long> values;
    values = ChartDatabaseUtil.getValuesForRecord(record, keys, relative);

    for (String s : values.keySet()) {
        dataset.setValue(s, values.get(s));
    }

    JFreeChart chart;
    if (options.is(OptionName.THREE_D)) {
        chart = ChartFactory.createPieChart3D(chartTitle, dataset, true, true, false);

        PiePlot3D plot = (PiePlot3D) chart.getPlot();
        plot.setStartAngle(290);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(0.5f);
        plot.setNoDataMessage(NO_DATA_AVAILABLE);
        plot.setLabelGenerator(new CustomLabelGenerator(options));
    } else {
        chart = ChartFactory.createPieChart(chartTitle, dataset, true, true, false);

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setSectionOutlinesVisible(true);
        plot.setNoDataMessage(NO_DATA_AVAILABLE);
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        plot.setLabelGenerator(new CustomLabelGenerator(options));
    }

    exportAutomatically(null, chart);

    return chart;
}

From source file:javaapplication2.PieChart.java

private JFreeChart createChart(PieDataset dataset, String title) {

    JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);//  w  w  w.  ja v a 2  s.co  m
    return chart;
}

From source file:com.codeandme.jfreechart.DemoView.java

private org.jfree.chart.JFreeChart createChart(final PieDataset dataset, final String title) {
    final JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false);
    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);//ww  w. ja v a  2s  . c o  m
    return chart;
}