ucar.unidata.view.sounding
Class DataModelImpl

java.lang.Object
  extended by ucar.unidata.view.sounding.DataModelImpl

public class DataModelImpl
extends Object

Provides support for adapting a JList of sounding observations to the API-s of the sounding and wind data models. The conceptual model that this class presents is that of a set of soundings -- a subset of which are the SELECTED SOUNDINGS -- and of which at most one sounding is the SELECTED SOUNDING. The soundings that constitute the set may change -- as may the selected soundings and the selected sounding. Modifications to the soundings by users of this class will appear to actually modify the soundings in the set.

Version:
$Id: DataModelImpl.java,v 1.12 2005/05/13 18:33:27 jeffmc Exp $
Author:
Steven R. Emmerson

Field Summary
static String SELECTED_INDEX
          The name of the index-of-the-selected-thing property.
static String SELECTED_INDEX
          The name of the index-of-the-selected-thing property.
 
Constructor Summary
DataModelImpl(JList jList)
          Constructs from a JList.
 
Method Summary
 void addListDataListener(ListDataListener listener)
          Adds a listener for changes to the underlying list of things.
 void addListSelectionListener(ListSelectionListener listener)
          Adds a listener for changes to the selected things.
 void addPropertyChangeListener(String name, PropertyChangeListener listener)
          Adds a PropertyChangeListener for a named property.
protected static FlatField ensureCartesianWindProfile(FlatField input)
          Ensures that a wind profile is in cartesian coordinates.
 Field getDewPointProfile(int index)
          Returns the dew-point profile at the given index.
 Tuple getMeanWind(int index)
          Returns the mean-wind at the given index.
protected  MeanWindCell getMeanWindCell(int index)
          Returns the mean-wind cell at the given index.
 DataReference getMeanWindRef(int index)
          Returns the data reference for the mean-wind at the given index.
protected  RAOB getRAOB(int index)
          Returns the RAOB at the given index.
 int getSelectedIndex()
          Returns the index of the selected sounding.
 int getSize()
          Returns the number of soundings.
 Field[] getSounding(int index)
          Returns the aerological sounding data at the given index.
 Field getTemperatureProfile(int index)
          Returns the temperature profile at the given index.
 Object[] getWindData(int index)
          Returns the wind profile and mean-wind at the given index.
 Field getWindProfile(int index)
          Returns the wind profile at the given index.
 boolean isSelectedIndex(int index)
          Indicates if the given sounding is a member of the selected soundings.
 void removeListDataListener(ListDataListener listener)
          Removes a listener for changes to the underlying list of things.
 void removeListSelectionListener(ListSelectionListener listener)
          Removes a listener for changes to the selected things.
 void removePropertyChangeListener(String name, PropertyChangeListener listener)
          Removes a PropertyChangeListener for a named property.
 void restoreSelectedSoundings()
          Restores the selected soundings to their original values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTED_INDEX

public static final String SELECTED_INDEX
The name of the index-of-the-selected-thing property.

See Also:
Constant Field Values

SELECTED_INDEX

public static final String SELECTED_INDEX
The name of the index-of-the-selected-thing property.

See Also:
Constant Field Values
Constructor Detail

DataModelImpl

public DataModelImpl(JList jList)
Constructs from a JList. The JList's data model and selection model must be in their final form. The SELECTED_INDEX property of this instance will be bound to the "selectedIndex" property of the JList and PropertyChangeEvent-s will be propagated.

Parameters:
jList - The underlying JList whose mutable data model contains the sounding data and whose list selection model determines the selected soundings and selected sounding.
Method Detail

getSize

public int getSize()
Returns the number of soundings.

Returns:
The number of soundings.

isSelectedIndex

public boolean isSelectedIndex(int index)
Indicates if the given sounding is a member of the selected soundings.

Parameters:
index - The index of the sounding.
Returns:
true if and only if the given sounding is a member of the selected soundings.

getSelectedIndex

public int getSelectedIndex()
Returns the index of the selected sounding.

Returns:
The index of the selected thing or -1 if nothing is selected.

restoreSelectedSoundings

public void restoreSelectedSoundings()
                              throws VisADException,
                                     RemoteException
Restores the selected soundings to their original values. Doesn't affect unselected soundings.

Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

getSounding

public Field[] getSounding(int index)
                    throws IndexOutOfBoundsException
Returns the aerological sounding data at the given index.

Parameters:
index - The index of the sounding.
Returns:
The aerological sounding data at the given index. The returned array has 2 elements; the first element is the temperature profile and the second element is the dew-point profile.
Throws:
IndexOutOfBoundsException - The index is out of range.

getTemperatureProfile

public Field getTemperatureProfile(int index)
                            throws IndexOutOfBoundsException
Returns the temperature profile at the given index.

Parameters:
index - The index of the temperature profile.
Returns:
The temperature profile at the given index.
Throws:
IndexOutOfBoundsException - The index is out of range.

getDewPointProfile

public Field getDewPointProfile(int index)
                         throws IndexOutOfBoundsException
Returns the dew-point profile at the given index.

Parameters:
index - The index of the dew-point profile.
Returns:
The dew-point profile at the given index.
Throws:
IndexOutOfBoundsException - The index is out of range.

getWindData

public Object[] getWindData(int index)
                     throws IndexOutOfBoundsException,
                            VisADException,
                            RemoteException
Returns the wind profile and mean-wind at the given index.

Parameters:
index - The index of the sounding.
Returns:
The wind data at the given index. The returned array has 2 elements; the first element is the wind profile and the second element is the mean wind.
Throws:
IndexOutOfBoundsException - The index is out of range.
VisADException - VisAD failure.
RemoteException - Java RMI failure.

getWindProfile

public Field getWindProfile(int index)
                     throws IndexOutOfBoundsException,
                            VisADException,
                            RemoteException
Returns the wind profile at the given index.

Parameters:
index - The index of the wind profile.
Returns:
The wind profile at the given index.
Throws:
IndexOutOfBoundsException - The index is out of range.
VisADException - VisAD failure.
RemoteException - Java RMI failure.

getMeanWind

public Tuple getMeanWind(int index)
                  throws VisADException,
                         RemoteException
Returns the mean-wind at the given index.

Parameters:
index - The index of the mean-wind.
Returns:
The mean-wind at the given index.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

getMeanWindRef

public DataReference getMeanWindRef(int index)
                             throws VisADException,
                                    RemoteException
Returns the data reference for the mean-wind at the given index.

Parameters:
index - The index of the mean-wind.
Returns:
The data reference for the mean-wind at the given index.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.

addPropertyChangeListener

public void addPropertyChangeListener(String name,
                                      PropertyChangeListener listener)
Adds a PropertyChangeListener for a named property.

Parameters:
name - The name of the property.
listener - The PropertyChangeListener to be added.

removePropertyChangeListener

public void removePropertyChangeListener(String name,
                                         PropertyChangeListener listener)
Removes a PropertyChangeListener for a named property.

Parameters:
name - The name of the property.
listener - The PropertyChangeListener to be removed.

addListSelectionListener

public void addListSelectionListener(ListSelectionListener listener)
Adds a listener for changes to the selected things.

Parameters:
listener - The listener for changes to the selected things.

removeListSelectionListener

public void removeListSelectionListener(ListSelectionListener listener)
Removes a listener for changes to the selected things.

Parameters:
listener - The listener for changes to the selected things.

addListDataListener

public void addListDataListener(ListDataListener listener)
Adds a listener for changes to the underlying list of things.

Parameters:
listener - The listener for changes to the underlying list of things.

removeListDataListener

public void removeListDataListener(ListDataListener listener)
Removes a listener for changes to the underlying list of things.

Parameters:
listener - The listener for changes to the underlying list of things.

getRAOB

protected RAOB getRAOB(int index)
                throws IndexOutOfBoundsException
Returns the RAOB at the given index.

Parameters:
index - The index of the RAOB.
Returns:
The RAOB at the given index.
Throws:
IndexOutOfBoundsException - The index is out of range.

ensureCartesianWindProfile

protected static FlatField ensureCartesianWindProfile(FlatField input)
                                               throws VisADException,
                                                      RemoteException
Ensures that a wind profile is in cartesian coordinates.

Parameters:
input - Wind profile in cartesian or polar coordinates.
Returns:
Wind profile in cartesian coordinates.
Throws:
VisADException - if a core VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.

getMeanWindCell

protected MeanWindCell getMeanWindCell(int index)
                                throws VisADException,
                                       RemoteException
Returns the mean-wind cell at the given index.

Parameters:
index - The index of the mean-wind cell.
Returns:
The mean-wind cell at the given index.
Throws:
VisADException - VisAD failure.
RemoteException - Java RMI failure.