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

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

Introduction

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

Prototype

public void setOutlinePaint(Paint paint) 

Source Link

Document

Sets the paint used to draw the outline of the plot area and sends a PlotChangeEvent to all registered listeners.

Usage

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

private static JFreeChart createPieChart() {
    DefaultPieDataset defaultpiedataset = new DefaultPieDataset();
    defaultpiedataset.setValue("Engineering", 43.200000000000003D);
    defaultpiedataset.setValue("Research", 13.199999999999999D);
    defaultpiedataset.setValue("Advertising", 20.899999999999999D);
    PiePlot pieplot = new PiePlot(defaultpiedataset);
    pieplot.setBackgroundPaint(null);//from  w w  w  . ja v  a 2s  .c o  m
    pieplot.setOutlinePaint(null);
    pieplot.setBaseSectionOutlinePaint(Color.white);
    pieplot.setBaseSectionOutlineStroke(new BasicStroke(2.0F));
    pieplot.setLabelFont(new Font("Dialog", 0, 18));
    pieplot.setMaximumLabelWidth(0.25D);
    JFreeChart jfreechart = new JFreeChart(pieplot);
    jfreechart.setBackgroundPaint(null);
    jfreechart.removeLegend();
    jfreechart.setPadding(RectangleInsets.ZERO_INSETS);
    return jfreechart;
}

From source file:com.thalesgroup.hudson.plugins.klocwork.graph.KloPieChart.java

protected JFreeChart createGraph() {

    JFreeChart chart = ChartFactory.createPieChart(null, dataset, true, true, false);
    chart.setBackgroundPaint(Color.white);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDataset(dataset);/*from   w w w.ja va 2  s.  c o m*/
    plot.setOutlinePaint(null);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No Klocwork data found.");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}"));

    // Set colours
    //plot.setOutlinePaint("New", new Color(200, 0, 0));
    int i = 0;
    if (kloConfig.getBuildGraph().isNeww() && kloReport.getNeww() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(200, 0, 0));
        i++;
    }
    if (kloConfig.getBuildGraph().isExisting() && kloReport.getExisting() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 0, 200));
        i++;
    }
    if (kloConfig.getBuildGraph().isFixed() && kloReport.getFixed() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 200, 0));
    }

    //plot.setOutlinePaint("Existing", new Color(0, 0, 200));
    //plot.setOutlinePaint("Fixed", new Color(0, 200, 0));

    return chart;

}

From source file:net.footballpredictions.footballstats.swing.ResultsPieChart.java

/**
 * Updates the relative sizes of the pie chart segments.
 *///from   www  .  j a  v a  2  s  .c o m
public void updateGraph(int won, int drawn, int lost) {
    DefaultKeyedValues values = new DefaultKeyedValues();
    values.addValue(messageResources.getString("headToHead.won"), won);
    values.addValue(messageResources.getString("headToHead.drawn"), drawn);
    values.addValue(messageResources.getString("headToHead.lost"), lost);
    PieDataset dataSet = new DefaultPieDataset(values);

    JFreeChart chart = ChartFactory.createPieChart(title, dataSet, false, // Legend.
            true, // Tooltips.
            false); // URLs.
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setInteriorGap(0);
    plot.setSectionPaint(0, Colours.WIN);
    plot.setSectionPaint(1, Colours.DRAW);
    plot.setSectionPaint(2, Colours.DEFEAT);
    plot.setBackgroundPaint(null);
    plot.setOutlinePaint(null);
    plot.setLabelGenerator(null);
    plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} {1} ({2})"));
    setChart(chart);
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java

/**
 * @param list//  www  . j a v a2  s .  c  o  m
 * @param title
 * @param xAxisTitle
 * @param yAxisTitle
 * @param isVertical
 * @param width
 * @param height
 */
public JFreeChart createPieChart(final List<Object> list, final String title, final int width, final int height,
        final boolean do3D) {
    DefaultPieDataset dataset = new DefaultPieDataset();

    for (int i = 0; i < list.size(); i++) {
        Object descObj = list.get(i++);
        Object valObj = list.get(i);
        dataset.setValue(getString(descObj), getInt(valObj));
    }

    String adjTitle = title;
    JFreeChart chart = do3D ? ChartFactory.createPieChart3D(adjTitle, dataset, false, false, false)
            : ChartFactory.createPieChart(adjTitle, dataset, false, false, false);
    chart.setBackgroundPaint(new Color(0, 0, 0, 0)); // transparent black

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11)); //$NON-NLS-1$
    plot.setBackgroundPaint(new Color(0, 0, 0, 0)); // transparent black
    plot.setOutlinePaint(null);

    setColors(plot, dataset);

    return chart;
}

From source file:com.manydesigns.portofino.chart.Chart1DGenerator.java

public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) {
    DefaultPieDataset dataset = new DefaultPieDataset();
    java.util.List<Object[]> result;
    String query = chartDefinition.getQuery();
    logger.info(query);//from  w w w .  j a  v  a2  s .  c o m
    Session session = persistence.getSession(chartDefinition.getDatabase());
    result = QueryUtils.runSql(session, query);
    for (Object[] current : result) {
        ComparableWrapper key = new ComparableWrapper((Comparable) current[0]);
        dataset.setValue(key, (Number) current[1]);
        if (current.length > 2) {
            key.setLabel(current[2].toString());
        }
    }

    JFreeChart chart = createChart(chartDefinition, dataset);

    chart.setAntiAlias(isAntiAlias());

    // impostiamo il bordo invisibile
    // eventualmente e' il css a fornirne uno
    // eventualmente e' il css a fornirne uno
    chart.setBorderVisible(isBorderVisible());

    // impostiamo il titolo
    TextTitle title = chart.getTitle();
    title.setFont(titleFont);
    title.setMargin(10.0, 0.0, 0.0, 0.0);

    // ottieni il Plot
    PiePlot plot = (PiePlot) chart.getPlot();

    String urlExpression = chartDefinition.getUrlExpression();
    if (!StringUtils.isBlank(urlExpression)) {
        PieURLGenerator urlGenerator = new ChartPieUrlGenerator(urlExpression);
        plot.setURLGenerator(urlGenerator);
    } else {
        plot.setURLGenerator(null);
    }

    // il plot ha sfondo e bordo trasparente
    // (quindi si vede il colore del chart)
    plot.setBackgroundPaint(transparentColor);
    plot.setOutlinePaint(transparentColor);

    // Modifico il toolTip
    // hongliangpan add
    // :?{0}  {1}  {2} ? ,???
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})",
            NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
    // {0}={1}({2})
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));
    // ?(0.0-1.0)
    // plot.setForegroundAlpha(1.0f);
    // imposta la distanza delle etichette dal plot
    plot.setLabelGap(0.03);
    // plot.setLabelGenerator(new MyPieSectionLabelGenerator());

    // imposta il messaggio se non ci sono dati
    plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available"));

    plot.setCircular(true);

    plot.setBaseSectionOutlinePaint(Color.BLACK);

    DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier());
    plot.setDrawingSupplier(supplier);
    // ?
    plot.setForegroundAlpha(1.0f);
    // impostiamo il titolo della legenda
    String legendString = chartDefinition.getLegend();
    Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM,
            HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0));
    subtitle.setMargin(0, 0, 5, 0);
    chart.addSubtitle(subtitle);

    // impostiamo la legenda
    LegendTitle legend = chart.getLegend();
    legend.setBorder(0, 0, 0, 0);
    legend.setItemFont(legendItemFont);
    int legendMargin = 10;
    legend.setMargin(0.0, legendMargin, legendMargin, legendMargin);
    legend.setBackgroundPaint(transparentColor);

    // impostiamo un gradiente orizzontale
    Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, getHeight(), Color.WHITE);
    chart.setBackgroundPaint(chartBgPaint);
    return chart;
}

From source file:gavisualizer.PieChart.java

@Override
public void generate() {
    // Creates Pie Chart from variables
    JFreeChart chart = ChartFactory.createPieChart(_title, // chart title
            _dataset, // data
            false, // include legend
            false, false);//from w  w w. j  a  v  a  2 s . c om

    // Set Plot canvas color and direction
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setBackgroundPaint(Color.WHITE);

    /*
    *  Use these to edit the decimal percentage: 
    *       NumberFormat nf = NumberFormat.getPercentInstance();
    *       nf.setRoundingMode(RoundingMode.);
    *       nf.setMinimumFractionDigits(2);
    *       plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}", NumberFormat.getNumberInstance(), nf));
    *  
    *  And remove line 63
    */

    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}"));
    plot.setOutlinePaint(Color.white);

    _chart = chart;
}

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);/*from   w  w w  .  ja  v a2s.  c o  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);
}

From source file:kolacer.Kolacer.java

private void upravPlot(PiePlot plot) {
    plot.setSectionOutlinesVisible(false);
    plot.setOutlinePaint(null);

    if (jRad_barvy_manual.isSelected()) {
        for (Udaj u : udaje) {
            plot.setSectionPaint(u.hodnota, u.barva);
        }//from   w  ww  .  jav a 2  s .c  o  m
    } else if (jRad_barvy_auto.isSelected()) {
        Barvy.nastavBarvy(plot);
    } else if (jRad_barvy_gradient.isSelected()) {
        Barvy.nastavBarvy(plot, barvaGradA, barvaGradB);
    }

    if (!jCHB_popisky.isSelected())
        plot.setLabelGenerator(null);
    else {
        plot.setLabelBackgroundPaint(new Color(0, 0, 0, 0));
        plot.setLabelOutlinePaint(null);
        plot.setLabelShadowPaint(null);
        plot.setSimpleLabels(true);
        plot.setInsets(new RectangleInsets(5, 5, 5, 400));
        plot.setLabelFont(popisekGrafuFont);
        //plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1} hl. ({2})"));
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}"));
    }
    plot.setBackgroundPaint(null);
    plot.setShadowPaint(null);
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{1} ({2}) - {0}"));
}

From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java

/**
 * Creates a Pie Chart based on map.//w ww  .  j a  v a 2s  .  c o  m
 *
 * @return the Pie Chart generated.
 */
public JFreeChart getPieChart(Map<String, Double> pieValues) {
    DefaultPieDataset dataset = new DefaultPieDataset();

    for (String key : pieValues.keySet()) {
        dataset.setValue(key, pieValues.get(key));
    }

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

    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(false);
    chart.setBorderPaint(null);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(true);
    plot.setLabelGap(0.02);
    plot.setOutlinePaint(null);
    plot.setLabelLinksVisible(false);

    plot.setLabelGenerator(null);

    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));

    plot.setStartAngle(270);
    plot.setDirection(Rotation.ANTICLOCKWISE);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.33);

    return chart;
}

From source file:net.sf.eclipsecs.ui.stats.views.GraphStatsView.java

/**
 * Cre le graphe JFreeChart./*from  w  w w.ja va  2s  . c  o  m*/
 * 
 * @param piedataset
 *            : la source de donnes  afficher
 * @return le diagramme
 */
private JFreeChart createChart(GraphPieDataset piedataset) {
    JFreeChart jfreechart = ChartFactory.createPieChart3D(null, piedataset, false, true, false);
    jfreechart.setAntiAlias(true);
    jfreechart.setTextAntiAlias(true);

    PiePlot pieplot3d = (PiePlot) jfreechart.getPlot();
    pieplot3d.setInsets(new RectangleInsets(0, 0, 0, 0));
    final double angle = 290D;
    pieplot3d.setStartAngle(angle);
    pieplot3d.setDirection(Rotation.CLOCKWISE);
    final float foreground = 0.5F;
    pieplot3d.setForegroundAlpha(foreground);
    pieplot3d.setNoDataMessage(Messages.GraphStatsView_noDataToDisplay);
    pieplot3d.setCircular(true);

    pieplot3d.setOutlinePaint(null);
    pieplot3d.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    pieplot3d.setLabelGap(0.02);
    pieplot3d.setLabelOutlinePaint(null);
    pieplot3d.setLabelShadowPaint(null);
    pieplot3d.setLabelBackgroundPaint(Color.WHITE);
    pieplot3d.setBackgroundPaint(Color.WHITE);

    pieplot3d.setInteriorGap(0.02);
    pieplot3d.setMaximumLabelWidth(0.20);

    return jfreechart;
}