com.objectplanet.chart
Class Chart

java.lang.Object
  |
  +--java.awt.Component
        |
        +--com.objectplanet.chart.Chart
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
BarChart, LineChart, PieChart

public abstract class Chart
extends java.awt.Component
implements java.awt.ItemSelectable, java.lang.Runnable

This class is the abstract superclass of all charts.

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

Nested Class Summary
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int BELOW
          Labels display below the chart grid.
static int BELOW_AND_FLOATING
          Labels display both below the grid and floating over a sample.
static int BOTTOM
          Bottom legend position.
protected  com.objectplanet.chart.ChartData chartData
          This contains the chart data.
static int FLOATING
          Floating labels display when mouse is over a sample.
static int HORIZONTAL
          Horizontal bar alignment.
static int INSIDE
          Labels display inside each sample.
static int LEFT
          Left legend position.
static int OUTSIDE
          Labels display outside pie edge next to each sample.
protected  java.util.Vector overlayCharts
          This contains any overlayed charts.
static int RIGHT
          Right legend position.
static int STATIC
          Used to create a static label
static int TARGET_LINE_ID_AND_VALUE_LABEL
          Use both the ID and value label with the target lines; setTargetValueLine().
static int TARGET_LINE_ID_LABEL
          Use the ID label with the target lines; setTargetValueLine().
static int TARGET_LINE_NO_LABEL
          Use no label with the target lines; setTargetValueLine().
static int TARGET_LINE_VALUE_LABEL
          Use the value label with the target lines; setTargetValueLine().
static int TOP
          Top legend position.
static int VERTICAL
          Vertical bar alignment.
protected  int[] visibleSamples
          The start index and count of the currently visible samples.
 
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
Chart(int count)
          Creates a chart with the given number of samples and no title.
Chart(int seriesCount, int sampleCount)
          Creates a chart with the given number of samples and no title.
 
Method Summary
 void addImage(java.lang.String name, java.awt.Image image)
          Adds an image to the chart.
 void addItemListener(java.awt.event.ItemListener l)
          Adds an item listener to the chart.
 int addOverlayChart(com.objectplanet.chart.Chart chart)
          Adds a new overlay chart.
 int appendSample(int serie, com.objectplanet.chart.ChartSample sample, boolean makeSpace)
          Appends a sample to the given series.
 int appendSampleLabel(java.lang.String label, boolean makeSpace)
          Appends a sample labels If makeSpace is set to false, and all the sample labels are filled up, they will be scrolled to the left, with the left most label deleted.
 int appendSampleValue(int serie, double value, boolean makeSpace)
          Appends a value to the given series.
 void autoRepaint()
          Calls repaint() if the automaticRepaintOn is turned on.
protected abstract  void calculateChartData(java.awt.Rectangle grid, java.awt.Rectangle dataBounds)
          Calculates the data used for the chart.
protected  void checkDataIntegrity()
          This method is called each time the sample count or series count changes, and ensures that all the data has the right size.
protected  com.objectplanet.chart.ChartSample checkSelection(java.awt.Point point)
          This method is called when the user releases the mouse and checks if the given point is inside a sample.
 java.awt.Image createImage(int width, int height)
          Creates an offscreen image.
 void forceRepaint()
          Forces immidiate repaint of the chart.
 java.lang.String formatNumber(double value, int decimals)
          Formats a floating number to the number of decimals given.
 int get3DDepth()
          Gets the depth of the 3D effect.
 java.awt.Color getChartBackground()
          Gets the color of the chart background itself.
 com.objectplanet.chart.ChartData getChartData()
          Gets the chart data for this chart.
 java.awt.Color getChartForeground()
          Gets the color of the chart foreground itself.
 double getCurrentLowerRange(int adjuster)
          Gets the current lower range of the specified range adjuster.
 double getCurrentRange(int adjuster)
          Gets the current upper range of the specified range adjuster.
 java.awt.Rectangle getDataBounds(java.awt.Rectangle grid)
          This method returns the bounding box for the data to be drawn in.
 java.awt.Font getFont(java.lang.String label)
          Gets the font for the specified label.
abstract  java.awt.Rectangle getGraphBounds()
          This method returns the bounding box for the chart grid.
 java.awt.Insets getGraphInsets()
          Gets the graph insets.
 double getGridLine(int index)
          Gets grid lines positon value by its index.
 java.awt.Color getGridLineColor(int index)
          Gets grid line's color value by it's index.
 java.awt.Color[] getGridLineColors()
          Gets the vertical grid lines colors.
 double[] getGridLines()
          Gets the vertical grid lines positons.
 java.awt.Image getImage(int width, int height)
          Returns the current chart as an image.
 java.awt.Image getImage(java.lang.String name)
          Gets the image with the specified name.
 java.lang.String getLabel(java.lang.String name)
          Gets the specified label from the chart.
 int getLabelAngle(java.lang.String name)
          Gets the angle of the specified label.
 int getLastSelectedSample()
          Gets the index of the last selected sample.
 int getLastSelectedSeries()
          Gets the index of the last selected series.
 java.awt.Color getLegendColor(int index)
          Gets legend entry's color value by it's index.
 java.awt.Color[] getLegendColors()
          Gets the legend colors.
 java.lang.String getLegendImage(int index)
          Gets a legend entry's image name.
 java.lang.String[] getLegendLabels()
          Gets the legend labels.
 int getLegendPosition()
          Gets the legend position.
 double getLowerRange(int index)
          Gets the lower value of the specified range.
 double getMaxValue(int serie)
          Gets the largest value in the specified data series.
 int getMaxValueLineCount()
          Gets the current maxium number of value lines set.
 java.awt.Dimension getMinimumSize()
          This method returns the minimum size of the chart.
 double getMinValue(int serie)
          Gets the smallest value in the specified data series.
 com.objectplanet.chart.Chart getOverlayChart(int index)
          Gets the specified overlay chart.
 java.awt.Dimension getPreferredSize()
          This method is called by the awt, and returns the preferred size of the chart.
 double getRange(int index)
          Gets the upper value of the specified range.
 int getRangeAdjusted(int adjuster)
          Gets the range(s) adjusted by the specified adjuster.
 int getRangeAdjusterPosition(int adjuster)
          Gets the position of the range adjuster.
 java.awt.Color getRangeColor(int index)
          Gets the color of the specified range.
 int getRangeDecimalCount(int index)
          Gets the number of decimals used in the range values.
 int getRangePosition(int index)
          Gets the range position.
 com.objectplanet.chart.ChartSample getSample(int serie, int index)
          Gets the specified sample.
 com.objectplanet.chart.ChartSample getSample(java.lang.Object key)
          Gets the sample with the given key.
 java.awt.Color getSampleColor(int index)
          Gets the color of the specified sample.
 java.awt.Color[] getSampleColors()
          Gets the array of colors used for the samples.
 int getSampleCount()
          Gets the number of samples.
 int getSampleDecimalCount(int serie)
          Gets the number of decimals used for the sample values.
 java.lang.String getSampleLabel(int index)
          Gets the specified sample label.
 java.awt.Color getSampleLabelColor(int index)
          Gets the color of the label of the specified sample.
 java.lang.String[] getSampleLabels()
          Gets the sample labels.
 java.awt.Color getSampleLabelSelectionColor()
          Gets the color used for the sample labels when a sample is selected.
 int getSampleLabelStyle()
          Gets the current style of the sample labels.
 com.objectplanet.chart.ChartSample[] getSamples(int serie)
          Gets the samples for the specified serie.
 double getSampleValue(int serie, int index)
          Gets the specified sample value.
 double[] getSampleValues(int serie)
          Gets the sample values for the specified serie.
 java.lang.Object[] getSelectedObjects()
          Gets the currently selected objects.
 int getSeriesCount()
          Gets the number of series.
 java.lang.String getSeriesLabel(int serie)
          Gets the specified series label.
 java.awt.Color getSeriesLabelColor(int serie)
          Gets the color of the label of the specified series.
 java.lang.String[] getSeriesLabels()
          Gets the series labels.
 int getSeriesLabelStyle()
          Gets the current style of the series labels.
 int getSeriesRange(int series)
          Gets the range the specified series belongs to.
 java.awt.Dimension getSize()
          Returns the size of the chart component.
 double getTargetValueLine(java.lang.String id)
          Gets the value of a target value line.
 java.lang.String getThousandsDelimeter()
          Gets the current thousands delimeter for use in the display of numbers.
 java.lang.String getTitle()
          Gets the chart title.
 java.awt.Color getValueLinesColor()
          Gets the color of the value lines.
static java.lang.String getVersion()
          Returns the current version of the charts.
 boolean is3DModeOn()
          Checks if the 3D mode is turned on.
 boolean isAutomaticRepaintOn()
          Checks if the automatic repaint is on.
 boolean isDefaultGridLinesOn()
          Checks if the default vertical grid lines are on.
 boolean isFloatingOnLegendOn()
          Checks if floating labels are displayed when the mouse moves over the legend.
 boolean isGridAdjustmentOn(int edge)
          Checks if runtime grid adjustment is on.
 boolean isLegendOn()
          Checks if the legend is turned on.
 boolean isOverlayChartOn(int index)
          Checks if the specified overlay chart is on.
 boolean isPrintAsBitmap()
          Checks if the chart will be printed as a bitmap.
 boolean isRangeAdjusterOn(int adjuster)
          Checks if the specified range adjuster is turned on.
 boolean isRangeLabelsOn(int range)
          Checks if the range labels are on or off for the specified range.
 boolean isRangeOn(int index)
          Checks if the specified range is on.
 boolean isSampleLabelsOn()
          Checks if the sample labels are turned on.
 boolean isSampleScrollerOn()
          Checks if the sample scroller is turned on.
 boolean isSelected(int serie, int sample)
          Checks if a sample is selected.
 boolean isSeriesLabelsOn()
          Checks if the floating series labels is turned on.
 boolean isServletModeOn()
          Checks if the servlet mode is turned on.
 boolean isTitleOn()
          Checks if the title is turned on.
 boolean isValueLabelsOn()
          Checks if the value labels are turned on for any series.
 boolean isValueLabelsOn(int serie)
          Checks if the value labels are turned on for a specified series.
 boolean isValueLinesOn()
          Checks if the value lines are turned on.
 java.awt.Image loadImage(java.lang.String name)
          Loads an image from the disk.
static void main(java.lang.String[] argv)
          Prints out the current version number.
 void paint(java.awt.Graphics g)
          This method is overridden to paint the chart using double buffering.
 void print(java.awt.Graphics g)
          Call this methods if you want to print the chart from a java program.
protected  void processEvent(java.awt.AWTEvent e)
          Handles the chart events.
 void removeExternalGraphics()
          Removes external graphics context if there is one.
 void removeItemListener(java.awt.event.ItemListener l)
          Removes the specified item listener from the chart.
 void removeOverlayChart(int index)
          Removes the specified overlay chart.
protected abstract  void render(java.awt.Graphics g)
          This method is called by paint(), and has to be implemented by the subclass to render the chart.
protected abstract  void renderData(java.awt.Graphics g, java.awt.Rectangle grid, java.awt.Rectangle dataBounds)
          This method renders the data (bars, lines, pies).
 void reset()
          Resets the chart data and features.
 void run()
          Internal do not call.
 void set3DDepth(int depth)
          Sets the depth of the 3D effect in number of pixels.
 void set3DModeOn(boolean on)
          Turns on or off 3D look of the chart.
 void setAutomaticRepaintOn(boolean state)
          Turns on or off the automatic repaint.
 void setBackground(java.awt.Color color)
          Sets the chart component background color, outside the chart grid.
 void setChartBackground(java.awt.Color color)
          Sets the background color of the chart itself.
 void setChartData(com.objectplanet.chart.ChartData chartData)
          Lets the chart use the specified chart data.
 void setChartForeground(java.awt.Color color)
          Sets the foreground color of the chart itself.
 void setCurrentLowerRange(int adjuster, double lower)
          Sets the current lower range of the specified range adjuster.
 void setCurrentRange(int adjuster, double upper)
          Sets the current upper range of the specified range adjuster.
 void setDefaultGridLinesColor(java.awt.Color color)
          Sets the color of the default vertical grid lines.
 void setDefaultGridLinesOn(boolean on)
          Turns on or off the default vertical grid lines.
 void setDefaultGridLinesOn(boolean on, double start, double step)
          Turns on or off the default vertical grid lines.
 void setExternalGraphics(java.awt.Graphics g, java.awt.Image image)
          Sets an external graphics context to paint with.
 void setFloatingOnLegendOn(boolean on)
          Turn on or off floating labels when the mouse moves over the legend.
 void setFont(java.lang.String label, java.awt.Font font)
          Sets the font for the specified label.
 void setForeground(java.awt.Color color)
          Sets the color of the labels.
 void setGraphInsets(int top, int left, int bottom, int right)
          Sets the insets between the graph itself and the chart component edges.
 void setGridAdjustmentOn(int edge, boolean on)
          Turns on or of runtime grid adjustment.
 void setGridLine(int index, double value)
          Sets a single grid line value.
 void setGridLineColor(int index, java.awt.Color color)
          Sets a single grid line color.
 void setGridLineColors(java.awt.Color[] colors)
          Sets the color of each vertical grid line.
 void setGridLines(double[] grid)
          Sets the vertical grid lines positons.
 void setGridLinesColor(java.awt.Color color)
          Sets the vertical grid lines color.
 void setLabel(java.lang.String name, java.lang.String label)
          Sets the specified label in the chart.
 void setLabelAngle(java.lang.String name, int angle)
          Sets the angle of the specified label.
static void setLabelAngleCacheSize(int count)
          Sets the angled label cache size.
 void setLegendColor(int index, java.awt.Color color)
          Sets a legend entry color.
 void setLegendColors(java.awt.Color[] colors)
          Sets the legend colors.
 void setLegendImage(int index, java.lang.String name)
          Sets an image to be used in front of the legend label.
 void setLegendLabels(java.lang.String[] labels)
          Sets the legend labels.
 void setLegendOn(boolean on)
          Turns on or off the label legend.
 void setLegendPosition(int position)
          Sets the legend position.
 void setLowerRange(int index, double range)
          Sets the lower range of the chart.
 void setLowerRelativeRange(double range)
          Sets the lower range of the chart relative to the current minimum value.
 void setLowerRelativeRange(double range, double step)
          Sets the lower range of the chart relative to the minimum value of the bars in the chart.
 void setLowerRelativeRange(int index, double range, double step)
          Sets the lower range of the chart relative to the minimum value of the bars in the chart.
 void setMaxValueLineCount(int count)
          Sets the maximum number of value lines there should be in the chart.
 void setOverlayChart(int index, com.objectplanet.chart.Chart chart)
          Sets the specified overlay chart.
 void setOverlayChartOn(int index, boolean on)
          Sets the specified overlay chart on or off.
 void setPreferredSize(int width, int height)
          Sets the preferred size of the chart.
 void setPrintAsBitmap(boolean on)
          Turns on printing as bimap.
 void setRange(int index, double range)
          Sets the upper value of the specified range.
 void setRangeAdjusted(int adjuster, int range)
          Sets which range(s) to be adjusted by the specified adjuster.
 void setRangeAdjusterOn(int adjuster, boolean on)
          Turns on or off the range adjuster.
 void setRangeAdjusterPosition(int adjuster, int position)
          Sets the position of the range adjuster.
 void setRangeColor(int index, java.awt.Color color)
          Sets the color of the specified range.
 void setRangeDecimalCount(int index, int count)
          Sets the number of decimals to use in the range label values.
 void setRangeLabelsOn(int range, boolean on)
          Turns on or off the range value labels for the specified range.
 void setRangeOn(int index, boolean on)
          Turns on or off the specified range.
 void setRangePosition(int index, int position)
          Sets the range position.
 void setRelativeRange(double range)
          Sets the upper range of the chart relative to the maximum value of the bars in the chart.
 void setRelativeRange(double range, double step)
          Sets the upper range of the chart relative to the maximum value of the bars in the chart.
 void setRelativeRange(int index, double range, double step)
          Sets the upper range of the chart relative to the maximum value of the bars in the chart.
 void setSample(int serie, int index, com.objectplanet.chart.ChartSample sample)
          Sets the specified sample.
 void setSampleAxisRange(double min, double max)
          Sets the left and the right range of the chart.
 void setSampleColor(int index, java.awt.Color color)
          Sets the color of the specified sample.
 void setSampleColors(java.awt.Color[] colors)
          Sets the sample colors.
 void setSampleCount(int count)
          Sets the number of samples.
 void setSampleDecimalCount(int serie, int count)
          Sets the number of decimals in the sample values.
 void setSampleLabel(int index, java.lang.String label)
          Sets the specified sample label.
 void setSampleLabelColor(int index, java.awt.Color color)
          Sets the color of of the label for the specified sample.
 void setSampleLabels(java.lang.String[] labels)
          Sets the sample labels.
 void setSampleLabelSelectionColor(java.awt.Color color)
          Sets the color used for the sample labels when a sample is selected.
 void setSampleLabelsOn(boolean on)
          Turns on the sample labels on the x-axis.
 void setSampleLabelStyle(int style)
          Sets the style of the sample labels.
 void setSamples(int serie, com.objectplanet.chart.ChartSample[] samples)
          Sets the samples for the specified series.
 void setSampleScrollerOn(boolean on)
          Turns on or off the sample scroller.
 void setSampleValue(int serie, int index, double value)
          Sets the specified sample value.
 void setSampleValues(int serie, double[] values)
          Sets the sample values for the specified series.
 void setSelection(int serie, int sample, boolean selected)
          Marks a sample as selected or deselected.
 void setSelection(int serie, int sample, boolean selected, boolean notify)
          Marks a sample as selected or deselected.
 void setSeriesCount(int count)
          Sets the number of series.
 void setSeriesLabel(int serie, java.lang.String label)
          Sets the specified series label.
 void setSeriesLabelColor(int serie, java.awt.Color color)
          Sets the color of of the label for the specified series.
 void setSeriesLabels(java.lang.String[] labels)
          Sets the series labels.
 void setSeriesLabelsOn(boolean on)
          Turns on the floating series labels.
 void setSeriesLabelStyle(int style)
          Sets the style of the series labels.
 void setSeriesRange(int series, int range)
          Sets wich range the specified series should belong to.
 void setServletModeOn(boolean on)
          Turns on or off servlet mode.
 void setTargetValueLine(java.lang.String id, double value, java.awt.Color color, int style)
          Sets a target value line with the specified ID, value, and color.
 void setThousandsDelimeter(java.lang.String delimiter)
          Sets the delimeter for use in the display of numbers.
 void setTitle(java.lang.String title)
          Sets the chart title.
 void setTitleOn(boolean on)
          Turns on or off the chart title.
 void setValueLabelsOn(boolean on)
          Turns on or off the value labels.
 void setValueLabelsOn(int serie, boolean on)
          Turns on or off the value labels for the specified series.
 void setValueLinesColor(java.awt.Color color)
          Sets the color of the value lines in the chart.
 void setValueLinesOn(boolean on)
          Turns on or off the chart value lines.
 void setVisibleSamples(int start, int count)
          Sets the visible samples in the chart.
 java.lang.String toString()
          Returns the title of the chart.
 void update(java.awt.Graphics g)
          This method is overridden to avoid flicker when the chart is repainted.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BELOW

public static final int BELOW
Labels display below the chart grid.

See Also:
Constant Field Values

BELOW_AND_FLOATING

public static final int BELOW_AND_FLOATING
Labels display both below the grid and floating over a sample.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Bottom legend position.

See Also:
Constant Field Values

chartData

protected com.objectplanet.chart.ChartData chartData
This contains the chart data. The data consists of multiple series with a number of samples in each series.


FLOATING

public static final int FLOATING
Floating labels display when mouse is over a sample.

See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
Horizontal bar alignment.

See Also:
Constant Field Values

INSIDE

public static final int INSIDE
Labels display inside each sample.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Left legend position.

See Also:
Constant Field Values

OUTSIDE

public static final int OUTSIDE
Labels display outside pie edge next to each sample.

See Also:
Constant Field Values

overlayCharts

protected java.util.Vector overlayCharts
This contains any overlayed charts.


RIGHT

public static final int RIGHT
Right legend position.

See Also:
Constant Field Values

STATIC

public static final int STATIC
Used to create a static label

See Also:
Constant Field Values

TARGET_LINE_ID_AND_VALUE_LABEL

public static final int TARGET_LINE_ID_AND_VALUE_LABEL
Use both the ID and value label with the target lines; setTargetValueLine().

See Also:
Constant Field Values

TARGET_LINE_ID_LABEL

public static final int TARGET_LINE_ID_LABEL
Use the ID label with the target lines; setTargetValueLine().

See Also:
Constant Field Values

TARGET_LINE_NO_LABEL

public static final int TARGET_LINE_NO_LABEL
Use no label with the target lines; setTargetValueLine().

See Also:
Constant Field Values

TARGET_LINE_VALUE_LABEL

public static final int TARGET_LINE_VALUE_LABEL
Use the value label with the target lines; setTargetValueLine().

See Also:
Constant Field Values

TOP

public static final int TOP
Top legend position.

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
Vertical bar alignment.

See Also:
Constant Field Values

visibleSamples

protected int[] visibleSamples
The start index and count of the currently visible samples.

Constructor Detail

Chart

public Chart(int count)
Creates a chart with the given number of samples and no title.


Chart

public Chart(int seriesCount,
             int sampleCount)
Creates a chart with the given number of samples and no title.

Parameters:
seriesCount - The number of series for the chart.
sampleCount - The number of samples for the chart.
Method Detail

addImage

public void addImage(java.lang.String name,
                     java.awt.Image image)
Adds an image to the chart.

Parameters:
name - The unique name of the image
image - The image to add, use null to remove the image.

addItemListener

public void addItemListener(java.awt.event.ItemListener l)
Adds an item listener to the chart. Any listener registered will be notified when a sample is selected or deselected. The event sent will be the ItemEvent event. Use the ItemEvent.getStateChange() to see if the event was a selection or deselection. Use the ItemEvent.getItem()to get the sample selected or deselected.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
l - The item listener to add.
See Also:
removeItemListener(java.awt.event.ItemListener)

addOverlayChart

public int addOverlayChart(com.objectplanet.chart.Chart chart)
Adds a new overlay chart. Adding overlay charts enables you to paint another charts data on top of this charts data. The overlay charts are stacked on top of each other, so the last one added is the one painted on top of all the others. The range of the chart added will be adjusted to the range of the base chart.

Parameters:
chart - The chart to be layed over this one.
Returns:
The index of this overlay chart, the first one has index 0.

appendSample

public int appendSample(int serie,
                        com.objectplanet.chart.ChartSample sample,
                        boolean makeSpace)
Appends a sample to the given series. If the number of samples is less than the sample count, the new sample is added after the last sample. If the number of samples in the series is the same as the sample count (series is full), the addition will depend on the makeSpace parameter.

If the makeSpace parameter is set to false, all the current samples will shift to the left, and the new sample will be added at the end.

If the makeSpace parameter is set to true, the sample count will be increased by one, and the sample will be added at the end.

The sample labels are also moved to the left with the samples.

Parameters:
serie - The series to append the sample to.
sample - The sample to append.
makeSpace - True to make space for the new parameter.
Returns:
The index of the position where the sample was inserted.
Throws:
java.lang.IllegalArgumentException - If the serie is invalid.

appendSampleLabel

public int appendSampleLabel(java.lang.String label,
                             boolean makeSpace)
Appends a sample labels If makeSpace is set to false, and all the sample labels are filled up, they will be scrolled to the left, with the left most label deleted. If makeSpace is set to true, the number of sample labels will be incremented by one.

Parameters:
label - The label to append.
makeSpace - True to make space for the new parameter.
Returns:
The index of the position where the sample was inserted.

appendSampleValue

public int appendSampleValue(int serie,
                             double value,
                             boolean makeSpace)
Appends a value to the given series. If the number of samples is less than the sample count, a new sample is added after the last one. If the number of samples in the series is the same as the sample count (series is full), the addition will depend on the makeSpace parameter.

If the makeSpace parameter is set to false, all the current values will shift one sample to the left (the sample itself will not move, only the value) and the new value will be set in the last sample.

If the makeSpace parameter is set to true, the sample count will be increased by one, and a new sample will be added at the end.

Parameters:
serie - The series to append the sample to.
value - The value to append.
makeSpace - True to make space for the new parameter.
Returns:
The index of the position where the sample was inserted.
Throws:
java.lang.IllegalArgumentException - If the serie is invalid.

autoRepaint

public void autoRepaint()
Calls repaint() if the automaticRepaintOn is turned on.


calculateChartData

protected abstract void calculateChartData(java.awt.Rectangle grid,
                                           java.awt.Rectangle dataBounds)
Calculates the data used for the chart.

Parameters:
grid - The chart grid bounds to paint data within.
dataBounds - The scrolled bounds to calculate the data within.

checkDataIntegrity

protected void checkDataIntegrity()
This method is called each time the sample count or series count changes, and ensures that all the data has the right size. Any class that overrides this method must remember to call super.checkDataIntegrity().


checkSelection

protected com.objectplanet.chart.ChartSample checkSelection(java.awt.Point point)
This method is called when the user releases the mouse and checks if the given point is inside a sample. The default behaviour is to check for selection on the legend if the legend is turned on. If the number of series is 1, the selected label in the legend corresponds to the respective sample in the chart. If the number of series is more than 1, the returned sample will have the series index set, but the sample index will be set to -1. If any subclass wants to add selection behaviour, override this and call super.checkSelection().

Parameters:
point - The point to check for.
Returns:
The sample selected, or null if none was selected.

createImage

public java.awt.Image createImage(int width,
                                  int height)
Creates an offscreen image.

Overrides:
createImage in class java.awt.Component
Parameters:
width - The width of the image in pixels.
height - The height of the image in pixels.

forceRepaint

public void forceRepaint()
Forces immidiate repaint of the chart.


formatNumber

public java.lang.String formatNumber(double value,
                                     int decimals)
Formats a floating number to the number of decimals given. The formatted number will have the integer part paired in three and three.

Parameters:
value - The value to format.
decimals - The number of decimals to use.
Returns:
A string with the formatted number.

get3DDepth

public int get3DDepth()
Gets the depth of the 3D effect.

Returns:
The depth in pixels, -1 if default depth (variable) is used.
See Also:
set3DDepth(int)

getChartBackground

public java.awt.Color getChartBackground()
Gets the color of the chart background itself.


getChartData

public com.objectplanet.chart.ChartData getChartData()
Gets the chart data for this chart.


getChartForeground

public java.awt.Color getChartForeground()
Gets the color of the chart foreground itself.


getCurrentLowerRange

public double getCurrentLowerRange(int adjuster)
Gets the current lower range of the specified range adjuster.

Parameters:
adjuster - The index of the range adjuster (0 or 1).
See Also:
setCurrentLowerRange(int, double)

getCurrentRange

public double getCurrentRange(int adjuster)
Gets the current upper range of the specified range adjuster.

Parameters:
adjuster - The index of the range adjuster (0 or 1).
See Also:
setCurrentRange(int, double)

getDataBounds

public java.awt.Rectangle getDataBounds(java.awt.Rectangle grid)
This method returns the bounding box for the data to be drawn in.

Parameters:
grid - The bounds of the chart grid.
Returns:
A rectangle with the bounds.
Throws:
java.lang.IllegalArgumentException - if the grid is null.

getFont

public java.awt.Font getFont(java.lang.String label)
Gets the font for the specified label. If no specific font is specified for this label, it returns the font returned by getFont().

Parameters:
label - The name of the label.
Returns:
The font (never null).

getGraphBounds

public abstract java.awt.Rectangle getGraphBounds()
This method returns the bounding box for the chart grid.


getGraphInsets

public java.awt.Insets getGraphInsets()
Gets the graph insets.

See Also:
setGraphInsets(int, int, int, int)

getGridLine

public double getGridLine(int index)
Gets grid lines positon value by its index.

Parameters:
index - The index of the line to get value from.
Returns:
A grid line position value.

getGridLineColor

public java.awt.Color getGridLineColor(int index)
Gets grid line's color value by it's index.

Parameters:
index - The index of the line to get color from.
Returns:
Grid line color of the given line.

getGridLineColors

public java.awt.Color[] getGridLineColors()
Gets the vertical grid lines colors.

Returns:
The array with grid lines colors.

getGridLines

public double[] getGridLines()
Gets the vertical grid lines positons.

Returns:
The array with grid lines position values, or null if not set.

getImage

public java.awt.Image getImage(int width,
                               int height)
Returns the current chart as an image.

Parameters:
width - The width of the chart in pixels.
height - The height of the chart in pixels.
Returns:
The chart as an image object.

getImage

public java.awt.Image getImage(java.lang.String name)
Gets the image with the specified name.

Parameters:
name - The name of the image.
Returns:
The image, or null if no image was found.

getLabel

public java.lang.String getLabel(java.lang.String name)
Gets the specified label from the chart.

Parameters:
name - The name of the label.
Returns:
The label, or null if not found.
See Also:
setLabel(java.lang.String, java.lang.String)

getLabelAngle

public int getLabelAngle(java.lang.String name)
Gets the angle of the specified label.

Parameters:
name - The name of the label.
Returns:
The label, or null if not found.
See Also:
setLabel(java.lang.String, java.lang.String)

getLastSelectedSample

public int getLastSelectedSample()
Gets the index of the last selected sample.

Returns:
The index of the sample, or -1 if none are selected.

getLastSelectedSeries

public int getLastSelectedSeries()
Gets the index of the last selected series.

Returns:
The index of the series, or -1 if none are selected.

getLegendColor

public java.awt.Color getLegendColor(int index)
Gets legend entry's color value by it's index.

Parameters:
index - The index of the legend entry to get color from.
Returns:
Color of the given legend entry.

getLegendColors

public java.awt.Color[] getLegendColors()
Gets the legend colors.

Returns:
The array with legend colors.

getLegendImage

public java.lang.String getLegendImage(int index)
Gets a legend entry's image name.

Parameters:
index - The index of the legend entry.
Returns:
The name of the image, or null if the default legend box is used.

getLegendLabels

public java.lang.String[] getLegendLabels()
Gets the legend labels. The array returned is the original, so don't change anything in it if you don't know what you are doing.

Returns:
An array containing the labels.
See Also:
setLegendLabels(java.lang.String[])

getLegendPosition

public int getLegendPosition()
Gets the legend position.

Returns:
TOP, BOTTOM, LEFT, or RIGHT.

getLowerRange

public double getLowerRange(int index)
Gets the lower value of the specified range.

Parameters:
index - The index of the range.

getMaxValue

public double getMaxValue(int serie)
Gets the largest value in the specified data series. If the specified series (i.e -1) does not exist, the value returned will be the maximum value of the whole chart.

Parameters:
serie - The index of the serie (0-based).

getMaxValueLineCount

public int getMaxValueLineCount()
Gets the current maxium number of value lines set.

Returns:
The count, or -1.
See Also:
setMaxValueLineCount(int)

getMinimumSize

public java.awt.Dimension getMinimumSize()
This method returns the minimum size of the chart. The default chart size is 100 by 70 pixels.

Overrides:
getMinimumSize in class java.awt.Component

getMinValue

public double getMinValue(int serie)
Gets the smallest value in the specified data series. If the specified series (i.e -1) does not exist, the value returned will be the minimum value of the whole chart.

Parameters:
serie - The index of the serie (0-based).

getOverlayChart

public com.objectplanet.chart.Chart getOverlayChart(int index)
Gets the specified overlay chart.

Parameters:
index - The index of the overlay chart.
Returns:
The chart, or null if not found.

getPreferredSize

public java.awt.Dimension getPreferredSize()
This method is called by the awt, and returns the preferred size of the chart. The default size of the chart is 300 by 200 pixels.

Overrides:
getPreferredSize in class java.awt.Component

getRange

public double getRange(int index)
Gets the upper value of the specified range.

Parameters:
index - The index of the range (0 or 1).

getRangeAdjusted

public int getRangeAdjusted(int adjuster)
Gets the range(s) adjusted by the specified adjuster.

Parameters:
adjuster - The index of the adjuster (0 or 1).
Returns:
0 = range 0, 1 = range 1, 2 = both ranges.

getRangeAdjusterPosition

public int getRangeAdjusterPosition(int adjuster)
Gets the position of the range adjuster.

Parameters:
adjuster - The index of the adjuster (0 or 1).
Returns:
0 for left, 1 for right.

getRangeColor

public java.awt.Color getRangeColor(int index)
Gets the color of the specified range.

Parameters:
index - The index of the range (0 or 1).

getRangeDecimalCount

public int getRangeDecimalCount(int index)
Gets the number of decimals used in the range values.

Parameters:
index - The index of the range (0 or 1).

getRangePosition

public int getRangePosition(int index)
Gets the range position.

Parameters:
index - The index of the range (0 or 1).
Returns:
0 for left, 1 for right.

getSample

public com.objectplanet.chart.ChartSample getSample(int serie,
                                                    int index)
Gets the specified sample.

Parameters:
serie - The index of the serie (0-based).
index - The index of the sample (0-based).
Returns:
The sample, or null if no sample was found.
Throws:
java.lang.IllegalArgumentException - if the serie or index is invalid.

getSample

public com.objectplanet.chart.ChartSample getSample(java.lang.Object key)
Gets the sample with the given key.

Parameters:
key - The key of the sample to get.
Returns:
The sample with the key, or null if no sample has that key.

getSampleColor

public java.awt.Color getSampleColor(int index)
Gets the color of the specified sample. This is the color of the sample itself, not the color of the sample label.

Parameters:
index - The index of the sample.

getSampleColors

public java.awt.Color[] getSampleColors()
Gets the array of colors used for the samples. This can also be used to find out the number of sample colors by taking the length of the array.

Returns:
An array containing the sample colors.

getSampleCount

public int getSampleCount()
Gets the number of samples.


getSampleDecimalCount

public int getSampleDecimalCount(int serie)
Gets the number of decimals used for the sample values.

Parameters:
serie - The index of the serie.

getSampleLabel

public java.lang.String getSampleLabel(int index)
Gets the specified sample label.

Parameters:
index - The index of the sample (0-based).
Returns:
The sample label, or null if no label was found.
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

getSampleLabelColor

public java.awt.Color getSampleLabelColor(int index)
Gets the color of the label of the specified sample.

Parameters:
index - The index of the sample (0-based).
Returns:
The color, or null if no color is set.

getSampleLabels

public java.lang.String[] getSampleLabels()
Gets the sample labels. The array returned is the original, so don't change anything in the array if you don't know what you are doing.

Returns:
The labels as an array of strings.

getSampleLabelSelectionColor

public java.awt.Color getSampleLabelSelectionColor()
Gets the color used for the sample labels when a sample is selected.

Returns:
The color used, or null if no special color is used.

getSampleLabelStyle

public int getSampleLabelStyle()
Gets the current style of the sample labels.


getSamples

public com.objectplanet.chart.ChartSample[] getSamples(int serie)
Gets the samples for the specified serie.

Parameters:
serie - The index of the serie (0-based).
Returns:
The samples as an array of ChartSample objects.
Throws:
java.lang.IllegalArgumentException - if the serie is invalid.

getSampleValue

public double getSampleValue(int serie,
                             int index)
Gets the specified sample value.

Parameters:
serie - The index of the serie (0-based).
index - The index of the sample (0-based).
Returns:
The sample value, or Double.NaN if no sample value is set.
Throws:
java.lang.IllegalArgumentException - if the serie or index is invalid.

getSampleValues

public double[] getSampleValues(int serie)
Gets the sample values for the specified serie.

Parameters:
serie - The index of the serie (0-based).
Returns:
The values as an array of floating point numbers.
Throws:
java.lang.IllegalArgumentException - if the serie is invalid.

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Gets the currently selected objects.

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
The objects as an array, or null if none are selected.

getSeriesCount

public int getSeriesCount()
Gets the number of series.


getSeriesLabel

public java.lang.String getSeriesLabel(int serie)
Gets the specified series label.

Parameters:
serie - The index of the serie (0-based).
Returns:
The sample label, or null if no label was found.
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

getSeriesLabelColor

public java.awt.Color getSeriesLabelColor(int serie)
Gets the color of the label of the specified series.

Parameters:
serie - The index of the series (0-based).
Returns:
The color, or null if no color is set.
Throws:
java.lang.IllegalArgumentException - if the series index is invalid.

getSeriesLabels

public java.lang.String[] getSeriesLabels()
Gets the series labels.

Returns:
The labels as an array of strings, or null if no labels are found.

getSeriesLabelStyle

public int getSeriesLabelStyle()
Gets the current style of the series labels.


getSeriesRange

public int getSeriesRange(int series)
Gets the range the specified series belongs to.

Parameters:
series - The index of the series.
Returns:
The index of the range (0 or 1).

getSize

public java.awt.Dimension getSize()
Returns the size of the chart component.

Overrides:
getSize in class java.awt.Component

getTargetValueLine

public double getTargetValueLine(java.lang.String id)
Gets the value of a target value line.

Parameters:
id - The id of the target line.
Returns:
The value of the line.

getThousandsDelimeter

public java.lang.String getThousandsDelimeter()
Gets the current thousands delimeter for use in the display of numbers.

Returns:
The current delimiter, or null if the Locale is used.

getTitle

public java.lang.String getTitle()
Gets the chart title.

See Also:
setTitle(java.lang.String)

getValueLinesColor

public java.awt.Color getValueLinesColor()
Gets the color of the value lines.


getVersion

public static java.lang.String getVersion()
Returns the current version of the charts.


is3DModeOn

public boolean is3DModeOn()
Checks if the 3D mode is turned on.

Returns:
True for on, false for off.

isAutomaticRepaintOn

public boolean isAutomaticRepaintOn()
Checks if the automatic repaint is on.

Returns:
True for on, false for off.
See Also:
setAutomaticRepaintOn(boolean)

isDefaultGridLinesOn

public boolean isDefaultGridLinesOn()
Checks if the default vertical grid lines are on.

Returns:
True if on, false if off.

isFloatingOnLegendOn

public boolean isFloatingOnLegendOn()
Checks if floating labels are displayed when the mouse moves over the legend. By default, the floating labels for all the samples in a series appear when the mouse hovers over the legend box for that series.

Returns:
True for on, false for off.
See Also:
setFloatingOnLegendOn(boolean)

isGridAdjustmentOn

public boolean isGridAdjustmentOn(int edge)
Checks if runtime grid adjustment is on.

Parameters:
edge - TOP, LEFT, BOTTOM, or RIGHT.
Returns:
True if on, false if off.

isLegendOn

public boolean isLegendOn()
Checks if the legend is turned on.

Returns:
True for on, false for off.

isOverlayChartOn

public boolean isOverlayChartOn(int index)
Checks if the specified overlay chart is on.

Parameters:
index - The index of the overlay chart.
Returns:
True if on, false if off.

isPrintAsBitmap

public boolean isPrintAsBitmap()
Checks if the chart will be printed as a bitmap.

Returns:
True if bitmap, false otherwise.

isRangeAdjusterOn

public boolean isRangeAdjusterOn(int adjuster)
Checks if the specified range adjuster is turned on.

Parameters:
adjuster - The index of the adjuster (0 or 1)
Returns:
True if turned on, false otherwise.

isRangeLabelsOn

public boolean isRangeLabelsOn(int range)
Checks if the range labels are on or off for the specified range.

Parameters:
range - The index of the range to check for.
Returns:
True for on, false for off.

isRangeOn

public boolean isRangeOn(int index)
Checks if the specified range is on.

Parameters:
index - The index of the range (0 or 1).
Returns:
True for on, false of off.

isSampleLabelsOn

public boolean isSampleLabelsOn()
Checks if the sample labels are turned on.

Returns:
True if they are turned on, false otherwise.

isSampleScrollerOn

public boolean isSampleScrollerOn()
Checks if the sample scroller is turned on.

Returns:
True if turned on, false otherwise.

isSelected

public boolean isSelected(int serie,
                          int sample)
Checks if a sample is selected.

Parameters:
serie - The series index (-1 is whole series).
sample - The sample index (-1 is all samples in series).
Throws:
java.lang.IllegalArgumentException - If the serie or sample is invalid.

isSeriesLabelsOn

public boolean isSeriesLabelsOn()
Checks if the floating series labels is turned on.

Returns:
True for on, false for off.

isServletModeOn

public boolean isServletModeOn()
Checks if the servlet mode is turned on.

Returns:
True for on, false for off.
See Also:
setServletModeOn(boolean)

isTitleOn

public boolean isTitleOn()
Checks if the title is turned on.

Returns:
True if on, false if off.

isValueLabelsOn

public boolean isValueLabelsOn()
Checks if the value labels are turned on for any series.

Returns:
True for on, false for off.

isValueLabelsOn

public boolean isValueLabelsOn(int serie)
Checks if the value labels are turned on for a specified series. Use -1 to check if any of the series has the value labels turned on.

Parameters:
serie - The serie to check for.
Returns:
True for on, false for off.

isValueLinesOn

public boolean isValueLinesOn()
Checks if the value lines are turned on.

Returns:
True for on, false for off.

loadImage

public java.awt.Image loadImage(java.lang.String name)
Loads an image from the disk.

Parameters:
name - The file name of the image.
Returns:
The image loaded, or null if not found or it failed.

main

public static void main(java.lang.String[] argv)
Prints out the current version number.


paint

public final void paint(java.awt.Graphics g)
This method is overridden to paint the chart using double buffering. This is done to avoid flickering, and the method render() has to be implemented by a subclass instead to paint the chart itself.

Overrides:
paint in class java.awt.Component
See Also:
render(java.awt.Graphics)

print

public final void print(java.awt.Graphics g)
Call this methods if you want to print the chart from a java program. If the VM has problems printing the chart correctly, call setPrintAsBitmap(true) before printing.

Overrides:
print in class java.awt.Component

processEvent

protected void processEvent(java.awt.AWTEvent e)
Handles the chart events.

Overrides:
processEvent in class java.awt.Component

removeExternalGraphics

public void removeExternalGraphics()
Removes external graphics context if there is one.

See Also:
setExternalGraphics(java.awt.Graphics, java.awt.Image)

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Removes the specified item listener from the chart.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
l - The item listener to remove.
See Also:
addItemListener(java.awt.event.ItemListener)

removeOverlayChart

public void removeOverlayChart(int index)
Removes the specified overlay chart. The charts with an index higher than the one removed will be moved down - their index will be decreased by on.

Parameters:
index - The index of the chart to be removed.
Throws:
java.lang.IllegalArgumentException - If the index is invalid.

render

protected abstract void render(java.awt.Graphics g)
This method is called by paint(), and has to be implemented by the subclass to render the chart.

Parameters:
g - The graphics context used to paint with.
See Also:
paint(java.awt.Graphics)

renderData

protected abstract void renderData(java.awt.Graphics g,
                                   java.awt.Rectangle grid,
                                   java.awt.Rectangle dataBounds)
This method renders the data (bars, lines, pies).

Parameters:
g - The graphics context used to paint with.
grid - The chart grid bounds to paint data within.
dataBounds - The scrolled bounds to calculate the data within.

reset

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


run

public void run()
Internal do not call.

Specified by:
run in interface java.lang.Runnable

set3DDepth

public void set3DDepth(int depth)
Sets the depth of the 3D effect in number of pixels. By default the depth is a function of the size of the chart and the number of samples.

Parameters:
depth - The number of pixels, -1 for default (variable) depth.

set3DModeOn

public void set3DModeOn(boolean on)
Turns on or off 3D look of the chart. Not all chart types will have both a 2D and 3D mode.

Parameters:
on - True for 3D, false for 2D look.

setAutomaticRepaintOn

public void setAutomaticRepaintOn(boolean state)
Turns on or off the automatic repaint. If this is turned on, the chart will automatically be refreshed after each chart update. If this is turned off it will not. You must turn it on before your then call autoRepaint() to refresh the chart. your updates. If you want to make a lot of changes to the chart and it's data, you might want to turn this off (for speed), and then turn it back on when you are done.

Parameters:
state - True for on, false for off.

setBackground

public void setBackground(java.awt.Color color)
Sets the chart component background color, outside the chart grid. Use the setChartBackground() method to set the chart grid color.

Overrides:
setBackground in class java.awt.Component
Parameters:
color - The color to use.
See Also:
setChartBackground(java.awt.Color)

setChartBackground

public void setChartBackground(java.awt.Color color)
Sets the background color of the chart itself. Use setBackground() to set the background color outside the chart grid itself.

Parameters:
color - The color to use.

setChartData

public void setChartData(com.objectplanet.chart.ChartData chartData)
Lets the chart use the specified chart data.

Parameters:
chartData - The chart data to use for the chart.

setChartForeground

public void setChartForeground(java.awt.Color color)
Sets the foreground color of the chart itself. Use setForeground() to set the color of the title, value labels, and other text.

Parameters:
color - The color to use.

setCurrentLowerRange

public void setCurrentLowerRange(int adjuster,
                                 double lower)
Sets the current lower range of the specified range adjuster. The chart lower range will not be affected.

Parameters:
adjuster - The index of the range adjuster (0 or 1).
lower - The range to use, larger or equal to the lower range.

setCurrentRange

public void setCurrentRange(int adjuster,
                            double upper)
Sets the current upper range of the specified range adjuster. The full range of the chart will be unaffected.

Parameters:
adjuster - The index of the adjuster (0 or 1)
upper - The range to use, less or equal to the full range.

setDefaultGridLinesColor

public void setDefaultGridLinesColor(java.awt.Color color)
Sets the color of the default vertical grid lines.

Parameters:
color - The color to set for default grid lines.

setDefaultGridLinesOn

public void setDefaultGridLinesOn(boolean on)
Turns on or off the default vertical grid lines. When calling this method, default grid lines are automatically set at the sample point positions for line chart and between the samples for bar chart.

Parameters:
on - True for on, false for off.
See Also:
setGridLines(double[])

setDefaultGridLinesOn

public void setDefaultGridLinesOn(boolean on,
                                  double start,
                                  double step)
Turns on or off the default vertical grid lines. When calling this method, the lines are shown from the start position and distance between the lines is set to step. The grid values are relative to the sample axis range (default 0 to 100).

Parameters:
on - True for on, false for off.
start - Position of the first line.
step - Distance between lines.
See Also:
setGridLines(double[])

setExternalGraphics

public void setExternalGraphics(java.awt.Graphics g,
                                java.awt.Image image)
Sets an external graphics context to paint with. The size of the image must at least as large as the largest chart that will be displayed.

Parameters:
g - The graphics context used for painting.
image - The image to which graphics context belongs. See here for an example.

setFloatingOnLegendOn

public void setFloatingOnLegendOn(boolean on)
Turn on or off floating labels when the mouse moves over the legend. By default, the floating labels for all the samples in a series appear when the mouse hovers over the legend box for that series.

Parameters:
on - True for on, false for off.

setFont

public void setFont(java.lang.String label,
                    java.awt.Font font)
Sets the font for the specified label. To remove the font and use the default one, pass in the font as null.

Parameters:
label - "titleFont" or "legendFont".
font - The font to set for the label.

setForeground

public void setForeground(java.awt.Color color)
Sets the color of the labels.

Overrides:
setForeground in class java.awt.Component
Parameters:
color - The color to use.
See Also:
setChartBackground(java.awt.Color)

setGraphInsets

public void setGraphInsets(int top,
                           int left,
                           int bottom,
                           int right)
Sets the insets between the graph itself and the chart component edges. Setting a value of -1 uses the default insets.

Parameters:
top - The top insets in pixels.
left - The left insets in pixels.
bottom - The bottom insets in pixels.
right - The right insets in pixels.

setGridAdjustmentOn

public void setGridAdjustmentOn(int edge,
                                boolean on)
Turns on or of runtime grid adjustment.

Parameters:
edge - TOP,LEFT,BOTTOM, or RIGHT.
on - True or on, false for off.

setGridLine

public void setGridLine(int index,
                        double value)
Sets a single grid line value.

Parameters:
index - The index of the line to set value for.
value - The value to set.
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

setGridLineColor

public void setGridLineColor(int index,
                             java.awt.Color color)
Sets a single grid line color.

Parameters:
index - The index of the line to set Color for.
color - The color to set for the grid line.
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

setGridLineColors

public void setGridLineColors(java.awt.Color[] colors)
Sets the color of each vertical grid line.

Parameters:
colors - The array with grid lines colors.

setGridLines

public void setGridLines(double[] grid)
Sets the vertical grid lines positons. The grid values are relative to the sample axis range (default 0 to 100).

Parameters:
grid - The array with grid lines position values.
See Also:
setSampleAxisRange(double, double)

setGridLinesColor

public void setGridLinesColor(java.awt.Color color)
Sets the vertical grid lines color. If new grid lines are added, this method has to be called again

Parameters:
color - The color to set for all lines.

setLabel

public void setLabel(java.lang.String name,
                     java.lang.String label)
Sets the specified label in the chart.

Parameters:
name - The name of the label.
label - The label to use, null for no label.

setLabelAngle

public void setLabelAngle(java.lang.String name,
                          int angle)
Sets the angle of the specified label.

Parameters:
name - The name of the label.
angle - The angle to use for the label.

setLabelAngleCacheSize

public static void setLabelAngleCacheSize(int count)
Sets the angled label cache size. Since JDK 1.1 is used, angled labels are not available using the normal drawing operations. Instead a label is drawn on an image and the image is then rotated, before painted as the label. Since the image rotation takes quite a long time, the images are cached to save rendering time. However, this causes a problem with Internet Explorer wich will throw a security exception if more than 1000 images are created and held on to in the VM. To avoid this the size of the cache is set to 900 by default. This can be adjusted if you will create other images in your applet. Also, the angled label image cache will increase memory and resource usage, so you might want to turn it off (set the cachec size to 0 or less. The angled label cache is static so it is shared across all applets running in the same browser instance. Good luck :)

Parameters:
count - The image cache count, less than 0 to turn it off.

setLegendColor

public void setLegendColor(int index,
                           java.awt.Color color)
Sets a legend entry color.

Parameters:
index - The index of the legend entry to set Color for.
color - The color to set for the legend entry.
See Also:
setLegendColors(java.awt.Color[]), setLegendImage(int, java.lang.String)

setLegendColors

public void setLegendColors(java.awt.Color[] colors)
Sets the legend colors. By default the legend colors are taken from the sample colors.

Parameters:
colors - The array with legend colors.
Throws:
java.lang.IllegalArgumentException - if the colors is null.
See Also:
setLegendColor(int, java.awt.Color), setLegendImage(int, java.lang.String)

setLegendImage

public void setLegendImage(int index,
                           java.lang.String name)
Sets an image to be used in front of the legend label. The image itself must be added prior to calling this method using the addImage() method.

Parameters:
index - The index of the legend entry to set the image for.
name - The image to use, null for the default legend box.
See Also:
addImage(java.lang.String, java.awt.Image)

setLegendLabels

public void setLegendLabels(java.lang.String[] labels)
Sets the legend labels. If the number of series, the default legend labels are the sampleLabels and if the number of series is larger than 1, the legend labels are the series labels. This method overrides the default legend labels. To use the series label when only one series, call setLegendLabels(getSeriesLabels());

Parameters:
labels - The labels to use, null for default behavior.

setLegendOn

public void setLegendOn(boolean on)
Turns on or off the label legend. The label legend displays the label for each of the samples with each sample keyed by its color code. The legend can be displayed on the top, bottom, left, or right of the chart.

Parameters:
on - True if the legend should be displayed.
See Also:
setLegendPosition(int)

setLegendPosition

public void setLegendPosition(int position)
Sets the legend position. The legend can be displayed at the top, bottom, left, or right side of the chart.

Parameters:
position - TOP, BOTTOM, LEFT, or RIGHT.
Throws:
java.lang.IllegalArgumentException - If the position is invalid.

setLowerRange

public void setLowerRange(int index,
                          double range)
Sets the lower range of the chart. The lower range is the minimum value on the value axis, and the bars are adjusted according to this value.

Parameters:
index - The index of the range to set (0 or 1).
range - The range to set.
See Also:
setRange(int, double)

setLowerRelativeRange

public void setLowerRelativeRange(double range)
Sets the lower range of the chart relative to the current minimum value. If the lowest value is -1000, and the lower range is set to 1.5, the new lower range will then be -1500. If all the values are positive, the lower range will be set to 0.

Parameters:
range - The relative range;
See Also:
setLowerRelativeRange(double)

setLowerRelativeRange

public void setLowerRelativeRange(double range,
                                  double step)
Sets the lower range of the chart relative to the minimum value of the bars in the chart. The range will be divisible by the step value specified. If the minimum value is -987, and the relative range is set to 1.0 and the step is set to 100, the new range will be -1000, and the bars will be adjusted according to the new range. If all the values are positive, the lower range will be set to 0.

Parameters:
range - The relative range (0.0->);
step - The range will be divisible by this value.
See Also:
setLowerRelativeRange(double)

setLowerRelativeRange

public void setLowerRelativeRange(int index,
                                  double range,
                                  double step)
Sets the lower range of the chart relative to the minimum value of the bars in the chart. The range will be divisible by the step value specified. If the minimum value is -987, and the relative range is set to 1.0 and the step is set to 100, the new range will be -1000, and the bars will be adjusted according to the new range. If all the values are positive, the lower range will be set to 0.

Parameters:
index - The index of the range (0 or 1).
range - The relative range (0.0->);
step - The range will be divisible by this value.
See Also:
setLowerRelativeRange(double)

setMaxValueLineCount

public void setMaxValueLineCount(int count)
Sets the maximum number of value lines there should be in the chart. If set to -1, the number will be as many as there is room for.

Parameters:
count - The value line count.

setOverlayChart

public void setOverlayChart(int index,
                            com.objectplanet.chart.Chart chart)
Sets the specified overlay chart. The lower and upper range of the overlay chart will be adjusted to the base chart's ranges.

Parameters:
index - The index of the overlay chart.
chart - The chart to set for this overlay position.
Throws:
java.lang.IllegalArgumentException - If the index is invalid.

setOverlayChartOn

public void setOverlayChartOn(int index,
                              boolean on)
Sets the specified overlay chart on or off.

Parameters:
index - The index of the overlay chart.
on - True for on, false for off (on by default).

setPreferredSize

public void setPreferredSize(int width,
                             int height)
Sets the preferred size of the chart. This is the size used with layout managers that do not stretch the component.

Parameters:
width - The preferred width.
height - The preferred height.

setPrintAsBitmap

public void setPrintAsBitmap(boolean on)
Turns on printing as bimap. Some browsers/VMs/printers/operating systems have problems printing java applets. If this is the case, turn bitmap printing on, and it might work around some of the problems.

Parameters:
on - True for on, false for off.

setRange

public void setRange(int index,
                     double range)
Sets the upper value of the specified range. The upper range is the maximum value on the value axis, and the bars are adjusted according to this value. If you have any overlay charts added to this chart, the range of those charts will also be set.

Parameters:
index - The index of the range to set (0 or 1).
range - The range to set.
See Also:
setLowerRange(int, double)

setRangeAdjusted

public void setRangeAdjusted(int adjuster,
                             int range)
Sets which range(s) to be adjusted by the specified adjuster. By default adjuster 0 adjusts range 0 and son on.

Parameters:
adjuster - The index of the adjuster (0 or 1).
range - 0 = range 0, 1 = range 1, 2 = both ranges.

setRangeAdjusterOn

public void setRangeAdjusterOn(int adjuster,
                               boolean on)
Turns on or off the range adjuster. When this is on, the user can adjust the range to see any low-value lines more clearly. This is only applicable for chart types with grids.

Parameters:
adjuster - The index of the adjuster (0 or 1)
on - True for on, false for off.

setRangeAdjusterPosition

public void setRangeAdjusterPosition(int adjuster,
                                     int position)
Sets the position of the range adjuster.

Parameters:
adjuster - The index of the adjuster (0 or 1).
position - 0 for left, 1 for right (default is right).

setRangeColor

public void setRangeColor(int index,
                          java.awt.Color color)
Sets the color of the specified range.

Parameters:
index - The index of the range (0 or 1).
color - The color to use for the range.

setRangeDecimalCount

public void setRangeDecimalCount(int index,
                                 int count)
Sets the number of decimals to use in the range label values.

Parameters:
index - The index of the range (0 or 1).
count - The number of decimals to use.

setRangeLabelsOn

public void setRangeLabelsOn(int range,
                             boolean on)
Turns on or off the range value labels for the specified range. The labels are on by default.

Parameters:
range - The index of the range.
on - True for on, false for off.

setRangeOn

public void setRangeOn(int index,
                       boolean on)
Turns on or off the specified range.

Parameters:
index - The index of the range (0 or 1).
on - True for on, false of off.

setRangePosition

public void setRangePosition(int index,
                             int position)
Sets the range position.

Parameters:
index - The index of the range (0 or 1).
position - 0 for left, 1 for right

setRelativeRange

public void setRelativeRange(double range)
Sets the upper range of the chart relative to the maximum value of the bars in the chart. If the maximum value is 1000, and the upper range is set to 1.5, the new range will be 1500, and the bars will be adjusted according to the new range. If all the values are negative, the upper range will be set to 0. If all values are 0 or null, the range will be set to 100.

Parameters:
range - The relative range (0.0->);
See Also:
setRelativeRange(double, double)

setRelativeRange

public void setRelativeRange(double range,
                             double step)
Sets the upper range of the chart relative to the maximum value of the bars in the chart. The range will be divisible by the step value specified. If the maximum value is 987, and the relative range is set to 1.0 and the step is set to 100, the new range will be 1000, and the bars will be adjusted according to the new range. If all the values are negative, the upper range will be set to 0.

Parameters:
range - The relative range (0.0->);
step - The range will be divisible by this value.
See Also:
setRelativeRange(double)

setRelativeRange

public void setRelativeRange(int index,
                             double range,
                             double step)
Sets the upper range of the chart relative to the maximum value of the bars in the chart. The range will be divisible by the step value specified. If the maximum value is 987, and the relative range is set to 1.0 and the step is set to 100, the new range will be 1000, and the bars will be adjusted according to the new range. If all the values are negative, the upper range will be set to 0.

Parameters:
index - The index of the range to set (0 or 1).
range - The relative range (0.0->);
step - The range will be divisible by this value.
See Also:
setRelativeRange(double)

setSample

public void setSample(int serie,
                      int index,
                      com.objectplanet.chart.ChartSample sample)
Sets the specified sample. If a null sample is given, the sample is cleared.

Parameters:
serie - The index of the serie (0-based).
index - The index of the sample (0-based).
sample - The sample to use.
Throws:
java.lang.IllegalArgumentException - if the serie or index is invalid.

setSampleAxisRange

public void setSampleAxisRange(double min,
                               double max)
Sets the left and the right range of the chart. All grid lines that fit into this period are shown on the chart. If this method is not used, default values are used. Default values are 0 for the left range and 100 for the right range.

Parameters:
min - The left range
max - The right range
Throws:
java.lang.IllegalArgumentException - if min more or equal than max.

setSampleColor

public void setSampleColor(int index,
                           java.awt.Color color)
Sets the color of the specified sample. If the index is larger than or equal to the number of total sample colors, later samples that fall on that index will be given the same color.

Parameters:
index - The index of the sample (0-based).
color - The color to be used for the sample.

setSampleColors

public void setSampleColors(java.awt.Color[] colors)
Sets the sample colors. If the number of samples is larger than the number of colors, the colors of the samples will cycle through the array. To use the default colors, use NULL as a parameter.

Parameters:
colors - An array with the colors to be used, null for default colors.

setSampleCount

public void setSampleCount(int count)
Sets the number of samples.

Parameters:
count - The number of samples.

setSampleDecimalCount

public void setSampleDecimalCount(int serie,
                                  int count)
Sets the number of decimals in the sample values. The default value is 0.

Parameters:
serie - The index of the series (-1 for all).
count - The number of decimals to use.

setSampleLabel

public void setSampleLabel(int index,
                           java.lang.String label)
Sets the specified sample label.

Parameters:
index - The index of the sample (0-based).
label - The label of the sample.
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

setSampleLabelColor

public void setSampleLabelColor(int index,
                                java.awt.Color color)
Sets the color of of the label for the specified sample.

Parameters:
index - The index of the sample (0-based).
color - The color to use, null for the default color.
Throws:
java.lang.IllegalArgumentException - if the sample index is invalid.

setSampleLabels

public void setSampleLabels(java.lang.String[] labels)
Sets the sample labels.

Parameters:
labels - The labels to use.

setSampleLabelSelectionColor

public void setSampleLabelSelectionColor(java.awt.Color color)
Sets the color used for the sample labels when a sample is selected.

Parameters:
color - The color to use, or null for no color.

setSampleLabelsOn

public void setSampleLabelsOn(boolean on)
Turns on the sample labels on the x-axis. The sample labels are for the first series only, and will be the same for all the series. These labels are not the same as the ones in the legend.

Parameters:
on - True for on, false for off.

setSampleLabelStyle

public void setSampleLabelStyle(int style)
Sets the style of the sample labels. By default, the sample labels are displayed below the chart grid for each sample point. The sample labels can also be displayed as a tooltip like label when the mouse is over the line's sample point (FLOATING) or statically near the sample point (OUTSIDE).

Parameters:
style - BELOW, FLOATING, BELOW_AND_FLOATING, OUTSIDE.

setSamples

public void setSamples(int serie,
                       com.objectplanet.chart.ChartSample[] samples)
Sets the samples for the specified series. If the number of samples is less than the current sample count, the rest of the samples will be set to null. If the number of samples is larger than the current sample count, the rest of the samples will be discarded.

Parameters:
serie - The index of the serie (0-based).
samples - The samples to set.
Throws:
java.lang.IllegalArgumentException - if the serie is invalid.

setSampleScrollerOn

public void setSampleScrollerOn(boolean on)
Turns on or off the sample scroller. When this is on, the user can adjust the samples seen in the chart. This is only applicable for chart types with grids.

Parameters:
on - True for on, false for off.

setSampleValue

public void setSampleValue(int serie,
                           int index,
                           double value)
Sets the specified sample value.

Parameters:
serie - The index of the serie (0-based).
index - The index of the sample (0-based).
value - The value to use for the sample.
Throws:
java.lang.IllegalArgumentException - if the serie or index is invalid.

setSampleValues

public void setSampleValues(int serie,
                            double[] values)
Sets the sample values for the specified series. If the number of values is less than the current sample count, the rest of the samples will be set to null. If the number of values is larger than the current sample count, the rest of the values will be discarded.

Parameters:
serie - The index of the serie (0-based).
values - The values to use for the series.
Throws:
java.lang.IllegalArgumentException - if the serie is invalid.

setSelection

public void setSelection(int serie,
                         int sample,
                         boolean selected)
Marks a sample as selected or deselected. If serie is -1, the specified sample in all series are marked. If sample is -1, all the samples in the specified series is marked. Listeners are notified of sample selections.

Parameters:
serie - The series index.
sample - The sample index.
selected - True for selected, false for deselected.
Throws:
java.lang.IllegalArgumentException - If the serie or sample is invalid.

setSelection

public void setSelection(int serie,
                         int sample,
                         boolean selected,
                         boolean notify)
Marks a sample as selected or deselected. Listeners are only notified if this is specified with the notify parameter.

Parameters:
serie - The series index.
sample - The sample index.
selected - True for selected, false for deselected.
notify - True if listeners should be notified, false otherwise.
Throws:
java.lang.IllegalArgumentException - If the serie or sample is invalid.

setSeriesCount

public void setSeriesCount(int count)
Sets the number of series.

Parameters:
count - The number of series.

setSeriesLabel

public void setSeriesLabel(int serie,
                           java.lang.String label)
Sets the specified series label.

Parameters:
serie - The index of the serie (0-based).
label - The label of the sample.
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

setSeriesLabelColor

public void setSeriesLabelColor(int serie,
                                java.awt.Color color)
Sets the color of of the label for the specified series.

Parameters:
serie - The index of the serie (0-based).
color - The color to use, null for the default color.
Throws:
java.lang.IllegalArgumentException - if the series index is invalid.

setSeriesLabels

public void setSeriesLabels(java.lang.String[] labels)
Sets the series labels.

Parameters:
labels - The labels to use.

setSeriesLabelsOn

public void setSeriesLabelsOn(boolean on)
Turns on the floating series labels.

Parameters:
on - True for on, false for off.

setSeriesLabelStyle

public void setSeriesLabelStyle(int style)
Sets the style of the series labels. The series labels can be displayed at each sample point of the chart or floating over each sample point when the mouse moves over it.

Parameters:
style - FLOATING, INSIDE, OUTSIDE.

setSeriesRange

public void setSeriesRange(int series,
                           int range)
Sets wich range the specified series should belong to.

Parameters:
series - The index of the series.
range - The index of the range (0 or 1).

setServletModeOn

public void setServletModeOn(boolean on)
Turns on or off servlet mode. In servlet mode double buffering and label cashing is turned off.

Parameters:
on - True for servlet mode on, false for servlet mode off.

setTargetValueLine

public void setTargetValueLine(java.lang.String id,
                               double value,
                               java.awt.Color color,
                               int style)
Sets a target value line with the specified ID, value, and color.

Parameters:
id - The id of the target line.
value - The value where the line should appear.
color - The color of the line, if null, the line is removed.
style - TARGET_LINE_NO_LABEL, TARGET_LINE_ID_LABEL, TARGET_LINE_VALUE_LABEL, or TARGET_LINE_ID_AND_VALUE_LABEL.
Throws:
java.lang.IllegalArgumentException - if the style is invalid.

setThousandsDelimeter

public void setThousandsDelimeter(java.lang.String delimiter)
Sets the delimeter for use in the display of numbers. By default, the delimiter is not set, so the delimiter for the default Locale is used instead.

Parameters:
delimiter - The delimiter to set, use null for default.

setTitle

public void setTitle(java.lang.String title)
Sets the chart title. The chart title is displayed at the chart's top.

Parameters:
title - The title to set.
See Also:
getTitle(), setTitleOn(boolean)

setTitleOn

public void setTitleOn(boolean on)
Turns on or off the chart title. The chart title is displayed at the top of the chart.

Parameters:
on - True for on, false for off.
See Also:
setTitle(java.lang.String)

setValueLabelsOn

public void setValueLabelsOn(boolean on)
Turns on or off the value labels. The value labels display the value for each of the sample in the chart.

Parameters:
on - True for on, false for off.
See Also:
setSampleValue(int, int, double), setSampleValues(int, double[])

setValueLabelsOn

public void setValueLabelsOn(int serie,
                             boolean on)
Turns on or off the value labels for the specified series.

Parameters:
serie - The index of the serie (-1) for all.
on - True for on, false for off.
See Also:
setSampleValue(int, int, double), setSampleValues(int, double[])

setValueLinesColor

public void setValueLinesColor(java.awt.Color color)
Sets the color of the value lines in the chart.

Parameters:
color - The color to use.

setValueLinesOn

public void setValueLinesOn(boolean on)
Turns on or off the chart value lines. The value lines are displayed with intervals based on 1, 2, 2.5, and 5 (0.1, 0.2, 0.25, 0.5, 10, 20, 25, 50, 100, 200, 250, 500 and so on) and how many lines there is room for. You can set the maximum number of lines to be displayed with the setMaxValueLineCount.

Parameters:
on - True for on, false for off.
See Also:
setMaxValueLineCount(int)

setVisibleSamples

public void setVisibleSamples(int start,
                              int count)
Sets the visible samples in the chart. If the sample scroller is turned on and the number of samples to be displayed is less than the total number of samples, the user can scroll to the other non-visible samples by using the sample scroller. Only applicable for chart types with a grid.

Parameters:
start - The index of the start sample.
count - The number of samples to be displayed, -1 for all after start.

toString

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

Overrides:
toString in class java.awt.Component

update

public final void update(java.awt.Graphics g)
This method is overridden to avoid flicker when the chart is repainted.

Overrides:
update in class java.awt.Component