com.objectplanet.chart
Class GenericChart

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.objectplanet.chart.GenericChart
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
Chart, PlotterChart

public abstract class GenericChart
extends javax.swing.JComponent
implements java.io.Serializable

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String chartType
           
protected static java.awt.Color[] DEFAULT_SAMPLE_COLORS
           
protected  java.awt.Point depth3dPoint
           
protected  boolean display3dOn
           
protected  boolean displayVersionOn
           
protected  java.lang.String dragged_label
           
protected  Grid grid
          This contains the grid data.
protected  GridRenderer gridRenderer
          Used to paint the grid.
protected  Legend legend
          This contains the legend data.
protected  LegendRenderer legendRenderer
          Used to paint the legend.
protected  boolean[] legendSelection
           
protected  boolean needChartCalculation
           
protected  boolean needGraphBounds
           
protected  boolean needRender
           
protected  java.awt.Cursor new_cursor
           
protected  java.awt.Cursor old_cursor
           
protected  java.util.Vector overlayCharts
          This contains any overlayed charts.
protected  ChartRenderer renderer
          Used to paint the chart data and labels.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
GenericChart()
          Initializes all common chart data.
 
Method Summary
 void addImage(java.lang.String name, java.awt.Image image)
          Adds an image to the chart.
 int addOverlayChart(GenericChart chart)
          Adds a new overlay chart.
 void autoRepaint()
          Calls repaint() if the automaticRepaintOn is turned on.
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  void clearAngledLabelCache()
          Clears the chache with angle label bounds.
protected abstract  java.lang.String constructLabel(int series, int sample, int style, boolean paintSeriesOn, java.lang.String percentLabel)
          Constructs the combination of labels.
 java.awt.Image createImage_oldstyle(int width, int height)
          Uses Component.createImage() or Frame.createImage to create an offscreen image.
 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.
 java.awt.Color getAlternateChartBackground()
          Gets the alternate color of the chart background itself.
 java.awt.Color getBackground2()
          Gets the secondary background of the chart component.
 java.awt.Color getChartBackground()
          Gets the color of the chart background itself.
 java.awt.Color getChartBackground2()
          Gets the secondary background of the chart grid itself.
 java.awt.Color getChartForeground()
          Gets the color of the chart foreground itself.
 java.awt.Font getFont(java.lang.String label)
          Gets the font for the specified label.
 java.awt.Rectangle getGraphBounds()
          This method returns the bounding box for the chart grid.
 java.awt.Insets getGraphInsets()
          Gets the graph insets.
 java.lang.String getGridImage(int index)
          Gets the image that is used as background for the grid.
protected abstract  double getHighestValue(int rangeIndex)
          Gets the highest value in the chart larger than 0.
 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.
 java.lang.String getLabelAtPoint(int x, int y)
          Gets ID of the label which contains given x and y if the label has and URL assigned or if it points to any sample
 java.awt.Rectangle getLabelBounds(java.lang.String id)
          Gets bounds of the label with given id.
 java.awt.Color getLabelColor(java.lang.String id)
          Gets color of the specified label.
 java.awt.Point getLabelPosition(java.lang.String id)
          Gets position of the specified label that has been set by setLabelPosition(String id, int x, int y);
 java.awt.Color getLegendColor(int index)
          Gets legend entry's color value by it's index.
 java.awt.Color[] getLegendColors()
          Gets the legend colors.
 int getLegendColumns()
          Gets the number of columns used to display the legend labels.
 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.
 java.util.Locale getLocale()
          Gets the current locale used for numbers.
protected abstract  double getLowestValue(int rangeIndex)
          Gets the lowest value in the chart.
 java.awt.Dimension getMinimumSize()
          This method returns the minimum size of the chart.
 GenericChart getOverlayChart(int index)
          Gets the specified overlay chart.
 double getOverlayInsets(int side)
          Gets the relative distance between the chart bound's and the grid for the specified side.
 java.awt.Dimension getPreferredSize()
          This method is called by the awt, and returns the preferred size of the chart.
abstract  int getSampleCount()
          Gets the number of series.
abstract  int getSeriesCount()
          Gets the number of series.
 java.awt.Dimension getSize()
          Returns the size of the chart component.
 java.lang.String getThousandsDelimeter()
          Gets the current thousands delimiter used for formatted numbers.
 java.lang.String getTitle()
          Gets the chart title.
protected  java.awt.Rectangle getTotalGraphBounds()
          Gets the bounds of the graph including all ranges and labels but without legend.
static java.lang.String getVersion()
          Returns the current version of the charts.
protected  void handleCustomLabels(java.awt.AWTEvent event)
          Handles the custom label movement.
 boolean hasDataChangedSince(long time)
          Checks if the data has been changed since the specified time.
 boolean is3DModeOn()
          Checks if the 3D mode is turned on.
 boolean isAntialiasingOn()
          Returns true if the anti-aliasing is turned on for this chart.
 boolean isAutomaticRepaintOn()
          * Checks if the automatic repaint is on.
 boolean isFloatingOnLegendOn()
          Checks if floating labels are displayed when the mouse moves over the legend.
 boolean isGridOutline3DOn()
          Checks if the 3D grid outline is turned on.
 boolean isLegendOn()
          Checks if the legend is turned on.
 boolean isLegendReverseOn()
          Returns true if the inverted legend is on.
 boolean isMultiSeriesOn()
          Checks if the multiseries mode is 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 isSampleHighlightOn(int series)
          Checks if the sample highlight is turned on or off for the series.
abstract  boolean isSeriesEmpty(int index)
          Checks if the series contains any data.
 boolean isServletModeOn()
          Checks if the servlet mode is turned on.
 boolean isTitleOn()
          Checks if the title is turned on.
 boolean isZoomOn()
          Checks if zoom is turned on.
 java.awt.Image loadImage(java.lang.String name)
          Loads an image from the disk.
 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 event)
          Handles the chart events.
 void removeExternalGraphics()
          Removes external graphics context if there is one.
 void removeOverlayChart(int index)
          Removes the specified overlay chart.
 void render(java.awt.Graphics g)
          Renders the chart according to the current chart attributes and which charts features are turned on or off.
protected  void render(java.awt.Graphics g, boolean offscreenOn)
          Renders the chart according to the set attributes, the current features that are turned on and GUI state values.
protected  void renderOffScreen(java.awt.Graphics g)
          A subclass should override this method to paint on top of the chart before it is painted to the AWT component.
 void reset()
          Resets the chart data and features.
 void set3DModeOn(boolean on)
          Turns on or off 3D look of the chart.
 void setAlternateChartBackground(java.awt.Color color)
          Sets the alternate background color of the chart.
 void setAntialiasingOn(boolean on)
          Turns on the anti-aliasing feature for this 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 setBackground2(java.awt.Color color)
          Sets the secondary chart component background color, outside the chart grid.
 void setChartBackground(java.awt.Color color)
          Sets the background color of the chart itself.
 void setChartBackground2(java.awt.Color color)
          Sets the secondary background color of the chart itself.
 void setChartForeground(java.awt.Color color)
          Sets the foreground color of the chart itself.
 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 setGridImage(java.lang.String name)
          Sets an image to be used as background for the chart grid.
 void setGridOutline3DOn(boolean on)
          Turns on the 3D grid outline.
 void setLabel(java.lang.String name, java.lang.String label)
          Sets the specified label in the chart.
 void setLabel(java.lang.String id, java.lang.String text, double x, double y)
          Sets a label to any point on the chart.
 void setLabel(java.lang.String id, java.lang.String text, double x, double y, int serie, int sample)
          Sets a label to any point on the chart.
 void setLabel(java.lang.String id, java.lang.String text, int x, int y)
          Sets a label to any point on the chart.
 void setLabel(java.lang.String id, java.lang.String text, int x, int y, int serie, int sample)
          Sets a label to any point on 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 setLabelColor(java.lang.String id, java.awt.Color color)
          Sets color for the specified label.
 void setLabelPosition(java.lang.String id, double x, double y)
          Sets position for the specified label.
 void setLabelPosition(java.lang.String id, int x, int y)
          Sets position for a specified label.
 void setLabelURL(java.lang.String id, java.lang.String adress)
          Sets the url for any label.
 void setLegendColor(int index, java.awt.Color color)
          Sets a legend entry color.
 void setLegendColors(java.awt.Color[] colors)
          Sets the legend colors.
 void setLegendColumns(int columns)
          Sets the number of columns that should be used to display legend labels.
 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 setLegendReverseOn(boolean on)
          Set on or off the inverted legend.
 void setLocale(java.util.Locale locale)
          Sets the locale used to format numbers.
 void setMultiSeriesOn(boolean on)
          Make the chart behave like it has multiple series even if it has only one.
protected  void setNeedChartCalculation(boolean state)
          Sets the needChartCalculation to true for this chart and it's overlays.
 void setOverlayChart(int index, GenericChart chart)
          Sets the specified overlay chart.
 void setOverlayChartOn(int index, boolean on)
          Sets the specified overlay chart on or off.
 void setOverlayInsets(double top, double left, double bottom, double right)
          Sets the relative distance between this chart's bounds and the grid.
 void setPreferredSize(int width, int height)
          Sets the preferred size of the chart.
 void setPrintAsBitmap(boolean on)
          Turns on printing as bimap.
abstract  void setSelection(int serie, int sample, boolean selected, boolean clear, boolean notify)
          Marks a sample as selected or deselected.
 void setServletModeOn(boolean on)
          Turns on or off servlet mode.
 void setThousandsDelimiter(java.lang.String delimiter)
          Sets the delimiter 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 setZoomOn(boolean on)
          Turns zoom on or off.
 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 javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

chartType

protected java.lang.String chartType

DEFAULT_SAMPLE_COLORS

protected static java.awt.Color[] DEFAULT_SAMPLE_COLORS

depth3dPoint

protected java.awt.Point depth3dPoint

display3dOn

protected boolean display3dOn

displayVersionOn

protected boolean displayVersionOn

dragged_label

protected java.lang.String dragged_label

grid

protected Grid grid
This contains the grid data.


gridRenderer

protected GridRenderer gridRenderer
Used to paint the grid.


legend

protected Legend legend
This contains the legend data.


legendRenderer

protected LegendRenderer legendRenderer
Used to paint the legend.


legendSelection

protected boolean[] legendSelection

needChartCalculation

protected boolean needChartCalculation

needGraphBounds

protected boolean needGraphBounds

needRender

protected boolean needRender

new_cursor

protected java.awt.Cursor new_cursor

old_cursor

protected java.awt.Cursor old_cursor

overlayCharts

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


renderer

protected ChartRenderer renderer
Used to paint the chart data and labels.

Constructor Detail

GenericChart

public GenericChart()
Initializes all common chart data.

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.

addOverlayChart

public int addOverlayChart(GenericChart 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.

autoRepaint

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


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.


clearAngledLabelCache

protected void clearAngledLabelCache()
Clears the chache with angle label bounds.


constructLabel

protected abstract java.lang.String constructLabel(int series,
                                                   int sample,
                                                   int style,
                                                   boolean paintSeriesOn,
                                                   java.lang.String percentLabel)
Constructs the combination of labels.

Parameters:
series - The series index.
sample - The sample index.
style - The style of the label: INSIDE, OUTSIDE, FLOATING or POINTING.
paintSeriesOn - True if the series label should be on.
percentLabel - A percent label for pie chart.
Returns:
The constructed label.

createImage_oldstyle

public java.awt.Image createImage_oldstyle(int width,
                                           int height)
Uses Component.createImage() or Frame.createImage to create an offscreen image.

Parameters:
width - The width of the image in pixels.
height - The height of the image in pixels.

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.

getAlternateChartBackground

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


getBackground2

public java.awt.Color getBackground2()
Gets the secondary background of the chart component.


getChartBackground

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


getChartBackground2

public java.awt.Color getChartBackground2()
Gets the secondary background of the chart grid itself.


getChartForeground

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


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 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)

getGridImage

public java.lang.String getGridImage(int index)
Gets the image that is used as background for the grid.

Returns:
The name of the image, or null if there is no grid image.

getHighestValue

protected abstract double getHighestValue(int rangeIndex)
Gets the highest value in the chart larger than 0. It also takes into account any overlay charts with grids (bar and line).

Parameters:
rangeIndex - The index of the range (0 or 1).
Returns:
The highest value or 0 if none are larger than 0.

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)

getLabelAtPoint

public java.lang.String getLabelAtPoint(int x,
                                        int y)
Gets ID of the label which contains given x and y if the label has and URL assigned or if it points to any sample

Parameters:
x - The x coordinate.
y - The y coordinate.
Returns:
ID of the label at the given point if it has and URL assigned or if it points to any sample.

getLabelBounds

public java.awt.Rectangle getLabelBounds(java.lang.String id)
Gets bounds of the label with given id.

Parameters:
id - ID of the given label.
Returns:
Bounding rectangle of this label.

getLabelColor

public java.awt.Color getLabelColor(java.lang.String id)
Gets color of the specified label.

Parameters:
id - The label id.
Returns:
Color of the label.

getLabelPosition

public java.awt.Point getLabelPosition(java.lang.String id)
Gets position of the specified label that has been set by setLabelPosition(String id, int x, int y);

Parameters:
id - The label id.
Returns:
Position of the label represented by the Point object.

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.

getLegendColumns

public int getLegendColumns()
Gets the number of columns used to display the legend labels.

Returns:
Number of legend columns.

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.

getLocale

public java.util.Locale getLocale()
Gets the current locale used for numbers.

Overrides:
getLocale in class java.awt.Component

getLowestValue

protected abstract double getLowestValue(int rangeIndex)
Gets the lowest value in the chart. Used when setting the relative range. It also takes into account any overlay charts with grids (bar and line).

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

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 javax.swing.JComponent

getOverlayChart

public GenericChart getOverlayChart(int index)
Gets the specified overlay chart.

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

getOverlayInsets

public double getOverlayInsets(int side)
Gets the relative distance between the chart bound's and the grid for the specified side.

Parameters:
side - Chart.TOP, Chart.LEFT, Chart.BOTTOM, Chart.RIGHT.
Returns:
A double value between 0 and 1 where 0 means no offset, and 1 means offset with size of the grid's height or width.

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 javax.swing.JComponent

getSampleCount

public abstract int getSampleCount()
Gets the number of series.


getSeriesCount

public abstract int getSeriesCount()
Gets the number of series.


getSize

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

Overrides:
getSize in class java.awt.Component

getThousandsDelimeter

public java.lang.String getThousandsDelimeter()
Gets the current thousands delimiter used for formatted 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)

getTotalGraphBounds

protected java.awt.Rectangle getTotalGraphBounds()
Gets the bounds of the graph including all ranges and labels but without legend.

Returns:
Bounds of the graph with ranges.

getVersion

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


handleCustomLabels

protected void handleCustomLabels(java.awt.AWTEvent event)
Handles the custom label movement.


hasDataChangedSince

public boolean hasDataChangedSince(long time)
Checks if the data has been changed since the specified time.

Parameters:
time - The time to check for.
Returns:
True if the data has changed, false otherwise.

is3DModeOn

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

Returns:
True for on, false for off.

isAntialiasingOn

public boolean isAntialiasingOn()
Returns true if the anti-aliasing is turned on for this chart.

Returns:
True if the anti-aliasing is turned on for this chart, false otherwise.

isAutomaticRepaintOn

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

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

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)

isGridOutline3DOn

public boolean isGridOutline3DOn()
Checks if the 3D grid outline is turned on.

Returns:
True if the 3D grid outline is turned on.

isLegendOn

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

Returns:
True for on, false for off.

isLegendReverseOn

public boolean isLegendReverseOn()
Returns true if the inverted legend is on.

Returns:
Number of legend columns.

isMultiSeriesOn

public boolean isMultiSeriesOn()
Checks if the multiseries mode is on.

Returns:
True if on, false if not.

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.

isSampleHighlightOn

public boolean isSampleHighlightOn(int series)
Checks if the sample highlight is turned on or off for the series.

Parameters:
series - The data series.
Returns:
True if on, false if off.
Throws:
java.lang.IllegalArgumentException - if the series or sample is invalid.

isSeriesEmpty

public abstract boolean isSeriesEmpty(int index)
Checks if the series contains any data.

Parameters:
index - The series index.
Returns:
True if the series is emty (does not contain any data).

isServletModeOn

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

Returns:
True for on, false for off.

isTitleOn

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

Returns:
True if on, false if off.

isZoomOn

public boolean isZoomOn()
Checks if zoom is turned on.

Returns:
True if turned on, false otherwise.

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.

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 javax.swing.JComponent

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 javax.swing.JComponent

processEvent

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

Overrides:
processEvent in class java.awt.Container
Parameters:
event - The event to process.

removeExternalGraphics

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

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

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

public void render(java.awt.Graphics g)
Renders the chart according to the current chart attributes and which charts features are turned on or off.


render

protected void render(java.awt.Graphics g,
                      boolean offscreenOn)
Renders the chart according to the set attributes, the current features that are turned on and GUI state values.


renderOffScreen

protected void renderOffScreen(java.awt.Graphics g)
A subclass should override this method to paint on top of the chart before it is painted to the AWT component. This is done to avoid flicker of graphics painted by these subclasses.

Parameters:
g - The graphics context used to paint with.

reset

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


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.

setAlternateChartBackground

public void setAlternateChartBackground(java.awt.Color color)
Sets the alternate background color of the chart. If not null it is used along with the primary chart background color alternating by the value lines.

Parameters:
color - The color to use.

setAntialiasingOn

public void setAntialiasingOn(boolean on)
Turns on the anti-aliasing feature for this chart.

Parameters:
on - If true the anti-aliasing is turned on.

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 javax.swing.JComponent
Parameters:
color - The color to use.
See Also:
setChartBackground(java.awt.Color)

setBackground2

public void setBackground2(java.awt.Color color)
Sets the secondary chart component background color, outside the chart grid. the secondary background can be used in order to display gradient background. Use the setChartBackground() method to set the chart grid color.

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.

setChartBackground2

public void setChartBackground2(java.awt.Color color)
Sets the secondary background color of the chart itself. The secondary background can be used in order to display gradient chart grid background.

Parameters:
color - The color to use.

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.

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 javax.swing.JComponent
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.

setGridImage

public void setGridImage(java.lang.String name)
Sets an image to be used as background for the chart grid. The image itself must be added prior to calling this method using the addImage() method.

Parameters:
name - The image to use, null if you want to remove grid image.
See Also:
addImage(java.lang.String, java.awt.Image)

setGridOutline3DOn

public void setGridOutline3DOn(boolean on)
Turns on the 3D grid outline.

Parameters:
on - True for 3D grid outline.

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.

setLabel

public void setLabel(java.lang.String id,
                     java.lang.String text,
                     double x,
                     double y)
Sets a label to any point on the chart. The method takes relative coordinates of the label. Position of the label can be from 0 to 1.

Parameters:
id - The label id.
text - The label text.
x - The relative horizontal position of the label.
y - The relative vertical position of the label.

setLabel

public void setLabel(java.lang.String id,
                     java.lang.String text,
                     double x,
                     double y,
                     int serie,
                     int sample)
Sets a label to any point on the chart. The method takes relative coordinates of the label. Position of the label can be from 0 to 1.

Parameters:
id - The label id.
text - The label text.
x - The relative horizontal position of the label.
y - The relative vertical position of the label.
serie - The serie if the sample, label should point to.
sample - The index of the sample, label should point to.

setLabel

public void setLabel(java.lang.String id,
                     java.lang.String text,
                     int x,
                     int y)
Sets a label to any point on the chart. The method takes absolute coordinates of the label in pixels.

Parameters:
id - The label id.
text - The label text.
x - The x coordinate of the label.
y - The y coordinate of the label.

setLabel

public void setLabel(java.lang.String id,
                     java.lang.String text,
                     int x,
                     int y,
                     int serie,
                     int sample)
Sets a label to any point on the chart. The method takes absolute coordinates of the label in pixels.

Parameters:
id - The label id.
text - The label text.
x - The x coordinate of the label.
y - The y coordinate of the label.
serie - The serie if the sample, label should point to.
sample - The index of the sample, label should point to.

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.

setLabelColor

public void setLabelColor(java.lang.String id,
                          java.awt.Color color)
Sets color for the specified label.

Parameters:
id - The label id.
color - The color of the label.

setLabelPosition

public void setLabelPosition(java.lang.String id,
                             double x,
                             double y)
Sets position for the specified label. The method takes relative coordinates of the label. Position of the label can be from 0 to 1.

Parameters:
id - The label id.
x - The x coordinate of the label.
y - The y coordinate of the label.

setLabelPosition

public void setLabelPosition(java.lang.String id,
                             int x,
                             int y)
Sets position for a specified label. The method takes absolute coordinates of the label in pixels.

Parameters:
id - The label id.
x - The x coordinate of the label.
y - The y coordinate of the label.

setLabelURL

public void setLabelURL(java.lang.String id,
                        java.lang.String adress)
Sets the url for any label.

Parameters:
id - The label id.
adress - The URL string for the label.

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:
setLegendColors(java.awt.Color[]), setLegendImage(int, java.lang.String)

setLegendColumns

public void setLegendColumns(int columns)
Sets the number of columns that should be used to display legend labels.

Parameters:
columns - Number of columns to display legends on. If columns is set to 0, the default legend rendering is used.

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.

setLegendReverseOn

public void setLegendReverseOn(boolean on)
Set on or off the inverted legend. Default legend entry order is from top to bottom and from left to right.

Parameters:
on - If true the legend entryes are displayed from bottom to top and from right to left.

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale used to format numbers.

Overrides:
setLocale in class java.awt.Component
Parameters:
locale - The locale to use, null for the default locale.

setMultiSeriesOn

public void setMultiSeriesOn(boolean on)
Make the chart behave like it has multiple series even if it has only one.

Parameters:
on - True if the multiseries mode is on, false if off.

setNeedChartCalculation

protected void setNeedChartCalculation(boolean state)
Sets the needChartCalculation to true for this chart and it's overlays.

Parameters:
state - True if the chart data position should be recalculated for the next render.

setOverlayChart

public void setOverlayChart(int index,
                            GenericChart 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).

setOverlayInsets

public void setOverlayInsets(double top,
                             double left,
                             double bottom,
                             double right)
Sets the relative distance between this chart's bounds and the grid. This can be used to manually set bounds for the overlay charts. The values should be between 0 and 1 where 0 means no offset, and 1 means offset with size of the grid's height or width.

Parameters:
top - The relative distance from the grid top.
left - The relative distance from the grid left edge.
bottom - The relative distance from the grid bottom.
right - The relative distance from the grid right edge.

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.

setSelection

public abstract void setSelection(int serie,
                                  int sample,
                                  boolean selected,
                                  boolean clear,
                                  boolean notify)
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.
clear - True if the other samples should be cleared.
notify - True if the listeners should be notified.
Throws:
java.lang.IllegalArgumentException - If the serie or sample is invalid.

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.

setThousandsDelimiter

public void setThousandsDelimiter(java.lang.String delimiter)
Sets the delimiter 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, or off for no thousands grouping.

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)

setZoomOn

public void setZoomOn(boolean on)
Turns zoom on or off. When this is on, the user can zoom the chart by using mouse box. This is only applicable for chart types with grids.

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

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 javax.swing.JComponent