com.objectplanet.chart
Class LineChart

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
                      extended by com.objectplanet.chart.LineChart
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
SplineChart, TimeLineChart

public class LineChart
extends Chart

This line chart component enables you to add a line chart to your java applications with just a few lines of code.

A simple line chart can be created with the following code:

 LineChart chart = new LineChart();
 long[] values = new long[] {20, 10, 30, 50, 40};
 chart.setSampleValues(values);
A chart with several data series can be created with the following code:
 LineChart chart = new LineChart(4, 10, 100);
 double[] series0 = new double[] {98,23,46,89,72,36,49,87,23,64};
 double[] series1 = new double[] {80,17,92,63,98,16,53,86,52,34};
 double[] series2 = new double[] {29,83,46,93,80,72,36,42,98,36};
 double[] series3 = new double[] {45,86,90,86,54,65,98,75,44,54};
 chart.setSampleValues(0, series0);
 chart.setSampleValues(1, series1);
 chart.setSampleValues(2, series2);
 chart.setSampleValues(3, series3);

See here for a list of parameters to set for the line chart.

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 BEHIND_LINE_LAYOUT
          The 3D lines are located behind each other
static int LINE_STYLE_LINE
          Paint series as a normal line
static int LINE_STYLE_TUBE
          Paint series as a tube line
static int SAME_LEVEL_LINE_LAYOUT
          the 3D lines are located at the same level
static int SAMPLE_HIGHLIGHT_CIRCLE
          Use a circle as a sample highlighter on a line.
static int SAMPLE_HIGHLIGHT_CIRCLE_FILLED
          Use a filled circle as a sample highlighter on a line.
static int SAMPLE_HIGHLIGHT_CIRCLE_OPAQUE
          Use an opaque circle as a sample highlighter on a line.
static int SAMPLE_HIGHLIGHT_DIAMOND
          Use a diamond as a sample highlighter on a line.
static int SAMPLE_HIGHLIGHT_DIAMOND_FILLED
          Use a filled diamond as a sample highlighter on a line.
static int SAMPLE_HIGHLIGHT_DIAMOND_OPAQUE
          Use an opaque diamond as a sample highlighter on a line.
static int SAMPLE_HIGHLIGHT_SQUARE
          Use a square as a sample highlighter on a line.
static int SAMPLE_HIGHLIGHT_SQUARE_FILLED
          Use a filled square as a sample highlighter on a line.
static int SAMPLE_HIGHLIGHT_SQUARE_OPAQUE
          Use an opaque square as a sample highlighter on a line.
 
Fields inherited from class com.objectplanet.chart.Chart
BELOW, BELOW_AND_FLOATING, BOTTOM, chartData, FLOATING, HORIZONTAL, INSIDE, LEFT, OUTSIDE, POINTING, RIGHT, TARGET_LINE_ID_AND_VALUE_LABEL, TARGET_LINE_ID_LABEL, TARGET_LINE_NO_LABEL, TARGET_LINE_VALUE_LABEL, TOP, VERTICAL, visibleSamples
 
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
LineChart()
          Creates a line chart with one series, 5 samples, and a range of 0-100.
LineChart(int seriesCount, int sampleCount, double range)
          Creates a line chart with the specified number of series, the number of samples per serie, and the chart range.
LineChart(int seriesCount, int sampleCount, double range, double lowerRange)
          Creates a line chart with the specified number of series, the number of samples per serie, and the chart range.
 
Method Summary
protected  void checkDataIntegrity()
          Makes sure the linechart specific data has the same number of series and samples as the chart data has.
 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 bar or a legend label.
 int[] getArea(int index)
          Gets the area bounding lines series by it's index.
 java.awt.Color getAreaColor(int index)
          Gets areas color value by it's index.
 java.awt.Color getAreaColor2(int index)
          Gets areas secondary color color value by it's index.
protected  double getHighestValue(int range)
          Gets the highest value in the chart larger than 0.
 java.lang.String getLegendImage(int index)
          Gets a legend entry's image name.
 java.lang.String[] getLegendLabels()
          Gets the legend labels.
 double getLine3DDepth(int series)
          Gets the current 3D depth of the given series line.
 int getLine3DLayout()
          Gets the current bar type in multiple series charts.
 float[] getLineStroke(int series)
          Gets the array describing type of the current serie line.
 int getLineStyle(int series)
          Gets the style of the given series line.
 int getLineWidth(int series)
          Gets the current width of the given series line.
 double getMaxValue(int serie)
          Gets the maximum value in the chart.
 java.lang.String getSampleHighlightImage(int series, int sample)
          Gets a sample highlight image name.
 int getSampleHighlightSize(int series)
          Gets the sample highlight size.
 int getSampleHighlightStyle(int series)
          Gets the sample highlight style.
 java.awt.Point getSamplePoint(int serie, int sample)
          Gets the coordinates of the specified sample.
 int getValuePosition(double value)
          Gets the position in the chart of the specified value.
 boolean isAutoLabelSpacingOn()
          Gets the state of the automatic label spacing.
 boolean isConnectedLinesOn(int serie)
          Checks if lines with missing values are connected.
 boolean isMissingValuesInterpolated()
          Check if the missig sample values are calculated autmatically in the stacked mode
 boolean isOutlineOn(int serie)
          Checks if the bar outline is turned on or off.
 boolean isRightToLeftScrollingOn()
          Checks if the right to left scrolling is turned on.
 boolean isSampleHighlightOn(int series)
          Checks if the sample highlight is turned on or off for the series.
 boolean isSampleHighlightOn(int series, int sample)
          Checks if the sample highlight is turned on or off for a sample.
 boolean isSeriesLineOn(int serie)
          Checks if the specified line is on.
 boolean isStackedOn()
          Checks if stacked lines are turned on.
protected  void paint3DLine(java.awt.Graphics g, int x1, int y1, int x2, int y2, int y3, java.awt.Color color, boolean top, boolean right, boolean outlined)
          Paints the 3D part of a line.
protected  void paintLine(java.awt.Graphics g, int serie, java.awt.Rectangle gridBounds, java.awt.Rectangle dataBounds, java.awt.Color color, boolean selected)
          Paints the line of one series.
protected  void paintSampleHighlight(java.awt.Graphics g, int serie, int sample, int x, int y, java.awt.Color color)
          Paints the sample highlight for a point.
 void reset()
          Resets the chart data and features.
 void setArea(int index, int line1, int line2)
          Sets an area between the two line series to be filled with a specific color.
 void setAreaColor(int index, java.awt.Color color)
          Sets color for a specified area.
 void setAreaColor2(int index, java.awt.Color color)
          Sets the secondary color for a specified area.
 void setAutoLabelSpacingOn(boolean on)
          Turns on or off automatic sample label spacing.
 void setConnectedLinesOn(int serie, boolean on)
          Connects lines with missing values.
 void setLine3DDepth(int series, double depth)
          Sets the 3D depth of the specified line.
 void setLine3DLayout(int layout)
          Sets the line layout in multiple series charts in 3D mode.
 void setLineStroke(int series, float[] dash)
          Sets an array of values to use as repeating dash lengths and clear sections.
 void setLineStyle(int series, int style)
          Sets the style of the data series lines.
 void setLineWidth(int series, int width)
          Sets the width of the specified line.
 void setMissingValuesInterpolated(boolean on)
          Turns on the automatic calculation of the missing sample values in the stacked mode
 void setOutlineOn(int serie, boolean on)
          Turns on or off the line or area outline.
 void setRightToLeftScrollingOn(boolean state)
          Turns on right to left scrolling when adding new values.
 void setSampleColors(java.awt.Color[] colors)
          Sets the sample colors.
 void setSampleHighlightImage(int series, int sample, java.lang.String name)
          Sets an image to be used as a highlight for a specified sample.
 void setSampleHighlightOn(boolean on)
          Turns on or off the sample highlight for the data series.
 void setSampleHighlightOn(int series, boolean on)
          Turns on or off the sample highlight for a data series.
 void setSampleHighlightOn(int series, int sample, boolean on)
          Turns on or off the sample highlight for a sample in a data series.
 void setSampleHighlightStyle(int style, int size)
          Sets the sample highlight style for all the data series.
 void setSampleHighlightStyle(int serie, int style, int size)
          Sets the sample highlight style for the specified data series.
 void setSeriesLineOn(boolean state)
          Turns on or off the series lines.
 void setSeriesLineOn(int serie, boolean state)
          Turns on or off the specified series line.
 void setStackedOn(boolean on)
          Turns on or off stacked lines.
 
Methods inherited from class com.objectplanet.chart.Chart
addItemListener, appendSample, appendSampleLabel, appendSampleValue, calculateChartData, constructLabel, displayFloatingLabel, formatRangeNumber, formatSeriesNumber, get3DDepth, getAngledLabelCache, getChartData, getCurrentLowerRange, getCurrentRange, getDataBounds, getGridLine, getGridLineColor, getGridLineColors, getGridLines, getLabelSize, getLastSelectedSample, getLastSelectedSeries, getLegendColor, getLowerRange, getLowestValue, getMaxValueLineCount, getMinValue, getRange, getRangeAdjusted, getRangeAdjusterPosition, getRangeColor, getRangeCount, getRangeDecimalCount, getRangeFormatter, getRangeInterval, getRangePosition, getSample, getSample, getSampleColor, getSampleColor2, getSampleColors, getSampleColors2, getSampleCount, getSampleDecimalCount, getSampleLabel, getSampleLabelColor, getSampleLabels, getSampleLabelSelectionColor, getSampleLabelStyle, getSamples, getSampleValue, getSampleValues, getSelectedObjects, getSeriesCount, getSeriesFormatter, getSeriesLabel, getSeriesLabelColor, getSeriesLabels, getSeriesLabelStyle, getSeriesRange, getStringValues, getTargetLabelsPosition, getTargetValueLine, getValueLabelColor, getValueLabelStyle, getValueLinesColor, getVisibleSamples, hasDataChangedSince, hashCode, isDefaultGridLinesOn, isGridAdjustmentOn, isLegendBoxSizeAsFont, isRangeAdjusterOn, isRangeLabelsOn, isRangeOn, isSampleLabelsOn, isSampleScrollerOn, isSelected, isSeriesEmpty, isSeriesLabelsOn, isValueLabelsOn, isValueLabelsOn, isValueLinesOn, main, paintGrid, processEvent, removeItemListener, renderData, set3DDepth, setChartData, setCurrentLowerRange, setCurrentRange, setDefaultGridLinesColor, setDefaultGridLinesOn, setDefaultGridLinesOn, setGridAdjustmentOn, setGridLine, setGridLineColor, setGridLineColors, setGridLines, setGridLinesColor, setLegendBoxSizeAsFont, setLowerRange, setLowerRelativeRange, setLowerRelativeRange, setLowerRelativeRange, setMaxValueLineCount, setRange, setRangeAdjusted, setRangeAdjusterOn, setRangeAdjusterPosition, setRangeColor, setRangeDecimalCount, setRangeFormatter, setRangeInterval, setRangeLabelsOn, setRangeOn, setRangePosition, setRelativeRange, setRelativeRange, setRelativeRange, setSample, setSampleAxisRange, setSampleColor, setSampleColor2, setSampleColors2, setSampleCount, setSampleDecimalCount, setSampleLabel, setSampleLabelColor, setSampleLabels, setSampleLabelSelectionColor, setSampleLabelsOn, setSampleLabelStyle, setSamples, setSampleScrollerOn, setSampleValue, setSampleValues, setSelection, setSelection, setSelection, setSeriesCount, setSeriesFormatter, setSeriesLabel, setSeriesLabelColor, setSeriesLabels, setSeriesLabelsOn, setSeriesLabelStyle, setSeriesRange, setTargetLabelsPosition, setTargetValueLine, setTargetValueLine, setValueLabelColor, setValueLabelsOn, setValueLabelsOn, setValueLabelStyle, setValueLinesColor, setValueLinesOn, setVisibleSamples, setVisibleSamples
 
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, getLegendPosition, getLocale, getMinimumSize, getOverlayChart, getOverlayInsets, getPreferredSize, getSize, getThousandsDelimeter, getTitle, getTotalGraphBounds, getVersion, handleCustomLabels, is3DModeOn, isAntialiasingOn, isAutomaticRepaintOn, isFloatingOnLegendOn, isGridOutline3DOn, isLegendOn, isLegendReverseOn, isMultiSeriesOn, isOverlayChartOn, isPrintAsBitmap, 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

BEHIND_LINE_LAYOUT

public static final int BEHIND_LINE_LAYOUT
The 3D lines are located behind each other

See Also:
Constant Field Values

LINE_STYLE_LINE

public static final int LINE_STYLE_LINE
Paint series as a normal line

See Also:
Constant Field Values

LINE_STYLE_TUBE

public static final int LINE_STYLE_TUBE
Paint series as a tube line

See Also:
Constant Field Values

SAME_LEVEL_LINE_LAYOUT

public static final int SAME_LEVEL_LINE_LAYOUT
the 3D lines are located at the same level

See Also:
Constant Field Values

SAMPLE_HIGHLIGHT_CIRCLE

public static final int SAMPLE_HIGHLIGHT_CIRCLE
Use a circle as a sample highlighter on a line.

See Also:
Constant Field Values

SAMPLE_HIGHLIGHT_CIRCLE_FILLED

public static final int SAMPLE_HIGHLIGHT_CIRCLE_FILLED
Use a filled circle as a sample highlighter on a line.

See Also:
Constant Field Values

SAMPLE_HIGHLIGHT_CIRCLE_OPAQUE

public static final int SAMPLE_HIGHLIGHT_CIRCLE_OPAQUE
Use an opaque circle as a sample highlighter on a line.

See Also:
Constant Field Values

SAMPLE_HIGHLIGHT_DIAMOND

public static final int SAMPLE_HIGHLIGHT_DIAMOND
Use a diamond as a sample highlighter on a line.

See Also:
Constant Field Values

SAMPLE_HIGHLIGHT_DIAMOND_FILLED

public static final int SAMPLE_HIGHLIGHT_DIAMOND_FILLED
Use a filled diamond as a sample highlighter on a line.

See Also:
Constant Field Values

SAMPLE_HIGHLIGHT_DIAMOND_OPAQUE

public static final int SAMPLE_HIGHLIGHT_DIAMOND_OPAQUE
Use an opaque diamond as a sample highlighter on a line.

See Also:
Constant Field Values

SAMPLE_HIGHLIGHT_SQUARE

public static final int SAMPLE_HIGHLIGHT_SQUARE
Use a square as a sample highlighter on a line.

See Also:
Constant Field Values

SAMPLE_HIGHLIGHT_SQUARE_FILLED

public static final int SAMPLE_HIGHLIGHT_SQUARE_FILLED
Use a filled square as a sample highlighter on a line.

See Also:
Constant Field Values

SAMPLE_HIGHLIGHT_SQUARE_OPAQUE

public static final int SAMPLE_HIGHLIGHT_SQUARE_OPAQUE
Use an opaque square as a sample highlighter on a line.

See Also:
Constant Field Values
Constructor Detail

LineChart

public LineChart()
Creates a line chart with one series, 5 samples, and a range of 0-100.


LineChart

public LineChart(int seriesCount,
                 int sampleCount,
                 double range)
Creates a line chart with the specified number of series, the number of samples per serie, and the chart range.

Parameters:
seriesCount - The number of sample series.
sampleCount - The number of samples per series.
range - The upper range of the chart.
Throws:
java.lang.IllegalArgumentException - If the seriesCount is less than 1

LineChart

public LineChart(int seriesCount,
                 int sampleCount,
                 double range,
                 double lowerRange)
Creates a line chart with the specified number of series, the number of samples per serie, and the chart range.

Parameters:
seriesCount - The number of sample series.
sampleCount - The number of samples per series.
range - The upper range of the chart.
lowerRange - The lower range of the chart.
Throws:
java.lang.IllegalArgumentException - If the seriesCount is less than 1
Method Detail

checkDataIntegrity

protected void checkDataIntegrity()
Makes sure the linechart specific data has the same number of series and samples as the chart data has.

Overrides:
checkDataIntegrity in class Chart

checkSelection

public 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 bar or a legend label.

Overrides:
checkSelection in class Chart
Parameters:
point - The point clicked on.
Returns:
The bar selected, or null if no bar was selected.

getArea

public int[] getArea(int index)
Gets the area bounding lines series by it's index.

Parameters:
index - The index of the area.
Returns:
An array of two elements, one per bounding line series.

getAreaColor

public java.awt.Color getAreaColor(int index)
Gets areas color value by it's index.

Parameters:
index - The index of the area.
Returns:
Color of the area.

getAreaColor2

public java.awt.Color getAreaColor2(int index)
Gets areas secondary color color value by it's index. It can be usde to paint the area with gradient fill.

Parameters:
index - The index of the area.

getHighestValue

protected double getHighestValue(int range)
Gets the highest value in the chart larger than 0.

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

getLegendImage

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

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

getLegendLabels

public java.lang.String[] getLegendLabels()
Gets the legend labels.

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

getLine3DDepth

public double getLine3DDepth(int series)
Gets the current 3D depth of the given series line.

Parameters:
series - The index of the data series.
Returns:
The depth from 0.0 to 1.0.

getLine3DLayout

public int getLine3DLayout()
Gets the current bar type in multiple series charts.

Returns:
STACKED_BARS, SIDE_BY_SIDE_BARS or BEHIND_BARS.

getLineStroke

public float[] getLineStroke(int series)
Gets the array describing type of the current serie line.

Parameters:
series - The index of the data series.
Returns:
The array describing type of the current serie line.

getLineStyle

public int getLineStyle(int series)
Gets the style of the given series line.

Parameters:
series - The index of the data series.
Returns:
The style of the line: LINE_STYLE_LINE or LINE_STYLE_TUBE.

getLineWidth

public int getLineWidth(int series)
Gets the current width of the given series line.

Parameters:
series - The index of the data series.
Returns:
The width in pixels.

getMaxValue

public double getMaxValue(int serie)
Gets the maximum value in the chart. If the series is given, the value returned will be the maximum value in that series. If the series is -1, the value returned will be the maximum in any series. If the series is -2, the value is the highest stacked value.

Overrides:
getMaxValue in class Chart
Parameters:
serie - The index of the series.

getSampleHighlightImage

public java.lang.String getSampleHighlightImage(int series,
                                                int sample)
Gets a sample highlight image name. If the sample is -1, the method returns the image used for the whole serie. If both sample and series are -1, the method returns image used for all samples in the chart.

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

getSampleHighlightSize

public int getSampleHighlightSize(int series)
Gets the sample highlight size.

Parameters:
series - The series to get the size for.
Returns:
The size in pixels.
Throws:
java.lang.IllegalArgumentException - if the series is invalid.

getSampleHighlightStyle

public int getSampleHighlightStyle(int series)
Gets the sample highlight style.

Parameters:
series - The series to get the style for.
Returns:
SAMPLE_HIGHLIGHT_CIRCLE, SAMPLE_HIGHLIGHT_CIRCLE_OPAQUE, SAMPLE_HIGHLIGHT_CIRCLE_FILLED, SAMPLE_HIGHLIGHT_SQUARE, SAMPLE_HIGHLIGHT_SQUARE_OPAQUE, SAMPLE_HIGHLIGHT_SQUARE_FILLED, SAMPLE_HIGHLIGHT_DIAMOND, SAMPLE_HIGHLIGHT_DIAMOND_OPAQUE, SAMPLE_HIGHLIGHT_DIAMOND_FILLED.
Throws:
java.lang.IllegalArgumentException - if the series is invalid.

getSamplePoint

public java.awt.Point getSamplePoint(int serie,
                                     int sample)
Gets the coordinates of the specified sample.

Parameters:
serie - The series index
sample - The sample index.
Returns:
The coordinates of the specified sample, or null if the sample was not found.

getValuePosition

public int getValuePosition(double value)
Gets the position in the chart of the specified value.

Parameters:
value - The value to find the position for.
Returns:
The pixel position.

isAutoLabelSpacingOn

public boolean isAutoLabelSpacingOn()
Gets the state of the automatic label spacing.

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

isConnectedLinesOn

public boolean isConnectedLinesOn(int serie)
Checks if lines with missing values are connected.

Parameters:
serie - The index of the series to check, -1 for all.
Returns:
True if connected, false if not.
See Also:
setConnectedLinesOn(int, boolean)

isMissingValuesInterpolated

public boolean isMissingValuesInterpolated()
Check if the missig sample values are calculated autmatically in the stacked mode

Returns:
True if the missig sample values are calculated autmatically in the stacked mode

isOutlineOn

public boolean isOutlineOn(int serie)
Checks if the bar outline is turned on or off. The bar outline is the frame drawn around each bar.

Returns:
True if on, false for off.

isRightToLeftScrollingOn

public boolean isRightToLeftScrollingOn()
Checks if the right to left scrolling is turned on.

Returns:
True if on, false if off.
See Also:
setRightToLeftScrollingOn(boolean)

isSampleHighlightOn

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

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

isSampleHighlightOn

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

Parameters:
series - The data series where the sample is.
sample - The sample to check.
Returns:
True if on, false if off.

isSeriesLineOn

public boolean isSeriesLineOn(int serie)
Checks if the specified line is on.

Parameters:
serie - The index of the data series.
Returns:
True if on, false for off.
See Also:
setSeriesLineOn(int, boolean)

isStackedOn

public boolean isStackedOn()
Checks if stacked lines are turned on.

Returns:
True if on, false if off.
See Also:
setStackedOn(boolean)

paint3DLine

protected void paint3DLine(java.awt.Graphics g,
                           int x1,
                           int y1,
                           int x2,
                           int y2,
                           int y3,
                           java.awt.Color color,
                           boolean top,
                           boolean right,
                           boolean outlined)
Paints the 3D part of a line.

Parameters:
g - The graphics context to paint with.
x1 - The beginning of the line.
y1 - The beginning of the line.
x2 - The end of the line.
y2 - The end of the line.
y3 - The bottom of the stacked line
color - The color of the line.
top - True if the top should be painted.
right - True if the right edge should be painted.
outlined - True if the 3D line should be outlined with a darker color.

paintLine

protected void paintLine(java.awt.Graphics g,
                         int serie,
                         java.awt.Rectangle gridBounds,
                         java.awt.Rectangle dataBounds,
                         java.awt.Color color,
                         boolean selected)
Paints the line of one series.

Parameters:
g - The graphics context to use.
serie - The index of the series to paint (0-based).
gridBounds - The chart grid bounds.
dataBounds - The bounds to paint the data in (same or larger as bonds).
color - The color of the line.
selected - True if the series is selected.

paintSampleHighlight

protected void paintSampleHighlight(java.awt.Graphics g,
                                    int serie,
                                    int sample,
                                    int x,
                                    int y,
                                    java.awt.Color color)
Paints the sample highlight for a point.

Parameters:
g - The graphics context used to paint with.
serie - The index of the serie.
x - The x-position of the sample.
y - The y-position of the sample.
color - The color of the sample highlight.

reset

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

Overrides:
reset in class Chart

setArea

public void setArea(int index,
                    int line1,
                    int line2)
Sets an area between the two line series to be filled with a specific color.

Parameters:
index - The index of the area
line1 - The bounding line.
line2 - The second bounding line.

setAreaColor

public void setAreaColor(int index,
                         java.awt.Color color)
Sets color for a specified area.

Parameters:
index - The index of the area
color - The color to paint area with.

setAreaColor2

public void setAreaColor2(int index,
                          java.awt.Color color)
Sets the secondary color for a specified area. This can be used to paint area with gradient fill.

Parameters:
index - The index of the area
color - The secondary color of the gradient fill to paint area with.

setAutoLabelSpacingOn

public void setAutoLabelSpacingOn(boolean on)
Turns on or off automatic sample label spacing. If this is on, only sample labels there is space for will be painted. If turned off, all labels will be painted, even if they overlap. It is turned off by default.

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

setConnectedLinesOn

public void setConnectedLinesOn(int serie,
                                boolean on)
Connects lines with missing values. By default, if you have missing or undefined values in a series there will be a hole in the line where the missing value is.

Parameters:
serie - The index of the series, -1 for all.
on - True for on, false for off.

setLine3DDepth

public void setLine3DDepth(int series,
                           double depth)
Sets the 3D depth of the specified line.

Parameters:
series - The series number, -1 for all.
depth - The depth from 0.0 to 1.0.

setLine3DLayout

public void setLine3DLayout(int layout)
Sets the line layout in multiple series charts in 3D mode.

Parameters:
layout - BEHIND_LINE_LAYOUT, SAME_LEVEL_LINE_LAYOUT.
Throws:
java.lang.IllegalArgumentException - If the type is not valid.

setLineStroke

public void setLineStroke(int series,
                          float[] dash)
Sets an array of values to use as repeating dash lengths and clear sections. Use only one value if all the dashes and clear sections have the same length. For instance, the array new int[] {3} produces a repeating dash of 3 pixel length followed by space of same length, while the array new int[] {3, 6} produces dash of 3 pixel length followed by 6 empty pixels. The length of the stroke will cycle trough the array if more drawing space is available.

Parameters:
series - The series number, -1 for all.
dash - The array of values to use as repeating dashes and clear sections. Use null for the plain line.

setLineStyle

public void setLineStyle(int series,
                         int style)
Sets the style of the data series lines.

Parameters:
series - The series number, -1 for all.
style - LINE_STYLE_LINE (default), LINE_STYLE_TUBE.

setLineWidth

public void setLineWidth(int series,
                         int width)
Sets the width of the specified line.

Parameters:
series - The series number, -1 for all.
width - The width in pixels, default is 2.

setMissingValuesInterpolated

public void setMissingValuesInterpolated(boolean on)
Turns on the automatic calculation of the missing sample values in the stacked mode

Parameters:
on - True of false.

setOutlineOn

public void setOutlineOn(int serie,
                         boolean on)
Turns on or off the line or area outline.

Parameters:
serie - The line serie to outline. If serie == -1 the parameter applies to all lines in the chart.
on - True if on, false for off.

setRightToLeftScrollingOn

public void setRightToLeftScrollingOn(boolean state)
Turns on right to left scrolling when adding new values. Turning this on will paint a line with the right end of the line adjusted with the right edge of the chart grid. When a new value is appended, the line will scroll to the left (same as the CPU usage history in Windows).

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

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.

Overrides:
setSampleColors in class Chart
Parameters:
colors - An array with the colors to be used, null for default colors.

setSampleHighlightImage

public void setSampleHighlightImage(int series,
                                    int sample,
                                    java.lang.String name)
Sets an image to be used as a highlight for a specified sample. If sample is -1, the image is set for the whole serie, if both sample and serie is -1, the image is set for all samples on the chart.

Parameters:
series - The series to set hightlight image for.
sample - The sample to set hightlight image for.
name - The image to use, null for the default highlight.
See Also:
GenericChart.addImage(java.lang.String, java.awt.Image)

setSampleHighlightOn

public void setSampleHighlightOn(boolean on)
Turns on or off the sample highlight for the data series.

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

setSampleHighlightOn

public void setSampleHighlightOn(int series,
                                 boolean on)
Turns on or off the sample highlight for a data series.

Parameters:
series - The series to turn highlights on or off for.
on - True for on, false for off.
Throws:
java.lang.IllegalArgumentException - if the series is invalid.

setSampleHighlightOn

public void setSampleHighlightOn(int series,
                                 int sample,
                                 boolean on)
Turns on or off the sample highlight for a sample in a data series.

Parameters:
series - The series where the sample is located.
sample - The sample on that serie to turn on or off.
on - True for on, false for off.
Throws:
java.lang.IllegalArgumentException - if the series is invalid.

setSampleHighlightStyle

public void setSampleHighlightStyle(int style,
                                    int size)
Sets the sample highlight style for all the data series.

Parameters:
style - SAMPLE_HIGHLIGHT_CIRCLE, SAMPLE_HIGHLIGHT_CIRCLE_OPAQUE, SAMPLE_HIGHLIGHT_CIRCLE_FILLED, SAMPLE_HIGHLIGHT_SQUARE, SAMPLE_HIGHLIGHT_SQUARE_OPAQUE, SAMPLE_HIGHLIGHT_SQUARE_FILLED, SAMPLE_HIGHLIGHT_DIAMOND, SAMPLE_HIGHLIGHT_DIAMOND_OPAQUE, SAMPLE_HIGHLIGHT_DIAMOND_FILLED.
size - The size of the circle or square.
Throws:
java.lang.IllegalArgumentException - if the type is invalid.
java.lang.IndexOutOfBoundsException - if the series is invalid.

setSampleHighlightStyle

public void setSampleHighlightStyle(int serie,
                                    int style,
                                    int size)
Sets the sample highlight style for the specified data series.

Parameters:
serie - The index of the serie.
style - SAMPLE_HIGHLIGHT_CIRCLE, SAMPLE_HIGHLIGHT_CIRCLE_OPAQUE, SAMPLE_HIGHLIGHT_CIRCLE_FILLED, SAMPLE_HIGHLIGHT_SQUARE, SAMPLE_HIGHLIGHT_SQUARE_OPAQUE, SAMPLE_HIGHLIGHT_SQUARE_FILLED, SAMPLE_HIGHLIGHT_DIAMOND, SAMPLE_HIGHLIGHT_DIAMOND_OPAQUE, SAMPLE_HIGHLIGHT_DIAMOND_FILLED.
size - The size of the circle or square.
Throws:
java.lang.IndexOutOfBoundsException - if the series is invalid.

setSeriesLineOn

public void setSeriesLineOn(boolean state)
Turns on or off the series lines. If this is turned off and the sample highlights are turned on, only the highlight shapes will be painted, and not the lines. It is turned on by default.

Parameters:
state - True for on (default), false for off.

setSeriesLineOn

public void setSeriesLineOn(int serie,
                            boolean state)
Turns on or off the specified series line. If this is turned off and the sample highlights are turned on, only the highlight shapes will be painted.

Parameters:
serie - The series index.
state - True for on (default), false for off.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the series is invalid.

setStackedOn

public void setStackedOn(boolean on)
Turns on or off stacked lines. When the lines are stacked they will be painted filled on top of each other.

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