pamScrollSystem
Class AbstractPamScroller

java.lang.Object
  extended by pamScrollSystem.AbstractPamScroller
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
PamScroller, PamScrollSlider, ScrollPaneAddon

public abstract class AbstractPamScroller
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Nested Class Summary
private  class AbstractPamScroller.MenuButtonMouse
           
(package private)  class AbstractPamScroller.MouseWheel
           
(package private)  class AbstractPamScroller.PageBackAction
           
(package private)  class AbstractPamScroller.PageForwardAction
           
(package private)  class AbstractPamScroller.ShowMenuButtonPress
           
 
Field Summary
private  javax.swing.JPanel buttonPanel
           
static int HORIZONTAL
           
(package private)  java.awt.Color iconFill
           
(package private)  java.awt.Color iconLine
           
private  boolean needsNotify
           
protected  java.util.Vector<PamScrollObserver> observers
           
private  javax.swing.JButton pageBack
           
private  javax.swing.JButton pageForward
           
private  ScrollerCoupling scrollerCoupling
           
protected  PamScrollerData scrollerData
           
private  AbstractScrollManager scrollManager
          reference to the global scroll manager.
private static long serialVersionUID
           
private  javax.swing.JButton showMenu
           
protected  java.util.Vector<PamDataBlock> usedDataBlocks
           
static int VERTICAL
           
 
Constructor Summary
AbstractPamScroller(java.lang.String name, int orientation, int stepSizeMillis, long defaultLoadTime, boolean hasMenu)
           
 
Method Summary
 void addDataBlock(PamDataBlock dataBlock)
          Add a datablock to the list for this scroller.
 void addMouseWheelSource(java.awt.Component component)
          Add a component to the scrollers mouse wheel listener.
 void addObserver(PamScrollObserver pamScrollObserver)
          Ad an observer that will receive notifications when the the scroller moves.
abstract  void anotherScrollerMovedInner(long newValue)
          Another managed scroller moved it's position
 void anotherScrollerMovedOuter(long newMin, long newMax)
          Another managed scroller moved its outer position - will cause new data to be loaded.
 void coupledScrollerChanged(AbstractPamScroller scroller)
          Called when a scroller which is coupled to this scroller changes in any way.
 ScrollerCoupling coupleScroller(java.lang.String couplingName)
          Couple this scroller to another scroller so that both have exactly the same behaviour, load the same data period, move their scrolls together, etc.
 void destroyScroller()
           
(package private) abstract  void doMouseWheelAction(java.awt.event.MouseWheelEvent mouseWheelEvent)
           
protected  javax.swing.JPanel getButtonPanel()
           
abstract  javax.swing.JComponent getComponent()
           
protected  long getDefaultLoadtime()
           
 long getMaximumMillis()
           
 long getMinimumMillis()
           
 int getNumUsedDataBlocks()
           
 java.util.Vector<PamScrollObserver> getObservers()
           
 int getPageStep()
           
 long getRangeMillis()
           
 ScrollerCoupling getScrollerCoupling()
           
 AbstractScrollManager getScrollManager()
           
 int getStepSizeMillis()
          stepSizeMillis is the resolution of the scroller in milliseconds.
 PamDataBlock getUsedDataBlock(int iBlock)
          Get a specific data block observed by this scroller.
abstract  long getValueMillis()
           
 boolean isDataBlockUsed(PamDataBlock dataBlock)
          See if this scroller is using a particular data block
protected  void menuButtonPress()
           
private  void notifyCoupledScrollers()
          Tell other scrollers coupled to this one that there has been a change
protected  void notifyRangeChange()
          Send a notification to all observers of this scroller to say that the range of data loaded has changed.
protected  void notifyValueChange()
          Send notification to all observers of this scroll bar to say that the value set by the slider in the scroll bar has changed.
protected  void pageBack()
           
protected  void pageForward()
           
abstract  void rangesChanged(long setValue)
          Called when ranges have been changed and tells scroller to go to a particular absolute value.
private  void rangesChangedF(long setValue)
          called when the set range is changed with a flag to send out a notification.
 void reLoad()
          Command passed through the the scroll manager telling it reload data.
 void removeDataBlock(PamDataBlock dataBlock)
          Remove a datablock from the viewed list.
 void removeObserver(PamScrollObserver pamScrollObserver)
          Remove an observer which no longer requires notifications when the scroller moves.
 void setBlockIncrement(long blockIncrement)
           
protected  void setDefaultLoadtime(long defaultLoadtime)
           
 void setPageStep(int pageStep)
           
 void setRangeMillis(long minimumMillis, long maximumMillis, boolean notify)
          Set the range of the currently loaded data and optionally noitify other scrollers.
 void setScrollerCoupling(ScrollerCoupling scrollerCoupling)
           
 void setStepSizeMillis(int stepSizeMillis)
           
 void setUnitIncrement(long unitIncrement)
           
 void setValueMillis(long valueMillis)
           
 void setVisible(boolean b)
          Set the visibility of the scroll bar component.
 void setVisibleAmount(long visibleAmount)
           
(package private)  void showMenuButtonPopup(java.awt.event.MouseEvent me)
          Show standard menu for mouse right click on the middle options button.
 void uncoupleScroller()
          Remove the scroller from it's coupling.
abstract  void valueSetMillis(long valueMillis)
          Called when a new position has been set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
See Also:
Constant Field Values

observers

protected transient java.util.Vector<PamScrollObserver> observers

usedDataBlocks

protected transient java.util.Vector<PamDataBlock> usedDataBlocks

scrollerData

protected PamScrollerData scrollerData

scrollManager

private AbstractScrollManager scrollManager
reference to the global scroll manager.


pageForward

private javax.swing.JButton pageForward

pageBack

private javax.swing.JButton pageBack

showMenu

private javax.swing.JButton showMenu

buttonPanel

private javax.swing.JPanel buttonPanel

needsNotify

private boolean needsNotify

scrollerCoupling

private ScrollerCoupling scrollerCoupling

iconLine

java.awt.Color iconLine

iconFill

java.awt.Color iconFill
Constructor Detail

AbstractPamScroller

public AbstractPamScroller(java.lang.String name,
                           int orientation,
                           int stepSizeMillis,
                           long defaultLoadTime,
                           boolean hasMenu)
Method Detail

getComponent

public abstract javax.swing.JComponent getComponent()
Returns:
the Swing component to go into the GUI.

addMouseWheelSource

public void addMouseWheelSource(java.awt.Component component)
Add a component to the scrollers mouse wheel listener. All mouse wheel actions over that component will then be sent to the scroller for processing.

Parameters:
component - component

doMouseWheelAction

abstract void doMouseWheelAction(java.awt.event.MouseWheelEvent mouseWheelEvent)

getButtonPanel

protected javax.swing.JPanel getButtonPanel()
Returns:
the buttonPanel

showMenuButtonPopup

void showMenuButtonPopup(java.awt.event.MouseEvent me)
Show standard menu for mouse right click on the middle options button.

Concrete instances of the scroller can either override this or add to the standard menu

Parameters:
me - Mouse event

pageForward

protected void pageForward()

pageBack

protected void pageBack()

menuButtonPress

protected void menuButtonPress()

destroyScroller

public void destroyScroller()

addObserver

public void addObserver(PamScrollObserver pamScrollObserver)
Ad an observer that will receive notifications when the the scroller moves.

Parameters:
pamScrollObserver -

removeObserver

public void removeObserver(PamScrollObserver pamScrollObserver)
Remove an observer which no longer requires notifications when the scroller moves.

Parameters:
pamScrollObserver -

addDataBlock

public void addDataBlock(PamDataBlock dataBlock)
Add a datablock to the list for this scroller.

When the scroller is moved, data from data blocks in this list will re read from the database and binary stores. Other data will not be read.

Parameters:
dataBlock - a PamDataBlock

removeDataBlock

public void removeDataBlock(PamDataBlock dataBlock)
Remove a datablock from the viewed list.

Parameters:
dataBlock - a PamDataBlock

isDataBlockUsed

public boolean isDataBlockUsed(PamDataBlock dataBlock)
See if this scroller is using a particular data block

Parameters:
dataBlock - a Pamguard data block
Returns:
true if it's being used.

anotherScrollerMovedInner

public abstract void anotherScrollerMovedInner(long newValue)
Another managed scroller moved it's position

Parameters:
newValue - new value in millis

anotherScrollerMovedOuter

public void anotherScrollerMovedOuter(long newMin,
                                      long newMax)
Another managed scroller moved its outer position - will cause new data to be loaded.

Parameters:
newMin -
newMax -

notifyValueChange

protected void notifyValueChange()
Send notification to all observers of this scroll bar to say that the value set by the slider in the scroll bar has changed.


notifyRangeChange

protected void notifyRangeChange()
Send a notification to all observers of this scroller to say that the range of data loaded has changed.


getMinimumMillis

public long getMinimumMillis()
Returns:
the minimumMillis

getMaximumMillis

public long getMaximumMillis()
Returns:
the maximumMillis

getRangeMillis

public long getRangeMillis()
Returns:
the difference between getMaximumMills and getMinimumMillis

setRangeMillis

public void setRangeMillis(long minimumMillis,
                           long maximumMillis,
                           boolean notify)
Set the range of the currently loaded data and optionally noitify other scrollers.

Parameters:
minimumMillis - minimum time in milliseconds
maximumMillis - maximum time in milliseconds
notify - notify the rangesChanged function.

rangesChangedF

private final void rangesChangedF(long setValue)
called when the set range is changed with a flag to send out a notification. Does some things that must be done, but also calls an abstract setRanges in order that specific scrollers can update their scrolling component.

Parameters:
setValue - scroller position in milliseconds.

rangesChanged

public abstract void rangesChanged(long setValue)
Called when ranges have been changed and tells scroller to go to a particular absolute value.

Parameters:
setValue -

reLoad

public void reLoad()
Command passed through the the scroll manager telling it reload data.


getValueMillis

public abstract long getValueMillis()
Returns:
the valueMillis

setValueMillis

public final void setValueMillis(long valueMillis)
Parameters:
valueMillis - the valueMillis to set

valueSetMillis

public abstract void valueSetMillis(long valueMillis)
Called when a new position has been set

Parameters:
valueMillis - new scroll value in milliseconds

getStepSizeMillis

public int getStepSizeMillis()
stepSizeMillis is the resolution of the scroller in milliseconds.

For displays which will only ever display a short amount of data this can be one, however for longer displays this should be 1000 (a second) or more to avoid wrap around of the 32 bit integers used to control the actual scroll bar.

Returns:
the stepSizeMillis

setStepSizeMillis

public void setStepSizeMillis(int stepSizeMillis)
Parameters:
stepSizeMillis - the stepSizeMillis to set

setBlockIncrement

public void setBlockIncrement(long blockIncrement)
Parameters:
blockIncrement - the blockIncrement to set in millis

setUnitIncrement

public void setUnitIncrement(long unitIncrement)
Parameters:
unitIncrement - the unitIncrement to set in millis

setVisibleAmount

public void setVisibleAmount(long visibleAmount)
Parameters:
visibleAmount - the visibleAmount to set in millis

getObservers

public java.util.Vector<PamScrollObserver> getObservers()
Returns:
the observers

getPageStep

public int getPageStep()
Returns:
the pageStep

setPageStep

public void setPageStep(int pageStep)
Parameters:
pageStep - the pageStep to set

getDefaultLoadtime

protected long getDefaultLoadtime()

setDefaultLoadtime

protected void setDefaultLoadtime(long defaultLoadtime)

getScrollManager

public AbstractScrollManager getScrollManager()
Returns:
the scrollManager

setVisible

public void setVisible(boolean b)
Set the visibility of the scroll bar component.

Parameters:
b -

coupleScroller

public ScrollerCoupling coupleScroller(java.lang.String couplingName)
Couple this scroller to another scroller so that both have exactly the same behaviour, load the same data period, move their scrolls together, etc.

Scollers are coupled by name so that they don't necessarily need to find references to each other in the code. These names can be anything by measures should be taken to ensure that they are going to be unique, for example by using module names as part of the coupling name.

Parameters:
couplingName - name of the coupling
Returns:
number of other scrollers in this coupling

uncoupleScroller

public void uncoupleScroller()
Remove the scroller from it's coupling.


getScrollerCoupling

public ScrollerCoupling getScrollerCoupling()

setScrollerCoupling

public void setScrollerCoupling(ScrollerCoupling scrollerCoupling)

coupledScrollerChanged

public void coupledScrollerChanged(AbstractPamScroller scroller)
Called when a scroller which is coupled to this scroller changes in any way.

Parameters:
scroller - coupled scroller which changes.

notifyCoupledScrollers

private void notifyCoupledScrollers()
Tell other scrollers coupled to this one that there has been a change


getNumUsedDataBlocks

public int getNumUsedDataBlocks()
Returns:
the number of data blocks observed by this scroller

getUsedDataBlock

public PamDataBlock getUsedDataBlock(int iBlock)
Get a specific data block observed by this scroller.

Parameters:
iBlock - block index
Returns:
reference to an observed datablock