/** * Returns the index for the item (if any) that corresponds to a time * period. * * @param period the time period (<code>null</code> not permitted). * * @return The index. */ public int getIndex(RegularTimePeriod period) { if (period == null) { throw new IllegalArgumentException("Null 'period' argument."); } TimeSeriesDataItem dummy = new TimeSeriesDataItem( period, Integer.MIN_VALUE); return Collections.binarySearch(this.data, dummy); }
/** * Adds a new data item to the series and sends a {@link SeriesChangeEvent} * to all registered listeners. * * @param period the time period (<code>null</code> not permitted). * @param value the value (<code>null</code> permitted). * @param notify notify listeners? */ public void add(RegularTimePeriod period, Number value, boolean notify) { // defer argument checking... TimeSeriesDataItem item = new TimeSeriesDataItem(period, value); add(item, notify); }
/** * Adds a new data item to the series and sends a {@link SeriesChangeEvent} * to all registered listeners. * * @param period the time period (<code>null</code> not permitted). * @param value the value. * @param notify notify listeners? */ public void add(RegularTimePeriod period, double value, boolean notify) { // defer argument checking... TimeSeriesDataItem item = new TimeSeriesDataItem(period, value); add(item, notify); }
/** * Adds a new data item to the series and sends a {@link SeriesChangeEvent} * to all registered listeners. * * @param period the time period ({@code null} not permitted). * @param value the value ({@code null} permitted). * @param notify notify listeners? */ public void add(RegularTimePeriod period, Number value, boolean notify) { // defer argument checking... TimeSeriesDataItem item = new TimeSeriesDataItem(period, value); add(item, notify); }
/** * Adds a new data item to the series and sends a {@link SeriesChangeEvent} * to all registered listeners. * * @param period the time period ({@code null} not permitted). * @param value the value. * @param notify notify listeners? */ public void add(RegularTimePeriod period, double value, boolean notify) { // defer argument checking... TimeSeriesDataItem item = new TimeSeriesDataItem(period, value); add(item, notify); }
/** * Returns the index for the item (if any) that corresponds to a time * period. * * @param period the time period ({@code null} not permitted). * * @return The index. */ public int getIndex(RegularTimePeriod period) { Args.nullNotPermitted(period, "period"); TimeSeriesDataItem dummy = new TimeSeriesDataItem( period, Integer.MIN_VALUE); return Collections.binarySearch(this.data, dummy); }
/** * Adds or updates an item in the times series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param period the time period to add/update (<code>null</code> not * permitted). * @param value the new value (<code>null</code> permitted). * * @return A copy of the overwritten data item, or <code>null</code> if no * item was overwritten. */ public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, Number value) { return addOrUpdate(new TimeSeriesDataItem(period, value)); }
/** * Adds or updates an item in the times series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param period the time period to add/update ({@code null} not * permitted). * @param value the new value ({@code null} permitted). * * @return A copy of the overwritten data item, or {@code null} if no * item was overwritten. */ public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, Number value) { return addOrUpdate(new TimeSeriesDataItem(period, value)); }
/** * Updates (changes) the value for a time period. Throws a * {@link SeriesException} if the period does not exist. * * @param period the period ({@code null} not permitted). * @param value the value ({@code null} permitted). */ public void update(RegularTimePeriod period, Number value) { TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value); int index = Collections.binarySearch(this.data, temp); if (index < 0) { throw new SeriesException("There is no existing value for the " + "specified 'period'."); } update(index, value); }
/** * Updates (changes) the value for a time period. Throws a * {@link SeriesException} if the period does not exist. * * @param period the period (<code>null</code> not permitted). * @param value the value (<code>null</code> permitted). */ public void update(RegularTimePeriod period, Number value) { TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value); int index = Collections.binarySearch(this.data, temp); if (index < 0) { throw new SeriesException("There is no existing value for the " + "specified 'period'."); } update(index, value); }
/** * Outputs the given DataPoint to the current TimeSeries. * @param dataPoint the DataPoint to output to the current TimeSeries. */ private void output( DataPoint dataPoint, String timeVariable ) throws InstantiationException, IllegalAccessException, InvocationTargetException, InstantiationException { long timeValue = (long)dataPoint.getIndependentValue(timeVariable); Object[] args = new Object[1]; args[0] = new Date( timeValue ); RegularTimePeriod period = (RegularTimePeriod)timePeriodConstructor.newInstance(args); double value = dataPoint.getDependentValue(); timeSeries.add( new TimeSeriesDataItem(period,value) ); } }
/** * Outputs the given DataPoint to the current TimeSeries. * @param dataPoint the DataPoint to output to the current TimeSeries. */ private void output( DataPoint dataPoint, String timeVariable ) throws InstantiationException, IllegalAccessException, InvocationTargetException, InstantiationException { long timeValue = (long)dataPoint.getIndependentValue(timeVariable); Object[] args = new Object[1]; args[0] = new Date( timeValue ); RegularTimePeriod period = (RegularTimePeriod)timePeriodConstructor.newInstance(args); double value = dataPoint.getDependentValue(); timeSeries.add( new TimeSeriesDataItem(period,value) ); } }
private TimeSeries computeSingleTimeSeries(final List<Band> bandList, int pixelX, int pixelY, int currentLevel, String positionName) { final Band firstBand = bandList.get(0); final String firstBandName = firstBand.getName(); final int lastUnderscore = firstBandName.lastIndexOf("_"); final String suffix = positionName.isEmpty()?positionName: "_" + positionName; final String timeSeriesName = firstBandName.substring(0, lastUnderscore); final TimeSeries timeSeries = new TimeSeries(timeSeriesName + suffix); for (Band band : bandList) { final TimeCoding timeCoding = this.timeSeries.getRasterTimeMap().get(band); if (timeCoding != null) { final ProductData.UTC startTime = timeCoding.getStartTime(); final Millisecond timePeriod = new Millisecond(startTime.getAsDate(), ProductData.UTC.UTC_TIME_ZONE, Locale.getDefault()); final double value = getValue(band, pixelX, pixelY, currentLevel); timeSeries.add(new TimeSeriesDataItem(timePeriod, value)); } } return timeSeries; }
if (records.get(k).status) { try { t = new TimeSeriesDataItem(new Millisecond(records.get(k).gcal.getTime()), 1); s1.addOrUpdate(t); } catch (Exception ex) { t = new TimeSeriesDataItem(new Millisecond(records.get(k).gcal.getTime()), 0); s1.addOrUpdate(t); } catch (Exception ex) {
if (res.getOperationalRecord().get(i - 1).isOperational()) { try { t = new TimeSeriesDataItem(previous, 1); s1.add(t); } catch (Exception ex) { t = new TimeSeriesDataItem(current, 1); s1.add(t); } catch (Exception ex) { t = new TimeSeriesDataItem(previous, 0); s1.add(t); } catch (Exception ex) { t = new TimeSeriesDataItem(current, 0); s1.add(t); } catch (Exception ex) { t = new TimeSeriesDataItem(new Millisecond(res.getOperationalRecord().get(res.getOperationalRecord().size() - 1).getTimestamp().getTime()), 1); s1.add(t); t = new TimeSeriesDataItem(new Millisecond(GregorianCalendar.getInstance().getTime()), 1); s1.add(t); } else { t = new TimeSeriesDataItem(new Millisecond(res.getOperationalRecord().get(res.getOperationalRecord().size() - 1).getTimestamp().getTime()), 0); s1.add(t); t = new TimeSeriesDataItem(new Millisecond(GregorianCalendar.getInstance().getTime()), 0); s1.add(t);
RegularTimePeriod.createInstance( timePeriodClass, keyDate, RegularTimePeriod.DEFAULT_TIME_ZONE ); TimeSeriesDataItem timeSeriesDataItem = new TimeSeriesDataItem( regularTimePeriod, ( (Number) rowData[2] ).doubleValue() ); if ( wrkSeries != null ) { wrkSeries.add( timeSeriesDataItem );
private void setDataByRow( final IPentahoResultSet data ) { // TODO Make this routine MDX friendly if ( data == null ) { noDataMessage = Messages.getInstance().getString( "CHART.USER_NO_DATA_AVAILABLE" ); //$NON-NLS-1$ return; // No data so we've got nothing to set // TODO come up with some sort of error strategy here. } Class timePeriodClass = TimeSeriesCollectionChartDefinition.getTimePeriodClass( getDomainPeriodType() ); Object[] rowData = data.next(); while ( rowData != null ) { String seriesName = (String) rowData[0]; TimeSeries wrkSeries = new TimeSeries( seriesName, timePeriodClass ); for ( int column = 1; column < rowData.length - 1; column = column + 2 ) { Date keyDate = getValidDate( rowData[column] ); TimeSeriesDataItem timeSeriesDataItem = new TimeSeriesDataItem( RegularTimePeriod.createInstance( timePeriodClass, keyDate, RegularTimePeriod.DEFAULT_TIME_ZONE ), ( (Number) rowData[column + 1] ).doubleValue() ); wrkSeries.add( timeSeriesDataItem ); } addSeries( wrkSeries ); rowData = data.next(); } if ( ( data.getRowCount() > 0 ) && ( this.getSeriesCount() <= 0 ) ) { noDataMessage = Messages.getInstance().getString( "CHART.USER_INCORRECT_DATA_FORMAT" ); //$NON-NLS-1$ } }