List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries
public void addSeries(XYSeries series)
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java
public void setGatingData(ArrayList<Integer> delays) { final XYSeries s1 = new XYSeries("delays"); for (Integer delay : delays) { s1.add((double) delay, 0); }/*from w w w . j av a2 s. co m*/ final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); rawGateData_ = delays; gatePositionData_ = dataset; XYPlot plot = chart_.getXYPlot(); plot.setDataset(1, gatePositionData_); }
From source file:ascensionxyplot.AscensionXYPlot.java
/** * Creates a sample dataset./*from ww w . ja v a 2 s. co m*/ * * @return Series 1. */ private XYDataset createDataset1(File dataFile) { Body body = DataReader.ReadAscensionControlLog(dataFile); Vector<Point> p = body.markers.get(String.valueOf(0)).points; // create dataset 1... final XYSeries series1a = new XYSeries("x"); // series1.add(10.0, 12353.3); // series1.add(20.0, 13734.4); final XYSeries series1b = new XYSeries("y"); // series1b.add(10.0, 15000.3); // series1b.add(20.0, 11000.4); final XYSeries series1c = new XYSeries("z"); // series1b.add(10.0, 15000.3); // series1b.add(20.0, 11000.4); Long lowerBound = 0L; Long upperBound = 120L; Long previousTime = lowerBound; int i = 0; while (previousTime < upperBound) { Point currentPoint = p.elementAt(i); Long currentTime = Long.valueOf(body.timepoints.elementAt(i).toString()); if (currentTime == lowerBound || currentTime - previousTime >= 10) { // plot a point if it is the first record or more than 0.01s passed since last plot // note: the actual time was multiplied by 1000 in DataReader, thus requiring time difference of 10 series1a.add(currentPoint.time, currentPoint.x); series1b.add(currentPoint.time, currentPoint.y); // series1c.add(currentPoint.z, currentTime); series1c.add(currentPoint.time, currentPoint.z); //HOW IS THIS NOT WORKING??? WHYYYYYY.... previousTime = currentTime; // System.out.println(previousTime); // System.out.println(currentTime); // System.out.println(currentPoint.time); } i++; } final XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1a); collection.addSeries(series1b); collection.addSeries(series1c); return collection; }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java
private XYDataset createDummyGatingData() { final XYSeries s1 = new XYSeries("DummyGating"); s1.add(0, 0);/*from w ww. j a v a 2s. c om*/ s1.add(1000, 0); s1.add(2000, 0); s1.add(3000, 0); s1.add(4000, 0); s1.add(5000, 0); final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); return dataset; }
From source file:edu.gmu.cs.sim.util.media.chart.TimeSeriesChartGenerator.java
/** Adds a series, plus a (possibly null) SeriesChangeListener which will receive a <i>single</i> event if/when the series is deleted from the chart by the user. The series should have a key in the form of a String. Returns the series attributes. */ public SeriesAttributes addSeries(final XYSeries series, final SeriesChangeListener stopper) { XYSeriesCollection xysc = (XYSeriesCollection) getSeriesDataset(); int i = xysc.getSeriesCount(); series.setKey(new ChartGenerator.UniqueString(series.getKey())); xysc.addSeries(series); TimeSeriesAttributes csa = new TimeSeriesAttributes(this, series, i, stopper); seriesAttributes.add(csa);/* w w w. j a va2s .com*/ revalidate(); return csa; }
From source file:org.gephi.statistics.plugin.EigenvectorCentrality.java
/** * /*w w w . jav a 2 s .c o m*/ * @return */ public String getReport() { //distribution of values Map<Double, Integer> dist = new HashMap<Double, Integer>(); for (int i = 0; i < centralities.length; i++) { Double d = centralities[i]; if (dist.containsKey(d)) { Integer v = dist.get(d); dist.put(d, v + 1); } else { dist.put(d, 1); } } //Distribution series XYSeries dSeries = ChartUtils.createXYSeries(dist, "Eigenvector Centralities"); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(dSeries); JFreeChart chart = ChartFactory.createScatterPlot("Eigenvector Centrality Distribution", "Score", "Count", dataset, PlotOrientation.VERTICAL, true, false, false); chart.removeLegend(); ChartUtils.decorateChart(chart); ChartUtils.scaleChart(chart, dSeries, true); String imageFile = ChartUtils.renderChart(chart, "eigenvector-centralities.png"); String report = "<HTML> <BODY> <h1>Eigenvector Centrality Report</h1> " + "<hr>" + "<h2> Parameters: </h2>" + "Network Interpretation: " + (isDirected ? "directed" : "undirected") + "<br>" + "Number of iterations: " + numRuns + "<br>" + "Sum change: " + sumChange + "<br> <h2> Results: </h2>" + imageFile + "</BODY></HTML>"; return report; }
From source file:io.jcml.gephi.plugins.abcd.ABCD.java
@Override public String getReport() { String report = ""; //Distribution series XYSeries cSeries = ChartUtils.createXYSeries(countsDist, "Friendship Scores Distribution"); XYSeriesCollection dataset1 = new XYSeriesCollection(); dataset1.addSeries(cSeries); JFreeChart chart1 = ChartFactory.createXYLineChart("Friendship Scores Distribution", "Value", "Count", dataset1, PlotOrientation.VERTICAL, true, false, false); chart1.removeLegend();/* w w w. j a v a 2 s .com*/ ChartUtils.decorateChart(chart1); ChartUtils.scaleChart(chart1, cSeries, false); String countsImageFile = ChartUtils.renderChart(chart1, "scores-distribution.png"); NumberFormat f = new DecimalFormat("#0.000"); report = "<HTML> <BODY> <h1>ABCD Report </h1> " + "<hr>" + "<br> <h2> Results: </h2>" + "Average score: " + f.format(avgFriendship) + "<br /><br />" + countsImageFile + "</BODY></HTML>"; return report; }
From source file:net.relet.freimap.LinkInfo.java
public void setFlowProfile(LinkedList<FlowData> lp) { XYSeries packets = new XYSeries("packets"); XYSeries bytes = new XYSeries("bytes"); XYSeries icmp = new XYSeries("icmp"); XYSeries tcp = new XYSeries("tcp"); XYSeries udp = new XYSeries("udp"); XYSeries other = new XYSeries("other"); XYSeriesCollection data1 = new XYSeriesCollection(bytes); XYSeriesCollection data2 = new XYSeriesCollection(packets); XYSeriesCollection data3 = new XYSeriesCollection(icmp); data3.addSeries(tcp); data3.addSeries(udp);//from w ww . ja v a 2 s . c o m data3.addSeries(other); //linkChart = ChartFactory.createXYLineChart("packets, bytes\r\nicmp, tcp, udp other", "time", "count", data1, PlotOrientation.VERTICAL, false, false, false); ValueAxis domain = new DateAxis(); ValueAxis range1 = new NumberAxis(); ValueAxis range2 = new NumberAxis(); ValueAxis range3 = new NumberAxis(); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(domain); plot.add(new XYPlot(data2, domain, range1, new XYLineAndShapeRenderer(true, false))); plot.add(new XYPlot(data1, domain, range2, new XYLineAndShapeRenderer(true, false))); plot.add(new XYPlot(data3, domain, range1, new XYLineAndShapeRenderer(true, false))); linkChart = new JFreeChart(plot); linkChart.setTitle(""); sexupLayout(linkChart); long min = lp.getFirst().begin, max = lp.getLast().end; for (float i = 0.0f; i < 1000.0f; i += 1.0f) { long cur = min + (long) ((max - min) * (i / 1000.0)); long cpackets = 0; long cbytes = 0; long cicmp = 0; long ctcp = 0; long cudp = 0; long cother = 0; Iterator<FlowData> li = lp.iterator(); while (li.hasNext()) { FlowData data = li.next(); if (data.begin > cur) break; if (data.end < cur) continue; cpackets += data.packets; cbytes += data.bytes; switch (data.protocol) { case 1: { cicmp += data.packets; break; } case 6: { ctcp += data.packets; break; } case 17: { cudp += data.packets; break; } default: { cother += data.packets; break; } } } packets.add(cur, cpackets); bytes.add(cur, cbytes); icmp.add(cur, cicmp); tcp.add(cur, ctcp); udp.add(cur, cudp); other.add(cur, cother); } status = STATUS_AVAILABLE; }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java
private XYDataset createDummyMaxpointData(int offset) { final XYSeries s1 = new XYSeries("DummyMaxpoint"); for (int i = 0; i < 16666; i = i + resolution_) { if (i < 1000) s1.add(i, 0);//from w w w .ja v a 2 s. c o m else { int num = (int) (4000 * exp(-((double) ((i - maxpointDelay_)) / (2000)))); s1.add(i, num); } // s1.add(i, 4000* exp(-((double) (i - maxpointDelay_)))); } // delays_ = final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); return dataset; }
From source file:org.gephi.statistics.plugin.dynamic.DynamicClusteringCoefficient.java
public String getReport() { //Transform to Map Map<Double, Double> map = new HashMap<Double, Double>(); for (Interval<Double> interval : averages.getIntervals()) { map.put(interval.getLow(), interval.getValue()); }// www .j a v a 2 s.c o m //Time series XYSeries dSeries = ChartUtils.createXYSeries(map, "Clustering Coefficient Time Series"); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(dSeries); JFreeChart chart = ChartFactory.createXYLineChart("Clustering Coefficient", "Time", "Average Clustering Coefficient", dataset, PlotOrientation.VERTICAL, true, false, false); chart.removeLegend(); ChartUtils.decorateChart(chart); ChartUtils.scaleChart(chart, dSeries, false); String coefficientImageFile = ChartUtils.renderChart(chart, "coefficient-ts.png"); NumberFormat f = new DecimalFormat("#0.000000"); String report = "<HTML> <BODY> <h1>Dynamic Clustering Coefficient Report </h1> " + "<hr>" + "<br> Bounds: from " + f.format(bounds.getLow()) + " to " + f.format(bounds.getHigh()) + "<br> Window: " + window + "<br> Tick: " + tick + "<br><br><h2> Average clustering cloefficient over time: </h2>" + "<br /><br />" + coefficientImageFile; /*for (Interval<Double> average : averages) { report += average.toString(dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DOUBLE)) + "<br />"; }*/ report += "<br /><br /></BODY></HTML>"; return report; }
From source file:com.griddynamics.jagger.engine.e1.reporting.WorkloadProcessTimePlotsReporter.java
public Map<String, TaskPlotDTO> createTaskPlots() { String sessionId = getSessionIdProvider().getSessionId(); @SuppressWarnings("unchecked") List<TimeInvocationStatistics> statistics = getHibernateTemplate() .find("select t from TimeInvocationStatistics t where t.taskData.sessionId=?", sessionId); Map<String, List<TimeInvocationStatistics>> aggregatedByTasks = Maps.newLinkedHashMap(); for (TimeInvocationStatistics stat : statistics) { List<TimeInvocationStatistics> taskData = aggregatedByTasks.get(stat.getTaskData().getTaskId()); if (taskData == null) { taskData = new ArrayList<TimeInvocationStatistics>(); aggregatedByTasks.put(stat.getTaskData().getTaskId(), taskData); }// ww w . j ava2 s. c o m taskData.add(stat); } Map<String, TaskPlotDTO> taskPlots = Maps.newHashMap(); for (String taskId : aggregatedByTasks.keySet()) { TaskPlotDTO taskPlot = new TaskPlotDTO(); List<TimeInvocationStatistics> taskStats = aggregatedByTasks.get(taskId); XYSeries throughput = new XYSeries("Throughput"); XYSeries latency = new XYSeries("Latency avg", true, false); XYSeries latencyStdDev = new XYSeries("Latency StdDev", true, false); SortedMap<Integer, XYSeries> percentileSeries = new TreeMap<Integer, XYSeries>(); String taskName = null; for (TimeInvocationStatistics stat : taskStats) { if (taskName == null) { taskName = stat.getTaskData().getTaskName(); } throughput.add(stat.getTime(), stat.getThroughput()); latency.add(stat.getTime(), stat.getLatency()); latencyStdDev.add(stat.getTime(), stat.getLatencyStdDev()); List<TimeLatencyPercentile> percentiles = stat.getPercentiles(); if (percentiles != null && !percentiles.isEmpty()) { Collections.sort(percentiles, new Comparator<Percentile>() { @Override public int compare(Percentile p1, Percentile p2) { return Double.compare(p1.getPercentileKey(), p2.getPercentileKey()); } }); for (int i = 0; i < percentiles.size(); i++) { Percentile currentPercentile = percentiles.get(i); double previousPercentile = i > 0 ? percentiles.get(i - 1).getPercentileValue() : 0; double additivePercentileValue = (currentPercentile.getPercentileValue() - previousPercentile) / 1000; addPercentile(percentileSeries, currentPercentile.getPercentileKey(), additivePercentileValue, stat.getTime()); } } else { for (XYSeries series : percentileSeries.values()) { series.add(stat.getTime(), 0); } } } XYSeriesCollection throughputCollection = new XYSeriesCollection(); throughputCollection.addSeries(throughput); Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(throughputCollection, null); throughputCollection = pair.getSecond(); JFreeChart chartThroughput = ChartHelper.createXYChart(null, throughputCollection, "Time (" + pair.getFirst() + ")", "Throughput (TPS)", 2, 2, ChartHelper.ColorTheme.LIGHT); taskPlot.setThroughputPlot(new JCommonDrawableRenderer(chartThroughput)); XYSeriesCollection latencyCollection = new XYSeriesCollection(); latencyCollection.addSeries(latency); latencyCollection.addSeries(latencyStdDev); XYSeriesCollection percentilesCollection = new XYSeriesCollection(); for (XYSeries series : percentileSeries.values()) { percentilesCollection.addSeries(series); } Pair<String, XYSeriesCollection> percentilesPair = ChartHelper.adjustTime(percentilesCollection, null); Pair<String, XYSeriesCollection> latencyPair = ChartHelper.adjustTime(latencyCollection, null); if (!latencyPair.getFirst().equals(percentilesPair.getFirst())) { throw new IllegalStateException("Time dimension for percentiles and latency is not equal"); } JFreeChart chartLatencyPercentiles = ChartHelper.createStackedAreaChart(null, percentilesPair.getSecond(), latencyPair.getSecond(), "Time (" + latencyPair.getFirst() + ")", "Latency (sec)", ChartHelper.ColorTheme.LIGHT); taskPlot.setLatencyPlot(new JCommonDrawableRenderer(chartLatencyPercentiles)); taskPlots.put(taskId, taskPlot); } return taskPlots; }