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.PieChartDemo4.java
/** * Default constructor./*from www.j a v a2 s. com*/ * * @param title the frame title. */ public PieChartDemo4(final String title) { super(title); final PieDataset dataset = createDataset(14); // create the chart... final JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 4", // chart title dataset, // dataset false, // include legend true, false); // set the background color for the chart... chart.setBackgroundPaint(new Color(222, 222, 255)); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setCircular(true); plot.setLabelGenerator(new StandardPieItemLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); plot.setNoDataMessage("No data available"); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); final Rotator rotator = new Rotator(plot); rotator.start(); }
From source file:monitoring.suhu.DynamicCharts.java
public DynamicCharts(final String title) { super(title); this.series = new TimeSeries("Temperature", Millisecond.class); final TimeSeriesCollection dataset = new TimeSeriesCollection(this.series); chart = createChart(dataset);//from w w w . j a v a 2 s.c o m final ChartPanel chartPanel = new ChartPanel(chart); final JPanel content = new JPanel(new BorderLayout()); content.add(chartPanel); chartPanel.setPreferredSize(new java.awt.Dimension(700, 500)); setContentPane(content); }
From source file:com.insa.tp3g1.esbsimulator.view.OverlaidBarChart.java
/** * Default constructor.//from ww w . jav a 2s .c om * * @param title the frame title. * @param result */ public OverlaidBarChart(final String title, Result result) { super(title); // create the first dataset... DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); LinkConsumerProvider[] linkConsProv = result.getLinksConsumerProvider(); for (LinkConsumerProvider linkConsProv1 : linkConsProv) { dataset1.addValue(Integer.parseInt(linkConsProv1.getAverageResponseTime()), average, link + linkConsProv1.getConsumerId()); } // create the first renderer... // final CategoryLabelGenerator generator = new StandardCategoryLabelGenerator(); final CategoryItemRenderer renderer = new BarRenderer(); // renderer.setLabelGenerator(generator); renderer.setItemLabelsVisible(true); final CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset1); plot.setRenderer(renderer); plot.setDomainAxis(new CategoryAxis("Category")); plot.setRangeAxis(new NumberAxis("Value (ms)")); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); // now create the second dataset and renderer... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); for (LinkConsumerProvider linkConsProv1 : linkConsProv) { dataset2.addValue(Integer.parseInt(result.getTotalResult().getResponseTime().getMinResponseTime()), min, link + linkConsProv1.getConsumerId()); } final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); // create the third dataset and renderer... final ValueAxis rangeAxis2 = new NumberAxis("value (ms)"); plot.setRangeAxis(1, rangeAxis2); DefaultCategoryDataset dataset3 = new DefaultCategoryDataset(); for (LinkConsumerProvider linkConsProv1 : linkConsProv) { dataset3.addValue(Integer.parseInt(result.getTotalResult().getResponseTime().getMaxResponseTime()), max, link + linkConsProv1.getConsumerId()); } plot.setDataset(2, dataset3); final CategoryItemRenderer renderer3 = new LineAndShapeRenderer(); plot.setRenderer(2, renderer3); plot.mapDatasetToRangeAxis(2, 1); // change the rendering order so the primary dataset appears "behind" the // other datasets... plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); final JFreeChart chart = new JFreeChart(plot); chart.setTitle("Response Time Chart"); // chart.setLegend(new StandardLegend()); // 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:com.seniorproject.augmentedreality.test.AreaChartDemo.java
/** * Creates a new demo application./* www . j a v a 2s . c o m*/ * * @param title the frame title. */ public AreaChartDemo(final String title) { super(title); // create a dataset... final double[][] data = new double[][] { { 1.0, 4.0, 3.0, 5.0, 5.0, 7.0, 7.0, 8.0 }, { 5.0, 7.0, 6.0, 8.0, 4.0, 4.0, 2.0, 1.0 }, { 4.0, 3.0, 2.0, 3.0, 6.0, 3.0, 4.0, 3.0 } }; final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Type ", data); // create the chart... final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(500, 270)); chartPanel.setEnforceFileExtensions(false); setContentPane(chartPanel); }
From source file:be.ac.ua.comp.scarletnebula.gui.AllGraphsPanel.java
/** * Places all components (graphs) in the panel. *//*from w w w .ja v a2 s . c om*/ private void placeComponents() { final GridBagConstraints constraints = new GridBagConstraints(); int numberOfComponentsPlaced = 0; int currXPos = 0; final int graphHeight = 150; final int graphWidth = 100; final Collection<String> datastreams = statisticsManager.getAvailableDatastreams(); for (final String streamname : datastreams) { LOG.info("drawing stream"); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 0.5; constraints.gridx = currXPos; constraints.gridy = numberOfComponentsPlaced / 2; constraints.insets = new Insets(10, 0, 0, 0); final DecoratedGraph graph = new DecoratedGraph((long) 10 * 60 * 1000, statisticsManager.getDatastream(streamname)); graph.registerRelativeDatastream(server, streamname, Color.GREEN); graph.addServerToRefresh(server); final ChartPanel chartPanel = graph.getChartPanel(); chartPanel.setPreferredSize(new Dimension(graphWidth, graphHeight)); add(chartPanel, constraints); if (currXPos == 0) { currXPos = 1; } else { currXPos = 0; } numberOfComponentsPlaced++; } }
From source file:GUI.PlotHere.java
/** * Creates new form PlotHere/* w w w. j a va 2s . c om*/ */ public PlotHere(String Title) { initComponents(); XYSeries Input00 = new XYSeries("Input 00"); XYSeries Input01 = new XYSeries("Input 01"); XYSeries Input02 = new XYSeries("Input 02"); XYSeriesCollection data = new XYSeriesCollection(Input00); data.addSeries(Input01); data.addSeries(Input02); JFreeChart chart = ChartFactory.createXYLineChart(Title, "Angle", "Voltage", data, PlotOrientation.VERTICAL, true, true, false); ChartPanel chartpanel = new ChartPanel(chart); //chartpanel.setDomainZoomable(true); chartpanel.setPreferredSize(new java.awt.Dimension(200, 200)); //JPanel jPanel4 = new JPanel(); Component[] a = GraphHerePanel.getComponents(); if (a.length == 0) { GraphHerePanel.setLayout(new BorderLayout()); GraphHerePanel.add(chartpanel); } this.revalidate(); this.repaint(); }
From source file:userInterface.StateAdminRole.DecisionCartJPanel2.java
public DecisionCartJPanel2(JPanel userProcessContainer, PhdEnterprise e) { initComponents();// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. this.userProcessContainer = userProcessContainer; this.e = e;/*from w w w. ja v a 2s . c o m*/ JFreeChart jfreechart1 = createChart1(createDataset1()); ChartPanel chartpanel1 = new ChartPanel(jfreechart1); chartpanel1.setPreferredSize(new Dimension(1000, 540)); jPanel1.add(chartpanel1); CardLayout layout1 = (CardLayout) jPanel1.getLayout(); layout1.next(jPanel1); }
From source file:eu.choreos.chart.XYChart.java
public XYChart(String applicationTitle, String chartTitle, List<ScalabilityReport> reports) { super(applicationTitle); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); XYSeriesCollection dataset = new XYSeriesCollection(); for (ScalabilityReport report : reports) { createDataset(dataset, report);/*from www .j a va 2s . c o m*/ } // based on the dataset we create the chart 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(500, 270)); // add it to our application setContentPane(chartPanel); }
From source file:javaapplication2.PieChart.java
public PieChart(String applicationTitle, String chartTitle) throws ClassNotFoundException, SQLException, IOException { super(applicationTitle); PieDataset dataset = createDataset(); JFreeChart chart = createChart(dataset, chartTitle); ChartPanel chartPanel = new ChartPanel(chart); //ChartUtilities.saveChartAsJPEG(new File("C:/Users/Public/Pictures/Piechart.jpg"), chart, 400, 300); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel);/*from w w w . j av a 2 s.c om*/ this.setExtendedState(BarChart3D.MAXIMIZED_BOTH); }
From source file:FaceRatios.java
public PropertyBoxWhisker(String propertyName, BoxAndWhiskerCategoryDataset dataset) { super(propertyName); final CategoryAxis xAxis = new CategoryAxis("Face"); final NumberAxis yAxis = new NumberAxis("Value"); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false);//w ww .j a v a 2s. co m final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart(propertyName, new Font("SansSerif", Font.BOLD, 14), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(900, 540)); setContentPane(chartPanel); }