com.davisor.graphics.chart
Class ImageChart

java.lang.Object
  extended bycom.davisor.graphics.chart.AbstractChart
      extended bycom.davisor.graphics.chart.ImageChart
All Implemented Interfaces:
Chart, java.io.Serializable
Direct Known Subclasses:
BufferedChart, SVGChart

public class ImageChart
extends AbstractChart

ImageChart represents an image chart.

ImageChart objects may also contain information about the general inner layout of chart components over the surface of the chart image. Two main areas are defined: chart backround area, and chart plot area. Plot area resides inside chart backround area, and chart backround resides inside chart image area. Plot area defines principal chart data visualization area, like for example the inner bounds of a 2D coordinate axis system. Background area covers that too, plus any labels and titles running along the coordinate axis system edges. Outside backround area there may still be some outer decorations, like a wide outer borderline.

ImageChart objects may also contain a reference to a Java Graphics2D context that if used for drawing, will apply additional graphics over the chart image. The context, in available, will always initially have identity transformation and no clipping regions. The initial values of all other graphics context parameters are undefined, and they should be explicitly set before invoking any operations that depend on them.

ImageChart comes also with a set of convenience image encoding methods to encoding chart images into different image formats. This functionality relies on the encoding powers of the CodecFactory class.

ImageChart sub-classes may define additional or alternative methods to access chart image data.

Since:
JDK1.2
See Also:
ChartAttributes, ChartData, ChartFactory, Serialized Form

Field Summary
protected  java.awt.geom.Rectangle2D M_backArea
          Chart background area.
protected  AnnotatedGraphics2D M_graphics
          Chart graphics content.
protected  java.awt.Image M_image
          Chart image.
protected  java.lang.String M_imageParams
          Chart content encoding image parameters.
protected  java.awt.geom.Rectangle2D M_plotArea
          Chart plot area.
 
Fields inherited from class com.davisor.graphics.chart.AbstractChart
M_annotatedShapes, M_contentType, M_height, M_resolution, M_width
 
Constructor Summary
  ImageChart(ImageChart ic)
          Shallow copy constructor.
protected ImageChart(java.lang.Number width, java.lang.Number height, java.lang.Number resolution, java.lang.String contentType, java.util.List annotatedShapes)
          Creates a new image chart.
  ImageChart(java.lang.Number width, java.lang.Number height, java.lang.Number resolution, java.lang.String contentType, java.util.List annotatedShapes, AnnotatedGraphics2D graphics, java.awt.Image image, java.lang.String imageParams, java.awt.geom.Rectangle2D backArea, java.awt.geom.Rectangle2D plotArea)
          Creates a new image chart.
protected ImageChart(java.lang.Number width, java.lang.Number height, java.lang.Number resolution, java.lang.String contentType, java.util.List annotatedShapes, java.lang.String imageParams)
          Creates a new image chart.
 
Method Summary
 java.util.List getAnnotatedShapes()
          Returns the current list of recorded serializable annotated shapes.
 java.awt.geom.Rectangle2D getBackArea()
          Gets the chart background area bounds.
 java.awt.Graphics2D getGraphics()
          Gets the chart graphics' context.
 java.awt.Image getImage()
          Gets chart image.
 java.lang.String getImageParams()
          Gets chart image parameters.
 java.awt.geom.Rectangle2D getPlotArea()
          Gets the chart plot area bounds.
 void putContent(java.io.OutputStream stream)
          Puts the chart content.
 void putImage(java.io.OutputStream stream)
          Deprecated. replaced with putContent(java.io.OutputStream)
 void putImage(java.io.OutputStream stream, java.lang.String mime)
          Writes the chart image into an output stream, using spesific encoding.
 void putImage(java.lang.String file)
          Writes the chart image into a file.
 void putImage(java.lang.String file, java.lang.String contentType)
          Writes the chart image into a file, using given MIME type.
protected  void setAntialiasDefaults(ChartAttributes attr)
          Sets current graphics' context antialias default rendering hints.
protected  void setAntialiasMode(ChartAttributes attr)
          Sets current graphics' context antialias rendering hints.
protected  void setAntialiasMode(int antialiasMode)
          Sets current graphics' context antialias rendering hints.
protected  java.lang.Object writeReplace()
          Subsitutes this object with a ByteArrayChart object during this object serialization.
 
Methods inherited from class com.davisor.graphics.chart.AbstractChart
addAnnotatedShape, getContentType, getHeight, getHeightInMillimeters, getResolution, getSizeInMillimeters, getWidth, getWidthInMillimeters, putChart, putChart, setContentType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

M_backArea

protected java.awt.geom.Rectangle2D M_backArea
Chart background area.


M_graphics

protected transient AnnotatedGraphics2D M_graphics
Chart graphics content.


M_image

protected java.awt.Image M_image
Chart image.


M_imageParams

protected java.lang.String M_imageParams
Chart content encoding image parameters.


M_plotArea

protected java.awt.geom.Rectangle2D M_plotArea
Chart plot area.

Constructor Detail

ImageChart

public ImageChart(ImageChart ic)
Shallow copy constructor.

Parameters:
ic - image chart to be copied

ImageChart

protected ImageChart(java.lang.Number width,
                     java.lang.Number height,
                     java.lang.Number resolution,
                     java.lang.String contentType,
                     java.util.List annotatedShapes)
Creates a new image chart.

Parameters:
width - chart width, in millimeters (may be null)
height - chart height, in millimeters (may be null)
resolution - resolution, in pixels-per-millimeters (may be null)
contentType - chart content encoding type (may be null)
annotatedShapes - list of annotated shapes (may be null)

ImageChart

protected ImageChart(java.lang.Number width,
                     java.lang.Number height,
                     java.lang.Number resolution,
                     java.lang.String contentType,
                     java.util.List annotatedShapes,
                     java.lang.String imageParams)
Creates a new image chart.

Parameters:
width - chart width, in millimeters (may be null)
height - chart height, in millimeters (may be null)
resolution - resolution, in pixels-per-millimeters (may be null)
contentType - chart content encoding type (may be null)
annotatedShapes - list of annotated shapes (may be null)
imageParams - image encoding parameters (may be null)

ImageChart

public ImageChart(java.lang.Number width,
                  java.lang.Number height,
                  java.lang.Number resolution,
                  java.lang.String contentType,
                  java.util.List annotatedShapes,
                  AnnotatedGraphics2D graphics,
                  java.awt.Image image,
                  java.lang.String imageParams,
                  java.awt.geom.Rectangle2D backArea,
                  java.awt.geom.Rectangle2D plotArea)
Creates a new image chart.

Parameters:
width - chart width, in millimeters (may be null)
height - chart height, in millimeters (may be null)
resolution - resolution, in pixels-per-millimeters (may be null)
contentType - chart content encoding type (may be null)
annotatedShapes - list of annotated shapes (may be null)
graphics - graphics context to draw into the chart image (may be null)
image - the chart image (may be null, in which case a sub-class should provide an alternative way to access chart image)
imageParams - image encoding parameters
backArea - chart background area bounds (may be null)
plotArea - chart plot area bounds (may be null)
See Also:
AbstractChart.getHeight(), getImage(), AbstractChart.getWidth()
Method Detail

getAnnotatedShapes

public java.util.List getAnnotatedShapes()
Returns the current list of recorded serializable annotated shapes. The annotated shapes are represented with AnnotatedSerializableShape objects, with the annotation information as label, and the corresponding serializable shape as assosiated object.

The list elements are arranged in last-in-first-out (LIFO) order, so that shapes drawn last are encountered first when traversing the list from beginning to end.

The returned list object refers directly to the list object this Chart uses to store the recorded shapes. Any modifications to the list will therefore affect this Chart instance, too.

This implementation of this method calls the corresponding AnnotatedGraphics2D.getAnnotatedShapes() method of the current graphics context instance.

Specified by:
getAnnotatedShapes in interface Chart
Overrides:
getAnnotatedShapes in class AbstractChart
Returns:
list of serializable annotated shapes
See Also:
AnnotatedGraphics2D.getAnnotatedShapes()

putContent

public void putContent(java.io.OutputStream stream)
                throws java.io.IOException
Puts the chart content.

Parameters:
stream - stream to write chart content into
Throws:
java.io.IOException - if an I/O error occurs
See Also:
AbstractChart.getContentType(), putImage(OutputStream,String)

setAntialiasMode

protected void setAntialiasMode(ChartAttributes attr)
Sets current graphics' context antialias rendering hints. If antialias mode is 'RenderAttributes.AUTO', default antialias hints as defined by setAntialiasDefaults(com.davisor.graphics.chart.ChartAttributes) are set.

Parameters:
attr - attributes to read antialias mode from
See Also:
setAntialiasDefaults(ChartAttributes), setAntialiasMode(int), ChartAttributes.getAntialiasMode()

setAntialiasMode

protected void setAntialiasMode(int antialiasMode)
Sets current graphics' context antialias rendering hints.

Parameters:
antialiasMode - antialias mode (as defined by RenderAttributes
See Also:
ChartAttributes.getAntialiasMode()

setAntialiasDefaults

protected void setAntialiasDefaults(ChartAttributes attr)
Sets current graphics' context antialias default rendering hints.

This default implementation seeks chart attributes encoder info with ChartAttributes.getEncoderInfo(), and if found, applies them on curreng graphics.

Parameters:
attr - attributes to read encoder info from
See Also:
ChartAttributes.getEncoderInfo(), MimeInfo, MimeInfo.configureHints(java.awt.Graphics2D)

getBackArea

public java.awt.geom.Rectangle2D getBackArea()
Gets the chart background area bounds. Depending of chart implementation, chart bounds may or may not be available. If they are, the background bounds define the area over which chart has been painted. This includes any data visualizations, labels, titles, any any other chart related decorations. The area outside the bounds is not part of the actual chart, but contains for example boundary line or other decorations. The bounds will therefore equal to the whole chart if and only if the chart image contains no boundary decorations.

Returns:
chart backround area bounds (may be null)
See Also:
AbstractChart.getHeight(), getPlotArea(), AbstractChart.getWidth()

getGraphics

public java.awt.Graphics2D getGraphics()
Gets the chart graphics' context. Depending of chart implementation, the context may or may not be available. If it is, any drawing applied to ot will affect the chart image. If the context is not not available, null is returned.

See Also:
getImage()

getImage

public java.awt.Image getImage()
Gets chart image.

Chart sub-classes may define additional or alternative methods to access chart image data. If sub-class implementation can not provide a direct reference to chart image, null is returned. In that case, the sub-class should provide an alternative method to access the image data.

See Also:
getGraphics()

getImageParams

public java.lang.String getImageParams()
Gets chart image parameters. These parameters specify additional image encoding parameters, as described by CodecFactory.getImageEncoder(java.lang.String) method.

Returns:
additional image encoding parameters

getPlotArea

public java.awt.geom.Rectangle2D getPlotArea()
Gets the chart plot area bounds. Depending of chart implementation, chart bounds may or may not be available. If they are, the plot area bounds define the principal area over which chart visualizations have been painted. This area does not cover labels, titles, or any other decorations drawn for example around coordinate axes.

Returns:
chart plot area bounds (may be null)
See Also:
getBackArea(), AbstractChart.getHeight(), AbstractChart.getWidth()

putImage

public void putImage(java.lang.String file)
              throws java.io.IOException
Writes the chart image into a file. The image is encoded by CodecFactory, using the current MIME type.

Parameters:
file - output file name
Throws:
java.io.IOException - if an I/O error occurs,
See Also:
AbstractChart.getContentType(), putImage(OutputStream), putImage(String,String)

putImage

public void putImage(java.io.OutputStream stream)
              throws java.io.IOException
Deprecated. replaced with putContent(java.io.OutputStream)

Writes the chart image into an output stream. The image is encoded by CodecFactory, using the current MIME type.

Parameters:
stream - output stream
Throws:
java.io.IOException - if an I/O error occurs
See Also:
putImage(String), putImage(OutputStream,String), ChartAttributes.getContentType(), CodecFactory

putImage

public void putImage(java.lang.String file,
                     java.lang.String contentType)
              throws java.io.IOException
Writes the chart image into a file, using given MIME type. The image is encoded by CodecFactory. If the given encoding type is null, the default encoding type image/png is used instead.

Parameters:
file - output file name
contentType - output MIME type (may be null)
Throws:
java.io.IOException - if an I/O error occurs
See Also:
putImage(OutputStream,String)

putImage

public void putImage(java.io.OutputStream stream,
                     java.lang.String mime)
              throws java.io.IOException
Writes the chart image into an output stream, using spesific encoding. The image is encoded by CodecFactory. If the given mime type is null, the default encoding type image/png is used instead.

Parameters:
stream - output stream
mime - output mime type (may be null)
Throws:
java.io.IOException
See Also:
getImage(), CodecFactory.putImage(Image,OutputStream,String)

writeReplace

protected java.lang.Object writeReplace()
                                 throws java.io.ObjectStreamException
Subsitutes this object with a ByteArrayChart object during this object serialization.

Throws:
java.io.ObjectStreamException
See Also:
ByteArrayChart.ByteArrayChart(Chart)


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.