public TimeSeries Get(String name, Class t) { for (int i = 0; i < data.size(); i++) { if (data.get(i).getKey().compareTo(name) == 0) { return data.get(i); } } TimeSeries ts = new TimeSeries(name, t); data.add(ts); return ts; } }
/** * Returns the key for a series. * * @param series the index of the series (zero-based). * * @return The key for a series. */ public Comparable getSeriesKey(int series) { // check arguments...delegated // fetch the series name... return getSeries(series).getKey(); }
/** * Returns the key for a series. * * @param series the index of the series (zero-based). * * @return The key for a series. */ @Override public Comparable getSeriesKey(int series) { // check arguments...delegated // fetch the series name... return getSeries(series).getKey(); }
/** * Returns the series with the specified key, or {@code null} if * there is no such series. * * @param key the series key ({@code null} permitted). * * @return The series with the given key. */ public TimeSeries getSeries(Comparable key) { TimeSeries result = null; Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { TimeSeries series = (TimeSeries) iterator.next(); Comparable k = series.getKey(); if (k != null && k.equals(key)) { result = series; } } return result; }
/** * Returns the series with the specified key, or <code>null</code> if * there is no such series. * * @param key the series key (<code>null</code> permitted). * * @return The series with the given key. */ public TimeSeries getSeries(Comparable key) { TimeSeries result = null; Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { TimeSeries series = (TimeSeries) iterator.next(); Comparable k = series.getKey(); if (k != null && k.equals(key)) { result = series; } } return result; }
/** * Returns the index of the series with the specified key, or -1 if no * series has that key. * * @param key the key ({@code null} not permitted). * * @return The index. * * @since 1.0.17 */ public int getSeriesIndex(Comparable key) { Args.nullNotPermitted(key, "key"); int seriesCount = getSeriesCount(); for (int i = 0; i < seriesCount; i++) { TimeSeries series = (TimeSeries) this.data.get(i); if (key.equals(series.getKey())) { return i; } } return -1; }
/** * Reduce a given dataset to only contain a specified number of columns * * @param dataset The dataset to reduce * @param rowKeysToKeep The rows to keep * @return A reduced dataset copy. */ public static TimeSeriesCollection reduceDataset(TimeSeriesCollection dataset, List rowKeysToKeep) { final TimeSeriesCollection newDataSet = new TimeSeriesCollection(); @SuppressWarnings("unchecked") final List<TimeSeries> timeSerieses = new ArrayList<TimeSeries>(dataset.getSeries()); for (TimeSeries timeSeries : timeSerieses) { if (rowKeysToKeep.contains(timeSeries.getKey())) { newDataSet.addSeries(timeSeries); } } return newDataSet; }
/** * Removes all data from the upper plot and sets the {@link TimerData} objects on the plot. * * @param map * The data to set on the plot. */ protected void setCountPlotData(Map<Object, List<E>> map) { for (TimeSeries series : countSeries) { series.clear(); series.setNotify(false); for (Entry<Object, List<E>> entry : map.entrySet()) { if (series.getKey().equals(entry.getKey())) { for (E data : entry.getValue()) { series.addOrUpdate(new Millisecond(data.getTimeStamp()), data.getCount()); } break; } } series.setNotify(true); series.fireSeriesChanged(); } }
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 serieHyperlinks = (Map) itemHyperlinks.get(series.getKey()); if (serieHyperlinks != null) { RegularTimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem()); printHyperlink = (JRPrintHyperlink) serieHyperlinks.get(timePeriod); } } return printHyperlink; }
TimeSeries sourceSeries = source.getSeries(i); TimeSeries maSeries = createMovingAverage(sourceSeries, sourceSeries.getKey() + suffix, periodCount, skip); result.addSeries(maSeries);
/** * Creates a new {@link TimeSeriesCollection} containing a moving average * series for each series in the source collection. * * @param source the source collection. * @param suffix the suffix added to each source series name to create the * corresponding moving average series name. * @param periodCount the number of periods in the moving average * calculation. * @param skip the number of initial periods to skip. * * @return A collection of moving average time series. */ public static TimeSeriesCollection createMovingAverage( TimeSeriesCollection source, String suffix, int periodCount, int skip) { Args.nullNotPermitted(source, "source"); if (periodCount < 1) { throw new IllegalArgumentException("periodCount must be greater " + "than or equal to 1."); } TimeSeriesCollection result = new TimeSeriesCollection(); for (int i = 0; i < source.getSeriesCount(); i++) { TimeSeries sourceSeries = source.getSeries(i); TimeSeries maSeries = createMovingAverage(sourceSeries, sourceSeries.getKey() + suffix, periodCount, skip); result.addSeries(maSeries); } return result; }
/** * Creates a TimeSeriesCollection which represents the cumulative values of a given TimeSeriesCollection. * * @param collection collection * @return TimeSeriesCollection */ public static TimeSeriesCollection makeCumulative(TimeSeriesCollection collection) { TimeSeriesCollection result = new TimeSeriesCollection(); for (int i = 0; i < collection.getSeriesCount(); i++) { TimeSeries oldSeries = collection.getSeries(i); TimeSeries cumulativeSeries = new TimeSeries(oldSeries.getKey(), oldSeries.getTimePeriodClass()); int cumulativeValue = 0; for (int j = 0; j < oldSeries.getItemCount(); j++) { cumulativeValue += oldSeries.getValue(j).intValue(); cumulativeSeries.add(oldSeries.getTimePeriod(j), Integer.valueOf(cumulativeValue)); } result.addSeries(cumulativeSeries); } return result; }
@Override public TimeSeries validate(TimeSeries timeSeries, String sourceName, TimeSeriesType type) throws ParseException { String qualifiedSourceName = createQualifiedSourcename(sourceName, type); final Symbol symbol = namespace.resolveSymbol(qualifiedSourceName); if (symbol == null) { throw new ParseException("No variable for identifier '" + qualifiedSourceName + "' registered."); } final String expression = getExpressionFor(qualifiedSourceName); if (expression == null || expression.trim().isEmpty()) { return timeSeries; } final Variable variable = (Variable) symbol; final Term term = parser.parse(expression, namespace); final int seriesCount = timeSeries.getItemCount(); final TimeSeries validatedSeries = new TimeSeries(timeSeries.getKey()); for (int i = 0; i < seriesCount; i++) { final TimeSeriesDataItem dataItem = timeSeries.getDataItem(i); final Number value = dataItem.getValue(); variable.assignD(null, value.doubleValue()); if (term.evalB(null)) { validatedSeries.add(dataItem); } } return validatedSeries; }
/** * Adds or updates data from one series to another. Returns another series * containing the values that were overwritten. * * @param series the series to merge with this. * * @return A series containing the values that were overwritten. */ public TimeSeries addAndOrUpdate(TimeSeries series) { TimeSeries overwritten = new TimeSeries("Overwritten values from: " + getKey()); for (int i = 0; i < series.getItemCount(); i++) { TimeSeriesDataItem item = series.getRawDataItem(i); TimeSeriesDataItem oldItem = addOrUpdate(item.getPeriod(), item.getValue()); if (oldItem != null) { overwritten.add(oldItem); } } return overwritten; }
/** * Adds or updates data from one series to another. Returns another series * containing the values that were overwritten. * * @param series the series to merge with this. * * @return A series containing the values that were overwritten. */ public TimeSeries addAndOrUpdate(TimeSeries series) { TimeSeries overwritten = new TimeSeries("Overwritten values from: " + getKey()); for (int i = 0; i < series.getItemCount(); i++) { TimeSeriesDataItem item = series.getRawDataItem(i); TimeSeriesDataItem oldItem = addOrUpdate(item.getPeriod(), item.getValue()); if (oldItem != null) { overwritten.add(oldItem); } } return overwritten; }
for (int j = 0; j < dataset.getSeriesCount(); j++) { TimeSeries ts = dataset.getSeries(j); if (ts.getKey().equals(groupName)) { renderer5.setSeriesPaint(j, c);
String timeseriesId = (String) dataset.getSeries(seriesIndex).getKey(); RenderingDesign dd = designDescriptions.get(timeseriesId);