com.objectplanet.chart
Class Chart

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

public abstract class Chart
extends GenericChart
implements java.awt.ItemSelectable

This class is the abstract superclass of all charts.

Author:
Bjorn J. Kvande.
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
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  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.
static int POINTING
          Lines point to the corresponding slices.
static int RIGHT
          Right legend position.
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 com.objectplanet.chart.GenericChart
chartType, DEFAULT_SAMPLE_COLORS, depth3dPoint, display3dOn, displayVersionOn, dragged_label, grid, gridRenderer, legend, legendRenderer, legendSelection, needChartCalculation, needGraphBounds, needRender, new_cursor, old_cursor, overlayCharts, renderer
 
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
Chart()
           
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 addItemListener(java.awt.event.ItemListener l)
          Adds an item listener to the chart.
 int appendSample(int serie, 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.
protected  void calculateChartData(java.awt.Rectangle gridBounds, java.awt.Rectangle dataBounds)
          Calculates the position and size of each bar in 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  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.
protected  java.lang.String constructLabel(int series, int sample, int style, boolean paintSeriesOn, java.lang.String percentLabel)
          Constructs the combination of labels.
 void displayFloatingLabel(int serie, int sample)
          Displays the floating labels for the specified series and/or sample.
 java.lang.String formatRangeNumber(int index, double value)
          Formats a floating number to the number of decimals given for the specified range.
 java.lang.String formatSeriesNumber(int index, double value)
          Formats a floating number to the number of decimals given for the specified series.
 int get3DDepth()
          Gets the depth of the 3D effect.
static java.util.Hashtable getAngledLabelCache()
          Getter for the angledLabelCache where the angled labels are stored.
 ChartData getChartData()
          Gets the chart data for this chart.
 double getCurrentLowerRange(int range)
          Gets the current lower range of the specified range.
 double getCurrentRange(int range)
          Gets the current upper range of the specified range.
 java.awt.Rectangle getDataBounds(java.awt.Rectangle gridBounds)
          This method returns the bounding box for the data to be drawn in.
 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.
protected  double getHighestValue(int rangeIndex)
          Gets the highest value in the chart larger than 0.
 java.awt.Dimension getLabelSize(java.lang.String label, java.awt.FontMetrics fm)
          Calculates the size of a multiline 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.lang.String[] getLegendLabels()
          Gets the legend labels.
 double getLowerRange(int index)
          Gets the lower value of the specified range.
protected  double getLowestValue(int rangeIndex)
          Gets the lowest value in the chart.
 double getMaxValue(int serie)
          Gets the largest value in the specified data series.
 int getMaxValueLineCount()
          Gets the current maxium number of value lines set.
 double getMinValue(int serie)
          Gets the smallest value in the specified data series.
 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()
          Gets the position of the first range adjuster.
 java.awt.Color getRangeColor(int index)
          Gets the color of the specified range.
 int getRangeCount()
           
 int getRangeDecimalCount(int index)
          Gets the number of decimals used in the range values.
 java.text.NumberFormat getRangeFormatter(int index)
          Get the number formatter of this range.
 double getRangeInterval(int range)
          Gets the interval between the ticks on the specified range.
 int getRangePosition(int index)
          Gets the range position.
 ChartSample getSample(int serie, int index)
          Gets the specified sample.
 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 getSampleColor2(int index)
          Gets the color of the specified sample.
 java.awt.Color[] getSampleColors()
          Gets the array of colors used for the samples.
 java.awt.Color[] getSampleColors2()
          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.
 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.text.NumberFormat getSeriesFormatter(int index)
          Get the number formatter of this 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.
static java.lang.String[] getStringValues(java.lang.String string, java.lang.String delimiter)
          Conterts a separated string to an array of string.
 int getTargetLabelsPosition()
          Gets the target labels position
 double getTargetValueLine(java.lang.String id)
          Gets the value of a target value line.
 java.awt.Color getValueLabelColor(int serie)
          Gets the color of the value labels of the specified series.
 int getValueLabelStyle()
          Gets the value label style.
 java.awt.Color getValueLinesColor()
          Gets the color of the value lines.
 int[] getVisibleSamples()
          Gets the visible samples in the chart.
 boolean hasDataChangedSince(long time)
          Checks if the data has been changed since the specified time.
static int hashCode(java.lang.String s)
          Returns a hashcode for the specified string.
 boolean isDefaultGridLinesOn()
          Checks if the default vertical grid lines are on.
 boolean isGridAdjustmentOn(int edge)
          Checks if runtime grid adjustment is on.
 boolean isLegendBoxSizeAsFont()
          Check if the legend box size should be the same as the legend font size.
 boolean isRangeAdjusterOn(int adjuster)
          Checks if the specified range adjuster is turned on.
 boolean isRangeLabelsOn(int index)
          Checks if the range labels are on or off.
 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 isSeriesEmpty(int index)
          Checks if the series contains any data.
 boolean isSeriesLabelsOn()
          Checks if the floating series labels 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.
static void main(java.lang.String[] argv)
          Prints out the current version number.
protected  void paintGrid(java.awt.Graphics g, java.awt.Rectangle gridBounds)
          Paints the chart grid.
protected  void processEvent(java.awt.AWTEvent event)
          Handles the chart events.
 void removeItemListener(java.awt.event.ItemListener l)
          Removes the specified item listener from the chart.
protected  void renderData(java.awt.Graphics g, java.awt.Rectangle gridBounds, java.awt.Rectangle dataBounds)
          Renders the bars and the value labels.
 void reset()
          Resets the chart data and features.
 void set3DDepth(int depth)
          Sets the depth of the 3D effect in number of pixels.
 void setChartData(ChartData chartData)
          Lets the chart use the specified chart data.
 void setCurrentLowerRange(int range, double lower)
          Sets the current lower range of the specified range.
 void setCurrentRange(int range, double upper)
          Sets the current upper range of the specified range.
 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 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[] lines)
          Sets the vertical grid lines positons.
 void setGridLinesColor(java.awt.Color color)
          Sets the vertical grid lines color.
 void setLegendBoxSizeAsFont(boolean on)
          If set to true the legend box size is set to the same size as the legend font.
 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 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 position)
          Sets the position of the first 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 setRangeFormatter(int index, java.text.NumberFormat formatter)
          Sets a number formatter for the specific range.
 void setRangeInterval(int range, double interval)
          Sets interval between the ticks on the specified range.
 void setRangeLabelsOn(int index, boolean on)
          Turns on or off the range value labels for 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, 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 setSampleColor2(int index, java.awt.Color color)
          Sets the color of the specified sample.
 void setSampleColors(java.awt.Color[] colors)
          Sets the sample colors.
 void setSampleColors2(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.
 void setSampleLabelStyle(int style)
          Sets the style of the sample labels.
 void setSamples(int serie, 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 setSelection(int serie, int sample, boolean selected, boolean clear, boolean notify)
          Marks a sample as selected or deselected.
 void setSeriesCount(int count)
          Sets the number of series.
 void setSeriesFormatter(int index, java.text.NumberFormat formatter)
          Sets a number formatter for the specific 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 setTargetLabelsPosition(int position)
          Sets the target labels position.
 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 setTargetValueLine(java.lang.String id, double value, java.awt.Color color, int style, int range)
          Sets a target value line with the specified ID, value, and color.
 void setValueLabelColor(int serie, java.awt.Color color)
          Sets the color of the value labels for the specified series.
 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 setValueLabelStyle(int style)
          Sets the style of the value labels.
 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.
 void setVisibleSamples(int start, int count, boolean adjustScrollers)
          Sets the visible samples in the chart.
 
Methods inherited from class com.objectplanet.chart.GenericChart
addImage, addOverlayChart, autoRepaint, clearAngledLabelCache, createImage_oldstyle, createImage, forceRepaint, formatNumber, getAlternateChartBackground, getBackground2, getChartBackground, getChartBackground2, getChartForeground, getFont, getGraphBounds, getGraphInsets, getGridImage, getImage, getImage, getLabel, getLabelAngle, getLabelAtPoint, getLabelBounds, getLabelColor, getLabelPosition, getLegendColors, getLegendColumns, getLegendImage, getLegendPosition, getLocale, getMinimumSize, getOverlayChart, getOverlayInsets, getPreferredSize, getSize, getThousandsDelimeter, getTitle, getTotalGraphBounds, getVersion, handleCustomLabels, is3DModeOn, isAntialiasingOn, isAutomaticRepaintOn, isFloatingOnLegendOn, isGridOutline3DOn, isLegendOn, isLegendReverseOn, isMultiSeriesOn, isOverlayChartOn, isPrintAsBitmap, isSampleHighlightOn, isServletModeOn, isTitleOn, isZoomOn, loadImage, paint, print, removeExternalGraphics, removeOverlayChart, render, render, renderOffScreen, set3DModeOn, setAlternateChartBackground, setAntialiasingOn, setAutomaticRepaintOn, setBackground, setBackground2, setChartBackground, setChartBackground2, setChartForeground, setExternalGraphics, setFloatingOnLegendOn, setFont, setForeground, setGraphInsets, setGridImage, setGridOutline3DOn, setLabel, setLabel, setLabel, setLabel, setLabel, setLabelAngle, setLabelAngleCacheSize, setLabelColor, setLabelPosition, setLabelPosition, setLabelURL, setLegendColor, setLegendColors, setLegendColumns, setLegendImage, setLegendLabels, setLegendOn, setLegendPosition, setLegendReverseOn, setLocale, setMultiSeriesOn, setNeedChartCalculation, setOverlayChart, setOverlayChartOn, setOverlayInsets, setPreferredSize, setPrintAsBitmap, setServletModeOn, setThousandsDelimiter, setTitle, setTitleOn, setZoomOn, toString, update
 
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

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

POINTING

public static final int POINTING
Lines point to the corresponding slices.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Right legend position.

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

Chart

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

Parameters:
count - The number of samples for the chart.

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

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)

appendSample

public int appendSample(int serie,
                        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.

calculateChartData

protected void calculateChartData(java.awt.Rectangle gridBounds,
                                  java.awt.Rectangle dataBounds)
Calculates the position and size of each bar in the chart.

Parameters:
gridBounds - The chart grid bounds.
dataBounds - The data bounds.

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

Overrides:
checkDataIntegrity in class GenericChart

checkSelection

protected 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.

constructLabel

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

Specified by:
constructLabel in class GenericChart
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.

displayFloatingLabel

public void displayFloatingLabel(int serie,
                                 int sample)
Displays the floating labels for the specified series and/or sample.

Parameters:
serie - The series index, -1 for no floating labels.
sample - The sample index, -1 for all the samples in a serie.

formatRangeNumber

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

Parameters:
index - The range index.
value - The value to format.
Returns:
A string with the formatted number.

formatSeriesNumber

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

Parameters:
index - The series index.
value - The value to format.
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)

getAngledLabelCache

public static java.util.Hashtable getAngledLabelCache()
Getter for the angledLabelCache where the angled labels are stored. Used by the PlotterChart. Nomally should not be used by the outer code.

Returns:
The angled labels hashtable.

getChartData

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


getCurrentLowerRange

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

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

getCurrentRange

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

Parameters:
range - The index of the range
See Also:
setCurrentRange(int, double)

getDataBounds

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

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

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.

getHighestValue

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

Specified by:
getHighestValue in class GenericChart
Parameters:
rangeIndex - The index of the range (0 or 1).
Returns:
The highest value or 0 if none are larger than 0.

getLabelSize

public java.awt.Dimension getLabelSize(java.lang.String label,
                                       java.awt.FontMetrics fm)
Calculates the size of a multiline label. If the label is empty, the size of the font is returned.

Parameters:
label - The label to check the size of.
fm - The font metrics used to measure labels with.
Returns:
The size.

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.

Overrides:
getLegendColor in class GenericChart
Parameters:
index - The index of the legend entry to get color from.
Returns:
Color of the given legend entry.

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.

Overrides:
getLegendLabels in class GenericChart
Returns:
An array containing the labels.
See Also:
GenericChart.setLegendLabels(java.lang.String[])

getLowerRange

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

Parameters:
index - The index of the range.

getLowestValue

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

Specified by:
getLowestValue in class GenericChart
Parameters:
rangeIndex - The index of the range (0 or 1)

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)

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

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.
Returns:
The index of range adjusted by this adjuster, -1 = all ranges.

getRangeAdjusterPosition

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

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

getRangeCount

public int getRangeCount()

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

getRangeFormatter

public java.text.NumberFormat getRangeFormatter(int index)
Get the number formatter of this range.

Parameters:
index - The index of the range.
Returns:
The number formatter.

getRangeInterval

public double getRangeInterval(int range)
Gets the interval between the ticks on the specified range.

Parameters:
range - The index of the range.
Returns:
Interval between the range ticks.

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

getSampleColor2

public java.awt.Color getSampleColor2(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.

getSampleColors2

public java.awt.Color[] getSampleColors2()
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.

Specified by:
getSampleCount in class GenericChart

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.

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

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

Specified by:
getSeriesCount in class GenericChart

getSeriesFormatter

public java.text.NumberFormat getSeriesFormatter(int index)
Get the number formatter of this series.

Parameters:
index - The index of the series.
Returns:
The number formatter.

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.

getStringValues

public static java.lang.String[] getStringValues(java.lang.String string,
                                                 java.lang.String delimiter)
Conterts a separated string to an array of string. This method is used for multiline labels and by the applet to read applet parameters.

Parameters:
string - The delimited string.
delimiter - The delimiter.
Returns:
The lines as an array of strings, or null if no label.

getTargetLabelsPosition

public int getTargetLabelsPosition()
Gets the target labels position

Returns:
0 for left, 1 for right, -1 - the target labels are displayed on the same side as the range with index 0.

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.

getValueLabelColor

public java.awt.Color getValueLabelColor(int serie)
Gets the color of the value labels 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.

getValueLabelStyle

public int getValueLabelStyle()
Gets the value label style.

See Also:
setValueLabelStyle(int)

getValueLinesColor

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


getVisibleSamples

public int[] getVisibleSamples()
Gets the visible samples in the chart.

Returns:
count Array of two elemets where the 0-element is the index if the first visible sample and the 1-element is the number if the visible samples.

hasDataChangedSince

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

Overrides:
hasDataChangedSince in class GenericChart
Parameters:
time - The time to check for.
Returns:
True if the data has changed, false otherwise.

hashCode

public static int hashCode(java.lang.String s)
Returns a hashcode for the specified string.

Parameters:
s - The string to calculate hash code for.
Returns:
a hash code value for the specified string.

isDefaultGridLinesOn

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

Returns:
True if on, false if off.

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.

isLegendBoxSizeAsFont

public boolean isLegendBoxSizeAsFont()
Check if the legend box size should be the same as the legend font size.

Returns:
True if the legend box size should be the same as the legend font size.

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 index)
Checks if the range labels are on or off.

Parameters:
index - 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.

isSeriesEmpty

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

Specified by:
isSeriesEmpty in class GenericChart
Parameters:
index - The series index.
Returns:
True if the series is emty (does not contain any data).

isSeriesLabelsOn

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

Returns:
True for on, false for 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.

main

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


paintGrid

protected void paintGrid(java.awt.Graphics g,
                         java.awt.Rectangle gridBounds)
Paints the chart grid.

Parameters:
g - The graphics context used to paint with.
gridBounds - The chart grid bounds.

processEvent

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

Overrides:
processEvent in class GenericChart
Parameters:
event - The event to process.

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)

renderData

protected void renderData(java.awt.Graphics g,
                          java.awt.Rectangle gridBounds,
                          java.awt.Rectangle dataBounds)
Renders the bars and the value labels.

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

reset

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

Overrides:
reset in class GenericChart

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.

setChartData

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

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

setCurrentLowerRange

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

Parameters:
range - The index of the range .
lower - The range to use, larger or equal to the lower range.

setCurrentRange

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

Parameters:
range - The index of the range
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[])

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[] lines)
Sets the vertical grid lines positons. The grid values are relative to the sample axis range (default 0 to 100).

Parameters:
lines - 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.

setLegendBoxSizeAsFont

public void setLegendBoxSizeAsFont(boolean on)
If set to true the legend box size is set to the same size as the legend font.

Parameters:
on - True or false

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.

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 - The range to be adjusted. -1 = all 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 position)
Sets the position of the first range adjuster. Per default the adjuster is set to opposite to the range side If there is only one range, else to the same side as the range.

Parameters:
position - 0 for left, 1 for 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.

setRangeFormatter

public void setRangeFormatter(int index,
                              java.text.NumberFormat formatter)
Sets a number formatter for the specific range.

Parameters:
index - The index of the range.
formatter - The number formatter to set.

setRangeInterval

public void setRangeInterval(int range,
                             double interval)
Sets interval between the ticks on the specified range.

Parameters:
range - The index of the range.
interval - The interval between the to range ticks.

setRangeLabelsOn

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

Parameters:
index - The index of the range to turn on/off the labels for. If index == -1, the property is set for all ranges.
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,
                      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.

setSampleColor2

public void setSampleColor2(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.

setSampleColors2

public void setSampleColors2(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. The sample labels 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. The sample labels can also be displayed as a tooltip like label when the mouse is over the sample or statically at the sample.

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

setSamples

public void setSamples(int serie,
                       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.

setSelection

public 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.

Specified by:
setSelection in class GenericChart
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.

setSeriesCount

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

Parameters:
count - The number of series.

setSeriesFormatter

public void setSeriesFormatter(int index,
                               java.text.NumberFormat formatter)
Sets a number formatter for the specific series.

Parameters:
index - The index of the series.
formatter - The number formatter to set.

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, POINTING.

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.

setTargetLabelsPosition

public void setTargetLabelsPosition(int position)
Sets the target labels position.

Parameters:
position - 0 for left, 1 for right, -1 - the target labels will be displayed on the same side as the range with index 0.

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.

setTargetValueLine

public void setTargetValueLine(java.lang.String id,
                               double value,
                               java.awt.Color color,
                               int style,
                               int range)
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.
range - The range where the label will appear, and the value line is related to.
Throws:
java.lang.IllegalArgumentException - if the style is invalid.

setValueLabelColor

public void setValueLabelColor(int serie,
                               java.awt.Color color)
Sets the color of the value labels 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.

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

setValueLabelStyle

public void setValueLabelStyle(int style)
Sets the style of the value labels. By default, the sample labels are displayed below the chart grid for each sample. The sample labels can also be displayed as a tooltip like label when the mouse is over the sample or statically at the sample.

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

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. Always adjusts scroller to the visible samples.

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

setVisibleSamples

public void setVisibleSamples(int start,
                              int count,
                              boolean adjustScrollers)
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.
adjustScrollers - True if the scroller should be adjusted according to the visible samples.