jsky.timeline
Class TimeLine

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jsky.timeline.TimeLine
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class TimeLine
extends javax.swing.JPanel

A time line which can contain nodes that can be adjusted by time and duration.

This code was developed by NASA, Goddard Space Flight Center, Code 588 for the Scientist's Expert Assistant (SEA) project.

Version:
$Revision: 1.1 $
Author:
M. Fishman, A. Brighton (modified original version)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.geom.Line2D.Float _centerLine
           
protected  java.util.Comparator _comparator
           
protected  Time _displayEnd
           
protected  Time _displayStart
           
protected  float _handleHeight
           
protected  int _intervalCount
           
protected  Time _intervalInTime
           
protected  java.awt.event.KeyAdapter _keyListener
           
protected  boolean _labelsAtTop
           
protected  java.lang.String _mode
           
protected  TimeLineModel _model
           
protected  java.awt.event.MouseMotionAdapter _mouseDragListener
          an adapter used to handle mouse drag events
protected  java.awt.event.MouseAdapter _mouseListener
          a listener for mouse events.
protected  java.beans.VetoableChangeListener _myChildListener
           
protected  java.beans.PropertyChangeListener _myModelListener
           
protected  java.util.TreeSet _nodes
           
protected  java.lang.String _unitType
           
protected  float _verticalSpacer
           
protected  java.util.List _vetoableListeners
           
static java.lang.String DATE_VIEW
           
static java.awt.Cursor DEFAULT_CURSOR
           
static java.lang.String DISPLAY_WINDOW_CHANGE
           
protected static double MIN_DISPLAY_WINDOW
           
static java.lang.String NODE_ADDED
           
static java.lang.String NODE_REMOVED
           
static java.lang.String SELECTION_MODE
           
static java.lang.String TIME_VIEW
           
static java.lang.String ZOOM_MODE
           
 
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
TimeLine()
          constructor
TimeLine(int interval)
          constructor
TimeLine(int start, int end, int intervals)
          constructor
TimeLine(TimeLineModel model)
          constructor
TimeLine(Time start, Time end, int intervals)
          constructor
 
Method Summary
protected  void addSilentTimeLineNode(TimeLineNode node)
          add a time line node to the time line without checking its legality
 void addTimeLineNode(TimeLineNode node)
          add a time line node to the time line
 void addTimeLineNodeNoEvents(TimeLineNode node)
          Add a time line node to the time line and save time by not checking or firing events.
 void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
          add a vetoable property change listener to the time line.
protected  void fireVetoableChange(java.beans.PropertyChangeEvent evt)
          fires a vetoable change event to all listeners of the timeline
 java.util.Date getDateForTime(Time time)
          takes a time and converts it into a date where the new date is equal to the start date + the time
 Time getDisplayEnd()
          get the displayed end of the timeline
 Time getDisplayStart()
          get the displayed start of the timeline
 Time getEndTime()
          get the ending value of the timeline
 float getHandleHeight()
           
 int getIntervalCount()
          get the number of intervals in the time line
 Time getIntervalTime()
          get the time value of a single interval in the timeline
 java.lang.String getMode()
          get the time line's mode
 TimeLineModel getModel()
           
 float getPointForTime(Time time)
          get the x coordinate for specified time
 java.util.List getSelectedNodes()
          get the list of nodes in the timeline which are currently selected
 java.util.Date getStartDate()
          get the start date
 Time getStartTime()
          get the starting value in the timeline
 Time getTimeForDate(java.util.Date date)
          takes a date and convert it to a time where the new time is equal to the date - start date
 Time getTimeForPoint(float xValue)
          get the time value of an X coordinate in the TimeLine
 java.util.Iterator getTimeLineNodesIterator()
          get an iterator for the time line nodes
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
           
 java.lang.String getUnitsType()
          get the unit types to display in the timeline
 float getVerticalSpacer()
           
 void handleKeyEvent(java.awt.event.KeyEvent evt)
          this method handles any key events received by the panel.
protected  void handleMouseClicked(java.awt.event.MouseEvent evt)
          this method handles any mouse clicked events
protected  void handleMousePressed(java.awt.event.MouseEvent evt)
          this method handles any mouse pressed or mouse released events
 boolean isLabelsAtTop()
           
static void main(java.lang.String[] args)
          test main (allan)
 void moveDisplayAreaBy(Time time)
          move the display window of the timeline by the specified amount
protected  void paintCenterLine(java.awt.Graphics2D g2)
          paint the component
protected  void paintComponent(java.awt.Graphics grph)
          paint the component
protected  void paintEndLabel(java.awt.Graphics2D g2)
          paint the timeline end label in the current units.
protected  void paintNodes(java.awt.Graphics2D g2)
          paint the timeline nodes.
protected  void paintStartLabel(java.awt.Graphics2D g2)
          paint the timeline start label in the current units.
 void removeAllTimeLineNodes()
          remove all time line nodes from time line
 void removeTimeLineNode(TimeLineNode node)
          remove a time line node from the time line
 void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
          remove a vetoable property change listener from the time line
 void resetDisplayArea()
          reset the display window to show all data
 void setDisplayArea(Time start, Time end)
          sets the diplay window of the timeline
 void setHandleHeight(float f)
           
 void setLabelsAtTop(boolean b)
           
 void setMode(java.lang.String mode)
          set the mode of the time line
 void setModel(TimeLineModel model)
          Set the model (allan: added this method)
 void setStartDate(java.util.Date date)
          set the date from which the timeline should start Note: if the date is not null then all time values are considered offsets from it
 void setUnitsType(java.lang.String unitType)
          Set the unit types to display in the timeline.
 void setVerticalSpacer(float f)
           
protected  void validatePropertyChange(java.beans.PropertyChangeEvent evt)
          takes a PropertyChangeEvent and throws a PropertyVetoException if anything in the event would cause it to be rejected
 void zoomIn()
          zoom the time line in
 void zoomIn(java.awt.Point centerPt)
          zoom the time line in with center point centerPt being at the center
 void zoomOut()
          zoom the time line out
 void zoomOut(java.awt.Point centerPt)
          zoom the time line out with center point centerPt being at the center
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
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, processEvent, 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, 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, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, 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, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATE_VIEW

public static final java.lang.String DATE_VIEW
See Also:
Constant Field Values

TIME_VIEW

public static final java.lang.String TIME_VIEW
See Also:
Constant Field Values

DISPLAY_WINDOW_CHANGE

public static final java.lang.String DISPLAY_WINDOW_CHANGE
See Also:
Constant Field Values

NODE_ADDED

public static final java.lang.String NODE_ADDED
See Also:
Constant Field Values

NODE_REMOVED

public static final java.lang.String NODE_REMOVED
See Also:
Constant Field Values

SELECTION_MODE

public static final java.lang.String SELECTION_MODE
See Also:
Constant Field Values

ZOOM_MODE

public static final java.lang.String ZOOM_MODE
See Also:
Constant Field Values

MIN_DISPLAY_WINDOW

protected static final double MIN_DISPLAY_WINDOW
See Also:
Constant Field Values

DEFAULT_CURSOR

public static final java.awt.Cursor DEFAULT_CURSOR

_comparator

protected java.util.Comparator _comparator

_handleHeight

protected float _handleHeight

_verticalSpacer

protected float _verticalSpacer

_centerLine

protected java.awt.geom.Line2D.Float _centerLine

_nodes

protected java.util.TreeSet _nodes

_vetoableListeners

protected java.util.List _vetoableListeners

_intervalCount

protected int _intervalCount

_mode

protected java.lang.String _mode

_unitType

protected java.lang.String _unitType

_displayStart

protected Time _displayStart

_displayEnd

protected Time _displayEnd

_intervalInTime

protected Time _intervalInTime

_model

protected TimeLineModel _model

_labelsAtTop

protected boolean _labelsAtTop

_mouseListener

protected java.awt.event.MouseAdapter _mouseListener
a listener for mouse events.


_mouseDragListener

protected java.awt.event.MouseMotionAdapter _mouseDragListener
an adapter used to handle mouse drag events


_keyListener

protected java.awt.event.KeyAdapter _keyListener

_myChildListener

protected java.beans.VetoableChangeListener _myChildListener

_myModelListener

protected java.beans.PropertyChangeListener _myModelListener
Constructor Detail

TimeLine

public TimeLine()
constructor


TimeLine

public TimeLine(int interval)
constructor

Parameters:
interval - the number of intervals in a 50 minute time line

TimeLine

public TimeLine(int start,
                int end,
                int intervals)
constructor

Parameters:
start - the starting minute of the timeline
end - the ending minute of the timeline
intervals - the number of intervals on the timeline

TimeLine

public TimeLine(Time start,
                Time end,
                int intervals)
constructor

Parameters:
start - the starting time of the timeline
end - the ending time of the timeline
intervals - the number of intervals on the timeline

TimeLine

public TimeLine(TimeLineModel model)
constructor

Parameters:
model - the time line model
Method Detail

addTimeLineNode

public void addTimeLineNode(TimeLineNode node)
                     throws IllegalNodePositionException
add a time line node to the time line

Throws:
IllegalNodePositionException

addTimeLineNodeNoEvents

public void addTimeLineNodeNoEvents(TimeLineNode node)
                             throws IllegalNodePositionException
Add a time line node to the time line and save time by not checking or firing events.

Throws:
IllegalNodePositionException

getModel

public TimeLineModel getModel()

setModel

public void setModel(TimeLineModel model)
Set the model (allan: added this method)


addSilentTimeLineNode

protected void addSilentTimeLineNode(TimeLineNode node)
add a time line node to the time line without checking its legality


setUnitsType

public void setUnitsType(java.lang.String unitType)
Set the unit types to display in the timeline.


isLabelsAtTop

public boolean isLabelsAtTop()

setLabelsAtTop

public void setLabelsAtTop(boolean b)

getHandleHeight

public float getHandleHeight()

setHandleHeight

public void setHandleHeight(float f)

getVerticalSpacer

public float getVerticalSpacer()

setVerticalSpacer

public void setVerticalSpacer(float f)

getUnitsType

public java.lang.String getUnitsType()
get the unit types to display in the timeline


setDisplayArea

public void setDisplayArea(Time start,
                           Time end)
sets the diplay window of the timeline


resetDisplayArea

public void resetDisplayArea()
reset the display window to show all data


moveDisplayAreaBy

public void moveDisplayAreaBy(Time time)
move the display window of the timeline by the specified amount


removeTimeLineNode

public void removeTimeLineNode(TimeLineNode node)
remove a time line node from the time line


removeAllTimeLineNodes

public void removeAllTimeLineNodes()
remove all time line nodes from time line


getIntervalTime

public Time getIntervalTime()
get the time value of a single interval in the timeline


getIntervalCount

public int getIntervalCount()
get the number of intervals in the time line


paintComponent

protected void paintComponent(java.awt.Graphics grph)
paint the component

Overrides:
paintComponent in class javax.swing.JComponent

paintCenterLine

protected void paintCenterLine(java.awt.Graphics2D g2)
paint the component


paintStartLabel

protected void paintStartLabel(java.awt.Graphics2D g2)
paint the timeline start label in the current units.


paintEndLabel

protected void paintEndLabel(java.awt.Graphics2D g2)
paint the timeline end label in the current units.


paintNodes

protected void paintNodes(java.awt.Graphics2D g2)
paint the timeline nodes.


getDisplayStart

public Time getDisplayStart()
get the displayed start of the timeline


getDisplayEnd

public Time getDisplayEnd()
get the displayed end of the timeline


getTimeLineNodesIterator

public java.util.Iterator getTimeLineNodesIterator()
get an iterator for the time line nodes


handleKeyEvent

public void handleKeyEvent(java.awt.event.KeyEvent evt)
this method handles any key events received by the panel.


addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
add a vetoable property change listener to the time line.

Overrides:
addVetoableChangeListener in class javax.swing.JComponent

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
remove a vetoable property change listener from the time line

Overrides:
removeVetoableChangeListener in class javax.swing.JComponent

setMode

public void setMode(java.lang.String mode)
set the mode of the time line


getTimeForPoint

public Time getTimeForPoint(float xValue)
get the time value of an X coordinate in the TimeLine


getPointForTime

public float getPointForTime(Time time)
get the x coordinate for specified time


getDateForTime

public java.util.Date getDateForTime(Time time)
takes a time and converts it into a date where the new date is equal to the start date + the time


getTimeForDate

public Time getTimeForDate(java.util.Date date)
takes a date and convert it to a time where the new time is equal to the date - start date


setStartDate

public void setStartDate(java.util.Date date)
set the date from which the timeline should start Note: if the date is not null then all time values are considered offsets from it


getStartDate

public java.util.Date getStartDate()
get the start date


getStartTime

public Time getStartTime()
get the starting value in the timeline


getEndTime

public Time getEndTime()
get the ending value of the timeline


getSelectedNodes

public java.util.List getSelectedNodes()
get the list of nodes in the timeline which are currently selected


getMode

public java.lang.String getMode()
get the time line's mode


validatePropertyChange

protected void validatePropertyChange(java.beans.PropertyChangeEvent evt)
                               throws DetailedPropertyVetoException
takes a PropertyChangeEvent and throws a PropertyVetoException if anything in the event would cause it to be rejected

Throws:
DetailedPropertyVetoException

fireVetoableChange

protected void fireVetoableChange(java.beans.PropertyChangeEvent evt)
                           throws DetailedPropertyVetoException
fires a vetoable change event to all listeners of the timeline

Throws:
DetailedPropertyVetoException

handleMouseClicked

protected void handleMouseClicked(java.awt.event.MouseEvent evt)
this method handles any mouse clicked events


handleMousePressed

protected void handleMousePressed(java.awt.event.MouseEvent evt)
this method handles any mouse pressed or mouse released events


zoomIn

public void zoomIn()
zoom the time line in


zoomOut

public void zoomOut()
zoom the time line out


zoomIn

public void zoomIn(java.awt.Point centerPt)
zoom the time line in with center point centerPt being at the center

Parameters:
centerPt - the point to center the zoom around

zoomOut

public void zoomOut(java.awt.Point centerPt)
zoom the time line out with center point centerPt being at the center

Parameters:
centerPt - the point to center the zoom around

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
Overrides:
getToolTipText in class javax.swing.JComponent

main

public static void main(java.lang.String[] args)
test main (allan)