All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.objectplanet.gui.PieChartApplet

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

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

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

 <applet com.objectplanet.gui.PieChartApplet width=300 height=200 
 archive=com.objectplanet.gui.PieChartApplet.jar>
 <param name="sampleValues" value="100,200,300,400,500">
 <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">

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 in the legend by setting the legendOn parameter to true, or floating above each pie slice when you move the mouse over if you set the sampleLabelsOn parameter to true.
<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, and legendLabels 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=":">
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">
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">
floatingLabelFont font string Sets the font used with the floating sample/value/percent labels.
<param name="floatingLabelFont" value="Dialog, plain, 12">
pieLabelFont font string Sets the font to use for the pie labels. The pie labels are displayed below each pie if multiple pies are used and pieLabelsOn is true.
<param name="pieLabelFont" value="Dialog, bold, 12">

COLORS
Parameter Type Description
sampleColors color array Sets the colors of the pie slices in the chart.
<param name="sampleColors" value="red, green, blue, orange, magenta">
sampleLabelColors color array Sets the colors of the sample labels in the legend.
<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 and legend labels
<param name="foreground" value="blue">
sliceSeperatorColor color Controls the slice seperator color. If this is not set, the color used is the same as the slice color, only a little darker.
<param name="sliceSeperatorColor" value="black">

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, and bottom.
<param name="legendPosition" value="left">
3DModeOn boolean Set this parameter to true to paint the chart in 3D.
<param name="3DModeOn" value=true>
sampleLabelsOn boolean By turning the sample labels on, the sample label for a pie segment will appear floating on top of the segment when the mouse pointer moves across the segment or the sample label in the legend.
<param name="sampleLabelsOn" value=true>
valueLabelsOn boolean By turning the value labels on, the value for a pie segment will appear floating on top of the segment when the mouse pointer moves across the segment or the sample label in the legend.
<param name="valueLabelsOn" value=true>
percentLabelsOn boolean By turning the percent labels on, the percentage for a pie segment will appear floating on top of the segment when the mouse pointer moves across the segment or the sample label in the legend.
<param name="percentLabelsOn" value=true>
pieLabelsOn boolean The pie labels are displayed below each pie if multiple series/pies are used. The labels displayed are the sample labels.
<param name="pieLabelsOn" value=true>
sampleDecimalCount integer Sets the number of fixed decimals to use for the value labels.
<param name="sampleDecimalCount" value=3>
percentDecimalCount integer Sets the number of fixed decimals to use for the percent labels.
<param name="percentDecimalCount" value=3>
angle integer Sets the angle of the 3D pie. Possible values are 10-90. The default value is 30.
<param name="angle" value=30>
depth decimal Sets the depth of the 3D pie. Possible values are 0.0-1.0. The default value is 0.4.
<param name="depth" value="0.2">
sliceSeperatorOn boolean Turns on the seperator lines between the slices in the pie(s). By default, the color of those lines is the same as the slice, only a little darker to create the seperator effect.
<param name="sliceSeperatorOn" value="true">
selectionStyle string Sets the effect painted when the user selects a pie slice or a series in the legend. The effects available is a triangle or circle marker within the pie slice, or detaching the slice as it is selected.
<param name="selectionStyle" value="detached">
<param name="selectionStyle" value="triangle">
<param name="selectionStyle" value="circle">
detachedDistance decimal Controls the distance the slices are detached from the pie. The value is a factor of the pie radius, so if the parameter value is set to 0.5, the slice is detached halfway out of the pie.
<param name="detachedDistance" value="0.2">

MISCELLANEOUS
Parameter Type Description
url_N_M url This feature can be used to create drill-down functionallity for the charts. You can associate any pie slice or series in the chart to a URL, and the document pointed to by that URL will be opened when the user double-clicks the pie slice or label in the legend.

The N is the index of the data series (first is numbered 0). The M is the index of the sample within the series (first is numbered 0). If there is only one series in the chart, N will be the index of the sample. However url_0_M will override url_N if M=N.

<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_M 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
urltarget_N_M - sets the target for the specified sample

_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">

detachedSlices_N decimal array Detaches the specified slices in pie number N.
<param name="detachedSlices" value="0,3">
<param name="detachedSlices_0" value="0,3">
<param name="detachedSlices_1" value="5">
graphInsets integer array Use this parameter to add space between the pie(s) 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").
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 PieChartApplet()

Method Index

 o handleEvent(Event)
Handles the events of the chart.
 o init()
Creates the piechart 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 PieChartApplet
 public PieChartApplet()

Methods

 o init
 public void init()
Creates the piechart 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