List of usage examples for org.jfree.data.xy XYSeries XYSeries
public XYSeries(Comparable key)
From source file:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java
private XYDataset createDataset1() { XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); XYSeries team1_xy_data = new XYSeries("MAP1"); int k = 126;/*w w w .jav a 2 s .co m*/ for (BigDecimal d : cm.getMapQ()) { team1_xy_data.add(k, d.floatValue()); k++; } xySeriesCollection.addSeries(team1_xy_data); return xySeriesCollection; }
From source file:no.ntnu.mmfplanner.ui.graph.SaNpvChart.java
private void updateModel() { XYSeriesCollection dataset = new XYSeriesCollection(); XYPlot plot = ((XYPlot) getChart().getPlot()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // the x=0 line XYSeries line = new XYSeries(""); line.add(1.0, 0.0);//from www .ja va 2 s . com line.add(project.getPeriods(), 0.0); dataset.addSeries(line); // adds the line plot for each mmf int[][] saNpvValues = project.getSaNpvTable(); for (int mmfI = 0; mmfI < saNpvValues.length; mmfI++) { Mmf mmf = project.get(mmfI); XYSeries values = new XYSeries(mmf.getId() + ": " + mmf.getName()); for (int period = 1; period <= saNpvValues[mmfI].length; period++) { values.add(period, saNpvValues[mmfI][period - 1]); } dataset.addSeries(values); renderer.setSeriesShapesVisible(mmfI + 1, false); renderer.setSeriesStroke(mmfI + 1, SERIES_STROKE); renderer.setSeriesPaint(mmfI + 1, CHART_COLOR[mmfI % CHART_COLOR.length]); } plot.setDataset(dataset); }
From source file:de.fub.maps.project.plugins.tasks.eval.heading.HeadingHistogrammContainer.java
public void setEvaluationItems(List<EvalutationItem> roadNetworkStatisticList) { headingHistogramm1.getDataset().removeAllSeries(); int seriesIndex = 0; for (EvalutationItem item : roadNetworkStatisticList) { String name = item.getAggregator().getAggregatorDescriptor().getName(); XYSeries series = new XYSeries(name); Set<Road> roads = item.getRoadNetworkProcess().getResult().getRoads(); int[] historamm = new int[180]; for (Road road : roads) { ILocation lastLocation = null; ILocation secondLastLocation = null; int i = 0; for (ILocation location : road.getNodes()) { if (lastLocation != null && secondLastLocation != null && i < historamm.length) { double angleBetweenEdges = GPSCalc.getAngleBetweenEdges(lastLocation, secondLastLocation, secondLastLocation, location); int value = (int) angleBetweenEdges; if (value < historamm.length) { historamm[value]++; }// w w w . java2 s .c o m i++; } lastLocation = secondLastLocation; secondLastLocation = location; } } for (int j = 0; j < historamm.length; j++) { series.add(j, historamm[j] == 0 ? null : historamm[j] / (double) historamm.length); } headingHistogramm1.getDataset().addSeries(series); XYItemRenderer renderer = headingHistogramm1.getBarChart().getXYPlot().getRenderer(); if (renderer instanceof LayeredBarRenderer) { LayeredBarRenderer layeredBarRenderer = (LayeredBarRenderer) renderer; layeredBarRenderer.setSeriesBarWidth(seriesIndex, 1. / roadNetworkStatisticList.size() * (seriesIndex + 1)); } seriesIndex++; } }
From source file:erigo.filewatch.DisplayPlot.java
/** * Add all the data to a new XYDataset//from w w w .j a v a2 s.co m */ private XYDataset createDataset() { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("data"); for (int i = 0; i < xData.size(); ++i) { series.add(xData.get(i).doubleValue(), yData.get(i).doubleValue()); } //Add series to dataset dataset.addSeries(series); return dataset; }
From source file:logica_controladores.controlador_estadistica.java
public static void grafica_reorden(JPanel panel_grafica_orden, Inventario inventario, JLabel lbLinea) { XYSeries serie_2 = null;/* www .j a v a 2 s. c o m*/ XYDataset datos; JFreeChart linea; serie_2 = new XYSeries("graficas relacion gastos-reorden"); for (int i = 0; i < inventario.getGastos().size(); i++) { serie_2.add(inventario.getGastos().get(i).getReorden(), inventario.getGastos().get(i).getGastos()); } datos = new XYSeriesCollection(serie_2); linea = ChartFactory.createXYLineChart("grafica representativa de reordenes por corrida", "punto de orden", "gastos", datos, PlotOrientation.VERTICAL, true, true, true); BufferedImage graficoLinea = linea.createBufferedImage(panel_grafica_orden.getWidth(), panel_grafica_orden.getHeight()); lbLinea.setSize(panel_grafica_orden.getSize()); lbLinea.setIcon(new ImageIcon(graficoLinea)); panel_grafica_orden.updateUI(); }
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);/*from w ww. ja v a 2 s .c om*/ data3.addSeries(udp); 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:Servizi.GraficoJ.java
/** * Creo la serie di dati che rappresentano la fitness della linea * * @param label targhetta da stampare sul grafo * @param datiFitness dati contenenti il valore della media del valore di * fitness di ogni popolazione// w w w . java 2s . c om * @param fitnessLinea valore di fitness della linea da generare * @return serie di valori per riempimento grafo */ private XYSeries riempiDataLinea(String label, Double[] datiFitness, Double fitnessLinea) { XYSeries serie = new XYSeries(label); for (int i = 0; i < datiFitness.length; i++) { serie.add(i, fitnessLinea); } return serie; }
From source file:utils.ChartUtils.java
/** * Update XY chart/* w w w . j av a 2s . c o m*/ * * @param plot ChartPanel Plot * @param sortedArray Sorted array of values */ public static void updateXYChart(ChartPanel plot, double[] sortedArray) { XYPlot xyplot = plot.getChart().getXYPlot(); double min = sortedArray[0]; double max = sortedArray[sortedArray.length - 1]; double median = Utils.getMedian(sortedArray); double q1 = Utils.getQ1(sortedArray); double q3 = Utils.getQ3(sortedArray); XYTextAnnotation annotation; //min-lowlimit horizontal XYSeries serie15 = new XYSeries("15"); serie15.add(min, 0.5); //max-toplimit horizontal XYSeries serie16 = new XYSeries("16"); serie16.add(max, 0.5); //min vertical XYSeries serie1 = new XYSeries("0"); serie1.add(min, 0.45); serie1.add(min, 0.55); annotation = new XYTextAnnotation("Min", min, 0.40); annotation.setFont(new Font("SansSerif", Font.PLAIN, 11)); xyplot.addAnnotation(annotation); //min-q1 horizontal XYSeries serie2 = new XYSeries("1"); serie2.add(min, 0.5); serie2.add(q1, 0.5); //q1 vertical XYSeries serie3 = new XYSeries("2"); serie3.add(q1, 0.1); serie3.add(q1, 0.9); annotation = new XYTextAnnotation("Q1", q1, 0.08); annotation.setFont(new Font("SansSerif", Font.PLAIN, 11)); xyplot.addAnnotation(annotation); // median XYSeries serie_mediana = new XYSeries("11"); serie_mediana.add(median, 0.1); serie_mediana.add(median, 0.9); annotation = new XYTextAnnotation("Median", median, 0.04); annotation.setFont(new Font("SansSerif", Font.PLAIN, 11)); xyplot.addAnnotation(annotation); //q1-q3 horizontal sup XYSeries serie4 = new XYSeries("3"); serie4.add(q1, 0.9); serie4.add(q3, 0.9); //q1-q3 horizontal inf XYSeries serie5 = new XYSeries("4"); serie5.add(q1, 0.1); serie5.add(q3, 0.1); //q3 vertical XYSeries serie6 = new XYSeries("5"); serie6.add(q3, 0.1); serie6.add(q3, 0.9); annotation = new XYTextAnnotation("Q3", q3, 0.08); annotation.setFont(new Font("SansSerif", Font.PLAIN, 11)); xyplot.addAnnotation(annotation); //q3-max horizontal XYSeries serie7 = new XYSeries("6"); serie7.add(q3, 0.5); serie7.add(max, 0.5); //max vertical XYSeries serie8 = new XYSeries("7"); serie8.add(max, 0.45); serie8.add(max, 0.55); annotation = new XYTextAnnotation("Max", max, 0.4); annotation.setFont(new Font("SansSerif", Font.PLAIN, 11)); xyplot.addAnnotation(annotation); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(serie1); xyseriescollection.addSeries(serie2); xyseriescollection.addSeries(serie3); xyseriescollection.addSeries(serie4); xyseriescollection.addSeries(serie5); xyseriescollection.addSeries(serie6); xyseriescollection.addSeries(serie7); xyseriescollection.addSeries(serie8); xyseriescollection.addSeries(serie15); xyseriescollection.addSeries(serie16); xyseriescollection.addSeries(serie_mediana); xyplot.getRenderer().setSeriesPaint(9, Color.black); xyplot.getRenderer().setSeriesPaint(10, Color.black); xyplot.getRenderer().setSeriesPaint(0, Color.black); xyplot.getRenderer().setSeriesPaint(1, Color.black); xyplot.getRenderer().setSeriesPaint(2, Color.black); xyplot.getRenderer().setSeriesPaint(3, Color.black); xyplot.getRenderer().setSeriesPaint(4, Color.black); xyplot.getRenderer().setSeriesPaint(5, Color.black); xyplot.getRenderer().setSeriesPaint(6, Color.black); xyplot.getRenderer().setSeriesPaint(7, Color.black); xyplot.getRenderer().setSeriesPaint(8, Color.black); xyplot.getRenderer().setSeriesPaint(9, Color.black); xyplot.getRenderer().setSeriesPaint(10, Color.black); xyplot.getRenderer().setSeriesPaint(11, Color.black); xyplot.getRenderer().setSeriesPaint(12, Color.black); xyplot.getRenderer().setSeriesPaint(13, Color.black); //add dataset xyplot.setDataset(xyseriescollection); // add a second dataset and renderer... XYSeriesCollection anotherserie = new XYSeriesCollection(); XYSeries serie_point = new XYSeries("21"); double[] yValue = { 0.47, 0.49, 0.51, 0.53 }; for (int i = 0, j = 0; i < sortedArray.length; i++, j++) { if (j % 4 == 0) { j = 0; } serie_point.add(sortedArray[i], yValue[j]); } anotherserie.addSeries(serie_point); XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(false, true); renderer1.setSeriesPaint(0, Color.lightGray); xyplot.setDataset(1, anotherserie); xyplot.setRenderer(1, renderer1); }
From source file:Result3.java
public void createGraphs() { XYSeries a_data = new XYSeries("A"); XYSeries c_data = new XYSeries("C"); XYSeries g_data = new XYSeries("G"); XYSeries t_data = new XYSeries("T"); for (int i = 0; i < a.length; i++) { a_data.add(i, a[i]);/* w w w . j a v a 2 s . com*/ c_data.add(i, c[i]); g_data.add(i, g[i]); t_data.add(i, t[i]); } XYSeriesCollection my_data_series = new XYSeriesCollection(); my_data_series.addSeries(a_data); my_data_series.addSeries(c_data); my_data_series.addSeries(g_data); my_data_series.addSeries(t_data); JFreeChart XYLineChart = ChartFactory.createXYLineChart("Frequency Table", "Position", "No. of Occurences", my_data_series, PlotOrientation.VERTICAL, true, true, false); bImage1 = (BufferedImage) XYLineChart.createBufferedImage(690, 337); ImageIcon imageIcon1 = new ImageIcon(bImage1); jLabel1.setIcon(imageIcon1); }
From source file:edu.ucla.stat.SOCR.chart.demo.MultiIndexChart.java
/** * Creates a sample dataset./* w ww . j a v a 2 s .c o m*/ * * @return a sample dataset. */ protected XYDataset createDataset1(boolean isDemo) { if (isDemo) { row_count = 11; raw_x2 = new String[2][row_count]; /*raw_x2[0][0] = "1.0"; raw_x2[0][1] = "2.0"; raw_x2[0][2] = "3.0"; raw_x2[0][3] = "4.0"; raw_x2[0][4] = "5.0"; raw_x2[0][5] = "6.0"; raw_x2[0][6] = "76.0"; raw_x2[0][7] = "78.0"; raw_x2[0][8] = "7.0"; raw_x2[0][9] = "8.0"; raw_x2[1][0] = "1.0"; raw_x2[1][1] = "3.0"; raw_x2[1][2] = "5.0"; raw_x2[1][3] = "9.0"; raw_x2[1][4] = "7.0"; raw_x2[1][5] = "4.0"; raw_x2[1][6] = "70.0"; raw_x2[1][7] = "30.0"; raw_x2[1][8] = "9.0"; raw_x2[1][9] = "7.0";raw_x2[1][10] = "20.0"; */ XYSeries series1 = new XYSeries("Data 1"); series1.add(1, 1.0); series1.add(2, 2.0); series1.add(3, 3.0); series1.add(4, 4.0); series1.add(5, 5.0); series1.add(6, 6.0); series1.add(7, 76.0); series1.add(8, 78.0); series1.add(9, 7.0); series1.add(10, 8.0); for (int i = 0; i < 10; i++) raw_x2[0][i] = series1.getY(i).toString(); XYSeries series2 = new XYSeries("Data 2"); series2.add(1, 1.0); series2.add(2, 3.0); series2.add(3, 5.0); series2.add(4, 9.0); series2.add(5, 7.0); series2.add(6, 4.0); series2.add(7, 70.0); series2.add(8, 30.0); series2.add(9, 9.0); series2.add(10, 7.0); series2.add(11, 20.0); for (int i = 0; i < 11; i++) raw_x2[1][i] = series2.getY(i).toString(); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); return dataset; } else return super.createDataset(false); }