All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.objectplanet.gui.LineChartApplet

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----com.objectplanet.gui.LineChartApplet

public class LineChartApplet
extends Applet
implements Runnable
The line chart applet enables you to plug a line chart directly into your html page and customize it by setting parameters in the applet tag.

A simple linechart applet can be created with the following tag:

 <applet com.objectplanet.gui.LineChartApplet width=300 height=200 
 archive=com.objectplanet.gui.LineChartApplet.jar>
 <param name="sampleValues" value="200,100,300,250,400">
 <applet>

If you need multiple data series you can create a line chart with the following applet tag:

 <applet com.objectplanet.gui.LineChartApplet width=300 height=200 
 archive=com.objectplanet.gui.LineChartApplet.jar>
 <param name="seriesCount" value=4>
 <param name="sampleValues_0" value="200,100,300,250,400">
 <param name="sampleValues_1" value="300,150,200,150,300">
 <param name="sampleValues_2" value="100,50,350,300,350">
 <param name="sampleValues_3" value="400,200,100,400,200">
 <applet>

To set a chart value or feature, use the following tag

<param name="parameterName" value="valueToUse">


SAMPLE VALUES
Parameter Type Description
sampleValues decimal array Sets the sample values for the first data series. If the sampleCount is not set the number of samples in the chart will be the number of values set.
<param name="sampleValues" value="10.5, 30.5, 20, 5.1234">
sampleCount integer Sets the number of samples in the chart. This will override the number of values set with the sampleValues parameter.
<param name="sampleCount" value=5>
seriesCount integer Sets the number of data series in the chart. You must set this to read more than one series of data (using the sampleValues_N parameter).
<param name="seriesCount" value=4>
sampleValues_N decimal array Sets the sample values for the specified data series.
<param name="seriesCount" value=4>
<param name="sampleValues_0" value="200,100,300,250,400">
<param name="sampleValues_1" value="300,150,200,150,300">
<param name="sampleValues_2" value="100,50,350,300,350">
<param name="sampleValues_3" value="400,200,100,400,200">
range decimal Sets the upper range of the chart. This is the value of the upper edge of the chart. If this is not set, the upper range will be set automatically.
<param name="range" value=200>
lowerRange decimal Sets the lower range of the chart. This is the value of the lower edge of the chart. If this is not set, the lower range will be adjusted automatically.
<param name="lowerRange" value=-200>
rangeStep decimal If the range is not set directly it will default to the largest value of the chart (or 0). If rangeStep is set, the range will be set to the next value divisible by the step. This parameter works for the lower range as well. If the maximum value of the chart is 325, and the step is set to 100, the range will automatically be set to 400.
<param name="rangeStep" value=100>

LABELS AND FONTS
Parameter Type Description
chartTitle string Sets the title of the chart. The title will be displayed at the top of the chart. To set the title font use the titleFont parameter.
<param name="chartTitle" value="This is my title">
sampleLabels string array Sets the sample labels for this chart. The sample labels will appear below the chart grid at the sample points when the sampleLabelsOn parameter is turned on.
<param name="sampleLabels" value="monday, tuesday, wednesday, thursday, friday">
seriesLabels string array Sets the series labels for this chart. The series labels will appear in the legend when multiple data series are used and legendOn is turned on.
<param name="seriesLabels" value="1997, 1998, 1999">
legendLabels string array Overrides the default labels in the legend. The default labels are either the sampleLabels (if 1 data series is used) or the seriesLabels (if multiple data series is used).
<param name="legendLabels" value="1997, 1998, 1999">
<param name="legendLabels" value="sampleLabels">
<param name="legendLabels" value="seriesLabels">
labelDelimiter string By default the sampleLabels, seriesLabel, targetValueLine, and legendLabels parameters use comma (,) as a field delimiter. Use this parameter to control the label delimiter if you need a comma in the labels to be displayed.
<param name="labelDelimiter" value=":">
sampleAxisLabel string Adds a label below the sample (X) axis.
<param name="sampleAxisLabel" value="samples">
rangeAxisLabel string Adds a label above the range (Y) axis.
<param name="rangeAxisLabel" value="range">
valueLabelPrefix string Adds a prefix before all value labels. You can also set the prefix for individual data series by adding the series index.
<param name="valueLabelPrefix" value="$">
<param name="valueLabelPrefix_0" value="£">
<param name="valueLabelPrefix_1" value="€">
valueLabelPostfix string Adds a postfix after all value labels. You can also set the postfix for individual data series by adding the series index.
<param name="valueLabelPostfix" value="%">
<param name="valueLabelPostfix_0" value="ms">
<param name="valueLabelPostfix_1" value="ns">
rangeLabelPrefix string Adds a prefix before the range labels.
<param name="rangeLabelPrefix" value="$">
rangeLabelPostfix string Adds a postfix after the range labels.
<param name="rangeLabelPostfix" value="%">
font font string Sets the default font for the chart.
<param name="font" value="Dialog, plain, 12">
titleFont font string Sets the title font.
<param name="titleFont" value="Dialog, bold, 20">
legendFont font string Sets the font for the labels in the legend.
<param name="legendFont" value="Dialog, plain, 12">
sampleLabelFont font string Sets the font for the sample labels.
<param name="sampleLabelFont" value="Dialog, plain, 12">
valueLabelFont font string Sets the font for the value labels.
<param name="valueLabelFont" value="Dialog, plain, 12">
rangeLabelFont font string Sets the font for the range labels.
<param name="rangeLabelFont" value="Dialog, plain, 12">
sampleAxisLabelFont font string Sets the font used for the sampleAxisLabel.
<param name="sampleAxisLabelFont" value="Dialog, plain, 12">
rangeAxisLabelFont font string Sets the font used for the rangeAxisLabel.
<param name="rangeAxisLabelFont" value="Dialog, plain, 12">

COLORS
Parameter Type Description
sampleColors color array Sets the colors of the data series in the chart.
<param name="sampleColors" value="red, green, blue, orange, magenta">
sampleLabelColors color array Sets the colors of the sample labels.
<param name="sampleLabelColors" value="red, green, blue, orange, magenta">
seriesLabelColors color array Sets the colors of the series labels (in the legend).
<param name="seriesLabelColors" value="red, green, blue, orange, magenta">
background color This is the background color of the chart applet.
<param name="background" value="red">
foreground color This is the color of the title, legend labels, value labels, sample labels, and range labels.
<param name="foreground" value="blue">
chartBackground color This is the color of the chart background itself.
<param name="chartBackground" value="red">
chartForeground color This is the color of the chart outline.
<param name="chartForeground" value="red">
valueLinesColor color Sets the color of the value grid lines.
<param name="valueLinesColor" value="red">

STYLE
Parameter Type Description
legendOn boolean Turns on the legend. The default position of the legend is to the right of the chart.
<param name="legendOn" value=true>
legendPosition string Sets the legend position. Possible positions are right, left, top, or bottom.
<param name="legendPosition" value="left">
3DModeOn boolean Set this parameter to true to paint the chart in 3D.
<param name="3DModeOn" value=true>
rangeAdjusterOn boolean Use this parameter to turn on the range adjuster. The range adjuster is a slider at the right edge of the chart, which allows the user to adjust the upper and lower ranges.
<param name="rangeAdjusterOn" value=true>
lineWidth integer Sets the width of each series line. The default with is 2.
<param name="lineWidth" value=1>
stackedOn boolean Turn this parameter on to paint filled and stacked lines.
<param name="stackedOn" value=true>
valueLabelsOn boolean Turns on the value labels for each sample. To control where the value labels are displayed, use the valueLabelStyle parameter. Use the sampleDecimalCount parameter to control the number of fixed decimals for the labels.
<param name="valueLabelsOn" value=true>
valueLabelStyle string The value labels are either painted above or below the sample point, or it can be painted directly at the sample point.
<param name="valueLabelStyle" value="outside">
<param name="valueLabelStyle" value="point">
sampleLabelsOn boolean Turns on the sample labels. The sample labels appear at the lower edge of the chart at each sample position. Use the setSampleLabels parameter to set the sample labels.
<param name="sampleLabelsOn" value=true>
rangeLabelsOff boolean This turns off the range labels.
<param name="rangeLabelsOff" value=true>
valueLinesOn boolean Turns on the value grid lines in the chart background.
<param name="valueLinesOn" value=true>
maxValueLineCount integer Sets the maximum number of value lines to be displayed in the chart.
<param name="maxValueLineCount" value=10>
sampleDecimalCount integer Sets the number of fixed decimals to use for the value labels.
<param name="sampleDecimalCount" value=3>
rangeDecimalCount integer Sets the number of fixed decimals to use for the range labels.
<param name="rangeDecimalCount" value=3>
seriesLineOff decimal array Turns off the series lines for all the series, or only the specified data series. This can be used with the sample highlights to make a plotter chart or a combined line and plotter chart.
<param name="seriesLineOff" value=true>
<param name="seriesLineOff" value="1,3">
sampleHighlightOn boolean array Each data series can have the samples highlighted by either a circle, a square, or a diamond shape. Use this parameter to turn sample highlighting on or off for the data series. The default highlight type is circle and highlighting is turned off by default.
<param name="sampleHighlightOn" value="true">
<param name="sampleHighlightOn" value="true, false, false, true">
sampleHighlightStyle string array Use this parameter to set the sample highlight style for each data series. The possible styles are circle, circle_opaque, circle_filled, square, square_opaque, square_filled, diamond, diamond_opaque, or diamond_filled.
<param name="sampleHighlightStyle" value="circle, square, diamond">
sampleHighlightSize integer array Use this parameter to set the size of the sample highlighting for each data series. The default size is 6.
<param name="sampleHighlightSize" value="6, 8, 10">

MISCELLANEOUS
Parameter Type Description
targetValueLine_N string array You can set grid lines with a specified label and color at any value position in the chart. A target value line has a label, a target value, a line color, and a label display style. The labels are counted from 0, where N is 0, 1, 2, 3, 4, and so on.
<param name="targetValueLine_0" value="break even, 150, green">
<param name="targetValueLine_1" value="bankrupt, 20, red, label">
<param name="targetValueLine_2" value="goal, 250, #0c0aa0, value">
url_N url This feature can be used to create drill-down functionallity for the charts. You can associate a data series in the chart to a URL, and the document pointed to by that URL will be opened when the user double-clicks the label in the legend.

The N is the index of the data series (first is numbered 0).

<param name="url_0" value="orange_sales_1999.html">
<param name="url_1" value="apple_sales_1999.html">
<param name="url_2" value="banana_sales_1999.html">
<param name="url_3" value="http://www.fruitorama.com">

urltarget_N string This parameter controls where HTML pages will be opened.
urltarget - sets the default target frame or window
urltarget_N - sets the target for the specified series

_self: Open new page in same window or frame.
_parent: Open in the parent window.
_top: Open in the top-level window.
_blank:Open in a new blank window.
name:Open in the frame or window with the specified name.
<param name="urltarget" value="bottom_frame">
<param name="urltarget_0" value="left_frame">

autoLabelSpacingOn boolean By default all the sample labels are painted, even if there is not enough space for them all (they will overlap). If this parameter is set to true, only labels there are room for will be painted.
<param name="autoLabelSpacingOn" value=true>
graphInsets integer array Use this parameter to add space between the chart grid and the chart component edges. The parameter consists of 4 comma seperated integers, whith the following sequence; top, left, bottom, right. A value of -1 uses the default inset.
<param name="graphInsets" value="-1, 50, -1, -1">
automaticRefreshTime integer Some web browsers has problems repainting applets correctly and causes "breaks" in the applet graphics. Use this parameter to repaint the chart periodically to repair these breaks in the charts. The value of the parameter is in milliseconds (1000 = 1 second).
<param name="automaticRefreshTime" value="1000">

PARAMETER VALUE TYPES
Parameter Type Description
string A text string between double quotes.
integer An integer number, positive or negative (-100 or 100).
decimal An integer or floating point number, positive or negative (-100.5 or 100.32).
boolean true or false.
string array A comma seperated set of strings between double quotes ("string1, string2, string3").
decimal array A comma seperated set of integer or floating point numbers between double quotes ("-100.5, 10, 100.12, 233.4234").
boolean array A comma seperated list of true or false between double quotes. ("true, false, true, true, false, false")
color A named color, a color triplet, or a 6-digit hex code. The named colors are (black, blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink, red, white, and yellow).
value="red"
value="50,100,150" (red, green, blue, <= 255)
value="#a07f00" (#RRGGBB, 00-ff)
color array A string of named colors or a 6-digit hex code between double quotes. The named colors are (black, blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink, red, white, and yellow).
value="red, green, blue, yellow, #a0b0c0, #ff00ee"
font string "fontName, plain/bold/italic/bolditalic, size"
url A complete or relative URL between double quotes.
value="http://www.thisismyurl.com/thisismypage.html"


Author:
Bjorn J. Kvande.

Constructor Index

 o LineChartApplet()

Method Index

 o handleEvent(Event)
Handles the events of the chart.
 o init()
Creates the line chart applet.
 o invalidate()
This method is called when the component is resized.
 o paint(Graphics)
Paints the chart.
 o render(Graphics)
Renders the chart.
 o run()
The automatic refresh thread.
 o setAutomaticRepaintOn(boolean)
Turns on or off automatic refresh.
 o setParameter(String, String)
Sets a parameter in the chart.
 o start()
Starts the automatic refresh thread.
 o stop()
Stops the automatic refresh thread.
 o update(Graphics)
This method is overridden to avoid flicker when the chart is repainted.

Constructors

 o LineChartApplet
 public LineChartApplet()

Methods

 o init
 public void init()
Creates the line chart applet.

Overrides:
init in class Applet
 o setAutomaticRepaintOn
 public void setAutomaticRepaintOn(boolean state)
Turns on or off automatic refresh.

Parameters:
state - True for on, false for off.
 o setParameter
 public void setParameter(String name,
                          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.
 o invalidate
 public void invalidate()
This method is called when the component is resized.

Overrides:
invalidate in class Container
 o update
 public final void update(Graphics g)
This method is overridden to avoid flicker when the chart is repainted.

Overrides:
update in class Container
 o paint
 public final void paint(Graphics g)
Paints the chart.

Parameters:
g - The graphics context used for painting.
Overrides:
paint in class Container
 o render
 protected void render(Graphics g)
Renders the chart.

Parameters:
g - The graphics context used for painting.
 o handleEvent
 public boolean handleEvent(Event event)
Handles the events of the chart.

Parameters:
e - The event.
Overrides:
handleEvent in class Component
 o start
 public void start()
Starts the automatic refresh thread.

Overrides:
start in class Applet
 o stop
 public void stop()
Stops the automatic refresh thread.

Overrides:
stop in class Applet
 o run
 public void run()
The automatic refresh thread.


All Packages  Class Hierarchy  This Package  Previous  Next  Index