jview
Class JChronology

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 jview.JChronology
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Initializable, PropertyAware, PropertyComposed, Refreshing
Direct Known Subclasses:
JAllskyChronology

public class JChronology
extends JPanel
implements PropertyComposed, Refreshing, Initializable

A component that displays component in a chronological order.

See Also:
Serialized Form

Nested Class Summary
private  class JChronology.ReplayThread
          A replay thread takes a list of componts and displays them until stopped.
static class JChronology.Show
          Test class that reads a properties file and constructs a image chronology out of it.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  SortedMap<Date,Component> cache
          The cache table linking times to components.
private  DisplayChronology chronos
          The object that provides me with components.
private static int DEFCACHESIZE
          Default cache size.
private static boolean DEFINCLUDEBORDER
          Default include border.
private static int DEFMAXLOOPS
          Default replay delay.
private static long DEFREPLAYDELAY
          Default replay delay.
private static boolean DEFREPLAYONCLICK
           
private static long DEFRESTARTDELAY
          Default replay delay.
private static String DEFTIMEZONE
          Default time zone.
private static DateFormat DEFTOOLTIPDATE
          Default tool tip format.
private  PropertyBearing info
          The properties of this component.
static String KEY_CACHESIZE
          The maximum number of items cached in chronological order.
static String KEY_CHRONOLOGY
          If given, properties the chronology can be instantiated from.
static String KEY_INCLUDEBORDER
          If true, on replays we also include the objects just prior and after.
static String KEY_MAINREFRESH
          The main refresh rate.
static String KEY_MAXLOOPS
          On replay the maximum number of rewinds.
static String KEY_PREFERREDHEIGHT
          A key to the preferred height of this component.
static String KEY_PREFERREDWIDTH
          A key to the preferred width of this component.
static String KEY_REPLAYDELAY
          On replay options the wait between components update.
static String KEY_REPLAYONCLICK
           
static String KEY_RESTARTDELAY
          On replay options the wait between components update.
static String KEY_TIMEZONE
          How the fetch time should be formatted.
static String KEY_TOOLTIP
          If set, the tooltip text to be displayed plust the fetch time.
static String KEY_TOOLTIPDATE
          How the fetch time should be formatted.
private  long lastfetch
          The last time we tried to fetch a component.
private  boolean noendplay
          If true, pictures fetched are added to the playlist.
private  JChronology.ReplayThread playing
          The thread that replays cached components.
private  boolean push
          If true, we display components as fast as delivered.
 
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
JChronology(Map<String,String> prop)
          Construct a new panel that can be used for displaying chronologically updated components.
JChronology(PropertyBearing prop)
          Construct a new panel that can be used for displaying chronologically updated components.
 
Method Summary
private  List<Component> derivePlayList(Date from, Date to, boolean addedge)
          We traverse our cache to find the list of components we want to play.
private  void fetchComponent()
          We try to fetch a component.
 PropertyBearing getComposedProperties()
          Returns my composed properties.
 DisplayChronology getDisplayChronology()
          Returns the currently served component chronology.
 Dimension getPreferredSize()
          Returns the preferred size of this component.
 long getRefreshInterval()
          The default update frequency is the frequency at which the chronology can deliver.
 void init()
          Inits the chronology.
 boolean isFixedRate()
          We are fixed rate.
 boolean isPlaying()
          Returns true if we are currently playing.
 void refresh()
          This method is normally called at higher frequencies than we actually want to request new components.
 void setComposedProperties(PropertyBearing prop)
          Sets the composed properties and defaults some values.
 void setDisplayChronology(DisplayChronology webcam)
          This sets the chronologically delivering components object.
 void startReplay()
          We start a reply of cached componts.
 void startReplay(Date from, Date to)
          We start a replay between the two dates specified.
protected  void startReplay(List<Component> movie)
          The class that directly takes the list of components that should be displayed in the movie.
protected  void startReplay(List<Component> movie, int loops)
          The class that directly takes the list of components that should be displayed in the movie.
 void stopReplay()
          We stop the replay if we are currently playing.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods 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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, 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, 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

KEY_MAINREFRESH

public static final String KEY_MAINREFRESH
The main refresh rate. Lower than the ComponentChronolgy's.

See Also:
Constant Field Values

KEY_CHRONOLOGY

public static final String KEY_CHRONOLOGY
If given, properties the chronology can be instantiated from.

See Also:
Constant Field Values

KEY_CACHESIZE

public static final String KEY_CACHESIZE
The maximum number of items cached in chronological order.

See Also:
Constant Field Values

KEY_MAXLOOPS

public static final String KEY_MAXLOOPS
On replay the maximum number of rewinds.

See Also:
Constant Field Values

KEY_REPLAYDELAY

public static final String KEY_REPLAYDELAY
On replay options the wait between components update.

See Also:
Constant Field Values

KEY_RESTARTDELAY

public static final String KEY_RESTARTDELAY
On replay options the wait between components update.

See Also:
Constant Field Values

KEY_TOOLTIP

public static final String KEY_TOOLTIP
If set, the tooltip text to be displayed plust the fetch time.

See Also:
Constant Field Values

KEY_TOOLTIPDATE

public static final String KEY_TOOLTIPDATE
How the fetch time should be formatted.

See Also:
Constant Field Values

KEY_TIMEZONE

public static final String KEY_TIMEZONE
How the fetch time should be formatted.

See Also:
Constant Field Values

KEY_INCLUDEBORDER

public static final String KEY_INCLUDEBORDER
If true, on replays we also include the objects just prior and after.

See Also:
Constant Field Values

KEY_PREFERREDWIDTH

public static final String KEY_PREFERREDWIDTH
A key to the preferred width of this component.

See Also:
Constant Field Values

KEY_PREFERREDHEIGHT

public static final String KEY_PREFERREDHEIGHT
A key to the preferred height of this component.

See Also:
Constant Field Values

KEY_REPLAYONCLICK

public static final String KEY_REPLAYONCLICK
See Also:
Constant Field Values

DEFCACHESIZE

private static final int DEFCACHESIZE
Default cache size.

See Also:
Constant Field Values

DEFMAXLOOPS

private static final int DEFMAXLOOPS
Default replay delay.

See Also:
Constant Field Values

DEFREPLAYDELAY

private static final long DEFREPLAYDELAY
Default replay delay.

See Also:
Constant Field Values

DEFRESTARTDELAY

private static final long DEFRESTARTDELAY
Default replay delay.

See Also:
Constant Field Values

DEFINCLUDEBORDER

private static final boolean DEFINCLUDEBORDER
Default include border.

See Also:
Constant Field Values

DEFTIMEZONE

private static final String DEFTIMEZONE
Default time zone.

See Also:
Constant Field Values

DEFREPLAYONCLICK

private static final boolean DEFREPLAYONCLICK
See Also:
Constant Field Values

DEFTOOLTIPDATE

private static final DateFormat DEFTOOLTIPDATE
Default tool tip format.


info

private PropertyBearing info
The properties of this component.


chronos

private DisplayChronology chronos
The object that provides me with components.


cache

private SortedMap<Date,Component> cache
The cache table linking times to components.


push

private boolean push
If true, we display components as fast as delivered.


lastfetch

private long lastfetch
The last time we tried to fetch a component.


noendplay

private boolean noendplay
If true, pictures fetched are added to the playlist.


playing

private JChronology.ReplayThread playing
The thread that replays cached components.

Constructor Detail

JChronology

public JChronology(Map<String,String> prop)
Construct a new panel that can be used for displaying chronologically updated components.


JChronology

public JChronology(PropertyBearing prop)
Construct a new panel that can be used for displaying chronologically updated components.

Method Detail

init

public void init()
Inits the chronology.

Specified by:
init in interface Initializable

setComposedProperties

public void setComposedProperties(PropertyBearing prop)
Sets the composed properties and defaults some values.

Specified by:
setComposedProperties in interface PropertyAware

getComposedProperties

public PropertyBearing getComposedProperties()
Returns my composed properties.

Specified by:
getComposedProperties in interface PropertyComposed

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of this component. If it is not set explicetly in the properties, we return the saize of the background image. If we do not have such an image, we return the parent's preferred size.

Overrides:
getPreferredSize in class JComponent

getRefreshInterval

public long getRefreshInterval()
The default update frequency is the frequency at which the chronology can deliver. Normally, we will not always request a new component, only if our main frame rate has passed. In server push mode, however, we will request components as they get in.

Specified by:
getRefreshInterval in interface Refreshing

isFixedRate

public boolean isFixedRate()
We are fixed rate.

Specified by:
isFixedRate in interface Refreshing
See Also:
Timer

refresh

public void refresh()
This method is normally called at higher frequencies than we actually want to request new components. Thus, if we are not pushed, we first check if we want an update by comparing the last update time with the current time. If this time span is higher than KEY_MAINREFRESH, than we update.

Specified by:
refresh in interface Refreshing

fetchComponent

private void fetchComponent()
We try to fetch a component. We always update the last fetch time to reflect the current time. If our chronology component can deliver, we ask it for the component, otherwise we return. If a component was fetched, we update our display if not in play mode. If in play mode, we revalidate our play list.


setDisplayChronology

public void setDisplayChronology(DisplayChronology webcam)
This sets the chronologically delivering components object.


getDisplayChronology

public DisplayChronology getDisplayChronology()
Returns the currently served component chronology.


isPlaying

public boolean isPlaying()
Returns true if we are currently playing.


stopReplay

public void stopReplay()
We stop the replay if we are currently playing.


startReplay

public void startReplay()
We start a reply of cached componts. This method uses the entire cache.


startReplay

public void startReplay(Date from,
                        Date to)
We start a replay between the two dates specified. Depending on the KEY_INCLUDEBORDER property, we either include the component that is just before the stated date or not. If any of the start or end dates is null, we include all that there is in cache.


startReplay

protected void startReplay(List<Component> movie)
The class that directly takes the list of components that should be displayed in the movie.


startReplay

protected void startReplay(List<Component> movie,
                           int loops)
The class that directly takes the list of components that should be displayed in the movie.


derivePlayList

private List<Component> derivePlayList(Date from,
                                       Date to,
                                       boolean addedge)
We traverse our cache to find the list of components we want to play. Submaps are not feasible here, we want a play list!