no.hig.okolloen.graphics.chart
Class ScaledChartDataSet

java.lang.Object
  |
  +--no.hig.okolloen.graphics.chart.ChartDataSet
        |
        +--no.hig.okolloen.graphics.chart.ScaledChartDataSet

public class ScaledChartDataSet
extends ChartDataSet

The ScaledChartDataSet class is used to hold scaleable data values used by LineChart and BarChart. It is more or less just a vector of ChartItems.

Since:
rev 0.1

Constructor Summary
ScaledChartDataSet(int maxElements)
          Constructor for the ScaledChartDataSet class.
 
Method Summary
 void addElement(ChartItem item)
          Adds an element to the ChartDataSet.
 void addElement(double value)
          Adds an element to the ChartDataSet.
 void addElement(double value, java.awt.Color color)
          Adds an element to the ChartDataSet.
 void addElement(double value, java.awt.Color color, java.lang.String title)
          Adds an element to the ChartDataSet.
 double getScaledElementAt(int element)
          Used to retrieve a normalized representation for the value in the given item.
 java.lang.String[] getScaleLabels()
          Returns the labels that should be used to indicate max, min and intermediate values.
 void rescale()
          Used perform a rescale of the dataset.
 void setElementAt(int element, double value)
          Sets element at given index in the ChartDataSet to given value.
 void setElementAt(int element, double value, java.awt.Color color)
          Sets element at given index in the ChartDataSet to given value and color.
 void setElementAt(int element, double value, java.awt.Color color, java.lang.String title)
          Sets element at given index in the ChartDataSet to given value, color and with given title.
 
Methods inherited from class no.hig.okolloen.graphics.chart.ChartDataSet
clear, getElementAt, removeElementAt, setElementAt, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScaledChartDataSet

public ScaledChartDataSet(int maxElements)
Constructor for the ScaledChartDataSet class.
Parameters:
maxElements - the maximum number of elements held by this ChartDataSet.
Method Detail

rescale

public void rescale()
Used perform a rescale of the dataset. Use it before using the dataset in any LineChart or BarChart and when you suspect large changes in your dataset.

getScaledElementAt

public double getScaledElementAt(int element)
Used to retrieve a normalized representation for the value in the given item.
Returns:
double value with the normalized value for the given datapoint.

getScaleLabels

public java.lang.String[] getScaleLabels()
Returns the labels that should be used to indicate max, min and intermediate values.
Returns:
String[] containing five strings with max, min and intermedtiate values.

addElement

public void addElement(ChartItem item)
Adds an element to the ChartDataSet. If this results in more than the maximum number of items being held in the dataset the first element is thrown away. Rescaling is done if this value breaks the max/min limit.
Parameters:
item - the ChartItem to be added.
Overrides:
addElement in class ChartDataSet

addElement

public void addElement(double value)
Adds an element to the ChartDataSet. If this results in more than the maximum number of items being held in the dataset the first element is thrown away. Rescaling is done if this value breaks the max/min limit.
Parameters:
value - the value of this datapoint.
Overrides:
addElement in class ChartDataSet

addElement

public void addElement(double value,
                       java.awt.Color color)
Adds an element to the ChartDataSet. If this results in more than the maximum number of items being held in the dataset the first element is thrown away. Rescaling is done if this value breaks the max/min limit.
Parameters:
value - the value of this datapoint.
color - the color that will be used when representing this datapoint
Overrides:
addElement in class ChartDataSet

addElement

public void addElement(double value,
                       java.awt.Color color,
                       java.lang.String title)
Adds an element to the ChartDataSet. If this results in more than the maximum number of items being held in the dataset the first element is thrown away. Rescaling is done if this value breaks the max/min limit.
Parameters:
value - the value of this datapoint.
color - the color that will be used when representing this datapoint
title - the title to give this datapoint
Overrides:
addElement in class ChartDataSet

setElementAt

public void setElementAt(int element,
                         double value)
Sets element at given index in the ChartDataSet to given value. Rescaling is done if this value breaks the max/min limit.
Parameters:
value - the value of this datapoint.
Overrides:
setElementAt in class ChartDataSet

setElementAt

public void setElementAt(int element,
                         double value,
                         java.awt.Color color)
Sets element at given index in the ChartDataSet to given value and color. Rescaling is done if this value breaks the max/min limit.
Parameters:
value - the value of this datapoint.
color - the color of used for the datapoint.
Overrides:
setElementAt in class ChartDataSet

setElementAt

public void setElementAt(int element,
                         double value,
                         java.awt.Color color,
                         java.lang.String title)
Sets element at given index in the ChartDataSet to given value, color and with given title. Rescaling is done if this value breaks the max/min limit.
Parameters:
value - the value of this datapoint.
color - the color of used for the datapoint.
title - the title to use for this datapoint.
Overrides:
setElementAt in class ChartDataSet