gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] fenfire/org/fenfire/view/buoy AbstractMainNode2...


From: Benja Fallenstein
Subject: [Gzz-commits] fenfire/org/fenfire/view/buoy AbstractMainNode2...
Date: Sat, 03 May 2003 07:17:43 -0400

CVSROOT:        /cvsroot/fenfire
Module name:    fenfire
Changes by:     Benja Fallenstein <address@hidden>      03/05/03 07:17:43

Modified files:
        org/fenfire/view/buoy: AbstractMainNode2D.java 
                               FisheyeMainNode2D.java MainNode2D.java 

Log message:
        Make dragging fisheye paper work

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/FisheyeMainNode2D.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/MainNode2D.java.diff?tr1=1.15&tr2=1.16&r1=text&r2=text

Patches:
Index: fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java
diff -u fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.3 
fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.4
--- fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.3   Fri May  2 
20:57:00 2003
+++ fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java       Sat May  3 
07:17:43 2003
@@ -47,6 +47,13 @@
        this.panX = panX; this.panY = panY;
     }
 
+    /** Cause the changes to the zooming and panning variables
+     * to be shown in the given vobscene.
+     * This changes the parameters of the coordinate systems 
+     * created by render().
+     */
+    protected abstract void setZoomPan(VobScene vs, int mainFrame);
+
     protected float[] v2dwh = new float[2];
 
     /** Clip the panX and panY values to the size of the canvas.
@@ -91,6 +98,57 @@
        pa("Key:"+s);
     }
 
+    // Mouse press state
+    // x, y, buttons
+    protected int[] m_state = null;
+    protected float pan[] = new float[2];
+
+    // Mouse x/y position on the paper
+    protected float m_pos[] = new float[3];
+
+    protected void readMouseState(MouseEvent e, VobScene oldVobScene) {
+       m_state = new int[]{ e.getX(), e.getY(), e.getModifiers()};
+       pan[0] = panX; pan[1] = panY;
+       m_pos[0] = m_state[0]; m_pos[1] = m_state[1]; m_pos[2] = 0;
+       oldVobScene.coords.inverseTransformPoints3(box2screen, m_pos, m_pos);
+    }
+
+    public boolean mouse(MouseEvent e, VobScene oldVobScene) {
+       if (e.getID() == MouseEvent.MOUSE_PRESSED) {
+           readMouseState(e, oldVobScene);
+           return false;
+       }
 
+       if (m_state == null) throw new Error("Mouse state not found!");
+       return doMouse(e, oldVobScene);
+    }
+    
+    protected boolean doMouse(MouseEvent e, VobScene oldVobScene) {
+       // Move by dragging with button 1
+       if(m_state[2] == e.BUTTON1_MASK && 
+          e.getID() == MouseEvent.MOUSE_DRAGGED) {
+
+           float[] pos2 = new float[] { e.getX(), e.getY(), 0 };
+           oldVobScene.coords.inverseTransformPoints3(box2screen, pos2, pos2);
+
+           panX = pan[0] + (m_pos[0] - pos2[0])/getZoom();
+           panY = pan[1] + (m_pos[1] - pos2[1])/getZoom();
+           clipPan();
+
+           setZoomPan(oldVobScene, box2screen);
+           return true;
+       }
+       
+       // Move around by clicking
+       if(m_state[2] == e.BUTTON1_MASK && 
+          e.getID() == MouseEvent.MOUSE_CLICKED){
+           mouseMoveClick(e.getX(), e.getY(), oldVobScene);
+           return false;
+       }
+
+       if(dbg) pa("nothing!");
+       return false;
+    }
 
+    protected float getZoom() { return 1; }
 }
Index: fenfire/org/fenfire/view/buoy/FisheyeMainNode2D.java
diff -u fenfire/org/fenfire/view/buoy/FisheyeMainNode2D.java:1.1 
fenfire/org/fenfire/view/buoy/FisheyeMainNode2D.java:1.2
--- fenfire/org/fenfire/view/buoy/FisheyeMainNode2D.java:1.1    Mon Apr 28 
07:56:32 2003
+++ fenfire/org/fenfire/view/buoy/FisheyeMainNode2D.java        Sat May  3 
07:17:43 2003
@@ -35,12 +35,7 @@
     }
 
 
-    /** Cause the changes to the zooming and panning variables
-     * to be shown in the given vobscene.
-     * This changes the parameters of the coordinate systems 
-     * created by render().
-     */
-    private void setZoomPan(VobScene vs, int mainFrame) {
+    protected void setZoomPan(VobScene vs, int mainFrame) {
        vs.coords.setTranslateParams(box2paper, panX, panY);
        fisheyeState.setCoordsysParams();
     }
@@ -64,6 +59,7 @@
     }
     
 
+    /**
     public void keystroke(String s) {
        // XXX
     }
@@ -86,6 +82,7 @@
        if(dbg) pa("nothing!");
        return false;
     }
+    **/
 
 
 }
Index: fenfire/org/fenfire/view/buoy/MainNode2D.java
diff -u fenfire/org/fenfire/view/buoy/MainNode2D.java:1.15 
fenfire/org/fenfire/view/buoy/MainNode2D.java:1.16
--- fenfire/org/fenfire/view/buoy/MainNode2D.java:1.15  Sat May  3 06:04:48 2003
+++ fenfire/org/fenfire/view/buoy/MainNode2D.java       Sat May  3 07:17:43 2003
@@ -89,38 +89,21 @@
        view2d.render(vs, plane, into, into, box2paper);
     }
 
-    /** Cause the changes to the zooming and panning variables
-     * to be shown in the given vobscene.
-     * This changes the parameters of the coordinate systems 
-     * created by render().
-     */
-    private void setZoomPan(VobScene vs, int mainFrame) {
+    protected void setZoomPan(VobScene vs, int mainFrame) {
        vs.coords.setOrthoBoxParams(box2paper, 0, 
                        panX-boxw/zoom/2, panY-boxh/zoom/2, 
                                    1/zoom, 1/zoom, boxw, boxh);
     }
 
-    public void keystroke(String s) {
-       // XXX
-    }
 
-    // Mouse press state
-    // x, y, buttons
-    private int [] m_state = null;
     private float m_state_zoom = -1;
-    private float pan[] = new float[2];
-
-
-    public boolean mouse(MouseEvent e, VobScene oldVobScene) {
-       if (e.getID() == MouseEvent.MOUSE_PRESSED) {
-           m_state = new int[]{ e.getX(), e.getY(), e.getModifiers()};
-           m_state_zoom = zoom;
-           pan[0] = panX; pan[1] = panY;
 
-           return false;
-       }
-       if (m_state == null) throw new Error("Mouse state not found!");
+    protected void readMouseState(MouseEvent e, VobScene oldVobScene) {
+       super.readMouseState(e, oldVobScene);
+       m_state_zoom = zoom;
+    }
 
+    public boolean doMouse(MouseEvent e, VobScene oldVobScene) {
        // let's zoom!!
        if (m_state[2] == e.BUTTON3_MASK) {
            zoom = m_state_zoom * (float) 
@@ -130,26 +113,8 @@
            return true;
        }
 
-       // Move by dragging with button 1
-       if(m_state[2] == e.BUTTON1_MASK && 
-          e.getID() == MouseEvent.MOUSE_DRAGGED) {
-           panX = pan[0] + (m_state[0] - e.getX())/zoom;
-           panY = pan[1] + (m_state[1] - e.getY())/zoom;
-           clipPan();
-
-           setZoomPan(oldVobScene, box2screen);
-           return true;
-       }
-       
-       // Move around by clicking
-       if(m_state[2] == e.BUTTON1_MASK && 
-          e.getID() == MouseEvent.MOUSE_CLICKED){
-           mouseMoveClick(e.getX(), e.getY(), oldVobScene);
-           return false;
-       }
-
-       if(dbg) pa("nothing!");
-       return false;
+       return super.doMouse(e, oldVobScene);
     }
 
+    protected float getZoom() { return zoom; }
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]