List of usage examples for org.jfree.data.xy XYSeries XYSeries
public XYSeries(Comparable key)
From source file:com.att.aro.ui.view.diagnostictab.plot.BufferInSecondsPlot.java
@Override public void populate(XYPlot plot, AROTraceData analysis) { if (analysis != null) { VideoUsage videoUsage = analysis.getAnalyzerResult().getVideoUsage(); bufferFillDataCollection.removeAllSeries(); seriesBufferFill = new XYSeries("Buffer Against Play Time"); seriesDataSets = new TreeMap<>(); seriesDataSets = bufferInSecondsCalculatorImpl.populate(videoUsage, chunkPlayTimeList); //updating video stall result in packetAnalyzerResult analysis.getAnalyzerResult().setVideoStalls(bufferInSecondsCalculatorImpl.getVideoStallResult()); bufferTimeList.clear();/*w w w . j a va2s .c om*/ double xCoordinate, yCoordinate; String ptCoordinate[] = new String[2]; // to hold x & y values if (!seriesDataSets.isEmpty()) { for (int key : seriesDataSets.keySet()) { ptCoordinate = seriesDataSets.get(key).trim().split(","); xCoordinate = Double.parseDouble(ptCoordinate[0]); yCoordinate = Double.parseDouble(ptCoordinate[1]); bufferTimeList.add(yCoordinate); seriesBufferFill.add(xCoordinate, yCoordinate); } } Collections.sort(bufferTimeList); BufferTimeBPResult bufferTimeResult = bufferInSecondsCalculatorImpl .updateBufferTimeResult(bufferTimeList); analysis.getAnalyzerResult().setBufferTimeResult(bufferTimeResult); // populate collection bufferFillDataCollection.addSeries(seriesBufferFill); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { // Tooltip value Number timestamp = dataset.getX(series, item); Number bufferTime = dataset.getY(series, item); StringBuffer tooltipValue = new StringBuffer(); Map<Double, Long> segmentEndTimeMap = bufferInSecondsCalculatorImpl.getSegmentEndTimeMap(); Map<Long, Double> segmentStartTimeMap = bufferInSecondsCalculatorImpl.getSegmentStartTimeMap(); double firstSegmentNo = videoUsage.getChunksBySegmentNumber().get(0).getSegment(); DecimalFormat decimalFormat = new DecimalFormat("0.##"); if (segmentStartTimeMap == null || segmentStartTimeMap.isEmpty()) { return "-,-,-"; } List<Long> segmentList = new ArrayList<Long>(segmentEndTimeMap.values()); Collections.sort(segmentList); Long lastSegmentNo = segmentList.get(segmentList.size() - 1); Long segmentNumber = 0L; boolean isSegmentPlaying = false; boolean startup = false; boolean endPlay = false; for (double segmentEndTime : segmentEndTimeMap.keySet()) { if (segmentEndTime > timestamp.doubleValue()) { segmentNumber = segmentEndTimeMap.get(segmentEndTime); if (segmentNumber == firstSegmentNo) { startup = true; } if (segmentStartTimeMap.get(segmentNumber) <= timestamp.doubleValue()) { tooltipValue.append(decimalFormat.format(segmentNumber) + ","); isSegmentPlaying = true; startup = false; } } else if (lastSegmentNo.equals(segmentEndTimeMap.get(segmentEndTime)) && segmentEndTime == timestamp.doubleValue()) { endPlay = true; } } if (endPlay || startup) { tooltipValue.append("-,"); } else if (!isSegmentPlaying && !startup) { tooltipValue.append("Stall,"); } tooltipValue.append(String.format("%.2f", bufferTime) + "," + String.format("%.2f", timestamp)); String[] value = tooltipValue.toString().split(","); return (MessageFormat.format(BUFFER_TIME_OCCUPANCY_TOOLTIP, value[0], value[1], value[2])); } }); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesPaint(0, Color.MAGENTA); renderer.setSeriesShape(0, shape); plot.setRenderer(renderer); } plot.setDataset(bufferFillDataCollection); }
From source file:cs.register.geraGrafico.java
private XYSeriesCollection datasocore(List<partida> list1) { XYSeriesCollection data = new XYSeriesCollection(); XYSeries ser = new XYSeries("kda"); for (partida p : list1) { ser.add(list1.indexOf(p) + 1, p.getScore()); }/*from ww w . jav a2 s . co m*/ data.addSeries(ser); return data; }
From source file:edu.valelab.gaussianfit.fitting.ZCalibrator.java
public void plotDataPoints() { String xAxis = "Z (frame nr)"; XYSeries[] plotData = new XYSeries[2]; plotData[0] = new XYSeries("wx"); plotData[1] = new XYSeries("wy"); for (DataPoint d : data_) { plotData[0].add(d.z_, d.wx_);//from w w w.j a v a 2s .c o m plotData[1].add(d.z_, d.wy_); } GaussianUtils.plotDataN("Z-calibration Data Points", plotData, xAxis, "Width(nm)", 0, 400, true, false); }
From source file:eu.hydrologis.jgrass.charting.impl.JGrassXYBarChart.java
/** * A line chart creator basing on series made up two values per row. More series, independing * one from the other are supported./*from w w w . j ava 2 s. com*/ * * @param chartValues - a hashmap containing as keys the name of the series and as values the * double[][] representing the data. Important: the data matrix has to be passed as two * rows (not two columns) * @param barwidth */ public JGrassXYBarChart(LinkedHashMap<String, double[][]> chartValues, double barwidth) { chartSeries = new XYSeries[chartValues.size()]; // extrapolate the data from the Hashmap and convert it to a XYSeries // Collection Iterator<String> it = chartValues.keySet().iterator(); int count = 0; while (it.hasNext()) { String key = it.next(); double[][] values = chartValues.get(key); chartSeries[count] = new XYSeries(key); for (int i = 0; i < values[0].length; i++) { // important: the data matrix has to be passed as two rows (not // two columns) double val = values[1][i]; if (isNovalue(val)) continue; chartSeries[count].add(values[0][i], val); } count++; } barDataset = new XYSeriesCollection(); for (int i = 0; i < chartSeries.length; i++) { barDataset.addSeries(chartSeries[i]); } dataset = new XYBarDataset(barDataset, barwidth); }
From source file:org.jgrasstools.gears.utils.chart.Scatter.java
/** * Get {@link Series} to be populated./*from ww w . j a v a 2 s . co m*/ * * <p>Teh series is added to the dataset. * * @param seriesName the name of the series to add. * @return the {@link XYSeries} to use. */ public XYSeries getSeries(String seriesName) { XYSeries series = new XYSeries(seriesName); dataset.addSeries(series); return series; }
From source file:org.jfree.data.xy.XYSeriesTest.java
/** * Confirm that the equals method can distinguish all the required fields. *//* w w w. j a v a 2 s . c om*/ @Test public void testEquals() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("Series"); s2.add(1.0, 1.1); assertTrue(s1.equals(s2)); assertTrue(s2.equals(s1)); s1.setKey("Series X"); assertFalse(s1.equals(s2)); s2.setKey("Series X"); assertTrue(s1.equals(s2)); s1.add(2.0, 2.2); assertFalse(s1.equals(s2)); s2.add(2.0, 2.2); assertTrue(s1.equals(s2)); }
From source file:intelligentWebAlgorithms.util.gui.XyGui.java
public XyGui(String title, double[] x, double[] y) { super(title); errMsg = new StringBuilder(); setLoopInt(x.length);/* w ww . ja va2s . c om*/ if (checkX(x) && checkY(x.length, y)) { XYSeries xydata = new XYSeries(title); for (int i = 0; i < loopInt; i++) { xydata.add(x[i], y[i]); } XYSeriesCollection xycollection = new XYSeriesCollection(xydata); final JFreeChart chart = ChartFactory.createXYLineChart(title + " (XY Plot)", "X", "Y", xycollection, PlotOrientation.VERTICAL, true, true, false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); } else { System.err.println(errMsg.toString()); } }
From source file:intelligentWebAlgorithms.util.gui.ScatterGui.java
public ScatterGui(String title, double[] x, double[] y) { super(title); errMsg = new StringBuilder(); setLoopInt(x.length);// ww w .ja va 2s. co m if (checkX(x) && checkY(x.length, y)) { XYSeries xydata = new XYSeries(title); for (int i = 0; i < loopInt; i++) { xydata.add(x[i], y[i]); } XYSeriesCollection xycollection = new XYSeriesCollection(xydata); final JFreeChart chart = ChartFactory.createScatterPlot(title + " (Scatter Plot)", "X", "Y", xycollection, PlotOrientation.VERTICAL, true, true, false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); } else { System.err.println(errMsg.toString()); } }
From source file:opensonata.dataDisplays.BaselineImage.java
private JFreeChart createChart(String inFilename, String userTitle, NssBaseline nssBaseline) { XYSeries series = new XYSeries(""); float[] baselineValues = nssBaseline.getBaselineValues(); // plot subband values for (int i = 0; i < baselineValues.length; i++) { series.add(i, baselineValues[i]); }// w w w.j a v a 2 s . c o m System.err.println("HERE!!!!"); // add a final point at the end with a zero Y value, series.add(baselineValues.length, 0.0); XYDataset data = new XYSeriesCollection(series); String inFilenameBase = new File(inFilename).getName(); DecimalFormat freqFormatter = new DecimalFormat("0000.000 MHz "); String freqString = freqFormatter.format(nssBaseline.getCenterFreqMhz()); DecimalFormat bandwidthFormatter = new DecimalFormat("0.00 MHz "); String bandwidthString = bandwidthFormatter.format(nssBaseline.getBandwidthMhz()); String mainTitle = ""; String xAxisLabel = "Subband"; String yAxisLabel = "Power"; JFreeChart chart = ChartFactory.createXYLineChart(mainTitle, xAxisLabel, yAxisLabel, data, PlotOrientation.VERTICAL, false, // legend true, // tooltips false // urls ); String subTitle1 = "Baseline: "; if (!userTitle.equals("")) { subTitle1 += userTitle; } else { subTitle1 += inFilenameBase; } chart.addSubtitle(new TextTitle(subTitle1)); String subTitle2 = "Center Freq: " + freqString + "Bandwidth: " + bandwidthString; chart.addSubtitle(new TextTitle(subTitle2)); // move the data off of the axes // by extending the minimum axis value XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot(); double axisMarginPercent = 0.02; NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); valueAxis = (NumberAxis) plot.getDomainAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); return chart; }
From source file:edu.turtlekit2.tools.chart.ChartWindow.java
/** * Add a new Serie to a given chart.//from w w w. ja v a2 s . co m * @param chartName - the name of the chart. * @param serieName - the name of the new serie. */ public void addSerie(String chartName, String serieName) { final XYSeries series = new XYSeries(serieName); sets.get(chartName).addSeries(series); }