@Immutable public class Angle extends Object implements Comparable<Angle>, Formattable, Serializable
AngleFormat
once, then to
reuse it many times. As a convenience, Angle
objects can also be formatted by the
"%s"
conversion specifier of Formatter
, but this is less efficient for this
class.Latitude
,
Longitude
,
AngleFormat
,
Serialized FormDefined in the sis-utility module
Constructor and Description |
---|
Angle(double θ)
Constructs a new angle with the specified value in decimal degrees.
|
Angle(String string)
Constructs a newly allocated
Angle object that contain the angular value
represented by the string. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Angle that)
Compares two
Angle objects numerically. |
double |
degrees()
Returns the angle value in decimal degrees.
|
boolean |
equals(Object object)
Compares the specified object with this angle for equality.
|
void |
formatTo(Formatter formatter,
int flags,
int width,
int precision)
Formats this angle using the provider formatter.
|
int |
hashCode()
Returns a hash code for this
Angle object. |
double |
radians()
Returns the angle value in radians.
|
String |
toString()
Returns a string representation of this
Angle object. |
public Angle(double θ)
θ
- Angle in decimal degrees.public Angle(String string) throws NumberFormatException
Angle
object that contain the angular value
represented by the string. The string should represent an angle in either fractional
degrees (e.g. 45.5°) or degrees with minutes and seconds (e.g. 45°30').
This is a convenience constructor mostly for testing purpose, since it uses a fixed
locale. Developers should consider using AngleFormat
for end-user applications
instead than this constructor.
string
- A string to be converted to an Angle
.NumberFormatException
- if the string does not contain a parsable angle.AngleFormat.parse(String)
public double degrees()
public double radians()
public int hashCode()
Angle
object.public boolean equals(Object object)
public int compareTo(Angle that)
Angle
objects numerically. The comparison
is done as if by the Double.compare(double, double)
method.compareTo
in interface Comparable<Angle>
that
- The angle to compare with this object for order.public String toString()
Angle
object.
This is a convenience method mostly for debugging purpose, since it uses a fixed locale.
Developers should consider using AngleFormat
for end-user applications instead
than this method.toString
in class Object
AngleFormat.format(double)
public void formatTo(Formatter formatter, int flags, int width, int precision)
Angle
object is formatted using the "%s"
conversion specifier of
Formatter
. Users don't need to invoke this method explicitely.
Special cases:
Latitude
or Longitude
,
then this method formats only the hemisphere symbol.AngleFormat.setMaximumWidth(int)
.formatTo
in interface Formattable
formatter
- The formatter in which to format this angle.flags
- FormattableFlags.LEFT_JUSTIFY
for left alignment, or 0 for right alignment.width
- Minimal number of characters to write, padding with ' '
if necessary.precision
- Maximal number of characters to write, or -1 if no limit.Copyright © 2010–2013 The Apache Software Foundation. All rights reserved.