Class Timeline

All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
IdvTimeline

public class Timeline extends JPanel implements MouseListener, MouseMotionListener
Widget for selecting dates and times
Version:
$Revision: 1.36 $
Author:
IDV Development Team
See Also:
  • Field Details

    • CMD_APPLY

      public static String CMD_APPLY
      Action command used for the Apply button
    • CMD_CANCEL

      public static String CMD_CANCEL
      Action command used for the Cancel button
    • CMD_OK

      public static String CMD_OK
      Action command used for the Cancel button
    • CURSOR_NORMAL

      public static final Cursor CURSOR_NORMAL
      The normal cursor_
    • CURSOR_MOVE

      public static final Cursor CURSOR_MOVE
      The normal cursor_
    • CURSOR_LEFT

      public static final Cursor CURSOR_LEFT
      The normal cursor_
    • CURSOR_RIGHT

      public static final Cursor CURSOR_RIGHT
      The normal cursor_
    • DIM_TIME_HEIGHT

      public static final int DIM_TIME_HEIGHT
      drawing size
      See Also:
    • DRAGMODE_LEFT

      public static final int DRAGMODE_LEFT
      when dragging the date selection box what are we dragging
      See Also:
    • DRAGMODE_RIGHT

      public static final int DRAGMODE_RIGHT
      when dragging the date selection box what are we dragging
      See Also:
    • DRAGMODE_CENTER

      public static final int DRAGMODE_CENTER
      when dragging the date selection box what are we dragging
      See Also:
    • sunriseDates

      protected List sunriseDates
      _more_
  • Constructor Details

    • Timeline

      public Timeline()
      Default ctor
    • Timeline

      public Timeline(List times, int initDimension)
      ctor. start and end date is the min/max of the times
      Parameters:
      times - List of DatedThings
      initDimension - initial width
    • Timeline

      public Timeline(List times, int width, int height)
      ctor. start and end date is the min/max of the times
      Parameters:
      times - List of DatedThings
      width - init width
      height - init height
    • Timeline

      public Timeline(Date start, Date end)
      Create a Timeline with the initial date range
      Parameters:
      start - start
      end - end
    • Timeline

      public Timeline(Date start, Date end, int initDimension)
      ctor
      Parameters:
      start - start
      end - end
      initDimension - width
  • Method Details

    • getTimeZone

      public static TimeZone getTimeZone()
      get default time zone
      Returns:
      time zone
    • setDateFormat

      public static void setDateFormat(String format)
      set the format
      Parameters:
      format - format
    • setTimeZone

      public static void setTimeZone(TimeZone tz)
      set timezone
      Parameters:
      tz - timezone
    • initGui

      protected void initGui()
      make gui
    • mouseMoved

      public void mouseMoved(MouseEvent me)
      handle mouse event
      Specified by:
      mouseMoved in interface MouseMotionListener
      Parameters:
      me - mouse event
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      handle mouse event
      Specified by:
      mouseDragged in interface MouseMotionListener
      Parameters:
      e - mouse event
    • mouseExited

      public void mouseExited(MouseEvent e)
      handle mouse event
      Specified by:
      mouseExited in interface MouseListener
      Parameters:
      e - mouse event
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      handle mouse event
      Specified by:
      mouseEntered in interface MouseListener
      Parameters:
      e - mouse event
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      handle mouse event
      Specified by:
      mouseClicked in interface MouseListener
      Parameters:
      e - mouse event
    • mousePressed

      public void mousePressed(MouseEvent e)
      handle mouse event
      Specified by:
      mousePressed in interface MouseListener
      Parameters:
      e - mouse event
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      handle mouse event
      Specified by:
      mouseReleased in interface MouseListener
      Parameters:
      e - mouse event
    • setDateSelection

      public void setDateSelection(DateSelection dateSelection)
      Set the date selection
      Parameters:
      dateSelection - The date selection
    • getDateSelection

      public DateSelection getDateSelection()
      Get the DateSelection property.
      Returns:
      The DateSelection
    • getDatedThings

      public List getDatedThings()
      Get the list of dated things we are displaying
      Returns:
      List of dated things
    • setSelected

      public void setSelected(List l)
      Set the list of selected items
      Parameters:
      l - List of selected items
    • selectedDatesChanged

      public void selectedDatesChanged()
      _more_
    • getSelected

      public List getSelected()
      Get the list of selected DatedThing-s
      Returns:
      The Selected things
    • init

      protected void init(Date start, Date end)
      initialize start/end time
      Parameters:
      start - start
      end - end
    • showPopupMenu

      protected void showPopupMenu(int x, int y)
      popup menu at
      Parameters:
      x - x
      y - y
    • resetDateRange

      public void resetDateRange()
      reset to original date range
    • resetDateSelection

      public void resetDateSelection()
      reset to original date selection
    • setDateSelection

      public void setDateSelection(Date[] r)
      set the range of the date selection
      Parameters:
      r - range
    • setVisibleRange

      public void setVisibleRange(Date[] r)
      set the visible range
      Parameters:
      r - The date range
    • getMenuItems

      protected void getMenuItems(List items)
      make menu items
      Parameters:
      items - items
    • removeIntervals

      public void removeIntervals()
      clear intervals
    • setSkipFactor

      public void setSkipFactor(Integer i)
      set skip
      Parameters:
      i - skip
    • setInterval

      public void setInterval(Double i)
      set interval
      Parameters:
      i - interval
    • setPreRange

      public void setPreRange(Double i)
      set pre range
      Parameters:
      i - range
    • setPostRange

      public void setPostRange(Double i)
      set post range
      Parameters:
      i - range_
    • setCount

      public void setCount(Integer i)
      set count
      Parameters:
      i - count
    • showProperties

      public void showProperties()
      show properties dialog
    • makeButtons

      public static JPanel makeButtons(ActionListener l, String[] labels)
    • makeButtons

      public static JPanel makeButtons(ActionListener listener, String[] labels, String[] cmds)
    • 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

      protected DatedThing findClosest(Point p)
      find closest thing
      Parameters:
      p - location
      Returns:
      closest thing
    • findClosest

      protected DatedThing findClosest(Point p, int minimumDistance)
      find closest thing
      Parameters:
      p - location
      minimumDistance - within
      Returns:
      closest thing
    • getToolTipLocation

      public Point getToolTipLocation(MouseEvent e)
      _more_
      Overrides:
      getToolTipLocation in class JComponent
      Parameters:
      e - _more_
      Returns:
      _more_
    • getToolTipText

      public String getToolTipText(MouseEvent event)
      get tooltip
      Overrides:
      getToolTipText in class JComponent
      Parameters:
      event - event
      Returns:
      tooltip
    • getContents

      public JComponent getContents(boolean withButtons)
      make gui
      Parameters:
      withButtons - add dialog buttons
      Returns:
      gui
    • getContents

      public JComponent getContents(boolean withButtons, boolean withBorder)
    • doMakeContents

      protected void doMakeContents(boolean withButtons)
      make gui
      Parameters:
      withButtons - with dialog buttons
    • doMakeContents

      protected void doMakeContents(boolean withButtons, boolean withBorder)
    • paintDateSelection

      protected void paintDateSelection(Graphics2D g, DateSelection dateSelection)
      paint
      Parameters:
      g - graphics
      dateSelection - the date selection
    • paintIntervals

      protected void paintIntervals(Graphics2D g)
      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

      protected void paintAxis(Graphics2D g)
      paint axis
      Parameters:
      g - graphics
    • paintBackgroundDecoration

      public void paintBackgroundDecoration(Graphics2D g)
      paint after we filled the background but before we do anything else
      Parameters:
      g - graphics
    • paint

      public void paint(Graphics g)
      paint
      Overrides:
      paint in class JComponent
      Parameters:
      g - graphics
    • setHighlightedDate

      public void setHighlightedDate(DatedThing d)
    • getHighlightedDate

      public DatedThing getHighlightedDate()
    • setDatedThings

      public void setDatedThings(List l)
      set list of things
      Parameters:
      l - list of DatedThings
    • setGroup

      public void setGroup(List group)
      set the group we're linked to
      Parameters:
      group - group of Timelines
    • setDatedThings

      public void setDatedThings(List l, boolean andSetRange)
      set list of things
      Parameters:
      l - list of DatedThings
      andSetRange - also set the start/end visible range
    • format

      public String format(Date date)
      format date
      Parameters:
      date - date
      Returns:
      date formatted
    • getFormat

      public String getFormat()
      get the format to use given the size of the visible range
      Returns:
      format
    • format

      public String format(long time)
      format time
      Parameters:
      time - time
      Returns:
      formatted time
    • format

      public String format(long time, String pattern)
      format time
      Parameters:
      time - time
      pattern - 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 much
      doDateSelection - visible or date selection
    • expandByPercent

      public void expandByPercent(double percent, boolean doDateSelection)
      zoom
      Parameters:
      percent - how much
      doDateSelection - visible or date selection
    • toDate

      public Date toDate(int location)
      map x location to date
      Parameters:
      location - x
      Returns:
      date
    • toLocation

      public int toLocation(Date date)
      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

      public void setRange(Date start, Date end)
      Set the StartDate property.
      Parameters:
      start - start
      end - end
    • makeCurrentRangeOriginal

      public void makeCurrentRangeOriginal()
      _more_
    • setRange

      public void setRange(Date start, Date end, boolean makeTheseTheOriginal)
      _more_
      Parameters:
      start - _more_
      end - _more_
      makeTheseTheOriginal - _more_
    • setStartDate

      public void setStartDate(Date value)
      Set the StartDate property.
      Parameters:
      value - The new value for StartDate
    • getStartDate

      public Date getStartDate()
      Get the StartDate property.
      Returns:
      The StartDate
    • setEndDate

      public void setEndDate(Date value)
      Set the EndDate property.
      Parameters:
      value - The new value for EndDate
    • getEndDate

      public Date getEndDate()
      Get the EndDate property.
      Returns:
      The EndDate
    • popup

      public boolean popup()
      popup timeline in a dialog
      Returns:
      ok
    • main

      public static void main(String[] args) throws Exception
      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

      public void setColorTimeSelected(Color value)
      Set the ColorTimeSelected property.
      Parameters:
      value - The new value for ColorTimeSelected
    • getColorTimeSelected

      public Color getColorTimeSelected()
      Get the ColorTimeSelected property.
      Returns:
      The ColorTimeSelected
    • setColorTimeUnselected

      public void setColorTimeUnselected(Color value)
      Set the ColorTimeUnselected property.
      Parameters:
      value - The new value for ColorTimeUnselected
    • getColorTimeUnselected

      public Color getColorTimeUnselected()
      Get the ColorTimeUnselected property.
      Returns:
      The ColorTimeUnselected