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

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

Introduction

In this page you can find the example usage for org.jfree.chart.plot PiePlot setLabelLinkMargin.

Prototype

public void setLabelLinkMargin(double margin) 

Source Link

Document

Sets the link margin and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.sonar.server.charts.deprecated.PieChart.java

private void configurePlot() {
    PiePlot plot = (PiePlot) jfreechart.getPlot();
    plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setDataset(dataset);//from w  w w . j  av  a  2s .  com
    plot.setBackgroundAlpha(0.0f);
    plot.setCircular(true);
    plot.setLabelGenerator(null);
    plot.setIgnoreNullValues(true);
    plot.setIgnoreZeroValues(true);
    plot.setShadowPaint(null);
    plot.setLabelLinkMargin(0.0);
    plot.setInteriorGap(0.02);
    plot.setMaximumLabelWidth(0.10);
}

From source file:edu.jhuapl.graphs.jfreechart.JFreeChartPieGraphSource.java

@SuppressWarnings("unchecked")
@Override//  w w w .  ja  v a 2s .c o m
public void initialize() throws GraphException {
    String title = getParam(GraphSource.GRAPH_TITLE, String.class, DEFAULT_TITLE);
    boolean legend = getParam(GraphSource.GRAPH_LEGEND, Boolean.class, DEFAULT_GRAPH_LEGEND);
    boolean graphToolTip = getParam(GraphSource.GRAPH_TOOL_TIP, Boolean.class, DEFAULT_GRAPH_TOOL_TIP);
    boolean graphDisplayLabel = getParam(GraphSource.GRAPH_DISPLAY_LABEL, Boolean.class, false);
    boolean legendBorder = getParam(GraphSource.LEGEND_BORDER, Boolean.class, DEFAULT_LEGEND_BORDER);
    boolean graphBorder = getParam(GraphSource.GRAPH_BORDER, Boolean.class, DEFAULT_GRAPH_BORDER);
    Font titleFont = getParam(GraphSource.GRAPH_FONT, Font.class, DEFAULT_GRAPH_TITLE_FONT);
    String noDataMessage = getParam(GraphSource.GRAPH_NO_DATA_MESSAGE, String.class,
            DEFAULT_GRAPH_NO_DATA_MESSAGE);
    PieGraphData pieGraphData = makeDataSet();
    Map<Comparable, Paint> colors = pieGraphData.colors;

    this.chart = ChartFactory.createPieChart(title, pieGraphData.data, false, graphToolTip, false);

    Paint backgroundColor = getParam(GraphSource.BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR);
    Paint plotColor = getParam(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Paint.class, backgroundColor);
    Paint labelColor = getParam(JFreeChartTimeSeriesGraphSource.GRAPH_LABEL_BACKGROUND_COLOR, Paint.class,
            DEFAULT_BACKGROUND_COLOR);

    this.chart.setBackgroundPaint(backgroundColor);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(plotColor);
    plot.setNoDataMessage(noDataMessage);

    if (!graphDisplayLabel) {
        plot.setLabelGenerator(null);
    } else {
        plot.setInteriorGap(0.001);
        plot.setMaximumLabelWidth(.3);
        //           plot.setIgnoreNullValues(true);
        plot.setIgnoreZeroValues(true);
        plot.setShadowPaint(null);
        //           plot.setOutlineVisible(false);
        //TODO use title font?
        Font font = plot.getLabelFont();
        plot.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE);
        plot.setLabelFont(font.deriveFont(font.getSize2D() * .75f));
        plot.setLabelBackgroundPaint(labelColor);
        plot.setLabelShadowPaint(null);
        plot.setLabelOutlinePaint(null);
        plot.setLabelGap(0.001);
        plot.setLabelLinkMargin(0.0);
        plot.setLabelLinksVisible(true);
        //           plot.setSimpleLabels(true);
        //           plot.setCircular(true);
    }

    if (!graphBorder) {
        plot.setOutlineVisible(false);
    }

    if (title != null && !"".equals(title)) {
        TextTitle title1 = new TextTitle();
        title1.setText(title);
        title1.setFont(titleFont);
        title1.setPadding(3, 2, 5, 2);
        chart.setTitle(title1);
    } else {
        chart.setTitle((TextTitle) null);
    }
    plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1));
    //Makes a wrapper for the legend to remove the border around it
    if (legend) {
        LegendTitle legend1 = new LegendTitle(chart.getPlot());
        BlockContainer wrapper = new BlockContainer(new BorderArrangement());

        if (legendBorder) {
            wrapper.setFrame(new BlockBorder(1, 1, 1, 1));
        } else {
            wrapper.setFrame(new BlockBorder(0, 0, 0, 0));
        }

        BlockContainer items = legend1.getItemContainer();
        items.setPadding(2, 10, 5, 2);
        wrapper.add(items);
        legend1.setWrapper(wrapper);
        legend1.setPosition(RectangleEdge.BOTTOM);
        legend1.setHorizontalAlignment(HorizontalAlignment.CENTER);

        if (params.get(GraphSource.LEGEND_FONT) instanceof Font) {
            legend1.setItemFont(((Font) params.get(GraphSource.LEGEND_FONT)));
        }

        chart.addSubtitle(legend1);
        plot.setLegendLabelGenerator(new PieGraphLabelGenerator());
    }

    for (Comparable category : colors.keySet()) {
        plot.setSectionPaint(category, colors.get(category));
    }

    plot.setToolTipGenerator(new PieGraphToolTipGenerator(pieGraphData));
    plot.setURLGenerator(new PieGraphURLGenerator(pieGraphData));

    initialized = true;
}

From source file:lucee.runtime.tag.Chart.java

private void chartPie() throws PageException, IOException {
    // do dataset
    DefaultPieDataset dataset = new DefaultPieDataset();
    ChartSeriesBean csb = _series.get(0);

    ChartDataBean cdb;/*from   w  ww.j a v a  2  s .  c  o m*/

    List datas = csb.getDatas();
    if (sortxaxis)
        Collections.sort(datas);
    Iterator itt = datas.iterator();
    while (itt.hasNext()) {
        cdb = (ChartDataBean) itt.next();
        dataset.setValue(cdb.getItemAsString(), cdb.getValue());
    }

    JFreeChart chart = show3d ? ChartFactory.createPieChart3D(title, dataset, false, true, true)
            : ChartFactory.createPieChart(title, dataset, false, true, true);

    Plot p = chart.getPlot();
    PiePlot pp = (PiePlot) p;

    Font _font = getFont();
    pp.setLegendLabelGenerator(new PieSectionLegendLabelGeneratorImpl(_font, chartwidth));
    pp.setBaseSectionOutlinePaint(Color.GRAY); // border
    pp.setLegendItemShape(new Rectangle(7, 7));
    pp.setLabelFont(new Font(font, 0, 11));
    pp.setLabelLinkPaint(COLOR_333333);
    pp.setLabelLinkMargin(-0.05);
    pp.setInteriorGap(0.123);
    pp.setLabelGenerator(new PieSectionLabelGeneratorImpl(labelFormat));

    databackgroundcolor = backgroundcolor;

    setBackground(chart, p);
    setBorder(chart, p);
    setLegend(chart, p, _font);
    set3d(p);
    setFont(chart, _font);
    setTooltip(chart);
    setScale(chart);

    // Slice Type and colors
    boolean doSclice = pieslicestyle == PIE_SLICE_STYLE_SLICED;
    Color[] colors = csb.getColorlist();
    Iterator it = csb.getDatas().iterator();
    int count = 0;
    while (it.hasNext()) {
        cdb = (ChartDataBean) it.next();
        if (doSclice)
            pp.setExplodePercent(cdb.getItemAsString(), 0.13);

        if (count < colors.length) {
            pp.setSectionPaint(cdb.getItemAsString(), colors[count]);
        }
        count++;
    }

    writeOut(chart);
}