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

/**
 * A demonstration application showing how to create a simple time series chart.
 *
 * @param title  the frame title./*from  w ww .  ja  va  2  s.co  m*/
 */
public TimeSeriesDemo8(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.YIntervalChartDemo.java

/**
 * Constructs the demo application.//w  w  w.  ja v a2s .c o m
 *
 * @param title  the frame title.
 */
public YIntervalChartDemo(final String title) {

    super(title);

    // create a dataset...
    final IntervalXYDataset dataset = new SimpleIntervalXYDataset2(100);

    // create the chart...
    final JFreeChart chart = createChart(dataset);

    // 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:business.management.system.Chart.java

/**
 * Creates new form Chart/*w ww  . ja v a2  s. co m*/
 */
public Chart(CategoryDataset dataset) throws SQLException {
    initComponents();
    JFreeChart barChart = ChartFactory.createBarChart("Stock quote", "Category", "Score", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    JPanel panel = new JPanel();
    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    panel.add(chartPanel);
    setContentPane(panel);
    /*JFreeChart pieChart = ChartFactory.createPieChart(
     "Completed projects",           
     createPieDataset()     
     );
    ChartPanel chartPanel1 = new ChartPanel( pieChart );        
    chartPanel.setPreferredSize(new java.awt.Dimension( 560 , 367 ) );       
    panel.add(chartPanel1);
    setContentPane(panel); */
}

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

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

    super(title);
    final CategoryDataset dataset = DemoDatasetFactory.createCategoryDataset();
    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.PeriodAxisDemo1.java

public PeriodAxisDemo1(String s) {
    super(s);/*from   ww  w. j  ava 2s.  c om*/
    XYDataset xydataset = createDataset();
    JFreeChart jfreechart = createChart(xydataset);
    ChartPanel chartpanel = new ChartPanel(jfreechart, false);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    chartpanel.setMouseZoomable(true, false);
    setContentPane(chartpanel);
}

From source file:scatterplot1k.JFreeScatter.java

/**
 * Creates a new fast scatter plot demo.
 *
 * @param title      the frame title./*from w  ww.jav  a 2 s  .  c om*/
 * @param sampleSize
 */
public JFreeScatter(final String title, int sampleSize) {
    super(title);
    this.sampleCount = sampleSize;

    data = new float[2][sampleSize];
    populateData();
    final NumberAxis domainAxis = new NumberAxis("X");
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis("Y");
    rangeAxis.setAutoRangeIncludesZero(false);
    final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
    final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot);
    //        chart.setLegend(null);

    // 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(800, 600));
    //      panel.setHorizontalZoom(true);
    //    panel.setVerticalZoom(true);
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(2000);

    setContentPane(panel);

}

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

/**
 * Constructs the demo application.//from   ww w  .ja  v  a  2 s .  c  o  m
 *
 * @param title  the frame title.
 */
public XYLineAndShapeRendererDemo(final String title) {

    super(title);
    XYDataset dataset = createSampleDataset();
    JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", dataset, PlotOrientation.VERTICAL, true,
            false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(1, true);
    plot.setRenderer(renderer);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    setContentPane(chartPanel);

}

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

/**
 * Creates a new demo.//  ww  w  .  j a v  a 2s. c o  m
 *
 * @param title  the frame title.
 */
public StackedBarChartDemo2(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.PieChartDemo2.java

/**
 * Default constructor.//from  ww w.  j ava 2  s . com
 *
 * @param title  the frame title.
 */
public PieChartDemo2(final String title) {

    super(title);
    final PieDataset 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.mwc.debrief.sensorfusion.views.MouseClickProblemDemo.java

/**
 * @param title/*  w  w  w. ja  v a2  s . c om*/
 *          the frame title.
 */
public MouseClickProblemDemo(final String title) {
    super(title);

    final TimeSeries s1 = new TimeSeries("Series to click");
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("[Alt]-click to switch orientation", // title
            "Time axis", // x-axis label
            "Value axis", // y-axis label
            dataset, // data
            false, // create legend?
            false, // generate tooltips?
            false // generate URLs?
    );

    final ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        public void chartMouseMoved(final ChartMouseEvent arg0) {
        }

        public void chartMouseClicked(final ChartMouseEvent arg0) {
            System.out.println("clicked on:" + arg0.getEntity());

            if (arg0.getTrigger().isAltDown()) {
                if (chart.getXYPlot().getOrientation() == PlotOrientation.HORIZONTAL)
                    chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);
                else
                    chart.getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
            }
        }
    });
    setContentPane(chartPanel);
}