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

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

Introduction

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

Prototype

public void setInteriorGap(double percent) 

Source Link

Document

Sets the interior gap and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:com.twocents.test.ui.chart.MultipieChart.java

/**
 * Creates a sample chart with the given dataset.
 * /*  w  w  w  .  j av a  2 s  .c  o m*/
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {
    final JFreeChart chart = ChartFactory.createMultiplePieChart("Multiple Pie Chart", // chart title
            dataset, // dataset
            TableOrder.BY_ROW, true, // include legend
            true, false);
    final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    final JFreeChart subchart = plot.getPieChart();
    final PiePlot p = (PiePlot) subchart.getPlot();
    p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}"));
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    p.setInteriorGap(0.30);

    return chart;
}

From source file:org.jfree.chart.demo.ImageMapDemo6.java

/**
 * Creates a sample chart with the given dataset.
 * /* w  w w  .  jav a 2  s  . c o m*/
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {
    final JFreeChart chart = ChartFactory.createMultiplePieChart("Multiple Pie Chart", // chart title
            dataset, // dataset
            TableOrder.BY_ROW, true, // include legend
            true, true);
    final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    final JFreeChart subchart = plot.getPieChart();
    final PiePlot p = (PiePlot) subchart.getPlot();
    p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}"));
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    p.setInteriorGap(0.30);

    return chart;
}

From source file:org.jfree.chart.demo.MultiplePieChartDemo4.java

/**
 * Creates a sample chart for the given dataset.
 * //from  w w  w.j  a v a 2 s . com
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {
    final JFreeChart chart = ChartFactory.createMultiplePieChart3D("Multiple Pie Chart Demo 4", dataset,
            TableOrder.BY_COLUMN, false, true, false);
    chart.setBackgroundPaint(new Color(216, 255, 216));
    final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    final JFreeChart subchart = plot.getPieChart();
    //        final StandardLegend legend = new StandardLegend();
    //      legend.setItemFont(new Font("SansSerif", Font.PLAIN, 8));
    //    legend.setAnchor(Legend.SOUTH);
    //  subchart.setLegend(legend);
    plot.setLimit(0.10);
    final PiePlot p = (PiePlot) subchart.getPlot();
    p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}"));
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    p.setInteriorGap(0.30);

    return chart;
}

From source file:jmemorize.gui.swing.panels.CardCounterPanel.java

private void setupPiePlot(PiePlot plot) {
    plot.setMaximumLabelWidth(0.0);/*www  .ja v a2  s .  c om*/
    plot.setLabelGap(0.0);
    plot.setInteriorGap(0.0);
    //piePlot.setLabelLinkMargin(0.0);
    plot.setCircular(true);
    plot.setLabelGenerator(new PieSectionLabelGenerator() {
        public String generateSectionLabel(PieDataset arg0, Comparable arg1) {
            return null;
        }

        public AttributedString generateAttributedSectionLabel(PieDataset arg0, Comparable arg1) {
            return null;
        }
    });
    //piePlot.setForegroundAlpha(0.5f);

    plot.setSectionPaint(Localization.get(LC.STATUS_LEARNED), ColorConstants.LEARNED_CARDS);
    plot.setSectionPaint(Localization.get(LC.STATUS_PARTIAL), ColorConstants.PARTIAL_LEARNED_CARDS);
    plot.setSectionPaint(Localization.get(LC.STATUS_UNLEARNED), ColorConstants.UNLEARNED_CARDS);
}

From source file:ch.zhaw.init.walj.projectmanagement.util.chart.PieChart.java

/**
 * creates the pie chart//from  w  w w  .  j a va 2 s  .  co m
 * @throws NumberFormatException
 * @throws IOException
 */
public void createChart() throws NumberFormatException, IOException {

    // create dataset with used and remaining budget
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("spent", con.getUsedBudget(project));
    dataset.setValue("remaining", con.getRemainingBudget(project));

    // create chart
    JFreeChart chart = ChartFactory.createPieChart("", dataset, false, false, false);

    // set color and style
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionPaint("remaining", new Color(0, 101, 166));
    plot.setSectionPaint("spent", new Color(0, 62, 102));
    plot.setLabelGenerator(null);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setShadowXOffset(0);
    plot.setShadowYOffset(0);
    plot.setOutlineVisible(false);
    plot.setInteriorGap(0);

    // set size and save it as JPEG
    int width = 350; /* Width of the image */
    int height = 350; /* Height of the image */
    File pieChart = new File(path + "/Charts/BudgetProject" + project.getID() + ".jpg");
    ChartUtilities.saveChartAsJPEG(pieChart, chart, width, height);
}

From source file:org.jfree.chart.demo.MultiplePieChartDemo2.java

/**
 * Creates a sample chart with the given dataset.
 * /*w ww. j  av  a2  s.com*/
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {
    final JFreeChart chart = ChartFactory.createMultiplePieChart("Multiple Pie Chart", // chart title
            dataset, // dataset
            TableOrder.BY_COLUMN, true, // include legend
            true, false);
    final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setOutlineStroke(new BasicStroke(1.0f));
    final JFreeChart subchart = plot.getPieChart();
    final PiePlot p = (PiePlot) subchart.getPlot();
    p.setBackgroundPaint(null);
    p.setOutlineStroke(null);
    p.setLabelGenerator(new StandardPieItemLabelGenerator("{0} ({2})", NumberFormat.getNumberInstance(),
            NumberFormat.getPercentInstance()));
    p.setMaximumLabelWidth(0.35);
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 9));
    p.setInteriorGap(0.30);
    return chart;
}

From source file:org.gephi.desktop.context.ContextPieChart.java

public ContextPieChart() {
    data = new DefaultPieDataset();
    final JFreeChart chart = ChartFactory.createPieChart("Employee Survey", data, false, false, false);
    chart.setTitle(new TextTitle());
    chart.setBackgroundPaint(null);/*from   w  w w . j a  v a 2s.  co m*/
    chart.setPadding(new RectangleInsets(0, 0, 0, 0));
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setShadowPaint(null);
    plot.setSimpleLabels(true);
    plot.setLabelBackgroundPaint(null);
    plot.setLabelOutlineStroke(null);
    plot.setLabelShadowPaint(null);
    plot.setOutlineVisible(false);
    plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10));
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelGap(0.5);
    plot.setCircular(true);
    plot.setInteriorGap(0);
    plot.setBackgroundPaint(null);
    plot.setBackgroundAlpha(1f);
    plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.visible"), new Color(0x222222));
    plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.notVisible"), new Color(0xDDDDDD));
    chartPanel = new ChartPanel(chart, 100, 100, 10, 10, 300, 300, true, false, false, false, false, false);
    ((FlowLayout) chartPanel.getLayout()).setHgap(0);
    ((FlowLayout) chartPanel.getLayout()).setVgap(0);
    chartPanel.setOpaque(false);
    chartPanel.setPopupMenu(null);
}

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

@SuppressWarnings("unchecked")
@Override//  w w w  . j a  v  a 2  s. c  om
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: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);//  w  ww.  j av  a 2  s . co  m
    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.gmu.cs.sim.util.media.chart.PieChartGenerator.java

protected void buildChart() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    chart = ChartFactory.createMultiplePieChart("Untitled Chart", dataset, org.jfree.util.TableOrder.BY_COLUMN,
            false, true, false);//w ww .  ja  v a 2s.  co m
    chart.setAntiAlias(true);
    //chartPanel = new ScrollableChartPanel(chart, true);            
    chartPanel = buildChartPanel(chart);
    //chartHolder.getViewport().setView(chartPanel);
    setChartPanel(chartPanel);

    JFreeChart baseChart = (JFreeChart) ((MultiplePiePlot) (chart.getPlot())).getPieChart();
    PiePlot base = (PiePlot) (baseChart.getPlot());
    base.setIgnoreZeroValues(true);
    base.setLabelOutlinePaint(java.awt.Color.WHITE);
    base.setLabelShadowPaint(java.awt.Color.WHITE);
    base.setMaximumLabelWidth(0.25); // allow bigger labels by a bit (this will make the chart smaller)
    base.setInteriorGap(0.000); // allow stretch to compensate for the bigger label width
    base.setLabelBackgroundPaint(java.awt.Color.WHITE);
    base.setOutlinePaint(null);
    base.setBackgroundPaint(null);
    base.setShadowPaint(null);
    base.setSimpleLabels(false); // I think they're false anyway

    // change the look of the series title to be smaller
    StandardChartTheme theme = new StandardChartTheme("Hi");
    TextTitle title = new TextTitle("Whatever", theme.getLargeFont());
    title.setPaint(theme.getAxisLabelPaint());
    title.setPosition(RectangleEdge.BOTTOM);
    baseChart.setTitle(title);

    // this must come last because the chart must exist for us to set its dataset
    setSeriesDataset(dataset);
}