org.jscience.ml.om
Class Angle

java.lang.Object
  extended by org.jscience.ml.om.Angle

public class Angle
extends java.lang.Object

Angle is a wrapper class for angles used in the XML Schema definition. It stores an angle as double value along with the unit of the angle. All possible units for angles can be accessed by this objects constants.

Since:
1.0

Field Summary
static java.lang.String ARCMINUTE
          Angle unit arcminute.
static java.lang.String ARCSECOND
          Angle unit arcsecond.
static java.lang.String DEGREE
          Angle unit degree.
static java.lang.String RADIANT
          Angle unit radiant.
static java.lang.String XML_ATTRIBUTE_UNIT
          XML Attribute name for unit
 
Constructor Summary
Angle(double value, java.lang.String unit)
           
Angle(org.w3c.dom.Node angleNode)
          Constructs a new instance of an Angle from a given DOM target Element.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Overwrittes equals(Object) method from java.lang.Object.
 java.lang.String getUnit()
          Returns the unit of the angles value.
 double getValue()
          Returns the value of this angle.
 org.w3c.dom.Element setToXmlElement(org.w3c.dom.Element element)
          Sets this Angle to an given XML DOM Element.
 double toArcMin()
          Converts and sets this Angles value and unit to an Angle given in arcminutes.
 double toArcSec()
          Converts and sets this Angles value and unit to an Angle given in arcseconds.
 double toDegree()
          Converts and sets this Angles value and unit to an Angle given in degrees.
 double toRadiant()
          Converts and sets this Angles value and unit to an Angle given in radiant.
 java.lang.String toString()
          Overwrittes toString() method from java.lang.Object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEGREE

public static final java.lang.String DEGREE
Angle unit degree. A degree is the 360th part of a circle. A degree can be divided in 60 arcseconds. In radiant values a degree is degreeValue/180PI.

See Also:
Constant Field Values

RADIANT

public static final java.lang.String RADIANT
Angle unit radiant. In degree values a radiant is radiantValue/PI180.

See Also:
Constant Field Values

ARCMINUTE

public static final java.lang.String ARCMINUTE
Angle unit arcminute. A arcminute is the 60th part of a degree.

See Also:
Constant Field Values

ARCSECOND

public static final java.lang.String ARCSECOND
Angle unit arcsecond. A arcsecond is the 60th part of a arcminute.

See Also:
Constant Field Values

XML_ATTRIBUTE_UNIT

public static final java.lang.String XML_ATTRIBUTE_UNIT
XML Attribute name for unit

See Also:
Constant Field Values
Constructor Detail

Angle

public Angle(org.w3c.dom.Node angleNode)
      throws SchemaException
Constructs a new instance of an Angle from a given DOM target Element.

Parameters:
angleNode - The origin XML DOM angle Element
Throws:
SchemaException - if given angleNode was null

Angle

public Angle(double value,
             java.lang.String unit)
      throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException
Method Detail

toString

public java.lang.String toString()
Overwrittes toString() method from java.lang.Object.
Returns the value of this Angle followed by its unit.
Example:
42.0 DEGREE

Overrides:
toString in class java.lang.Object
Returns:
The angle value followed by its unit
See Also:
Object

equals

public boolean equals(java.lang.Object obj)
Overwrittes equals(Object) method from java.lang.Object.
Checks if this Angle and the given Object are equal. Two Angles are equal if both have the same value when represented as degree based angle.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The Object to compare this Angle with.
Returns:
true if both Objects are instances from class Angle and their values in degrees is equal.
See Also:
Object

setToXmlElement

public org.w3c.dom.Element setToXmlElement(org.w3c.dom.Element element)
Sets this Angle to an given XML DOM Element.
The Angles value will be set as the Elements value and the Angles unit will be set as the Elements attribute.
Example:
<element unit="degree">40.3</element>

Parameters:
element - The XML DOM Element this Angle belongs to
Returns:
Returns the element given as parameter with this Angles value as element value and this Angles unit as attribute
See Also:
Element

getUnit

public java.lang.String getUnit()
Returns the unit of the angles value.
The returned value may be any valid Angle unit, which can be accessed by Angles constants.

Returns:
This angles value unit.

getValue

public double getValue()
Returns the value of this angle.
The returned value may be any double value (positiv or negativ).

Returns:
This angles value

toDegree

public double toDegree()
Converts and sets this Angles value and unit to an Angle given in degrees.
If the Angle is already given in degree, the Angle will not change.

Returns:
This Angles new value based on degree units.

toArcMin

public double toArcMin()
Converts and sets this Angles value and unit to an Angle given in arcminutes.
If the Angle is already given in arcminutes, the Angle will not change.

Returns:
This Angles new value based on arcminute units.

toArcSec

public double toArcSec()
Converts and sets this Angles value and unit to an Angle given in arcseconds.
If the Angle is already given in arcseconds, the Angle will not change.

Returns:
This Angles new value based on arcsecond units.

toRadiant

public double toRadiant()
Converts and sets this Angles value and unit to an Angle given in radiant.
If the Angle is already given in radiants, the Angle will not change.

Returns:
This Angles new value based on radiant units.