public static TimeSeries createTimeseries(String category, Vector<Object[]> dateValues) { TimeSeries timeseries = new TimeSeries(category); if (dateValues != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); for (Object[] objects : dateValues) { Date date = null; try { date = dateFormat.parse(objects[0].toString()); } catch (ParseException e) { } String sValue = objects[1].toString(); double dValue = 0; if (date != null && isNumber(sValue)) { dValue = Double.parseDouble(sValue); timeseries.add(new Day(date), dValue); } } } return timeseries; }
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1", Day.class); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
@Override public void addSeries(agentgui.ontology.DataSeries series){ org.jfree.data.time.TimeSeries newSeries = new org.jfree.data.time.TimeSeries(series.getLabel()); List valuePairs = ((agentgui.ontology.TimeSeries)series).getTimeSeriesValuePairs(); for (int i = 0; i < valuePairs.size(); i++) { TimeSeriesValuePair valuePair = (TimeSeriesValuePair) valuePairs.get(i); Simple_Long simpleLong = valuePair.getTimestamp(); Simple_Float simpleFloat = valuePair.getValue(); Long timeStampLong = simpleLong.getLongValue(); Float floatValue = simpleFloat.getFloatValue(); if (timeStampLong!=null) { TimeSeriesDataItem newItem = new TimeSeriesDataItem(new FixedMillisecond(timeStampLong), floatValue); newSeries.addOrUpdate(newItem); } } this.getTimeSeriesCollection().addSeries(newSeries); this.setChanged(); this.notifyObservers(ChartModel.EventType.SERIES_ADDED); }
/** * Update the time stamp in all series that contain it * @param oldKey The old time stamp * @param newKey The new time stamp */ public void updateKey(Number oldKey, Number newKey) { // --- Iterate over all series ------------------------------ for (int i=0; i < this.getSeriesCount(); i++) { org.jfree.data.time.TimeSeries series = this.getSeries(i); // Try to find a value pair with the old time stamp TimeSeriesDataItem oldValuePair = series.getDataItem(new FixedMillisecond(oldKey.longValue())); // If found, remove it and add a new one with the new time stamp and the old value if(oldValuePair != null){ series.delete(new FixedMillisecond(oldKey.longValue())); series.addOrUpdate(new FixedMillisecond(newKey.longValue()), oldValuePair.getValue()); } } }
/** * Edits the data series by adding data. * @param series the series * @param targetDataSeriesIndex the target data series index */ public void editSeriesAddData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException { if (targetDataSeriesIndex<=(this.getSeriesCount()-1)) { // --- Get the series ------------------------- org.jfree.data.time.TimeSeries addToSeries = (org.jfree.data.time.TimeSeries) this.getSeries(targetDataSeriesIndex); List valuePairs = ((agentgui.ontology.TimeSeries)series).getTimeSeriesValuePairs(); for (int i = 0; i < valuePairs.size(); i++) { TimeSeriesValuePair valuePair = (TimeSeriesValuePair) valuePairs.get(i); Simple_Long simpleLong = valuePair.getTimestamp(); Simple_Float simpleFloat = valuePair.getValue(); Long timeStampLong = simpleLong.getLongValue(); Float floatValue = simpleFloat.getFloatValue(); if (timeStampLong!=null) { TimeSeriesDataItem newItem = new TimeSeriesDataItem(new FixedMillisecond(timeStampLong), floatValue); addToSeries.addOrUpdate(newItem); } } } else { throw new NoSuchSeriesException(); } }
/** * Edits the data series by adding or exchanging data. * @param series the series * @param targetDataSeriesIndex the target data series index */ public void editSeriesAddOrExchangeData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException { if (targetDataSeriesIndex<=(this.getSeriesCount()-1)) { org.jfree.data.time.TimeSeries addToSeries = (org.jfree.data.time.TimeSeries) this.getSeries(targetDataSeriesIndex); List valuePairs = ((agentgui.ontology.TimeSeries)series).getTimeSeriesValuePairs(); for (int i = 0; i < valuePairs.size(); i++) { TimeSeriesValuePair valuePair = (TimeSeriesValuePair) valuePairs.get(i); Simple_Long simpleLong = valuePair.getTimestamp(); Simple_Float simpleFloat = valuePair.getValue(); Long timeStampLong = simpleLong.getLongValue(); Float floatValue = simpleFloat.getFloatValue(); if (timeStampLong!=null) { TimeSeriesDataItem newItem = new TimeSeriesDataItem(new FixedMillisecond(timeStampLong), floatValue); addToSeries.addOrUpdate(newItem); } } } else { throw new NoSuchSeriesException(); } }
/** * Edits the data series by exchanging data. * @param series the series * @param targetDataSeriesIndex the target data series index */ public void editSeriesExchangeData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException { if (targetDataSeriesIndex<=(this.getSeriesCount()-1)) { org.jfree.data.time.TimeSeries exchangeSeries = (org.jfree.data.time.TimeSeries) this.getSeries(targetDataSeriesIndex); List valuePairs = ((agentgui.ontology.TimeSeries)series).getTimeSeriesValuePairs(); for (int i = 0; i < valuePairs.size(); i++) { TimeSeriesValuePair valuePair = (TimeSeriesValuePair) valuePairs.get(i); Simple_Long simpleLong = valuePair.getTimestamp(); Simple_Float simpleFloat = valuePair.getValue(); Long timeStampLong = simpleLong.getLongValue(); Float floatValue = simpleFloat.getFloatValue(); if (timeStampLong!=null) { try { exchangeSeries.update(new FixedMillisecond(timeStampLong), floatValue); } catch (SeriesException se) { // --- Nothing to do here, just take the next value --- } } } } else { throw new NoSuchSeriesException(); } }
/** * Edits the data series by remove data. * @param series the series * @param targetDataSeriesIndex the target data series index */ public void editSeriesRemoveData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException { if (targetDataSeriesIndex<=(this.getSeriesCount()-1)) { org.jfree.data.time.TimeSeries removeSeries = (org.jfree.data.time.TimeSeries) this.getSeries(targetDataSeriesIndex); List valuePairs = ((agentgui.ontology.TimeSeries)series).getTimeSeriesValuePairs(); for (int i = 0; i < valuePairs.size(); i++) { TimeSeriesValuePair valuePair = (TimeSeriesValuePair) valuePairs.get(i); Simple_Long simpleLong = valuePair.getTimestamp(); Long timeStampLong = simpleLong.getLongValue(); if (timeStampLong!=null) { removeSeries.delete(new FixedMillisecond(timeStampLong)); } } } else { throw new NoSuchSeriesException(); } }
private int getDataIndex(TimeSeries timeSeries, Day targetDay) { int low = 0; int high = timeSeries.getItemCount() - 1; while (low <= high) { int mid = (low + high) >>> 1; final TimeSeriesDataItem timeSeriesDataItem = timeSeries.getDataItem(mid); final Day searchDay = (Day)timeSeriesDataItem.getPeriod(); final long cmp = searchDay.compareTo(targetDay); if (cmp < 0) { low = mid + 1; } else if (cmp > 0) { high = mid - 1; } else { return mid; } } return -1; }
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j) { final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0); final XYPlot plot = (XYPlot) main_plot; final TimeSeries series = new TimeSeries(p); ///* for(Integer i: toPlot) { switch(j) { case 0: series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen()); break; case 1: series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh()); break; case 2: series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow()); break; case 3: series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose()); break; } } /* for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++) { series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]); } */ XYDataset dataSet = new TimeSeriesCollection(series); plot.setDataset(k, dataSet); XYItemRenderer ir = new XYShapeRenderer(); //ir.s plot.setRenderer(k, ir); }
private XYDataset createIndicatorPlot(String name, Double[] plot) { final TimeSeries series = new TimeSeries(name); ///* for (int i = 0; i < chartDatas.size(); i++) { series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),plot[i]); } /* for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++) { series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]); } */ return new TimeSeriesCollection(series); }
private XYDataset createDataset(List<String> industrys) { TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); if (industrys != null) { for (String industry : industrys) { TimeSeries timeseries = new TimeSeries(industry + "资金统计", org.jfree.data.time.Day.class); List<IndustryInfo> industryInfos = industryInfoDao.get(industry); Double value = 0.0; if (industryInfos != null) { for (IndustryInfo industryInfo : industryInfos) { value = value + industryInfo.getTotal() / 10000; timeseries.add(new Day(DateUtil.parse(String.valueOf(industryInfo.getDate()), DateUtil.DATE_FORMAT_DAY_SHORT)), value); } } timeseriescollection.addSeries(timeseries); } } return timeseriescollection; }
private XYDataset createDataset(List<String> industrys) { TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); if (industrys != null) { for (String industry : industrys) { TimeSeries timeseries = new TimeSeries(industry + "涨跌统计", org.jfree.data.time.Day.class); List<IndustryInfo> industryInfos = industryInfoDao.get(industry); BigDecimal value = new BigDecimal(0); if (industryInfos != null) { for (IndustryInfo industryInfo : industryInfos) { if (industryInfo.getRise() != null) { value = value.add(industryInfo.getRise()); } timeseries.add(new Day(DateUtil.parse(String.valueOf(industryInfo.getDate()), DateUtil.DATE_FORMAT_DAY_SHORT)), value); } } timeseriescollection.addSeries(timeseries); } } return timeseriescollection; }
/** * Tests the remove series method. */ public void testRemoveSeries() { final TimeSeriesCollection c1 = new TimeSeriesCollection(); final TimeSeries s1 = new TimeSeries("Series 1"); final TimeSeries s2 = new TimeSeries("Series 2"); final TimeSeries s3 = new TimeSeries("Series 3"); final TimeSeries s4 = new TimeSeries("Series 4"); c1.addSeries(s1); c1.addSeries(s2); c1.addSeries(s3); c1.addSeries(s4); c1.removeSeries(s3); final TimeSeries s = c1.getSeries(2); final boolean b1 = s.equals(s4); assertTrue(b1); }
/** * A test for the values calculated from a time series. */ public void test1() { final TimeSeries source = createDailyTimeSeries1(); final TimeSeries maverage = MovingAverage.createMovingAverage( source, "Moving Average", 3, 3 ); // the moving average series has 7 items, the first three // days (11, 12, 13 August are skipped) assertEquals(7, maverage.getItemCount()); double value = maverage.getValue(0).doubleValue(); assertTrue(NumberUtils.equal(value, 14.1)); value = maverage.getValue(1).doubleValue(); assertTrue(NumberUtils.equal(value, 13.4)); value = maverage.getValue(2).doubleValue(); assertTrue(NumberUtils.equal(value, 14.43333333333)); value = maverage.getValue(3).doubleValue(); assertTrue(NumberUtils.equal(value, 14.93333333333)); value = maverage.getValue(4).doubleValue(); assertTrue(NumberUtils.equal(value, 19.8)); value = maverage.getValue(5).doubleValue(); assertTrue(NumberUtils.equal(value, 15.25)); value = maverage.getValue(6).doubleValue(); assertTrue(NumberUtils.equal(value, 12.5)); }
/** * Creates a sample series. * * @return A sample series. */ private TimeSeries createDailyTimeSeries1() { final TimeSeries series = new TimeSeries("Series 1", Day.class); series.add(new Day(11, SerialDate.AUGUST, 2003), 11.2); series.add(new Day(13, SerialDate.AUGUST, 2003), 13.8); series.add(new Day(17, SerialDate.AUGUST, 2003), 14.1); series.add(new Day(18, SerialDate.AUGUST, 2003), 12.7); series.add(new Day(19, SerialDate.AUGUST, 2003), 16.5); series.add(new Day(20, SerialDate.AUGUST, 2003), 15.6); series.add(new Day(25, SerialDate.AUGUST, 2003), 19.8); series.add(new Day(27, SerialDate.AUGUST, 2003), 10.7); series.add(new Day(28, SerialDate.AUGUST, 2003), 14.3); return series; }
/** * Test the setMaximumItemCount() method to ensure that it removes items from the series * if necessary. */ public void testSetMaximumItemCount() { TimeSeries s1 = new TimeSeries("S1", Year.class); s1.add(new Year(2000), 13.75); s1.add(new Year(2001), 11.90); s1.add(new Year(2002), null); s1.add(new Year(2005), 19.32); s1.add(new Year(2007), 16.89); assertTrue(s1.getItemCount() == 5); s1.setMaximumItemCount(3); assertTrue(s1.getItemCount() == 3); TimeSeriesDataItem item = s1.getDataItem(0); assertTrue(item.getPeriod().equals(new Year(2002))); }
/** * Creates a sample dataset. * * @param name the dataset name. * @param base the starting value. * @param start the starting period. * @param count the number of values to generate. * * @return The dataset. */ private static XYDataset createDataset(String name, double base, RegularTimePeriod start, int count) { TimeSeries series = new TimeSeries(name, start.getClass()); RegularTimePeriod period = start; double value = base; for (int i = 0; i < count; i++) { series.add(period, value); period = period.next(); value = value * (1 + (Math.random() - 0.495) / 10.0); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); return dataset; }
/** * Tests the remove series method. */ public void testRemoveSeries() { TimeSeriesCollection c1 = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Series 1"); TimeSeries s2 = new TimeSeries("Series 2"); TimeSeries s3 = new TimeSeries("Series 3"); TimeSeries s4 = new TimeSeries("Series 4"); c1.addSeries(s1); c1.addSeries(s2); c1.addSeries(s3); c1.addSeries(s4); c1.removeSeries(s3); TimeSeries s = c1.getSeries(2); boolean b1 = s.equals(s4); assertTrue(b1); }
/** * A test for the values calculated from a time series. */ public void test1() { TimeSeries source = createDailyTimeSeries1(); TimeSeries maverage = MovingAverage.createMovingAverage( source, "Moving Average", 3, 3 ); // the moving average series has 7 items, the first three // days (11, 12, 13 August are skipped) assertEquals(7, maverage.getItemCount()); double value = maverage.getValue(0).doubleValue(); assertEquals(14.1, value, EPSILON); value = maverage.getValue(1).doubleValue(); assertEquals(13.4, value, EPSILON); value = maverage.getValue(2).doubleValue(); assertEquals(14.433333333333, value, EPSILON); value = maverage.getValue(3).doubleValue(); assertEquals(14.933333333333, value, EPSILON); value = maverage.getValue(4).doubleValue(); assertEquals(19.8, value, EPSILON); value = maverage.getValue(5).doubleValue(); assertEquals(15.25, value, EPSILON); value = maverage.getValue(6).doubleValue(); assertEquals(12.5, value, EPSILON); }
/** * Creates a sample series. * * @return A sample series. */ private TimeSeries createDailyTimeSeries1() { TimeSeries series = new TimeSeries("Series 1", Day.class); series.add(new Day(11, MonthConstants.AUGUST, 2003), 11.2); series.add(new Day(13, MonthConstants.AUGUST, 2003), 13.8); series.add(new Day(17, MonthConstants.AUGUST, 2003), 14.1); series.add(new Day(18, MonthConstants.AUGUST, 2003), 12.7); series.add(new Day(19, MonthConstants.AUGUST, 2003), 16.5); series.add(new Day(20, MonthConstants.AUGUST, 2003), 15.6); series.add(new Day(25, MonthConstants.AUGUST, 2003), 19.8); series.add(new Day(27, MonthConstants.AUGUST, 2003), 10.7); series.add(new Day(28, MonthConstants.AUGUST, 2003), 14.3); return series; }
/** * Test the setMaximumItemCount() method to ensure that it removes items * from the series if necessary. */ public void testSetMaximumItemCount() { TimeSeries s1 = new TimeSeries("S1", Year.class); s1.add(new Year(2000), 13.75); s1.add(new Year(2001), 11.90); s1.add(new Year(2002), null); s1.add(new Year(2005), 19.32); s1.add(new Year(2007), 16.89); assertTrue(s1.getItemCount() == 5); s1.setMaximumItemCount(3); assertTrue(s1.getItemCount() == 3); TimeSeriesDataItem item = s1.getDataItem(0); assertTrue(item.getPeriod().equals(new Year(2002))); }
/** * Some checks for the getIndex() method. */ public void testGetIndex() { TimeSeries series = new TimeSeries("Series", Month.class); assertEquals(-1, series.getIndex(new Month(1, 2003))); series.add(new Month(1, 2003), 45.0); assertEquals(0, series.getIndex(new Month(1, 2003))); assertEquals(-1, series.getIndex(new Month(12, 2002))); assertEquals(-2, series.getIndex(new Month(2, 2003))); series.add(new Month(3, 2003), 55.0); assertEquals(-1, series.getIndex(new Month(12, 2002))); assertEquals(0, series.getIndex(new Month(1, 2003))); assertEquals(-2, series.getIndex(new Month(2, 2003))); assertEquals(1, series.getIndex(new Month(3, 2003))); assertEquals(-3, series.getIndex(new Month(4, 2003))); }
public void add(final CalendarDateSeries<?> aSeries) { final String tmpName = aSeries.getName(); final TimeSeries tmpSeries = new TimeSeries(tmpName); for (final Entry<CalendarDate, ? extends Number> tmpEntry : aSeries.entrySet()) { final CalendarDate tmpKey = tmpEntry.getKey(); final FixedMillisecond tmpPeriod = new FixedMillisecond(tmpKey.millis); final Number tmpValue = tmpEntry.getValue(); final TimeSeriesDataItem tmpItem = new TimeSeriesDataItem(tmpPeriod, tmpValue); tmpSeries.add(tmpItem); } myCollection.addSeries(tmpSeries); ColourData tmpColour2 = aSeries.getColour(); if (tmpColour2 == null) { tmpColour2 = ColourData.random(); aSeries.colour(tmpColour2); } final int tmpRgb = tmpColour2.getRGB(); final Color tmpColour = new Color(tmpRgb); this.putColour(tmpName, tmpColour); }
/** * Creates a sample dataset. * * @param name the dataset name. * @param base the starting value. * @param start the starting period. * @param count the number of values to generate. * * @return The dataset. */ private static XYDataset createDataset(String name, double base, RegularTimePeriod start, int count) { TimeSeries series = new TimeSeries(name); RegularTimePeriod period = start; double value = base; for (int i = 0; i < count; i++) { series.add(period, value); period = period.next(); value = value * (1 + (Math.random() - 0.495) / 10.0); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); return dataset; }
/** * Serialize a time seroes chart, restore it, and check for equality. */ @Test public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset); JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); assertEquals(c1, c2); }
/** * Serialize a time seroes chart, restore it, and check for equality. */ @Test public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset); JFreeChart c2 = (JFreeChart) TestUtils.serialised(c1); assertEquals(c1, c2); }
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1"); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
@Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink printHyperlink = null; if (hasHyperlinks() && entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; TimeSeriesCollection dataset = (TimeSeriesCollection) itemEntity.getDataset(); TimeSeries series = dataset.getSeries(itemEntity.getSeriesIndex()); Map<RegularTimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey()); if (serieHyperlinks != null) { RegularTimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem()); printHyperlink = serieHyperlinks.get(timePeriod); } } return printHyperlink; }
public void nodeCompleted(Object parent) { TimeSeriesCollectionBuilder tsc = null; try { if(parent != null && parent instanceof TimeSeriesCollectionBuilder) tsc = (TimeSeriesCollectionBuilder)parent; if(this.series == null) { this.series = new TimeSeries(name, domain, range, Class.forName(timePeriodClass) ); this.setProperties(this.series, beanMap ); } if(addValue != null) { boolean notify = false; if(addValue.containsKey(("notify"))) notify = Boolean.valueOf((String)addValue.get("notify")); this.series.add((RegularTimePeriod)addValue.get("period"), ((Number)addValue.get("value")).doubleValue(), notify); addValue = null; } if(tsc != null) tsc.addSeries(this.series); } catch (Throwable ex) { logger.log(Level.WARNING, ex.getMessage(), ex); } }
public static TimeSeries getForecastData(TimeSeries observationData, int forcastperc) { TimeSeries fcdataset = new TimeSeries("Time Series Forecast"); if (observationData.isEmpty() == true) return fcdataset; int size = observationData.getItemCount(); long fcsize = size + Math.round( (double)size * ((double)forcastperc/100)); // new data set try { fcdataset = observationData.createCopy(0,size-1); for (int i=size; i < fcsize; i++) { RegularTimePeriod nexttp = fcdataset.getNextTimePeriod(); fcdataset.add(nexttp,0.00D); } } catch (Exception e) { System.out.println("Exception:" + e.getLocalizedMessage()); System.out.println("Could not create forecasted data sample"); return fcdataset; } return fcdataset; }
/** * Creates the dataset. * * @return the XY dataset */ private XYDataset createDataset() { TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries(this.values1_des); for(int i = 0; i < this.values1.length; i++) { s1.add(new Day(dates.get(i)), this.values1[i]); } dataset.addSeries(s1); if(this.values2 != null) { TimeSeries s2 = new TimeSeries(this.values2_des); for(int i = 0; i < this.values2.length; i++) { s2.add(new Day(dates.get(i)), this.values2[i]); } dataset.addSeries(s2); } return dataset; }
@SuppressWarnings("deprecation") private void createTable(Composite rtComp) { thread1 = new Thread(this); lastValue = 100D; // 创建时序图对象 timeseries = new TimeSeries( "实时内存", MemInfo.class$org$jfree$data$time$Millisecond != null ? MemInfo.class$org$jfree$data$time$Millisecond : (MemInfo.class$org$jfree$data$time$Millisecond = MemInfo .getClass("org.jfree.data.time.Millisecond"))); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries); // 创建图表面板 disp = shell.getDisplay(); final ChartComposite frame = new ChartComposite(rtComp, SWT.NONE, createChart(timeseriescollection), true); frame.pack(); MemInfo.startThread(); }
@SuppressWarnings("deprecation") private void createTable(Composite rtComp) { thread1 = new Thread(this); lastValue = 20D; // 创建时序图对象 timeseries = new TimeSeries( "实时FPS", FpsInfo.class$org$jfree$data$time$Millisecond != null ? FpsInfo.class$org$jfree$data$time$Millisecond : (FpsInfo.class$org$jfree$data$time$Millisecond = FpsInfo .getClass("org.jfree.data.time.Millisecond"))); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries); // 创建图表面板 disp = shell.getDisplay(); final ChartComposite frame = new ChartComposite(rtComp, SWT.NONE, createChart(timeseriescollection), true); frame.pack(); FpsInfo.startThread(); }
private IntervalXYDataset createDatasetNumberRequestsUntampered() { Date currentDate; long currentMsTs; final TimeSeries series = new TimeSeries( "Sent Untampered Requests per Second" ); if ( model.getMapLogEntryIntervalUntampered() != null ) { for ( Map.Entry<Integer, LogEntryInterval> log : model.getMapLogEntryIntervalUntampered().entrySet() ) { // Create TS from model.startTime and log.getIntervalNumber(); currentMsTs = model.getTsAttackStart() + log.getValue().getIntervalNumber(); currentDate = new Date( currentMsTs ); series.add( new Second( currentDate ), ( log.getValue().getNumberRequests() ) ); } } final TimeSeriesCollection dataset = new TimeSeriesCollection( series ); dataset.setXPosition( TimePeriodAnchor.MIDDLE ); return dataset; }
private IntervalXYDataset createDatasetNumberRequestsTampered() { Date currentDate; long currentMsTs; final TimeSeries series = new TimeSeries( "Sent Tampered Requests per Second" ); if ( model.getMapLogEntryIntervalTampered() != null ) { for ( Map.Entry<Integer, LogEntryInterval> log : model.getMapLogEntryIntervalTampered().entrySet() ) { // Create TS from model.startTime and log.getIntervalNumber(); currentMsTs = model.getTsAttackStart() + log.getValue().getIntervalNumber(); currentDate = new Date( currentMsTs ); series.add( new Second( currentDate ), ( log.getValue().getNumberRequests() ) ); } } final TimeSeriesCollection dataset = new TimeSeriesCollection( series ); dataset.setXPosition( TimePeriodAnchor.MIDDLE ); return dataset; }