/** * Creates a new (empty) dataset. */ public DefaultCategoryDataset() { this.data = new DefaultKeyedValues2D(); }
/** * Returns the number of series in the dataset. * * @return The series count. */ @Override public int getSeriesCount() { return this.values.getColumnCount(); }
/** * Returns the value for a given chip x and y or null. * * @param chipx the x-index. * @param chipy the y-index. * * @return The data value. */ public Number getChipValue(Comparable chipx, Comparable chipy) { int rowIndex = this.data.getRowIndex(chipx); if (rowIndex < 0) { return null; } int colIndex = this.data.getColumnIndex(chipy); if (colIndex < 0) { return null; } return this.data.getValue(rowIndex, colIndex); }
/** * Removes a column. * * @param columnIndex the column index. * * @see #removeColumn(Comparable) * @see #removeRow(int) */ public void removeColumn(int columnIndex) { Comparable columnKey = getColumnKey(columnIndex); removeColumn(columnKey); }
if (!getRowKeys().equals(kv2D.getRowKeys())) { return false; if (!getColumnKeys().equals(kv2D.getColumnKeys())) { return false; int rowCount = getRowCount(); if (rowCount != kv2D.getRowCount()) { return false; int colCount = getColumnCount(); if (colCount != kv2D.getColumnCount()) { return false; Number v1 = getValue(r, c); Number v2 = kv2D.getValue(r, c); if (v1 == null) {
/** * Returns the set of unique values. * * @return The set of unique values. */ public Set getUniqueValues() { Set unique = new TreeSet(); //step through all the values and add them to the hash for (int r = 0; r < this.data.getRowCount(); r++) { for (int c = 0; c < this.data.getColumnCount(); c++) { Number value = this.data.getValue(r, c); if (value != null) { unique.add(value); } } } return unique; }
/** * Removes all data items from the dataset and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @since 1.0.7 */ public void clear() { if (this.values.getRowCount() > 0) { this.values.clear(); fireDatasetChanged(); } }
/** * Returns the key for a series. * * @param series the series (zero-based index). * * @return The key for the series. */ @Override public Comparable getSeriesKey(int series) { return this.values.getColumnKey(series); }
/** * Returns the number of items in ALL series. * * @return The item count. */ @Override public int getItemCount() { return this.values.getRowCount(); }
/** * Returns a clone of the dataset. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * dataset. */ public Object clone() throws CloneNotSupportedException { DefaultCategoryDataset clone = (DefaultCategoryDataset) super.clone(); clone.data = (DefaultKeyedValues2D) this.data.clone(); return clone; }
/** * Adds a value to the table. Performs the same function as setValue(). * * @param value the value. * @param rowKey the row key. * @param columnKey the column key. * * @see #getValue(Comparable, Comparable) * @see #removeValue(Comparable, Comparable) */ public void addValue(Number value, Comparable rowKey, Comparable columnKey) { this.data.addValue(value, rowKey, columnKey); fireDatasetChanged(); }
return false; if (!this.values.equals(that.values)) { return false;
/** * Clears all data from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. */ public void clear() { this.data.clear(); fireDatasetChanged(); }
/** * Returns the column keys. * * @return The keys. * * @see #getColumnKey(int) */ @Override public List getColumnKeys() { return this.data.getColumnKeys(); }
/** * Returns the column index for a given key. * * @param key the column key (<code>null</code> not permitted). * * @return The column index. * * @see #getColumnKey(int) */ public int getColumnIndex(Comparable key) { // defer null argument check return this.data.getColumnIndex(key); }
if (!getRowKeys().equals(kv2D.getRowKeys())) { return false; if (!getColumnKeys().equals(kv2D.getColumnKeys())) { return false; int rowCount = getRowCount(); if (rowCount != kv2D.getRowCount()) { return false; int colCount = getColumnCount(); if (colCount != kv2D.getColumnCount()) { return false; Number v1 = getValue(r, c); Number v2 = kv2D.getValue(r, c); if (v1 == null) {
/** * Returns the set of unique values. * * @return The set of unique values. */ public Set getUniqueValues() { Set unique = new TreeSet(); //step through all the values and add them to the hash for (int r = 0; r < this.data.getRowCount(); r++) { for (int c = 0; c < this.data.getColumnCount(); c++) { Number value = this.data.getValue(r, c); if (value != null) { unique.add(value); } } } return unique; }
/** * Removes all data items from the dataset and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @since 1.0.7 */ public void clear() { if (this.values.getRowCount() > 0) { this.values.clear(); fireDatasetChanged(); } }
/** * Removes a column. * * @param columnIndex the column index. * * @see #removeColumn(Comparable) * @see #removeRow(int) */ public void removeColumn(int columnIndex) { Comparable columnKey = getColumnKey(columnIndex); removeColumn(columnKey); }
/** * Returns a column key. * * @param column the column index (zero-based). * * @return The column key. * * @see #getColumnIndex(Comparable) */ public Comparable getColumnKey(int column) { return this.data.getColumnKey(column); }