Example usage for org.jfree.chart ChartPanel setPreferredSize

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

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:simcommunity.XYChart.java

public XYChart(String applicationTitle, String chartTitle, ArrayList<Float> dSet) {
    super(applicationTitle);

    // based on the dataset we create the chart
    JFreeChart pieChart = ChartFactory.createXYLineChart(chartTitle, "ERA", "OMOGENEITA'", createDataset(dSet),
            PlotOrientation.VERTICAL, true, true, false);

    // Adding chart into a chart panel
    ChartPanel chartPanel = new ChartPanel(pieChart);

    // settind default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    // add to contentPane
    setContentPane(chartPanel);//  www . j  a  va  2 s .c  o m

    this.pack();
    this.setVisible(true);
}

From source file:com.bbn.c2s2.pint.testdata.chart.ScatterPlot.java

public ScatterPlot(String chartTitle, String domainAxisTitle, String rangeAxisTitle, double[][] data) {
    super(chartTitle);
    this.data = data;
    final NumberAxis domainAxis = new NumberAxis(domainAxisTitle);
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis(rangeAxisTitle);
    rangeAxis.setAutoRangeIncludesZero(false);
    XYDataset dataSet = getDataSet(data);
    XYItemRenderer renderer = getRenderer();
    final XYPlot plot = new XYPlot(dataSet, domainAxis, rangeAxis, renderer);
    //      plot.
    //      final FastScatterPlot plot = new FastScatterPlot(data, domainAxis,
    //            rangeAxis);
    //      DrawingSupplier supplier = new ModifiedDrawingSupplier(5.0);
    //      plot.setDrawingSupplier(supplier);
    chart = new JFreeChart(chartTitle, plot);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    chart.removeLegend();/*  w  ww.  j  a  v  a  2s  .c  o m*/

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(500, 270));
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(2000);

    setContentPane(panel);
}

From source file:j2se.jfreechart.barchart.BarChart3DDemo2.java

/**
 * Creates a new demo.//  w  w  w. j  a  v  a 2s .co m
 *
 * @param title  the frame title.
 */
public BarChart3DDemo2(final String title) {

    super(title);

    // create the chart...
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(23.0, "Series 1", "London");
    dataset.addValue(14.0, "Series 1", "New York");
    dataset.addValue(14.0, "Series 1", "Istanbul");
    dataset.addValue(14.0, "Series 1", "Cairo");
    dataset.addValue(13.0, "Series 2", "London");
    dataset.addValue(19.0, "Series 2", "New York");
    dataset.addValue(19.0, "Series 2", "Istanbul");
    dataset.addValue(19.0, "Series 2", "Cairo");
    dataset.addValue(7.0, "Series 3", "London");
    dataset.addValue(9.0, "Series 3", "New York");
    dataset.addValue(9.0, "Series 3", "Istanbul");
    dataset.addValue(9.0, "Series 3", "Cairo");

    final JFreeChart chart = createChart(dataset);

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

}

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

/**
 * Creates an internal frame./* ww w.j a v  a2 s. c o  m*/
 * 
 * @return An internal frame.
 */
private JInternalFrame createFrame1() {
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(34.0, "Series 1", "Category 1");
    dataset.addValue(23.0, "Series 1", "Category 2");
    dataset.addValue(54.0, "Series 1", "Category 3");
    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart", "Category", "Series", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(200, 100));
    final JInternalFrame frame = new JInternalFrame("Frame 1", true);
    frame.getContentPane().add(chartPanel);
    return frame;

}

From source file:turtlekit.pvequalsnrt.PhysicsChecker.java

@Override
public void setupFrame(JFrame frame) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    final ChartPanel chartPanel = ChartsUtil.createChartPanel(dataset, "PV = nRT", null, null);
    chartPanel.setPreferredSize(new java.awt.Dimension(550, 250));
    rightSide = new XYSeries("Gas on the right side");
    dataset.addSeries(rightSide);//w w w.  j  av  a2s  .com
    total = new XYSeries("Total");
    dataset.addSeries(total);
    frame.setContentPane(chartPanel);
    frame.setLocation(50, 0);
    XYSeries s = dataset.getSeries("Total");
}

From source file:j2se.jfreechart.barchart.BarChartDemo4.java

/**
 * Creates a new demo instance./*  w w  w  . ja  v  a 2s .  com*/
 *
 * @param title  the frame title.
 */
public BarChartDemo4(final String title) {

    super(title);

    final CategoryDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);

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

}

From source file:org.aksw.iguana.reborn.charts.datasets.StatisticalBarChartDemo.java

/**
 * Creates a new demo.//  w  w w .  j a va  2 s.  co m
 *
 * @param title
 *            the frame title.
 * @throws DocumentException
 * @throws FileNotFoundException
 */
public StatisticalBarChartDemo(final String title) throws FileNotFoundException, DocumentException {

    super(title);
    final StatisticalCategoryDataset dataset = createDataset();

    final CategoryAxis xAxis = new CategoryAxis("Type");
    xAxis.setLowerMargin(0.01d); // percentage of space before first bar
    xAxis.setUpperMargin(0.01d); // percentage of space after last bar
    xAxis.setCategoryMargin(0.05d); // percentage of space between
    // categories
    final ValueAxis yAxis = new NumberAxis("Value");

    // define the plot
    final CategoryItemRenderer renderer = new StatisticalBarRenderer();
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    final JFreeChart chart = new JFreeChart("Statistical Bar Chart Demo", new Font("Helvetica", Font.BOLD, 14),
            plot, true);
    ChartUtilities2.saveChartAsPDF(new File("/home/raven/tmp/foo.pdf"), chart, 1000, 300);

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

}

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

/**
 * A demo.//from ww w.  j av a2s  . c o m
 * 
 * @param title  the frame title.
 */
public TimeSeriesDemo12(final String title) {

    super(title);

    final XYDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);

}

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

/**
 * Creates a new WaterFall Chart demo.//from w ww  .  jav  a 2s  . c o  m
 * 
 * @param title  the frame title.
 */
public WaterfallChartDemo2(final String title) {

    super(title);

    final CategoryDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setEnforceFileExtensions(false);
    setContentPane(chartPanel);
}

From source file:net.chaosserver.timelord.swingui.ChartingPanel.java

/**
 * Creates the charting panel./*from  ww w  .  j a va  2 s.  com*/
 *
 * @param timelordData the data object to be charted.
 */
public ChartingPanel(TimelordData timelordData) {
    this.timelordData = timelordData;

    CategoryDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset);
    ChartPanel chartPanel = new ChartPanel(chart, false);
    chartPanel.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT));
    add(chartPanel);

}