jsky.science
Class Coordinates

java.lang.Object
  extended by jsky.science.Coordinates
All Implemented Interfaces:
java.io.Serializable

public class Coordinates
extends java.lang.Object
implements java.io.Serializable

A position in the World Coordinate System. This position is represented by a right-ascension angle and a declination angle.

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

Version:
10/29/99
Author:
J. Jones / 588
See Also:
Serialized Form

Nested Class Summary
static class Coordinates.LocalPropertyChangeHandler
           
 
Field Summary
static java.lang.String ARCSEC
           
static int B1950_EQUINOX
          The B1950 equinox
static java.lang.String B1950_EQUINOX_LABEL
           
static int COLON_SEPARATOR_STYLE
          Constant for indicating that coordinate values should be separated by colons.
static java.lang.String COLON_SEPARATOR_STYLE_LABEL
           
static java.lang.String DEGREE
          support conversion units
static java.lang.String FORMATSTYLEPROPERTY
          Bound property name.
static int J2000_EQUINOX
          The J2000 equinox
static java.lang.String J2000_EQUINOX_LABEL
           
static int LETTER_SEPARATOR_STYLE
          Constant for indicating that coordinate values should be separated by 'h', 'd', 'm', 's' letters.
static java.lang.String LETTER_SEPARATOR_STYLE_LABEL
           
static int NUM_DECIMAL
          Number of decimal places to show when displaying as string
static java.lang.String RADIAN
           
static int SPACE_SEPARATOR_STYLE
          Constant for indicating that coordinate values should be separated by spaces.
static java.lang.String SPACE_SEPARATOR_STYLE_LABEL
           
 
Constructor Summary
Coordinates()
          Constructs a coordinates object with RA and Dec of zero.
Coordinates(Coordinates old)
          Constructs a new coordinates object that is a copy of the specified object.
Coordinates(double ra, double dec)
          Constructs a coordinates object with specified RA and Dec in the default equinox.
Coordinates(double ra, double dec, int equinox)
          Constructs a coordinates object with specified RA and Dec in the specified equinox.
Coordinates(double ra, double dec, int equinox, double epoch)
          Constructs a coordinates object with specified RA and Dec in the specified equinox and epoch.
 
Method Summary
 Coordinates add(CoordinatesOffset offset)
          Adds an offset to the current coordinates and returns the sum as a new Coordinates object.
static void addSeparatorStyleChangeListener(java.beans.PropertyChangeListener listener)
          add a listener to the list of objects listening to changes in the separator style
static double convert(double coord, java.lang.String fromUnits, java.lang.String toUnits)
          converts a coordinate from specified source units to the destination units
 java.lang.String decToString()
          Returns a string representation of the declination.
 java.lang.String decToString(int separatorStyle)
          Returns a string representation of the declination.
 java.lang.String epochToString()
          Returns a string representation of the epoch.
 boolean equals(java.lang.Object obj)
          Compares this Coordinates object to the specified object and returns true if the objects are equivalent.
static java.lang.String equinoxIntToString(int equinox)
          returns the full label name of an equinox
static double equinoxIntToYear(int equinox)
          returns the year of the enumerated equinox value
static int equinoxStringToInt(java.lang.String equinox)
          returns the equinox given its label
 java.lang.String equinoxToString()
          Returns a string representation of the equinox.
protected static void fireSeparatorStyleChange(java.beans.PropertyChangeEvent evt)
          fire a property change event to all listeners of the separator style
static java.lang.String[] getAllEquinoxes()
          returns the list of string labels for possible equinoxs
static java.lang.String[] getAllSeparatorStyles()
          returns the list of string labels for possible separator styles
 double getDec()
          Returns the declination of the position in degrees.
 double getDec(java.lang.String units)
          Returns the declination of the position in degrees.
static int getDefaultEquinox()
          Returns the default equinox
 double getEclipticLatitude()
          Returns the ecliptic latitude of the position in degrees.
 double getEclipticLongitude()
          Returns the ecliptic longitude of the position in degrees.
 double getEpoch()
          Returns the epoch year for the position.
 int getEquinox()
          Returns the equinox used to display and parse the coordinate values.
 double getRa()
          Returns the right-ascension of the position in degrees.
 double getRa(java.lang.String units)
          Returns the right-ascension of the position in degrees.
static int getSeparatorStyle()
          Returns the global separator style.
 int hashCode()
          Returns the hashcode for this Coordinates.
 java.lang.String raToString()
          Returns a string representation of the right-ascension.
 java.lang.String raToString(int separatorStyle)
          Returns a string representation of the right-ascension.
static void removeSeparatorStyleChangeListener(java.beans.PropertyChangeListener listener)
          remove a listener from the list of objects listening to changes in the separator style
 void rotate(double angleRad, double ra, double dec)
          Rotates the position angleRad radians about a specified center position (ra, dec).
static java.lang.String separatorStyleIntToString(int style)
          returns the full label name of a separator style
static int separatorStyleStringToInt(java.lang.String style)
          returns the separator style given its label
 void setDec(double dec)
          Sets the declination of the position in degrees.
 void setDec(double dec, java.lang.String units)
          Sets the declination of the position in degrees.
 void setEpoch(double epoch)
          Sets the epoch year for the position.
 void setEquinox(int equinox)
          Sets the equinox used to display and parse the coordinate values.
 void setRa(double ra)
          Sets the right-ascension of the position in degrees.
 void setRa(double ra, java.lang.String units)
          Sets the right-ascension of the position in degrees.
static void setSeparatorStyle(int style)
          Changes the global separator style.
 void setValue(double ra, double dec)
          Sets the right-ascension and declination of the position in degrees.
 CoordinatesOffset subtract(Coordinates c)
          Subtracts the coordinates c from the current coordinates and returns the difference as a new CoordinatesOffset.
 Coordinates toB1950()
          Returns the coordinates converted to the B1950 equinox, or just returns itself if already B1950.
 Coordinates toJ2000()
          Returns the coordinates converted to the J2000 equinox, or just returns itself if already J2000.
 java.lang.String toString()
          Returns a string representation of the position.
 void translate(CoordinatesOffset offset)
          Translates this position by the specified offset so that the new position equals the current position + the argument.
 void translate(double raArcsec, double decArcsec)
          Translates this position by the specified amounts so that the new position equals the current position + the arguments.
static double validateDec(double dec)
          Returns a properly validated declination in degrees.
static double validateDec(double dec, java.lang.String units)
          Returns a properly validated declination in specified units
static double validateRa(double ra)
          Returns a properly validated right-ascension in degrees.
static double validateRa(double ra, java.lang.String units)
          Returns a properly validated right-ascension in specified units
static Coordinates valueOf(java.lang.String raInput, java.lang.String decInput)
          Creates a new Coordinates object using two strings for the RA and Dec.
static Coordinates valueOf(java.lang.String raInput, java.lang.String decInput, int equinox)
          Creates a new Coordinates object using two strings for the RA and Dec.
protected static void writeError(java.lang.Object source, java.lang.Object message)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEGREE

public static final java.lang.String DEGREE
support conversion units


ARCSEC

public static final java.lang.String ARCSEC

RADIAN

public static final java.lang.String RADIAN

NUM_DECIMAL

public static final int NUM_DECIMAL
Number of decimal places to show when displaying as string

See Also:
Constant Field Values

SPACE_SEPARATOR_STYLE

public static final int SPACE_SEPARATOR_STYLE
Constant for indicating that coordinate values should be separated by spaces.

See Also:
Constant Field Values

SPACE_SEPARATOR_STYLE_LABEL

public static final java.lang.String SPACE_SEPARATOR_STYLE_LABEL
See Also:
Constant Field Values

COLON_SEPARATOR_STYLE

public static final int COLON_SEPARATOR_STYLE
Constant for indicating that coordinate values should be separated by colons.

See Also:
Constant Field Values

COLON_SEPARATOR_STYLE_LABEL

public static final java.lang.String COLON_SEPARATOR_STYLE_LABEL
See Also:
Constant Field Values

LETTER_SEPARATOR_STYLE

public static final int LETTER_SEPARATOR_STYLE
Constant for indicating that coordinate values should be separated by 'h', 'd', 'm', 's' letters.

See Also:
Constant Field Values

LETTER_SEPARATOR_STYLE_LABEL

public static final java.lang.String LETTER_SEPARATOR_STYLE_LABEL
See Also:
Constant Field Values

B1950_EQUINOX

public static final int B1950_EQUINOX
The B1950 equinox

See Also:
Constant Field Values

B1950_EQUINOX_LABEL

public static final java.lang.String B1950_EQUINOX_LABEL
See Also:
Constant Field Values

J2000_EQUINOX

public static final int J2000_EQUINOX
The J2000 equinox

See Also:
Constant Field Values

J2000_EQUINOX_LABEL

public static final java.lang.String J2000_EQUINOX_LABEL
See Also:
Constant Field Values

FORMATSTYLEPROPERTY

public static final java.lang.String FORMATSTYLEPROPERTY
Bound property name.

Constructor Detail

Coordinates

public Coordinates()
Constructs a coordinates object with RA and Dec of zero.


Coordinates

public Coordinates(double ra,
                   double dec)
Constructs a coordinates object with specified RA and Dec in the default equinox.

Parameters:
ra - right-ascension in degrees
dec - declination in degrees

Coordinates

public Coordinates(double ra,
                   double dec,
                   int equinox)
Constructs a coordinates object with specified RA and Dec in the specified equinox.

Parameters:
ra - right-ascension in degrees
dec - declination in degrees
equinox - equinox constant

Coordinates

public Coordinates(double ra,
                   double dec,
                   int equinox,
                   double epoch)
Constructs a coordinates object with specified RA and Dec in the specified equinox and epoch.

Parameters:
ra - right-ascension in degrees
dec - declination in degrees
equinox - equinox constant
epoch - epoch year

Coordinates

public Coordinates(Coordinates old)
Constructs a new coordinates object that is a copy of the specified object.

Parameters:
old - Coordinates object to copy
Method Detail

getRa

public double getRa()
Returns the right-ascension of the position in degrees.

Returns:
right-ascension of the position in degrees

getDec

public double getDec()
Returns the declination of the position in degrees.

Returns:
declination of the position in degrees

convert

public static double convert(double coord,
                             java.lang.String fromUnits,
                             java.lang.String toUnits)
converts a coordinate from specified source units to the destination units

Parameters:
coord - The coordinate to be converted
fromUnits - String containing source units
toUnits - String containing target units

writeError

protected static void writeError(java.lang.Object source,
                                 java.lang.Object message)

getRa

public double getRa(java.lang.String units)
Returns the right-ascension of the position in degrees.

Returns:
right-ascension of the position in degrees

getDec

public double getDec(java.lang.String units)
Returns the declination of the position in degrees.

Returns:
declination of the position in degrees

setRa

public void setRa(double ra)
Sets the right-ascension of the position in degrees.

Parameters:
ra - the new right-ascension of the position in degrees

setDec

public void setDec(double dec)
Sets the declination of the position in degrees.

Parameters:
dec - the new declination of the position in degrees

setRa

public void setRa(double ra,
                  java.lang.String units)
Sets the right-ascension of the position in degrees.

Parameters:
ra - the new right-ascension of the position
units - ra's units

setDec

public void setDec(double dec,
                   java.lang.String units)
Sets the declination of the position in degrees.

Parameters:
dec - the new declination of the position in degrees
units - dec's units

setValue

public void setValue(double ra,
                     double dec)
Sets the right-ascension and declination of the position in degrees.

Parameters:
ra - the new right-ascension of the position in degrees
dec - the new declination of the position in degrees

validateRa

public static final double validateRa(double ra,
                                      java.lang.String units)
Returns a properly validated right-ascension in specified units

Parameters:
ra - a right-ascension of a position
units - the units of the right ascension
Returns:
a validated right-ascension of the position

validateRa

public static final double validateRa(double ra)
Returns a properly validated right-ascension in degrees.

Parameters:
ra - a right-ascension of a position in degrees
Returns:
a validated right-ascension of the position in degrees.

validateDec

public static final double validateDec(double dec,
                                       java.lang.String units)
Returns a properly validated declination in specified units

Parameters:
dec - a declination of a position
units - the units of the declination
Returns:
a validated declination of the position

validateDec

public static final double validateDec(double dec)
Returns a properly validated declination in degrees.

Parameters:
dec - a declination of a position in degrees
Returns:
a validated declination of the position in degrees.

getEclipticLongitude

public double getEclipticLongitude()
Returns the ecliptic longitude of the position in degrees.

Returns:
ecliptic longitude of the position in degrees
See Also:
"getEclipticLatitude for source tcl code from WFPC2"

getEclipticLatitude

public double getEclipticLatitude()
Returns the ecliptic latitude of the position in degrees. This code converted from the WFPC2 ETC

Returns:
ecliptic latitude of the position in degrees

getEquinox

public int getEquinox()
Returns the equinox used to display and parse the coordinate values. This is an enumerated value, not the year.

Returns:
enumerated equinox constant

setEquinox

public void setEquinox(int equinox)
Sets the equinox used to display and parse the coordinate values. Setting the equinox also sets the epoch.

Parameters:
equinox - enumerated equinox constant

getEpoch

public double getEpoch()
Returns the epoch year for the position.

Returns:
epoch year

setEpoch

public void setEpoch(double epoch)
Sets the epoch year for the position. Does not affect equinox.

Parameters:
epoch - the epoch year

getSeparatorStyle

public static int getSeparatorStyle()
Returns the global separator style.

Returns:
the global separator style

setSeparatorStyle

public static void setSeparatorStyle(int style)
Changes the global separator style. Notifies listeners of change.

Parameters:
style - new global separator style

getDefaultEquinox

public static int getDefaultEquinox()
Returns the default equinox

Returns:
the default equinox

equals

public boolean equals(java.lang.Object obj)
Compares this Coordinates object to the specified object and returns true if the objects are equivalent.

Overrides:
equals in class java.lang.Object
Parameters:
obj - object to compare to this Coodinates object

hashCode

public int hashCode()
Returns the hashcode for this Coordinates. Hashing algorithm taken from java.awt.geom.Point2D.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code for this Coordinates.

translate

public void translate(double raArcsec,
                      double decArcsec)
Translates this position by the specified amounts so that the new position equals the current position + the arguments. Note that the arguments are in arcseconds while the Coordinates RA and Dec are in degrees.

Parameters:
raArcsec - amount to translate the right-ascension
decArcsec - amount to translate the declination

translate

public void translate(CoordinatesOffset offset)
Translates this position by the specified offset so that the new position equals the current position + the argument.

Parameters:
offset - amount to add to current coordinates

rotate

public void rotate(double angleRad,
                   double ra,
                   double dec)
Rotates the position angleRad radians about a specified center position (ra, dec).

Parameters:
angleRad - rotation angle in radians
ra - rotate about a center point with this ra
dec - rotate about a center point with this dec

add

public Coordinates add(CoordinatesOffset offset)
Adds an offset to the current coordinates and returns the sum as a new Coordinates object.

Parameters:
offset - add to the current coordinates
Returns:
sum of the two

subtract

public CoordinatesOffset subtract(Coordinates c)
Subtracts the coordinates c from the current coordinates and returns the difference as a new CoordinatesOffset.

Parameters:
c - subtract these coordinates from current
Returns:
difference between two points

toString

public java.lang.String toString()
Returns a string representation of the position.

Overrides:
toString in class java.lang.Object
Returns:
position as a string

toB1950

public Coordinates toB1950()
Returns the coordinates converted to the B1950 equinox, or just returns itself if already B1950.

Returns:
coordinates converted to B1950

toJ2000

public Coordinates toJ2000()
Returns the coordinates converted to the J2000 equinox, or just returns itself if already J2000.

Returns:
coordinates converted to J2000

raToString

public java.lang.String raToString()
Returns a string representation of the right-ascension.

Returns:
right-ascension as a string

raToString

public java.lang.String raToString(int separatorStyle)
Returns a string representation of the right-ascension. The desired separator style can be specified as an argument.

Parameters:
separatorStyle - style of separator desired in output
Returns:
right-ascension as a string

decToString

public java.lang.String decToString()
Returns a string representation of the declination.

Returns:
declination as a string

decToString

public java.lang.String decToString(int separatorStyle)
Returns a string representation of the declination. The desired separator style can be specified as an argument.

Parameters:
separatorStyle - style of separator desired in output
Returns:
declination as a string

equinoxToString

public java.lang.String equinoxToString()
Returns a string representation of the equinox.

Returns:
equinox as a string

epochToString

public java.lang.String epochToString()
Returns a string representation of the epoch.

Returns:
epoch as a string

valueOf

public static Coordinates valueOf(java.lang.String raInput,
                                  java.lang.String decInput,
                                  int equinox)
                           throws java.lang.NumberFormatException,
                                  java.lang.IllegalArgumentException
Creates a new Coordinates object using two strings for the RA and Dec. The strings are parsed and the values fed into a new Coordinates object.

Parameters:
raInput - Right-ascension in string format
decInput - Declination in string format
equinox - equinox constant for the new Coordinates
Returns:
new Coordinates object for the input RA and Dec
Throws:
java.lang.NumberFormatException - thrown if unable to parse the input strings
java.lang.IllegalArgumentException

valueOf

public static Coordinates valueOf(java.lang.String raInput,
                                  java.lang.String decInput)
                           throws java.lang.NumberFormatException,
                                  java.lang.IllegalArgumentException
Creates a new Coordinates object using two strings for the RA and Dec. The strings are parsed and the values fed into a new Coordinates object.

Parameters:
raInput - Right-ascension in string format
decInput - Declination in string format
Returns:
new Coordinates object for the input RA and Dec
Throws:
java.lang.NumberFormatException - thrown if unable to parse the input strings
java.lang.IllegalArgumentException

separatorStyleStringToInt

public static int separatorStyleStringToInt(java.lang.String style)
returns the separator style given its label


separatorStyleIntToString

public static java.lang.String separatorStyleIntToString(int style)
returns the full label name of a separator style


getAllSeparatorStyles

public static java.lang.String[] getAllSeparatorStyles()
returns the list of string labels for possible separator styles


equinoxStringToInt

public static int equinoxStringToInt(java.lang.String equinox)
returns the equinox given its label


equinoxIntToString

public static java.lang.String equinoxIntToString(int equinox)
returns the full label name of an equinox


equinoxIntToYear

public static double equinoxIntToYear(int equinox)
returns the year of the enumerated equinox value


getAllEquinoxes

public static java.lang.String[] getAllEquinoxes()
returns the list of string labels for possible equinoxs


addSeparatorStyleChangeListener

public static void addSeparatorStyleChangeListener(java.beans.PropertyChangeListener listener)
add a listener to the list of objects listening to changes in the separator style

Parameters:
listener - to add

removeSeparatorStyleChangeListener

public static void removeSeparatorStyleChangeListener(java.beans.PropertyChangeListener listener)
remove a listener from the list of objects listening to changes in the separator style

Parameters:
listener - to remove

fireSeparatorStyleChange

protected static void fireSeparatorStyleChange(java.beans.PropertyChangeEvent evt)
fire a property change event to all listeners of the separator style