org.corpstein.image
Class ChartData

java.lang.Object
  extended by org.corpstein.image.ChartData

public class ChartData
extends java.lang.Object

Encapsulates the data (data points, labels, title, etc) needed to create a chart using ChartFactory.

Version:
$Revision: 1.3 $ $Date: 2005/04/24 20:45:36 $
Author:
David Corpstein

Constructor Summary
ChartData()
          Sole constructor.
 
Method Summary
 void addKeyLabel(java.lang.String label)
          Adds the specified label to the list of key labels
 void addLabel(java.lang.String label)
          Adds the specified label to the list of labels
 void addPoint(java.lang.String label, double value)
          Adds the specified label-value pair to the list of points, converting the double value to a Double object
 void addPoint(java.lang.String label, float value)
          Adds the specified label-value pair to the list of points, converting the float value to a Double object
 void addPoint(java.lang.String label, int value)
          Adds the specified label-value pair to the list of points, converting the int value to a Double object
 void addPoint(java.lang.String label, java.lang.Number value)
          Adds the specified label-value pair to the list of points, converting the Number value to a Double object
 void addValue(double value)
          Adds the specified value, converting the double to a Double
 void addValue(float value)
          Adds the specified value, converting the float to a Double
 void addValue(int value)
          Adds the specified value, converting the int to a Double
 void addValue(java.lang.Number value)
          Adds the specified value, converting the Number to a Double
 java.lang.String getKeyLabel(int index)
          Returns the key label based on the specified index
 java.lang.String getLabel(int index)
          Returns the label based on the specified index
 double getMaximumValue()
          Returns the maximum value that the ChartData object contains as a double
 java.lang.String getTitle()
          Returns the title String
 int getTotalColumns()
          Returns the total number of columns defined in the ChartData object
 int getTotalKeys()
          Returns the total number of keys defined in the ChartData object
 double getTotalValue()
          Returns the total of all of the calues defined in the ChartData object
 int getTotalValues()
          Returns the total number of values defined in the ChartData object
 int getTotalValuesPerColumn()
          Returns the total number of values per columns defined in the ChartData object
 double getValue(int index)
          Returns the value stored at the specified index
 void setKeyLabel(int index, java.lang.String text)
          Sets the key label String at the specified index
 void setLabel(int index, java.lang.String text)
          Sets the label String at the specified index
 void setTitle(java.lang.String title)
          Sets the title String to the specified text
 java.lang.String toString()
          Creates and returns a String describing all of the contents of the ChartData object for debugging use
 void validate()
          Called before the ChartData object is used to create a chart.
 void validateColumns()
          Sets the total values per column and checks to make sure that the number of values and labels match.
 void validateKeys()
          Checks to make sure the number of values per column matches the number of key labels
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChartData

public ChartData()
Sole constructor. Initializes title and internal Lists.

Method Detail

addKeyLabel

public void addKeyLabel(java.lang.String label)
Adds the specified label to the list of key labels

Parameters:
label - The key label to add

addLabel

public void addLabel(java.lang.String label)
Adds the specified label to the list of labels

Parameters:
label - The label to add

addPoint

public void addPoint(java.lang.String label,
                     double value)
              throws java.lang.IllegalStateException
Adds the specified label-value pair to the list of points, converting the double value to a Double object

Parameters:
label - The point's label
value - The point's double value
Throws:
java.lang.IllegalStateException

addPoint

public void addPoint(java.lang.String label,
                     int value)
Adds the specified label-value pair to the list of points, converting the int value to a Double object

Parameters:
label - The point's label
value - The point's int value

addPoint

public void addPoint(java.lang.String label,
                     float value)
Adds the specified label-value pair to the list of points, converting the float value to a Double object

Parameters:
label - The point's label
value - The point's float value

addPoint

public void addPoint(java.lang.String label,
                     java.lang.Number value)
Adds the specified label-value pair to the list of points, converting the Number value to a Double object

Parameters:
label - The point's label
value - The point's Number value

addValue

public void addValue(double value)
Adds the specified value, converting the double to a Double

Parameters:
value - The double value

addValue

public void addValue(int value)
Adds the specified value, converting the int to a Double

Parameters:
value - The int value

addValue

public void addValue(float value)
Adds the specified value, converting the float to a Double

Parameters:
value - The float value

addValue

public void addValue(java.lang.Number value)
Adds the specified value, converting the Number to a Double

Parameters:
value - The Number value

getKeyLabel

public java.lang.String getKeyLabel(int index)
Returns the key label based on the specified index

Parameters:
index - The index of the key label
Returns:
The key label

getLabel

public java.lang.String getLabel(int index)
Returns the label based on the specified index

Parameters:
index - The index of the label
Returns:
The label

getMaximumValue

public double getMaximumValue()
Returns the maximum value that the ChartData object contains as a double

Returns:
The maximum value stored by the ChartData object

getTitle

public java.lang.String getTitle()
Returns the title String

Returns:
The title String

getTotalColumns

public int getTotalColumns()
Returns the total number of columns defined in the ChartData object

Returns:
The total number of columns

getTotalKeys

public int getTotalKeys()
Returns the total number of keys defined in the ChartData object

Returns:
The total number of keys

getTotalValue

public double getTotalValue()
Returns the total of all of the calues defined in the ChartData object

Returns:
The total value

getTotalValues

public int getTotalValues()
Returns the total number of values defined in the ChartData object

Returns:
The total number of values

getTotalValuesPerColumn

public int getTotalValuesPerColumn()
Returns the total number of values per columns defined in the ChartData object

Returns:
The total number of values per columns

getValue

public double getValue(int index)
Returns the value stored at the specified index

Returns:
The value stored at the specified index

setKeyLabel

public void setKeyLabel(int index,
                        java.lang.String text)
Sets the key label String at the specified index

Parameters:
index - The index of the key label to set
text - The String to set the key label to
Throws:
java.lang.IllegalArgumentException - if the text parameter is null

setLabel

public void setLabel(int index,
                     java.lang.String text)
Sets the label String at the specified index

Parameters:
index - The index of the label to set
text - The String to set the label to
Throws:
java.lang.IllegalArgumentException - if the text parameter is null

setTitle

public void setTitle(java.lang.String title)
Sets the title String to the specified text

Parameters:
title - The String to set the title to
Throws:
java.lang.IllegalArgumentException - if the title parameter is null

toString

public java.lang.String toString()
Creates and returns a String describing all of the contents of the ChartData object for debugging use

Overrides:
toString in class java.lang.Object
Returns:
a String describing all of the contents of the ChartData object

validate

public void validate()
Called before the ChartData object is used to create a chart. Calls validateColumns to ensure that the number of labels and values match.


validateKeys

public void validateKeys()
Checks to make sure the number of values per column matches the number of key labels

Throws:
java.lang.IllegalStateException - if the number of values per column does not match the number of key labels

validateColumns

public void validateColumns()
                     throws java.lang.IllegalStateException
Sets the total values per column and checks to make sure that the number of values and labels match.

Throws:
java.lang.IllegalStateException - if the total labels and values do not match


Last update: 20050424 1651