gov.noaa.pmel.sgt.demo
Class PseudoRealTimeData

java.lang.Object
  |
  +--gov.noaa.pmel.sgt.demo.PseudoRealTimeData
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, SGTData, SGTLine

public class PseudoRealTimeData
extends java.lang.Object
implements SGTLine, java.awt.event.ActionListener

Generates a real-time data stream using SGTLine and javax.swing.Timer. PseudoRealTimeData generates PropertyCchangeEvents whenever data is added "dataModified" or the data range changes "rangeModified". The "dataModified" event is directly handled by sgt and the "rangeModified" event needs to be handled by the graphics application.

PseudoRealTimeData demonstrates how a class that implements the SGTLine interface can use the getXRange() and getYRange() methods to produce "nice" plots. This class updates the data each time step, but updates the range only after a day has passed.

Since:
2.0
Version:
$Revision: 1.6 $, $Date: 2001/12/13 19:07:05 $
Author:
Donald Denbo

Constructor Summary
PseudoRealTimeData(java.lang.String id, java.lang.String title)
          Constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handle timer ActionEvents
Property Change: rangeModified and DataModified
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a PropertyChangeListener to the listener list.
 SGTData copy()
          Create a shallow copy.
 SGTLine getAssociatedData()
          Get the associated data.
 java.lang.String getId()
          Get the unique identifier.
 SGLabel getKeyTitle()
          Get a title formatted for a Key.
 GeoDate[] getTimeArray()
          Get the array of Time values.
 java.lang.String getTitle()
          Get the title.
 double[] getXArray()
          Get x data array.
 SGTMetaData getXMetaData()
          Returns the X SGTMetaData.
 SoTRange getXRange()
          Returns the range of the X coordinates.
 double[] getYArray()
          Get y data values.
 SGTMetaData getYMetaData()
          Returns the Y SGTMetaData.
 SoTRange getYRange()
          Returns the range of the Y coordinates.
 boolean hasAssociatedData()
          Is there associated data available?
 boolean isXTime()
          Returns true if the X coordinate is Time.
 boolean isYTime()
          Returns true if the Y coordinate is Time.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a PropertyChangeListener from the listener list.
 void resetData()
          Reset the demonstration to the begining.
 void startData()
          Start the timer and begin/continue generating property change events.
 void stopData()
          Stop the timer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PseudoRealTimeData

public PseudoRealTimeData(java.lang.String id,
                          java.lang.String title)
Constructor.
Method Detail

getXArray

public double[] getXArray()
Get x data array. Always returns null.
Specified by:
getXArray in interface SGTLine

getYArray

public double[] getYArray()
Get y data values. Creates a copy of the buffer array.
Specified by:
getYArray in interface SGTLine

getTimeArray

public GeoDate[] getTimeArray()
Description copied from interface: SGTLine
Get the array of Time values.
Specified by:
getTimeArray in interface SGTLine

getAssociatedData

public SGTLine getAssociatedData()
Description copied from interface: SGTLine
Get the associated data. The associated data must be of the same type (SGTLine) and length. The Y array will be used.
Specified by:
getAssociatedData in interface SGTLine

hasAssociatedData

public boolean hasAssociatedData()
Description copied from interface: SGTLine
Is there associated data available?
Specified by:
hasAssociatedData in interface SGTLine

getTitle

public java.lang.String getTitle()
Description copied from interface: SGTData
Get the title.
Specified by:
getTitle in interface SGTData

getKeyTitle

public SGLabel getKeyTitle()
Description copied from interface: SGTData
Get a title formatted for a Key. JPlotLayout will use this if an explicit Key title is not given in the addData method.
Specified by:
getKeyTitle in interface SGTData
Following copied from interface: gov.noaa.pmel.sgt.dm.SGTData
See Also:
SGLabel, ColorKey, LineKey, PointCollectionKey, VectorKey

getId

public java.lang.String getId()
Description copied from interface: SGTData
Get the unique identifier. The presence of the identifier is optional, but if it is present it should be unique. This field is used to search for the layer that contains the data.
Specified by:
getId in interface SGTData
Following copied from interface: gov.noaa.pmel.sgt.dm.SGTData
Returns:
unique identifier
See Also:
Pane, Layer

copy

public SGTData copy()
Description copied from interface: SGTData
Create a shallow copy. User should implement using the clone() method, which requires the Cloneable interface be inherited. If clone() is used, then references to objects are copied NOT the object itself.

For example,

 public SGTData copy() {
   SGTData newData;
   try {
     newData = (SGTData)clone();
   } catch (CloneNotSupportedException e) {
     newData = null;
   }
   return newData;
 }
 
Specified by:
copy in interface SGTData
Following copied from interface: gov.noaa.pmel.sgt.dm.SGTData
Returns:
shallow copy
See Also:
Object

isXTime

public boolean isXTime()
Description copied from interface: SGTData
Returns true if the X coordinate is Time.
Specified by:
isXTime in interface SGTData

isYTime

public boolean isYTime()
Description copied from interface: SGTData
Returns true if the Y coordinate is Time.
Specified by:
isYTime in interface SGTData

getXMetaData

public SGTMetaData getXMetaData()
Description copied from interface: SGTData
Returns the X SGTMetaData.
Specified by:
getXMetaData in interface SGTData

getYMetaData

public SGTMetaData getYMetaData()
Description copied from interface: SGTData
Returns the Y SGTMetaData.
Specified by:
getYMetaData in interface SGTData

getXRange

public SoTRange getXRange()
Description copied from interface: SGTData
Returns the range of the X coordinates. If all the data in the array is missing, this method will return Double.NaN as the start and end values for data of type double and return GeoDate(Long.MIN_VALUE) for data of type GeoDate.
Specified by:
getXRange in interface SGTData
Following copied from interface: gov.noaa.pmel.sgt.dm.SGTData
See Also:
GeoDate.isMissing()

getYRange

public SoTRange getYRange()
Description copied from interface: SGTData
Returns the range of the Y coordinates.
Specified by:
getYRange in interface SGTData
Following copied from interface: gov.noaa.pmel.sgt.dm.SGTData
See Also:
SGTData.getXRange()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface: SGTData
Add a PropertyChangeListener to the listener list.
Specified by:
addPropertyChangeListener in interface SGTData

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface: SGTData
Remove a PropertyChangeListener from the listener list.
Specified by:
removePropertyChangeListener in interface SGTData

startData

public void startData()
Start the timer and begin/continue generating property change events.

stopData

public void stopData()
Stop the timer.

resetData

public void resetData()
Reset the demonstration to the begining.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handle timer ActionEvents
Property Change: rangeModified and DataModified
Specified by:
actionPerformed in interface java.awt.event.ActionListener


Send comments about the Scientific Graphics toolkit to dwd@pmel.noaa.gov. For more information about Java Development in the EPIC Group see the EPIC Software Page
Generated on December 13 2001