List of usage examples for org.jfree.data.xy XYSeries XYSeries
public XYSeries(Comparable key)
From source file:org.eumetsat.metop.visat.MhsInfoView.java
@Override protected XYSeries createSpectrumPlotXYSeries(double[] radiances) { final XYSeries series = new XYSeries(0); for (int i = 0; i < CHANNEL_FREQUENCIES.length; i++) { series.add(i + 1, BlackBody.temperatureAtFrequency(CHANNEL_FREQUENCIES[i], radiances[i] * 0.1)); }//from www . ja v a 2 s . c o m return series; }
From source file:se.lnu.cs.doris.metrics.SLOC.java
private void generateImage(ImageType type) throws Exception { if (this.m_mainDir == null) { throw new Exception("Base directory not set."); }//from w ww .ja va 2s . c om XYSeries linesOfCodeTotal = new XYSeries("Total lines"); XYSeries linesOfCode = new XYSeries("Lines of code"); XYSeries linesOfComments = new XYSeries("Lines of comments"); XYSeries baseLine = new XYSeries("index 100"); for (File f : this.m_mainDir.listFiles()) { if (f.isDirectory() && !f.getName().contains(this.m_avoid)) { int commitNumber = Utilities.parseInt(f.getName()); int slocd = 0; int slocmt = 0; int sloct = 0; for (File sd : f.listFiles()) { if (!sd.getName().toLowerCase().contains(this.m_avoid)) { slocd += this.countLines(sd, false); slocmt += this.countLines(sd, true); sloct += slocd + slocmt; } } if (this.m_baseValueTotal < 0) { this.m_baseValueTotal = sloct; this.m_baseValueComments = slocmt; this.m_baseValueCode = slocd; sloct = 100; slocmt = 100; slocd = 100; } else { sloct = (int) ((double) sloct / (double) this.m_baseValueTotal * 100); slocmt = (int) ((double) slocmt / (double) this.m_baseValueComments * 100); slocd = (int) ((double) slocd / (double) this.m_baseValueCode * 100); } linesOfCodeTotal.add(commitNumber, sloct); linesOfCode.add(commitNumber, slocd); linesOfComments.add(commitNumber, slocmt); baseLine.add(commitNumber, 100); } } XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(linesOfCodeTotal); collection.addSeries(linesOfCode); collection.addSeries(linesOfComments); collection.addSeries(baseLine); JFreeChart chart = ChartFactory.createXYLineChart( "Source lines of code change for " + this.m_projectName + " \nBase value code: " + this.m_baseValueCode + "\nBase value comments: " + this.m_baseValueComments, "Commit", "SLOC change %", collection, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setTickUnit(new NumberTickUnit(2)); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setTickUnit(new NumberTickUnit(10)); switch (type) { case JPEG: ChartUtilities.saveChartAsJPEG(new File(this.m_mainDir.getAbsolutePath(), "sloc_chart.jpg"), chart, 1000, 720); break; case PNG: ChartUtilities.saveChartAsPNG(new File(this.m_mainDir.getAbsolutePath(), "sloc_chart.png"), chart, 1000, 720); break; default: break; } }
From source file:syg_Wykresy.PanelRysunek_Wykres.java
private void initGUI() { try {/*from w ww .ja va2s .c om*/ GridLayout thisLayout = new GridLayout(1, 1); thisLayout.setHgap(5); thisLayout.setVgap(5); thisLayout.setColumns(1); this.setLayout(thisLayout); setPreferredSize(new Dimension(400, 300)); if (this.wykres) { XYSeries series = new XYSeries("Sygna " + (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY ? "cigy" : "dyskretny")); double punkt; double ta = this.sygnalWyswietlany.gett1(); if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY || sygnalWyswietlany.getPunktyY_wykres().size() <= 0) { punkt = this.sygnalWyswietlany.gett1(); while (ta <= this.sygnalWyswietlany.gett1() + this.sygnalWyswietlany.getd()) { punkt = this.sygnalWyswietlany.wykres_punkty(punkt, ta); this.sygnalWyswietlany.setPunktyY_wykres(punkt); series.add(ta, punkt); if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY) { if (this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10) ta = ta + this.sygnalWyswietlany.getkroczek(); else ta = ta + this.sygnalWyswietlany.getkroczek() * 10; } else { if (this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10) ta = ta + this.sygnalWyswietlany.getkrok(); else ta = ta + this.sygnalWyswietlany.getkrok() * 10; } } } else if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.DYSKRETNY && sygnalWyswietlany.getPunktyY_wykres().size() > 0) { int iloscProbek = (int) (this.sygnalWyswietlany.getPunktyY_wykres().size()); for (int i = 0; i < iloscProbek; i++) { punkt = this.sygnalWyswietlany.getPunktzindexu(i); series.add(ta, punkt); ta = ta + this.sygnalWyswietlany.getkrok(); } } XYSeriesCollection dataset = new XYSeriesCollection(series); JFreeChart chart; if ((this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10) && (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY)) { chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, true, true); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); } else { chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, true, true); final XYPlot plot = chart.getXYPlot(); final XYDotRenderer renderer = new XYDotRenderer(); renderer.setDotHeight(3); renderer.setDotWidth(3); plot.setRenderer(renderer); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } // JOptionPane.showMessageDialog(null, "Rysowanie wykresu...", // "PanelRysunek_Wykres", JOptionPane.INFORMATION_MESSAGE); ChartPanel chartpanel = new ChartPanel(chart); chartpanel.setDomainZoomable(true); this.add(chartpanel); } Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.encog.workbench.dialogs.training.ChartPane.java
/** * Construct the pane./*from w w w .j a v a2 s . co m*/ */ public ChartPane() { this.series1 = new XYSeries("Current Error"); this.dataset1 = new XYSeriesCollection(); this.dataset1.addSeries(this.series1); this.series1.setMaximumItemCount(50); this.series2 = new XYSeries("Error Improvement"); this.dataset2 = new XYSeriesCollection(); this.dataset2.addSeries(this.series2); this.series2.setMaximumItemCount(50); // addData(1,1,0.01); final JFreeChart chart = createChart(); this.chartPanel = new ChartPanel(chart); this.chartPanel.setPreferredSize(new java.awt.Dimension(600, 270)); this.chartPanel.setDomainZoomable(true); this.chartPanel.setRangeZoomable(true); setLayout(new BorderLayout()); add(this.chartPanel, BorderLayout.CENTER); }
From source file:ui.Graph.java
/** * Creates a chart.//from www .java 2s . co m * * @param dataset * the data for the chart. * * @return a chart. */ private JFreeChart createChart(ArrayList<Setpoint> setpoints, ArrayList<Setpoint> traj) { trajectory = traj; XYSeries posSeries = new XYSeries("Position"); XYSeries trajSeries = new XYSeries("Trajectory"); XYSeries velSeries = new XYSeries("Velocity"); for (int i = 0; i < setpoints.size(); i++) { Setpoint p = setpoints.get(i); posSeries.add(p.time, p.position); velSeries.add(p.time, p.velocity); } for (int i = 0; i < trajectory.size(); i++) { Setpoint p = trajectory.get(i); trajSeries.add(p.time, p.position); } XYSeriesCollection posDataset = new XYSeriesCollection(); XYSeriesCollection trajDataset = new XYSeriesCollection(); XYSeriesCollection velDataset = new XYSeriesCollection(); posDataset.addSeries(posSeries); velDataset.addSeries(velSeries); trajDataset.addSeries(trajSeries); // create the chart... final JFreeChart chart = ChartFactory.createScatterPlot("System output", // chart title "X", // x axis label "Y", // y axis label posDataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setDataset(0, posDataset); plot.setDataset(1, trajDataset); plot.setDataset(2, velDataset); plot.setBackgroundPaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer posRenderer = new XYLineAndShapeRenderer(); // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f, // 1.0f)); posRenderer.setSeriesPaint(0, Color.BLUE); posRenderer.setSeriesLinesVisible(0, true); posRenderer.setSeriesShapesVisible(0, false); XYStepRenderer trajRenderer = new XYStepRenderer(); trajRenderer.setSeriesPaint(1, Color.RED); trajRenderer.setSeriesStroke(1, new BasicStroke(10)); trajRenderer.setSeriesLinesVisible(1, true); trajRenderer.setSeriesShapesVisible(1, false); XYLineAndShapeRenderer velRenderer = new XYLineAndShapeRenderer(); velRenderer.setSeriesPaint(0, Color.MAGENTA); velRenderer.setSeriesLinesVisible(0, true); velRenderer.setSeriesShapesVisible(0, false); // renderer.setSeriesStroke(1, new BasicStroke(0.01f)); plot.setRenderer(0, posRenderer); plot.setRenderer(1, trajRenderer); plot.setRenderer(2, velRenderer); for (Setpoint s : trajectory) { Marker marker = new ValueMarker(s.time); marker.setPaint(Color.DARK_GRAY); marker.setLabel(Float.toString((float) s.position)); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(marker); } XYTextAnnotation p = new XYTextAnnotation("kP = " + gains.kP, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .75); p.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(p); XYTextAnnotation i = new XYTextAnnotation("kI = " + gains.kI, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .7); i.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(i); XYTextAnnotation d = new XYTextAnnotation("kD = " + gains.kD, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .65); d.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(d); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:serial.ChartFromSerial.java
/** * Creates new form JavaArduinoInterfacingAttempt *///from ww w.j a v a2 s . co m public ChartFromSerial() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println(e); } initComponents(); //set autoscroll autoScroll_chkBx.setSelected(true); autoScrollEnabled = true; //create the graph defaultSeries = new XYSeries(graphName); defaultDataset = new XYSeriesCollection(defaultSeries); defaultChart = ChartFactory.createXYLineChart(graphName, xAxisLabel, yAxisLabel, defaultDataset); graph = new ChartPanel(defaultChart); chartPanel.add(graph, BorderLayout.CENTER); graph.setVisible(true); //create the text log text = new JTextArea(); text.setEditable(false); textScrollPane = new JScrollPane(text); textScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); textPanel.add(textScrollPane, BorderLayout.CENTER); textScrollPane.setVisible(true); //Populate the combo box portNames = SerialPort.getCommPorts(); while (portNames.length == 0) { if (JOptionPane.showConfirmDialog(rootPane, "No connected devices found.\nWould you like to refresh?", "Could not connect to any devices.", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.NO_OPTION) { buttonsOff(); return; } else { portNames = SerialPort.getCommPorts(); } } portList_jCombo.removeAllItems(); for (SerialPort portName : portNames) { portList_jCombo.addItem(portName.getSystemPortName()); } }
From source file:eu.choreos.chart.XYChart.java
private void createDataset(XYSeriesCollection dataset, ScalabilityReport report) { XYSeries series = new XYSeries(report.getName()); double[] values = report.getSeries(); for (int i = 1; i < values.length; i++) { series.add((double) i, values[i]); }//w w w . j av a 2 s.c o m dataset.addSeries(series); }
From source file:IHM.NewClass.java
private XYDataset createDataset() { XYSeries s1 = new XYSeries("Temperature"); XYSeries s2 = new XYSeries("Humidit"); XYSeries s3 = new XYSeries("Nebulosit"); Controller c = new Controller(); // c.AfficherStationMoyenneTousLesJours(); for (ReleveMeteo i : c.getStationRecherchee()) { System.out.println(i.getTemperature()); if (i.getJour().getJour() == 0) { s1.add(Double.parseDouble("" + i.getMois().getMois()), Double.parseDouble(i.getTemperature())); s2.add(Double.parseDouble("" + i.getMois().getMois()), Double.parseDouble(i.getHumidite())); s3.add(Double.parseDouble("" + i.getMois().getMois()), Double.parseDouble(i.getNebulosite())); } else {/*from w w w. j av a 2 s. c om*/ s1.add(Double.parseDouble("" + i.getJour().getJour()), Double.parseDouble(i.getTemperature())); s2.add(Double.parseDouble("" + i.getJour().getJour()), Double.parseDouble(i.getHumidite())); s3.add(Double.parseDouble("" + i.getJour().getJour()), Double.parseDouble(i.getNebulosite())); } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); dataset.addSeries(s3); return dataset; }
From source file:openomr.dataanalysis.XYChart.java
public XYChart(int size, int data[], String name) { XYSeries series = new XYSeries(name); for (int i = 0; i < size; i += 1) series.add(i, data[i]);/* w ww . jav a 2 s . c om*/ XYDataset xyDataset = new XYSeriesCollection(series); chart = ChartFactory.createXYAreaChart(name, "width", "# Pixels", xyDataset, PlotOrientation.HORIZONTAL, true, false, false); }
From source file:net.sf.clichart.chart.XYChartBuilder.java
protected void initialiseSeriesColumn(String title) { XYSeries series = new XYSeries(title); m_seriesCollection.addSeries(series); }