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

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

Introduction

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

Prototype

public void setForegroundAlpha(float alpha) 

Source Link

Document

Sets the alpha-transparency for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:chart.PieChart3D.java

public static void main(String[] args) throws Exception {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("IPhone 5s", new Double(20));
    dataset.setValue("SamSung Grand", new Double(20));
    dataset.setValue("MotoG", new Double(40));
    dataset.setValue("Nokia Lumia", new Double(10));

    JFreeChart chart = ChartFactory.createPieChart3D("Mobile Sales", // chart title                   
            dataset, // data 
            true, // include legend                   
            true, false);//from w  w  w. ja  v a2  s .  c om

    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(270);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.02);
    int width = 640; /* Width of the image */
    int height = 480; /* Height of the image */
    File pieChart3D = new File("pie_Chart3D.jpeg");
    ChartUtilities.saveChartAsJPEG(pieChart3D, chart, width, height);
}

From source file:statistique.PieChart3D.java

public static void main(String[] args) throws Exception {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("IPhone 5s", new Double(20));
    dataset.setValue("SamSung Grand", new Double(20));
    dataset.setValue("MotoG", new Double(40));
    dataset.setValue("Nokia Lumia", new Double(10));

    JFreeChart chart = ChartFactory.createPieChart3D("Mobile Sales", // chart title                   
            dataset, // data 
            true, // include legend                   
            true, false);//from   w ww. j a v  a2s.  c  om

    final PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(270);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.02);
    int width = 640; /* Width of the image */
    int height = 480; /* Height of the image */
    File pieChart3D = new File("pie_Chart3D.png");
    ChartUtilities.saveChartAsPNG(pieChart3D, chart, width, height);
}

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);
    plot.setDirection(Rotation.CLOCKWISE);
    return chart;
}

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);/*from   w  w  w .j  a  va 2s  .  c o  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:de.aidger.view.utils.Charts.java

/**
 * Creates a 3D pie chart.//from  w ww. j a  v a 2  s . com
 * 
 * @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: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();
        }/*from w w w  .  j av  a 2 s.  c  o m*/

        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: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()));
    }/*from  w  w w.  j  av  a 2s  .c  o m*/

    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  .  c o 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:com.globalsight.util.JfreeCharUtil.java

public static void drawPieChart3D(String title, Map<String, Double> datas, File OutFile) {
    PieDataset dataset = buildDatas(datas);
    JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})",
            NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})"));
    chart.setBackgroundPaint(Color.white);
    plot.setForegroundAlpha(0.7f);
    plot.setCircular(true);/*from  w  ww  . j  a  v  a2 s. c om*/
    TextTitle textTitle = new TextTitle(title);
    Font font = new Font(textTitle.getFont().getName(), Font.CENTER_BASELINE, 20);
    textTitle.setFont(font);
    chart.setTitle(textTitle);
    FileOutputStream fos_jpg = null;

    try {
        fos_jpg = new FileOutputStream(OutFile);
        ChartUtilities.writeChartAsJPEG(fos_jpg, 1, chart, 640, 480, null);
        fos_jpg.close();
    } catch (Exception e) {
        s_logger.error(e.getMessage(), e);
    }
}

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);/*w  w w.j  av a2s. c  o m*/
    pieplot3d.setDirection(Rotation.ANTICLOCKWISE);
    pieplot3d.setForegroundAlpha(0.6F);
    return jfreechart;
}