devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1749229 - in /devicemap/trunk/examples/1.0/java/gwtcanvas: src/org/apache/devicemap/gwt/gwtcanvasdemo/client/ war/
Date Sun, 19 Jun 2016 23:15:51 GMT
Author: wkeil
Date: Sun Jun 19 23:15:51 2016
New Revision: 1749229

URL: http://svn.apache.org/viewvc?rev=1749229&view=rev
Log:
DMAP-153: Add a demo for HTML5 Canvas 

Task-Url: https://issues.apache.org/jira/browse/DMAP-153

Added:
    devicemap/trunk/examples/1.0/java/gwtcanvas/war/asflogo40_40.png   (with props)
    devicemap/trunk/examples/1.0/java/gwtcanvas/war/asflogo40_40.xcf   (with props)
    devicemap/trunk/examples/1.0/java/gwtcanvas/war/feather40_40.png   (with props)
    devicemap/trunk/examples/1.0/java/gwtcanvas/war/feather40_40.xcf   (with props)
Modified:
    devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/DmapGwtCanvas.java
    devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Logo.java
    devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/LogoGroup.java
    devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Vector.java
    devicemap/trunk/examples/1.0/java/gwtcanvas/war/DmapGwtCanvas.html

Modified: devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/DmapGwtCanvas.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/DmapGwtCanvas.java?rev=1749229&r1=1749228&r2=1749229&view=diff
==============================================================================
--- devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/DmapGwtCanvas.java
(original)
+++ devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/DmapGwtCanvas.java
Sun Jun 19 23:15:51 2016
@@ -15,11 +15,13 @@
  */
 
 package org.apache.devicemap.gwt.gwtcanvasdemo.client;
-
+import com.google.gwt.user.client.Window;
+import com.google.gwt.useragent.client.UserAgent;
 import com.google.gwt.canvas.client.Canvas;
 import com.google.gwt.canvas.dom.client.Context2d;
 import com.google.gwt.canvas.dom.client.CssColor;
 import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
 import com.google.gwt.dom.client.Touch;
 import com.google.gwt.event.dom.client.GestureStartEvent;
 import com.google.gwt.event.dom.client.GestureStartHandler;
@@ -33,126 +35,133 @@ import com.google.gwt.event.dom.client.T
 import com.google.gwt.event.dom.client.TouchMoveHandler;
 import com.google.gwt.user.client.Timer;
 import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.RootPanel;	
 
 public class DmapGwtCanvas implements EntryPoint {
-  static final String HOLDER_ID = "canvasholder";
-  static final String UPGRADE_MESSAGE = "Your browser does not support the HTML5 Canvas.
Please upgrade your browser to view this demo.";
+    private static final String HOLDER_ID = "canvasholder";
+    private static final String UPGRADE_MESSAGE = "Your browser does not support the HTML5
Canvas. Please upgrade your browser to view this demo.";
+
+    // timer refresh rate, in milliseconds
+    private static final int REFRESH_RATE = 25;
 
-  private Canvas canvas;
-  private Canvas backBuffer;
-  private LogoGroup logoGroup;
-  private BallGroup ballGroup;
-  private Lens lens;
-  
-  // mouse positions relative to canvas
-  private int mouseX;
-  private int mouseY;
-
-  //timer refresh rate, in milliseconds
-  static final int REFRESH_RATE = 25;
-  
-  // canvas size, in px
-  private int height = 300;
-  private int width = 300;
-  
-  final CssColor redrawColor = CssColor.make("rgba(255,255,255,0.6)");
-  Context2d context;
-  Context2d backBufferContext;
-  
-  public void onModuleLoad() {
-    height = 300;
-    width = 300;
-      
-    canvas = Canvas.createIfSupported();
-    backBuffer = Canvas.createIfSupported();
-    if (canvas == null) {
-      RootPanel.get(HOLDER_ID).add(new Label(UPGRADE_MESSAGE));
-      return;
+    private Canvas canvas;
+    private Canvas backBuffer;
+    private LogoGroup logoGroup;
+    private BallGroup ballGroup;
+    private Lens lens;
+
+    // mouse positions relative to canvas
+    private int mouseX;
+    private int mouseY;
+
+    // canvas size, in px
+    private int height;
+    private int width;
+
+    final CssColor redrawColor = CssColor.make("rgba(255,255,255,0.6)");
+    Context2d context;
+    Context2d backBufferContext;
+
+    public void onModuleLoad() {
+	UserAgent impl = GWT.create(UserAgent.class);
+	Window win = GWT.create(Window.class);
+	
+	String compileTimeValue = impl.getCompileTimeValue();
+	String runtimeValue = impl.getRuntimeValue();
+	System.out.println(compileTimeValue + "->" + runtimeValue);
+	height = win.getClientHeight() - 100;
+	width = win.getClientWidth() - 80;
+
+	canvas = Canvas.createIfSupported();
+	backBuffer = Canvas.createIfSupported();
+	if (canvas == null) {
+	    RootPanel.get(HOLDER_ID).add(new Label(UPGRADE_MESSAGE));
+	    return;
+	}
+
+	// init the canvases
+	canvas.setWidth(width + "px");
+	canvas.setHeight(height + "px");
+	canvas.setCoordinateSpaceWidth(width);
+	canvas.setCoordinateSpaceHeight(height);
+	backBuffer.setCoordinateSpaceWidth(width);
+	backBuffer.setCoordinateSpaceHeight(height);
+	RootPanel.get(HOLDER_ID).add(canvas);
+	context = canvas.getContext2d();
+	backBufferContext = backBuffer.getContext2d();
+
+	// init the objects
+	logoGroup = new LogoGroup(width, height, 18, 165);
+	ballGroup = new BallGroup(width, height);
+	lens = new Lens(35, 15, width, height, new Vector(320, 150),
+		new Vector(1, 1));
+
+	// init handlers
+	initHandlers();
+
+	// setup timer
+	final Timer timer = new Timer() {
+	    @Override
+	    public void run() {
+		doUpdate();
+	    }
+	};
+	timer.scheduleRepeating(REFRESH_RATE);
     }
 
-    // init the canvases
-    canvas.setWidth(width + "px");
-    canvas.setHeight(height + "px");
-    canvas.setCoordinateSpaceWidth(width);
-    canvas.setCoordinateSpaceHeight(height);
-    backBuffer.setCoordinateSpaceWidth(width);
-    backBuffer.setCoordinateSpaceHeight(height);
-    RootPanel.get(HOLDER_ID).add(canvas);
-    context = canvas.getContext2d();
-    backBufferContext = backBuffer.getContext2d();
-    
-    // init the objects
-    logoGroup = new LogoGroup(width, height, 18, 165);
-    ballGroup = new BallGroup(width, height);
-    lens = new Lens(35, 15, width, height, new Vector(320, 150), new Vector(1, 1));
-
-    // init handlers
-    initHandlers();
-    
-    // setup timer
-    final Timer timer = new Timer() {
-      @Override
-      public void run() {
-        doUpdate();
-      }
-    };
-    timer.scheduleRepeating(REFRESH_RATE);
-  }
-
-  void doUpdate() {
-    // update the back canvas
-    backBufferContext.setFillStyle(redrawColor);
-    backBufferContext.fillRect(0, 0, width, height);
-    logoGroup.update(mouseX, mouseY);
-    ballGroup.update(mouseX, mouseY);
-    logoGroup.draw(backBufferContext);
-    ballGroup.draw(backBufferContext);
-
-    // update the front canvas
-    lens.update();
-    lens.draw(backBufferContext, context);
-  }
-  
-  void initHandlers() {
-    canvas.addMouseMoveHandler(new MouseMoveHandler() {
-      public void onMouseMove(MouseMoveEvent event) {
-        mouseX = event.getRelativeX(canvas.getElement());
-        mouseY = event.getRelativeY(canvas.getElement());
-      }
-    });
-
-    canvas.addMouseOutHandler(new MouseOutHandler() {
-      public void onMouseOut(MouseOutEvent event) {
-        mouseX = -200;
-        mouseY = -200;
-      }
-    });
-
-    canvas.addTouchMoveHandler(new TouchMoveHandler() {
-      public void onTouchMove(TouchMoveEvent event) {
-        event.preventDefault();
-        if (event.getTouches().length() > 0) {
-          Touch touch = event.getTouches().get(0);
-          mouseX = touch.getRelativeX(canvas.getElement());
-          mouseY = touch.getRelativeY(canvas.getElement());
-        }
-        event.preventDefault();
-      }
-    });
-
-    canvas.addTouchEndHandler(new TouchEndHandler() {
-      public void onTouchEnd(TouchEndEvent event) {
-        event.preventDefault();
-        mouseX = -200;
-        mouseY = -200;
-      }
-    });
-
-    canvas.addGestureStartHandler(new GestureStartHandler() {
-      public void onGestureStart(GestureStartEvent event) {
-        event.preventDefault();
-      }
-    });
-  }
+    void doUpdate() {
+	// update the back canvas
+	backBufferContext.setFillStyle(redrawColor);
+	backBufferContext.fillRect(0, 0, width, height);
+	logoGroup.update(mouseX, mouseY);
+	ballGroup.update(mouseX, mouseY);
+	logoGroup.draw(backBufferContext);
+	ballGroup.draw(backBufferContext);
+
+	// update the front canvas
+	lens.update();
+	lens.draw(backBufferContext, context);
+    }
+
+    void initHandlers() {
+	canvas.addMouseMoveHandler(new MouseMoveHandler() {
+	    public void onMouseMove(MouseMoveEvent event) {
+		mouseX = event.getRelativeX(canvas.getElement());
+		mouseY = event.getRelativeY(canvas.getElement());
+	    }
+	});
+
+	canvas.addMouseOutHandler(new MouseOutHandler() {
+	    public void onMouseOut(MouseOutEvent event) {
+		mouseX = -200;
+		mouseY = -200;
+	    }
+	});
+
+	canvas.addTouchMoveHandler(new TouchMoveHandler() {
+	    public void onTouchMove(TouchMoveEvent event) {
+		event.preventDefault();
+		if (event.getTouches().length() > 0) {
+		    Touch touch = event.getTouches().get(0);
+		    mouseX = touch.getRelativeX(canvas.getElement());
+		    mouseY = touch.getRelativeY(canvas.getElement());
+		}
+		event.preventDefault();
+	    }
+	});
+
+	canvas.addTouchEndHandler(new TouchEndHandler() {
+	    public void onTouchEnd(TouchEndEvent event) {
+		event.preventDefault();
+		mouseX = -200;
+		mouseY = -200;
+	    }
+	});
+
+	canvas.addGestureStartHandler(new GestureStartHandler() {
+	    public void onGestureStart(GestureStartEvent event) {
+		event.preventDefault();
+	    }
+	});
+    }
 }

Modified: devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Logo.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Logo.java?rev=1749229&r1=1749228&r2=1749229&view=diff
==============================================================================
--- devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Logo.java
(original)
+++ devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Logo.java
Sun Jun 19 23:15:51 2016
@@ -20,7 +20,7 @@ import com.google.gwt.canvas.dom.client.
 import com.google.gwt.dom.client.ImageElement;
 
 public class Logo extends SpringObject {
-  ImageElement image;
+  final ImageElement image;
   double rot;
 
   Logo(ImageElement image) {

Modified: devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/LogoGroup.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/LogoGroup.java?rev=1749229&r1=1749228&r2=1749229&view=diff
==============================================================================
--- devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/LogoGroup.java
(original)
+++ devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/LogoGroup.java
Sun Jun 19 23:15:51 2016
@@ -32,7 +32,7 @@ public class LogoGroup {
   Logo[] logos;
   boolean imageLoaded;
   
-  double k;
+  private double k;
   
   public LogoGroup(double width, double height, int numLogos, double radius) {
     this.width = width;
@@ -44,7 +44,7 @@ public class LogoGroup {
     logos = new Logo[numLogos];
     
     // init image
-    logoImg = new Image("gwtlogo40_40.png");
+    logoImg = new Image("asflogo40_40.png");
     logoImg.addLoadHandler(new LoadHandler() {
       public void onLoad(LoadEvent event) {
         imageLoaded = true;

Modified: devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Vector.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Vector.java?rev=1749229&r1=1749228&r2=1749229&view=diff
==============================================================================
--- devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Vector.java
(original)
+++ devicemap/trunk/examples/1.0/java/gwtcanvas/src/org/apache/devicemap/gwt/gwtcanvasdemo/client/Vector.java
Sun Jun 19 23:15:51 2016
@@ -17,7 +17,8 @@
 package org.apache.devicemap.gwt.gwtcanvasdemo.client;
 
 public class Vector {
-  public double x, y;
+  public double x;
+  public double y;
   
   public Vector() {
     this(0, 0);

Modified: devicemap/trunk/examples/1.0/java/gwtcanvas/war/DmapGwtCanvas.html
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/gwtcanvas/war/DmapGwtCanvas.html?rev=1749229&r1=1749228&r2=1749229&view=diff
==============================================================================
--- devicemap/trunk/examples/1.0/java/gwtcanvas/war/DmapGwtCanvas.html (original)
+++ devicemap/trunk/examples/1.0/java/gwtcanvas/war/DmapGwtCanvas.html Sun Jun 19 23:15:51
2016
@@ -5,7 +5,7 @@
     <meta name="viewport" content="width=device-width, user-scalable=no" />
     <meta http-equiv="Cache-Control" content="no-cache" /> 
     <link type="text/css" rel="stylesheet" href="DmapGwtCanvas.css">
-    <title>GWT Canvas Demo</title>
+    <title>Devicemap Canvas Demo</title>
     <script type="text/javascript" language="javascript" src="gwtcanvasdemo/gwtcanvasdemo.nocache.js"></script>
   </head>
   <body>
@@ -17,7 +17,7 @@
       </div>
     </noscript>
 
-    <h1>GWT Canvas Demo</h1>
+    <h1>DeviceMap Canvas Demo</h1>
     <div id="canvasholder"></div>
     <br/>
     <span id="source">

Added: devicemap/trunk/examples/1.0/java/gwtcanvas/war/asflogo40_40.png
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/gwtcanvas/war/asflogo40_40.png?rev=1749229&view=auto
==============================================================================
Binary file - no diff available.

Propchange: devicemap/trunk/examples/1.0/java/gwtcanvas/war/asflogo40_40.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: devicemap/trunk/examples/1.0/java/gwtcanvas/war/asflogo40_40.xcf
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/gwtcanvas/war/asflogo40_40.xcf?rev=1749229&view=auto
==============================================================================
Binary file - no diff available.

Propchange: devicemap/trunk/examples/1.0/java/gwtcanvas/war/asflogo40_40.xcf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: devicemap/trunk/examples/1.0/java/gwtcanvas/war/feather40_40.png
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/gwtcanvas/war/feather40_40.png?rev=1749229&view=auto
==============================================================================
Binary file - no diff available.

Propchange: devicemap/trunk/examples/1.0/java/gwtcanvas/war/feather40_40.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: devicemap/trunk/examples/1.0/java/gwtcanvas/war/feather40_40.xcf
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/1.0/java/gwtcanvas/war/feather40_40.xcf?rev=1749229&view=auto
==============================================================================
Binary file - no diff available.

Propchange: devicemap/trunk/examples/1.0/java/gwtcanvas/war/feather40_40.xcf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message