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

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

Introduction

In this page you can find the example usage for org.jfree.chart.plot PiePlot 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:it.eng.spagobi.engines.chart.bo.charttypes.piecharts.LinkablePie.java

public JFreeChart createChart(DatasetMap datasets) {
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");

    boolean document_composition = false;
    if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))
        document_composition = true;//from  ww w .  ja va 2 s . co  m

    JFreeChart chart = null;

    if (!threeD) {
        chart = ChartFactory.createPieChart(name, (PieDataset) dataset, // data
                legend, // include legend
                true, false);

        chart.setBackgroundPaint(color);

        TextTitle title = chart.getTitle();
        title.setToolTipText("A title tooltip!");

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        plot.setNoDataMessage("No data available");

        if (percentage == false) {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
        } else {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
        }

        MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl);
        pieUrl.setDocument_composition(document_composition);
        pieUrl.setCategoryUrlLabel(categoryUrlName);
        pieUrl.setDrillDocTitle(drillDocTitle);
        pieUrl.setTarget(target);

        plot.setURLGenerator(pieUrl);

    } else {
        chart = ChartFactory.createPieChart3D(name, (PieDataset) dataset, // data
                true, // include legend
                true, false);

        chart.setBackgroundPaint(color);

        TextTitle title = chart.getTitle();
        title.setToolTipText("A title tooltip!");

        PiePlot3D plot = (PiePlot3D) chart.getPlot();

        plot.setDarkerSides(true);
        plot.setStartAngle(290);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(1.0f);
        plot.setDepthFactor(0.2);

        plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        plot.setNoDataMessage("No data available");

        //org.jfree.chart.renderer.category.BarRenderer renderer = new org.jfree.chart.renderer.category.AreaRenderer);

        MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl);
        pieUrl.setDocument_composition(document_composition);
        pieUrl.setCategoryUrlLabel(categoryUrlName);
        pieUrl.setDrillDocTitle(drillDocTitle);
        pieUrl.setTarget(target);

        plot.setURLGenerator(pieUrl);

        if (percentage == false) {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
        } else {
            plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
        }
    }

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    return chart;

}