From 3f30f2c4bd5ee30aba5553ac249c8eb94595792a Mon Sep 17 00:00:00 2001 From: Rami Santina Date: Thu, 6 Oct 2011 01:12:06 +0300 Subject: GraphUI demo: add x and y translation for 1 pointer --- .../junit/graph/demos/GPUUISceneGLListener0A.java | 33 ++++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src') 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; } } } -- cgit v1.2.3