org.jfree.data.statistics

Class DefaultBoxAndWhiskerXYDataset

Implemented Interfaces:
BoxAndWhiskerXYDataset, Cloneable, Dataset, EventListener, ObjectInputValidation, RangeInfo, Serializable, SeriesChangeListener, SeriesDataset, XYDataset

public class DefaultBoxAndWhiskerXYDataset
extends AbstractXYDataset
implements BoxAndWhiskerXYDataset, RangeInfo

A simple implementation of the BoxAndWhiskerXYDataset. The dataset can hold only one series.

Constructor Summary

DefaultBoxAndWhiskerXYDataset(Comparable seriesKey)
Constructs a new box and whisker dataset.

Method Summary

void
add(Date date, BoxAndWhiskerItem item)
Adds an item to the dataset.
double
getFaroutCoefficient()
Returns the value used as the farout coefficient.
BoxAndWhiskerItem
getItem(int series, int item)
Return an item from within the dataset.
int
getItemCount(int series)
Returns the number of items in the specified series.
Number
getMaxOutlier(int series, int item)
Returns the maximum value which is not a farout, ie Q3 + (interquartile range * farout coefficient).
Number
getMaxRegularValue(int series, int item)
Returns the max-value for the specified series and item.
Number
getMeanValue(int series, int item)
Returns the mean for the specified series and item.
Number
getMedianValue(int series, int item)
Returns the median-value for the specified series and item.
Number
getMinOutlier(int series, int item)
Returns the minimum value which is not a farout.
Number
getMinRegularValue(int series, int item)
Returns the min-value for the specified series and item.
double
getOutlierCoefficient()
Returns the value used as the outlier coefficient.
List
getOutliers(int series, int item)
Returns an array of outliers for the specified series and item.
Number
getQ1Value(int series, int item)
Returns the Q1 median-value for the specified series and item.
Number
getQ3Value(int series, int item)
Returns the Q3 median-value for the specified series and item.
Range
getRangeBounds(boolean includeInterval)
Returns the range of the values in this dataset's range.
double
getRangeLowerBound(boolean includeInterval)
Returns the minimum y-value in the dataset.
double
getRangeUpperBound(boolean includeInterval)
Returns the maximum y-value in the dataset.
int
getSeriesCount()
Returns the number of series in the dataset.
Comparable
getSeriesKey(int i)
Returns the name of the series stored in this dataset.
Number
getX(int series, int item)
Returns the x-value for one item in a series.
Date
getXDate(int series, int item)
Returns the x-value for one item in a series, as a Date.
Number
getY(int series, int item)
Returns the y-value for one item in a series.
void
setFaroutCoefficient(double faroutCoefficient)
Sets the value used as the farouts coefficient.
void
setOutlierCoefficient(double outlierCoefficient)
Sets the value used as the outlier coefficient

Methods inherited from class org.jfree.data.xy.AbstractXYDataset

getDomainOrder, getXValue, getYValue

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

getSeriesCount, getSeriesKey, indexOf, seriesChanged

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

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

Constructor Details

DefaultBoxAndWhiskerXYDataset

public DefaultBoxAndWhiskerXYDataset(Comparable seriesKey)
Constructs a new box and whisker dataset.

The current implementation allows only one series in the dataset. This may be extended in a future version.

Parameters:
seriesKey - the key for the series.

Method Details

add

public void add(Date date,
                BoxAndWhiskerItem item)
Adds an item to the dataset.
Parameters:
date - the date.
item - the item.

getFaroutCoefficient

public double getFaroutCoefficient()
Returns the value used as the farout coefficient. The farout coefficient allows the calculation of which values will be off the graph.
Specified by:
getFaroutCoefficient in interface BoxAndWhiskerXYDataset
Returns:
A double representing the value used to calculate farouts.

getItem

public BoxAndWhiskerItem getItem(int series,
                                 int item)
Return an item from within the dataset.
Parameters:
series - the series index (ignored, since this dataset contains only one series).
item - the item within the series (zero-based index)
Returns:
The item.

getItemCount

public int getItemCount(int series)
Returns the number of items in the specified series.
Specified by:
getItemCount in interface XYDataset
Parameters:
series - the index (zero-based) of the series.
Returns:
The number of items in the specified series.

getMaxOutlier

public Number getMaxOutlier(int series,
                            int item)
Returns the maximum value which is not a farout, ie Q3 + (interquartile range * farout coefficient).
Specified by:
getMaxOutlier in interface BoxAndWhiskerXYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
A Number representing the maximum non-farout value.

getMaxRegularValue

public Number getMaxRegularValue(int series,
                                 int item)
Returns the max-value for the specified series and item.
Specified by:
getMaxRegularValue in interface BoxAndWhiskerXYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The max-value for the specified series and item.

getMeanValue

public Number getMeanValue(int series,
                           int item)
Returns the mean for the specified series and item.
Specified by:
getMeanValue in interface BoxAndWhiskerXYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The mean for the specified series and item.

getMedianValue

public Number getMedianValue(int series,
                             int item)
Returns the median-value for the specified series and item.
Specified by:
getMedianValue in interface BoxAndWhiskerXYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The median-value for the specified series and item.

getMinOutlier

public Number getMinOutlier(int series,
                            int item)
Returns the minimum value which is not a farout.
Specified by:
getMinOutlier in interface BoxAndWhiskerXYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
A Number representing the maximum non-farout value.

getMinRegularValue

public Number getMinRegularValue(int series,
                                 int item)
Returns the min-value for the specified series and item.
Specified by:
getMinRegularValue in interface BoxAndWhiskerXYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The min-value for the specified series and item.

getOutlierCoefficient

public double getOutlierCoefficient()
Returns the value used as the outlier coefficient. The outlier coefficient gives an indication of the degree of certainty in an unskewed distribution. Increasing the coefficient increases the number of values included. Currently only used to ensure farout coefficient is greater than the outlier coefficient
Specified by:
getOutlierCoefficient in interface BoxAndWhiskerXYDataset
Returns:
A double representing the value used to calculate outliers.

getOutliers

public List getOutliers(int series,
                        int item)
Returns an array of outliers for the specified series and item.
Specified by:
getOutliers in interface BoxAndWhiskerXYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The array of outliers for the specified series and item.

getQ1Value

public Number getQ1Value(int series,
                         int item)
Returns the Q1 median-value for the specified series and item.
Specified by:
getQ1Value in interface BoxAndWhiskerXYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The Q1 median-value for the specified series and item.

getQ3Value

public Number getQ3Value(int series,
                         int item)
Returns the Q3 median-value for the specified series and item.
Specified by:
getQ3Value in interface BoxAndWhiskerXYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The Q3 median-value for the specified series and item.

getRangeBounds

public Range getRangeBounds(boolean includeInterval)
Returns the range of the values in this dataset's range.
Specified by:
getRangeBounds in interface RangeInfo
Parameters:
includeInterval - a flag that determines whether or not the y-interval is taken into account.
Returns:
The range.

getRangeLowerBound

public double getRangeLowerBound(boolean includeInterval)
Returns the minimum y-value in the dataset.
Specified by:
getRangeLowerBound in interface RangeInfo
Parameters:
includeInterval - a flag that determines whether or not the y-interval is taken into account.
Returns:
The minimum value.

getRangeUpperBound

public double getRangeUpperBound(boolean includeInterval)
Returns the maximum y-value in the dataset.
Specified by:
getRangeUpperBound in interface RangeInfo
Parameters:
includeInterval - a flag that determines whether or not the y-interval is taken into account.
Returns:
The maximum value.

getSeriesCount

public int getSeriesCount()
Returns the number of series in the dataset.

This implementation only allows one series.

Specified by:
getSeriesCount in interface SeriesDataset
Overrides:
getSeriesCount in interface AbstractSeriesDataset
Returns:
The number of series.

getSeriesKey

public Comparable getSeriesKey(int i)
Returns the name of the series stored in this dataset.
Specified by:
getSeriesKey in interface SeriesDataset
Overrides:
getSeriesKey in interface AbstractSeriesDataset
Parameters:
i - the index of the series. Currently ignored.
Returns:
The name of this series.

getX

public Number getX(int series,
                   int item)
Returns the x-value for one item in a series.

The value returned is a Long object generated from the underlying Date object.

Specified by:
getX in interface XYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The x-value.

getXDate

public Date getXDate(int series,
                     int item)
Returns the x-value for one item in a series, as a Date.

This method is provided for convenience only.

Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The x-value as a Date.

getY

public Number getY(int series,
                   int item)
Returns the y-value for one item in a series.

This method (from the XYDataset interface) is mapped to the getMaxNonOutlierValue() method.

Specified by:
getY in interface XYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
The y-value.

setFaroutCoefficient

public void setFaroutCoefficient(double faroutCoefficient)
Sets the value used as the farouts coefficient. The farout coefficient must b greater than the outlier coefficient.
Parameters:
faroutCoefficient - being a double representing the value used to calculate farouts.

setOutlierCoefficient

public void setOutlierCoefficient(double outlierCoefficient)
Sets the value used as the outlier coefficient
Parameters:
outlierCoefficient - being a double representing the value used to calculate outliers.