KavaChart 5.3.1 API

com.ve.kavachart.servlet
Class Bean

java.lang.Object
  extended by com.ve.kavachart.servlet.Bean
All Implemented Interfaces:
com.ve.kavachart.utility.GetParam, java.io.Serializable
Direct Known Subclasses:
areaApp, areaLineApp, barApp, barAreaApp, barLineApp, bubbleApp, columnApp, DateApp, disLabelLineApp, disLineApp, hHiLoBarApp, hiLoBarApp, hSpeedoApp, labelLineApp, LayerChartBean, lineApp, lineAreaApp, pieApp, polarApp, regressApp, sectorMapApp, speedoApp, stackBarApp, stackColumnApp, TableBean

public abstract class Bean
extends java.lang.Object
implements com.ve.kavachart.utility.GetParam, java.io.Serializable

A server side chart bean for creating image files and image streams corresponding to a list of properties. This bean is designed to be used from servlets, such as com.ve.kavachart.servlet.ChartServlet although a servlet isn't required. Subclasses of this bean load instances of various kinds of KavaChart charts, and modify data and aesthetic aspects of those charts via properties that parallel KavaChart applets. Image information can be generated in various encodings, and stored locally in the bean or written to a file.

These beans use a CacheManager to write image data to a File if required, and can identify and load a pre-written chart definition from a disk cache if it already exists. This is done by generating unique file names that correspond (via a Secure Hash Algorithm digest) to the bean's property list. If the properties are changed, the file name will also change. If a file with this bean's automatic name already exists in the disk cache, the image will not be regenerated unless the property "useCache" is set to false.

See Also:
Serialized Form

Field Summary
protected  boolean antialiasOn
           
static com.ve.kavachart.utility.CacheCleaner cacheCleaner
           
 ChartInterface chart
           
protected  com.ve.kavachart.utility.DataProvider dataProvider
           
 java.lang.String delimiter
           
protected  java.lang.String dwellLabelTemplate
           
protected  boolean dwellUseDatasetName
           
protected  boolean dwellUseString
           
protected  boolean dwellUseXValue
           
protected  boolean dwellUseY2Value
           
protected  boolean dwellUseYValue
           
protected  java.text.Format dwellXLabelFormat
           
protected  java.lang.String dwellXString
           
protected  java.lang.String dwellY2String
           
protected  java.text.NumberFormat dwellYLabelFormat
           
protected  java.lang.String dwellYString
           
protected  boolean isChartServlet
           
protected  boolean javascriptTooltips
           
static java.lang.String keyCheckFailure
           
static java.lang.String keyIP
           
protected  java.io.OutputStream logStream
           
 com.ve.kavachart.utility.ParameterParser parser
           
protected  java.util.Properties properties
           
 boolean remoteStream
           
static java.lang.String serverIP
           
protected  boolean useDwellLabel
           
protected  UserImagingCodec userImagingCodec
           
protected  java.util.Locale userLocale
           
 
Constructor Summary
Bean()
           
 
Method Summary
 void accumulateProperty(java.lang.String name, java.lang.Object value)
          Convenience method for building properties that have the form a,b,c,d,...
protected  void buildChart()
          Creates a chart instance for imaging by the CacheManager.
 void drawMyStuff(java.awt.Graphics g)
          Draws overlays (if any).
 void generate()
          Starts image generation, if the image isn't cached.
protected  void generate(boolean geometriesOnly)
          Generates the image geometries for linkmaps, as well as encoding the image when geometriesOnly is set to false.
 ChartInterface getChart()
          Returns the com.ve.kavachart.chart.ChartInterface managed by this bean.
 com.ve.kavachart.utility.DataProvider getDataProvider()
          Returns the bean's DataProvider, if defined.
 Dataset getDataset(ChartInterface chart, int which)
          Returns null.
protected  java.lang.String getDwellLabelLabelString(Datum d)
          Returns a label string for the specified Datum
protected  java.lang.String getDwellLabelXString(Datum d)
          Returns an X value string for the specified Datum
protected  java.lang.String getDwellLabelY2String(Datum d)
           
protected  java.lang.String getDwellLabelYString(Datum d)
          Returns a Y value string for the specified Datum
 java.lang.String getFileName()
          Returns the name of the file containing image data.
protected  java.lang.String getFileName(boolean geometriesOnly)
           
 byte[] getImageBytes()
          Returns a byte array of encoded image data for this chart.
 java.lang.String getLinkMap()
          Generates a link map and ALT statements to create tooltip popups over Datum objects
protected  java.lang.String getLinkMap(boolean geometriesOnly)
           
 java.io.OutputStream getLogStream()
          Returns the logging OutputStream, or null if undefined
 void getMyDatasets(java.lang.String s)
          doesn't do anything here...
 void getMyOptions()
          Generally implemented by subclasses of this class.
protected  void getOptions()
          Called to parse this chart's property list.
 java.lang.String getParameter(java.lang.String name)
          Get the value of a specified property.
 java.util.Enumeration getParameterNames()
          Return the entire property list.
 java.lang.String getProperty(java.lang.String property)
          Return a specified property.
abstract  void init()
          Must be implemented by subclass to set the protected variable "chart" to an instance of a com.ve.kavachart.chart.Chart subclass (BarChart, LineChart, etc.), and call "getOptions()".
protected  void initializeToolTipVars()
           
protected  void initLocale()
          Checks for a custom locale setting otherwise sets the charts locale to the default
 void loadProperties(java.lang.String filename)
          Load default properties from a specified file.
 void log(java.lang.String s)
          Log errors.
 java.awt.Image makeURLImage(java.lang.String s)
          Creates an Image from the specified filename.
protected  java.io.InputStream openFile(java.lang.String s)
           
 java.io.InputStream openURL(java.lang.String s)
          Internal utility method
 void setDataProvider(com.ve.kavachart.utility.DataProvider dp)
          Sets an external data provider for this chart.
protected  void setDelimiter()
          Sets the delimiter if parser is null
 void setLogStream(java.io.OutputStream out)
          Sets the output stream used to log errors
 void setProperties(java.util.Properties props)
          Copy the property values of props into this chart bean.
 void setProperty(java.lang.String property, java.lang.Object value)
          Define the specified property.
 void setStringProperty(java.lang.String property, java.lang.String value)
          Define the specified property.
 void setUserImagingCodec(UserImagingCodec codec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

remoteStream

public boolean remoteStream

parser

public com.ve.kavachart.utility.ParameterParser parser

chart

public transient ChartInterface chart

properties

protected java.util.Properties properties

logStream

protected java.io.OutputStream logStream

useDwellLabel

protected boolean useDwellLabel

dwellXLabelFormat

protected java.text.Format dwellXLabelFormat

dwellYLabelFormat

protected java.text.NumberFormat dwellYLabelFormat

dwellUseXValue

protected boolean dwellUseXValue

dwellUseYValue

protected boolean dwellUseYValue

dwellUseY2Value

protected boolean dwellUseY2Value

dwellUseString

protected boolean dwellUseString

dwellUseDatasetName

protected boolean dwellUseDatasetName

dwellXString

protected java.lang.String dwellXString

dwellYString

protected java.lang.String dwellYString

dwellY2String

protected java.lang.String dwellY2String

userImagingCodec

protected UserImagingCodec userImagingCodec

antialiasOn

protected boolean antialiasOn

javascriptTooltips

protected boolean javascriptTooltips

dwellLabelTemplate

protected java.lang.String dwellLabelTemplate

cacheCleaner

public static com.ve.kavachart.utility.CacheCleaner cacheCleaner

dataProvider

protected com.ve.kavachart.utility.DataProvider dataProvider

keyCheckFailure

public static java.lang.String keyCheckFailure

keyIP

public static java.lang.String keyIP

serverIP

public static java.lang.String serverIP

delimiter

public java.lang.String delimiter

isChartServlet

protected boolean isChartServlet

userLocale

protected java.util.Locale userLocale
Constructor Detail

Bean

public Bean()
Method Detail

setProperties

public void setProperties(java.util.Properties props)
Copy the property values of props into this chart bean.

Parameters:
props -

accumulateProperty

public void accumulateProperty(java.lang.String name,
                               java.lang.Object value)
Convenience method for building properties that have the form a,b,c,d,... This uses value's toString method to obtain a proper input for the property String. This is fine in the case of Integers and Doubles, and also allows the use of custom classes.

Parameters:
name - java.lang.String
value - java.lang.Objectg

buildChart

protected void buildChart()
                   throws ChartException
Creates a chart instance for imaging by the CacheManager.

Throws:
ChartException

drawMyStuff

public void drawMyStuff(java.awt.Graphics g)
Draws overlays (if any). This is the equivalent of ChartAppShell's drawMyStuff(Graphics)

Parameters:
g - java.awt.Graphics

generate

public void generate()
              throws ChartException
Starts image generation, if the image isn't cached.

Throws:
ChartException

generate

protected void generate(boolean geometriesOnly)
                 throws ChartException
Generates the image geometries for linkmaps, as well as encoding the image when geometriesOnly is set to false.

Parameters:
geometriesOnly -
Throws:
ChartException

getChart

public ChartInterface getChart()
Returns the com.ve.kavachart.chart.ChartInterface managed by this bean.


getDataset

public Dataset getDataset(ChartInterface chart,
                          int which)
Returns null. To be implemented by custom Bean subclasses that want to supply their own data.

Specified by:
getDataset in interface com.ve.kavachart.utility.GetParam
Parameters:
chart - com.ve.kavachart.chart.ChartInterface
which - int
Returns:
com.ve.kavachart.chart.Dataset

getDwellLabelLabelString

protected java.lang.String getDwellLabelLabelString(Datum d)
Returns a label string for the specified Datum


getDwellLabelXString

protected java.lang.String getDwellLabelXString(Datum d)
Returns an X value string for the specified Datum


getDwellLabelYString

protected java.lang.String getDwellLabelYString(Datum d)
Returns a Y value string for the specified Datum


getDwellLabelY2String

protected java.lang.String getDwellLabelY2String(Datum d)

getFileName

public java.lang.String getFileName()
                             throws java.lang.Exception
Returns the name of the file containing image data. Useful if you use the default naming scheme in an image cache.

Returns:
java.lang.String
Throws:
java.lang.Exception

getFileName

protected java.lang.String getFileName(boolean geometriesOnly)

getImageBytes

public byte[] getImageBytes()
Returns a byte array of encoded image data for this chart.

Returns:
byte[]

getLinkMap

public java.lang.String getLinkMap()
                            throws java.lang.Exception
Generates a link map and ALT statements to create tooltip popups over Datum objects

Throws:
java.lang.Exception

getLinkMap

protected java.lang.String getLinkMap(boolean geometriesOnly)
                               throws java.lang.Exception
Throws:
java.lang.Exception

getLogStream

public java.io.OutputStream getLogStream()
Returns the logging OutputStream, or null if undefined

Returns:
java.io.OutputStream

getMyDatasets

public void getMyDatasets(java.lang.String s)
doesn't do anything here... meant to be overloaded by user defined method. This function must perform create an x, y, y2 array, and then call parser.getDatasetParameters(setnumber,x,y,y2,y3) This method is overloaded by all Date subclasses to provide date parsing. User subclasses can use this method to obtain customized data, e.g. from a JDBC connection, a CORBA process, etc.

Specified by:
getMyDatasets in interface com.ve.kavachart.utility.GetParam
Parameters:
s - java.lang.String

getMyOptions

public void getMyOptions()
Generally implemented by subclasses of this class.


getOptions

protected void getOptions()
Called to parse this chart's property list.


getParameter

public java.lang.String getParameter(java.lang.String name)
Get the value of a specified property.

Specified by:
getParameter in interface com.ve.kavachart.utility.GetParam
Parameters:
name - java.lang.String
Returns:
java.lang.String

getParameterNames

public java.util.Enumeration getParameterNames()
Return the entire property list.

Returns:
java.util.Enumeration

getProperty

public java.lang.String getProperty(java.lang.String property)
Return a specified property.

Parameters:
property - java.lang.String
Returns:
java.lang.String

init

public abstract void init()
Must be implemented by subclass to set the protected variable "chart" to an instance of a com.ve.kavachart.chart.Chart subclass (BarChart, LineChart, etc.), and call "getOptions()".


initializeToolTipVars

protected void initializeToolTipVars()

initLocale

protected void initLocale()
Checks for a custom locale setting otherwise sets the charts locale to the default


loadProperties

public void loadProperties(java.lang.String filename)
Load default properties from a specified file.


log

public void log(java.lang.String s)
Log errors. Defaults to System.out.

Parameters:
s - java.lang.String

makeURLImage

public java.awt.Image makeURLImage(java.lang.String s)
Creates an Image from the specified filename. Used for loading background images, markers, pictograms, etc.

Specified by:
makeURLImage in interface com.ve.kavachart.utility.GetParam
Parameters:
s - java.lang.String
Returns:
Image

openFile

protected java.io.InputStream openFile(java.lang.String s)

openURL

public java.io.InputStream openURL(java.lang.String s)
Internal utility method

Specified by:
openURL in interface com.ve.kavachart.utility.GetParam
Parameters:
s - java.lang.String
Returns:
java.io.InputStream

setLogStream

public void setLogStream(java.io.OutputStream out)
Sets the output stream used to log errors

Parameters:
out - java.io.OutputStream

setStringProperty

public void setStringProperty(java.lang.String property,
                              java.lang.String value)
Define the specified property. This class is necessary in certain special cases when class casting is not possible. If you have problems setting properties, try using this method instead.

Parameters:
property - java.lang.String
value - java.lang.String

setProperty

public void setProperty(java.lang.String property,
                        java.lang.Object value)
Define the specified property.

Parameters:
property - java.lang.String
value - java.lang.Object

setUserImagingCodec

public void setUserImagingCodec(UserImagingCodec codec)

setDelimiter

protected void setDelimiter()
Sets the delimiter if parser is null


setDataProvider

public void setDataProvider(com.ve.kavachart.utility.DataProvider dp)
Sets an external data provider for this chart. DataProvider provides a sequence of Dataset objects that have been pre-populated with data. This is an effective way to avoid using properties to define your chart's data.

Specified by:
setDataProvider in interface com.ve.kavachart.utility.GetParam
Parameters:
dp - DataProvider
See Also:
com.ve.kavachart.applet.GetParam#setDataProvider(DataProvider)

getDataProvider

public com.ve.kavachart.utility.DataProvider getDataProvider()
Returns the bean's DataProvider, if defined.

Specified by:
getDataProvider in interface com.ve.kavachart.utility.GetParam
Returns:
DataProvider
See Also:
com.ve.kavachart.applet.GetParam#getDataProvider()

KavaChart 5.3.1 API