com.objectplanet.chart.ext
Class TimeLineChart

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

public class TimeLineChart
extends LineChart

The time line chart component adds time line chart specific properties to the line chart. A simple time line chart can be created with the following code (the sequence of the function calls is important!) :

 TimeLineChart chart = new TimeLineChart();
 String[] time_plots = {"01/01/2002|1234", " 02/01/2002|1414", " 03/01/2002|1655", " 04/01/2002|1361", 
                        "05/01/2002|1663", " 06/01/2002|1598", " 07/01/2002|1099", " 08/01/2002|1136", 
                        "09/01/2002|1135", " 10/01/2002|2510", " 11/01/2002|4833", " 12/01/2002|5905"};
 chart.setAutoTimeLabelsOn(true);
 chart.setTimeFormatInput("MM/dd/yyyy");
 chart.setLowerTime("01/01/2002");
 chart.setUpperTime("12/01/2002");
 chart.setTimeScale(86400);
 chart.setLabelAngle("sampleLabelAngle", 270);
 chart.setTimePlots(0, time_plots);
 chart.setDefaultGridLinesOn(true);
 chart.setRelativeRange(0, 1, 1000);
 chart.setSampleScrollerOn(true);
 chart.setRangeAdjusterOn(0, true);

See here for a list of parameters to set for the time line chart.
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
 
Fields inherited from class com.objectplanet.chart.LineChart
BEHIND_LINE_LAYOUT, LINE_STYLE_LINE, LINE_STYLE_TUBE, SAME_LEVEL_LINE_LAYOUT, SAMPLE_HIGHLIGHT_CIRCLE, SAMPLE_HIGHLIGHT_CIRCLE_FILLED, SAMPLE_HIGHLIGHT_CIRCLE_OPAQUE, SAMPLE_HIGHLIGHT_DIAMOND, SAMPLE_HIGHLIGHT_DIAMOND_FILLED, SAMPLE_HIGHLIGHT_DIAMOND_OPAQUE, SAMPLE_HIGHLIGHT_SQUARE, SAMPLE_HIGHLIGHT_SQUARE_FILLED, SAMPLE_HIGHLIGHT_SQUARE_OPAQUE
 
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
TimeLineChart()
          Creates the TimeLineChart.
 
Method Summary
 java.lang.String createTimeLabelBySample(int sample)
          Creates the time label using the input time format.
 java.lang.String getLowerTime()
          Gets the start time of the time axis.
 java.lang.String getTimeFormatInput()
          Gets the format of the input date time paremeters.
 java.lang.String getTimeFormatOut()
          Gets the display format of the time labels.
 double getTimeScale()
          Gets the scaling of the time axis.
 java.lang.String getUpperTime()
          Gets the end time of the time axis.
 boolean isAutoTimeLabelsOn()
          Checks if the auto time labels are on.
 void reset()
          Resets the chart data and features.
 void setAutoTimeLabelsOn(boolean on)
          If you turn this on, labels will automatically be added to the x-axis at each plot point.
 void setDefaultGridLinesOn(boolean on)
          Shows the grid lines for each time label entry.
 void setLowerTime(java.lang.String time)
          Sets the start time of the time axis.
 void setTimeFormatInput(java.lang.String pattern)
          Sets the format of the input date time parameters.
 void setTimeFormatInputLocale(java.lang.String value)
          Sets the locale of the input date time parameters (example, en,us).
 void setTimeFormatOut(java.lang.String pattern)
          Sets the display format of the time labels.
 void setTimeFormatOutLocale(java.lang.String value)
          Sets the locale of the output date time parameters (example, en,us).
 void setTimeLabels(java.lang.String[] labels)
          Adds time labels at the plot points indicated by the time labels.
 void setTimePlots(int series, java.lang.String[] plots)
          Sets the x|y plots, where x is a datetime string, y is the value, The x and y values must be delimited by |, and the datetime string must be in the format specified by timeFormatInput.
 void setTimeScale(double seconds)
          Sets the scaling of the time axis in number of seconds.
 void setUpperTime(java.lang.String time)
          Sets the end time of the time axis.
 
Methods inherited from class com.objectplanet.chart.LineChart
checkDataIntegrity, checkSelection, getArea, getAreaColor, getAreaColor2, getHighestValue, getLegendImage, getLegendLabels, getLine3DDepth, getLine3DLayout, getLineStroke, getLineStyle, getLineWidth, getMaxValue, getSampleHighlightImage, getSampleHighlightSize, getSampleHighlightStyle, getSamplePoint, getValuePosition, isAutoLabelSpacingOn, isConnectedLinesOn, isMissingValuesInterpolated, isOutlineOn, isRightToLeftScrollingOn, isSampleHighlightOn, isSampleHighlightOn, isSeriesLineOn, isStackedOn, paint3DLine, paintLine, paintSampleHighlight, setArea, setAreaColor, setAreaColor2, setAutoLabelSpacingOn, setConnectedLinesOn, setLine3DDepth, setLine3DLayout, setLineStroke, setLineStyle, setLineWidth, setMissingValuesInterpolated, setOutlineOn, setRightToLeftScrollingOn, setSampleColors, setSampleHighlightImage, setSampleHighlightOn, setSampleHighlightOn, setSampleHighlightOn, setSampleHighlightStyle, setSampleHighlightStyle, setSeriesLineOn, setSeriesLineOn, setStackedOn
 
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, 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
 

Constructor Detail

TimeLineChart

public TimeLineChart()
Creates the TimeLineChart.

Method Detail

createTimeLabelBySample

public java.lang.String createTimeLabelBySample(int sample)
Creates the time label using the input time format.

Parameters:
sample - The sample index of the plot.
Returns:
The time string.

getLowerTime

public java.lang.String getLowerTime()
Gets the start time of the time axis.

Returns:
A string representing the start time in output format.

getTimeFormatInput

public java.lang.String getTimeFormatInput()
Gets the format of the input date time paremeters.

Returns:
The current input data parser pattern.

getTimeFormatOut

public java.lang.String getTimeFormatOut()
Gets the display format of the time labels.

Returns:
The pattern used for the time labels.

getTimeScale

public double getTimeScale()
Gets the scaling of the time axis.

Returns:
The time scale in seconds.

getUpperTime

public java.lang.String getUpperTime()
Gets the end time of the time axis.

Returns:
A string representing the end time in output format.

isAutoTimeLabelsOn

public boolean isAutoTimeLabelsOn()
Checks if the auto time labels are on.

Returns:
True if auto time labels are on, false otherwise.

reset

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

Overrides:
reset in class LineChart

setAutoTimeLabelsOn

public void setAutoTimeLabelsOn(boolean on)
If you turn this on, labels will automatically be added to the x-axis at each plot point.

Parameters:
on - If thrue the auto time labels are on.

setDefaultGridLinesOn

public void setDefaultGridLinesOn(boolean on)
Shows the grid lines for each time label entry.

Overrides:
setDefaultGridLinesOn in class Chart
Parameters:
on - If true, the grid lines are turned on.
See Also:
Chart.setGridLines(double[])

setLowerTime

public void setLowerTime(java.lang.String time)
Sets the start time of the time axis. The time string must be in the format specified in the timeFormatInput parameter.

Parameters:
time - The start time of the time axis.

setTimeFormatInput

public void setTimeFormatInput(java.lang.String pattern)
Sets the format of the input date time parameters.

Parameters:
pattern - The current input data parser pattern.

setTimeFormatInputLocale

public void setTimeFormatInputLocale(java.lang.String value)
Sets the locale of the input date time parameters (example, en,us).

Parameters:
value - The locale code: language, country.

setTimeFormatOut

public void setTimeFormatOut(java.lang.String pattern)
Sets the display format of the time labels.

Parameters:
pattern - The pattern used for the time labels.

setTimeFormatOutLocale

public void setTimeFormatOutLocale(java.lang.String value)
Sets the locale of the output date time parameters (example, en,us).

Parameters:
value - The locale code: language, country.

setTimeLabels

public void setTimeLabels(java.lang.String[] labels)
Adds time labels at the plot points indicated by the time labels.

Parameters:
labels - The time labels to set to the plot.

setTimePlots

public void setTimePlots(int series,
                         java.lang.String[] plots)
Sets the x|y plots, where x is a datetime string, y is the value, The x and y values must be delimited by |, and the datetime string must be in the format specified by timeFormatInput.

Parameters:
series - The Index of data series to set plots for.
plots - The array of x|y plots.

setTimeScale

public void setTimeScale(double seconds)
Sets the scaling of the time axis in number of seconds. The default value is 1 which means that each step on the x-axis is one second. If you set the timeScale to 60 each step on the axis will be one minute. If you set the timeScale to 3600, each step will be one hour, and so on.

Parameters:
seconds - The time scale in seconds.

setUpperTime

public void setUpperTime(java.lang.String time)
Sets the end time of the time axis. The time string must be in the format specified in the timeFormatInput parameter.

Parameters:
time - The end time of the time axis.