1 /* 2 * Copyright the original author or authors. 3 * 4 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.mozilla.org/MPL/MPL-1.1.html 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import org.as2lib.data.type.Angle; 18 import org.as2lib.Config; 19 20 /** 21 * {@code Degree} represents a angle in degree. 22 * 23 * @author Martin Heidegger 24 */ 25 class org.as2lib.data.type.Degree extends Number implements Angle { 26 27 /** Angle in degree. */ 28 private var degree:Number; 29 30 /** 31 * Constructs a new {@code Degree} instance. 32 * 33 * @param degree the angle in degree 34 */ 35 public function Degree(degree:Number) { 36 this.degree = degree; 37 } 38 39 /** 40 * Returns the angle in degree as number. 41 * 42 * @return the angle in degree as number 43 */ 44 public function valueOf(Void):Number { 45 return degree; 46 } 47 48 /** 49 * Returns the angle in radian. 50 * 51 * @return the angle in radian 52 */ 53 public function toRadian(Void):Number { 54 return (degree * Math.PI/180); 55 } 56 57 /** 58 * Returns the angle in degree. 59 * 60 * @return the angle in degree 61 */ 62 public function toDegree(Void):Number { 63 return degree; 64 } 65 66 /** 67 * Returns the string representation of this instance. 68 * 69 * <p>The string representation is obtained via the stringifier returned by the 70 * {@link Config#getObjectStringifier} method. 71 * 72 * @return the string representation of this instance 73 */ 74 public function toString():String { 75 return Config.getObjectStringifier().execute(this); 76 } 77 78 }