Example usage for org.jfree.chart.block BlockBorder BlockBorder

List of usage examples for org.jfree.chart.block BlockBorder BlockBorder

Introduction

In this page you can find the example usage for org.jfree.chart.block BlockBorder BlockBorder.

Prototype

public BlockBorder(double top, double left, double bottom, double right, Paint paint) 

Source Link

Document

Creates a new border with the specified line widths (in black).

Usage

From source file:com.polivoto.vistas.Charts.java

private JPanel hacerPiePanel(Pregunta pregunta, List<Opcion> opciones) {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(Color.white);
    DefaultPieDataset data = new DefaultPieDataset();
    // Fuente de Datos
    for (Opcion opc : opciones) {
        data.setValue(opc.getNombre(), opc.getCantidad());
    }/*  www .  jav a2s  .c  o m*/

    // Creando el Grafico
    JFreeChart chart = ChartFactory.createPieChart("\n" + pregunta.getTitulo(), data, true, false, //TOOLTIPS
            false);
    chart.setBackgroundPaint(Color.white);
    chart.getTitle().setFont(new Font("Roboto", 0, 28));

    // Crear el Panel del Grafico con ChartPanel
    ChartPanel chartPanel = new ChartPanel(chart);
    PiePlot plot = (PiePlot) chart.getPlot();

    Rectangle bounds = panel.getBounds();
    chartPanel.setBounds(bounds.x, bounds.y, bounds.height, bounds.height);

    panel.add(chartPanel);

    plot.setLabelGenerator(null);
    plot.setBackgroundPaint(Color.white);
    plot.setOutlineVisible(false);
    //StandardPieSectionLabelGenerator labels = new StandardPieSectionLabelGenerator("{0} = {1}");
    //plot.setLabelGenerator(labels);

    plot.setBaseSectionOutlinePaint(Color.white);
    plot.setShadowXOffset(0);
    plot.setShadowYOffset(0);

    //#7cb5ec,#f45b5b,#90ed7d,#434348,
    //#f7a35c,#8085e9,#f15c80,#e4d354,
    //#2b908f,#91e8e1
    Color[] colors = { new Color(124, 181, 236), new Color(244, 91, 91), new Color(144, 237, 125),
            new Color(67, 67, 72), new Color(247, 163, 92), new Color(128, 133, 233), new Color(241, 92, 128),
            new Color(228, 211, 84), new Color(43, 144, 143), new Color(145, 232, 225) };
    PieRenderer renderer = new PieRenderer(colors);
    renderer.setColor(plot, data);

    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);
    Font nwfont = new Font("Roboto", 0, 18);
    legend.setItemFont(nwfont);
    legend.setFrame(new BlockBorder(0, 0, 0, 90, Color.white));
    legend.setBackgroundPaint(Color.WHITE);
    legend.setItemLabelPadding(new RectangleInsets(8, 8, 8, 0));
    //RectangleInsets padding = new RectangleInsets(5, 5, 5, 5);
    //legend.setItemLabelPadding(padding);
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{1} {0}"));
    plot.setLegendItemShape(new Rectangle(25, 25));
    return panel;
}