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:edu.coeia.charts.BarChartPanel.java

public JPanel getBarChartPanel(Map<String, Double> map2) throws IOException {
    map = map2;//from  w w  w.  j  av  a 2 s  . com

    // create the chart...
    final DefaultCategoryDataset dataset = createSampleDataset();
    final JFreeChart chart = createChart(dataset, this.indexName + " " + this.indexLocation + " Visualization");

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    map2 = null;
    return chartPanel;
}

From source file:org.talend.dataprofiler.chart.util.ChartUtils.java

/**
 * Create a AWT_SWT bridge composite for displaying the <CODE>ChartPanel</CODE>.
 * /*w  w w .j  av  a 2 s . c  o  m*/
 * @param composite
 * @param gd
 * @param chartPanel
 */
public static ChartPanel createAWTSWTComp(Composite composite, GridData gd, JFreeChart chart) {

    ChartPanel chartPanel = new ChartPanel(chart);
    Composite frameComp = new Composite(composite, SWT.EMBEDDED);
    frameComp.setLayout(new GridLayout());
    frameComp.setLayoutData(gd);
    frameComp.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));

    Frame frame = SWT_AWT.new_Frame(frameComp);
    frame.setLayout(new java.awt.GridLayout());
    frame.add(chartPanel);
    frame.validate();

    return chartPanel;
}

From source file:org.wsm.database.tools.editor.ui.GraphPane.java

public GraphPane() {
    GridBagLayout gbl = new GridBagLayout();
    this.setLayout(gbl);

    this.qesi = new QueryExecStatsInfo();
    this.qesi.addPropertyChangeListener(this);
    dcd = new DefaultCategoryDataset();
    JFreeChart chart = getChart(CHART_TYPE_BAR_3D);

    chart.setBackgroundPaint(Color.white);

    cp = new ChartPanel(chart);
    cp.setBorder(BorderFactory.createTitledBorder(null, "Graph", TitledBorder.LEADING, TitledBorder.TOP,
            UIConstants.LABEL_FONT));//from www.  j  a v  a 2s . c  o m

    cp.setMouseZoomable(true, true);
    //cp.setPreferredSize(new Dimension(700, 500));
    gbl.setConstraints(cp, SwingUtils.getGridBagConstraints(0, 0, 2, 1));

    this.add(cp);
    JPanel graphTypeSelectionPanel = new JPanel();
    viewBarGraph = new JRadioButton("View Bar Graph", true);
    viewLineGraph = new JRadioButton("View Line Graph", false);
    viewLineGraph.setEnabled(false);
    ButtonGroup bg = new ButtonGroup();
    bg.add(viewBarGraph);
    bg.add(viewLineGraph);

    GridBagLayout graphTypeGBL = new GridBagLayout();
    graphTypeSelectionPanel.setLayout(graphTypeGBL);

    graphTypeGBL.setConstraints(viewBarGraph, SwingUtils.getGridBagConstraints(0, 0));
    graphTypeGBL.setConstraints(viewLineGraph, SwingUtils.getGridBagConstraints(1, 0));
    graphTypeSelectionPanel.add(viewBarGraph);
    graphTypeSelectionPanel.add(viewLineGraph);
    viewBarGraph.addActionListener(this);
    viewLineGraph.addActionListener(this);

    graphTypeSelectionPanel.setBorder(BorderFactory.createTitledBorder(null, "Graph Type", TitledBorder.LEADING,
            TitledBorder.TOP, UIConstants.LABEL_FONT));

    gbl.setConstraints(graphTypeSelectionPanel, SwingUtils.getGridBagConstraints(0, 1, 2, 1));

    this.add(graphTypeSelectionPanel);
    //this.setBounds(50, 100, 100, 200);
    this.setBackground(Color.WHITE);
}

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

/**
 * Creates a new demo.//from w  w w  .  ja v a  2 s  .  c o m
 *
 * @param title  the frame title.
 */
public PieChart3DDemo3(final String title) {

    super(title);
    final PieDataset dataset = createSampleDataset();
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:eu.choreos.vv.chart.YIntervalChart.java

public YIntervalChart(String applicationTitle, String chartTitle, List<PlotData> reports, String xLabel,
        String yLabel) {//from   www.  java 2 s  .  c  o  m
    super(applicationTitle);

    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();

    for (PlotData report : reports) {
        createDataset(dataset, (StatisticalData) report);
    }
    // based on the dataset we create the chart
    JFreeChart chart = createChart(dataset, chartTitle, xLabel, yLabel);
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);

}

From source file:ec.ui.view.ARPView.java

protected ARPView() {
    this.chartPanel = new ChartPanel(createARPChart());
    Charts.avoidScaling(chartPanel);//  ww  w.jav  a2  s  .c om
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);

    setTransferHandler(new TsTransferHandler());
}

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

/**
 * Creates a new demo.//from  w  ww  . jav a2 s.co  m
 * 
 * @param title  the frame title.
 */
public HistogramDemo2(final String title) {
    super(title);
    final IntervalXYDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
}

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

/**
 * A demonstration application showing a bubble chart.
 *
 * @param title  the frame title./*  w w w  .  j  a va2s .  c o m*/
 */
public BubblePlotDemo(final String title) {

    super(title);
    final XYZDataset data = new SampleXYZDataset();
    final JFreeChart chart = createChart(data);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    //   chartPanel.setVerticalZoom(true);
    // chartPanel.setHorizontalZoom(true);
    setContentPane(chartPanel);

}

From source file:br.com.ant.system.util.ChartUtil.java

public void createTempoTotalExecucao(Set<EstatisticaColetor> estatisticas) {

    // Create a simple XY chart
    XYSeries series = new XYSeries("Formiga");

    JFrame frame = new JFrame();

    for (EstatisticaColetor e : estatisticas) {
        series.add(e.getId(), e.getTempoExecucao());
    }/* ww  w  .  java 2  s  .co  m*/

    // Add the series to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart("Tempo total de Execuo", "Execuo", "Tempo (ms)",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    frame.getContentPane().add(new ChartPanel(chart));

    frame.setPreferredSize(new Dimension(600, 600));
    frame.setMinimumSize(new Dimension(600, 600));
    frame.setMaximumSize(new Dimension(600, 600));
    frame.setVisible(true);

    try {
        ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 500, 300);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }
}

From source file:electroStaticUI.DrawElectricFieldLines.java

public DrawElectricFieldLines(CustomMapper cMapper) {
    mapper = cMapper;//from w  w  w.  ja v a 2  s .com
    sumTotalVector();
    createDataset();
    renderer = new VectorRenderer();
    graph = new XYPlot(dataSet, new NumberAxis("Axis X"), new NumberAxis("Axis Y"), renderer);
    eFieldChart = new JFreeChart(graph);
    eFieldChart.setTitle("Electric Field Vectors");
    graphChart = new ChartPanel(eFieldChart);
    graphChart.setVisible(true);
}