/** * Sets the maximum category count and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param max the maximum. * * @see #getMaximumCategoryCount() */ public void setMaximumCategoryCount(int max) { if (max < 0) { throw new IllegalArgumentException("Requires 'max' >= 0."); } this.maximumCategoryCount = max; fireDatasetChanged(); }
/** * Returns the number of columns in the table. * * @return The column count. */ public int getColumnCount() { int last = lastCategoryIndex(); if (last == -1) { return 0; } else { return Math.max(last - this.firstCategoryIndex + 1, 0); } }
/** * Returns the value for a pair of keys. * * @param rowKey the row key (<code>null</code> not permitted). * @param columnKey the column key (<code>null</code> not permitted). * * @return The value (possibly <code>null</code>). * * @throws UnknownKeyException if either key is not defined in the dataset. */ public Number getValue(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getValue(r, c + this.firstCategoryIndex); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } }
/** * 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 columns in the table. * * @return The column count. */ @Override public int getColumnCount() { int last = lastCategoryIndex(); if (last == -1) { return 0; } else { return Math.max(last - this.firstCategoryIndex + 1, 0); } }
/** * Sets the maximum category count and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param max the maximum. * * @see #getMaximumCategoryCount() */ public void setMaximumCategoryCount(int max) { if (max < 0) { throw new IllegalArgumentException("Requires 'max' >= 0."); } this.maximumCategoryCount = max; fireDatasetChanged(); }
/** * Returns the index for the specified column key. * * @param key the key. * * @return The column index, or -1 if the key is not recognised. */ public int getColumnIndex(Comparable key) { int index = this.underlying.getColumnIndex(key); if (index >= this.firstCategoryIndex && index <= lastCategoryIndex()) { return index - this.firstCategoryIndex; } return -1; // we didn't find the key }
/** * Sets the index of the first category that should be used from the * underlying dataset, and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param first the index. * * @see #getFirstCategoryIndex() */ public void setFirstCategoryIndex(int first) { if (first < 0 || first >= this.underlying.getColumnCount()) { throw new IllegalArgumentException("Invalid index."); } this.firstCategoryIndex = first; fireDatasetChanged(); }
/** * Returns the column keys. * * @return The keys. * * @see #getColumnKey(int) */ public List getColumnKeys() { List result = new java.util.ArrayList(); int last = lastCategoryIndex(); for (int i = this.firstCategoryIndex; i <= last; i++) { result.add(this.underlying.getColumnKey(i)); } return Collections.unmodifiableList(result); }
/** * Sets the index of the first category that should be used from the * underlying dataset, and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param first the index. * * @see #getFirstCategoryIndex() */ public void setFirstCategoryIndex(int first) { if (first < 0 || first >= this.underlying.getColumnCount()) { throw new IllegalArgumentException("Invalid index."); } this.firstCategoryIndex = first; fireDatasetChanged(); }
/** * Returns the index for the specified column key. * * @param key the key. * * @return The column index, or -1 if the key is not recognised. */ @Override public int getColumnIndex(Comparable key) { int index = this.underlying.getColumnIndex(key); if (index >= this.firstCategoryIndex && index <= lastCategoryIndex()) { return index - this.firstCategoryIndex; } return -1; // we didn't find the key }
/** * Returns the column keys. * * @return The keys. * * @see #getColumnKey(int) */ @Override public List getColumnKeys() { List result = new java.util.ArrayList(); int last = lastCategoryIndex(); for (int i = this.firstCategoryIndex; i <= last; i++) { result.add(this.underlying.getColumnKey(i)); } return Collections.unmodifiableList(result); }