Example usage for org.jfree.chart ChartPanel ChartPanel

List of usage examples for org.jfree.chart ChartPanel ChartPanel

Introduction

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

Prototype

public ChartPanel(JFreeChart chart) 

Source Link

Document

Constructs a panel that displays the specified chart.

Usage

From source file:net.imglib2.script.analysis.ChartUtils.java

public static final Img<ARGBType> asImage(final JFreeChart chart, int width, int height) {
    final ChartPanel panel = new ChartPanel(chart);
    final Dimension d = panel.getPreferredSize();
    if (-1 == width && -1 == height) {
        width = d.width;// w w w.  ja  v a2 s.c  o  m
        height = d.height;
        panel.setSize(d);
    } else {
        panel.setSize(width, height);
    }
    layoutComponent(panel);
    final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D g = bi.createGraphics();
    if (!panel.isOpaque()) {
        g.setColor(panel.getBackground());
        g.fillRect(0, 0, width, height);
    }
    panel.paint(g);
    final int[] pixels = new int[width * height];
    final PixelGrabber pg = new PixelGrabber(bi, 0, 0, width, height, pixels, 0, width);
    try {
        pg.grabPixels();
    } catch (final InterruptedException e) {
    }
    g.dispose();

    final ArrayImg<ARGBType, IntArray> a = new ArrayImg<ARGBType, IntArray>(new IntArray(pixels),
            new long[] { width, height }, 1);

    // create a Type that is linked to the container
    final ARGBType linkedType = new ARGBType(a);
    // pass it to the DirectAccessContainer
    a.setLinkedType(linkedType);

    return a;
}

From source file:GraphingProject.TheJApplet.java

public TheJApplet() {

    super();//  ww w  .  j av  a 2  s. com
    final CategoryDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    setContentPane(chartPanel);

}

From source file:cv.mikusher.freechart.TimeSeries_AWT.java

public TimeSeries_AWT(final String title) {
    super(title);
    setDefaultCloseOperation(ApplicationFrame.EXIT_ON_CLOSE);
    final XYDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 370));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);//from ww w. j  a v a  2  s .c om
}

From source file:edu.coeia.charts.LineChartPanel.java

public static JPanel getLineChartPanel(String userName, String otherName, ArrayList<Message> data,
        ArrayList<Message> data2) throws ParseException {

    CategoryDataset categoryDataset = createCategoryDataset(userName, otherName, data, data2);

    JFreeChart chart = createChart(categoryDataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setSize(400, 400);//  www  .j  a  v  a2  s.  c  o  m

    return chartPanel;
}

From source file:com.js.quickestquail.ui.stats.YearStat.java

public YearStat() {
    setLayout(new BorderLayout());
    add(new ChartPanel(generateChart()), BorderLayout.CENTER);
}

From source file:charts.ErroresPorMilChart.java

public ChartPanel getChartPanel(String chartTitle, JTable table) {

    DefaultCategoryDataset dataset = createDataset(table);
    JFreeChart chart = createChart(dataset, chartTitle);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(450, 440));
    chartPanel.setMouseWheelEnabled(true);
    return chartPanel;

}

From source file:com.js.quickestquail.ui.stats.RatingStat.java

public RatingStat() {
    setLayout(new BorderLayout());
    add(new ChartPanel(generateChart()), BorderLayout.CENTER);
}

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

public CategoryStepChartDemo1(String s) {
    super(s);/*from   w ww.  jav  a2s  . c  om*/
    CategoryDataset categorydataset = createDataset();
    JFreeChart jfreechart = createChart(categorydataset);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    chartpanel.setEnforceFileExtensions(false);
    setContentPane(chartpanel);
}

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

public StackedBarChart3DDemo1(String s) {
    super(s);//from   www.  java2  s  . co  m
    CategoryDataset categorydataset = createDataset();
    JFreeChart jfreechart = createChart(categorydataset);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}

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

public StackedBarChart3DDemo3(String s) {
    super(s);/*from  w  w w . j a v a 2s .  c om*/
    CategoryDataset categorydataset = createDataset();
    JFreeChart jfreechart = createChart(categorydataset);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}