List of usage examples for org.jfree.data.xy XYSeriesCollection XYSeriesCollection
public XYSeriesCollection(XYSeries series)
From source file:org.marekasf.troughput.XYHistogramChart.java
public XYHistogramChart(final AdaptiveHistogram h, final String title) { super(title); final XYSeries series = new XYSeries(title); IntStream.rangeClosed(0, 100).forEach(i -> series.add(i, h.getValueForPercentile(i))); final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart("XY Histogram Chart " + title, "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel);/* w w w . j a v a 2 s .c o m*/ }
From source file:com.joey.software.plottingToolkit.PlotingToolkit.java
public static XYSeriesCollection getCollection(float[] xData, float[] yData, String name) { if (xData.length != yData.length) { throw new InvalidParameterException("X and Y must be same length"); }// w w w .j a va2 s . c o m XYSeries series = new XYSeries(name); for (int i = 0; i < xData.length; i++) { series.add(xData[i], yData[i]); } XYSeriesCollection result = new XYSeriesCollection(series); return result; }
From source file:fr.ign.cogit.simplu3d.rjmcmc.generic.visitor.StatsVisitor.java
public StatsVisitor(String title) { aF = new ApplicationFrame(title); this.series = new XYSeries("U Total"); this.seriesUnary = new XYSeries("U Unaire"); this.seriesBinary = new XYSeries("U Binaire"); this.seriesBest = new XYSeries("Meilleur candidat"); final XYSeriesCollection dataset = new XYSeriesCollection(this.series); dataset.addSeries(seriesUnary);/* w ww . j a va2 s. c om*/ dataset.addSeries(seriesBinary); dataset.addSeries(seriesBest); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); final JPanel content = new JPanel(new BorderLayout()); content.add(chartPanel); chartPanel.setPreferredSize(new java.awt.Dimension(800, (int) (0.8 * 540))); aF.setContentPane(content); aF.pack(); aF.setVisible(true); CHARTSINGLETON = chartPanel; }
From source file:openomr.dataanalysis.XYChart.java
public XYChart(int data[], int size, String name) { XYSeries series = new XYSeries(name); for (int i = 0; i < size; i += 1) series.add(i, data[i]);/*from w ww. j ava 2 s .c o m*/ XYDataset xyDataset = new XYSeriesCollection(series); chart = ChartFactory.createXYAreaChart(name, "width", "# Pixels", xyDataset, PlotOrientation.VERTICAL, true, false, false); }
From source file:de.suse.swamp.test.TestStatisticsGraph.java
public void testStatistic() { XYSeries series = new XYSeries("Running Workflows"); series.add(1995, 0.5);//from ww w. ja va 2 s.c o m series.add(2000, 3.0); series.add(2010, 20.0); series.add(2020, 50.0); XYDataset dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createTimeSeriesChart("test", "time", "value", dataset, false, false, false); JFreeChart chart4; DefaultPieDataset dataset2 = new DefaultPieDataset(); // Initialize the dataset dataset2.setValue("California", new Double(10.0)); dataset2.setValue("Arizona", new Double(8.0)); dataset2.setValue("New Mexico", new Double(8.0)); dataset2.setValue("Texas", new Double(40.0)); dataset2.setValue("Louisiana", new Double(8.0)); dataset2.setValue("Mississippi", new Double(4.0)); dataset2.setValue("Alabama", new Double(2.0)); dataset2.setValue("Florida", new Double(20.0)); chart4 = ChartFactory.createPieChart3D("Driving Time Spent Per State (3D with Transparency)", // The chart title dataset2, // The dataset for the chart true, // Is a legend required? true, // Use tooltips false // Configure chart to generate URLs? ); PiePlot3D plot4 = (PiePlot3D) chart4.getPlot(); plot4.setForegroundAlpha(0.6f); try { ChartUtilities.saveChartAsPNG(new java.io.File("test.png"), chart, 500, 300); ChartUtilities.saveChartAsPNG(new java.io.File("test2.png"), chart4, 500, 300); } catch (java.io.IOException exc) { System.err.println("Error writing image to file"); } }
From source file:neironweb.Frame.java
public Frame() { super("neural network"); //JPanel pane = new JPanel(); setLayout(null);// w ww . j ava 2 s . c o m JPanel mailPanel = new JPanel(); mailPanel.setLayout(null); mailPanel.setLocation(50, 30); mailPanel.setSize(300, 170); mailPanel.setBorder(BorderFactory.createLineBorder(Color.black)); JLabel mailLabel = new JLabel("e-mail:"); mailLabel.setLocation(10, 10); mailLabel.setSize(50, 30); mailPanel.add(mailLabel); JLabel dirMailLabel = new JLabel("direct:"); dirMailLabel.setLocation(10, 50); dirMailLabel.setSize(50, 30); mailPanel.add(dirMailLabel); JTextField mailField = new JTextField("mail@mail.ru"); mailField.setSize(150, 30); mailField.setLocation(80, 10); mailPanel.add(mailField); JTextField textField = new JTextField("INBOX"); textField.setLocation(80, 50); textField.setSize(150, 30); mailPanel.add(textField); JButton mailButton = new JButton("Analyze"); mailButton.setLocation(80, 90); mailButton.setSize(150, 30); mailPanel.add(mailButton); // JButton eduButton = new JButton("Start education"); // eduButton.setLocation(0, 50); // eduButton.setSize(150, 30); // buttonPanel.add(eduButton); XYSeries xyser = new XYSeries(""); XYDataset xy = new XYSeriesCollection(xyser); JFreeChart jf = ChartFactory.createXYLineChart("Education", "X", "Y", xy); for (int i = 0; i < 100; i++) xyser.add(i, Math.cos(i)); ChartPanel chartPanel = new ChartPanel(jf); chartPanel.setSize(700, 300); chartPanel.setLocation(50, 230); chartPanel.setBorder(BorderFactory.createLineBorder(Color.black)); // JPanel myChartPanel = new JPanel(); // myChartPanel.setLayout(null); // myChartPanel.setLocation(50, 230); // myChartPanel.setSize(700, 300); // myChartPanel // myChartPanel.add(chartPanel); setSize(800, 600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container con = this.getContentPane(); // inherit main frame //con.add(pane); con.add(mailPanel); //con.add(myChartPanel); con.add(chartPanel); setVisible(true); }
From source file:mt.DisplayHistogram.java
public static IntervalXYDataset createDataset(final List<Double> values, final int numBins, final String title) { final XYSeries series = new XYSeries(title); final ValuePair<Double, Double> minmax = getMinMax(values); min = minmax.getA();//from w w w . j a v a2s . c o m max = minmax.getB(); final List<ValuePair<Double, Integer>> hist = binData(values, min, max, numBins); for (final ValuePair<Double, Integer> pair : hist) series.add(pair.getA(), pair.getB()); final XYSeriesCollection dataset = new XYSeriesCollection(series); dataset.setAutoWidth(true); return dataset; }
From source file:org.altusmetrum.altosuilib_2.AltosUIGraph.java
public void addSeries(String label, int fetch, AltosUnits units, Color color, boolean enabled, AltosUIAxis axis) {/*from ww w .ja v a 2s. c o m*/ AltosUISeries series = new AltosUISeries(label, fetch, units, color, enabled, axis); XYSeriesCollection dataset = new XYSeriesCollection(series); series.renderer.setPlot(plot); plot.setDataset(series_index, dataset); plot.setRenderer(series_index, series.renderer); plot.mapDatasetToRangeAxis(series_index, axis.index); if (enable != null) enable.add(label, series, enabled); this.graphers.add(series); series_index++; }
From source file:endrov.frameTime.FrameTimeWindow.java
/** * Make a new window at some specific location *///from w w w. j av a2s.co m public FrameTimeWindow(Rectangle bounds) { bAdd.addActionListener(this); bApply.addActionListener(this); bRefresh.addActionListener(this); objectCombo.addActionListener(this); XYDataset xyDataset = new XYSeriesCollection(frametimeSeries); JFreeChart chart = ChartFactory.createXYLineChart("", "Time", "Frame", xyDataset, PlotOrientation.HORIZONTAL, false/*legend*/, false/*tooltips*/, false/*urls*/); ChartPanel graphpanel = new ChartPanel(chart); //Put GUI together JPanel datapanel = new JPanel(new BorderLayout()); JPanel dataparto = new JPanel(new BorderLayout()); dataparto.add(datapart, BorderLayout.NORTH); JScrollPane datapartscroll = new JScrollPane(dataparto, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JPanel buttonpanel = new JPanel(new GridLayout(2, 2)); buttonpanel.add(bAdd); buttonpanel.add(bApply); buttonpanel.add(bRefresh); datapanel.add(buttonpanel, BorderLayout.SOUTH); datapanel.add(datapartscroll, BorderLayout.CENTER); setLayout(new BorderLayout()); add(datapanel, BorderLayout.EAST); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(graphpanel, BorderLayout.CENTER); leftPanel.add(objectCombo, BorderLayout.SOUTH); add(leftPanel, BorderLayout.CENTER); loadData(); //Window overall things setTitleEvWindow("Frame/Time"); packEvWindow(); setVisibleEvWindow(true); setBoundsEvWindow(bounds); }
From source file:org.jfree.chart.demo.SmallNumberDemo.java
/** * Creates a new demo instance./*from w w w . j av a 2 s . c o m*/ * * @param title the frame title. */ public SmallNumberDemo(final String title) { super(title); final XYSeries series = new XYSeries("Small Numbers"); series.add(1.0E-5, 1.0E-16); series.add(5.0E-5, 2.0E-12); series.add(17.3E-5, 5.0E-7); series.add(21.2E-5, 9.0E-6); final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart("Small Number Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setStandardTickUnits(new StandardTickUnitSource()); plot.getRangeAxis().setStandardTickUnits(new StandardTickUnitSource()); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }