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

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

Introduction

In this page you can find the example usage for org.jfree.chart.plot PiePlot 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:simx.profiler.info.application.MessagesInfoTopComponent.java

private void createPieChart(final DefaultPieDataset data, final javax.swing.JPanel targetPanel) {
    final JFreeChart chart = ChartFactory.createPieChart("", data, false, false, false);
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);/*from   w  w  w .  j  a  va2  s .  co m*/
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(261, 157));
    targetPanel.setLayout(new BorderLayout());
    targetPanel.add(chartPanel, BorderLayout.CENTER);
}

From source file:com.orange.atk.atkUI.coregui.StatisticTool.java

/**
 * Creates the chart./*from  w ww  .jav  a 2s. co m*/
 * 
 * @param piedataset
 *            the data set
 * @return the created chart
 */
private JFreeChart createChart(PieDataset piedataset) {
    JFreeChart jfreechart = ChartFactory.createPieChart3D("", piedataset, true, true, false);
    jfreechart.setBackgroundPaint(Color.lightGray);
    PiePlot pie3dplot = (PiePlot) jfreechart.getPlot();
    pie3dplot.setStartAngle(0);
    pie3dplot.setDirection(Rotation.CLOCKWISE);
    pie3dplot.setForegroundAlpha(0.5F);
    pie3dplot.setNoDataMessage("No data to display");
    pie3dplot.setSectionPaint(0, Color.GREEN);// passed
    pie3dplot.setSectionPaint(1, Color.RED);// failed
    pie3dplot.setSectionPaint(2, Color.ORANGE);// skipped
    pie3dplot.setSectionPaint(3, Color.LIGHT_GRAY);// not analysed
    pie3dplot.setToolTipGenerator(new MyToolTipGenerator());
    pie3dplot.setLabelGenerator(new MySectionLabelGenerator());
    pie3dplot.setLegendLabelGenerator(new MySectionLabelGenerator());
    return jfreechart;
}

From source file:com.polivoto.vistas.acciones.Datos.java

private JFreeChart crearChartPie(PieDataset dataset, String titulo) {
    JFreeChart chart = ChartFactory.createPieChart(titulo, dataset, false, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setStartAngle(290);/*from  w w w  .java2s .  c om*/
    plot.setDirection(Rotation.ANTICLOCKWISE);

    plot.setNoDataMessage("No hay votos");
    try {
        if (ac.getConteoOpcionesPregunta().getJSONObject(pox).getInt("participantes") != 0) {
            int j = 0;
            for (int i = 0; i < ac.getConteoOpcionesPregunta().getJSONObject(pox).getJSONArray("conteo")
                    .length(); i++) {
                try {
                    if (ac.getConteoOpcionesPregunta().getJSONObject(pox).getJSONArray("conteo")
                            .getJSONObject(i).getString("reactivo").equals("Anular mi voto")) {
                        plot.setSectionPaint("Nulo", Color.lightGray);
                    } else {
                        plot.setSectionPaint(ac.getConteoOpcionesPregunta().getJSONObject(pox)
                                .getJSONArray("conteo").getJSONObject(i).getString("reactivo"), colores.get(j));
                        j++;
                    }
                } catch (JSONException ex) {
                    ex.printStackTrace();
                }
            }
        }
    } catch (JSONException ex) {
        ex.printStackTrace();
    }
    plot.setSimpleLabels(true);
    plot.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.white));
    PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {2} de votos",
            new DecimalFormat("0"), new DecimalFormat("0.000%"));
    plot.setLabelGenerator(gen);
    if (rotating) {
        final Rotator rotate = new Rotator(plot);
        rotate.start();
    }
    return chart;
}

From source file:userinterface.CountryNetworkAdminRole.CountryReportsJPanel.java

public JFreeChart createDonorsReportsChart(PieDataset dataSet, String chartTitle) {

    JFreeChart chart = ChartFactory.createPieChart(chartTitle, dataSet, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setStartAngle(0);//w  ww  . ja v a  2  s.  c om
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
}

From source file:userinterface.CountryNetworkAdminRole.CountryReportsJPanel.java

public JFreeChart createPatientReportsChart(PieDataset dataSet, String chartTitle) {
    //ChartFactory.createPieChart(chartTitle, dataSet, true, true, false);
    JFreeChart chart = ChartFactory.createPieChart(chartTitle, dataSet, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setStartAngle(0);/*  w  ww.ja  v a 2 s  . c o m*/
    plot.setDirection(Rotation.CLOCKWISE);
    //plot.setForegroundAlpha(0.8f);
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
}

From source file:de.main.sessioncreator.ReportingHelper.java

/**
 * Creates a chart/*from ww  w  .ja  v  a2s.c  om*/
 */
private JFreeChart createChart(PieDataset dataset, String title) {

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

    //        PiePlot3D plot = (PiePlot3D) chart.getPlot();
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(),
            NumberFormat.getPercentInstance()));
    plot.setStartAngle(90);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    return chart;

}

From source file:org.pentaho.plugin.jfreereport.reportcharts.PieChartExpression.java

protected void configureChart(final JFreeChart chart) {
    super.configureChart(chart);

    final Plot plot = chart.getPlot();
    final PiePlot pp = (PiePlot) plot;
    final PieDataset pieDS = pp.getDataset();
    pp.setDirection(rotationClockwise ? Rotation.CLOCKWISE : Rotation.ANTICLOCKWISE);
    if ((explodeSegment != null) && (explodePct != null)) {
        configureExplode(pp);/*from   w ww  .ja va 2  s.  c  o m*/
    }
    if (StringUtils.isEmpty(getTooltipFormula()) == false) {
        pp.setToolTipGenerator(new FormulaPieTooltipGenerator(getRuntime(), getTooltipFormula()));
    }
    if (StringUtils.isEmpty(getUrlFormula()) == false) {
        pp.setURLGenerator(new FormulaPieURLGenerator(getRuntime(), getUrlFormula()));
    }

    pp.setIgnoreNullValues(ignoreNulls);
    pp.setIgnoreZeroValues(ignoreZeros);
    if (Boolean.FALSE.equals(getItemsLabelVisible())) {
        pp.setLabelGenerator(null);
    } else {
        final ExpressionRuntime runtime = getRuntime();
        final Locale locale = runtime.getResourceBundleFactory().getLocale();

        final FastDecimalFormat fastPercent = new FastDecimalFormat(FastDecimalFormat.TYPE_PERCENT, locale);
        final FastDecimalFormat fastInteger = new FastDecimalFormat(FastDecimalFormat.TYPE_INTEGER, locale);

        final DecimalFormat numFormat = new DecimalFormat(fastInteger.getPattern(),
                new DecimalFormatSymbols(locale));
        numFormat.setRoundingMode(RoundingMode.HALF_UP);

        final DecimalFormat percentFormat = new DecimalFormat(fastPercent.getPattern(),
                new DecimalFormatSymbols(locale));
        percentFormat.setRoundingMode(RoundingMode.HALF_UP);

        final StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator(pieLabelFormat,
                numFormat, percentFormat);
        pp.setLabelGenerator(labelGen);

        final StandardPieSectionLabelGenerator legendGen = new StandardPieSectionLabelGenerator(
                pieLegendLabelFormat, numFormat, percentFormat);
        pp.setLegendLabelGenerator(legendGen);
    }

    if (StringUtils.isEmpty(getLabelFont()) == false) {
        pp.setLabelFont(Font.decode(getLabelFont()));
    }

    if (pieDS != null) {
        final String[] colors = getSeriesColor();
        for (int i = 0; i < colors.length; i++) {
            if (i < pieDS.getItemCount()) {
                pp.setSectionPaint(pieDS.getKey(i), parseColorFromString(colors[i]));
            } else {
                break;
            }
        }
    }

    if (shadowPaint != null) {
        pp.setShadowPaint(shadowPaint);
    }
    if (shadowXOffset != null) {
        pp.setShadowXOffset(shadowXOffset.doubleValue());
    }
    if (shadowYOffset != null) {
        pp.setShadowYOffset(shadowYOffset.doubleValue());
    }
    pp.setCircular(circular);

    if (isShowBorder() == false || isChartSectionOutline() == false) {
        chart.setBorderVisible(false);
        chart.getPlot().setOutlineVisible(false);
    }

}

From source file:edu.isistan.carcha.plugin.editors.DXMIEditor.java

/**
 * Creates the PieChart page./* w w  w  . ja va  2s.c o m*/
 */
void createPieChartPage() {
    result = new DefaultPieDataset();

    JFreeChart chart = ChartFactory.createPieChart("Design Decisions", result, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);

    Composite composite = new Composite(getContainer(), SWT.NONE);
    FillLayout layout = new FillLayout();
    composite.setLayout(layout);
    new ChartComposite(composite, SWT.NONE, chart, true);
    int index = addPage(composite);
    setPageText(index, "Graph");

}

From source file:edu.isistan.carcha.plugin.editors.TraceabilityEditor.java

/**
 * Creates the impact Pie Chart page. It allows users to select a Crosscutting Concern and see Design Decision type distribution
 *///from   ww  w.  ja  v a2s .c  o  m
void impactPieChartPage() {

    ddDataset = new DefaultPieDataset();
    impactDataset = new DefaultPieDataset();
    JFreeChart ddChart = ChartFactory.createPieChart("Crosscutting Concerns", ddDataset, true, true, false);
    JFreeChart impactChart = ChartFactory.createPieChart("Design Decisions", impactDataset, true, true, false);

    PiePlot ddPlot = (PiePlot) ddChart.getPlot();
    ddPlot.setStartAngle(290);
    ddPlot.setDirection(Rotation.CLOCKWISE);
    ddPlot.setForegroundAlpha(0.5f);

    PiePlot impactPlot = (PiePlot) impactChart.getPlot();
    impactPlot.setStartAngle(290);
    impactPlot.setDirection(Rotation.CLOCKWISE);
    impactPlot.setForegroundAlpha(0.5f);

    PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}  ({2})");
    ddPlot.setLabelGenerator(gen);
    impactPlot.setLabelGenerator(gen);

    Composite composite = new Composite(getContainer(), SWT.NONE);
    FillLayout layout = new FillLayout();
    composite.setLayout(layout);
    final ChartComposite cComposite = new ChartComposite(composite, SWT.NONE, ddChart, true);
    cComposite.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            String[] parts = event.getEntity().getToolTipText().split(":");
            HashMap<String, Integer> values = PluginUtil.getDDDistributionForCrossCuttingConcern(cp, parts[0]);
            logger.info("Impact Pie Chart for: " + parts[0]);
            impactDataset.clear();
            for (String key : values.keySet()) {
                impactDataset.setValue(key, values.get(key));
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        }
    });
    new ChartComposite(composite, SWT.NONE, impactChart, true);
    int index = addPage(composite);
    setPageText(index, "Graph");
}

From source file:simx.profiler.info.actor.ActorInstanceInfoTopComponent.java

/**
 * This method creates a pie chart and adds it to the target panel.
 * /* w w  w  .jav a  2 s.c  o m*/
 * @param data The data set that should be visualized by the pie chart.
 * @param targetPanel The panel where the pie chart should be added to.
 */
private void createPieChart(final DefaultPieDataset data, final javax.swing.JPanel targetPanel) {
    if (data == null)
        throw new IllegalArgumentException("The parameter 'data' must not be 'null'!");
    if (targetPanel == null)
        throw new IllegalArgumentException("The parameter 'targetPanel' must not be 'null'!");

    data.setValue("???", 100);
    final JFreeChart chart = ChartFactory.createPieChart("", data, false, false, false);
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(261, 157));
    targetPanel.setLayout(new BorderLayout());
    targetPanel.add(chartPanel, BorderLayout.CENTER);
}