jsky.science
Class Redshift

java.lang.Object
  extended by jsky.science.AbstractScienceObject
      extended by jsky.science.Quantity
          extended by jsky.science.Redshift
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, java.util.EventListener, ScienceObjectModel, ReplaceablePropertyChangeListener

public class Redshift
extends Quantity

Redshift manages redshift quantities and provides a means to easily track different units Users can set a static default units and then retrieve a redshift value (as double) by calling getLength(). On construction, the normal constructor is Redshift( value, units).

Currently units of Z and RADIALVELOCITY are supported. (Some additional units names such as PARSEC have been defined, but are not yet supported as valid units).

This code was developed by NASA, Goddard Space Flight Center, Code 588 for the Scientist's Expert Assistant (SEA) project for Next Generation Space Telescope (NGST).

Version:
7.20.99
Author:
Sandy Grosvenor
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jsky.science.AbstractScienceObject
AbstractScienceObject.EventMonitor
 
Field Summary
static java.lang.String ASTRONOMICALUNIT
           
static java.lang.String ASTRONOMICALUNITABBREV
           
static java.lang.String DEFAULTUNITS_PROPERTY
           
static java.lang.String DISTANCEMODULUS
           
static java.lang.String DISTANCEMODULUSABBREV
           
static java.lang.String PARSEC
           
static java.lang.String PARSECABBREV
           
static java.lang.String RADIALVELOCITY
           
static java.lang.String RADIALVELOCITYABBREV
           
static java.lang.String Z
           
static java.lang.String ZABBREV
           
 
Fields inherited from class jsky.science.Quantity
fValue
 
Fields inherited from interface jsky.science.ScienceObjectModel
NAME_PROPERTY, PENDING_PROPERTY, VALID_PROPERTY
 
Constructor Summary
Redshift()
          creates a default Redshift of length 0 with no name
Redshift(double inValue)
          creates a new Redshift of specified value in the default units
Redshift(double inValue, java.lang.String inUnits)
          primary constructor
 
Method Summary
static void addDefaultUnitsChangeListener(java.beans.PropertyChangeListener listener)
           
static double convert(double inVal, java.lang.String fromUnits, java.lang.String toUnits)
          This is the workhorse of the Redshift class - converts a value from one unit to the other.
static java.lang.String getDefaultUnitsAbbrev()
           
 double getValue(java.lang.String unitsName)
          Returns a doublecontaining current value in the specified units.
static void main(java.lang.String[] args)
          testing only
 Quantity newInstance(double inValue)
          returns a new Redshift (as a Quantity) with value as specified in default units.
static void removeDefaultUnitsChangeListener(java.beans.PropertyChangeListener listener)
           
protected  void setValue(double inValue, java.lang.String unitsName)
          Sets the double value of a redshift with the specified units
 
Methods inherited from class jsky.science.Quantity
add, addDefaultUnitsChangeListener, equals, fireDefaultUnitsChange, fireDefaultUnitsChange, getAllUnits, getAllUnits, getAllUnitsAbbrev, getAllUnitsAbbrev, getDefaultUnits, getDefaultUnits, getDefaultUnitsAbbrev, getDefaultUnitsProperty, getUnitsAbbrev, getUnitsIgnoreCase, getValue, hashCode, initializeSubClass, isInitialized, removeDefaultUnitsChangeListener, setDefaultUnits, toString, toString
 
Methods inherited from class jsky.science.AbstractScienceObject
addEventMonitor, addPropertyChangeListener, areNamesEqual, clearAllListeners, clone, compareTo, createDefaultName, firePropertyChange, firePropertyChange, fireReplaceObject, fireReplaceObject, fireReplaceObject, fireVetoableChange, fireVetoableChange, getException, getLabel, getName, getObjectIdString, getObjectIdString, getParent, isHolding, isPending, isTracing, isValid, notifyEventMonitors, propertyChange, removeEventMonitor, removePropertyChangeListener, replaceObject, replaceObjectNYI, setException, setHolding, setName, setParent, setTraceAll, setTracing, writeDebug, writeError
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULTUNITS_PROPERTY

public static final java.lang.String DEFAULTUNITS_PROPERTY

Z

public static final java.lang.String Z

RADIALVELOCITY

public static final java.lang.String RADIALVELOCITY

PARSEC

public static final java.lang.String PARSEC

ASTRONOMICALUNIT

public static final java.lang.String ASTRONOMICALUNIT

DISTANCEMODULUS

public static final java.lang.String DISTANCEMODULUS

ZABBREV

public static final java.lang.String ZABBREV

RADIALVELOCITYABBREV

public static final java.lang.String RADIALVELOCITYABBREV

PARSECABBREV

public static final java.lang.String PARSECABBREV

ASTRONOMICALUNITABBREV

public static final java.lang.String ASTRONOMICALUNITABBREV

DISTANCEMODULUSABBREV

public static final java.lang.String DISTANCEMODULUSABBREV
Constructor Detail

Redshift

public Redshift()
creates a default Redshift of length 0 with no name


Redshift

public Redshift(double inValue)
creates a new Redshift of specified value in the default units


Redshift

public Redshift(double inValue,
                java.lang.String inUnits)
primary constructor

Parameters:
inValue - double of the actual Redshift
inUnits - string containing the units in which the value is given
Method Detail

main

public static void main(java.lang.String[] args)
testing only


newInstance

public Quantity newInstance(double inValue)
returns a new Redshift (as a Quantity) with value as specified in default units.

Specified by:
newInstance in class Quantity

getValue

public double getValue(java.lang.String unitsName)
Returns a doublecontaining current value in the specified units.

Specified by:
getValue in class Quantity

setValue

protected void setValue(double inValue,
                        java.lang.String unitsName)
Sets the double value of a redshift with the specified units

Specified by:
setValue in class Quantity

convert

public static double convert(double inVal,
                             java.lang.String fromUnits,
                             java.lang.String toUnits)
                      throws UnitsNotSupportedException
This is the workhorse of the Redshift class - converts a value from one unit to the other.

Throws:
UnitsNotSupportedException

addDefaultUnitsChangeListener

public static void addDefaultUnitsChangeListener(java.beans.PropertyChangeListener listener)

removeDefaultUnitsChangeListener

public static void removeDefaultUnitsChangeListener(java.beans.PropertyChangeListener listener)

getDefaultUnitsAbbrev

public static java.lang.String getDefaultUnitsAbbrev()