You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/05/01 18:26:42 UTC

svn commit: r770742 - in /incubator/pivot/trunk/wtk/test/pivot/wtk: media/drawing/test/RotationTest.java media/drawing/test/rotate.wtkd media/drawing/test/sample.wtkd test/MovieViewTest.java

Author: gbrown
Date: Fri May  1 16:26:41 2009
New Revision: 770742

URL: http://svn.apache.org/viewvc?rev=770742&view=rev
Log:
Add rotation test.

Added:
    incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/RotationTest.java
    incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/rotate.wtkd
Modified:
    incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd
    incubator/pivot/trunk/wtk/test/pivot/wtk/test/MovieViewTest.java

Added: incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/RotationTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/RotationTest.java?rev=770742&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/RotationTest.java (added)
+++ incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/RotationTest.java Fri May  1 16:26:41 2009
@@ -0,0 +1,53 @@
+package pivot.wtk.media.drawing.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.ApplicationContext;
+import pivot.wtk.DesktopApplicationContext;
+import pivot.wtk.Display;
+import pivot.wtk.ImageView;
+import pivot.wtk.Window;
+import pivot.wtk.media.Image;
+import pivot.wtk.media.drawing.Shape;
+import pivot.wtkx.WTKXSerializer;
+
+public class RotationTest implements Application {
+    private Window window = null;
+
+    public void startup(Display display, Dictionary<String, String> properties)
+        throws Exception{
+        WTKXSerializer wtkxSerializer = new WTKXSerializer();
+        Image image = (Image)wtkxSerializer.readObject(getClass().getResource("rotate.wtkd"));
+
+        final Shape.Rotate rotation = (Shape.Rotate)wtkxSerializer.getObjectByName("rotation");
+        ApplicationContext.scheduleRecurringCallback(new Runnable() {
+            public void run() {
+                int angle = (int)rotation.getAngle();
+                angle = (angle + 6) % 360;
+                rotation.setAngle(angle);
+            }
+        }, 1000);
+
+        window = new Window(new ImageView(image));
+        window.setMaximized(true);
+        window.open(display);
+    }
+
+    public boolean shutdown(boolean optional) {
+        if (window != null) {
+            window.close();
+        }
+
+        return true;
+    }
+
+    public void suspend() {
+    }
+
+    public void resume() {
+    }
+
+    public static void main(String[] args) {
+        DesktopApplicationContext.main(RotationTest.class, args);
+    }
+}

Added: incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/rotate.wtkd
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/rotate.wtkd?rev=770742&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/rotate.wtkd (added)
+++ incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/rotate.wtkd Fri May  1 16:26:41 2009
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<Drawing width="320" height="320" background="#cccccc" 
+    xmlns="pivot.wtk.media"
+    xmlns:wtkx="http://incubator.apache.org/pivot/wtkx/1.1">
+    <canvas>
+        <Canvas xmlns="pivot.wtk.media.drawing">
+            <Line x1="0" y1="0" x2="0" y2="-160" strokeThickness="4">
+                <transforms>
+                    <Shape.Translate x="160" y="160"/>
+                    <Shape.Rotate wtkx:id="rotation"/>
+                </transforms>
+            </Line>
+        </Canvas>
+    </canvas>
+</Drawing>

Modified: incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd?rev=770742&r1=770741&r2=770742&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd (original)
+++ incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd Fri May  1 16:26:41 2009
@@ -17,7 +17,8 @@
 -->
 
 <Drawing width="640" height="480" background="#ffff00"
-    xmlns="pivot.wtk.media">
+    xmlns="pivot.wtk.media"
+    xmlns:wtkx="http://incubator.apache.org/pivot/wtkx/1.1">
     <canvas>
         <Canvas xmlns="pivot.wtk.media.drawing">
             <Rectangle x="10" y="20"

Modified: incubator/pivot/trunk/wtk/test/pivot/wtk/test/MovieViewTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/pivot/wtk/test/MovieViewTest.java?rev=770742&r1=770741&r2=770742&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/pivot/wtk/test/MovieViewTest.java (original)
+++ incubator/pivot/trunk/wtk/test/pivot/wtk/test/MovieViewTest.java Fri May  1 16:26:41 2009
@@ -21,6 +21,7 @@
 
 import pivot.collections.Dictionary;
 import pivot.wtk.Application;
+import pivot.wtk.DesktopApplicationContext;
 import pivot.wtk.Display;
 import pivot.wtk.MovieView;
 import pivot.wtk.Window;
@@ -35,7 +36,7 @@
     private Movie movie = new Movie() {
         private int angle = 6;
         private Drawing drawing = new Drawing();
-            private Shape.Rotate rotateTransform = new Shape.Rotate();
+            private Shape.Rotate rotateTransform = new Shape.Rotate(0, 320, 240);
 
         {
             setLooping(true);
@@ -44,17 +45,17 @@
             drawing.setSize(640, 480);
 
             Line line = new Line();
-            /*
             line.setX1(220);
             line.setY1(240);
             line.setX2(220);
             line.setY2(40);
-            */
+            /*
             line.setOrigin(320, 240);
             line.setX1(0);
             line.setY1(0);
             line.setX2(0);
             line.setY2(-200);
+            */
 
             line.setStroke(Color.BLACK);
             line.setStrokeThickness(5);
@@ -90,6 +91,10 @@
         }
     };
 
+    public static void main(String[] args) {
+        DesktopApplicationContext.main(MovieViewTest.class, args);
+    }
+
     public void startup(Display display, Dictionary<String, String> properties) {
         window = new Window();
         window.setMaximized(true);