diff options
author | Rami Santina <[email protected]> | 2011-10-06 01:12:06 +0300 |
---|---|---|
committer | Rami Santina <[email protected]> | 2011-10-06 01:12:06 +0300 |
commit | 3f30f2c4bd5ee30aba5553ac249c8eb94595792a (patch) | |
tree | 7b6b32c58abc2b10bcaa707a520ff95542de0d89 | |
parent | 54fe0a4a5ccc74030e6c00fd13b29fc443620c8f (diff) |
GraphUI demo: add x and y translation for 1 pointer
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index 540aade38..83b64bfac 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -360,7 +360,8 @@ public class GPUUISceneGLListener0A implements GLEventListener { } private class MultiTouchListener extends MouseAdapter { - int lv = 0; + int lx = 0; + int ly = 0; boolean first = false; @@ -378,30 +379,38 @@ public class GPUUISceneGLListener0A implements GLEventListener { public void mouseDragged(MouseEvent e) { System.err.println("demo:mousedragged "+e); if(e.getPointerCount()==2) { - // 2 finger zoom .. + // 2 pointers zoom .. if(first) { - lv = Math.abs(e.getY(0)-e.getY(1)); + lx = Math.abs(e.getY(0)-e.getY(1)); first=false; return; } int nv = Math.abs(e.getY(0)-e.getY(1)); - int dy = nv - lv; + int dy = nv - lx; zoom += 2 * Math.signum(dy); - lv = nv; + lx = nv; } else { - // 1 finger drag + // 1 pointer drag if(first) { - lv = e.getX(); + lx = e.getX(); + ly = e.getY(); first=false; return; } - int nv = e.getX(); - int dx = nv - lv; - xTran += Math.signum(dx); - - lv = nv; + int nx = e.getX(); + int ny = e.getY(); + int dx = nx - lx; + int dy = ny - ly; + if(Math.abs(dx) > Math.abs(dy)){ + xTran += Math.signum(dx); + } + else { + yTran += Math.signum(dy); + } + lx = nx; + ly = ny; } } } |