Module org.jfree.chart
Package org.jfree.data.category
Class SlidingCategoryDataset<R extends Comparable<R>,C extends Comparable<C>>
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.category.SlidingCategoryDataset<R,C>
-
- All Implemented Interfaces:
ObjectInputValidation,Serializable,Cloneable,CategoryDataset<R,C>,Dataset,KeyedValues2D<R,C>,Values2D
public class SlidingCategoryDataset<R extends Comparable<R>,C extends Comparable<C>> extends AbstractDataset implements CategoryDataset<R,C>
ACategoryDatasetimplementation 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
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SlidingCategoryDataset(CategoryDataset<R,C> underlying, int firstColumn, int maxColumns)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Returns an independent copy of the dataset.booleanequals(Object obj)Tests thisSlidingCategoryDatasetfor equality with an arbitrary object.intgetColumnCount()Returns the number of columns in the table.intgetColumnIndex(C key)Returns the index for the specified column key.CgetColumnKey(int column)Returns the column key for a given index.List<C>getColumnKeys()Returns the column keys.intgetFirstCategoryIndex()Returns the index of the first visible category.intgetMaximumCategoryCount()Returns the maximum category count.intgetRowCount()Returns the number of rows in the table.intgetRowIndex(R key)Returns the row index for a given key.RgetRowKey(int row)Returns the row key for a given index.List<R>getRowKeys()Returns the row keys.CategoryDataset<R,C>getUnderlyingDataset()Returns the underlying dataset that was supplied to the constructor.NumbergetValue(int row, int column)Returns a value from the table.NumbergetValue(R rowKey, C columnKey)Returns the value for a pair of keys.inthashCode()voidsetFirstCategoryIndex(int first)Sets the index of the first category that should be used from the underlying dataset, and sends aDatasetChangeEventto all registered listeners.voidsetMaximumCategoryCount(int max)Sets the maximum category count and sends aDatasetChangeEventto all registered listeners.-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, fireDatasetChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotify, validateObject
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, removeChangeListener
-
-
-
-
Constructor Detail
-
SlidingCategoryDataset
public SlidingCategoryDataset(CategoryDataset<R,C> underlying, int firstColumn, int maxColumns)
Creates a new instance.- Parameters:
underlying- the underlying dataset (nullnot permitted).firstColumn- the index of the first visible column from the underlying dataset.maxColumns- the maximumColumnCount.
-
-
Method Detail
-
getUnderlyingDataset
public CategoryDataset<R,C> getUnderlyingDataset()
Returns the underlying dataset that was supplied to the constructor.- Returns:
- The underlying dataset (never
null).
-
getFirstCategoryIndex
public int getFirstCategoryIndex()
Returns the index of the first visible category.- Returns:
- The index.
- See Also:
setFirstCategoryIndex(int)
-
setFirstCategoryIndex
public void setFirstCategoryIndex(int first)
Sets the index of the first category that should be used from the underlying dataset, and sends aDatasetChangeEventto all registered listeners.- Parameters:
first- the index.- See Also:
getFirstCategoryIndex()
-
getMaximumCategoryCount
public int getMaximumCategoryCount()
Returns the maximum category count.- Returns:
- The maximum category count.
- See Also:
setMaximumCategoryCount(int)
-
setMaximumCategoryCount
public void setMaximumCategoryCount(int max)
Sets the maximum category count and sends aDatasetChangeEventto all registered listeners.- Parameters:
max- the maximum.- See Also:
getMaximumCategoryCount()
-
getColumnIndex
public int getColumnIndex(C key)
Returns the index for the specified column key.- Specified by:
getColumnIndexin interfaceKeyedValues2D<R extends Comparable<R>,C extends Comparable<C>>- Parameters:
key- the key.- Returns:
- The column index, or -1 if the key is not recognised.
-
getColumnKey
public C getColumnKey(int column)
Returns the column key for a given index.- Specified by:
getColumnKeyin interfaceKeyedValues2D<R extends Comparable<R>,C extends Comparable<C>>- Parameters:
column- the column index (zero-based).- Returns:
- The column key.
- Throws:
IndexOutOfBoundsException- ifrowis out of bounds.
-
getColumnKeys
public List<C> getColumnKeys()
Returns the column keys.- Specified by:
getColumnKeysin interfaceKeyedValues2D<R extends Comparable<R>,C extends Comparable<C>>- Returns:
- The keys.
- See Also:
getColumnKey(int)
-
getRowIndex
public int getRowIndex(R key)
Returns the row index for a given key.- Specified by:
getRowIndexin interfaceKeyedValues2D<R extends Comparable<R>,C extends Comparable<C>>- Parameters:
key- the row key.- Returns:
- The row index, or
-1if the key is unrecognised.
-
getRowKey
public R getRowKey(int row)
Returns the row key for a given index.- Specified by:
getRowKeyin interfaceKeyedValues2D<R extends Comparable<R>,C extends Comparable<C>>- Parameters:
row- the row index (zero-based).- Returns:
- The row key.
- Throws:
IndexOutOfBoundsException- ifrowis out of bounds.
-
getRowKeys
public List<R> getRowKeys()
Returns the row keys.- Specified by:
getRowKeysin interfaceKeyedValues2D<R extends Comparable<R>,C extends Comparable<C>>- Returns:
- The keys.
-
getValue
public Number getValue(R rowKey, C columnKey)
Returns the value for a pair of keys.- Specified by:
getValuein interfaceKeyedValues2D<R extends Comparable<R>,C extends Comparable<C>>- Parameters:
rowKey- the row key (nullnot permitted).columnKey- the column key (nullnot permitted).- Returns:
- The value (possibly
null). - Throws:
UnknownKeyException- if either key is not defined in the dataset.
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the table.- Specified by:
getColumnCountin interfaceValues2D- Returns:
- The column count.
-
getRowCount
public int getRowCount()
Returns the number of rows in the table.- Specified by:
getRowCountin interfaceValues2D- Returns:
- The row count.
-
equals
public boolean equals(Object obj)
Tests thisSlidingCategoryDatasetfor equality with an arbitrary object.
-
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
PublicCloneableinterface; - the listeners registered with this dataset are not carried over to the cloned dataset.
- Overrides:
clonein classAbstractDataset- Returns:
- An independent copy of the dataset.
- Throws:
CloneNotSupportedException- if the dataset cannot be cloned for any reason.
- the underlying dataset is only cloned if it implements the
-
-