org.jfree.data.statistics
Class DefaultBoxAndWhiskerXYDataset

java.lang.Object
  extended byorg.jfree.data.AbstractDataset
      extended byorg.jfree.data.AbstractSeriesDataset
          extended byorg.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset
All Implemented Interfaces:
BoxAndWhiskerXYDataset, java.lang.Cloneable, Dataset, java.util.EventListener, java.io.ObjectInputValidation, RangeInfo, java.io.Serializable, SeriesChangeListener, SeriesDataset, XYDataset

public class DefaultBoxAndWhiskerXYDataset
extends AbstractSeriesDataset
implements BoxAndWhiskerXYDataset, RangeInfo

A simple implementation of the BoxAndWhiskerXYDataset.

Author:
David Browning
See Also:
Serialized Form

Constructor Summary
DefaultBoxAndWhiskerXYDataset(java.lang.String seriesName)
          Constructs a new box and whisker dataset.
 
Method Summary
 void add(java.util.Date date, BoxAndWhiskerItem item)
          Adds an item to the dataset.
 double getFaroutCoefficient()
          Returns the value used as the farout coefficient.
 int getItemCount(int series)
          Returns the number of items in the specified series.
 java.lang.Number getMaximumRangeValue()
          Returns the maximum value in the dataset's range (or null if all the values in the range are null).
 java.lang.Number getMaxOutlier(int series, int item)
          Returns the maximum value which is not a farout, ie Q3 + (interquartile range * farout coefficient).
 java.lang.Number getMaxRegularValue(int series, int item)
          Returns the max-value for the specified series and item.
 java.lang.Number getMeanValue(int series, int item)
          Returns the mean for the specified series and item.
 java.lang.Number getMedianValue(int series, int item)
          Returns the median-value for the specified series and item.
 java.lang.Number getMinimumRangeValue()
          Returns the minimum value in the dataset's range (or null if all the values in the range are null).
 java.lang.Number getMinOutlier(int series, int item)
          Returns the minimum value which is not a farout.
 java.lang.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.
 java.util.List getOutliers(int series, int item)
          Returns an array of outliers for the specified series and item.
 java.lang.Number getQ1Value(int series, int item)
          Returns the Q1 median-value for the specified series and item.
 java.lang.Number getQ3Value(int series, int item)
          Returns the Q3 median-value for the specified series and item.
 int getSeriesCount()
          Returns the number of series in the dataset.
 java.lang.String getSeriesName(int i)
          Returns the name of the series stored in this dataset.
 Range getValueRange()
          Returns the range of the values in this dataset's range.
 java.util.Date getXDate(int series, int item)
          Returns the x-value for one item in a series, as a Date.
 java.lang.Number getXValue(int series, int item)
          Returns the x-value for one item in a series.
 java.lang.Number getYValue(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.AbstractSeriesDataset
seriesChanged
 
Methods inherited from class org.jfree.data.AbstractDataset
addChangeListener, clone, fireDatasetChanged, getGroup, notifyListeners, removeChangeListener, setGroup, validateObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.data.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
 

Constructor Detail

DefaultBoxAndWhiskerXYDataset

public DefaultBoxAndWhiskerXYDataset(java.lang.String seriesName)
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:
seriesName - the name of the series.
Method Detail

add

public void add(java.util.Date date,
                BoxAndWhiskerItem item)
Adds an item to the dataset.

Parameters:
date - the date.
item - the item.

getSeriesName

public java.lang.String getSeriesName(int i)
Returns the name of the series stored in this dataset.

Specified by:
getSeriesName in interface SeriesDataset
Specified by:
getSeriesName in class AbstractSeriesDataset
Parameters:
i - the index of the series. Currently ignored.
Returns:
the name of this series.

getXValue

public java.lang.Number getXValue(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:
getXValue in interface XYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
the x-value.

getXDate

public java.util.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.

getYValue

public java.lang.Number getYValue(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:
getYValue in interface XYDataset
Parameters:
series - the series (zero-based index).
item - the item (zero-based index).
Returns:
the y-value.

getMeanValue

public java.lang.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 java.lang.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.

getQ1Value

public java.lang.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 java.lang.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.

getMinRegularValue

public java.lang.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.

getMaxRegularValue

public java.lang.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.

getMinOutlier

public java.lang.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.

getMaxOutlier

public java.lang.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.

getOutliers

public java.util.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.

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

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

getSeriesCount

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

This implementation only allows one series.

Specified by:
getSeriesCount in interface SeriesDataset
Specified by:
getSeriesCount in class AbstractSeriesDataset
Returns:
the number of series.

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.

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

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

getMinimumRangeValue

public java.lang.Number getMinimumRangeValue()
Returns the minimum value in the dataset's range (or null if all the values in the range are null).

Specified by:
getMinimumRangeValue in interface RangeInfo
Returns:
the minimum value.

getMaximumRangeValue

public java.lang.Number getMaximumRangeValue()
Returns the maximum value in the dataset's range (or null if all the values in the range are null).

Specified by:
getMaximumRangeValue in interface RangeInfo
Returns:
the maximum value.

getValueRange

public Range getValueRange()
Returns the range of the values in this dataset's range.

Specified by:
getValueRange in interface RangeInfo
Returns:
the range.