com.objectplanet.chart
Class Chart

java.lang.Object
  extended byjava.awt.Component
      extended bycom.objectplanet.chart.GenericChart
          extended bycom.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 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 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.
 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 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 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 java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BELOW

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

See Also:
Constant Field Values

BELOW_AND_FLOATING

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

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Bottom legend position.

See Also:
Constant Field Values

chartData

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

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