@SuppressWarnings("rawtypes") public XYEdgeSeries getSeries(Comparable key) { for(XYEdgeSeries s : seriesList) if (s.getKey().equals(key)) return s; throw new UnknownKeyException("Key not found: " + key); }
@SuppressWarnings("rawtypes") public XYEdgeSeries getSeries(Comparable key) { for(XYEdgeSeries s : seriesList) if (s.getKey().equals(key)) return s; throw new UnknownKeyException("Key not found: " + key); }
/** * Returns a series from the collection. * * @param key the key (<code>null</code> not permitted). * * @return The series with the specified key. * * @throws UnknownKeyException if <code>key</code> is not found in the * collection. * * @since 1.0.9 */ public XYSeries getSeries(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { XYSeries series = (XYSeries) iterator.next(); if (key.equals(series.getKey())) { return series; } } throw new UnknownKeyException("Key not found: " + key); }
/** * Returns a series from the collection. * * @param key the key ({@code null} not permitted). * * @return The series with the specified key. * * @throws UnknownKeyException if {@code key} is not found in the * collection. * * @since 1.0.9 */ public XYSeries getSeries(Comparable key) { Args.nullNotPermitted(key, "key"); Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { XYSeries series = (XYSeries) iterator.next(); if (key.equals(series.getKey())) { return series; } } throw new UnknownKeyException("Key not found: " + key); }
/** * Returns the start data value for one category in a series. * * @param series the required series. * @param category the required category. * * @return The start data value for one category in a series * (possibly <code>null</code>). * * @see #getStartValue(int, int) */ public Number getStartValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getStartValue(seriesIndex, itemIndex); }
/** * Returns the end data value for one category in a series. * * @param series the required series. * @param category the required category. * * @return The end data value for one category in a series (null possible). * * @see #getEndValue(int, int) */ public Number getEndValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getEndValue(seriesIndex, itemIndex); }
/** * Returns the start data value for one category in a series. * * @param series the required series. * @param category the required category. * * @return The start data value for one category in a series * (possibly {@code null}). * * @see #getStartValue(int, int) */ @Override public Number getStartValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getStartValue(seriesIndex, itemIndex); }
/** * Returns the percent complete for a given item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The percent complete. */ @Override public Number getPercentComplete(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c == -1) { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } else if (r == -1) { throw new UnknownKeyException("Unknown rowKey: " + rowKey); } else { return this.underlying.getPercentComplete(r, c + this.firstCategoryIndex); } }
/** * Returns the end value for the interval for a given series and category. * * @param rowKey the series key. * @param columnKey the category key. * * @return The end value (possibly {@code null}). * * @see #getStartValue(Comparable, Comparable) */ @Override public Number getEndValue(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c == -1) { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } else if (r == -1) { throw new UnknownKeyException("Unknown rowKey: " + rowKey); } else { return this.underlying.getEndValue(r, c + this.firstCategoryIndex); } }
/** * Returns the end data value for one category in a series. * * @param series the required series. * @param category the required category. * * @return The end data value for one category in a series (null possible). * * @see #getEndValue(int, int) */ @Override public Number getEndValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getEndValue(seriesIndex, itemIndex); }
/** * Returns the start value for the interval for a given series and category. * * @param rowKey the series key. * @param columnKey the category key. * * @return The start value (possibly {@code null}). * * @see #getEndValue(Comparable, Comparable) */ @Override public Number getStartValue(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c == -1) { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } else if (r == -1) { throw new UnknownKeyException("Unknown rowKey: " + rowKey); } else { return this.underlying.getStartValue(r, c + this.firstCategoryIndex); } }
/** * Removes a value from the collection. * * @param key the key (<code>null</code> not permitted). * * @see #removeValue(int) * * @throws UnknownKeyException if the key is not recognised. */ public void removeValue(Comparable key) { // defer argument checking int index = getIndex(key); if (index < 0) { throw new UnknownKeyException("The key (" + key.toString() + ") is not recognised."); } removeValue(index); }
/** * Returns the number of values associated with the given <code>rowKey</code> * between the given <code>start</code> and <code>end</code> values. */ public int getCount(R rowKey, C start, C end) { // fetch the relevant pair of trees final TreePair<C> treePair = getTreePair(rowKey); // ensure we found something if (treePair == null) throw new UnknownKeyException("unrecognized rowKey: " + rowKey); // return the number of values between start and end return treePair.getCount(start, end); }
/** * Returns the number of sub-intervals for a given item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The sub-interval count. * * @see #getSubIntervalCount(int, int) */ @Override public int getSubIntervalCount(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c == -1) { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } else if (r == -1) { throw new UnknownKeyException("Unknown rowKey: " + rowKey); } else { return this.underlying.getSubIntervalCount(r, c + this.firstCategoryIndex); } }
/** * Returns the value for a pair of keys. * * @param rowKey the row key ({@code null} not permitted). * @param columnKey the column key ({@code null} not permitted). * * @return The value (possibly {@code null}). * * @throws UnknownKeyException if either key is not defined in the dataset. */ @Override public Number getValue(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c == -1) { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } else if (r == -1) { throw new UnknownKeyException("Unknown rowKey: " + rowKey); } else { return this.underlying.getValue(r, c + this.firstCategoryIndex); } }
/** * Returns the number of values associated with the given <code>rowKey</code> * between the given <code>start</code> and <code>end</code> values. */ public int getCount(R rowKey, C start, C end) { // fetch the relevant pair of trees final TreePair<C> treePair = getTreePair(rowKey); // ensure we found something if (treePair == null) throw new UnknownKeyException("unrecognized rowKey: " + rowKey); // return the number of values between start and end return treePair.getCount(start, end); }
/** * Returns the number of values associated with the given <code>rowKey</code> * between the given <code>start</code> and <code>end</code> values. */ public int getCount(R rowKey, C start, C end) { // fetch the relevant pair of trees final TreePair<C> treePair = getTreePair(rowKey); // ensure we found something if (treePair == null) throw new UnknownKeyException("unrecognized rowKey: " + rowKey); // return the number of values between start and end return treePair.getCount(start, end); }
/** * Removes a value from the collection. * * @param key the key ({@code null} not permitted). * * @see #removeValue(int) * * @throws UnknownKeyException if the key is not recognised. */ public void removeValue(Comparable key) { // defer argument checking int index = getIndex(key); if (index < 0) { throw new UnknownKeyException("The key (" + key.toString() + ") is not recognised."); } removeValue(index); }
/** * Returns the data value for one category in a series. * <P> * This method is part of the CategoryDataset interface. Not particularly * meaningful for this class...returns the end value. * * @param series The required series (zero based index). * @param category The required category. * * @return The data value for one category in a series (null possible). * * @see #getEndValue(Comparable, Comparable) */ @Override public Number getValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getValue(seriesIndex, itemIndex); }
/** * Returns the value for a pair of keys. * * @param rowKey the row key ({@code null} not permitted). * @param columnKey the column key ({@code null} not permitted). * * @return The value (possibly {@code null}). * * @throws UnknownKeyException if either key is not defined in the dataset. */ @Override public Number getValue(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c == -1) { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } else if (r == -1) { throw new UnknownKeyException("Unknown rowKey: " + rowKey); } else { return this.underlying.getValue(r, c + this.firstCategoryIndex); } }