JMSLTM Numerical Library 6.1

com.imsl.chart
Class Chart

java.lang.Object
  extended by com.imsl.chart.AbstractChartNode
      extended by com.imsl.chart.ChartNode
          extended by com.imsl.chart.Chart
All Implemented Interfaces:
Printable, Serializable, Cloneable

public class Chart
extends ChartNode
implements Cloneable, Printable

The root node of the chart tree.

This chart node creates the following child nodes: Background, ChartTitle and Legend.

See Also:
Example, Chart Programmer's Guide, Serialized Form

Field Summary
 
Fields inherited from class com.imsl.chart.ChartNode
AXIS_X_TOP, AXIS_Y_RIGHT, BAR_TYPE_HORIZONTAL, BAR_TYPE_VERTICAL, DASH_PATTERN_DASH, DASH_PATTERN_DASH_DOT, DASH_PATTERN_DOT, DASH_PATTERN_SOLID, DATA_TYPE_FILL, DATA_TYPE_LINE, DATA_TYPE_MARKER, DATA_TYPE_PICTURE, DATA_TYPE_TUBE, DENDROGRAM_TYPE_HORIZONTAL, DENDROGRAM_TYPE_VERTICAL, FILL_TYPE_GRADIENT, FILL_TYPE_NONE, FILL_TYPE_PAINT, FILL_TYPE_SOLID, LABEL_TYPE_PERCENT, MARKER_TYPE_ASTERISK, MARKER_TYPE_CIRCLE_CIRCLE, MARKER_TYPE_CIRCLE_PLUS, MARKER_TYPE_CIRCLE_X, MARKER_TYPE_DIAMOND_PLUS, MARKER_TYPE_FILLED_CIRCLE, MARKER_TYPE_FILLED_DIAMOND, MARKER_TYPE_FILLED_SQUARE, MARKER_TYPE_FILLED_TRIANGLE, MARKER_TYPE_HOLLOW_CIRCLE, MARKER_TYPE_HOLLOW_DIAMOND, MARKER_TYPE_HOLLOW_SQUARE, MARKER_TYPE_HOLLOW_TRIANGLE, MARKER_TYPE_OCTAGON_PLUS, MARKER_TYPE_OCTAGON_X, MARKER_TYPE_PLUS, MARKER_TYPE_SQUARE_PLUS, MARKER_TYPE_SQUARE_X, MARKER_TYPE_X, TEXT_X_CENTER, TEXT_X_LEFT, TEXT_X_RIGHT, TEXT_Y_BOTTOM, TEXT_Y_CENTER, TEXT_Y_TOP
 
Fields inherited from class com.imsl.chart.AbstractChartNode
AUTOSCALE_DATA, AUTOSCALE_DENSITY, AUTOSCALE_NUMBER, AUTOSCALE_OFF, AUTOSCALE_WINDOW, AXIS_X, AXIS_Y, AXIS_Z, LABEL_TYPE_NONE, LABEL_TYPE_TITLE, LABEL_TYPE_X, LABEL_TYPE_Y, LABEL_TYPE_Z, TRANSFORM_CUSTOM, TRANSFORM_LINEAR, TRANSFORM_LOG
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
Chart()
          This is the root of our tree, it has no parent.
Chart(Component component)
          This is the root of our tree, it has no parent.
Chart(Image image)
          This is the root of our tree, it has no parent.
 
Method Summary
 void addLegendItem(int type, ChartNode node)
          Adds a legend to this ChartNode.
 void addMouseListener(MouseListener listener)
          Adds a MouseListener to the component associated with this chart.
 void addMouseMotionListener(MouseMotionListener listener)
          Adds a MouseMotionListener to the component associated with this chart.
 Object clone()
          Returns a clone of the graphics tree.
protected  Object clone(Map hashClonedNode)
          Returns a clone of this node.
 void copy()
          Copy the chart to the clipboard.
protected  void finalize()
           
 void paint(Draw draw)
          Paints this node and all of its children.
 void paint(Graphics g)
          Paints this node and all of its children.
 void paintChart(Graphics graphics)
          Draw the chart using the given Graphics object.
 Image paintImage()
          Returns an Image of the chart.
 void pick(MouseEvent event)
          Fire the PickListeners for the nodes hit by the event.
 int print(Graphics graphics, PageFormat pageFormat, int param)
          This method implements the Printable interface.
 void repaint()
          Prepares the chart to be repainted by deleting any double buffering image.
 void setComponent(Component component)
          Sets the Component for this chart.
 void update(Graphics g)
           
 void writePNG(OutputStream os, int width, int height)
          Writes the chart as an PNG file.
 void writeSVG(Writer writer, boolean useCSS)
          Writes the chart as an SVG file.
 
Methods inherited from class com.imsl.chart.ChartNode
addPickListener, firePickListeners, getALT, getAxis, getBackground, getBarGap, getBarType, getBarWidth, getChart, getChartTitle, getChildren, getClipData, getComponent, getConcatenatedViewport, getDataType, getDoubleBuffering, getExplode, getFillOutlineColor, getFillOutlineType, getFillPaint, getFillType, getGradient, getHREF, getLegend, getLineDashPattern, getMarkerDashPattern, getMarkerThickness, getMarkerType, getParent, getReference, getScreenAxis, getScreenSize, getScreenViewport, getSize, getSkipWeekends, getTextAngle, getTextColor, getTitle, getToolTip, getViewport, isBitSet, prePaint, removePickListener, setALT, setBarGap, setBarType, setBarWidth, setChartTitle, setClipData, setCustomTransform, setDataType, setDoubleBuffering, setExplode, setFillOutlineColor, setFillOutlineColor, setFillOutlineType, setFillPaint, setFillPaint, setFillPaint, setFillType, setGradient, setGradient, setGradient, setHREF, setImage, setLineDashPattern, setMarkerDashPattern, setMarkerThickness, setMarkerType, setReference, setScreenSize, setSize, setSkipWeekends, setTextAngle, setTextColor, setTextColor, setTitle, setTitle, setToolTip, setViewport, setViewport
 
Methods inherited from class com.imsl.chart.AbstractChartNode
clone, clone, clone, getAbstractParent, getAttribute, getAutoscaleInput, getAutoscaleMinimumTimeInterval, getAutoscaleOutput, getBooleanAttribute, getChildList, getColorAttribute, getCustomTransform, getDensity, getDoubleAttribute, getFillColor, getFont, getFontName, getFontSize, getFontStyle, getImage, getIntegerAttribute, getLabelType, getLightColor, getLineColor, getLineWidth, getLocale, getMarkerColor, getMarkerSize, getName, getNumber, getPaint, getStringAttribute, getTextFormat, getTickLength, getTransform, getX, getY, isAncestorOf, isAttributeSet, isAttributeSetAtThisNode, parseColor, remove, setAttribute, setAutoscaleInput, setAutoscaleMinimumTimeInterval, setAutoscaleOutput, setDensity, setFillColor, setFillColor, setFont, setFontName, setFontSize, setFontStyle, setImage, setLabelType, setLightColor, setLightColor, setLineColor, setLineColor, setLineWidth, setLocale, setMarkerColor, setMarkerColor, setMarkerSize, setName, setNumber, setPaint, setTextFormat, setTextFormat, setTickLength, setTransform, setX, setY, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Chart

public Chart()
This is the root of our tree, it has no parent. This creates the Chart with a null component


Chart

public Chart(Component component)
This is the root of our tree, it has no parent. This creates the Chart with the named component

Parameters:
component - the Component that contains the chart.

Chart

public Chart(Image image)
This is the root of our tree, it has no parent. This creates the Chart drawn into the image.

Parameters:
image - the Image into which the chart is to be drawn.
Method Detail

addLegendItem

public void addLegendItem(int type,
                          ChartNode node)
Adds a legend to this ChartNode. This method is intended to be called from within the paint method of classes which explicitly paint their own child chart nodes. The child chart nodes to be included in the legend must be added to the legend during each call to paint of the parent chart node.

Typical users of the chart library do not need to call this routine. This method is for use by those writing new charting classes.

Parameters:
type - an int which specifies the LegendItem type. 0 = DATA_TYPE_NONE; 1 = DATA_TYPE_LINE; 2 = DATA_TYPE_MARKER; 3 = DATA_TYPE_FILL
node - the ChartNode object to which this legend is to be added

addMouseListener

public void addMouseListener(MouseListener listener)
Adds a MouseListener to the component associated with this chart. If the component is null the listener will be saved and added to the component when it is assigned.

See Also:
setComponent(java.awt.Component)

addMouseMotionListener

public void addMouseMotionListener(MouseMotionListener listener)
Adds a MouseMotionListener to the component associated with this chart. If the component is null the listener will be saved and added to the component when it is assigned.

See Also:
setComponent(java.awt.Component)

clone

public Object clone()
Returns a clone of the graphics tree.

Overrides:
clone in class Object
Returns:
an Object which is a clone of this graphics tree

clone

protected Object clone(Map hashClonedNode)
Returns a clone of this node.

Overrides:
clone in class AbstractChartNode
Parameters:
hashClonedNode - the Hashtable to be cloned
Returns:
an Object which is a clone of this node

copy

public void copy()
Copy the chart to the clipboard.


finalize

protected void finalize()
Overrides:
finalize in class Object

paint

public void paint(Draw draw)
Paints this node and all of its children.

Specified by:
paint in class ChartNode
Parameters:
draw - a Draw object to be painted

paint

public void paint(Graphics g)
Paints this node and all of its children. This should be called whenever the paint member function in the Component used in this object's constructor is called.

Parameters:
g - Graphics object to be painted

paintChart

public void paintChart(Graphics graphics)
Draw the chart using the given Graphics object.

Parameters:
graphics - is the object for which the chart is to be drawn.

paintImage

public Image paintImage()
Returns an Image of the chart.

Returns:
an Image containing a picture of the chart. Call flush() on the image when it is no longer needed.

pick

public void pick(MouseEvent event)
Fire the PickListeners for the nodes hit by the event.

Parameters:
event - MouseEvent whose position determines which nodes have been selected

print

public int print(Graphics graphics,
                 PageFormat pageFormat,
                 int param)
          throws PrinterException
This method implements the Printable interface. It prints the chart on a single page. The output is scaled to fill the page as much as possible while preserving the aspect ratio.

Specified by:
print in interface Printable
Throws:
PrinterException
See Also:
Printable

repaint

public void repaint()
Prepares the chart to be repainted by deleting any double buffering image.


setComponent

public void setComponent(Component component)
Sets the Component for this chart. Also registers MouseListeners or MouseMotionListeners that could not be added previously.

See Also:
addMouseListener(java.awt.event.MouseListener), addMouseMotionListener(java.awt.event.MouseMotionListener)

update

public void update(Graphics g)

writePNG

public void writePNG(OutputStream os,
                     int width,
                     int height)
              throws IOException
Writes the chart as an PNG file. PNG (Portable Network Graphics) is a lossless bitmap format.

Parameters:
os - is the output stream to which the PNG image is to be written.
width - is the width of the output image.
height - is the height of the output image.
Throws:
IOException - if there is a problem writing the image to the stream.
NoClassDefFoundError - if an older version of J2SE is used and the Java Advanced Imaging Toolkit cannot be found.

writeSVG

public void writeSVG(Writer writer,
                     boolean useCSS)
              throws IOException
Writes the chart as an SVG file. This method requires the Apache Batik library.

Parameters:
writer - is the output character stream
useCSS - is true if the CSS style attribute is to be used
Throws:
IOException - if there is a problem writing the file.
NoClassDefFoundError - if the Batik library cannot be found.

JMSLTM Numerical Library 6.1

Copyright © 1970-2010 Visual Numerics, Inc.
Built July 30 2010.