List of usage examples for org.jfree.data.xy XYSeriesCollection XYSeriesCollection
public XYSeriesCollection()
From source file:org.jfree.data.xy.IntervalXYDelegateTest.java
/** * Confirm that the equals method can distinguish all the required fields. *///from w w w . jav a 2s. c om @Test public void testEquals() { XYSeries s1 = new XYSeries("Series"); s1.add(1.2, 3.4); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); IntervalXYDelegate d1 = new IntervalXYDelegate(c1); XYSeries s2 = new XYSeries("Series"); XYSeriesCollection c2 = new XYSeriesCollection(); s2.add(1.2, 3.4); c2.addSeries(s2); IntervalXYDelegate d2 = new IntervalXYDelegate(c2); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.setAutoWidth(false); assertFalse(d1.equals(d2)); d2.setAutoWidth(false); assertTrue(d1.equals(d2)); d1.setIntervalPositionFactor(0.123); assertFalse(d1.equals(d2)); d2.setIntervalPositionFactor(0.123); assertTrue(d1.equals(d2)); d1.setFixedIntervalWidth(1.23); assertFalse(d1.equals(d2)); d2.setFixedIntervalWidth(1.23); assertTrue(d1.equals(d2)); }
From source file:etssi.Graphique.java
/** * Creates a sample dataset.//from w w w . j a v a2s.c om * * @return a sample dataset. */ private XYDataset createDataset(Dataset courbe1, Dataset courbe2, Dataset courbe3) { final XYSeries series1 = new XYSeries("JOB"); for (Data data : courbe1.getArray()) { series1.add(data.getTranche_horaire(), data.getMontant()); } final XYSeries series2 = new XYSeries("Samedi"); for (Data data : courbe2.getArray()) { series2.add(data.getTranche_horaire(), data.getMontant()); } final XYSeries series3 = new XYSeries("Dimanche"); for (Data data : courbe3.getArray()) { series3.add(data.getTranche_horaire(), data.getMontant()); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); dataset.addSeries(series3); return dataset; }
From source file:cachedataanalysis.FlowCacheGroup.java
public XYSeries exportReportChart() throws IOException { ArrayList<XYSeries> series = new ArrayList<XYSeries>(); for (FlowCache cache : caches) { series.add(cache.exportReportChart()); }//from w w w . j a v a 2s . c o m XYSeriesCollection data = new XYSeriesCollection(); for (XYSeries s : series) { data.addSeries(s); } JFreeChart chart = ChartFactory.createXYLineChart("Performance by Size", "Second", "Hit Rate", data); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitRateComp" + size + ".jpg"), chart, 1500, 900); return series.get(series.size() / 2 + 1); }
From source file:eu.udig.tools.jgrass.profile.ProfileView.java
public void createPartControl(Composite parent) { series = new XYSeries("profile"); XYSeriesCollection lineDataset = new XYSeriesCollection(); lineDataset.addSeries(series);/*from w ww.j av a 2 s.c om*/ JFreeChart result = ChartFactory.createXYAreaChart("", "Progressive distance", "Elevation", lineDataset, PlotOrientation.VERTICAL, true, true, false); plot = (XYPlot) result.getPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); new ChartComposite(parent, SWT.None, result); Action action = new ExportChartData(); IActionBars actionBars = getViewSite().getActionBars(); IMenuManager dropDownMenu = actionBars.getMenuManager(); dropDownMenu.add(action); }
From source file:edu.wustl.cab2b.client.ui.visualization.charts.ScatterPlot.java
@Override protected Dataset createColumnWiseData() { List<String> selectedRowNames = chartModel.getSelectedRowNames(); List<String> selectedColumnsNames = chartModel.getSelectedColumnsNames(); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); if (selectedColumnsNames.size() == 1) { String seriesName = chartModel.getColumnName(0); XYSeries xySeries = new XYSeries(seriesName); for (int j = 0; j < selectedRowNames.size(); j++) { Object value = null;/*from ww w .j ava2 s .co m*/ value = chartModel.getValueAt(j, 0); xySeries.add(convertValue(selectedRowNames.get(j)), convertValue(value)); } xySeriesCollection.addSeries(xySeries); } else { for (int i = 1; i < selectedColumnsNames.size(); i++) { String seriesName = chartModel.getColumnName(i); XYSeries xySeries = new XYSeries(seriesName); for (int j = 0; j < selectedRowNames.size(); j++) { Object yValueString = null; Object xValueString = null; xValueString = chartModel.getValueAt(j, 0); yValueString = chartModel.getValueAt(j, i); xySeries.add(convertValue(xValueString), convertValue(yValueString)); } xySeriesCollection.addSeries(xySeries); } } return xySeriesCollection; }
From source file:org.jfree.chart.demo.AnnotationDemo2.java
private static XYDataset createDataset2() { XYSeries xyseries = new XYSeries("Random Data 2"); xyseries.add(1.0D, 429.60000000000002D); xyseries.add(2D, 323.19999999999999D); xyseries.add(3D, 417.19999999999999D); xyseries.add(4D, 624.10000000000002D); xyseries.add(5D, 422.60000000000002D); xyseries.add(6D, 619.20000000000005D); xyseries.add(7D, 416.5D);//from www.j a va 2 s.c o m xyseries.add(8D, 512.70000000000005D); xyseries.add(9D, 501.5D); xyseries.add(10D, 306.10000000000002D); xyseries.add(11D, 410.30000000000001D); xyseries.add(12D, 511.69999999999999D); xyseries.add(13D, 611D); xyseries.add(14D, 709.60000000000002D); xyseries.add(15D, 613.20000000000005D); xyseries.add(16D, 711.60000000000002D); xyseries.add(17D, 708.79999999999995D); xyseries.add(18D, 501.60000000000002D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); return xyseriescollection; }
From source file:PlotsBuilding.PlotPanel.java
private JFreeChart fillCollection(ArrayList<PlotsData> plotscollection) { XYSeriesCollection col = new XYSeriesCollection(); ArrayList<Integer> seriesCount = new ArrayList<>(); int SeriesCount = 0; PlotsData plotdata = new PlotsData(); if (plotscollection.isEmpty()) { XYSeries series = new XYSeries("1. "); series.add(0, 0);/*from www.ja v a2 s . com*/ plotdata.y1 = -10; plotdata.y2 = 10; col.addSeries(series); } for (int i = 0; i < plotscollection.size(); i++) { plotdata = (PlotsData) plotscollection.get(i); col = plotdata.createPlotdataset(i, col); seriesCount.add(col.getSeriesCount() - SeriesCount); SeriesCount = col.getSeriesCount(); } double y1 = plotdata.y1; double y2 = plotdata.y2; JFreeChart chart = createChart(col, seriesCount, y1, y2); return chart; }
From source file:org.matsim.core.utils.charts.XYScatterChart.java
public XYScatterChart(final String title, final String xAxisLabel, final String yAxisLabel, boolean isLogarithmicAxis) { super(title, xAxisLabel, yAxisLabel); this.isLogarithmicAxis = isLogarithmicAxis; this.dataset = new XYSeriesCollection(); this.chart = createChart(title, xAxisLabel, yAxisLabel, this.dataset); addDefaultFormatting();/*from ww w .j av a2 s. c om*/ }
From source file:gestionelectrica.VentanaEjemploGraf.java
private void rellenar(JPanel jp) { // Create a simple XY chart XYSeries series = new XYSeries("EC"); series.add(1, 1);//from w w w .j a v a 2s . com series.add(1, 2); series.add(2, 1); series.add(3, 9); series.add(4, 10); series.add(7, 15); series.add(10, 6); // Add the series to your data set XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart("Energa comprada", // Title "hora", // x-axis Label "KWh", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); JFreeChart pieChart = ChartFactory.createXYLineChart("EJEMPLOOOO", "Category", "Score", createDataset(), PlotOrientation.VERTICAL, true, true, false); System.out.println(System.getProperty("user.home")); System.out.println(System.getProperty("java.io.tmpdir")); System.out.println(System.getProperties()); File f = new File(System.getProperty("java.io.tmpdir") + "\\chart.jpg"); try { ChartUtilities.saveChartAsJPEG(f, chart, jp.getWidth(), jp.getHeight()); } catch (IOException e) { System.err.println("Problem occurred creating chart."); System.err.println(e.getMessage()); } // Adding chart into a chart panel //ChartPanel chartPanel = new ChartPanel(pieChart); // settind default size //chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); // add to contentPane //setContentPane(chartPanel); //jPanel1.add(chartPanel); ImageIcon ic = new ImageIcon(f.getAbsolutePath()); ImagePanel panel = new ImagePanel(ic.getImage(), jp.getWidth(), jp.getHeight()); jp.add(panel); /*jPanel1.repaint(); jPanel1.updateUI(); jPanel1.validate();*/ if (f.delete()) System.out.println("BORRADO CORRECTAMENTE"); else System.err.println("NO SE PUDO BORRAR"); }
From source file:com.compomics.pepshell.view.statistics.RatioStatisticsScatterplotPane.java
@Override public void setGraphData(PepshellProtein aPepshellProtein) { List<XYLineAnnotation> annotations = new ArrayList<>(); XYSeriesCollection allExperiments = new XYSeriesCollection(); for (Experiment anExperiment : experiments) { int proteinIndex = anExperiment.getProteins().indexOf(aPepshellProtein); if (proteinIndex != -1) { XYSeries anExperimentSeries = new XYSeries(anExperiment.getExperimentName()); PepshellProtein experimentPepshellProtein = anExperiment.getProteins().get(proteinIndex); for (PeptideGroup aGroup : experimentPepshellProtein.getPeptideGroups()) { PeptideInterface shortestPeptide = aGroup.getRepresentativePeptide(); if (shortestPeptide instanceof QuantedPeptide && ((QuantedPeptide) shortestPeptide).getRatio() != null) { Double value = Math.log(((QuantedPeptide) shortestPeptide).getRatio()) / Math.log(2); //Double value = ((QuantedPeptide) shortestPeptide).getRatio(); if (value == Double.NEGATIVE_INFINITY) { value = 0.0;//from ww w . j av a 2s.c om } double barWithErrors = (shortestPeptide.getEndProteinMatch() + shortestPeptide.getBeginningProteinMatch()) / 2; double error = Math.log(((QuantedPeptide) shortestPeptide).getStandardError()) / Math.log(2); //double error =((QuantedPeptide) shortestPeptide).getStandardError(); XYLineAnnotation vertical = new XYLineAnnotation(barWithErrors, value - error, barWithErrors, value + error, new BasicStroke(), Color.black); XYLineAnnotation horizontalUpper = new XYLineAnnotation(value + error - 0.25, value + error, value + error + 0.25, value + error, new BasicStroke(), Color.black); XYLineAnnotation horizontalLower = new XYLineAnnotation(value - error - 0.25, value - error, value - error + 0.25, value - error, new BasicStroke(), Color.black); annotations.add(vertical); annotations.add(horizontalUpper); annotations.add(horizontalLower); for (int i = shortestPeptide.getBeginningProteinMatch(); i < shortestPeptide .getEndProteinMatch(); i++) { anExperimentSeries.add(i, value); } } } allExperiments.addSeries(anExperimentSeries); } } JFreeChart ratioChart = ChartFactory.createHistogram( "ratio for " + aPepshellProtein.getVisibleAccession() + " over all experiments", "peptide start", "log^2 ratio", allExperiments, PlotOrientation.VERTICAL, true, true, false); chart.setChart(ratioChart); for (XYLineAnnotation anAnnotation : annotations) { ((XYPlot) ratioChart.getPlot()).addAnnotation(anAnnotation); } prettifyChart(ratioChart); }