jsky.coords
Class DMS

java.lang.Object
  extended by jsky.coords.DMS
All Implemented Interfaces:
Serializable

public class DMS
extends Object
implements Serializable

Class representing a value of the form "deg:min:sec".

Version:
$Revision: 1.4 $
Author:
Allan Brighton
See Also:
Serialized Form

Constructor Summary
DMS()
          Default constructor: initialize to null values
DMS(DMS hms)
          Copy constructor
DMS(double val)
          Initialize from a decimal value and calculate H:M:S.sss.
DMS(double degrees, int min, double sec)
          Initialize with the given degrees, minutes and seconds.
DMS(String s)
          Initialize from a string value, in format H:M:S.sss, hh, d.ddd, or H M S.
 
Method Summary
 boolean equals(Object obj)
          Define equality based on the value
 int getDegrees()
          Return the number of degrees (not including minutes or seconds)
 int getMin()
          Return the number of minutes (not including degrees or seconds)
 double getSec()
          Return the number of seconds (not including degrees and minutes)
 byte getSign()
          Return the sign of the value
 double getVal()
          Return the value (fractional number of degrees) as a double
 boolean isInitialized()
          Return true if this object has been initialized with a valid value
static void main(String[] args)
          Test cases
 void set(double degrees, int min, double sec)
          Set the degrees, minutes and seconds.
 void setVal(double val)
          Set from a decimal value and calculate H:M:S.sss.
 String toString()
          Return the value as a String in the form hh:mm:ss.sss.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DMS

public DMS()
Default constructor: initialize to null values


DMS

public DMS(double degrees,
           int min,
           double sec)
Initialize with the given degrees, minutes and seconds.


DMS

public DMS(double val)
Initialize from a decimal value and calculate H:M:S.sss.


DMS

public DMS(DMS hms)
Copy constructor


DMS

public DMS(String s)
Initialize from a string value, in format H:M:S.sss, hh, d.ddd, or H M S.

Method Detail

set

public void set(double degrees,
                int min,
                double sec)
Set the degrees, minutes and seconds.


setVal

public void setVal(double val)
Set from a decimal value and calculate H:M:S.sss.


toString

public String toString()
Return the value as a String in the form hh:mm:ss.sss. Seconds are formatted with leading zero if needed. The seconds are formatted with 2 digits precission.

Overrides:
toString in class Object

isInitialized

public boolean isInitialized()
Return true if this object has been initialized with a valid value


getDegrees

public int getDegrees()
Return the number of degrees (not including minutes or seconds)


getMin

public int getMin()
Return the number of minutes (not including degrees or seconds)


getSec

public double getSec()
Return the number of seconds (not including degrees and minutes)


getVal

public double getVal()
Return the value (fractional number of degrees) as a double


getSign

public byte getSign()
Return the sign of the value


equals

public boolean equals(Object obj)
Define equality based on the value

Overrides:
equals in class Object

main

public static void main(String[] args)
Test cases