org.jfree.data.category

Class SlidingCategoryDataset

Implemented Interfaces:
CategoryDataset, Cloneable, Dataset, KeyedValues2D, ObjectInputValidation, Serializable, Values2D

public class SlidingCategoryDataset
extends AbstractDataset
implements CategoryDataset

A CategoryDataset implementation that presents a subset of the categories in an underlying dataset. The index of the first "visible" category can be modified, which provides a means of "sliding" through the categories in the underlying dataset.
Since:
1.0.10

Constructor Summary

SlidingCategoryDataset(CategoryDataset underlying, int firstColumn, int maxColumns)
Creates a new instance.

Method Summary

Object
clone()
Returns an independent copy of the dataset.
boolean
equals(Object obj)
Tests this SlidingCategoryDataset for equality with an arbitrary object.
int
getColumnCount()
Returns the number of columns in the table.
int
getColumnIndex(Comparable key)
Returns the index for the specified column key.
Comparable
getColumnKey(int column)
Returns the column key for a given index.
List
getColumnKeys()
Returns the column keys.
int
getFirstCategoryIndex()
Returns the index of the first visible category.
int
getMaximumCategoryCount()
Returns the maximum category count.
int
getRowCount()
Returns the number of rows in the table.
int
getRowIndex(Comparable key)
Returns the row index for a given key.
Comparable
getRowKey(int row)
Returns the row key for a given index.
List
getRowKeys()
Returns the row keys.
CategoryDataset
getUnderlyingDataset()
Returns the underlying dataset that was supplied to the constructor.
Number
getValue(Comparable rowKey, Comparable columnKey)
Returns the value for a pair of keys.
Number
getValue(int row, int column)
Returns a value from the table.
void
setFirstCategoryIndex(int first)
Sets the index of the first category that should be used from the underlying dataset, and sends a DatasetChangeEvent to all registered listeners.
void
setMaximumCategoryCount(int max)
Sets the maximum category count and sends a DatasetChangeEvent to all registered listeners.

Methods inherited from class org.jfree.data.general.AbstractDataset

addChangeListener, clone, fireDatasetChanged, getGroup, hasListener, notifyListeners, removeChangeListener, setGroup, validateObject

Constructor Details

SlidingCategoryDataset

public SlidingCategoryDataset(CategoryDataset underlying,
                              int firstColumn,
                              int maxColumns)
Creates a new instance.
Parameters:
underlying - the underlying dataset (null not permitted).
firstColumn - the index of the first visible column from the underlying dataset.
maxColumns - the maximumColumnCount.

Method Details

clone

public Object clone()
            throws CloneNotSupportedException
Returns an independent copy of the dataset. Note that:
  • the underlying dataset is only cloned if it implements the PublicCloneable interface;
  • the listeners registered with this dataset are not carried over to the cloned dataset.
Overrides:
clone in interface AbstractDataset
Returns:
An independent copy of the dataset.

equals

public boolean equals(Object obj)
Tests this SlidingCategoryDataset for equality with an arbitrary object.
Parameters:
obj - the object (null permitted).
Returns:
A boolean.

getColumnCount

public int getColumnCount()
Returns the number of columns in the table.
Specified by:
getColumnCount in interface Values2D
Returns:
The column count.

getColumnIndex

public int getColumnIndex(Comparable key)
Returns the index for the specified column key.
Specified by:
getColumnIndex in interface KeyedValues2D
Parameters:
key - the key.
Returns:
The column index, or -1 if the key is not recognised.

getColumnKey

public Comparable getColumnKey(int column)
Returns the column key for a given index.
Specified by:
getColumnKey in interface KeyedValues2D
Parameters:
column - the column index (zero-based).
Returns:
The column key.

getColumnKeys

public List getColumnKeys()
Returns the column keys.
Specified by:
getColumnKeys in interface KeyedValues2D
Returns:
The keys.

getFirstCategoryIndex

public int getFirstCategoryIndex()
Returns the index of the first visible category.
Returns:
The index.

getMaximumCategoryCount

public int getMaximumCategoryCount()
Returns the maximum category count.
Returns:
The maximum category count.

getRowCount

public int getRowCount()
Returns the number of rows in the table.
Specified by:
getRowCount in interface Values2D
Returns:
The row count.

getRowIndex

public int getRowIndex(Comparable key)
Returns the row index for a given key.
Specified by:
getRowIndex in interface KeyedValues2D
Parameters:
key - the row key.
Returns:
The row index, or -1 if the key is unrecognised.

getRowKey

public Comparable getRowKey(int row)
Returns the row key for a given index.
Specified by:
getRowKey in interface KeyedValues2D
Parameters:
row - the row index (zero-based).
Returns:
The row key.

getRowKeys

public List getRowKeys()
Returns the row keys.
Specified by:
getRowKeys in interface KeyedValues2D
Returns:
The keys.

getUnderlyingDataset

public CategoryDataset getUnderlyingDataset()
Returns the underlying dataset that was supplied to the constructor.
Returns:
The underlying dataset (never null).

getValue

public Number getValue(Comparable rowKey,
                       Comparable columnKey)
Returns the value for a pair of keys.
Specified by:
getValue in interface KeyedValues2D
Parameters:
rowKey - the row key (null not permitted).
columnKey - the column key (null not permitted).
Returns:
The value (possibly null).

getValue

public Number getValue(int row,
                       int column)
Returns a value from the table.
Specified by:
getValue in interface Values2D
Parameters:
row - the row index (zero-based).
column - the column index (zero-based).
Returns:
The value (possibly null).

setFirstCategoryIndex

public void setFirstCategoryIndex(int first)
Sets the index of the first category that should be used from the underlying dataset, and sends a DatasetChangeEvent to all registered listeners.
Parameters:
first - the index.

setMaximumCategoryCount

public void setMaximumCategoryCount(int max)
Sets the maximum category count and sends a DatasetChangeEvent to all registered listeners.
Parameters:
max - the maximum.