com.davisor.graphics.chart
Class AbstractChart

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

public abstract class AbstractChart
extends java.lang.Object
implements Chart

AbstractChart represents a base class for all concrete implementations of the Chart interface.

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

Field Summary
protected  java.util.List M_annotatedShapes
          List of serializable annotated shapes.
protected  java.lang.String M_contentType
          Chart content MIME type.
protected  java.lang.Number M_height
          Chart height, in millimeters.
protected  java.lang.Number M_resolution
          Chart pixels-per-millimeter raster image resolution.
protected  java.lang.Number M_width
          Chart width, in millimeters.
 
Constructor Summary
  AbstractChart(AbstractChart ac)
          Shallow copy constructor.
protected AbstractChart(java.lang.Number width, java.lang.Number height, java.lang.Number resolution, java.lang.String contentType, java.util.List annotatedShapes)
          Creates a new abstract chart.
 
Method Summary
 void addAnnotatedShape(java.lang.Object shape)
           
 java.util.List getAnnotatedShapes()
          Get the current list of recorded annotated shapes.
 java.lang.String getContentType()
          Gets the chart content MIME type.
 float getHeight()
          Gets chart height as described by Chart.getHeight().
 float getHeightInMillimeters()
          Gets chart height in pixels.
 java.lang.Number getResolution()
          Gets chart raster image pixels-per-millimeter resolution as described by Chart.getResolution().
static float getSizeInMillimeters(float size, java.lang.Number resolution)
          Computes chart size in pixels.
 float getWidth()
          Gets chart width as described by Chart.getWidth().
 float getWidthInMillimeters()
          Gets chart width in pixels.
 void putChart(java.lang.String file)
          Writes this chart into a file, using current MIME type.
static void putChart(java.lang.String file, Chart chart)
          Writes given chart into a file, using chart current MIME type.
 void setContentType(java.lang.String contentType)
          Sets the chart content MIME type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.davisor.graphics.chart.Chart
putContent
 

Field Detail

M_annotatedShapes

protected java.util.List M_annotatedShapes
List of serializable annotated shapes.


M_contentType

protected java.lang.String M_contentType
Chart content MIME type.


M_height

protected java.lang.Number M_height
Chart height, in millimeters.


M_resolution

protected java.lang.Number M_resolution
Chart pixels-per-millimeter raster image resolution.


M_width

protected java.lang.Number M_width
Chart width, in millimeters.

Constructor Detail

AbstractChart

public AbstractChart(AbstractChart ac)
Shallow copy constructor.

Parameters:
ac - chart to be copied

AbstractChart

protected AbstractChart(java.lang.Number width,
                        java.lang.Number height,
                        java.lang.Number resolution,
                        java.lang.String contentType,
                        java.util.List annotatedShapes)
Creates a new abstract 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 MIME type (may be null)
annotatedShapes - list of annotated shapes (may be null)
Method Detail

getAnnotatedShapes

public java.util.List getAnnotatedShapes()
Get the current list of recorded annotated shapes. The annotated shapes are represented with AnnotatedShape objects, with the annotation information as label, and the corresponding 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 instance uses to store the recorded shapes. Any modifications to the list will therefore affect this instance, too.

Specified by:
getAnnotatedShapes in interface Chart

addAnnotatedShape

public void addAnnotatedShape(java.lang.Object shape)

getContentType

public java.lang.String getContentType()
Gets the chart content MIME type.

Specified by:
getContentType in interface Chart
Returns:
content encoding MIME type (never null)
See Also:
Chart.putContent(java.io.OutputStream), setContentType(java.lang.String)

getHeight

public float getHeight()
Gets chart height as described by Chart.getHeight().

If chart height is not set, zero is returned.

Specified by:
getHeight in interface Chart
See Also:
getWidth(), getResolution()

getResolution

public java.lang.Number getResolution()
Gets chart raster image pixels-per-millimeter resolution as described by Chart.getResolution().

Specified by:
getResolution in interface Chart
Returns:
chart resolution (may be null)
See Also:
getHeight(), getWidth(), ChartAttributes.getResolution()

getWidth

public float getWidth()
Gets chart width as described by Chart.getWidth().

If chart height is not set, zero is returned.

Specified by:
getWidth in interface Chart
See Also:
getHeight(), getResolution()

getHeightInMillimeters

public float getHeightInMillimeters()
Gets chart height in pixels.

Returns:
chart height in pixels
See Also:
getHeight(), getResolution(), getSizeInMillimeters(float, java.lang.Number)

getWidthInMillimeters

public float getWidthInMillimeters()
Gets chart width in pixels.

Returns:
chart width in pixels
See Also:
getResolution(), getSizeInMillimeters(float, java.lang.Number), getWidth()

getSizeInMillimeters

public static float getSizeInMillimeters(float size,
                                         java.lang.Number resolution)
Computes chart size in pixels. If given resolution is defined, chart size in pixels equals given millimeters size, multiplied by the resolution (pixels/millimeter), and rounded up to the next integer value. If given resolution is null, the given size is expected to already be expressed in pixels, and it is therefore just returned unmodified.

Parameters:
size - chart size
resolution - chart resolution (may be null)
Returns:
chart size in pixels

putChart

public void putChart(java.lang.String file)
              throws java.io.IOException
Writes this chart into a file, using current MIME type.

Parameters:
file - output file name
Throws:
java.io.IOException - if an I/O error occurs

putChart

public static void putChart(java.lang.String file,
                            Chart chart)
                     throws java.io.IOException
Writes given chart into a file, using chart current MIME type.

Parameters:
file - output file name
chart - chart to write
Throws:
java.io.IOException - if an I/O error occurs

setContentType

public void setContentType(java.lang.String contentType)
Sets the chart content MIME type. Chart content type does not typically change, but if it does, this can be done with this method. Please note however that this method is not part of the principal Chart interface.

Parameters:
contentType - new chart content type
See Also:
getContentType()


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