Updated JOGL and gluegen to 2.1.5-01. Fixed errors due to API changes in JOGL. Fixed a bug in View when using NEWT or Offscreen canvases.

This commit is contained in:
Nils Hoffmann 2014-03-19 20:34:11 +01:00
parent b147b896cf
commit 05b84a9613
18 changed files with 166 additions and 560 deletions

View File

@ -24,12 +24,12 @@
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.0-rc11</version>
<version>2.1.5-01</version>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
<version>2.0-rc11</version>
<version>2.1.5-01</version>
</dependency>
<dependency>
<groupId>log4j</groupId>

View File

@ -1,21 +1,13 @@
package org.jzy3d.chart;
<<<<<<< HEAD:src/api/org/jzy3d/chart/Chart.java
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
=======
>>>>>>> upstream/master:jzy3d-api/src/api/org/jzy3d/chart/Chart.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import org.jzy3d.bridge.IFrame;
import org.jzy3d.chart.controllers.camera.AbstractCameraController;
@ -30,12 +22,8 @@ import org.jzy3d.maths.Rectangle;
import org.jzy3d.maths.Scale;
import org.jzy3d.plot3d.primitives.AbstractDrawable;
import org.jzy3d.plot3d.primitives.axes.layout.IAxeLayout;
import org.jzy3d.plot3d.rendering.canvas.CanvasAWT;
import org.jzy3d.plot3d.rendering.canvas.CanvasNewt;
import org.jzy3d.plot3d.rendering.canvas.CanvasSwing;
import org.jzy3d.plot3d.rendering.canvas.ICanvas;
import org.jzy3d.plot3d.rendering.canvas.IScreenCanvas;
import org.jzy3d.plot3d.rendering.canvas.OffscreenCanvas;
import org.jzy3d.plot3d.rendering.canvas.Quality;
import org.jzy3d.plot3d.rendering.lights.Light;
import org.jzy3d.plot3d.rendering.view.View;

View File

@ -1,10 +1,9 @@
package org.jzy3d.chart.controllers.keyboard.lights;
import org.jzy3d.chart.Chart;
import org.jzy3d.plot3d.rendering.lights.Light;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import org.jzy3d.chart.Chart;
import org.jzy3d.plot3d.rendering.lights.Light;
public class NewtLightKeyController implements KeyListener{
@ -42,8 +41,6 @@ public class NewtLightKeyController implements KeyListener{
}
@Override
public void keyReleased(KeyEvent e) {}
@Override
public void keyTyped(KeyEvent e) {}
protected Chart chart;
protected int lightId = 0;

View File

@ -1,16 +1,14 @@
package org.jzy3d.chart.controllers.keyboard.screenshot;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.controllers.AbstractController;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.opengl.util.texture.TextureIO;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.controllers.AbstractController;
/** Saves a screenshot in PNG format once key S is pressed.
*
@ -54,9 +52,8 @@ public class NewtScreenshotKeyController extends AbstractController implements K
listeners.add(listener);
}
@Override
public void keyTyped(KeyEvent e) {
public void keyReleased(KeyEvent e) {
switch (e.getKeyChar()) {
case 's':
try {
@ -70,10 +67,6 @@ public class NewtScreenshotKeyController extends AbstractController implements K
}
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}

View File

@ -5,7 +5,7 @@ import com.jogamp.newt.event.MouseEvent;
public class NewtMouseUtilities {
public static boolean isDoubleClick(MouseEvent e){
return (e.getClickCount() > 1);
return (e.getClickCount() > (short)1);
}
public static boolean isLeftDown(MouseEvent e){
@ -19,4 +19,8 @@ public class NewtMouseUtilities {
public static boolean isRightClick(MouseEvent e){
return (e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK;
}
public static float convertWheelRotation(MouseEvent e, float offset, float stepSize) {
return offset+((e.getRotation()[1]*e.getRotationScale())/stepSize);
}
}

View File

@ -2,13 +2,13 @@ package org.jzy3d.chart.controllers.mouse.camera;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.controllers.camera.AbstractCameraController;
import org.jzy3d.chart.controllers.thread.camera.CameraThreadController;
import org.jzy3d.maths.Coord2d;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.controllers.camera.AbstractCameraController;
import org.jzy3d.chart.controllers.mouse.NewtMouseUtilities;
import org.jzy3d.chart.controllers.thread.camera.CameraThreadController;
import org.jzy3d.maths.Coord2d;
@ -92,7 +92,7 @@ public class NewtCameraMouseController extends AbstractCameraController implemen
public void mouseWheelMoved(MouseEvent e) {
stopThreadController();
float factor = 1 + (e.getWheelRotation()/10.0f);
float factor = NewtMouseUtilities.convertWheelRotation(e, 1.0f, 10.0f);
zoomZ(factor);
}

View File

@ -1,8 +1,9 @@
package org.jzy3d.chart.controllers.mouse.picking;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import javax.media.opengl.GL;
import javax.media.opengl.glu.GLU;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.controllers.camera.AbstractCameraController;
import org.jzy3d.chart.controllers.mouse.NewtMouseUtilities;
@ -14,9 +15,6 @@ import org.jzy3d.picking.PickingSupport;
import org.jzy3d.plot3d.rendering.scene.Graph;
import org.jzy3d.plot3d.rendering.view.View;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
public class NewtMousePickingController<V, E> extends AbstractCameraController
implements MouseListener {
public NewtMousePickingController() {
@ -88,8 +86,7 @@ public class NewtMousePickingController<V, E> extends AbstractCameraController
public void mouseWheelMoved(MouseEvent e) {
if (threadController != null)
threadController.stop();
System.out.println(e.getWheelRotation());
float factor = 1 + (e.getWheelRotation() / 10.0f);
float factor = NewtMouseUtilities.convertWheelRotation(e, 1.0f, 10.0f);
System.out.println(NewtMousePickingController.class.getSimpleName() + "wheel:" + factor * 100);
zoomX(factor);
zoomY(factor);

View File

@ -1,74 +1,77 @@
package org.jzy3d.chart.controllers.mouse.picking;
import com.jogamp.newt.event.MouseEvent;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.controllers.ControllerType;
import org.jzy3d.chart.controllers.mouse.NewtMouseUtilities;
import org.jzy3d.maths.BoundingBox3d;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot3d.rendering.view.View;
import com.jogamp.newt.event.MouseEvent;
public class NewtMousePickingPan2dController<V, E> extends NewtMousePickingController<V, E> {
public class NewtMousePickingPan2dController<V,E> extends NewtMousePickingController<V,E>{
public NewtMousePickingPan2dController(){
public NewtMousePickingPan2dController() {
super();
}
public NewtMousePickingPan2dController(Chart chart){
public NewtMousePickingPan2dController(Chart chart) {
super(chart);
}
public NewtMousePickingPan2dController(Chart chart, int brushSize){
public NewtMousePickingPan2dController(Chart chart, int brushSize) {
super(chart, brushSize);
}
public NewtMousePickingPan2dController(Chart chart, int brushSize, int bufferSize){
public NewtMousePickingPan2dController(Chart chart, int brushSize, int bufferSize) {
super(chart, brushSize, bufferSize);
}
/****************/
/**
* *************
*/
public void mouseDragged(MouseEvent e) {
int yflip = -e.getY() + targets.get(0).getCanvas().getRendererHeight();
Coord2d mouse = new Coord2d(e.getX(),yflip);
Coord2d mouse = new Coord2d(e.getX(), yflip);
View view = targets.get(0).getView();
Coord3d thisMouse3d = view.projectMouse(e.getX(),yflip);
Coord3d thisMouse3d = view.projectMouse(e.getX(), yflip);
// 1/2 pan for cleaner rendering
if(!done){
pan(prevMouse3d, thisMouse3d); done = true;
}
else
if (!done) {
pan(prevMouse3d, thisMouse3d);
done = true;
} else {
done = false;
}
prevMouse = mouse;
prevMouse3d = thisMouse3d;
}
protected boolean done;
public void mouseWheelMoved(MouseEvent e) {
lastInc = (e.getWheelRotation()/10.0f);
lastInc = NewtMouseUtilities.convertWheelRotation(e, 0.0f, 10.0f);
factor = factor + lastInc;
View view = targets.get(0).getView();
mouse3d = view.projectMouse( lastMouseX, lastMouseY );
mouse3d = view.projectMouse(lastMouseX, lastMouseY);
zoom(1+lastInc);
zoom(1 + lastInc);
}
/**********************/
protected void zoom(final float factor){
/**
* *******************
*/
protected void zoom(final float factor) {
Chart chart = targets.get(0);
BoundingBox3d viewBounds = chart.getView().getBounds();
BoundingBox3d newBounds = viewBounds.scale(new Coord3d(factor,factor,1));
BoundingBox3d newBounds = viewBounds.scale(new Coord3d(factor, factor, 1));
chart.getView().setBoundManual(newBounds);
chart.getView().shoot();
fireControllerEvent(ControllerType.ZOOM, factor);
}
protected void pan(Coord3d from, Coord3d to){
protected void pan(Coord3d from, Coord3d to) {
Chart chart = targets.get(0);
BoundingBox3d viewBounds = chart.getView().getBounds();
@ -83,7 +86,9 @@ public class NewtMousePickingPan2dController<V,E> extends NewtMousePickingContro
protected static float PAN_FACTOR = 0.25f;
protected int lastMouseX = 0;
protected int lastMouseY = 0;
protected int lastMouseY = 0;
/**********************/
/**
* *******************
*/
}

View File

@ -1,8 +1,9 @@
package org.jzy3d.plot3d.rendering.canvas;
import com.jogamp.opengl.util.texture.TextureData;
import com.jogamp.opengl.util.texture.TextureIO;
import java.io.File;
import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLCapabilities;
@ -10,15 +11,11 @@ import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLPbuffer;
import javax.media.opengl.GLProfile;
import org.jzy3d.chart.factories.IChartComponentFactory;
import org.jzy3d.plot3d.rendering.scene.Scene;
import org.jzy3d.plot3d.rendering.view.Renderer3d;
import org.jzy3d.plot3d.rendering.view.View;
import com.jogamp.opengl.util.texture.TextureData;
import com.jogamp.opengl.util.texture.TextureIO;
/**
* An {@link ICanvas} implementation able to render the chart in an offscreen canvas,
* meaning no frame or GUI is needed to get a chart.
@ -47,7 +44,7 @@ public class OffscreenCanvas implements ICanvas {
protected void initGLPBuffer(GLCapabilities capabilities, int width, int height) {
GLProfile profile = capabilities.getGLProfile();
capabilities.setDoubleBuffered(false);
if (!GLDrawableFactory.getFactory(profile).canCreateGLPbuffer(null))
if (!GLDrawableFactory.getFactory(profile).canCreateGLPbuffer(null, profile))
throw new RuntimeException("No pbuffer support");
GLDrawableFactory factory = GLDrawableFactory.getFactory(profile);
glpBuffer = factory.createGLPbuffer(null, capabilities, null, width, height, null);
@ -57,7 +54,7 @@ public class OffscreenCanvas implements ICanvas {
protected void initGLPBuffer(int width, int height) {
GLCapabilities caps = org.jzy3d.chart.Settings.getInstance().getGLCapabilities();
caps.setDoubleBuffered(false);
if (!GLDrawableFactory.getFactory(caps.getGLProfile()).canCreateGLPbuffer(null))
if (!GLDrawableFactory.getFactory(caps.getGLProfile()).canCreateGLPbuffer(null, caps.getGLProfile()))
throw new RuntimeException("No pbuffer support");
glpBuffer = GLDrawableFactory.getFactory(caps.getGLProfile()).createGLPbuffer(null, caps, null, width, height, null);

View File

@ -1,14 +1,13 @@
package org.jzy3d.plot3d.rendering.compat;
import java.nio.ByteBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES1;
import com.jogamp.opengl.util.ImmModeSink;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderState;
import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil;
import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode;
import java.nio.ByteBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES1;
public class GLES2CompatUtils {
@ -25,13 +24,13 @@ public class GLES2CompatUtils {
public static void init(GL gl, int initialElementCount, int vComps,
int vDataType, int cComps, int cDataType, int nComps,
int nDataType, int tComps, int tDataType, int glBufferUsage) {
int nDataType, int tComps, int tDataType, int glBufferUsage, ShaderState shaderState) {
GLES2CompatUtils.gl = gl;
immModeSink = ImmModeSink.createGLSL(/*gl, */initialElementCount, vComps,
vDataType, cComps, cDataType, nComps, nDataType, tComps,
tDataType, glBufferUsage);
tDataType, glBufferUsage, shaderState);
pmvMatrix = new PMVMatrix();

View File

@ -1,14 +1,13 @@
package org.jzy3d.plot3d.rendering.view;
import com.jogamp.opengl.util.awt.Overlay;
import java.util.ArrayList;
import java.util.List;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLContext;
import javax.media.opengl.glu.GLU;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.factories.IChartComponentFactory;
import org.jzy3d.colors.Color;
@ -36,8 +35,6 @@ import org.jzy3d.plot3d.rendering.view.modes.ViewPositionMode;
import org.jzy3d.plot3d.transform.Scale;
import org.jzy3d.plot3d.transform.Transform;
import com.jogamp.opengl.util.awt.Overlay;
/**
* A {@link View} holds a {@link Scene}, a {@link LightSet}, an {@link ICanvas}
* to render into. It is the responsability to layout a set of concrete
@ -632,7 +629,11 @@ public class View {
protected GLAutoDrawable getCanvasAsGLAutoDrawable() {
if (canvas instanceof GLAutoDrawable) {
//this covers AWT and Swing
return ((GLAutoDrawable) canvas);
} else if(canvas.getDrawable() instanceof GLAutoDrawable) {
//this also covers NEWT and Offscreen
return ((GLAutoDrawable) canvas.getDrawable());
} else
throw new RuntimeException("Unexpected instance type");
}

View File

@ -1,14 +1,13 @@
package org.jzy3d.plot3d.rendering.view.controllers;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import org.jzy3d.chart.controllers.mouse.NewtMouseUtilities;
import org.jzy3d.chart.controllers.thread.camera.CameraThreadController;
import org.jzy3d.maths.Coord2d;
import org.jzy3d.plot3d.rendering.canvas.IScreenCanvas;
import org.jzy3d.plot3d.rendering.view.View;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
public class ViewMouseController extends ViewCameraController implements
MouseListener {
@ -92,7 +91,7 @@ public class ViewMouseController extends ViewCameraController implements
if (threadController != null)
threadController.stop();
float factor = 1 + (e.getWheelRotation() / 10.0f);
float factor = NewtMouseUtilities.convertWheelRotation(e, 1.0f, 10.0f);
zoom(factor);
}

View File

@ -1,5 +1,7 @@
package org.jzy3d.chart.controllers.mouse.picking;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import org.jzy3d.chart.Chart;
import org.jzy3d.chart.controllers.ControllerType;
import org.jzy3d.maths.BoundingBox3d;
@ -7,8 +9,6 @@ import org.jzy3d.maths.Coord2d;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot3d.rendering.view.View;
import com.jogamp.newt.event.MouseEvent;
public class AWTMousePickingPan2dController<V,E> extends AWTMousePickingController<V,E>{
public AWTMousePickingPan2dController(){
super();
@ -28,6 +28,7 @@ public class AWTMousePickingPan2dController<V,E> extends AWTMousePickingControll
/****************/
@Override
public void mouseDragged(MouseEvent e) {
int yflip = -e.getY() + targets.get(0).getCanvas().getRendererHeight();
Coord2d mouse = new Coord2d(e.getX(),yflip);
@ -45,7 +46,8 @@ public class AWTMousePickingPan2dController<V,E> extends AWTMousePickingControll
}
protected boolean done;
public void mouseWheelMoved(MouseEvent e) {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
lastInc = (e.getWheelRotation()/10.0f);
factor = factor + lastInc;

View File

@ -1,6 +1,8 @@
package org.jzy3d.plot3d.pipelines;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES1;
import javax.media.opengl.GL2ES2;
/** This utility allows checking the GL2 error bit after a call to a
* GL2 command.
@ -34,10 +36,10 @@ public class GLErrorReader {
else if(err==GL2.GL_INVALID_OPERATION){
System.err.println("GL_INVALID_OPERATION : The specified operation is not allowed in the current state. The offending command is ignored, having no side effect other than to set the error flag.");
}
else if(err==GL2.GL_STACK_OVERFLOW){
else if(err==GL2ES1.GL_STACK_OVERFLOW || err==GL2ES2.GL_STACK_OVERFLOW){
System.err.println("GL_STACK_OVERFLOW: This command would cause a stack overflow. The offending command is ignored, having no side effect other than to set the error flag.");
}
else if(err==GL2.GL_STACK_UNDERFLOW){
else if(err==GL2ES1.GL_STACK_UNDERFLOW || err==GL2ES2.GL_STACK_UNDERFLOW){
System.err.println("GL_STACK_UNDERFLOW: This command would cause a stack underflow. The offending command is ignored, having no side effect other than to set the error flag.");
}
else if(err==GL2.GL_OUT_OF_MEMORY){

View File

@ -3,446 +3,64 @@ package org.jzy3d.bridge.newt.controllers;
import com.jogamp.newt.event.KeyEvent;
/**
* Utilities for mapping key codes and events from awt to
* newt.
* Utilities for mapping key codes and events from awt to newt.
*
* @author Nils Hoffmann
*/
public class AwtToNewtUtilities {
public static int mapKeyCode(KeyEvent event) {
return jogamp.newt.awt.event.AWTNewtEventFactory.newtKeyCode2AWTKeyCode(event.getKeyCode());
}
if(event.getEventType()==KeyEvent.EVENT_KEY_TYPED) {
return java.awt.event.KeyEvent.VK_UNDEFINED;
}
public static int mask(com.jogamp.newt.event.MouseEvent event) {
int newtMods = event.getModifiers();
int awtMods = 0;
if ((newtMods & com.jogamp.newt.event.InputEvent.SHIFT_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.SHIFT_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.CTRL_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.CTRL_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.META_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.META_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.ALT_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.ALT_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.ALT_GRAPH_MASK;
}
if (event.getButton() == com.jogamp.newt.event.MouseEvent.BUTTON1) {
awtMods |= java.awt.event.InputEvent.BUTTON1_DOWN_MASK;
}
if (event.getButton() == com.jogamp.newt.event.MouseEvent.BUTTON2) {
awtMods |= java.awt.event.InputEvent.BUTTON2_DOWN_MASK;
}
if (event.getButton() == com.jogamp.newt.event.MouseEvent.BUTTON3) {
awtMods |= java.awt.event.InputEvent.BUTTON3_DOWN_MASK;
}
return awtMods;
}
switch(event.getKeyCode()) {
case KeyEvent.VK_0:
return java.awt.event.KeyEvent.VK_0;
case KeyEvent.VK_1:
return java.awt.event.KeyEvent.VK_1;
case KeyEvent.VK_2:
return java.awt.event.KeyEvent.VK_2;
case KeyEvent.VK_3:
return java.awt.event.KeyEvent.VK_3;
case KeyEvent.VK_4:
return java.awt.event.KeyEvent.VK_4;
case KeyEvent.VK_5:
return java.awt.event.KeyEvent.VK_5;
case KeyEvent.VK_6:
return java.awt.event.KeyEvent.VK_6;
case KeyEvent.VK_7:
return java.awt.event.KeyEvent.VK_7;
case KeyEvent.VK_8:
return java.awt.event.KeyEvent.VK_8;
case KeyEvent.VK_9:
return java.awt.event.KeyEvent.VK_9;
case KeyEvent.VK_A:
return java.awt.event.KeyEvent.VK_A;
case KeyEvent.VK_ACCEPT:
return java.awt.event.KeyEvent.VK_ACCEPT;
case KeyEvent.VK_ADD:
return java.awt.event.KeyEvent.VK_ADD;
case KeyEvent.VK_ALL_CANDIDATES:
return java.awt.event.KeyEvent.VK_ALL_CANDIDATES;
case KeyEvent.VK_ALPHANUMERIC:
return java.awt.event.KeyEvent.VK_ALPHANUMERIC;
case KeyEvent.VK_ALT:
return java.awt.event.KeyEvent.VK_ALT;
case KeyEvent.VK_ALT_GRAPH:
return java.awt.event.KeyEvent.VK_ALT_GRAPH;
case KeyEvent.VK_AMPERSAND:
return java.awt.event.KeyEvent.VK_AMPERSAND;
case KeyEvent.VK_ASTERISK:
return java.awt.event.KeyEvent.VK_ASTERISK;
case KeyEvent.VK_AT:
return java.awt.event.KeyEvent.VK_AT;
case KeyEvent.VK_B:
return java.awt.event.KeyEvent.VK_B;
case KeyEvent.VK_BACK_QUOTE:
return java.awt.event.KeyEvent.VK_BACK_QUOTE;
case KeyEvent.VK_BACK_SLASH:
return java.awt.event.KeyEvent.VK_BACK_SLASH;
case KeyEvent.VK_BACK_SPACE:
return java.awt.event.KeyEvent.VK_BACK_SPACE;
case KeyEvent.VK_BEGIN:
return java.awt.event.KeyEvent.VK_BEGIN;
case KeyEvent.VK_BRACELEFT:
return java.awt.event.KeyEvent.VK_BRACELEFT;
case KeyEvent.VK_BRACERIGHT:
return java.awt.event.KeyEvent.VK_BRACERIGHT;
case KeyEvent.VK_C:
return java.awt.event.KeyEvent.VK_C;
case KeyEvent.VK_CANCEL:
return java.awt.event.KeyEvent.VK_CANCEL;
case KeyEvent.VK_CAPS_LOCK:
return java.awt.event.KeyEvent.VK_CAPS_LOCK;
case KeyEvent.VK_CIRCUMFLEX:
return java.awt.event.KeyEvent.VK_CIRCUMFLEX;
case KeyEvent.VK_CLEAR:
return java.awt.event.KeyEvent.VK_CLEAR;
case KeyEvent.VK_CLOSE_BRACKET:
return java.awt.event.KeyEvent.VK_CLOSE_BRACKET;
case KeyEvent.VK_CODE_INPUT:
return java.awt.event.KeyEvent.VK_CODE_INPUT;
case KeyEvent.VK_COLON:
return java.awt.event.KeyEvent.VK_COLON;
case KeyEvent.VK_COMMA:
return java.awt.event.KeyEvent.VK_COMMA;
case KeyEvent.VK_COMPOSE:
return java.awt.event.KeyEvent.VK_COMPOSE;
case KeyEvent.VK_CONTEXT_MENU:
return java.awt.event.KeyEvent.VK_CONTEXT_MENU;
case KeyEvent.VK_CONTROL:
return java.awt.event.KeyEvent.VK_CONTROL;
case KeyEvent.VK_CONVERT:
return java.awt.event.KeyEvent.VK_CONVERT;
case KeyEvent.VK_COPY:
return java.awt.event.KeyEvent.VK_COPY;
case KeyEvent.VK_CUT:
return java.awt.event.KeyEvent.VK_CUT;
case KeyEvent.VK_D:
return java.awt.event.KeyEvent.VK_D;
case KeyEvent.VK_DEAD_ABOVEDOT:
return java.awt.event.KeyEvent.VK_DEAD_ABOVEDOT;
case KeyEvent.VK_DEAD_ABOVERING:
return java.awt.event.KeyEvent.VK_DEAD_ABOVERING;
case KeyEvent.VK_DEAD_ACUTE:
return java.awt.event.KeyEvent.VK_DEAD_ACUTE;
case KeyEvent.VK_DEAD_BREVE:
return java.awt.event.KeyEvent.VK_DEAD_BREVE;
case KeyEvent.VK_DEAD_CARON:
return java.awt.event.KeyEvent.VK_DEAD_CARON;
case KeyEvent.VK_DEAD_CEDILLA:
return java.awt.event.KeyEvent.VK_DEAD_CEDILLA;
case KeyEvent.VK_DEAD_CIRCUMFLEX:
return java.awt.event.KeyEvent.VK_DEAD_CIRCUMFLEX;
case KeyEvent.VK_DEAD_DIAERESIS:
return java.awt.event.KeyEvent.VK_DEAD_DIAERESIS;
case KeyEvent.VK_DEAD_DOUBLEACUTE:
return java.awt.event.KeyEvent.VK_DEAD_DOUBLEACUTE;
case KeyEvent.VK_DEAD_GRAVE:
return java.awt.event.KeyEvent.VK_DEAD_GRAVE;
case KeyEvent.VK_DEAD_IOTA:
return java.awt.event.KeyEvent.VK_DEAD_IOTA;
case KeyEvent.VK_DEAD_MACRON:
return java.awt.event.KeyEvent.VK_DEAD_MACRON;
case KeyEvent.VK_DEAD_OGONEK:
return java.awt.event.KeyEvent.VK_DEAD_OGONEK;
case KeyEvent.VK_DEAD_SEMIVOICED_SOUND:
return java.awt.event.KeyEvent.VK_DEAD_SEMIVOICED_SOUND;
case KeyEvent.VK_DEAD_TILDE:
return java.awt.event.KeyEvent.VK_DEAD_TILDE;
case KeyEvent.VK_DEAD_VOICED_SOUND:
return java.awt.event.KeyEvent.VK_DEAD_VOICED_SOUND;
case KeyEvent.VK_DECIMAL:
return java.awt.event.KeyEvent.VK_DECIMAL;
case KeyEvent.VK_DELETE:
return java.awt.event.KeyEvent.VK_DELETE;
case KeyEvent.VK_DIVIDE:
return java.awt.event.KeyEvent.VK_DIVIDE;
case KeyEvent.VK_DOLLAR:
return java.awt.event.KeyEvent.VK_DOLLAR;
case KeyEvent.VK_DOWN:
return java.awt.event.KeyEvent.VK_DOWN;
case KeyEvent.VK_E:
return java.awt.event.KeyEvent.VK_E;
case KeyEvent.VK_END:
return java.awt.event.KeyEvent.VK_END;
case KeyEvent.VK_ENTER:
return java.awt.event.KeyEvent.VK_ENTER;
case KeyEvent.VK_EQUALS:
return java.awt.event.KeyEvent.VK_EQUALS;
case KeyEvent.VK_ESCAPE:
return java.awt.event.KeyEvent.VK_ESCAPE;
case KeyEvent.VK_EURO_SIGN:
return java.awt.event.KeyEvent.VK_EURO_SIGN;
case KeyEvent.VK_EXCLAMATION_MARK:
return java.awt.event.KeyEvent.VK_EXCLAMATION_MARK;
case KeyEvent.VK_F:
return java.awt.event.KeyEvent.VK_F;
case KeyEvent.VK_F1:
return java.awt.event.KeyEvent.VK_F1;
case KeyEvent.VK_F10:
return java.awt.event.KeyEvent.VK_F10;
case KeyEvent.VK_F11:
return java.awt.event.KeyEvent.VK_F11;
case KeyEvent.VK_F12:
return java.awt.event.KeyEvent.VK_F12;
case KeyEvent.VK_F13:
return java.awt.event.KeyEvent.VK_F13;
case KeyEvent.VK_F14:
return java.awt.event.KeyEvent.VK_F14;
case KeyEvent.VK_F15:
return java.awt.event.KeyEvent.VK_F15;
case KeyEvent.VK_F16:
return java.awt.event.KeyEvent.VK_F16;
case KeyEvent.VK_F17:
return java.awt.event.KeyEvent.VK_F17;
case KeyEvent.VK_F18:
return java.awt.event.KeyEvent.VK_F18;
case KeyEvent.VK_F19:
return java.awt.event.KeyEvent.VK_F19;
case KeyEvent.VK_F2:
return java.awt.event.KeyEvent.VK_F2;
case KeyEvent.VK_F20:
return java.awt.event.KeyEvent.VK_F20;
case KeyEvent.VK_F21:
return java.awt.event.KeyEvent.VK_F21;
case KeyEvent.VK_F22:
return java.awt.event.KeyEvent.VK_F22;
case KeyEvent.VK_F23:
return java.awt.event.KeyEvent.VK_F23;
case KeyEvent.VK_F24:
return java.awt.event.KeyEvent.VK_F24;
case KeyEvent.VK_F3:
return java.awt.event.KeyEvent.VK_F3;
case KeyEvent.VK_F4:
return java.awt.event.KeyEvent.VK_F4;
case KeyEvent.VK_F5:
return java.awt.event.KeyEvent.VK_F5;
case KeyEvent.VK_F6:
return java.awt.event.KeyEvent.VK_F6;
case KeyEvent.VK_F7:
return java.awt.event.KeyEvent.VK_F7;
case KeyEvent.VK_F8:
return java.awt.event.KeyEvent.VK_F8;
case KeyEvent.VK_F9:
return java.awt.event.KeyEvent.VK_F9;
case KeyEvent.VK_FINAL:
return java.awt.event.KeyEvent.VK_FINAL;
case KeyEvent.VK_FIND:
return java.awt.event.KeyEvent.VK_FIND;
case KeyEvent.VK_FULL_WIDTH:
return java.awt.event.KeyEvent.VK_FULL_WIDTH;
case KeyEvent.VK_G:
return java.awt.event.KeyEvent.VK_G;
case KeyEvent.VK_GREATER:
return java.awt.event.KeyEvent.VK_GREATER;
case KeyEvent.VK_H:
return java.awt.event.KeyEvent.VK_H;
case KeyEvent.VK_HALF_WIDTH:
return java.awt.event.KeyEvent.VK_HALF_WIDTH;
case KeyEvent.VK_HELP:
return java.awt.event.KeyEvent.VK_HELP;
case KeyEvent.VK_HIRAGANA:
return java.awt.event.KeyEvent.VK_HIRAGANA;
case KeyEvent.VK_HOME:
return java.awt.event.KeyEvent.VK_HOME;
case KeyEvent.VK_I:
return java.awt.event.KeyEvent.VK_I;
case KeyEvent.VK_INPUT_METHOD_ON_OFF:
return java.awt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF;
case KeyEvent.VK_INSERT:
return java.awt.event.KeyEvent.VK_INSERT;
case KeyEvent.VK_INVERTED_EXCLAMATION_MARK:
return java.awt.event.KeyEvent.VK_INVERTED_EXCLAMATION_MARK;
case KeyEvent.VK_J:
return java.awt.event.KeyEvent.VK_J;
case KeyEvent.VK_JAPANESE_HIRAGANA:
return java.awt.event.KeyEvent.VK_JAPANESE_HIRAGANA;
case KeyEvent.VK_JAPANESE_KATAKANA:
return java.awt.event.KeyEvent.VK_JAPANESE_KATAKANA;
case KeyEvent.VK_JAPANESE_ROMAN:
return java.awt.event.KeyEvent.VK_JAPANESE_ROMAN;
case KeyEvent.VK_K:
return java.awt.event.KeyEvent.VK_K;
case KeyEvent.VK_KANA:
return java.awt.event.KeyEvent.VK_KANA;
case KeyEvent.VK_KANA_LOCK:
return java.awt.event.KeyEvent.VK_KANA_LOCK;
case KeyEvent.VK_KANJI:
return java.awt.event.KeyEvent.VK_KANJI;
case KeyEvent.VK_KATAKANA:
return java.awt.event.KeyEvent.VK_KATAKANA;
case KeyEvent.VK_KP_DOWN:
return java.awt.event.KeyEvent.VK_KP_DOWN;
case KeyEvent.VK_KP_LEFT:
return java.awt.event.KeyEvent.VK_KP_LEFT;
case KeyEvent.VK_KP_RIGHT:
return java.awt.event.KeyEvent.VK_KP_RIGHT;
case KeyEvent.VK_KP_UP:
return java.awt.event.KeyEvent.VK_KP_UP;
case KeyEvent.VK_L:
return java.awt.event.KeyEvent.VK_L;
case KeyEvent.VK_LEFT:
return java.awt.event.KeyEvent.VK_LEFT;
case KeyEvent.VK_LEFT_PARENTHESIS:
return java.awt.event.KeyEvent.VK_LEFT_PARENTHESIS;
case KeyEvent.VK_LESS:
return java.awt.event.KeyEvent.VK_LESS;
case KeyEvent.VK_M:
return java.awt.event.KeyEvent.VK_M;
case KeyEvent.VK_META:
return java.awt.event.KeyEvent.VK_META;
case KeyEvent.VK_MINUS:
return java.awt.event.KeyEvent.VK_MINUS;
case KeyEvent.VK_MODECHANGE:
return java.awt.event.KeyEvent.VK_MODECHANGE;
case KeyEvent.VK_MULTIPLY:
return java.awt.event.KeyEvent.VK_MULTIPLY;
case KeyEvent.VK_N:
return java.awt.event.KeyEvent.VK_N;
case KeyEvent.VK_NONCONVERT:
return java.awt.event.KeyEvent.VK_NONCONVERT;
case KeyEvent.VK_NUM_LOCK:
return java.awt.event.KeyEvent.VK_NUM_LOCK;
case KeyEvent.VK_NUMBER_SIGN:
return java.awt.event.KeyEvent.VK_NUMBER_SIGN;
case KeyEvent.VK_NUMPAD0:
return java.awt.event.KeyEvent.VK_NUMPAD0;
case KeyEvent.VK_NUMPAD1:
return java.awt.event.KeyEvent.VK_NUMPAD1;
case KeyEvent.VK_NUMPAD2:
return java.awt.event.KeyEvent.VK_NUMPAD2;
case KeyEvent.VK_NUMPAD3:
return java.awt.event.KeyEvent.VK_NUMPAD3;
case KeyEvent.VK_NUMPAD4:
return java.awt.event.KeyEvent.VK_NUMPAD4;
case KeyEvent.VK_NUMPAD5:
return java.awt.event.KeyEvent.VK_NUMPAD5;
case KeyEvent.VK_NUMPAD6:
return java.awt.event.KeyEvent.VK_NUMPAD6;
case KeyEvent.VK_NUMPAD7:
return java.awt.event.KeyEvent.VK_NUMPAD7;
case KeyEvent.VK_NUMPAD8:
return java.awt.event.KeyEvent.VK_NUMPAD8;
case KeyEvent.VK_NUMPAD9:
return java.awt.event.KeyEvent.VK_NUMPAD9;
case KeyEvent.VK_O:
return java.awt.event.KeyEvent.VK_O;
case KeyEvent.VK_OPEN_BRACKET:
return java.awt.event.KeyEvent.VK_OPEN_BRACKET;
case KeyEvent.VK_P:
return java.awt.event.KeyEvent.VK_P;
case KeyEvent.VK_PAGE_DOWN:
return java.awt.event.KeyEvent.VK_PAGE_DOWN;
case KeyEvent.VK_PAGE_UP:
return java.awt.event.KeyEvent.VK_PAGE_UP;
case KeyEvent.VK_PASTE:
return java.awt.event.KeyEvent.VK_PASTE;
case KeyEvent.VK_PAUSE:
return java.awt.event.KeyEvent.VK_PAUSE;
case KeyEvent.VK_PERIOD:
return java.awt.event.KeyEvent.VK_PERIOD;
case KeyEvent.VK_PLUS:
return java.awt.event.KeyEvent.VK_PLUS;
case KeyEvent.VK_PREVIOUS_CANDIDATE:
return java.awt.event.KeyEvent.VK_PREVIOUS_CANDIDATE;
case KeyEvent.VK_PRINTSCREEN:
return java.awt.event.KeyEvent.VK_PRINTSCREEN;
case KeyEvent.VK_PROPS:
return java.awt.event.KeyEvent.VK_PROPS;
case KeyEvent.VK_Q:
return java.awt.event.KeyEvent.VK_Q;
case KeyEvent.VK_QUOTE:
return java.awt.event.KeyEvent.VK_QUOTE;
case KeyEvent.VK_QUOTEDBL:
return java.awt.event.KeyEvent.VK_QUOTEDBL;
case KeyEvent.VK_R:
return java.awt.event.KeyEvent.VK_R;
case KeyEvent.VK_RIGHT:
return java.awt.event.KeyEvent.VK_RIGHT;
case KeyEvent.VK_RIGHT_PARENTHESIS:
return java.awt.event.KeyEvent.VK_RIGHT_PARENTHESIS;
case KeyEvent.VK_ROMAN_CHARACTERS:
return java.awt.event.KeyEvent.VK_ROMAN_CHARACTERS;
case KeyEvent.VK_S:
return java.awt.event.KeyEvent.VK_S;
case KeyEvent.VK_SCROLL_LOCK:
return java.awt.event.KeyEvent.VK_SCROLL_LOCK;
case KeyEvent.VK_SEMICOLON:
return java.awt.event.KeyEvent.VK_SEMICOLON;
case KeyEvent.VK_SEPARATOR:
return java.awt.event.KeyEvent.VK_SEPARATOR;
case KeyEvent.VK_SHIFT:
return java.awt.event.KeyEvent.VK_SHIFT;
case KeyEvent.VK_SLASH:
return java.awt.event.KeyEvent.VK_SLASH;
case KeyEvent.VK_SPACE:
return java.awt.event.KeyEvent.VK_SPACE;
case KeyEvent.VK_STOP:
return java.awt.event.KeyEvent.VK_STOP;
case KeyEvent.VK_SUBTRACT:
return java.awt.event.KeyEvent.VK_SUBTRACT;
case KeyEvent.VK_T:
return java.awt.event.KeyEvent.VK_T;
case KeyEvent.VK_TAB:
return java.awt.event.KeyEvent.VK_TAB;
case KeyEvent.VK_U:
return java.awt.event.KeyEvent.VK_U;
case KeyEvent.VK_UNDEFINED:
return java.awt.event.KeyEvent.VK_UNDEFINED;
case KeyEvent.VK_UNDERSCORE:
return java.awt.event.KeyEvent.VK_UNDERSCORE;
case KeyEvent.VK_UNDO:
return java.awt.event.KeyEvent.VK_UNDO;
case KeyEvent.VK_UP:
return java.awt.event.KeyEvent.VK_UP;
case KeyEvent.VK_V:
return java.awt.event.KeyEvent.VK_V;
case KeyEvent.VK_W:
return java.awt.event.KeyEvent.VK_W;
case KeyEvent.VK_WINDOWS:
return java.awt.event.KeyEvent.VK_WINDOWS;
case KeyEvent.VK_X:
return java.awt.event.KeyEvent.VK_X;
case KeyEvent.VK_Y:
return java.awt.event.KeyEvent.VK_Y;
case KeyEvent.VK_Z:
return java.awt.event.KeyEvent.VK_Z;
default:
throw new RuntimeException("Unmapped key: "+event.toString());
}
}
public static int mask(com.jogamp.newt.event.MouseEvent event) {
int newtMods = event.getModifiers();
int awtMods = 0;
if ((newtMods & com.jogamp.newt.event.InputEvent.SHIFT_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.SHIFT_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.CTRL_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.CTRL_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.META_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.META_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.ALT_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.ALT_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.ALT_GRAPH_MASK;
}
if (event.getButton() == com.jogamp.newt.event.MouseEvent.BUTTON1) {
awtMods |= java.awt.event.InputEvent.BUTTON1_DOWN_MASK;
}
if (event.getButton() == com.jogamp.newt.event.MouseEvent.BUTTON2) {
awtMods |= java.awt.event.InputEvent.BUTTON2_DOWN_MASK;
}
if (event.getButton() == com.jogamp.newt.event.MouseEvent.BUTTON3) {
awtMods |= java.awt.event.InputEvent.BUTTON3_DOWN_MASK;
}
return awtMods;
}
public static int mask(com.jogamp.newt.event.KeyEvent event) {
int newtMods = event.getModifiers();
int awtMods = 0;
if ((newtMods & com.jogamp.newt.event.InputEvent.SHIFT_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.SHIFT_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.CTRL_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.CTRL_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.META_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.META_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.ALT_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.ALT_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.ALT_GRAPH_MASK;
}
return awtMods;
}
public static int mask(com.jogamp.newt.event.KeyEvent event) {
int newtMods = event.getModifiers();
int awtMods = 0;
if ((newtMods & com.jogamp.newt.event.InputEvent.SHIFT_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.SHIFT_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.CTRL_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.CTRL_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.META_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.META_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.ALT_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.ALT_MASK;
}
if ((newtMods & com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK) != 0) {
awtMods |= java.awt.event.InputEvent.ALT_GRAPH_MASK;
}
return awtMods;
}
}

View File

@ -34,9 +34,4 @@ public class AwtToNewtKeyListener implements com.jogamp.newt.event.KeyListener {
keyListener.keyReleased(convertEvent(ke, java.awt.event.KeyEvent.KEY_RELEASED));
}
@Override
public void keyTyped(KeyEvent ke) {
keyListener.keyTyped(convertEvent(ke, java.awt.event.KeyEvent.KEY_TYPED));
}
}

View File

@ -1,8 +1,7 @@
package org.jzy3d.bridge.newt.controllers.keyboard;
import jogamp.newt.awt.event.AWTNewtEventFactory;
import com.jogamp.newt.Window;
import jogamp.newt.awt.event.AWTNewtEventFactory;
/**
*
@ -32,9 +31,17 @@ public class NewtToAWTKeyListener implements java.awt.event.KeyListener {
keyListener.keyReleased(convertEvent(ke));
}
/**
* This method will throw a RuntimeException since 'keyType' is no longer
* supported in JOGL 2.1.
* @deprecated
* @param ke
* @throws RuntimeException
*/
@Deprecated
@Override
public void keyTyped(java.awt.event.KeyEvent ke) {
keyListener.keyTyped(convertEvent(ke));
public void keyTyped(java.awt.event.KeyEvent ke) throws RuntimeException {
throw new RuntimeException("'keyTyped' can not be mapped to NEWT's event model. Please use 'keyReleased' instead!");
}
}

View File

@ -3,7 +3,6 @@ package org.jzy3d.bridge.newt.controllers.mouse;
import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import org.jzy3d.bridge.newt.controllers.AwtToNewtUtilities;
/**
@ -32,7 +31,10 @@ public class AwtToNewtMouseListener implements com.jogamp.newt.event.MouseListen
}
protected java.awt.event.MouseWheelEvent convertWheelEvent(com.jogamp.newt.event.MouseEvent event, int id) {
return new java.awt.event.MouseWheelEvent(source, id, event.getWhen(), AwtToNewtUtilities.mask(event), event.getX(), event.getY(), event.getClickCount(), false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, event.getWheelRotation());
//rotation direction needs to be inverted between NEWT and AWT
int direction = event.getRotation()[1]>0?-1:1;
int units = (int)Math.round(event.getRotation()[1]*event.getRotationScale());
return new java.awt.event.MouseWheelEvent(source, id, event.getWhen(), AwtToNewtUtilities.mask(event), event.getX(), event.getY(), event.getClickCount(), false, MouseWheelEvent.WHEEL_UNIT_SCROLL, units, direction);
}
@Override