/** * Returns the time period at the specified index. * * @param index the index of the data item. * * @return The time period. */ public RegularTimePeriod getTimePeriod(int index) { return getRawDataItem(index).getPeriod(); }
/** * Returns the time period at the specified index. * * @param index the index of the data item. * * @return The time period. */ public RegularTimePeriod getTimePeriod(int index) { return getRawDataItem(index).getPeriod(); }
/** * Returns an integer indicating the order of this data pair object * relative to another object. * <P> * For the order we consider only the timing: * negative == before, zero == same, positive == after. * * @param o1 The object being compared to. * * @return An integer indicating the order of the data item object * relative to another object. */ @Override public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another TimeSeriesDataItem object // ------------------------------------------------------- if (o1 instanceof TimeSeriesDataItem) { TimeSeriesDataItem datapair = (TimeSeriesDataItem) o1; result = getPeriod().compareTo(datapair.getPeriod()); } // CASE 2 : Comparing to a general object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; }
/** * Returns an integer indicating the order of this data pair object * relative to another object. * <P> * For the order we consider only the timing: * negative == before, zero == same, positive == after. * * @param o1 The object being compared to. * * @return An integer indicating the order of the data item object * relative to another object. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another TimeSeriesDataItem object // ------------------------------------------------------- if (o1 instanceof TimeSeriesDataItem) { TimeSeriesDataItem datapair = (TimeSeriesDataItem) o1; result = getPeriod().compareTo(datapair.getPeriod()); } // CASE 2 : Comparing to a general object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; }
public String generateToolTip(XYDataset xyDataset, int row, int col) { final TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection) xyDataset; final TimeSeries timeSeries = timeSeriesCollection.getSeries(row); final TimeSeriesDataItem item = timeSeries.getDataItem(col); final RegularTimePeriod period = item.getPeriod(); int total = matchingIssues.get(period).intValue(); return period.toString() + ": " + total + " " + StringEscapeUtils.escapeHtml(dateField.getName()) + " " + i18nBean.getText("datacollector.tooltip.issues") + "."; } });
Class c = item.getPeriod().getClass(); if (this.timePeriodClass == null) { this.timePeriodClass = c; b.append("You are trying to add data where the time period class "); b.append("is "); b.append(item.getPeriod().getClass().getName()); b.append(", but the TimeSeries is expecting an instance of "); b.append(this.timePeriodClass.getName()); if (item.getPeriod().compareTo(last) > 0) { this.data.add(item); added = true; b.append("You are attempting to add an observation for "); b.append("the time period "); b.append(item.getPeriod().toString()); b.append(" but the series already contains an observation"); b.append(" for that time period. Duplicates are not ");
List<AverageStatusDataRow> generateDataSet(XYDataset dataset, XYURLGenerator urlGenerator) { TimeSeriesCollection timeSeries = (TimeSeriesCollection) dataset; Map<Number, AverageStatusDataRow> dataRowMap = new LinkedHashMap<Number, AverageStatusDataRow>(); TimePeriodUtils timePeriodUtils = new TimePeriodUtils(timeZoneManager); for (int seriesIndex = 0, seriesCount = timeSeries.getSeriesCount(); seriesIndex < seriesCount; ++seriesIndex) { Comparable status = timeSeries.getSeriesKey(seriesIndex); for (int xyItemIndex = 0, itemCount = timeSeries.getItemCount(seriesIndex); xyItemIndex < itemCount; ++xyItemIndex) { TimeSeriesDataItem dataItem = timeSeries.getSeries(seriesIndex).getDataItem(xyItemIndex); Number periodInMillis = timeSeries.getX(seriesIndex, xyItemIndex); AverageStatusDataRow averageStatusDataRow = dataRowMap.containsKey(periodInMillis) ? dataRowMap.get(periodInMillis) : new AverageStatusDataRow(timePeriodUtils.prettyPrint(dataItem.getPeriod())); dataRowMap.put(periodInMillis, averageStatusDataRow); Number value = dataset.getY(seriesIndex, xyItemIndex); String url = urlGenerator.generateURL(dataset, seriesIndex, xyItemIndex); averageStatusDataRow.setStatusValue(status.toString(), value.doubleValue(), url); } } return new ArrayList<AverageStatusDataRow>(dataRowMap.values()); }
/** * Builds a DataPoint from the given TimeSeriesDataItem. The name used for * the independent, time variable can be changed using the setTimeVariable * method. * @param dataItem the TimeSeriesDataItem from which the values are to be * read and used to construct a new DataPoint. * @return a DataPoint object with values as specified by the given * TimeSeriesDataItem. */ private DataPoint build( TimeSeriesDataItem dataItem ) { DataPoint dataPoint = new Observation( dataItem.getValue().doubleValue() ); // Get time value (at middle of time period) double timeValue = dataItem.getPeriod().getMiddleMillisecond(); // Store time value as independent variable dataPoint.setIndependentValue( getVariableName(0), timeValue ); return dataPoint; } }
/** * Builds a DataPoint from the given TimeSeriesDataItem. The name used for * the independent, time variable can be changed using the setTimeVariable * method. * @param dataItem the TimeSeriesDataItem from which the values are to be * read and used to construct a new DataPoint. * @return a DataPoint object with values as specified by the given * TimeSeriesDataItem. */ private DataPoint build( TimeSeriesDataItem dataItem ) { DataPoint dataPoint = new Observation( dataItem.getValue().doubleValue() ); // Get time value (at middle of time period) double timeValue = dataItem.getPeriod().getMiddleMillisecond(); // Store time value as independent variable dataPoint.setIndependentValue( getVariableName(0), timeValue ); return dataPoint; } }
for (int i = 0; i < this.data.size(); i++) { TimeSeriesDataItem item = (TimeSeriesDataItem) this.data.get(i); long millis = item.getPeriod().getMillisecond(xAnchor, calendar); if (xRange.contains(millis)) { Number n = item.getValue();
RegularTimePeriod period = current.getPeriod();
throw new IllegalArgumentException("Null 'period' argument."); Class periodClass = item.getPeriod().getClass(); if (this.timePeriodClass == null) { this.timePeriodClass = periodClass;
Class periodClass = item.getPeriod().getClass(); if (this.timePeriodClass == null) { this.timePeriodClass = periodClass;
RegularTimePeriod period = current.getPeriod();
/** * 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; }
public String generateURL(XYDataset xyDataset, int row, int col) { final TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection) xyDataset; final TimeSeries timeSeries = timeSeriesCollection.getSeries(row); final TimeSeriesDataItem item = timeSeries.getDataItem(col); final RegularTimePeriod period = item.getPeriod(); final JqlQueryBuilder jqlQueryBuilder = JqlQueryBuilder.newBuilder(searchRequest.getQuery()); final Date startDate = period.getStart(); final Date endDate = new Date(period.getEnd().getTime()); jqlQueryBuilder.where().defaultAnd().addDateRangeCondition(getJqlFieldIdFor(dateField), startDate, endDate); jqlQueryBuilder.orderBy().addSortForFieldName(dateFieldId, SortOrder.DESC, true); final QueryOptimizer optimizer = new RedundantClausesQueryOptimizer(); final Query query = optimizer.optimizeQuery(jqlQueryBuilder.buildQuery()); return velocityRequestContext.getCanonicalBaseUrl() + "/issues/?" + searchService.getQueryString(remoteUser, query); } };
/** * 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; }
TimeSeriesDataItem item = source.getRawDataItem( i - offset); RegularTimePeriod p = item.getPeriod(); Number v = item.getValue(); long currentIndex = p.getSerialIndex();
TimeSeriesDataItem item = source.getRawDataItem( i - offset); RegularTimePeriod p = item.getPeriod(); Number v = item.getValue(); long currentIndex = p.getSerialIndex();
public String generateURL(final XYDataset xyDataset, final int row, final int col) { TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection) xyDataset; TimeSeries timeSeries = timeSeriesCollection.getSeries(row); if (row == 0) // only generate urls for the first row in the dataset { final TimeSeriesDataItem item = timeSeries.getDataItem(col); final RegularTimePeriod period = item.getPeriod(); final StatisticsMapper createdMapper = new DatePeriodStatisticsMapper(ChartUtil.getTimePeriodClass(periodName), dateFieldId, timeZoneManager.getLoggedInUserTimeZone()); final SearchRequest searchUrlSuffix = createdMapper.getSearchUrlSuffix(period, searchRequest); Query query; if (searchUrlSuffix == null) { query = new QueryImpl(); } else { QueryOptimizer optimizer = new RedundantClausesQueryOptimizer(); query = optimizer.optimizeQuery(searchUrlSuffix.getQuery()); } return velocityRequestContext.getCanonicalBaseUrl() + "/issues/?" + searchService.getQueryString(remoteUser, query); } else { return null; } } };