public class Coordinates extends Object implements Serializable
This code was developed by NASA, Goddard Space Flight Center, Code 588 for the Scientist's Expert Assistant (SEA) project.
Modifier and Type | Class and Description |
---|---|
static class |
Coordinates.LocalPropertyChangeHandler |
Modifier and Type | Field and Description |
---|---|
static String |
ARCSEC |
static int |
B1950_EQUINOX
The B1950 equinox
|
static String |
B1950_EQUINOX_LABEL |
static int |
COLON_SEPARATOR_STYLE
Constant for indicating that coordinate values should be separated by colons.
|
static String |
COLON_SEPARATOR_STYLE_LABEL |
static String |
DEGREE
support conversion units
|
static String |
FORMATSTYLEPROPERTY
Bound property name.
|
static int |
J2000_EQUINOX
The J2000 equinox
|
static 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 String |
LETTER_SEPARATOR_STYLE_LABEL |
static int |
NUM_DECIMAL
Number of decimal places to show when displaying as string
|
static String |
RADIAN |
static int |
SPACE_SEPARATOR_STYLE
Constant for indicating that coordinate values should be separated by spaces.
|
static String |
SPACE_SEPARATOR_STYLE_LABEL |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
Coordinates |
add(CoordinatesOffset offset)
Adds an offset to the current coordinates and returns the
sum as a new Coordinates object.
|
static void |
addSeparatorStyleChangeListener(PropertyChangeListener listener)
add a listener to the list of objects listening to changes in the separator style
|
static double |
convert(double coord,
String fromUnits,
String toUnits)
converts a coordinate from specified source units to the destination units
|
String |
decToString()
Returns a string representation of the declination.
|
String |
decToString(int separatorStyle)
Returns a string representation of the declination.
|
String |
epochToString()
Returns a string representation of the epoch.
|
boolean |
equals(Object obj)
Compares this Coordinates object to the specified object and
returns true if the objects are equivalent.
|
static 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(String equinox)
returns the equinox given its label
|
String |
equinoxToString()
Returns a string representation of the equinox.
|
protected static void |
fireSeparatorStyleChange(PropertyChangeEvent evt)
fire a property change event to all listeners of the separator style
|
static String[] |
getAllEquinoxes()
returns the list of string labels for possible equinoxs
|
static String[] |
getAllSeparatorStyles()
returns the list of string labels for possible separator styles
|
double |
getDec()
Returns the declination of the position in degrees.
|
double |
getDec(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(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.
|
String |
raToString()
Returns a string representation of the right-ascension.
|
String |
raToString(int separatorStyle)
Returns a string representation of the right-ascension.
|
static void |
removeSeparatorStyleChangeListener(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 String |
separatorStyleIntToString(int style)
returns the full label name of a separator style
|
static int |
separatorStyleStringToInt(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,
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,
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.
|
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,
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,
String units)
Returns a properly validated right-ascension in specified units
|
static Coordinates |
valueOf(String raInput,
String decInput)
Creates a new Coordinates object using two strings for the RA and Dec.
|
static Coordinates |
valueOf(String raInput,
String decInput,
int equinox)
Creates a new Coordinates object using two strings for the RA and Dec.
|
protected static void |
writeError(Object source,
Object message) |
public static final String DEGREE
public static final String ARCSEC
public static final String RADIAN
public static final int NUM_DECIMAL
public static final int SPACE_SEPARATOR_STYLE
public static final String SPACE_SEPARATOR_STYLE_LABEL
public static final int COLON_SEPARATOR_STYLE
public static final String COLON_SEPARATOR_STYLE_LABEL
public static final int LETTER_SEPARATOR_STYLE
public static final String LETTER_SEPARATOR_STYLE_LABEL
public static final int B1950_EQUINOX
public static final String B1950_EQUINOX_LABEL
public static final int J2000_EQUINOX
public static final String J2000_EQUINOX_LABEL
public static final String FORMATSTYLEPROPERTY
public Coordinates()
public Coordinates(double ra, double dec)
ra
- right-ascension in degreesdec
- declination in degreespublic Coordinates(double ra, double dec, int equinox)
ra
- right-ascension in degreesdec
- declination in degreesequinox
- equinox constantpublic Coordinates(double ra, double dec, int equinox, double epoch)
ra
- right-ascension in degreesdec
- declination in degreesequinox
- equinox constantepoch
- epoch yearpublic Coordinates(Coordinates old)
old
- Coordinates object to copypublic double getRa()
public double getDec()
public static double convert(double coord, String fromUnits, String toUnits)
coord
- The coordinate to be convertedfromUnits
- String containing source unitstoUnits
- String containing target unitspublic double getRa(String units)
public double getDec(String units)
public void setRa(double ra)
ra
- the new right-ascension of the position in degreespublic void setDec(double dec)
dec
- the new declination of the position in degreespublic void setRa(double ra, String units)
ra
- the new right-ascension of the positionunits
- ra's unitspublic void setDec(double dec, String units)
dec
- the new declination of the position in degreesunits
- dec's unitspublic void setValue(double ra, double dec)
ra
- the new right-ascension of the position in degreesdec
- the new declination of the position in degreespublic static final double validateRa(double ra, String units)
ra
- a right-ascension of a positionunits
- the units of the right ascensionpublic static final double validateRa(double ra)
ra
- a right-ascension of a position in degreespublic static final double validateDec(double dec, String units)
ra
- a declination of a positionunits
- the units of the declinationpublic static final double validateDec(double dec)
dec
- a declination of a position in degreespublic double getEclipticLongitude()
public double getEclipticLatitude()
public int getEquinox()
public void setEquinox(int equinox)
equinox
- enumerated equinox constantpublic double getEpoch()
public void setEpoch(double epoch)
epoch
- the epoch yearpublic static int getSeparatorStyle()
public static void setSeparatorStyle(int style)
style
- new global separator stylepublic static int getDefaultEquinox()
public boolean equals(Object obj)
public int hashCode()
public void translate(double raArcsec, double decArcsec)
raArcsec
- amount to translate the right-ascensiondecArcsec
- amount to translate the declinationpublic void translate(CoordinatesOffset offset)
offset
- amount to add to current coordinatespublic void rotate(double angleRad, double ra, double dec)
angleRad
- rotation angle in radiansra
- rotate about a center point with this radec
- rotate about a center point with this decpublic Coordinates add(CoordinatesOffset offset)
offset
- add to the current coordinatespublic CoordinatesOffset subtract(Coordinates c)
c
- subtract these coordinates from currentpublic String toString()
public Coordinates toB1950()
public Coordinates toJ2000()
public String raToString()
public String raToString(int separatorStyle)
separatorStyle
- style of separator desired in outputpublic String decToString()
public String decToString(int separatorStyle)
separatorStyle
- style of separator desired in outputpublic String equinoxToString()
public String epochToString()
public static Coordinates valueOf(String raInput, String decInput, int equinox) throws NumberFormatException, IllegalArgumentException
raInput
- Right-ascension in string formatdecInput
- Declination in string formatequinox
- equinox constant for the new CoordinatesNumberFormatException
- thrown if unable to parse the input stringsIllegalArgumentException
public static Coordinates valueOf(String raInput, String decInput) throws NumberFormatException, IllegalArgumentException
raInput
- Right-ascension in string formatdecInput
- Declination in string formatNumberFormatException
- thrown if unable to parse the input stringsIllegalArgumentException
public static int separatorStyleStringToInt(String style)
public static String separatorStyleIntToString(int style)
public static String[] getAllSeparatorStyles()
public static int equinoxStringToInt(String equinox)
public static String equinoxIntToString(int equinox)
public static double equinoxIntToYear(int equinox)
public static String[] getAllEquinoxes()
public static void addSeparatorStyleChangeListener(PropertyChangeListener listener)
listener
- to addpublic static void removeSeparatorStyleChangeListener(PropertyChangeListener listener)
listener
- to removeprotected static void fireSeparatorStyleChange(PropertyChangeEvent evt)
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.