チェンジセット 3542

差分発生行の前後
無視リスト:
コミット日時:
2010/03/14 22:08:11 (2 年前)
コミッタ:
hkrn
ログメッセージ:

fixed a bug that works incorrectly at using R and T button

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/CanvasModule.as

    r3532 r3542  
    102102         
    103103        /** 
    104          * 最後に移動した座標を保存する 
     104         * 始点と終点を取得する(現在は単体テスト用に使われているのみ) 
     105         *  
     106         * @param start 始点 
     107         * @param end 終点 
     108         */ 
     109        public function getLineSegment(start:Point, end:Point):void 
     110        { 
     111            start.x = s_startPointX; 
     112            start.y = s_startPointY; 
     113            end.x = s_endPointX; 
     114            end.y = s_endPointY; 
     115        } 
     116         
     117        /** 
     118         * 始点と終点の座標を保存する 
    105119         *  
    106120         * @param x 
    107121         * @param y 
    108122         */ 
    109         public function saveCoordinate(x:Number, y:Number):void 
    110         { 
    111             s_coordinateXWithButtonDown = s_coordinateX; 
    112             s_coordinateYWithButtonDown = s_coordinateY; 
    113             s_coordinateXWithButtonUp = x; 
    114             s_coordinateYWithButtonUp = y; 
     123        protected function saveCoordinate(x:Number, y:Number):void 
     124        { 
     125            s_startPointX = s_coordinateX; 
     126            s_startPointY = s_coordinateY; 
     127            s_endPointX = x; 
     128            s_endPointY = y; 
    115129        } 
    116130         
     
    138152        protected function setCoordinate(x:Number, y:Number):void 
    139153        { 
    140             if (s_shouldStartAfterDrawing) { 
    141                 s_coordinateX = s_coordinateXWithButtonUp
    142                 s_coordinateY = s_coordinateYWithButtonUp
     154            if (s_shouldDrawFromEndPoint) { 
     155                s_coordinateX = s_endPointX
     156                s_coordinateY = s_endPointY
    143157            } 
    144             else if (s_shouldStartBeforeDrawing) { 
    145                 s_coordinateX = s_coordinateXWithButtonDown
    146                 s_coordinateY = s_coordinateYWithButtonDown
     158            else if (s_shouldDrawFromStartPoint) { 
     159                s_coordinateX = s_startPointX
     160                s_coordinateY = s_startPointY
    147161            } 
    148162            else { 
     
    224238        } 
    225239         
    226         /** 
    227          * 開始座標を描写終了後の座標に設定するかどうか (R) 
    228          *  
    229          * @param value  
    230          */ 
    231         public function set shouldStartAfterDrawing(value:Boolean):void 
    232         { 
    233             s_shouldStartAfterDrawing = value; 
    234         } 
    235          
    236         /** 
    237          * 開始座標を描写開始時の座標に設定するかどうか (T) 
    238          *  
    239          * @param value  
    240          */ 
    241         public function set shouldStartBeforeDrawing(value:Boolean):void 
    242         { 
    243             s_shouldStartBeforeDrawing = value; 
     240        public function set shouldDrawFromStartPoint(value:Boolean):void 
     241        { 
     242            s_shouldDrawFromStartPoint = value; 
     243        } 
     244         
     245        public function set shouldDrawFromEndPoint(value:Boolean):void 
     246        { 
     247            s_shouldDrawFromEndPoint = value; 
    244248        } 
    245249         
     
    341345        private static var s_coordinateX:Number = 0; 
    342346        private static var s_coordinateY:Number = 0; 
    343         private static var s_coordinateXWithButtonUp:Number = 0; 
    344         private static var s_coordinateYWithButtonUp:Number = 0; 
    345         private static var s_coordinateXWithButtonDown:Number = 0; 
    346         private static var s_coordinateYWithButtonDown:Number = 0; 
     347        private static var s_startPointX:Number = 0; 
     348        private static var s_startPointY:Number = 0; 
     349        private static var s_endPointX:Number = 0; 
     350        private static var s_endPointY:Number = 0; 
    347351        private static var s_keyA:Boolean = false; 
    348352        private static var s_keyQ:Boolean = false; 
    349         private static var s_shouldStartBeforeDrawing:Boolean = false; 
    350         private static var s_shouldStartAfterDrawing:Boolean = false; 
     353        private static var s_shouldDrawFromStartPoint:Boolean = false; 
     354        private static var s_shouldDrawFromEndPoint:Boolean = false; 
    351355        protected var m_recorder:Recorder; 
    352356    } 
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/CircleModule.as

    r3532 r3542  
    1414        public function CircleModule(recorder:Recorder) 
    1515        { 
     16            m_rectangle = new Rectangle(0, 0, 0, 0); 
    1617            super(recorder); 
    1718        } 
     
    2930            m_recorder.clear(); 
    3031            m_recorder.resetPen(); 
    31             m_recorder.moveTo(s_rectangle.x, s_rectangle.y); 
    32             m_recorder.drawCircle(s_rectangle.width); 
     32            m_recorder.moveTo(m_rectangle.x, m_rectangle.y); 
     33            m_recorder.drawCircle(m_rectangle.width); 
    3334        } 
    3435         
     
    4041                m_recorder.commitCommand( 
    4142                    MoveToCommand.ID, 
    42                     getArgumentsFromCoordinate(s_rectangle.x, s_rectangle.y) 
     43                    getArgumentsFromCoordinate(m_rectangle.x, m_rectangle.y) 
    4344                ); 
    4445                m_recorder.commitCommand( 
    4546                    DrawCircleCommand.ID, 
    46                     { "radius": s_rectangle.width } 
     47                    { "radius": m_rectangle.width } 
    4748                ); 
    4849                m_recorder.commitCommand( 
     
    5152                ); 
    5253            } 
     54            saveCoordinate(x, y); 
    5355        } 
    5456         
     
    6365        } 
    6466         
    65         protected function storeCircleCoordinate(x:Number, y:Number):void 
     67        private function storeCircleCoordinate(x:Number, y:Number):void 
    6668        { 
    6769            var dx:Number = x - coordinateX; 
    6870            var dy:Number = y - coordinateY; 
    6971            if (key_A) { 
    70                 s_rectangle.x = x + dx; 
    71                 s_rectangle.y = y - dy; 
     72                m_rectangle.x = x + dx; 
     73                m_rectangle.y = y - dy; 
    7274            } 
    7375            else if (key_Q) { 
    74                 s_rectangle.x = x - dx; 
    75                 s_rectangle.y = x + dy; 
     76                m_rectangle.x = x - dx; 
     77                m_rectangle.y = x + dy; 
    7678            } 
    7779            else { 
    78                 s_rectangle.x = coordinateX; 
    79                 s_rectangle.y = coordinateY; 
     80                m_rectangle.x = coordinateX; 
     81                m_rectangle.y = coordinateY; 
    8082            } 
    81             s_rectangle.width = Math.sqrt(dx * dx + dy * dy); 
    82             s_rectangle.height = 0; 
     83            m_rectangle.width = Math.sqrt(dx * dx + dy * dy); 
    8384        } 
    8485         
    85         private static var s_rectangle:Rectangle = new Rectangle()
     86        private var m_rectangle:Rectangle
    8687    } 
    8788} 
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/DropperModule.as

    r3524 r3542  
    2626        { 
    2727            drop(x, y); 
     28            saveCoordinate(x, y); 
    2829        } 
    2930         
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/EllipseModule.as

    r3532 r3542  
    3737                // TODO: implement this 
    3838            } 
     39            saveCoordinate(x, y); 
    3940        } 
    4041         
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/FloodFillModule.as

    r3524 r3542  
    3333        public function stop(x:Number, y:Number):void 
    3434        { 
     35            saveCoordinate(x, y); 
    3536        } 
    3637         
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/FreeHandModule.as

    r3532 r3542  
    7676                {} 
    7777            ); 
     78            saveCoordinate(x, y); 
    7879        } 
    7980         
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/ICanvasModule.as

    r3524 r3542  
    3838         */ 
    3939        function interrupt(x:Number, y:Number):void; 
    40          
    41         /** 
    42          * 最後に移動した位置を保存する 
    43          *  
    44          * @param x x座標 
    45          * @param y y座標 
    46         function saveCoordinate(x:Number, y:Number):void; 
    47          */ 
    4840         
    4941        /** 
     
    113105         
    114106        function set keyA(value:Boolean):void; 
     107         
    115108        function set keyQ(value:Boolean):void; 
    116         function set shouldStartAfterDrawing(value:Boolean):void; 
    117         function set shouldStartBeforeDrawing(value:Boolean):void; 
     109         
     110        /** 
     111         * 描写開始時に終点固定を設定するかどうか (T) 
     112         *  
     113         */ 
     114        function set shouldDrawFromStartPoint(value:Boolean):void; 
     115         
     116        /** 
     117         * 描写開始時に始点固定を設定するかどうか (R) 
     118         *  
     119         */ 
     120        function set shouldDrawFromEndPoint(value:Boolean):void; 
    118121         
    119122        /** 
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/LineModule.as

    r3532 r3542  
    4040                m_recorder.commitCommand(CompositeCommand.ID, {}); 
    4141            } 
     42            saveCoordinate(x, y); 
    4243        } 
    4344         
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/PixelModule.as

    r3532 r3542  
    2626        public function stop(x:Number, y:Number):void 
    2727        { 
     28            saveCoordinate(x, y); 
    2829        } 
    2930         
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/RectModule.as

    r3532 r3542  
    3737                // TODO: implement this 
    3838            } 
     39            saveCoordinate(x, y); 
    3940        } 
    4041         
  • as3/gunyarapaint/branches/gunyarapaint/framework/src/org/libspark/gunyarapaint/framework/modules/RoundRectModule.as

    r3532 r3542  
    3030                // TODO: implement this 
    3131            } 
     32            saveCoordinate(x, y); 
    3233        } 
    3334         
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/CircleModuleTest.as

    r3534 r3542  
    66    import org.libspark.gunyarapaint.framework.Recorder; 
    77    import org.libspark.gunyarapaint.framework.commands.ICommand; 
     8    import org.libspark.gunyarapaint.framework.modules.CanvasModule; 
    89    import org.libspark.gunyarapaint.framework.modules.CanvasModuleContext; 
    910    import org.libspark.gunyarapaint.framework.modules.CircleModule; 
     
    3334            m_module.start(1, 1); 
    3435            m_module.stop(1, 1); 
    35             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    36             Assert.assertEquals(0, commands.length); 
     36            ModuleTestUtil.countCommands(0, m_bytes); 
    3737        } 
    3838         
     
    4343            m_module.move(2, 2); 
    4444            m_module.stop(3, 3); 
    45             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    46             Assert.assertEquals(3, commands.length); 
     45            ModuleTestUtil.countCommands(3, m_bytes); 
     46        } 
     47         
     48        [Test] 
     49        public function getLineSegment():void 
     50        { 
     51            ModuleTestUtil.getLineSegment(m_module); 
    4752        } 
    4853         
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/DropperModuleTest.as

    r3534 r3542  
    3434            m_module.move(2, 2); 
    3535            m_module.stop(3, 3); 
    36             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    37             Assert.assertEquals(3, commands.length); 
     36            ModuleTestUtil.countCommands(3, m_bytes); 
     37        } 
     38         
     39        [Test] 
     40        public function getLineSegment():void 
     41        { 
     42            ModuleTestUtil.getLineSegment(m_module); 
    3843        } 
    3944         
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/EllipseModuleTest.as

    r3534 r3542  
    3535            m_module.start(1, 1); 
    3636            m_module.stop(1, 1); 
    37             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    38             Assert.assertEquals(0, commands.length); 
     37            ModuleTestUtil.countCommands(0, m_bytes); 
    3938        } 
    4039         
     
    4443        } 
    4544         
     45        [Test] 
     46        public function getLineSegment():void 
     47        { 
     48            ModuleTestUtil.getLineSegment(m_module); 
     49        } 
     50         
    4651        private var m_bytes:ByteArray; 
    4752        private var m_module:ICanvasModule; 
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/FloodFillModuleTest.as

    r3534 r3542  
    3434            m_module.move(2, 2); 
    3535            m_module.stop(3, 3); 
    36             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    37             Assert.assertEquals(2, commands.length); 
     36            ModuleTestUtil.countCommands(2, m_bytes); 
     37        } 
     38         
     39        [Test] 
     40        public function getLineSegment():void 
     41        { 
     42            ModuleTestUtil.getLineSegment(m_module); 
    3843        } 
    3944         
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/FreeHandModuleTest.as

    r3534 r3542  
    3333            m_module.start(1, 1); 
    3434            m_module.stop(1, 1); 
    35             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    36             Assert.assertEquals(7, commands.length); 
     35            ModuleTestUtil.countCommands(7, m_bytes); 
    3736        } 
    3837         
     
    4342            m_module.move(2, 2); 
    4443            m_module.stop(3, 3); 
    45             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    46             Assert.assertEquals(3, commands.length); 
     44            ModuleTestUtil.countCommands(3, m_bytes); 
     45        } 
     46         
     47        [Test] 
     48        public function getLineSegment():void 
     49        { 
     50            ModuleTestUtil.getLineSegment(m_module); 
    4751        } 
    4852         
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/LineModuleTest.as

    r3534 r3542  
    3333            m_module.start(1, 1); 
    3434            m_module.stop(1, 1); 
    35             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    36             Assert.assertEquals(0, commands.length); 
     35            ModuleTestUtil.countCommands(0, m_bytes); 
    3736        } 
    3837         
     
    4342            m_module.move(2, 2); 
    4443            m_module.stop(3, 3); 
    45             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    46             Assert.assertEquals(3, commands.length); 
     44            ModuleTestUtil.countCommands(3, m_bytes); 
     45        } 
     46         
     47        [Test] 
     48        public function getLineSegment():void 
     49        { 
     50            ModuleTestUtil.getLineSegment(m_module); 
    4751        } 
    4852         
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/ModuleTestUtil.as

    r3534 r3542  
    22{ 
    33    import flash.errors.IllegalOperationError; 
     4    import flash.geom.Point; 
    45    import flash.utils.ByteArray; 
    56     
     7    import org.flexunit.Assert; 
    68    import org.libspark.gunyarapaint.framework.FakePainter; 
    79    import org.libspark.gunyarapaint.framework.Parser; 
    810    import org.libspark.gunyarapaint.framework.Recorder; 
    911    import org.libspark.gunyarapaint.framework.commands.ICommand; 
     12    import org.libspark.gunyarapaint.framework.modules.CanvasModule; 
     13    import org.libspark.gunyarapaint.framework.modules.ICanvasModule; 
    1014 
    1115    internal final class ModuleTestUtil 
     
    3943            return commands; 
    4044        } 
     45         
     46        public static function countCommands(expected:uint, bytes:ByteArray):void 
     47        { 
     48            Assert.assertEquals(expected, getCommands(bytes).length); 
     49        } 
     50         
     51        public static function getLineSegment(module:ICanvasModule):void 
     52        { 
     53            var start:Point = new Point(); 
     54            var end:Point = new Point(); 
     55            module.start(12, 34); 
     56            module.stop(56, 78); 
     57            CanvasModule(module).getLineSegment(start, end); 
     58            Assert.assertEquals(start.x, 12); 
     59            Assert.assertEquals(start.y, 34); 
     60            Assert.assertEquals(end.x, 56); 
     61            Assert.assertEquals(end.y, 78); 
     62        } 
    4163    } 
    4264} 
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/PixelModuleTest.as

    r3534 r3542  
    3333            m_module.start(1, 1); 
    3434            m_module.stop(1, 1); 
    35             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    36             Assert.assertEquals(1, commands.length); 
     35            ModuleTestUtil.countCommands(1, m_bytes); 
    3736        } 
    3837         
     
    4342            m_module.move(2, 2); 
    4443            m_module.stop(3, 3); 
    45             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    46             Assert.assertEquals(2, commands.length); 
     44            ModuleTestUtil.countCommands(2, m_bytes); 
     45        } 
     46         
     47        [Test] 
     48        public function getLineSegment():void 
     49        { 
     50            ModuleTestUtil.getLineSegment(m_module); 
    4751        } 
    4852         
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/RectModuleTest.as

    r3534 r3542  
    3333            m_module.start(1, 1); 
    3434            m_module.stop(1, 1); 
    35             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    36             Assert.assertEquals(0, commands.length); 
     35            ModuleTestUtil.countCommands(0, m_bytes); 
    3736        } 
    3837         
     
    4241        } 
    4342         
     43        [Test] 
     44        public function getLineSegment():void 
     45        { 
     46            ModuleTestUtil.getLineSegment(m_module); 
     47        } 
     48         
    4449        private var m_bytes:ByteArray; 
    4550        private var m_module:ICanvasModule; 
  • as3/gunyarapaint/branches/gunyarapaint/test/src/org/libspark/gunyarapaint/framework/module/RoundRectModuleTest.as

    r3534 r3542  
    3333            m_module.start(1, 1); 
    3434            m_module.stop(1, 1); 
    35             var commands:Vector.<ICommand> = ModuleTestUtil.getCommands(m_bytes); 
    36             Assert.assertEquals(0, commands.length); 
     35            ModuleTestUtil.countCommands(0, m_bytes); 
    3736        } 
    3837         
     
    4241        } 
    4342         
     43        [Test] 
     44        public function getLineSegment():void 
     45        { 
     46            ModuleTestUtil.getLineSegment(m_module); 
     47        } 
     48         
    4449        private var m_bytes:ByteArray; 
    4550        private var m_module:ICanvasModule;