com.objectplanet.chart
Class ChartApplet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--com.objectplanet.chart.ChartApplet
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.MenuContainer, java.awt.event.MouseMotionListener, java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
BarChartApplet, LineChartApplet, PieChartApplet

public abstract class ChartApplet
extends java.applet.Applet
implements java.lang.Runnable, java.awt.event.ItemListener, java.awt.event.MouseMotionListener

This is the superclass for all the chart applets, and reads the default parameters.

Author:
Bjorn J. Kvande.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String labelDelimiter
          Used as the label delimiter for label string "arrays".
protected  int sampleCountRead
          This is set after loadParameters() has been called in this class.
protected  int seriesCountRead
          This is set after loadParameters() has been called in this class.
 com.objectplanet.chart.Chart theChart
          The chart component of the applet.Use this reference to access the charts methods directly via JavaScript or subclasses.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ChartApplet()
          Creates the chart applet.
 
Method Summary
 void callJavaScript(java.lang.String javascript)
          Calls a javascript function in the applet page.
protected abstract  com.objectplanet.chart.Chart createChart(java.lang.String className)
          This is called by the constructor and creates the chart used for the applet.
static java.awt.Color createColor(java.lang.String color)
          Creates a color based on the string.
 java.awt.Font createFont(java.lang.String value, java.lang.String name, int type, int size)
          Creates a font based on the information in the specified string.
 void destroy()
          Releases all the resources claimed by the applet.
 java.applet.AppletContext getAppletContext()
          Gets the applet context.
protected  java.awt.Color[] getColorValues(java.lang.String string)
          Converts a comma seperated string to a color array.
 java.net.URL getDocumentBase()
          Gets the document base.
protected static java.lang.Double[] getDoubleValues(java.lang.String string)
          Convers a string parameter to an array of double values.
 java.lang.String getParameter(java.lang.String parameter)
          Gets the value of the specified applet parameter.
 java.lang.String getParameterPrefix()
          Gets the prefix used when reading applet parameters.
protected  java.lang.String[] getStringValues(java.lang.String string, java.lang.String delimiter)
          Converts a comma seperated string to an array of strings.
 void init()
          Initializes the default applet parameters.
 void itemStateChanged(java.awt.event.ItemEvent e)
          Called when a sample is selected.
 void loadParameters(java.util.Hashtable parameters)
          Loads the parameters into the specified hashtable.
 void loadURLParameters(java.lang.String url, java.util.Hashtable parameters)
          Loads the parameters from the specified url.
 void mouseDragged(java.awt.event.MouseEvent event)
          Required by the MouseMotionListener, does nothing.
 void mouseMoved(java.awt.event.MouseEvent event)
          Checks of the mouse is over a sample with a URL.
 void print(java.awt.Graphics g)
          Called when a print request is issued.
 void reset()
          Resets the chart data and features.
 void run()
          The automatic refresh thread.
 void setParameter(java.lang.String name, java.lang.String value)
          Sets a parameter in the chart.
 void setParameterPrefix(java.lang.String prefix)
          Sets the parameter prefix for this chart.
 void setParameters(java.util.Hashtable parameters)
          Sets the applet parameters.
 void setParentApplet(java.applet.Applet parent)
          Sets the parent applet.
 void start()
          Starts the automatic refresh thread.
 void stop()
          Stops the automatic refresh thread.
 java.lang.String toString()
          Returns the title of the chart.
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getImage, getImage, getLocale, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

labelDelimiter

protected java.lang.String labelDelimiter
Used as the label delimiter for label string "arrays".


sampleCountRead

protected int sampleCountRead
This is set after loadParameters() has been called in this class.


seriesCountRead

protected int seriesCountRead
This is set after loadParameters() has been called in this class.


theChart

public com.objectplanet.chart.Chart theChart
The chart component of the applet.Use this reference to access the charts methods directly via JavaScript or subclasses.

Constructor Detail

ChartApplet

public ChartApplet()
Creates the chart applet.

Method Detail

callJavaScript

public void callJavaScript(java.lang.String javascript)
Calls a javascript function in the applet page.

Parameters:
javascript - The javascript URL.

createChart

protected abstract com.objectplanet.chart.Chart createChart(java.lang.String className)
This is called by the constructor and creates the chart used for the applet. It can be overridden by a subclass to use a specialized class for the chart applet.

Parameters:
className - The class name of the chart.

createColor

public static java.awt.Color createColor(java.lang.String color)
Creates a color based on the string. The string can either be the name of a java defined color, a comma seperated RGB string (255,255,255), or a 6-digit hex-string (#af10cd).

Returns:
The color object, or null if string is invalid.

createFont

public java.awt.Font createFont(java.lang.String value,
                                java.lang.String name,
                                int type,
                                int size)
Creates a font based on the information in the specified string.

Parameters:
value - The font string value.
name - The name of the default font.
type - The default type (Font.PLAIN, Font.BOLD, Font.ITALIC).
size - The default size.

destroy

public void destroy()
Releases all the resources claimed by the applet.

Overrides:
destroy in class java.applet.Applet

getAppletContext

public java.applet.AppletContext getAppletContext()
Gets the applet context. If the the table is used in another component and the parent applet has been set, the parent applets context is gotten.

Overrides:
getAppletContext in class java.applet.Applet

getColorValues

protected java.awt.Color[] getColorValues(java.lang.String string)
Converts a comma seperated string to a color array.

Parameters:
string - The comma seperated string.
Returns:
A color array with the values, or null if not found.

getDocumentBase

public java.net.URL getDocumentBase()
Gets the document base.

Overrides:
getDocumentBase in class java.applet.Applet

getDoubleValues

protected static java.lang.Double[] getDoubleValues(java.lang.String string)
Convers a string parameter to an array of double values.

Parameters:
string - The array of string numbers.
Returns:
An array with the values, or null if not found.

getParameter

public java.lang.String getParameter(java.lang.String parameter)
Gets the value of the specified applet parameter. If a prefix is specified, this is added in front of the specified parameter name.

Overrides:
getParameter in class java.applet.Applet
Parameters:
parameter - The name of the parameter.
Returns:
The value of the parameter, or null if parameter is not specified.

getParameterPrefix

public java.lang.String getParameterPrefix()
Gets the prefix used when reading applet parameters.

Returns:
The prefix used, or null if no prefix is used.

getStringValues

protected java.lang.String[] getStringValues(java.lang.String string,
                                             java.lang.String delimiter)
Converts a comma seperated string to an array of strings.

Parameters:
string - The string parameter to return the values from.
delimiter - The field delimiter.
Returns:
A string array.

init

public void init()
Initializes the default applet parameters.

Overrides:
init in class java.applet.Applet

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Called when a sample is selected.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener

loadParameters

public void loadParameters(java.util.Hashtable parameters)
Loads the parameters into the specified hashtable. Subclasses should override this method, call super.loadParameters() and add it's own parameters before they are set using the setParameters() method.

Parameters:
parameters - The hashtable where the parameters should be loaded.

loadURLParameters

public void loadURLParameters(java.lang.String url,
                              java.util.Hashtable parameters)
Loads the parameters from the specified url.

Parameters:
url - The url to load the data from.
parameters - Read the parameters into this hashtable.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
Required by the MouseMotionListener, does nothing.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent event)
Checks of the mouse is over a sample with a URL. If so it changes the cursor to a hand.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
event - The mouse event.

print

public void print(java.awt.Graphics g)
Called when a print request is issued.

Overrides:
print in class java.awt.Container

reset

public void reset()
Resets the chart data and features.


run

public void run()
The automatic refresh thread.

Specified by:
run in interface java.lang.Runnable

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Sets a parameter in the chart. The parameters set here are the default ones for all the chart types.

Parameters:
name - The name of the parameter.
value - The value of the parameter as a string.

setParameterPrefix

public void setParameterPrefix(java.lang.String prefix)
Sets the parameter prefix for this chart.

Parameters:
prefix - The prefix to use when reading applet parameters.

setParameters

public void setParameters(java.util.Hashtable parameters)
Sets the applet parameters. All the parameter keys are assumes to be lower case letter.

Parameters:
parameters - The parameters to be set.

setParentApplet

public void setParentApplet(java.applet.Applet parent)
Sets the parent applet. This is necessary if this applet is contained within another applet, and we need to call the init() method of this applet and/or read applet parameters.

Parameters:
parent - The parent applet, use null for ourselves.

start

public void start()
Starts the automatic refresh thread.

Overrides:
start in class java.applet.Applet

stop

public void stop()
Stops the automatic refresh thread.

Overrides:
stop in class java.applet.Applet

toString

public java.lang.String toString()
Returns the title of the chart.

Overrides:
toString in class java.awt.Component