com.objectplanet.chart
Class ChartDataLoader

java.lang.Object
  extended by com.objectplanet.chart.ChartDataLoader
Direct Known Subclasses:
ChartDataLoaderExt

public class ChartDataLoader
extends java.lang.Object

This is the class that reads and sets all the chart parameters for ChartApplet and ChartServlet.

Author:
Philipp Kolibaba.

Field Summary
protected  BarChart barChart
          The bar charts used.
protected  java.lang.String chartType
          Chart type.
protected  java.lang.String labelDelimiter
          Used as the label delimiter for label string "arrays".
protected  java.util.Hashtable labels
          The IDs of the labels that can be set anywhere in the chart.
protected  java.util.Hashtable labelURLs
          The URLs for the anywhere labels.
protected  java.util.Hashtable labelURLTargets
          The list of label URL targets.
protected  LineChart lineChart
          The line charts used.
protected  PieChart pieChart
          The pie charts used.
protected  java.util.Hashtable targets
          The IDs of the target value lines.
protected  Chart theChart
          Reference to the actual chart displayed.
 
Constructor Summary
ChartDataLoader()
          Creates the chart data loader.
 
Method Summary
 void addChartItemListener(ChartApplet chartApplet)
          Adds and item listener to the specified chart.
protected static java.lang.String convertLineBreaks(java.lang.String label)
          Converts the characters \ and n to '\n'.
 java.lang.String createArrayString(int[] array)
          Creates a separated string from the array.
static java.awt.Color createColor(java.lang.String color)
          Creates a color based on the string.
protected  GenericChart createExtChart(java.lang.String type)
           
 java.awt.Font createFont(java.lang.String value, java.lang.String name, int type, int size)
          Creates a font based on the information in the specified string.
protected  boolean[] getBooleanValues(java.lang.String string)
          Converts a comma seperated true/false string to a boolean array.
 Chart getChart()
          Gets the actual chart displayed
 java.lang.String getChartType()
          Gets the chart type.
protected  java.awt.Color[] getColorValues(java.lang.String string)
          Converts a comma seperated string to a color array.
protected static java.lang.Double[] getDoubleValues(java.lang.String string)
          Convers a string parameter to an array of double values.
 ChartDataLoader getOverlayDataLoader(java.lang.String name)
          Gets a data loader for specified overlay chart
protected  java.lang.String[] getStringValues(java.lang.String string, java.lang.String delimiter)
          Converts a comma seperated string to an array of strings.
protected  int[] getStyleValues(java.lang.String string)
          Converts a comma seperated string to sample highlight style types.
 void init()
          This method is called when the servlet is placed into service.
 void reset()
          Resets the chart data and features.
 java.awt.Component setChart(java.awt.Component chart)
          Sets the actual chart displayed.
 void setChartType(java.lang.String type)
          Sets the chart type.
protected  void setImage(java.lang.String name, java.awt.Image image)
          Adds an image to the chart and sets it to be used in a right way
 void setParameter(java.lang.String name, java.lang.String value)
          Sets a parameter in the chart.
 void setParameters(java.util.Hashtable parameters)
          Sets the applet parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

barChart

protected BarChart barChart
The bar charts used.


chartType

protected java.lang.String chartType
Chart type.


labelDelimiter

protected java.lang.String labelDelimiter
Used as the label delimiter for label string "arrays".


labels

protected java.util.Hashtable labels
The IDs of the labels that can be set anywhere in the chart.


labelURLs

protected java.util.Hashtable labelURLs
The URLs for the anywhere labels.


labelURLTargets

protected java.util.Hashtable labelURLTargets
The list of label URL targets.


lineChart

protected LineChart lineChart
The line charts used.


pieChart

protected PieChart pieChart
The pie charts used.


targets

protected java.util.Hashtable targets
The IDs of the target value lines.


theChart

protected Chart theChart
Reference to the actual chart displayed.

Constructor Detail

ChartDataLoader

public ChartDataLoader()
Creates the chart data loader.

Method Detail

addChartItemListener

public void addChartItemListener(ChartApplet chartApplet)
Adds and item listener to the specified chart.


convertLineBreaks

protected static java.lang.String convertLineBreaks(java.lang.String label)
Converts the characters \ and n to '\n'. Converts also the Unicode char sequences and uxxxx to valid chars.

Parameters:
label - The label with the \ and n.

createArrayString

public java.lang.String createArrayString(int[] array)
Creates a separated string from the array. This method is useful when you want to create arrays using javascript, since javasript can not use java arrays directly.

Parameters:
array - The array to convert.
Returns:
A comma separated string of numbers.

createColor

public static java.awt.Color createColor(java.lang.String color)
Creates a color based on the string. The string can either be the name of a java defined color, a comma seperated RGB string (255,255,255), or a 6-digit hex-string (#af10cd).

Returns:
The color object, or null if string is invalid.

createExtChart

protected GenericChart createExtChart(java.lang.String type)

createFont

public java.awt.Font createFont(java.lang.String value,
                                java.lang.String name,
                                int type,
                                int size)
Creates a font based on the information in the specified string.

Parameters:
value - The font string value.
name - The name of the default font.
type - The default type (Font.PLAIN, Font.BOLD, Font.ITALIC).
size - The default size.

getBooleanValues

protected boolean[] getBooleanValues(java.lang.String string)
Converts a comma seperated true/false string to a boolean array.

Parameters:
string - The comma seperated string.
Returns:
An array with true/false values.

getChart

public Chart getChart()
Gets the actual chart displayed

Returns:
The chart current data loader is used for.

getChartType

public java.lang.String getChartType()
Gets the chart type.

Returns:
Type of the chart.

getColorValues

protected java.awt.Color[] getColorValues(java.lang.String string)
Converts a comma seperated string to a color array.

Parameters:
string - The comma seperated string.
Returns:
A color array with the values, or null if not found.

getDoubleValues

protected static java.lang.Double[] getDoubleValues(java.lang.String string)
Convers a string parameter to an array of double values.

Parameters:
string - The array of string numbers.
Returns:
An array with the values, or null if not found.

getOverlayDataLoader

public ChartDataLoader getOverlayDataLoader(java.lang.String name)
Gets a data loader for specified overlay chart

Parameters:
name - The name of the overlay chart
Returns:
Data loader for overlay chart

getStringValues

protected java.lang.String[] getStringValues(java.lang.String string,
                                             java.lang.String delimiter)
Converts a comma seperated string to an array of strings.

Parameters:
string - The string parameter to return the values from.
delimiter - The field delimiter.
Returns:
A string array.

getStyleValues

protected int[] getStyleValues(java.lang.String string)
Converts a comma seperated string to sample highlight style types.

Parameters:
string - The comma seperated string.
Returns:
An integer array with the values, or null if not found.

init

public void init()
This method is called when the servlet is placed into service. It creates the bar/line/pie charts to be used for generating the chart images.


reset

public void reset()
Resets the chart data and features.


setChart

public java.awt.Component setChart(java.awt.Component chart)
Sets the actual chart displayed.

Returns:
The chart that has been set.

setChartType

public void setChartType(java.lang.String type)
Sets the chart type.

Parameters:
type - Type of the chart.

setImage

protected void setImage(java.lang.String name,
                        java.awt.Image image)
Adds an image to the chart and sets it to be used in a right way

Parameters:
name - The name of the image
image - The image object itself

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Sets a parameter in the chart. The parameters set here are the default ones for all the chart types.

Parameters:
name - The name of the parameter.
value - The value of the parameter as a string.

setParameters

public void setParameters(java.util.Hashtable parameters)
Sets the applet parameters. All the parameter keys are assumes to be lower case letter.

Parameters:
parameters - The parameters to be set.