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:org.jfree.chart.demo.PopulationChartDemo.java

/**
 * Creates a new demo./* w  ww .  j av a  2 s  .c o  m*/
 *
 * @param title  the frame title.
 */
public PopulationChartDemo(final String title) {

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

    // create the chart...
    final JFreeChart chart = ChartFactory.createStackedBarChart("Population Chart Demo", "Age Group", // domain axis label
            "Population (millions)", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // 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.MouseListenerDemo2.java

public MouseListenerDemo2(String s) {
    super(s);//from   www  .  ja  va  2s .  c o  m
    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    defaultcategorydataset.addValue(1.0D, "S1", "C1");
    defaultcategorydataset.addValue(4D, "S1", "C2");
    defaultcategorydataset.addValue(3D, "S1", "C3");
    defaultcategorydataset.addValue(5D, "S1", "C4");
    defaultcategorydataset.addValue(5D, "S1", "C5");
    defaultcategorydataset.addValue(6D, "S1", "C6");
    defaultcategorydataset.addValue(7D, "S1", "C7");
    defaultcategorydataset.addValue(8D, "S1", "C8");
    defaultcategorydataset.addValue(5D, "S2", "C1");
    defaultcategorydataset.addValue(7D, "S2", "C2");
    defaultcategorydataset.addValue(6D, "S2", "C3");
    defaultcategorydataset.addValue(8D, "S2", "C4");
    defaultcategorydataset.addValue(4D, "S2", "C5");
    defaultcategorydataset.addValue(4D, "S2", "C6");
    defaultcategorydataset.addValue(3D, "S2", "C7");
    defaultcategorydataset.addValue(1.0D, "S2", "C8");
    defaultcategorydataset.addValue(4D, "S3", "C1");
    defaultcategorydataset.addValue(3D, "S3", "C2");
    defaultcategorydataset.addValue(2D, "S3", "C3");
    defaultcategorydataset.addValue(3D, "S3", "C4");
    defaultcategorydataset.addValue(6D, "S3", "C5");
    defaultcategorydataset.addValue(3D, "S3", "C6");
    defaultcategorydataset.addValue(4D, "S3", "C7");
    defaultcategorydataset.addValue(3D, "S3", "C8");
    org.jfree.chart.JFreeChart jfreechart = ChartFactory.createBarChart("Test", "Category", "Value",
            defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.addChartMouseListener(this);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}

From source file:CPU.StackedBarChartExample1.java

/**
 * Constructor//from   ww w.  j a v  a  2s.c o  m
 * @param titel
 */
StackedBarChartExample1(String titel) {
    super(titel);

    final CategoryDataset dataset = createDataset();
    final JFreeChart sbchart = createChart(dataset);
    final ChartPanel pnl = new ChartPanel(sbchart);
    pnl.setPreferredSize(new java.awt.Dimension(450, 350));
    setContentPane(pnl);

}

From source file:info.debatty.java.datasets.examples.GaussianMixtureBuilder.java

/**
 * Creates a new fast scatter plot demo.
 *
 * @param title  the frame title.//  w  w w .j a  va  2 s .  c  o m
 */
FastScatterPlot2D(final String title, final float[][] data) {

    super(title);
    final NumberAxis x_axis = new NumberAxis("X");
    x_axis.setAutoRangeIncludesZero(false);
    final NumberAxis y_axis = new NumberAxis("Y");
    y_axis.setAutoRangeIncludesZero(false);

    final FastScatterPlot plot = new FastScatterPlot(data, x_axis, y_axis);
    final JFreeChart chart = new JFreeChart(title, plot);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(1024, 768));

    setContentPane(panel);
}

From source file:test.GanttDemo1.java

public GanttDemo1(ArrayList<proceso> lista_imprimir, String algorithmType) {
    this("SO Algoritmo de Planificacion " + algorithmType);

    final IntervalCategoryDataset dataset = createDataset(lista_imprimir);
    final JFreeChart chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);/*  w  ww .  j a  va  2 s  .com*/
}

From source file:net.pickapack.chart.BarPlotFrame.java

/**
 * Create a bar plot frame./*from ww w .  j  a v a 2  s  .  c  om*/
 *
 * @param barPlot the bar plot
 * @param domainAxisLabel the domain axis label
 * @param width the width
 * @param height the height
 */
public BarPlotFrame(BarPlot<ItemT> barPlot, String domainAxisLabel, int width, int height) {
    super(barPlot.getTitle());

    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

    for (ItemT item : barPlot.getItems()) {
        if (barPlot.getPredicate().apply(item)) {
            for (SubBarPlot<ItemT> subBarPlot : barPlot.getSubBarPlots()) {
                dataSet.addValue(subBarPlot.getGetValueCallback().apply(item), subBarPlot.getTitle(),
                        subBarPlot.getGetTitleCallback().apply(item));
            }
        }
    }

    JFreeChart chart = barPlot.isStacked()
            ? ChartFactory.createStackedBarChart(barPlot.getTitle(), domainAxisLabel, barPlot.getTitleY(),
                    dataSet, PlotOrientation.VERTICAL, true, true, false)
            : ChartFactory.createBarChart(barPlot.getTitle(), domainAxisLabel, barPlot.getTitleY(), dataSet,
                    PlotOrientation.VERTICAL, true, true, false);

    CategoryPlot plot = chart.getCategoryPlot();

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    ChartPanel chartPanel = new ChartPanel(chart, false);
    chartPanel.setPreferredSize(new Dimension(width, height));
    chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setContentPane(chartPanel);
}

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

public ScatterCanvas(int width, int height, int xArea, int yArea) {

    xEffectiveArea = xArea;/*  ww  w .  j ava 2 s .  c o m*/
    yEffectiveArea = yArea;
    this.series = new XYSeries("series");

    final XYSeriesCollection dataset = new XYSeriesCollection(this.series);

    final JFreeChart chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);

    this.add(chartPanel);

    chartPanel.setPreferredSize(new java.awt.Dimension(width - padding, height - padding));

}

From source file:my.demo.PieChart.java

public PieChart(String applicationTitle, String chartTitle, PieDataset dataset, JPanel jp) {
    super(applicationTitle);

    JFreeChart chart = createChart(dataset, chartTitle);
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 350));
    // add it to our application

    setContentPane(chartPanel);//from   www  .j  a v a  2 s.  com
    jp.add(chartPanel);

}

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

/**
 * A demonstration application showing an XY series containing a null value.
 *
 * @param title  the frame title.//  w w  w.j  av  a  2 s  .c  om
 */
public WaterTemperatureDemo(final String title) {

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

    final NumberAxis rangeAxis = new NumberAxis("Temperature");
    rangeAxis.setRange(-0.55, -0.15);

    final NumberAxis domainAxis = new NumberAxis("Depth");
    domainAxis.setInverted(true);
    domainAxis.setRange(0.0, 35.0);
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final XYItemRenderer renderer = new StandardXYItemRenderer();

    final XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    final JFreeChart chart = new JFreeChart("Water Temperature By Depth", plot);

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

}

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

/**
 * Creates a new demo./*from w w  w.  ja v  a 2 s.  c om*/
 * 
 * @param title  the frame title.
 */
public HistogramDemo(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));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
}