summaryrefslogtreecommitdiffstats
path: root/src/gleem/ManipManager.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-10-24 19:21:28 +0000
committerKenneth Russel <[email protected]>2005-10-24 19:21:28 +0000
commit6873f65775af236ed270fcbd08661f5b53ba3598 (patch)
tree6fcefdc3a9429d7d3071b1464c11d40fa7bc3ab9 /src/gleem/ManipManager.java
parent538be101e7bce7788c82e1b254a66deb5d35bb56 (diff)
Merged JSR-231 branch on to the main JOGL trunk. The main trunk now
contains the evolving JSR-231 Reference Implementation and the JSR-231 branch is permanently closed. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@144 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/gleem/ManipManager.java')
-rw-r--r--src/gleem/ManipManager.java59
1 files changed, 32 insertions, 27 deletions
diff --git a/src/gleem/ManipManager.java b/src/gleem/ManipManager.java
index 0a0d86d..b959e74 100644
--- a/src/gleem/ManipManager.java
+++ b/src/gleem/ManipManager.java
@@ -44,7 +44,8 @@ import java.util.*;
import gleem.linalg.*;
-import net.java.games.jogl.*;
+import javax.media.opengl.*;
+import com.sun.opengl.utils.*;
/** The ManipManager handles making manipulators visible in a
window. */
@@ -55,7 +56,7 @@ public class ManipManager {
private static ManipManager soleInstance;
// Maps GLDrawables to WindowInfos
private Map windowToInfoMap = new HashMap();
- // Maps Manips to Set<GLDrawable>
+ // Maps Manips to Set<GLAutoDrawable>
private Map manipToWindowMap = new HashMap();
// MouseAdapter for this
@@ -78,10 +79,8 @@ public class ManipManager {
}
};
private WindowUpdateListener defaultWindowListener = new WindowUpdateListener() {
- public void update(GLDrawable window) {
- if (!window.getNoAutoRedrawMode()) {
- window.display();
- }
+ public void update(GLAutoDrawable window) {
+ window.repaint();
}
};
private WindowUpdateListener windowListener;
@@ -110,25 +109,31 @@ public class ManipManager {
/** Make the ManipManager aware of the existence of a given
window. This causes mouse and mouse motion listeners to be
installed on this window; see setupMouseListeners, below. */
- public synchronized void registerWindow(GLDrawable window) {
+ public synchronized void registerWindow(GLAutoDrawable window) {
windowToInfoMap.put(window, new WindowInfo());
setupMouseListeners(window);
}
/** Remove all references to a given window, including removing all
manipulators from it. */
- public synchronized void unregisterWindow(GLDrawable window) {
+ public synchronized void unregisterWindow(GLAutoDrawable window) {
+ if (window == null) {
+ return;
+ }
WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
- for (Iterator iter = info.manips.iterator(); iter.hasNext(); ) {
- removeManipFromWindow((Manip) iter.next(), window);
+ if (info != null) {
+ Object[] manips = info.manips.toArray();
+ for (int i = 0; i < manips.length; i++) {
+ removeManipFromWindow((Manip) manips[i], window);
+ }
+ windowToInfoMap.remove(window);
+ removeMouseListeners(window);
}
- windowToInfoMap.remove(window);
- removeMouseListeners(window);
}
/** Make a given manipulator visible and active in a given
window. The window must be registered. */
- public synchronized void showManipInWindow(Manip manip, GLDrawable window) {
+ public synchronized void showManipInWindow(Manip manip, GLAutoDrawable window) {
WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
if (info == null) {
throw new RuntimeException("Window not registered");
@@ -144,7 +149,7 @@ public class ManipManager {
/** Remove a given manipulator from a given window. The window must
be registered. */
- public synchronized void removeManipFromWindow(Manip manip, GLDrawable window) {
+ public synchronized void removeManipFromWindow(Manip manip, GLAutoDrawable window) {
WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
if (info == null) {
throw new RuntimeException("Window not registered");
@@ -159,7 +164,7 @@ public class ManipManager {
/** This must be called for a registered window every time the
camera parameters of the window change. */
- public synchronized void updateCameraParameters(GLDrawable window, CameraParameters params) {
+ public synchronized void updateCameraParameters(GLAutoDrawable window, CameraParameters params) {
WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
if (info == null) {
throw new RuntimeException("Window not registered");
@@ -182,7 +187,7 @@ public class ManipManager {
repainting of windows in which manipulators have moved. The
default implementation, which can be restored by passing a null
listener argument to this method, calls repaint() on the
- GLDrawable if it is not a GLRunnable instance (i.e., a
+ GLAutoDrawable if it is not a GLRunnable instance (i.e., a
GLAnimCanvas or GLAnimJPanel, which redraw themselves
automatically). */
public synchronized void setWindowUpdateListener(WindowUpdateListener listener) {
@@ -197,7 +202,7 @@ public class ManipManager {
drawing occurs immediately; this routine must be called when an
OpenGL context is valid, i.e., from within the display() method
of a GLEventListener. */
- public synchronized void render(GLDrawable window, GL gl) {
+ public synchronized void render(GLAutoDrawable window, GL gl) {
WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
if (info == null) {
throw new RuntimeException("Window not registered");
@@ -214,7 +219,7 @@ public class ManipManager {
listeners for the canvas (see the ExaminerViewer class), the
setupMouseListeners and removeMouseListeners routines, as well
as the appropriate delegate routines, are made public here. */
- public synchronized void setupMouseListeners(GLDrawable window) {
+ public synchronized void setupMouseListeners(GLAutoDrawable window) {
window.addMouseMotionListener(mouseMotionListener);
window.addMouseListener(mouseListener);
}
@@ -222,7 +227,7 @@ public class ManipManager {
/** Removes the automatically-installed mouse listeners for the
given window. This allows application code to determine the
policy for intercepting mouse events. */
- public synchronized void removeMouseListeners(GLDrawable window) {
+ public synchronized void removeMouseListeners(GLAutoDrawable window) {
window.removeMouseMotionListener(mouseMotionListener);
window.removeMouseListener(mouseListener);
}
@@ -232,7 +237,7 @@ public class ManipManager {
are exposed so application-level code can intercept events when
certain modifier keys are depressed. */
public synchronized void mouseMoved(MouseEvent e) {
- passiveMotionMethod((GLDrawable) e.getComponent(), e.getX(), e.getY());
+ passiveMotionMethod((GLAutoDrawable) e.getComponent(), e.getX(), e.getY());
}
/** The ManipManager watches for the following events: mouseMoved,
@@ -240,7 +245,7 @@ public class ManipManager {
are exposed so application-level code can intercept events when
certain modifier keys are depressed. */
public synchronized void mouseDragged(MouseEvent e) {
- motionMethod((GLDrawable) e.getComponent(), e.getX(), e.getY());
+ motionMethod((GLAutoDrawable) e.getComponent(), e.getX(), e.getY());
}
/** The ManipManager watches for the following events: mouseMoved,
@@ -248,7 +253,7 @@ public class ManipManager {
are exposed so application-level code can intercept events when
certain modifier keys are depressed. */
public synchronized void mousePressed(MouseEvent e) {
- mouseMethod((GLDrawable) e.getComponent(), e.getModifiers(),
+ mouseMethod((GLAutoDrawable) e.getComponent(), e.getModifiers(),
true, e.getX(), e.getY());
}
@@ -257,7 +262,7 @@ public class ManipManager {
are exposed so application-level code can intercept events when
certain modifier keys are depressed. */
public synchronized void mouseReleased(MouseEvent e) {
- mouseMethod((GLDrawable) e.getComponent(), e.getModifiers(),
+ mouseMethod((GLAutoDrawable) e.getComponent(), e.getModifiers(),
false, e.getX(), e.getY());
}
@@ -270,7 +275,7 @@ public class ManipManager {
setWindowUpdateListener(null);
}
- private void motionMethod(GLDrawable window, int x, int y) {
+ private void motionMethod(GLAutoDrawable window, int x, int y) {
WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
if (info.dragging) {
// Compute ray in 3D
@@ -282,7 +287,7 @@ public class ManipManager {
}
}
- private void passiveMotionMethod(GLDrawable window, int x, int y) {
+ private void passiveMotionMethod(GLAutoDrawable window, int x, int y) {
WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
// Compute ray in 3D
Vec3f rayStart = new Vec3f();
@@ -322,7 +327,7 @@ public class ManipManager {
}
}
- private void mouseMethod(GLDrawable window, int modifiers,
+ private void mouseMethod(GLAutoDrawable window, int modifiers,
boolean isPress, int x, int y) {
if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
@@ -398,7 +403,7 @@ public class ManipManager {
Set windows = (Set) manipToWindowMap.get(manip);
assert windows != null;
for (Iterator iter = windows.iterator(); iter.hasNext(); ) {
- windowListener.update((GLDrawable) iter.next());
+ windowListener.update((GLAutoDrawable) iter.next());
}
}
}