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.LayeredBarChartDemo1.java

/**
 * Creates a new demo instance.//from   w w w . java  2 s  .  co m
 *
 * @param title  the frame title.
 */
public LayeredBarChartDemo1(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));
    setContentPane(chartPanel);

}

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

/**
 * Default constructor.// w w  w .  j  a  v  a  2 s .  co m
 *
 * @param title  the frame title.
 */
public OverlaidBarChartDemo2(final String title) {
    super(title);
    final JFreeChart chart = createChart();
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
}

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

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

    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);
    //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:agentlogfileanalyzer.gui.ComparisonFrame.java

/**
 * Creates a chart frame for comparing a selected classifier to a set of
 * other classifiers.// w ww  .j  ava 2 s  .  co  m
 * 
 * @param firstTitle
 *            the first line of the chart title
 * @param secondTitle
 *            the second line of the chart title
 * @param compDataForColumns
 *            the data the will be displayed in the chart
 */
public ComparisonFrame(String firstTitle, String secondTitle, Vector<ComparisonDataSet> compDataForColumns) {

    super("Classifier comparison");

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < compDataForColumns.size(); i++) {
        ComparisonDataSet mms = compDataForColumns.get(i);
        dataset.addValue(mms.getMax(), "max", mms.getColumnName());
        dataset.addValue(mms.getMin(), "min", mms.getColumnName());
        dataset.addValue(mms.getSelected(), "selected", mms.getColumnName());
    }

    JFreeChart jfreechart = ChartFactory.createBarChart("", // title
            "", // x-axis title
            "", // y-axis title
            dataset, PlotOrientation.VERTICAL, true, true, false);
    TextTitle subtitle1 = new TextTitle(firstTitle, new Font("SansSerif", Font.BOLD, 12));
    TextTitle subtitle2 = new TextTitle(secondTitle, new Font("SansSerif", Font.BOLD, 12));
    jfreechart.addSubtitle(0, subtitle1);
    jfreechart.addSubtitle(1, subtitle2);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer();
    categoryplot.setRenderer(minmaxcategoryrenderer);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}

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

/**
 * Creates a new demo.//from ww  w.  j av a 2 s.  com
 *
 * @param title  the frame title.
 */
public PieChart3DDemo4(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:org.jfree.chart.demo.XYBarChartDemo2.java

/**
 * Constructs the demo application./*from  ww  w  .  j  a  v a2s.  co  m*/
 *
 * @param title  the frame title.
 */
public XYBarChartDemo2(final String title) {

    super(title);

    // create a dataset...
    final TimeSeries series1 = new TimeSeries("Series 1", Day.class);
    series1.add(new Day(1, 1, 2003), 54.3);
    series1.add(new Day(2, 1, 2003), 20.3);
    series1.add(new Day(3, 1, 2003), 43.4);
    series1.add(new Day(4, 1, 2003), -12.0);

    final TimeSeries series2 = new TimeSeries("Series 2", Day.class);
    series2.add(new Day(1, 1, 2003), 8.0);
    series2.add(new Day(2, 1, 2003), 16.0);
    series2.add(new Day(3, 1, 2003), 21.0);
    series2.add(new Day(4, 1, 2003), 5.0);

    final TimeSeriesCollection data = new TimeSeriesCollection();
    data.setDomainIsPointsInTime(false);
    data.addSeries(series1);
    data.addSeries(series2);

    final JFreeChart chart = createChart(data);

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

}

From source file:br.com.una.apa.p02e01.Graph.java

/**
 * Creates a new chart./*  www  . ja v a 2  s. c om*/
 *
 * @param title
 *            the frame title.
 */
public Graph(final String title, int[] cordenadas) {

    super(title);

    final XYDataset dataset = createDataset(LenghtVector.cordenadas(cordenadas));
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
}

From source file:com.jeco.ui.view.GraficoPeso.java

public void drawGrafico(Ovino ovino) {
    if (ovino == null) {
        ovino = new Ovino();
        ovino.setCodigo("00");
    }// w ww  .  ja  va2s.  com
    DefaultCategoryDataset ds = new DefaultCategoryDataset();

    for (Pesagem pesagem : ovino.getHistoricoPesos()) {
        ds.addValue(pesagem.getPeso(), "Peso", pesagem.getData());
    }

    //cria o grafico..
    JFreeChart data = ChartFactory.createBarChart("", "Data", "Peso do Ovino " + ovino.getCodigo(), ds,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(data);
    this.chartPanel = chartPanel;
    chartPanel.setPreferredSize(new java.awt.Dimension(378, 260));
    this.setBackground(new java.awt.Color(255, 255, 255));
    this.remove(chartPanel);
    this.repaint();
    this.add(chartPanel);
    chartPanel.setBackground(new java.awt.Color(255, 255, 255));
    this.repaint();
}

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

/**
 * Creates a new demo instance.//  ww  w .j ava 2s . com
 *
 * @param title  the frame title.
 */
public BarChartDemo5(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));
    setContentPane(chartPanel);

}

From source file:netplot.TimeSeriesPlotPanel.java

public void init() {
    finalize();//from  ww  w  .  j a  v  a 2 s. c o  m
    timeSeriesList = new Vector<TimeSeries>();
    chart = createChart(null);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    add(chartPanel);
}