/** * Returns a collection of all the time periods in the time series. * * @return A collection of all the time periods. */ public Collection getTimePeriods() { Collection result = new java.util.ArrayList(); for (int i = 0; i < getItemCount(); i++) { result.add(getTimePeriod(i)); } 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; }
/** * Returns a collection of all the time periods in the time series. * * @return A collection of all the time periods. */ public Collection getTimePeriods() { Collection result = new java.util.ArrayList(); for (int i = 0; i < getItemCount(); i++) { result.add(getTimePeriod(i)); } return result; }
/** * Returns the ending X value for the specified series and item. * * @param series The series (zero-based index). * @param item The item (zero-based index). * * @return The value. */ @Override public synchronized Number getEndX(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); return new Long(ts.getTimePeriod(item).getLastMillisecond( this.workingCalendar)); }
/** * Returns the x-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public Number getX(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); RegularTimePeriod period = ts.getTimePeriod(item); return new Long(getX(period)); }
/** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value. */ public double getXValue(int series, int item) { TimeSeries s = (TimeSeries) this.data.get(series); RegularTimePeriod period = s.getTimePeriod(item); return getX(period); }
/** * Returns the ending X value for the specified series and item. * * @param series The series (zero-based index). * @param item The item (zero-based index). * * @return The value. */ public synchronized Number getEndX(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); return new Long(ts.getTimePeriod(item).getLastMillisecond( this.workingCalendar)); }
/** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ @Override public synchronized Number getStartX(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); return new Long(ts.getTimePeriod(item).getFirstMillisecond( this.workingCalendar)); }
/** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public synchronized Number getStartX(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); return new Long(ts.getTimePeriod(item).getFirstMillisecond( this.workingCalendar)); }
/** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value. */ @Override public double getXValue(int series, int item) { TimeSeries s = (TimeSeries) this.data.get(series); RegularTimePeriod period = s.getTimePeriod(item); return getX(period); }
/** * Returns the x-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ @Override public Number getX(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); RegularTimePeriod period = ts.getTimePeriod(item); return new Long(getX(period)); }
/** * Returns a time period that would be the next in sequence on the end of * the time series. * * @return The next time period. */ public RegularTimePeriod getNextTimePeriod() { RegularTimePeriod last = getTimePeriod(getItemCount() - 1); return last.next(); }
/** * Returns a collection of time periods in the specified series, but not in * this series, and therefore unique to the specified series. * * @param series the series to check against this one. * * @return The unique time periods. */ public Collection getTimePeriodsUniqueToOtherSeries(TimeSeries series) { Collection result = new java.util.ArrayList(); for (int i = 0; i < series.getItemCount(); i++) { RegularTimePeriod period = series.getTimePeriod(i); int index = getIndex(period); if (index < 0) { result.add(period); } } return result; }
/** * Constructs a new TimeSeriesBuilder that reads its input from the given * TimeSeries object. This builder defaults the of the independent, time * variable to be the class name of the RegularTimePeriod used in the * TimeSeries. For example, if a series of org.jfree.data.time.Day objects * are used, then the name of the independent variable will default to * "Day" (without the quotes). * * See the class description for more information. * @param timeSeries the TimeSeries object containing data to be used to * build the DataSet. * @throws IllegalArgumentException if the TimeSeries is empty. */ public TimeSeriesBuilder( TimeSeries timeSeries ) { if ( timeSeries.getItemCount() <= 0 ) throw new IllegalArgumentException("TimeSeries cannot be empty."); this.timeSeries = timeSeries; // Use base name of TimePeriod class, as name of time variable RegularTimePeriod timePeriod = timeSeries.getTimePeriod(0); String name = timePeriod.getClass().getName(); name = name.substring( name.lastIndexOf(".")+1 ); addVariable( name ); }
public String generateLabel(XYDataset dataset, int series, int item) { Comparable seriesName = dataset.getSeriesKey(series); Map labels = (Map)labelsMap.get(seriesName); if(labels != null) { return (String)labels.get(((TimeSeriesCollection)dataset).getSeries(series).getTimePeriod(item)); } return super.generateLabel( dataset, series, item ); } }
/** * Returns a time period that would be the next in sequence on the end of * the time series. * * @return The next time period. */ public RegularTimePeriod getNextTimePeriod() { RegularTimePeriod last = getTimePeriod(getItemCount() - 1); return last.next(); }
/** * Returns a collection of time periods in the specified series, but not in * this series, and therefore unique to the specified series. * * @param series the series to check against this one. * * @return The unique time periods. */ public Collection getTimePeriodsUniqueToOtherSeries(TimeSeries series) { Collection result = new java.util.ArrayList(); for (int i = 0; i < series.getItemCount(); i++) { RegularTimePeriod period = series.getTimePeriod(i); int index = getIndex(period); if (index < 0) { result.add(period); } } return result; }
TimeChart.TimeDataRow[] generateDataSet(final TimeSeriesCollection dataSet, XYURLGenerator urlGenerator, TimeZoneManager timeZoneManager) { final TimePeriodUtils timePeriodUtils = new TimePeriodUtils(timeZoneManager); final TimeSeries issuesSeries = dataSet.getSeries(0); TimeSeries totalSeries = dataSet.getSeries(1); TimeSeries averageSeries = dataSet.getSeries(2); int count = issuesSeries.getItems().size(); ArrayList<TimeDataRow> data = new ArrayList<TimeChart.TimeDataRow>(count); for (int i = 0; i < count; i++) { final int issues = issuesSeries.getValue(i).intValue(); final int total = totalSeries.getValue(i).intValue(); final int avg = averageSeries.getValue(i).intValue(); final String issuesLink = urlGenerator != null ? urlGenerator.generateURL(dataSet, 0, i) : null; final RegularTimePeriod timePeriod = issuesSeries.getTimePeriod(i); data.add(new TimeChart.TimeDataRow(timePeriodUtils.prettyPrint(timePeriod), issues, issuesLink, total, avg)); } return data.toArray(new TimeChart.TimeDataRow[data.size()]); } }
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; }
public String generateURL(XYDataset xyDataset, int series, int item) { TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection) xyDataset; TimeSeries timeSeries = timeSeriesCollection.getSeries(series); RegularTimePeriod period = timeSeries.getTimePeriod(item); SearchRequest searchUrlSuffix; StatisticsMapper createdMapper = new DatePeriodStatisticsMapper( ChartUtil.getTimePeriodClass(periodName), DocumentConstants.ISSUE_UPDATED, timeZoneManager.getLoggedInUserTimeZone()); searchUrlSuffix = createdMapper.getSearchUrlSuffix(period, searchRequestCopy); return velocityRequestContext.getCanonicalBaseUrl() + "/secure/IssueNavigator.jspa?reset=true" + searchService.getQueryString(jiraAuthenticationContext.getLoggedInUser(), searchUrlSuffix.getQuery()); } };