Example usage for org.jfree.chart JFreeChart getPlot

List of usage examples for org.jfree.chart JFreeChart getPlot

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getPlot.

Prototype

public Plot getPlot() 

Source Link

Document

Returns the plot for the chart.

Usage

From source file:org.gephi.statistics.plugin.ChartUtils.java

public static void decorateChart(JFreeChart chart) {
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(0, 0, 2, 2));
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setDomainGridlinePaint(java.awt.Color.GRAY);
    plot.setRangeGridlinePaint(java.awt.Color.GRAY);
    plot.setRenderer(renderer);/*from w  w w. j  ava  2 s .co  m*/
}

From source file:br.unesp.rc.desafio.utils.Utils.java

public static void createPie(DefaultPieDataset pieDataset) {

    JFreeChart chart = ChartFactory.createPieChart("Grafico Torta", pieDataset, true, true, true);
    PiePlot p = (PiePlot) chart.getPlot();
    ChartFrame frame = new ChartFrame("Grafico Torta", chart);

    frame.setVisible(true);/*from  w w  w. ja va2s  . co  m*/
    frame.setSize(450, 500);
    ManagerGUI.centralizar(frame);

}

From source file:org.gaixie.micrite.jfreechart.style.PieStyle.java

/**
 * ?1 ,? Familiar(30%) /*from  w ww.j a va2s.com*/
 * @param chart
 */
public static void styleOne(JFreeChart chart) {
    PiePlot plot = (PiePlot) chart.getPlot();
    PieDataset pd = plot.getDataset();
    PieStyle.setBackground(chart);
    if (pd != null) {
        //?
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));
        //??
        for (int i = 0; i < pd.getItemCount(); i++) {
            int color = i % colors.length;
            plot.setSectionPaint(pd.getKey(i), colors[color]);
        }
    } else {
        plot.setNoDataMessage("NO DATA");
    }

}

From source file:org.gaixie.micrite.jfreechart.style.BarStyle.java

/**
 * ???// w w w.j  av  a  2  s . c o  m
 * @param chart JFreeChart
 */
public static void styleOne(JFreeChart chart) {
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    CategoryDataset dca = categoryplot.getDataset();
    //?
    chart.setBackgroundPaint(null);
    if (dca != null) {
        BarRenderer categoryitemrenderer = (BarRenderer) categoryplot.getRenderer();
        // ?
        categoryitemrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
        //            categoryitemrenderer.setBaseItemLabelFont(
        //                    new Font("", Font.PLAIN, 15));
        categoryitemrenderer.setBaseItemLabelsVisible(true);
        //tooltip
        categoryplot.getRenderer()
                .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{0}={2}", new DecimalFormat()));
        //?
        for (int i = 0; i < dca.getRowCount(); i++) {
            int colorIdx = i % colors.length;
            categoryitemrenderer.setSeriesPaint(i, colors[colorIdx]);
        }
    } else {
        //?
        categoryplot.setNoDataMessage("NO DATA");
    }
}

From source file:org.gaixie.micrite.jfreechart.style.PieStyle.java

/**
 * ?2???block/* w ww .jav  a2 s .c om*/
 * <p>
 * ? LegendTitle
 * @param chart JFreeChart
 */
public static void styleTwo(JFreeChart chart) {
    PiePlot plot = (PiePlot) chart.getPlot();

    PieStyle.setBackground(chart);

    // LegendTitleblockblock
    BlockContainer block = new BlockContainer(new BorderArrangement());
    block.setBorder(new BlockBorder(1.0D, 1.0D, 1.0D, 1.0D));

    // LegendTitleblock
    LegendTitle legend = new LegendTitle(plot);
    BlockContainer legendBlock = legend.getItemContainer();

    // legendBlockblock?
    block.add(legendBlock);
    legend.setWrapper(block);
    legend.setPosition(RectangleEdge.BOTTOM);

    chart.addSubtitle(legend);
    //label
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})"));

}

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

public static JPanel createDemoPanel() {
    JFreeChart jfreechart = createChart("Axis Offsets: 0", createDataset());
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setMinimumDrawWidth(0);//from  w w  w  . j  a v a2 s  .co  m
    chartpanel.setMinimumDrawHeight(0);
    JFreeChart jfreechart1 = createChart("Axis Offsets: 5", createDataset());
    ChartPanel chartpanel1 = new ChartPanel(jfreechart1);
    chartpanel1.setMinimumDrawWidth(0);
    chartpanel1.setMinimumDrawHeight(0);
    CategoryPlot categoryplot1 = (CategoryPlot) jfreechart1.getPlot();
    categoryplot1.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    DemoPanel demopanel = new DemoPanel(new GridLayout(2, 1));
    demopanel.add(chartpanel);
    demopanel.add(chartpanel1);
    demopanel.addChart(jfreechart);
    demopanel.addChart(jfreechart1);
    return demopanel;
}

From source file:testes.Histograma.java

private static JFreeChart crearChart(IntervalXYDataset dataset) {
    JFreeChart chart = ChartFactory.createHistogram("Histograma", null, null, dataset, PlotOrientation.VERTICAL,
            true, true, false);/*from   w ww .  j  a v  a 2 s  . c om*/
    XYPlot plot = (XYPlot) chart.getPlot();
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);
    return chart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createScatterPlot("Grid Band Demo 1", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setNoDataMessage("NO DATA");
    xyplot.setRangeZeroBaselineVisible(true);
    xyplot.setDomainTickBandPaint(new Color(0, 100, 0, 50));
    xyplot.setRangeTickBandPaint(new Color(0, 100, 0, 50));
    return jfreechart;
}

From source file:spminiproject.lab2.chart.Histogram2.java

private static JFreeChart createChart(IntervalXYDataset dataset, String x, String y) {
    JFreeChart chart = ChartFactory.createHistogram("Histogram", x, y, dataset, PlotOrientation.VERTICAL, true,
            true, false);//from   w  w  w  .  ja v a 2s  .c  o  m
    XYPlot plot = (XYPlot) chart.getPlot();
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    try {
        ChartUtilities.saveChartAsJPEG(new File("C:\\Users\\User\\Desktop\\histogram.jpg"), chart, 500, 475);
    } catch (IOException e) {
        System.out.println("Failed to open file");
    }
    return chart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Function2DDemo1 ", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.getDomainAxis().setLowerMargin(0.0D);
    xyplot.getDomainAxis().setUpperMargin(0.0D);
    return jfreechart;
}