List of usage examples for org.jfree.data.xy XYSeriesCollection XYSeriesCollection
public XYSeriesCollection()
From source file:org.jfree.data.xy.IntervalXYDelegateTest.java
/** * Confirm that cloning works.//from ww w .j a v a2 s . co m */ @Test public void testCloning() throws CloneNotSupportedException { XYSeries s1 = new XYSeries("Series"); s1.add(1.2, 3.4); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); IntervalXYDelegate d1 = new IntervalXYDelegate(c1); IntervalXYDelegate d2 = (IntervalXYDelegate) d1.clone(); assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); }
From source file:com.googlecode.logVisualizer.chart.MPGainedSpentPerTurnXYBarChart.java
@Override protected IntervalXYDataset createDataset() { final XYSeriesCollection datasets = new XYSeriesCollection(); if (getLogData().isDetailedLog()) { final XYSeries gainedDataset = new XYSeries("MP gained", false); final XYSeries spentDataset = new XYSeries("MP spent", false); for (final SingleTurn st : getLogData().getTurnsSpent()) { gainedDataset.add(st.getTurnNumber(), st.getMPGain().getTotalMPGains()); int spentMP = 0; for (final Skill s : st.getSkillsCast()) spentMP += s.getMpCost(); spentDataset.add(st.getTurnNumber(), spentMP); }/*ww w .j av a2 s.c om*/ datasets.addSeries(spentDataset); datasets.addSeries(gainedDataset); } return datasets; }
From source file:graphique.GrapheCourse.java
/** * Genere un graphe pour une course/* ww w. j a v a 2 s . c om*/ * @param nomC String */ public void genererGraphe(String nomC) { XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < lesVoitures.length; i++) { // Create a simple XY chart XYSeries series = new XYSeries("Voiture " + lesVoitures[i]); int[] temps = this.getTempsDeCourse(lesVoitures[i]); //1er tours series.add(1, temps[0]); for (int j = 1; j < nbTours; j++) { if (temps[j] != 0) { series.add(j + 1, (temps[j] - temps[j - 1])); } else { series.add(j + 1, 0); } } // Add the series to your data set dataset.addSeries(series); } // Generate the graph chart = ChartFactory.createXYLineChart("Rsultat de la course " + nomC, // Title "tours", // x-axis Label "temps ms", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); }
From source file:edu.fullerton.viewerplugin.TsPlot.java
@Override public ArrayList<Integer> makePlot(ArrayList<ChanDataBuffer> dbufs, boolean compact) throws WebUtilException { int imageId;/*from w ww . j a v a2 s . c o m*/ try { if (parameterMap.containsKey("ts_newplt")) { imageId = makeAddPlotFiles(dbufs, compact); } else { String gtitle = getTitle(dbufs, compact); XYSeriesCollection xyds = new XYSeriesCollection(); TimeSeriesCollection mtds = new TimeSeriesCollection(); compact = dbufs.size() > 2 ? false : compact; for (ChanDataBuffer dbuf : dbufs) { if (timeAxis.equalsIgnoreCase("utc")) { addTimeSeries(dbuf, compact, mtds); } else { addXySeries(dbuf, compact, xyds); } } Double minx, miny, maxx, maxy; Double[] rng = new Double[4]; if (timeAxis.equalsIgnoreCase("utc")) { PluginSupport.getRangeLimits(mtds, rng); } else { PluginSupport.getRangeLimits(xyds, rng, 0); } minx = rng[0]; miny = rng[1]; maxx = rng[2]; maxy = rng[3]; int exp; if (timeAxis.equalsIgnoreCase("utc")) { exp = PluginSupport.scaleRange(mtds, miny, maxy); } else { exp = PluginSupport.scaleRange(xyds, miny, maxy); } ChartPanel cpnl; DefaultXYDataset ds = new DefaultXYDataset(); JFreeChart chart; if (timeAxis.equalsIgnoreCase("utc")) { chart = ChartFactory.createTimeSeriesChart(gtitle, "Time (UTC)", "Amplitude (Counts)", ds, true, true, false); } else { chart = ChartFactory.createXYLineChart(gtitle, xAxisLabel, "Amplitude (Counts)", ds, PlotOrientation.VERTICAL, true, false, false); } XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis rangeAxis = new NumberAxis("Amplitude (Counts)"); ScaledAxisNumberFormat sanf = new ScaledAxisNumberFormat(); sanf.setExp(exp); if (maxy != 0 && Math.abs(maxy - miny) <= Math.abs(maxy) * 1e-25) { // this garbage is to get jFreeChart to put labels on the Y axis double dt = Math.abs(miny) / 10; double scaledMin = (miny - dt) * Math.pow(10., exp); double scaledMax = (maxy + dt) * Math.pow(10., exp); rangeAxis.setRange(scaledMin, scaledMax); NumberTickUnit unit = new NumberTickUnit((scaledMax - scaledMin) / 10.); rangeAxis.setTickUnit(unit); rangeAxis.setAutoRange(false); } // else // { // sanf.setMinMax(miny, maxy); // rangeAxis.setRange(miny, maxy); // NumberTickUnit unit = new NumberTickUnit((maxy - miny)/6.); // rangeAxis.setTickUnit(unit); // rangeAxis.setAutoRange(false); // } rangeAxis.setNumberFormatOverride(sanf); rangeAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(rangeAxis); if (timeAxis.equalsIgnoreCase("utc")) { plot.setDataset(0, mtds); } else { plot.setDataset(0, xyds); } // Set the line thickness XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); BasicStroke str = new BasicStroke(lineThickness); int n = plot.getSeriesCount(); for (int i = 0; i < n; i++) { r.setSeriesStroke(i, str); } plot.setBackgroundPaint(Color.WHITE); // add plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); r.setBaseFillPaint(Color.WHITE); if (compact) { chart.removeLegend(); } chart.setBackgroundPaint(Color.WHITE); cpnl = new ChartPanel(chart); imageId = saveImageAsPNG(cpnl); } } catch (LdvTableException | NoSuchAlgorithmException | SQLException | IOException ex) { throw new WebUtilException("Making time series plot: ", ex); } ArrayList<Integer> ret = new ArrayList<Integer>(); ret.add(imageId); return ret; }
From source file:celeste.Celeste.java
public void todasPosiciones(double t) { XYSeriesCollection coleccion = new XYSeriesCollection(); for (int i = 0; i < planetas.size(); i++) { String name = planetas.get(i)[0]; double a = Double.parseDouble(planetas.get(i)[1]); double epsilon = Double.parseDouble(planetas.get(i)[2]); double p = Double.parseDouble(planetas.get(i)[3]); Planeta planeta = new Planeta(a, epsilon, p); XYSeries serie2 = planeta.generarPosiciones(); serie2.setKey(name);//from w ww.j ava 2 s . c o m Vector pos = planeta.posicion(t); XYSeries serie = new XYSeries(name + " en t"); serie.add(pos.getX1(), pos.getX2()); coleccion.addSeries(serie2); coleccion.addSeries(serie); } generarGrafica(coleccion, true); }
From source file:edu.fullerton.viewerplugin.XYPlotter.java
private ChartPanel getPanel(double[][] data) throws WebUtilException { ChartPanel ret = null;/* w w w . j a v a2 s. com*/ try { XYSeries xys; XYSeriesCollection mtds = new XYSeriesCollection(); String mylegend = legend == null || legend.isEmpty() ? "series 1" : legend; xys = new XYSeries(legend); int len = data.length; double minx = Double.MAX_VALUE; double maxx = Double.MIN_VALUE; double miny = Double.MAX_VALUE; double maxy = Double.MIN_VALUE; boolean gotZeroX = false; boolean gotZeroY = false; for (int i = 0; i < len; i++) { double x = data[i][0]; double y = data[i][1]; if (x == 0) { gotZeroX = true; } else { minx = Math.min(minx, x); maxx = Math.max(maxx, x); } if (y == 0) { gotZeroY = true; } else { miny = Math.min(miny, y); maxy = Math.max(maxy, y); } } // this kludge lets us plot a 0 on a log axis double fakeZeroX = 0.; double fakeZeroY = 0.; if (gotZeroX) { if (logXaxis) { fakeZeroX = minx / 10; } else { minx = Math.min(0, minx); maxx = Math.max(0, maxx); } } if (gotZeroY) { if (logYaxis) { fakeZeroY = miny / 10; } else { miny = Math.min(0, miny); maxy = Math.max(0, maxy); } } for (int i = 0; i < len; i++) { double x = data[i][0]; double y = data[i][1]; x = x == 0 ? fakeZeroX : x; y = y == 0 ? fakeZeroY : y; xys.add(x, y); } mtds.addSeries(xys); DefaultXYDataset ds = new DefaultXYDataset(); int exp; if (maxy == 0. && miny == 0.) { miny = -1.; exp = 0; logYaxis = false; } else { maxy = maxy > miny ? maxy : miny * 10; exp = PluginSupport.scaleRange(mtds, miny, maxy); if (!logYaxis && exp > 0) { yLabel += " x 1e-" + Integer.toString(exp); } } JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, ds, PlotOrientation.VERTICAL, true, false, false); org.jfree.chart.plot.XYPlot plot = (org.jfree.chart.plot.XYPlot) chart.getPlot(); if (logYaxis) { LogAxis rangeAxis = new LogAxis(yLabel); double smallest = miny * Math.pow(10, exp); rangeAxis.setSmallestValue(smallest); rangeAxis.setMinorTickCount(9); LogAxisNumberFormat lanf = new LogAxisNumberFormat(); lanf.setExp(exp); rangeAxis.setNumberFormatOverride(lanf); rangeAxis.setRange(smallest, maxy * Math.pow(10, exp)); plot.setRangeAxis(rangeAxis); } if (logXaxis) { LogAxis domainAxis = new LogAxis(xLabel); domainAxis.setMinorTickCount(9); domainAxis.setSmallestValue(minx); domainAxis.setNumberFormatOverride(new LogAxisNumberFormat()); plot.setDomainAxis(domainAxis); } ValueAxis domainAxis = plot.getDomainAxis(); if (fmin != null && fmin > 0) { domainAxis.setLowerBound(fmin); } if (fmax != null && fmax > 0) { domainAxis.setUpperBound(fmax); } plot.setDomainAxis(domainAxis); plot.setDataset(0, mtds); // Set the line thickness XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); BasicStroke str = new BasicStroke(lineThickness); int n = plot.getSeriesCount(); for (int i = 0; i < n; i++) { r.setSeriesStroke(i, str); } if (legend == null || legend.isEmpty()) { chart.removeLegend(); } ret = new ChartPanel(chart); } catch (Exception ex) { throw new WebUtilException("Creating spectrum plot" + ex.getLocalizedMessage()); } return ret; }
From source file:Similaridade.GraficosSimilaridade.java
public static XYDataset newDataset2OndasComDeslocada(CapturaAtual onda1, CapturaAtual onda2, int deslocamento, double correlacao) { //metodo que cria um CategoryDataset para ser usado em grafico de linhas float valOnda1[] = new float[Configuracoes.PONTOSONDA]; float valOnda2[] = new float[Configuracoes.PONTOSONDA]; float sen1[] = new float[Configuracoes.HARMONICAS]; float cos1[] = new float[Configuracoes.HARMONICAS]; float sen2[] = new float[Configuracoes.HARMONICAS]; float cos2[] = new float[Configuracoes.HARMONICAS]; int i;/* w w w .ja va2 s . co m*/ float s1, s2, tempo[] = new float[Configuracoes.PONTOSONDA]; XYSeriesCollection result = new XYSeriesCollection(); for (i = 0; i < Configuracoes.HARMONICAS; i++) { sen1[i] = 0; cos1[i] = 0; sen2[i] = 0; cos2[i] = 0; } i = 0; for (HarmAtual oa : onda1.getHarmAtual()) { sen1[i] = oa.getSen(); cos1[i] = oa.getCos(); i++; } i = 0; for (HarmAtual oa : onda2.getHarmAtual()) { sen2[i] = oa.getSen(); cos2[i] = oa.getCos(); i++; } XYSeries series1 = new XYSeries(String.valueOf(onda1.getCodCaptura())); XYSeries series3 = new XYSeries("Shift " + String.valueOf(onda2.getCodCaptura())); tempo[0] = 0; //(float) 1 / 60; for (i = 0; i < Configuracoes.PONTOSONDA; i++) { if (TIRADOVM == 0) { s1 = onda1.getValorMedio() / 2; s2 = onda2.getValorMedio() / 2; } else { s1 = onda1.getValorMedio(); s2 = onda2.getValorMedio(); } for (int x = 0; x < Configuracoes.HARMONICAS; x++) { if (TIRADOVM == 0) { s1 += (float) (sen1[x] * Math.sin(2 * Math.PI * ((x + 1) * Configuracoes.FREQBASE) * tempo[i])) + (cos1[x] * Math.cos(-2 * Math.PI * ((x + 1) * Configuracoes.FREQBASE) * tempo[i])); s2 += (float) (sen2[x] * Math.sin(2 * Math.PI * ((x + 1) * Configuracoes.FREQBASE) * tempo[i])) + (cos2[x] * Math.cos(-2 * Math.PI * ((x + 1) * Configuracoes.FREQBASE) * tempo[i])); } else { s1 += (float) (sen1[x] * Math.sin(2 * Math.PI * ((x + 1) * Configuracoes.FREQBASE) * tempo[i])) + (cos1[x] * Math.cos(2 * Math.PI * ((x + 1) * Configuracoes.FREQBASE) * tempo[i])); s2 += (float) (sen2[x] * Math.sin(2 * Math.PI * ((x + 1) * Configuracoes.FREQBASE) * tempo[i])) + (cos2[x] * Math.cos(2 * Math.PI * ((x + 1) * Configuracoes.FREQBASE) * tempo[i])); } } if (TIRADOVM == 0) { valOnda1[i] = (int) ((s1 * (2.0)) / 256.0); valOnda1[i] = (valOnda1[i] - onda1.getOffset()); valOnda2[i] = (int) ((s2 * (2.0)) / 256.0); valOnda2[i] = (valOnda2[i] - onda2.getOffset()); } else { valOnda1[i] = (s1); valOnda2[i] = (s2); } valOnda1[i] = (valOnda1[i]) / onda1.getGain(); valOnda2[i] = (valOnda2[i]) / onda2.getGain(); series1.add(tempo[i] * 1000, valOnda1[i]); if (i == (Configuracoes.PONTOSONDA - 1)) { break; } tempo[i + 1] = (tempo[i] + (float) (1.0 / (60 * 256))); } int j = 0; if (correlacao < 0) { for (i = 0; i < Configuracoes.PONTOSONDA; i++) { if ((i + deslocamento) <= (Configuracoes.PONTOSONDA - 1)) { series3.add(tempo[i] * 1000, -1 * valOnda2[i + deslocamento]); } else { series3.add(tempo[i] * 1000, -1 * valOnda2[j++]); } } } else { for (i = 0; i < Configuracoes.PONTOSONDA; i++) { if ((i + deslocamento) <= (Configuracoes.PONTOSONDA - 1)) { series3.add(tempo[i] * 1000, valOnda2[i + deslocamento]); } else { series3.add(tempo[i] * 1000, valOnda2[j++]); } } } result.addSeries(series1); result.addSeries(series3); return result; }
From source file:fungus.UtilizationChartFrame.java
public UtilizationChartFrame(String prefix) { simulationCycles = Configuration.getDouble(PAR_SIMULATION_CYCLES); this.setTitle("MycoNet Statistics Chart"); graph = JungGraphObserver.getGraph(); //data.add(-1,0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.setAutoWidth(false);/* ww w.j a va 2 s .c om*/ dataset.setIntervalWidth(simulationCycles); averageUtilizationData = new XYSeries("Average Utilization"); dataset.addSeries(averageUtilizationData); averageStableUtilizationData = new XYSeries("Avg Stable Util"); dataset.addSeries(averageStableUtilizationData); hyphaRatioData = new XYSeries("Hypha Ratio"); dataset.addSeries(hyphaRatioData); stableHyphaRatioData = new XYSeries("Stable Hypha Ratio"); dataset.addSeries(stableHyphaRatioData); //XYSeriesCollection dataset; JFreeChart utilizationChart = ChartFactory.createXYLineChart("Utilization Metrics", "Cycle", "Average Utilization", dataset, PlotOrientation.VERTICAL, true, false, false); ChartPanel utilizationChartPanel = new ChartPanel(utilizationChart); //chart.setBackgroundPaint(Color.white); //XYPlot plot = chart.getXYPlot(); // BufferedImage chartImage = chart.createBufferedImage(500,300); // chartLabel = new JLabel(); //chartLabel.setIcon(new ImageIcon(chartImage)); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); JPanel labelPane = new JPanel(); labelPane.setLayout(new GridLayout(1, 1)); //chartPane.setPreferredSize(new java.awt.Dimension(500, 300)); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); ////contentPane.add(labelPane,BorderLayout.PAGE_START); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); contentPane.add(utilizationChartPanel, BorderLayout.CENTER); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); ////contentPane.add(buttonPane, BorderLayout.PAGE_END); //data = node.getHyphaData(); //link = node.getHyphaLink(); //mycocast = node.getMycoCast(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //chartPanel.add(chartLabel); /*JButton updateButton = new JButton("Refresh"); ActionListener updater = new ActionListener() { public void actionPerformed(ActionEvent e) { refreshData(); } }; updateButton.addActionListener(updater); JButton closeButton = new JButton("Close"); ActionListener closer = new ActionListener() { public void actionPerformed(ActionEvent e) { closeFrame(); } }; closeButton.addActionListener(closer); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(updateButton); buttonPane.add(Box.createRigidArea(new Dimension(5,0))); buttonPane.add(closeButton); refreshData(); */ //JungGraphObserver.addChangeListener(this); this.pack(); this.setVisible(true); }
From source file:cs.register.geraGrafico.java
private XYSeriesCollection datakill(List<partida> list1) { XYSeriesCollection data = new XYSeriesCollection(); XYSeries ser = new XYSeries("kda"); for (partida p : list1) { ser.add(list1.indexOf(p) + 1, p.getKill()); }/*from www . j a v a 2 s . c o m*/ data.addSeries(ser); return data; }
From source file:guineu.modules.filter.Alignment.RANSAC.AlignmentRansacPlot.java
public AlignmentRansacPlot() { super(null, true); dataset = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart("", null, null, dataset, PlotOrientation.VERTICAL, true, true, false);/*from ww w . j ava2 s . c om*/ chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // legend constructed by ChartFactory legend = chart.getLegend(); legend.setItemFont(legendFont); // legend.setFrame(BlockBorder.NONE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // set default renderer properties XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseLinesVisible(false); renderer.setBaseShapesVisible(true); renderer.setSeriesShape(0, dataPointsShape); renderer.setSeriesShape(1, dataPointsShape); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GRAY); renderer.setSeriesPaint(2, Color.BLUE); renderer.setBaseItemLabelPaint(labelsColor); plot.setRenderer(renderer); }