com.odesys.chart.image
Class ChartImage

java.lang.Object
  |
  +--com.odesys.chart.image.ChartImage
Direct Known Subclasses:
BarChartImage, BubbleChartImage, LineChartImage, PieChartImage

public abstract class ChartImage
extends java.lang.Object

ChartImage is the abstract superclass of the chart image generation components. They are intended to be used on a web server to generate dynamic chart images. ChartImage only handles the creation of the image, so it has to be placed in a Servlet or JSP page that specifies the parameters and provides the OutputStream that the image data is written into. In general the Servet will do the following:
1. Create a ChartImage instance.
2. Create appropriate ChartModel or use the default one and set its data.
3. Invoke write() with an appropriate OutputStream (most likely a ByteArrayOutputStream that will be used as a buffer).
4. Set the content type of the Response to "image/jpeg", set the content length.
5. Write the data to the OutputStream of the Response.
ChartImage is not Thread-safe and may produce unexpected results if used by multiple threads. ChartImage uses the package com.sun.image.codec.jpeg, which is not part of the Java 2 Platform. It is provided with Sun's Java 2 SDK and therefore ChartImage requres Sun's Java 2 Runtime Environment.


Constructor Summary
ChartImage()
          Creates new ChartImage instance.
 
Method Summary
protected abstract  Chart createChart()
          Factory methods that creates the Chart instance to be used by this ChartImage.
protected  Chart getChart()
          Gets the Chart instance used by this ChartImage.
 ChartModel getModel()
          Gets the ChartModel used by this ChartImage.
 void setBackground(java.awt.Color color)
          Sets the background color of this ChartImage.
 void setChartBackground(java.awt.Color color)
          Sets the background color of the internal ChartView.
 void setChartContoursVisible(boolean visible)
          Detemines whether the contours of the Chart elements should be drawn.
 void setChartFont(java.awt.Font font)
          Sets the font of the internal ChartView.
 void setChartForeground(java.awt.Color color)
          Sets the foreground color of the internal ChartView.
 void setFont(java.awt.Font font)
          Sets the Font of this ChartImage.
 void setLabelsVisible(boolean visible)
          Sets whether the labels of this ChartImage elements are drawn.
 void setLegendBackground(java.awt.Color color)
          Sets the background color of the internal LegendView.
 void setLegendContoursVisible(boolean visible)
          Detemines whether the contours of the Legend items should be drawn.
 void setLegendFont(java.awt.Font font)
          Sets the font of the internal LegendView.
 void setLegendForeground(java.awt.Color color)
          Sets the foreground color of the internal LegendView.
 void setLegendVisible(boolean visible)
          Shows or hides the Legend depending on the value of parameter visible.
 void setModel(ChartModel model)
          Sets the ChartModel to be used by this ChartImage.
 void setQuality(float quality)
          Sets the quality of the produced JPEG.
 void setSize(int width, int height)
          Sets the size of the image to be produced.
 void write(java.io.OutputStream out)
          Writes the ChartImage JPEG data into the provided OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChartImage

public ChartImage()
Creates new ChartImage instance.
Method Detail

createChart

protected abstract Chart createChart()
Factory methods that creates the Chart instance to be used by this ChartImage. The subclasses should implement this method to create the appropriate Chart.

getChart

protected Chart getChart()
Gets the Chart instance used by this ChartImage.
Returns:
The Chart instance used by this ChartImage.

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Writes the ChartImage JPEG data into the provided OutputStream.
Parameters:
out - The OutputStream to write the JPEG data into.

setQuality

public void setQuality(float quality)
Sets the quality of the produced JPEG. Higher values give better quality.
Parameters:
quality - The quality of the produced JPEG [0.0f, 1.0f].

getModel

public ChartModel getModel()
Gets the ChartModel used by this ChartImage.
Returns:
The ChartModel used by this ChartImage.

setModel

public void setModel(ChartModel model)
              throws java.lang.IllegalArgumentException
Sets the ChartModel to be used by this ChartImage.
Parameters:
model - The ChartModel to be used by this ChartImage.

setSize

public void setSize(int width,
                    int height)
Sets the size of the image to be produced.
Parameters:
width - The width of the image.
height - The height of the image.

setBackground

public void setBackground(java.awt.Color color)
Sets the background color of this ChartImage.
Parameters:
color - The background color of this ChartImage.

setFont

public void setFont(java.awt.Font font)
Sets the Font of this ChartImage.
Parameters:
font - The Font of this ChartImage.

setLegendVisible

public void setLegendVisible(boolean visible)
Shows or hides the Legend depending on the value of parameter visible.
Parameters:
visible - If true, shows the Legend; otherwise, hides the Legend.

setLabelsVisible

public void setLabelsVisible(boolean visible)
Sets whether the labels of this ChartImage elements are drawn.

setChartContoursVisible

public void setChartContoursVisible(boolean visible)
Detemines whether the contours of the Chart elements should be drawn.

setLegendContoursVisible

public void setLegendContoursVisible(boolean visible)
Detemines whether the contours of the Legend items should be drawn.

setChartBackground

public void setChartBackground(java.awt.Color color)
Sets the background color of the internal ChartView.
Parameters:
color - The background color of the internal ChartView.

setChartForeground

public void setChartForeground(java.awt.Color color)
Sets the foreground color of the internal ChartView.
Parameters:
color - The foreground color of the internal ChartView.

setChartFont

public void setChartFont(java.awt.Font font)
Sets the font of the internal ChartView.
Parameters:
font - The font of the internal ChartView.

setLegendBackground

public void setLegendBackground(java.awt.Color color)
Sets the background color of the internal LegendView.
Parameters:
color - The background color of the internal LegendView.

setLegendForeground

public void setLegendForeground(java.awt.Color color)
Sets the foreground color of the internal LegendView.
Parameters:
color - The foreground color of the internal LegendView.

setLegendFont

public void setLegendFont(java.awt.Font font)
Sets the font of the internal LegendView.
Parameters:
font - The font of the internal LegendView.