List of usage examples for org.jfree.data.time TimeSeries addOrUpdate
public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, Number value)
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.SurefireTimeChartStrategy.java
public void fillDataset() { TimeSeries s1 = new TimeSeries(this.bundle.getString("report.surefire.label.tests"), this.periodClass); TimeSeries s2 = new TimeSeries(this.bundle.getString("report.surefire.label.errors"), this.periodClass); TimeSeries s3 = new TimeSeries(this.bundle.getString("report.surefire.label.failures"), this.periodClass); TimeSeries s4 = new TimeSeries(this.bundle.getString("report.surefire.label.skipped"), this.periodClass); Iterator iter = mResults.iterator(); while (iter.hasNext()) { SurefireReportBean surefire = (SurefireReportBean) iter.next(); Date date = surefire.getDateGeneration(); s1.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), surefire.getNbTests()); s2.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), surefire.getNbErrors()); s3.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), surefire.getNbFailures()); s4.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), surefire.getNbSkipped()); }/*w w w .j av a2s . c o m*/ defaultdataset.addSeries(s1); defaultdataset.addSeries(s2); defaultdataset.addSeries(s3); defaultdataset.addSeries(s4); }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.FindBugsTimeChartStrategy.java
public void fillDataset() { TimeSeries s1 = new TimeSeries(this.bundle.getString("report.findbugs.label.nbclasses"), this.periodClass); TimeSeries s2 = new TimeSeries(this.bundle.getString("report.findbugs.label.nbbugs"), this.periodClass); TimeSeries s3 = new TimeSeries(this.bundle.getString("report.findbugs.label.nberrors"), this.periodClass); TimeSeries s4 = new TimeSeries(this.bundle.getString("report.findbugs.label.nbMissingClasses"), this.periodClass); Iterator iter = mResults.iterator(); while (iter.hasNext()) { FindBugsReportBean findbugs = (FindBugsReportBean) iter.next(); Date date = findbugs.getDateGeneration(); s1.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), findbugs.getNbClasses()); s2.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), findbugs.getNbBugs()); s3.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), findbugs.getNbErrors()); s4.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), findbugs.getNbMissingClasses()); }//from w ww . j ava 2 s . c o m defaultdataset.addSeries(s1); defaultdataset.addSeries(s2); defaultdataset.addSeries(s3); defaultdataset.addSeries(s4); }
From source file:org.yccheok.jstock.gui.SellPortfolioTimeChartJDialog.java
private JFreeChart createChart(String name) { final JStockOptions jStockOptions = MainFrame.getInstance().getJStockOptions(); final boolean isFeeCalculationEnabled = jStockOptions.isFeeCalculationEnabled(); final boolean isPenceToPoundConversionEnabled = jStockOptions.isPenceToPoundConversionEnabled(); final Portfolio portfolio = (Portfolio) portfolioTreeTableModel.getRoot(); final int count = portfolio.getChildCount(); final List<DataEx> dataExs = new ArrayList<DataEx>(); for (int i = 0; i < count; i++) { TransactionSummary transactionSummary = (TransactionSummary) portfolio.getChildAt(i); if (transactionSummary.getChildCount() <= 0) { continue; }//ww w.j av a2 s. c o m Transaction transaction = (Transaction) transactionSummary.getChildAt(0); final Date date = transaction.getDate().getTime(); if (name.equals(cNames[2]) || name.equals(cNames[3])) { this.isCumulativeChart = true; } else { this.isCumulativeChart = false; } /* Should use reflection technology. */ if (name.equals(cNames[0]) || name.equals(cNames[2])) { if (isPenceToPoundConversionEnabled == false) { if (isFeeCalculationEnabled) { dataExs.add(DataEx.newInstance(date, portfolioTreeTableModel.getNetGainLossValue(transactionSummary))); } else { dataExs.add(DataEx.newInstance(date, portfolioTreeTableModel.getGainLossValue(transactionSummary))); } } else { if (isFeeCalculationEnabled) { dataExs.add(DataEx.newInstance(date, portfolioTreeTableModel.getNetGainLossValue(transactionSummary) / 100.0)); } else { dataExs.add(DataEx.newInstance(date, portfolioTreeTableModel.getGainLossValue(transactionSummary) / 100.0)); } } } else if (name.equals(cNames[1]) || name.equals(cNames[3])) { if (isPenceToPoundConversionEnabled == false) { if (isFeeCalculationEnabled) { dataExs.add(DataEx.newInstance(date, -portfolioTreeTableModel.getNetGainLossValue(transactionSummary))); } else { dataExs.add(DataEx.newInstance(date, -portfolioTreeTableModel.getGainLossValue(transactionSummary))); } } else { if (isFeeCalculationEnabled) { dataExs.add(DataEx.newInstance(date, -portfolioTreeTableModel.getNetGainLossValue(transactionSummary) / 100.0)); } else { dataExs.add(DataEx.newInstance(date, -portfolioTreeTableModel.getGainLossValue(transactionSummary) / 100.0)); } } } } Collections.sort(dataExs); TimeSeries series = new TimeSeries(name); double totalValue = 0; for (DataEx dataEx : dataExs) { double value = dataEx.value; if (!this.isCumulativeChart && series.getValue(new Day(dataEx.date)) != null) { value += series.getValue(new Day(dataEx.date)).doubleValue(); } if (this.isCumulativeChart) { totalValue += value; series.addOrUpdate(new Day(dataEx.date), totalValue); } else { series.addOrUpdate(new Day(dataEx.date), value); } } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createTimeSeriesChart(name, "date", null, dataset, false, true, false); ValueMarker marker = new ValueMarker(0); marker.setPaint(Color.black); XYPlot plot = (XYPlot) chart.getXYPlot(); plot.addRangeMarker(marker); return chart; }
From source file:org.mwc.cmap.LiveDataMonitor.views.LiveDataMonitor.java
/** * The constructor./* w ww. j ava 2s .c o m*/ */ public LiveDataMonitor() { _attListener = new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { // aah, is this for the scenario we're watching if (_myIndexedAttr != null) if (evt.getSource() == _myIndexedAttr.index) { final DataDoublet newD = (DataDoublet) evt.getNewValue(); final long time = newD.getTime(); final Object newValue = newD.getValue(); if (newValue instanceof Number) { final Number value = (Number) newValue; // and store it final TimeSeriesCollection coll = (TimeSeriesCollection) _chart.getXYPlot() .getDataset(); TimeSeries tmpSeries; if (coll == null) { final TimeSeriesCollection dataset = new TimeSeriesCollection(); tmpSeries = new TimeSeries(_watchedAttr.getName()); dataset.addSeries(tmpSeries); // add to series in different thread... Display.getDefault().asyncExec(new Runnable() { public void run() { _chart.getXYPlot().setDataset(dataset); } }); } else { tmpSeries = coll.getSeries(0); } final TimeSeries series = tmpSeries; // add to series in current thread, accepting it will slow down // the // UI Display.getDefault().syncExec(new Runnable() { public void run() { // are we still open?i if (!_chartFrame.isDisposed()) { // sure, go for it, series.addOrUpdate(new Millisecond(new Date(time)), value); } } }); } } } }; }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.CheckstyleTimeChartStrategy.java
public void fillDataset() { TimeSeries s1 = new TimeSeries(this.bundle.getString("report.checkstyle.files"), this.periodClass); TimeSeries s2 = new TimeSeries(this.bundle.getString("report.checkstyle.column.total"), this.periodClass); TimeSeries s3 = new TimeSeries(this.bundle.getString("report.checkstyle.column.infos"), this.periodClass); TimeSeries s4 = new TimeSeries(this.bundle.getString("report.checkstyle.column.warnings"), this.periodClass); TimeSeries s5 = new TimeSeries(this.bundle.getString("report.checkstyle.column.errors"), this.periodClass); Iterator iter = mResults.iterator(); while (iter.hasNext()) { CheckstyleReportBean check = (CheckstyleReportBean) iter.next(); Date date = check.getDateGeneration(); s1.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), check.getNbClasses()); s2.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), check.getNbTotal()); s3.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), check.getNbInfos()); s4.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), check.getNbWarnings()); s5.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), check.getNbErrors()); }/*from w w w .j a va2 s .c o m*/ defaultdataset.addSeries(s1); defaultdataset.addSeries(s2); defaultdataset.addSeries(s3); defaultdataset.addSeries(s4); defaultdataset.addSeries(s5); }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.CloverTimeChartStrategy.java
public void fillDataset() { TimeSeries s1 = new TimeSeries(this.bundle.getString("report.clover.label.total"), this.periodClass); TimeSeries s2 = new TimeSeries(this.bundle.getString("report.clover.label.conditionals"), this.periodClass); TimeSeries s3 = new TimeSeries(this.bundle.getString("report.clover.label.statements"), this.periodClass); TimeSeries s4 = new TimeSeries(this.bundle.getString("report.clover.label.methods"), this.periodClass); Iterator iter = mResults.iterator(); while (iter.hasNext()) { CloverReportBean clover = (CloverReportBean) iter.next(); Date date = clover.getDateGeneration(); int total = clover.getElements(); int covered = clover.getCoveredElements(); s1.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), (covered / (double) total)); int totalCond = clover.getConditionals(); int coveredCond = clover.getCoveredConditionals(); s2.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), (coveredCond / (double) totalCond)); int totalStat = clover.getStatements(); int coveredStat = clover.getCoveredStatements(); s3.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), (coveredStat / (double) totalStat)); int totalMeth = clover.getMethods(); int coveredMeth = clover.getCoveredMethods(); s4.addOrUpdate(getChartDate(this.timePeriod.normalize(date)), (coveredMeth / (double) totalMeth)); }//w w w .j ava2 s.c o m defaultdataset.addSeries(s1); defaultdataset.addSeries(s2); defaultdataset.addSeries(s3); defaultdataset.addSeries(s4); }
From source file:org.openiot.gsn.vsensor.ChartVirtualSensor.java
/** * This method adds the specified stream elements to the timeSeries of the * appropriate plot./* w w w . ja v a 2 s. c om*/ * * @param streamElement */ public synchronized void addData(StreamElement streamElement) { for (int i = 0; i < streamElement.getFieldNames().length; i++) { TimeSeries timeSeries = dataForTheChart.get(streamElement.getFieldNames()[i]); if (timeSeries == null) { dataForTheChart.put(streamElement.getFieldNames()[i], timeSeries = new TimeSeries(streamElement.getFieldNames()[i], org.jfree.data.time.FixedMillisecond.class)); timeSeries.setMaximumItemCount(historySize); dataCollectionForTheChart.addSeries(timeSeries); } try { timeSeries.addOrUpdate(new FixedMillisecond(new Date(streamElement.getTimeStamp())), Double.parseDouble(streamElement.getData()[i].toString())); } catch (SeriesException e) { logger.warn(e.getMessage(), e); } } changed = true; }
From source file:ch.algotrader.client.chart.ChartTab.java
@SuppressWarnings("unchecked") public void updateData(ChartDataVO chartData) { resetAxis();// w ww. j a va2 s . co m // add/update indicators for (IndicatorVO indicator : chartData.getIndicators()) { RegularTimePeriod timePeriod = getRegularTimePeriod(indicator.getDateTime()); TimeSeries series = this.indicators.get(indicator.getName()); if (series != null) { series.addOrUpdate(timePeriod, indicator.getValue()); } } // add/update bars for (BarVO bar : chartData.getBars()) { OHLCSeries series = this.bars.get(bar.getSecurityId()); if (series != null) { // remove a value if it already exists RegularTimePeriod timePeriod = getRegularTimePeriod(bar.getDateTime()); if (series.indexOf(timePeriod) >= 0) { series.remove(timePeriod); } series.add(timePeriod, bar.getOpen().doubleValue(), bar.getHigh().doubleValue(), bar.getLow().doubleValue(), bar.getClose().doubleValue()); } } // make all invisible since they might not currently have a value for (Marker marker : this.markers.values()) { marker.setAlpha(0); } // update markers for (MarkerVO markerVO : chartData.getMarkers()) { Marker marker = this.markers.get(markerVO.getName()); Boolean selected = this.markersSelectionStatus.get(markerVO.getName()); String name = marker.getLabel().split(":")[0]; if (marker instanceof ValueMarker && markerVO instanceof ValueMarkerVO) { ValueMarker valueMarker = (ValueMarker) marker; ValueMarkerVO valueMarkerVO = (ValueMarkerVO) markerVO; valueMarker.setValue(valueMarkerVO.getValue()); marker.setLabel(name + ": " + valueMarkerVO.getValue()); marker.setAlpha(selected ? 1.0f : 0.0f); } else if (marker instanceof IntervalMarker && markerVO instanceof IntervalMarkerVO) { IntervalMarker intervalMarker = (IntervalMarker) marker; IntervalMarkerVO intervalMarkerVO = (IntervalMarkerVO) markerVO; intervalMarker.setStartValue(intervalMarkerVO.getStartValue()); intervalMarker.setEndValue(intervalMarkerVO.getEndValue()); marker.setLabel( name + ": " + intervalMarkerVO.getStartValue() + " - " + intervalMarkerVO.getEndValue()); marker.setAlpha(selected ? 0.5f : 0.0f); } else { throw new RuntimeException(marker.getClass() + " does not match " + markerVO.getClass()); } } // update annotations for (AnnotationVO annotationVO : chartData.getAnnotations()) { AbstractXYAnnotation annotation; if (annotationVO instanceof PointerAnnotationVO) { PointerAnnotationVO pointerAnnotationVO = (PointerAnnotationVO) annotationVO; XYPointerAnnotation pointerAnnotation = new XYPointerAnnotation(pointerAnnotationVO.getText(), pointerAnnotationVO.getDateTime().getTime(), pointerAnnotationVO.getValue(), 3.926990816987241D); pointerAnnotation.setTipRadius(0); pointerAnnotation.setBaseRadius(20); pointerAnnotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT); pointerAnnotation.setFont(new Font("SansSerif", 0, 9)); pointerAnnotation.setToolTipText("<html>" + formatter.format(pointerAnnotationVO.getDateTime()) + "<br>" + pointerAnnotationVO.getValue() + "</html>"); annotation = pointerAnnotation; } else if (annotationVO instanceof BoxAnnotationVO) { BoxAnnotationVO boxAnnotationVO = (BoxAnnotationVO) annotationVO; XYBoxAnnotation boxAnnotation = new XYBoxAnnotation(boxAnnotationVO.getStartDateTime().getTime(), boxAnnotationVO.getStartValue(), boxAnnotationVO.getEndDateTime().getTime(), boxAnnotationVO.getEndValue(), null, null, new java.awt.Color(0, 0, 0, 60)); boxAnnotation.setToolTipText("<html>" + formatter.format(boxAnnotationVO.getStartDateTime()) + " - " + formatter.format(boxAnnotationVO.getEndDateTime()) + "<br>" + boxAnnotationVO.getStartValue() + " - " + boxAnnotationVO.getEndValue() + "</html>"); annotation = boxAnnotation; } else { throw new RuntimeException("unkown annotation type" + annotationVO.getClass()); } if (!getPlot().getAnnotations().contains(annotation)) { getPlot().addAnnotation(annotation); } } // update description for (Title title : (List<Title>) this.getChart().getSubtitles()) { if (title instanceof TextTitle) { TextTitle textTitle = ((TextTitle) title); if (chartData.getDescription() != null && !("".equals(chartData.getDescription()))) { textTitle.setText(chartData.getDescription()); textTitle.setVisible(true); } else { textTitle.setVisible(false); } } } initAxis(); }
From source file:org.cerberus.crud.service.impl.TestCaseExecutionwwwDetService.java
@Override public BufferedImage getHistoricOfParameter(TestCase testcase, String parameter) { List<TestCaseExecutionwwwSumHistoric> historic = testCaseExecutionWWWDetDAO .getHistoricForParameter(testcase, parameter); BufferedImage result = null;/*from w w w .j a v a 2 s .com*/ DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); /*Create timeseries with the data*/ String timeseriesname = parameter; TimeSeries timeseries = new TimeSeries(timeseriesname, Minute.class); for (TestCaseExecutionwwwSumHistoric ep : historic) { defaultcategorydataset.addValue(Float.valueOf(ep.getParameter()), parameter, ep.getStart()); if (!ep.getStart().equals("2011-01-01 00:00")) { String tims = ep.getStart(); int year = Integer.valueOf(tims.substring(0, 4)); int month = Integer.valueOf(tims.substring(5, 7)); int day = Integer.valueOf(tims.substring(8, 10)); int hour = Integer.valueOf(tims.substring(11, 13)); int min = Integer.valueOf(tims.substring(14, 16)); float value = Float.valueOf(ep.getParameter()); timeseries.addOrUpdate(new Minute(min, hour, day, month, year), value); } } timeseriescollection.addSeries(timeseries); result = this.bi(timeseriescollection, "test", parameter, 1); return result; }
From source file:edu.fullerton.ldvservlet.SrcList.java
private TimeSeries getTimeSeries(double[][] data, String legend) { TimeSeries ts; ts = new TimeSeries(legend); SimpleTimeZone utctz = new SimpleTimeZone(0, "UTC"); for (double[] data1 : data) { long gps = Math.round(data1[0]); long utcms = TimeAndDate.gps2utc(gps) * 1000; Date t = new Date(utcms); ts.addOrUpdate(new Millisecond(t, utctz, Locale.US), data1[1]); }/* w w w. j av a2 s. c o m*/ return ts; }