Package ucar.unidata.ui
Class Timeline
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ucar.unidata.ui.Timeline
- All Implemented Interfaces:
MouseListener,MouseMotionListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible
- Direct Known Subclasses:
IdvTimeline
Widget for selecting dates and times
- Version:
- $Revision: 1.36 $
- Author:
- IDV Development Team
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic StringAction command used for the Apply buttonstatic StringAction command used for the Cancel buttonstatic StringAction command used for the Cancel buttonstatic final CursorThe normal cursor_static final CursorThe normal cursor_static final CursorThe normal cursor_static final CursorThe normal cursor_static final intdrawing sizestatic final intwhen dragging the date selection box what are we draggingstatic final intwhen dragging the date selection box what are we draggingstatic final intwhen dragging the date selection box what are we draggingprotected List_more_Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanare we using the date selectionprotected voidhandle changed date selectionprotected voiddoMakeContents(boolean withButtons) make guiprotected voiddoMakeContents(boolean withButtons, boolean withBorder) voidexpandByPercent(double percent, boolean doDateSelection) zoomprotected DatedThingfindClosest(Point p) find closest thingprotected DatedThingfindClosest(Point p, int minimumDistance) find closest thingformat(long time) format timeformat timeformat dateprotected intget the axis lineprotected intbottom of drawing areaGet the ColorTimeSelected property.Get the ColorTimeUnselected property.getContents(boolean withButtons) make guigetContents(boolean withButtons, boolean withBorder) Get the list of dated things we are displayingGet the DateSelection property.Get the EndDate property.get the format to use given the size of the visible rangebooleanGet the IsCapableOfSelection property.protected intgetLeft()left of drawing areaprotected voidgetMenuItems(List items) make menu itemsprotected intgetRight()right of drawing areaGet the list of selected DatedThing-sbooleanGet the ShortDisplay property.booleanGet the ShowIntervals property.Get the StartDate property.booleanGet the Sticky property.static TimeZoneget default time zone_more_getToolTipText(MouseEvent event) get tooltipbooleanGet the UseDateSelection property.protected voidinitialize start/end timeprotected voidinitGui()make guistatic voidmainstatic JPanelmakeButtons(ActionListener l, String[] labels) static JPanelmakeButtons(ActionListener listener, String[] labels, String[] cmds) void_more_voidvoidhandle mouse eventvoidhandle mouse eventvoidhandle mouse eventvoidhandle mouse eventvoidmouseMoved(MouseEvent me) handle mouse eventvoidhandle mouse eventvoidhandle mouse eventvoidpaintprotected voidpaint axisvoidpaint after we filled the background but before we do anything elseprotected voidpaintDateSelection(Graphics2D g, DateSelection dateSelection) paintprotected voidpaint intervalsbooleanpopup()popup timeline in a dialogvoidclear intervalsprotected voidreset(boolean doDateSelection) reset rangevoidreset to original date rangevoidreset to original date selectionvoid_more_void_more_voidsetColorTimeSelected(Color value) Set the ColorTimeSelected property.voidsetColorTimeUnselected(Color value) Set the ColorTimeUnselected property.voidset countvoidset list of thingsvoidsetDatedThings(List l, boolean andSetRange) set list of thingsstatic voidsetDateFormat(String format) set the formatvoidsetDateSelection(Date[] r) set the range of the date selectionvoidsetDateSelection(DateSelection dateSelection) Set the date selectionvoidsetEndDate(Date value) Set the EndDate property.voidset the group we're linked tovoidvoidset intervalvoidsetIsCapableOfSelection(boolean value) Set the IsCapableOfSelection property.voidset post rangevoidset pre rangevoidSet the StartDate property.void_more_voidsetSelected(List l) Set the list of selected itemsvoidsetShortDisplay(boolean value) Set the ShortDisplay property.voidsetShowIntervals(boolean value) Set the ShowIntervals property.voidset skipvoidsetStartDate(Date value) Set the StartDate property.voidsetSticky(boolean sticky) Set the Sticky property.static voidsetTimeZone(TimeZone tz) set timezonevoidsetUseDateSelection(boolean value) Set the UseDateSelection property.voidsetVisibleRange(Date[] r) set the visible rangeprotected voidshiftByPercent(double percent, boolean doDateSelection) shift left/right a percentageprotected voidshowPopupMenu(int x, int y) popup menu atvoidshow properties dialogvoidThe timeline changed.toDate(int location) map x location to dateinttoLocation(long date) map date to xinttoLocation(Date date) map date to x locationMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, 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, 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, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
CMD_APPLY
Action command used for the Apply button -
CMD_CANCEL
Action command used for the Cancel button -
CMD_OK
Action command used for the Cancel button -
CURSOR_NORMAL
The normal cursor_ -
CURSOR_MOVE
The normal cursor_ -
CURSOR_LEFT
The normal cursor_ -
CURSOR_RIGHT
The normal cursor_ -
DIM_TIME_HEIGHT
public static final int DIM_TIME_HEIGHTdrawing size- See Also:
-
DRAGMODE_LEFT
public static final int DRAGMODE_LEFTwhen dragging the date selection box what are we dragging- See Also:
-
DRAGMODE_RIGHT
public static final int DRAGMODE_RIGHTwhen dragging the date selection box what are we dragging- See Also:
-
DRAGMODE_CENTER
public static final int DRAGMODE_CENTERwhen dragging the date selection box what are we dragging- See Also:
-
sunriseDates
_more_
-
-
Constructor Details
-
Timeline
public Timeline()Default ctor -
Timeline
ctor. start and end date is the min/max of the times- Parameters:
times- List of DatedThingsinitDimension- initial width
-
Timeline
ctor. start and end date is the min/max of the times- Parameters:
times- List of DatedThingswidth- init widthheight- init height
-
Timeline
Create a Timeline with the initial date range- Parameters:
start- startend- end
-
Timeline
ctor- Parameters:
start- startend- endinitDimension- width
-
-
Method Details
-
getTimeZone
get default time zone- Returns:
- time zone
-
setDateFormat
set the format- Parameters:
format- format
-
setTimeZone
set timezone- Parameters:
tz- timezone
-
initGui
protected void initGui()make gui -
mouseMoved
handle mouse event- Specified by:
mouseMovedin interfaceMouseMotionListener- Parameters:
me- mouse event
-
mouseDragged
handle mouse event- Specified by:
mouseDraggedin interfaceMouseMotionListener- Parameters:
e- mouse event
-
mouseExited
handle mouse event- Specified by:
mouseExitedin interfaceMouseListener- Parameters:
e- mouse event
-
mouseEntered
handle mouse event- Specified by:
mouseEnteredin interfaceMouseListener- Parameters:
e- mouse event
-
mouseClicked
handle mouse event- Specified by:
mouseClickedin interfaceMouseListener- Parameters:
e- mouse event
-
mousePressed
handle mouse event- Specified by:
mousePressedin interfaceMouseListener- Parameters:
e- mouse event
-
mouseReleased
handle mouse event- Specified by:
mouseReleasedin interfaceMouseListener- Parameters:
e- mouse event
-
setDateSelection
Set the date selection- Parameters:
dateSelection- The date selection
-
getDateSelection
Get the DateSelection property.- Returns:
- The DateSelection
-
getDatedThings
Get the list of dated things we are displaying- Returns:
- List of dated things
-
setSelected
Set the list of selected items- Parameters:
l- List of selected items
-
selectedDatesChanged
public void selectedDatesChanged()_more_ -
getSelected
Get the list of selected DatedThing-s- Returns:
- The Selected things
-
init
initialize start/end time- Parameters:
start- startend- end
-
showPopupMenu
protected void showPopupMenu(int x, int y) popup menu at- Parameters:
x- xy- y
-
resetDateRange
public void resetDateRange()reset to original date range -
resetDateSelection
public void resetDateSelection()reset to original date selection -
setDateSelection
set the range of the date selection- Parameters:
r- range
-
setVisibleRange
set the visible range- Parameters:
r- The date range
-
getMenuItems
make menu items- Parameters:
items- items
-
removeIntervals
public void removeIntervals()clear intervals -
setSkipFactor
set skip- Parameters:
i- skip
-
setInterval
set interval- Parameters:
i- interval
-
setPreRange
set pre range- Parameters:
i- range
-
setPostRange
set post range- Parameters:
i- range_
-
setCount
set count- Parameters:
i- count
-
showProperties
public void showProperties()show properties dialog -
makeButtons
-
makeButtons
-
setSticky
public void setSticky(boolean sticky) Set the Sticky property.- Parameters:
sticky- The new value for Sticky
-
getSticky
public boolean getSticky()Get the Sticky property.- Returns:
- The Sticky
-
dateSelectionActive
protected boolean dateSelectionActive()are we using the date selection- Returns:
- using the date selection
-
setUseDateSelection
public void setUseDateSelection(boolean value) Set the UseDateSelection property.- Parameters:
value- The new value for UseDateSelection
-
getUseDateSelection
public boolean getUseDateSelection()Get the UseDateSelection property.- Returns:
- The UseDateSelection
-
setShowIntervals
public void setShowIntervals(boolean value) Set the ShowIntervals property.- Parameters:
value- The new value for ShowIntervals
-
getShowIntervals
public boolean getShowIntervals()Get the ShowIntervals property.- Returns:
- The ShowIntervals
-
dateSelectionChanged
protected void dateSelectionChanged()handle changed date selection -
timelineChanged
public void timelineChanged()The timeline changed. repaint, etc. -
makeSunriseDates
public void makeSunriseDates() -
selectDaytime
public void selectDaytime()_more_ -
findClosest
find closest thing- Parameters:
p- location- Returns:
- closest thing
-
findClosest
find closest thing- Parameters:
p- locationminimumDistance- within- Returns:
- closest thing
-
getToolTipLocation
_more_- Overrides:
getToolTipLocationin classJComponent- Parameters:
e- _more_- Returns:
- _more_
-
getToolTipText
get tooltip- Overrides:
getToolTipTextin classJComponent- Parameters:
event- event- Returns:
- tooltip
-
getContents
make gui- Parameters:
withButtons- add dialog buttons- Returns:
- gui
-
getContents
-
doMakeContents
protected void doMakeContents(boolean withButtons) make gui- Parameters:
withButtons- with dialog buttons
-
doMakeContents
protected void doMakeContents(boolean withButtons, boolean withBorder) -
paintDateSelection
paint- Parameters:
g- graphicsdateSelection- the date selection
-
paintIntervals
paint intervals- Parameters:
g- graphics
-
getBaseLine
protected int getBaseLine()get the axis line- Returns:
- axis line location
-
getBottom
protected int getBottom()bottom of drawing area- Returns:
- bottom
-
getLeft
protected int getLeft()left of drawing area- Returns:
- left
-
getRight
protected int getRight()right of drawing area- Returns:
- right
-
paintAxis
paint axis- Parameters:
g- graphics
-
paintBackgroundDecoration
paint after we filled the background but before we do anything else- Parameters:
g- graphics
-
paint
paint- Overrides:
paintin classJComponent- Parameters:
g- graphics
-
setHighlightedDate
-
getHighlightedDate
-
setDatedThings
set list of things- Parameters:
l- list of DatedThings
-
setGroup
set the group we're linked to- Parameters:
group- group of Timelines
-
setDatedThings
set list of things- Parameters:
l- list of DatedThingsandSetRange- also set the start/end visible range
-
format
format date- Parameters:
date- date- Returns:
- date formatted
-
getFormat
get the format to use given the size of the visible range- Returns:
- format
-
format
format time- Parameters:
time- time- Returns:
- formatted time
-
format
format time- Parameters:
time- timepattern- date format- Returns:
- formatted time
-
reset
protected void reset(boolean doDateSelection) reset range- Parameters:
doDateSelection- determines whether we reset the date selection range or the visible range
-
shiftByPercent
protected void shiftByPercent(double percent, boolean doDateSelection) shift left/right a percentage- Parameters:
percent- how muchdoDateSelection- visible or date selection
-
expandByPercent
public void expandByPercent(double percent, boolean doDateSelection) zoom- Parameters:
percent- how muchdoDateSelection- visible or date selection
-
toDate
map x location to date- Parameters:
location- x- Returns:
- date
-
toLocation
map date to x location- Parameters:
date- location- Returns:
- x
-
toLocation
public int toLocation(long date) map date to x- Parameters:
date- date- Returns:
- x
-
setRange
Set the StartDate property.- Parameters:
start- startend- end
-
makeCurrentRangeOriginal
public void makeCurrentRangeOriginal()_more_ -
setRange
_more_- Parameters:
start- _more_end- _more_makeTheseTheOriginal- _more_
-
setStartDate
Set the StartDate property.- Parameters:
value- The new value for StartDate
-
getStartDate
Get the StartDate property.- Returns:
- The StartDate
-
setEndDate
Set the EndDate property.- Parameters:
value- The new value for EndDate
-
getEndDate
Get the EndDate property.- Returns:
- The EndDate
-
popup
public boolean popup()popup timeline in a dialog- Returns:
- ok
-
main
main- Parameters:
args- args- Throws:
Exception- _more_
-
setIsCapableOfSelection
public void setIsCapableOfSelection(boolean value) Set the IsCapableOfSelection property.- Parameters:
value- The new value for IsCapableOfSelection
-
getIsCapableOfSelection
public boolean getIsCapableOfSelection()Get the IsCapableOfSelection property.- Returns:
- The IsCapableOfSelection
-
setShortDisplay
public void setShortDisplay(boolean value) Set the ShortDisplay property.- Parameters:
value- The new value for ShortDisplay
-
getShortDisplay
public boolean getShortDisplay()Get the ShortDisplay property.- Returns:
- The ShortDisplay
-
setColorTimeSelected
Set the ColorTimeSelected property.- Parameters:
value- The new value for ColorTimeSelected
-
getColorTimeSelected
Get the ColorTimeSelected property.- Returns:
- The ColorTimeSelected
-
setColorTimeUnselected
Set the ColorTimeUnselected property.- Parameters:
value- The new value for ColorTimeUnselected
-
getColorTimeUnselected
Get the ColorTimeUnselected property.- Returns:
- The ColorTimeUnselected
-