Package org.jfree.data.category
Class SlidingCategoryDataset
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.category.SlidingCategoryDataset
-
- All Implemented Interfaces:
java.io.ObjectInputValidation,java.io.Serializable,java.lang.Cloneable,CategoryDataset,Dataset,KeyedValues2D,Values2D
public class SlidingCategoryDataset extends AbstractDataset implements CategoryDataset
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.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private intfirstCategoryIndexThe index of the first category to present.private intmaximumCategoryCountThe maximum number of categories to present.private CategoryDatasetunderlyingThe underlying dataset.
-
Constructor Summary
Constructors Constructor Description SlidingCategoryDataset(CategoryDataset underlying, int firstColumn, int maxColumns)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Returns an independent copy of the dataset.booleanequals(java.lang.Object obj)Tests thisSlidingCategoryDatasetfor equality with an arbitrary object.intgetColumnCount()Returns the number of columns in the table.intgetColumnIndex(java.lang.Comparable key)Returns the index for the specified column key.java.lang.ComparablegetColumnKey(int column)Returns the column key for a given index.java.util.ListgetColumnKeys()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(java.lang.Comparable key)Returns the row index for a given key.java.lang.ComparablegetRowKey(int row)Returns the row key for a given index.java.util.ListgetRowKeys()Returns the row keys.CategoryDatasetgetUnderlyingDataset()Returns the underlying dataset that was supplied to the constructor.java.lang.NumbergetValue(int row, int column)Returns a value from the table.java.lang.NumbergetValue(java.lang.Comparable rowKey, java.lang.Comparable columnKey)Returns the value for a pair of keys.private intlastCategoryIndex()Returns the index of the last column for this dataset, or -1.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, canEqual, fireDatasetChanged, getGroup, getNotify, hashCode, hasListener, notifyListeners, removeChangeListener, setGroup, 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, getGroup, removeChangeListener, setGroup
-
-
-
-
Field Detail
-
underlying
private CategoryDataset underlying
The underlying dataset.
-
firstCategoryIndex
private int firstCategoryIndex
The index of the first category to present.
-
maximumCategoryCount
private int maximumCategoryCount
The maximum number of categories to present.
-
-
Constructor Detail
-
SlidingCategoryDataset
public SlidingCategoryDataset(CategoryDataset 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 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()
-
lastCategoryIndex
private int lastCategoryIndex()
Returns the index of the last column for this dataset, or -1.- Returns:
- The index.
-
getColumnIndex
public int getColumnIndex(java.lang.Comparable key)
Returns the index for the specified column key.- Specified by:
getColumnIndexin interfaceKeyedValues2D- Parameters:
key- the key.- Returns:
- The column index, or -1 if the key is not recognised.
-
getColumnKey
public java.lang.Comparable getColumnKey(int column)
Returns the column key for a given index.- Specified by:
getColumnKeyin interfaceKeyedValues2D- Parameters:
column- the column index (zero-based).- Returns:
- The column key.
- Throws:
java.lang.IndexOutOfBoundsException- ifrowis out of bounds.
-
getColumnKeys
public java.util.List getColumnKeys()
Returns the column keys.- Specified by:
getColumnKeysin interfaceKeyedValues2D- Returns:
- The keys.
- See Also:
getColumnKey(int)
-
getRowIndex
public int getRowIndex(java.lang.Comparable key)
Returns the row index for a given key.- Specified by:
getRowIndexin interfaceKeyedValues2D- Parameters:
key- the row key.- Returns:
- The row index, or
-1if the key is unrecognised.
-
getRowKey
public java.lang.Comparable getRowKey(int row)
Returns the row key for a given index.- Specified by:
getRowKeyin interfaceKeyedValues2D- Parameters:
row- the row index (zero-based).- Returns:
- The row key.
- Throws:
java.lang.IndexOutOfBoundsException- ifrowis out of bounds.
-
getRowKeys
public java.util.List getRowKeys()
Returns the row keys.- Specified by:
getRowKeysin interfaceKeyedValues2D- Returns:
- The keys.
-
getValue
public java.lang.Number getValue(java.lang.Comparable rowKey, java.lang.Comparable columnKey)Returns the value for a pair of keys.- Specified by:
getValuein interfaceKeyedValues2D- 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.
-
getValue
public java.lang.Number getValue(int row, int column)Returns a value from the table.
-
equals
public boolean equals(java.lang.Object obj)
Tests thisSlidingCategoryDatasetfor equality with an arbitrary object.- Overrides:
equalsin classAbstractDataset- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns 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:
java.lang.CloneNotSupportedException- if the dataset cannot be cloned for any reason.
- the underlying dataset is only cloned if it implements the
-
-