List of usage examples for org.jfree.chart ChartPanel setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:org.jfree.chart.demo.LineChartDemo5.java
/** * Creates a new demo./* w ww .ja v a2 s . co m*/ * * @param title the frame title. */ public LineChartDemo5(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:BarChartDemo.java
/** * Creates a new demo instance.// w ww . j av a 2s . c o m * * @param title the frame title. */ public BarChartDemo(final String title) { super(title); // Populate data for plotting final CategoryDataset dataset = createDataset(); final JFreeChart chart1 = createChart(dataset); // Create a Panel for display purposes final ChartPanel chartPanel = new ChartPanel(chart1); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); // Also dump the jpeg version of the chart to a file try { File f = new File("barchart.jpeg"); ChartUtilities.saveChartAsJPEG(f, chart1, 500, 270); } catch (Exception e) { // If any errors occur discard; it's just a placeholder anyways e.printStackTrace(); } }
From source file:Client.Gui.TeamBarChart.java
public TeamBarChart(final String title, statistic statisticQ) { super(title); this.statisticQ = statisticQ; // this.thing=thing; final CategoryDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(700, 400)); setContentPane(chartPanel);//from w w w .j a v a 2s. c o m }
From source file:org.jfree.chart.demo.CombinedCategoryPlotDemo1.java
/** * Creates a new demo instance./* w w w . j ava2 s. c om*/ * * @param title the frame title. */ public CombinedCategoryPlotDemo1(final String title) { super(title); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(createChart()); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:pharoslabut.logger.CompassLoggerGUI.java
/** * Creates a new demo./*from w w w.jav a 2 s.c o m*/ * * @param title the frame title. */ public CompassLoggerGUI(final String title) { super(title); final XYDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60); // 60 seconds final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); // new Thread(new ChartUpdater(chart.getXYPlot())).start(); }
From source file:Main.Chart.java
/** * Creates a new demo.//from w ww.j a v a 2 s . c om * * @param title the frame title. */ public Chart(final String title, WeatherData wd) { super(title); final XYDataset dataset = createDataset(wd); 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.CombinedXYPlotDemo2.java
/** * Constructs a new demonstration application. * * @param title the frame title.//from w w w. j a v a2 s . com */ public CombinedXYPlotDemo2(final String title) { super(title); final JFreeChart chart = createCombinedChart(); final ChartPanel panel = new ChartPanel(chart, true, true, true, false, true); panel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(panel); }
From source file:org.jfree.chart.demo.OverlaidXYPlotDemo.java
/** * Constructs a new demonstration application. * * @param title the frame title./* w w w . j a v a 2 s . c o m*/ */ public OverlaidXYPlotDemo(final String title) { super(title); final JFreeChart chart = createOverlaidChart(); final ChartPanel panel = new ChartPanel(chart, true, true, true, true, true); panel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(panel); }
From source file:org.jfree.chart.demo.selection.SelectionDemo3.java
/** * A demonstration application showing a scatter plot. * * @param title the frame title./*from w w w .ja va 2 s . c om*/ */ public SelectionDemo3(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); this.dataset = (XYSeriesCollection) plot.getDataset(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(chartPanel); this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "X:", "Y:" }, 0); this.table = new JTable(this.model); TableColumnModel tcm = this.table.getColumnModel(); tcm.getColumn(2).setCellRenderer(new NumberCellRenderer()); tcm.getColumn(3).setCellRenderer(new NumberCellRenderer()); JPanel p = new JPanel(new BorderLayout()); JScrollPane scroller = new JScrollPane(this.table); p.add(scroller); p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "), new EmptyBorder(4, 4, 4, 4))); split.add(p); setContentPane(split); }
From source file:DualAxisDemo2.java
/** * A demonstration application showing how to create a time series chart with dual axes. * * @param title the frame title./*from www .j a va 2s . c o m*/ */ public DualAxisDemo2(final String title) { super(title); // create a title... final String chartTitle = "Dual Axis Demo 2"; final XYDataset dataset = createDataset1(); final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Date", "Price Per Unit", dataset, true, true, false); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); final NumberAxis axis2 = new NumberAxis("Secondary"); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, createDataset2()); plot.mapDatasetToRangeAxis(1, 1); final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; // rr.setPlotShapes(true); rr.setShapesFilled(true); } final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.black); // renderer2.setPlotShapes(true); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); plot.setRenderer(1, renderer2); final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }