List of usage examples for org.jfree.data.xy XYSeriesCollection XYSeriesCollection
public XYSeriesCollection()
From source file:Charts.LineChart.java
private XYSeriesCollection createDataset() { final XYSeriesCollection dataset = new XYSeriesCollection(); // Acces tableau for (int i = 0; i < super.values.length; i++) { final XYSeries serie = new XYSeries(i); // Acces ArrayList for (int j = 0; j < super.values[i].size(); j++) { serie.add(super.values[i].get(j).key(), super.values[i].get(j).value()); }//from w w w.j a v a2 s .c om dataset.addSeries(serie); } return dataset; }
From source file:edu.ucsd.hep.slhaviewer.view.MassGraphPanel.java
public MassGraphPanel() { this.setLayout(new BorderLayout()); dataset = new XYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart("Mass Spectrum", "", "mass [GeV]", dataset, PlotOrientation.VERTICAL, false, // no legend true, // add tooltips false // add urls );/*from w ww . j a v a 2s . c o m*/ // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setTickMarksVisible(false); domainAxis.setTickLabelsVisible(false); chart.setBackgroundPaint(Color.WHITE); // 'outside' plot.setBackgroundPaint(Color.WHITE); // 'inside' plot.setRangeGridlinePaint(Color.DARK_GRAY); this.add(new ChartPanel(chart), BorderLayout.CENTER); }
From source file:utlis.HistogramPlot.java
public JFreeChart plotColorChart(ArrayList<int[]> histograms) { XYSeries xysRed = new XYSeries("Red"); XYSeries xysGreen = new XYSeries("Grean"); XYSeries xysBlue = new XYSeries("blue"); for (int i = 0; i < histograms.get(0).length; i++) { xysRed.add(i, histograms.get(0)[i]); xysBlue.add(i, histograms.get(2)[i]); xysGreen.add(i, histograms.get(1)[i]); }/*ww w . j ava 2 s .c om*/ XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(xysRed); collection.addSeries(xysBlue); collection.addSeries(xysGreen); JFreeChart chart = ChartFactory.createXYLineChart("Histogram", "Color Value", "Pixel count", collection); try { ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 500, 300); } catch (IOException ex) { Logger.getLogger(HistogramPlot.class.getName()).log(Level.SEVERE, null, ex); } return chart; }
From source file:gov.sandia.umf.platform.ui.jobs.Raster.java
public void parsePrnFile(File f) { dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("Spikes"); dataset.addSeries(series);//from ww w. j a v a 2 s.c o m int columns = 1; try { int row = 0; int timeColumn = -1; // It's possible that there might not be a time column. In that case, we use raw row index; BufferedReader br = new BufferedReader(new FileReader(f)); while (true) { String line = br.readLine(); if (line == null) break; // indicates end of stream line = line.trim(); if (line.length() == 0) continue; if (line.startsWith("End of")) continue; String[] parts = line.split("\t"); // TODO: does Xyce output tabs or spaces? May have to switch regexp here, depending on source. columns = Math.max(columns, parts.length); char firstCharacter = parts[0].charAt(0); if (firstCharacter < '0' || firstCharacter > '9') // column header { if (timeColumn >= 0) continue; int timeMatch = 0; // goodness of match for (int p = 0; p < parts.length; p++) { int potentialMatch = 0; String columnName = parts[p]; if (columnName.equals("TIME")) potentialMatch = 1; else if (columnName.equals("$t")) potentialMatch = 2; if (potentialMatch > timeMatch) { timeMatch = potentialMatch; timeColumn = p; } } } else { int p = timeColumn; double time = row; if (p >= 0) time = Double.parseDouble(parts[timeColumn]); p++; for (; p < parts.length; p++) { if (!parts[p].isEmpty() && Double.parseDouble(parts[p]) != 0) series.add(time, p); } row++; } } br.close(); } catch (IOException e) { } availableHeight = Math.min(20, Math.max(1, Math.round((float) availableHeight / columns))); }
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 v a 2 s.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:playground.benjamin.scenarios.zurich.analysis.charts.BkChartTemplate.java
private void createDataSet() { double xvalue = 0; double yvalue = 0; this.dataset = new XYSeriesCollection(); // 1. boolean = autosort, 2. boolean = allow multiple x-values XYSeries series = new XYSeries("Series name", false, true); this.dataset.addSeries(series); series.add(xvalue, yvalue);/* w w w. j a va 2 s. co m*/ }
From source file:web.diva.server.unused.PCAGenerator.java
/** * * * @return dataset./*from w w w .j a v a 2s. co m*/ */ private XYDataset createDataset(TreeMap<Integer, PCAPoint> points, int[] subSelectionData, int[] selection, boolean zoom, DivaDataset divaDataset) { final XYSeriesCollection dataset = new XYSeriesCollection(); seriesList = new TreeMap<String, XYSeries>(); seriesList.put("#000000", new XYSeries("#000000")); seriesList.put("unGrouped", new XYSeries("LIGHT_GRAY")); for (Group g : divaDataset.getRowGroups()) { if (g.isActive() && !g.getName().equalsIgnoreCase("all")) { seriesList.put(g.getHashColor(), new XYSeries(g.getHashColor())); } } if (!zoom && (selection == null || selection.length == 0) && subSelectionData == null) { for (int key : points.keySet()) { PCAPoint point = points.get(key); if (seriesList.containsKey(point.getColor())) { // seriesList.get(divaDataset.getGeneColorArr()[point.getGeneIndex()]).add(point.getX(), point.getY()); } else { seriesList.get("unGrouped").add(point.getX(), point.getY()); } } } else if (zoom) { selectionSet.clear(); for (int i : selection) { selectionSet.add(i); } for (int x : subSelectionData) { PCAPoint point = points.get(x); if (selectionSet.contains(point.getGeneIndex())) { if (seriesList.containsKey(point.getColor())) { // seriesList.get(divaDataset.getGeneColorArr()[point.getGeneIndex()]).add(point.getX(), point.getY()); } else { seriesList.get("#000000").add(point.getX(), point.getY()); } } else { seriesList.get("unGrouped").add(point.getX(), point.getY()); } } } else if (subSelectionData != null) { selectionSet.clear(); for (int i : selection) { selectionSet.add(i); } // for (int key : subSelectionData) { // PCAPoint point = points.get(key); // if (selectionSet.contains(point.getGeneIndex())) { // if (seriesList.containsKey(divaDataset.getGeneColorArr()[point.getGeneIndex()])) { // seriesList.get(divaDataset.getGeneColorArr()[point.getGeneIndex()]).add(point.getX(), point.getY()); // // } else { // // seriesList.get("#000000").add(point.getX(), point.getY()); // } // // } else { // // seriesList.get("unGrouped").add(point.getX(), point.getY()); // } // // } } else //selection without zoom { selectionSet.clear(); for (int i : selection) { selectionSet.add(i); } // for (int key : points.keySet()) { // PCAPoint point = points.get(key); // // if (selectionSet.contains(point.getGeneIndex())) { // if (seriesList.containsKey(divaDataset.getGeneColorArr()[point.getGeneIndex()])) { // seriesList.get(divaDataset.getGeneColorArr()[point.getGeneIndex()]).add(point.getX(), point.getY()); // // } else { // // seriesList.get("#000000").add(point.getX(), point.getY()); // } // // } else { // // seriesList.get("unGrouped").add(point.getX(), point.getY()); // } // // } } for (XYSeries ser : seriesList.values()) { dataset.addSeries(ser); } return dataset; }
From source file:geneticalgorithm.gui.view.VGraphic.java
public VGraphic(String title, String xLabel, String yLabel) { setSize(800, 600);//from w ww . j av a 2 s . co m setLocationRelativeTo(this); setTitle(title); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { dispose(); } }); setLayout(new BorderLayout()); average = new XYSeries("Average"); offline = new XYSeries("Offline"); online = new XYSeries("Online"); dataset = new XYSeriesCollection(); dataset.addSeries(average); dataset.addSeries(offline); dataset.addSeries(online); chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false); add(new ChartPanel(chart), BorderLayout.CENTER); JPanel south = new JPanel(new MigLayout()); lblAverage = new JLabel(""); lblAverage.setHorizontalTextPosition(SwingConstants.LEFT); lblAverage.setFont(new Font("ARIAL", Font.BOLD, 26)); JLabel lblAverageTitle = new JLabel("Average: "); lblAverageTitle.setFont(new Font("ARIAL", Font.BOLD, 26)); south.add(lblAverageTitle); south.add(lblAverage, "wrap"); lblOffline = new JLabel(""); lblOffline.setHorizontalTextPosition(SwingConstants.LEFT); lblOffline.setFont(new Font("ARIAL", Font.BOLD, 26)); JLabel lblOfflineTitle = new JLabel("Offline: "); lblOfflineTitle.setFont(new Font("ARIAL", Font.BOLD, 26)); south.add(lblOfflineTitle); south.add(lblOffline, "wrap"); lblOnline = new JLabel(""); lblOnline.setHorizontalTextPosition(SwingConstants.LEFT); lblOnline.setFont(new Font("ARIAL", Font.BOLD, 26)); JLabel lblOnlineTitle = new JLabel("Online: "); lblOnlineTitle.setFont(new Font("ARIAL", Font.BOLD, 26)); south.add(lblOnlineTitle); south.add(lblOnline, "wrap"); add(south, BorderLayout.SOUTH); }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.KaplanMeierPlot.java
public KaplanMeierPlot(Collection<KaplanMeierPlotPointSeriesSet> kmPlotSets) { kaplanMeierPlotSets = kmPlotSets;//from www . ja v a 2 s . c o m finalDataCollection = new XYSeriesCollection(); /** * Repackage all the datasets to go into the XYSeriesCollection */ for (KaplanMeierPlotPointSeriesSet dataSet : kaplanMeierPlotSets) { finalDataCollection.addSeries(dataSet.getCensorPlotPoints()); finalDataCollection.addSeries(dataSet.getProbabilityPlotPoints()); } createChart(finalDataCollection); }
From source file:org.gwaspi.reports.PlinkReportLoader.java
public static CombinedRangeXYPlot loadAssocUnadjLogPvsPos(File plinkReport, Set<String> redMarkersHS) throws IOException { XYSeriesCollection chrData = new XYSeriesCollection(); NumberAxis sharedAxis = new NumberAxis("-log?(P)"); CombinedRangeXYPlot combinedPlot = new CombinedRangeXYPlot(sharedAxis); combinedPlot.setGap(0);/* w w w . j ava 2 s . c o m*/ XYSeries series1 = null; XYSeries series2 = null; FileReader inputFileReader = null; BufferedReader inputBufferReader = null; String tempChr = null; try { inputFileReader = new FileReader(plinkReport); inputBufferReader = new BufferedReader(inputFileReader); // Getting data from file and subdividing to series all points by chromosome String l; tempChr = ""; String header = inputBufferReader.readLine(); int count = 0; while ((l = inputBufferReader.readLine()) != null) { if (count % 10000 == 0) { log.info("loadAssocUnadjLogPvsPos -> reader count: {}", count); } count++; l = l.trim().replaceAll("\\s+", ","); String[] cVals = l.split(","); String markerId = cVals[1]; int position = Integer.parseInt(cVals[2]); String s_pVal = cVals[8]; if (!s_pVal.equals("NA")) { double logPValue = Math.abs(Math.log(Double.parseDouble(s_pVal)) / Math.log(10)); if (cVals[0].toString().equals(tempChr)) { if (redMarkersHS.contains(markerId)) { series2.add(position, logPValue); } else { series1.add(position, logPValue); } labeler.put(tempChr + "_" + position, markerId); } else { if (!tempChr.isEmpty()) { // SKIP FIRST TIME (NO DATA YET!) chrData.addSeries(series1); chrData.addSeries(series2); appendToCombinedRangePlot(combinedPlot, tempChr, chrData); } tempChr = cVals[0]; series1 = new XYSeries("Imputed"); series2 = new XYSeries("Observed"); labeler.put(tempChr + "_" + position, markerId); if (redMarkersHS.contains(markerId)) { series2.add(position, logPValue); } else { series1.add(position, logPValue); } } } } } finally { if (inputBufferReader != null) { inputBufferReader.close(); } else if (inputFileReader != null) { inputFileReader.close(); } } chrData.addSeries(series1); chrData.addSeries(series2); appendToCombinedRangePlot(combinedPlot, tempChr, chrData); // ADD LAST CHR TO PLOT return combinedPlot; }