You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2014/03/16 02:00:23 UTC
[23/50] [abbrv] rename folder
http://git-wip-us.apache.org/repos/asf/flex-flexunit/blob/68f0bd35/FlexUnit4Tutorials/Unit4/startx/FlexUnit4Training_wt3/src/net/digitalprimates/math/Circle.as
----------------------------------------------------------------------
diff --git a/FlexUnit4Tutorials/Unit4/startx/FlexUnit4Training_wt3/src/net/digitalprimates/math/Circle.as b/FlexUnit4Tutorials/Unit4/startx/FlexUnit4Training_wt3/src/net/digitalprimates/math/Circle.as
deleted file mode 100644
index 5f4978a..0000000
--- a/FlexUnit4Tutorials/Unit4/startx/FlexUnit4Training_wt3/src/net/digitalprimates/math/Circle.as
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.digitalprimates.math {
- import flash.geom.Point;
-
- /**
- * Class to represent a mathematical circle in addition to circle-specific convenience methods.
- *
- * @author mlabriola
- *
- */
- public class Circle {
- /**
- * Constant representing the number of radians in a circle
- */
- public static const RADIANS_PER_CIRCLE:Number = Math.PI * 2;
-
- private var _origin:Point = new Point( 0, 0 );
- private var _radius:Number;
-
- /**
- * Returns the circle's origin point as a <code>flash.geom.Point</code> object.
- * The <code>origin</code> is a read only property supplied during the instantiation
- * of the Circle.
- *
- * @return The circle's origin point.
- *
- */
- public function get origin():Point {
- return _origin;
- }
-
- /**
- * Returns the circle's radius as a <code>Number</code>.
- * The <code>radius</code> is a read only property supplied during the instantiation
- * of the Circle.
- *
- * @return The circle's radius.
- */
- public function get radius():Number {
- return _radius;
- }
-
- /**
- * Returns the circle's diameter based on the <code>radius</code> property.
- * The <code>diameter</code> is a read only property.
- *
- * @see #radius
- * @return The circle's diameter.
- */
- public function get diameter():Number {
- return radius * 2;
- }
-
- /**
- * Returns a point on the circle at a given radian offset.
- *
- * @param t radian position along the circle. 0 is the top-most point of the circle.
- * @return a Point object describing the cartesian coordinate of the point.
- *
- */
- public function getPointOnCircle( t:Number ):Point {
- var x:Number = origin.x + ( radius * Math.cos( t ) );
- var y:Number = origin.y + ( radius * Math.sin( t ) );
-
- return new Point( x, y );
- }
-
- /**
- *
- * Convenience method for converting radians to degrees.
- *
- * @param radians a radian offset from the top-most point of the circle.
- * @return a corresponding angle represented in degrees.
- *
- */
- public function radiansToDegrees( radians:Number ):Number {
- return ( ( radians - Math.PI/2 ) * 180 / Math.PI );
- }
-
- /**
- * Comparison method to determine circle equivalence (same center and radius).
- *
- * @param circle a circle for comparison
- * @return a boolean indicating if the circles are equivalent
- *
- */
- public function equals( circle:Circle ):Boolean {
- var equal:Boolean = false;
-
- if ( ( circle ) && ( this.radius == circle.radius ) && ( this.origin ) && ( circle.origin ) ) {
- if ( ( this.origin.x == circle.origin.x ) && ( this.origin.y == circle.origin.y ) ) {
- equal = true;
- }
- }
-
- return equal;
- }
-
- /**
- * Creates a new circle
- *
- * @param origin the origin point of the new circle
- * @param radius the radius of the new circle
- *
- */
- public function Circle( origin:Point, radius:Number ) {
-
- if ( ( radius <= 0 ) || isNaN( radius ) ) {
- throw new RangeError("Radius must be a positive Number");
- }
-
- this._origin = origin;
- this._radius = radius;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-flexunit/blob/68f0bd35/FlexUnit4Tutorials/Unit4/startx/FlexUnit4Training_wt3/tests/math/testcases/BasicCircleTest.as
----------------------------------------------------------------------
diff --git a/FlexUnit4Tutorials/Unit4/startx/FlexUnit4Training_wt3/tests/math/testcases/BasicCircleTest.as b/FlexUnit4Tutorials/Unit4/startx/FlexUnit4Training_wt3/tests/math/testcases/BasicCircleTest.as
deleted file mode 100644
index f85bf23..0000000
--- a/FlexUnit4Tutorials/Unit4/startx/FlexUnit4Training_wt3/tests/math/testcases/BasicCircleTest.as
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package math.testcases {
- import flash.geom.Point;
-
- import net.digitalprimates.math.Circle;
-
- import org.flexunit.asserts.assertEquals;
- import org.flexunit.asserts.assertFalse;
- import org.flexunit.asserts.assertTrue;
-
- public class BasicCircleTest {
-
- [Test]
- public function shouldReturnProvidedRadius():void {
- var circle:Circle = new Circle( new Point( 0, 0 ), 5 );
- assertEquals( 5, circle.radius );
- }
-
- [Test]
- public function shouldComputeCorrectDiameter ():void {
- var circle:Circle = new Circle( new Point( 0, 0 ), 5 );
- assertEquals( 10, circle.diameter );
- }
-
- [Test]
- public function shouldReturnProvidedOrigin():void {
- var circle:Circle = new Circle( new Point( 0, 0 ), 5 );
- assertEquals( 0, circle.origin.x );
- assertEquals( 0, circle.origin.y );
- }
-
- [Test]
- public function shouldReturnTrueForEqualCircle():void {
- var circle:Circle = new Circle( new Point( 0, 0 ), 5 );
- var circle2:Circle = new Circle( new Point( 0, 0 ), 5 );
-
- assertTrue( circle.equals( circle2 ) );
- }
-
- [Test]
- public function shouldReturnFalseForUnequalOrigin():void {
- var circle:Circle = new Circle( new Point( 0, 0 ), 5 );
- var circle2:Circle = new Circle( new Point( 0, 5 ), 5);
-
- assertFalse( circle.equals( circle2 ) );
- }
-
- [Test]
- public function shouldReturnFalseForUnequalRadius():void {
- var circle:Circle = new Circle( new Point( 0, 0 ), 5 );
- var circle2:Circle = new Circle( new Point( 0, 0 ), 7);
-
- assertFalse( circle.equals( circle2 ) );
- }
-
- [Test]
- public function shouldGetPointsOnCircle():void {
- var circle:Circle = new Circle( new Point( 0, 0 ), 5 );
- var point:Point;
-
- //top-most point of circle
- point = circle.getPointOnCircle( 0 );
- assertEquals( 5, point.x );
- assertEquals( 0, point.y );
-
- //bottom-most point of circle
- point = circle.getPointOnCircle( Math.PI );
- assertEquals( -5, point.x );
- assertEquals( 0, point.y );
- }
-
- [Test]
- public function shouldThrowRangeError():void {
-
- }
-
-
- }
-}
\ No newline at end of file