diff options
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/awt')
5 files changed, 88 insertions, 87 deletions
diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java index 72c9ac54b..26ec62785 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java @@ -86,7 +86,7 @@ public class AWTThreadingPlugin implements ToolkitThreadingPlugin { } @Override - public final void invokeOnOpenGLThread(boolean wait, Runnable r) throws GLException { + public final void invokeOnOpenGLThread(final boolean wait, final Runnable r) throws GLException { switch (ThreadingImpl.getMode()) { case ST_AWT: // FIXME: ideally should run all OpenGL work on the Java2D QFT diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 1c1d2350a..a5f5b4702 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -83,11 +83,11 @@ public class AWTTilePainter { private Graphics2D g2d = null; private AffineTransform saveAT = null; - public static void dumpHintsAndScale(Graphics2D g2d) { + public static void dumpHintsAndScale(final Graphics2D g2d) { final RenderingHints rHints = g2d.getRenderingHints(); final Set<Entry<Object, Object>> rEntries = rHints.entrySet(); int count = 0; - for(Iterator<Entry<Object, Object>> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { + for(final Iterator<Entry<Object, Object>> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { final Entry<Object, Object> rEntry = rEntryIter.next(); System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); } @@ -105,7 +105,7 @@ public class AWTTilePainter { /** * @return resulting number of samples by comparing w/ {@link #customNumSamples} and the caps-config, 0 if disabled */ - public int getNumSamples(GLCapabilitiesImmutable caps) { + public int getNumSamples(final GLCapabilitiesImmutable caps) { if( 0 > customNumSamples ) { return 0; } else if( 0 < customNumSamples ) { @@ -137,7 +137,7 @@ public class AWTTilePainter { * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param verbose */ - public AWTTilePainter(TileRenderer renderer, int componentCount, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight, boolean verbose) { + public AWTTilePainter(final TileRenderer renderer, final int componentCount, final double scaleMatX, final double scaleMatY, final int numSamples, final int tileWidth, final int tileHeight, final boolean verbose) { this.renderer = renderer; this.renderer.setGLEventListener(preTileGLEL, postTileGLEL); this.componentCount = componentCount; @@ -160,16 +160,16 @@ public class AWTTilePainter { * @param flipVertical if <code>true</code>, the image will be flipped vertically (Default for OpenGL). * @param originBottomLeft if <code>true</code>, the image's origin is on the bottom left (Default for OpenGL). */ - public void setGLOrientation(boolean flipVertical, boolean originBottomLeft) { + public void setGLOrientation(final boolean flipVertical, final boolean originBottomLeft) { this.flipVertical = flipVertical; this.originBottomLeft = originBottomLeft; } - private static Rectangle2D getClipBounds2D(Graphics2D g) { + private static Rectangle2D getClipBounds2D(final Graphics2D g) { final Shape shape = g.getClip(); return null != shape ? shape.getBounds2D() : null; } - private static Rectangle2D clipNegative(Rectangle2D in) { + private static Rectangle2D clipNegative(final Rectangle2D in) { if( null == in ) { return null; } double x=in.getX(), y=in.getY(), width=in.getWidth(), height=in.getHeight(); if( 0 > x ) { @@ -201,7 +201,7 @@ public class AWTTilePainter { * @throws NoninvertibleTransformException if the {@link Graphics2D}'s {@link AffineTransform} {@link AffineTransform#invert() inversion} fails. * Since inversion is tested before scaling the given {@link Graphics2D}, caller shall ignore the whole <i>term</i>. */ - public void setupGraphics2DAndClipBounds(Graphics2D g2d, int width, int height) throws NoninvertibleTransformException { + public void setupGraphics2DAndClipBounds(final Graphics2D g2d, final int width, final int height) throws NoninvertibleTransformException { this.g2d = g2d; saveAT = g2d.getTransform(); if( null == saveAT ) { @@ -278,11 +278,11 @@ public class AWTTilePainter { final GLEventListener preTileGLEL = new GLEventListener() { @Override - public void init(GLAutoDrawable drawable) {} + public void init(final GLAutoDrawable drawable) {} @Override - public void dispose(GLAutoDrawable drawable) {} + public void dispose(final GLAutoDrawable drawable) {} @Override - public void display(GLAutoDrawable drawable) { + public void display(final GLAutoDrawable drawable) { final GL gl = drawable.getGL(); if( null == tBuffer ) { final int tWidth = renderer.getParam(TileRenderer.TR_TILE_WIDTH); @@ -302,17 +302,17 @@ public class AWTTilePainter { } } @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {} }; static int _counter = 0; final GLEventListener postTileGLEL = new GLEventListener() { @Override - public void init(GLAutoDrawable drawable) { + public void init(final GLAutoDrawable drawable) { } @Override - public void dispose(GLAutoDrawable drawable) {} + public void dispose(final GLAutoDrawable drawable) {} @Override - public void display(GLAutoDrawable drawable) { + public void display(final GLAutoDrawable drawable) { final DimensionImmutable cis = renderer.getClippedImageSize(); final int tWidth = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH); final int tHeight = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); @@ -337,7 +337,7 @@ public class AWTTilePainter { final File fout = new File(fname); try { ImageIO.write(tBuffer.image, "png", fout); - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); } } @@ -368,7 +368,7 @@ public class AWTTilePainter { final File fout = new File(fname); try { ImageIO.write(dstImage, "png", fout); - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); } _counter++; @@ -395,6 +395,6 @@ public class AWTTilePainter { } } @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {} }; } diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java b/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java index dc286ca59..e34ec18b6 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java @@ -59,7 +59,7 @@ public class AWTUtil { isOGLPipelineActive = j2dClazz.getMethod("isOGLPipelineActive", (Class[])null); isQueueFlusherThread = j2dClazz.getMethod("isQueueFlusherThread", (Class[])null); j2dOk = true; - } catch (Exception e) {} + } catch (final Exception e) {} } } @@ -84,7 +84,7 @@ public class AWTUtil { !((Boolean)isQueueFlusherThread.invoke(null, (Object[])null)).booleanValue() ) { NativeWindowFactory.getAWTToolkitLock().lock(); } - } catch (Exception e) { j2dOk=false; } + } catch (final Exception e) { j2dOk=false; } } if(!j2dOk) { NativeWindowFactory.getAWTToolkitLock().lock(); @@ -107,7 +107,7 @@ public class AWTUtil { !((Boolean)isQueueFlusherThread.invoke(null, (Object[])null)).booleanValue() ) { NativeWindowFactory.getAWTToolkitLock().unlock(); } - } catch (Exception e) { j2dOk=false; } + } catch (final Exception e) { j2dOk=false; } } if(!j2dOk) { NativeWindowFactory.getAWTToolkitLock().unlock(); diff --git a/src/jogl/classes/jogamp/opengl/awt/Java2D.java b/src/jogl/classes/jogamp/opengl/awt/Java2D.java index 5735b875e..86ca7650f 100644 --- a/src/jogl/classes/jogamp/opengl/awt/Java2D.java +++ b/src/jogl/classes/jogamp/opengl/awt/Java2D.java @@ -59,6 +59,7 @@ import javax.media.opengl.GLProfile; import com.jogamp.common.os.Platform; +import jogamp.common.os.PlatformPropsImpl; import jogamp.opengl.Debug; @@ -128,7 +129,7 @@ public class Java2D { // OpenGL graphics configuration final GraphicsConfiguration cfg; final String cfgName; - final boolean java2dOGLDisabledByOS = Platform.OS_TYPE == Platform.OSType.MACOS; + final boolean java2dOGLDisabledByOS = PlatformPropsImpl.OS_TYPE == Platform.OSType.MACOS; final boolean java2dOGLDisabledByProp; { boolean enabled = true; @@ -160,7 +161,7 @@ public class Java2D { if (isOGLPipelineActive) { try { // Try to get methods we need to integrate - Class<?> utils = Class.forName("sun.java2d.opengl.OGLUtilities"); + final Class<?> utils = Class.forName("sun.java2d.opengl.OGLUtilities"); invokeWithOGLContextCurrentMethod = utils.getDeclaredMethod("invokeWithOGLContextCurrent", new Class[] { Graphics.class, @@ -208,7 +209,7 @@ public class Java2D { Graphics.class }); getOGLSurfaceTypeMethod.setAccessible(true); - } catch (Exception e) { + } catch (final Exception e) { fbObjectSupportInitialized = false; if (DEBUG) { e.printStackTrace(); @@ -223,7 +224,7 @@ public class Java2D { Graphics.class }); getOGLTextureTypeMethod.setAccessible(true); - } catch (Exception e) { + } catch (final Exception e) { if (DEBUG) { e.printStackTrace(); System.err.println("Info: GL_ARB_texture_rectangle FBO support disabled"); @@ -236,7 +237,7 @@ public class Java2D { Class<?> cglSurfaceData = null; try { cglSurfaceData = Class.forName("sun.java2d.opengl.CGLSurfaceData"); - } catch (Exception e) { + } catch (final Exception e) { if (DEBUG) { e.printStackTrace(); System.err.println("Info: Unable to find class sun.java2d.opengl.CGLSurfaceData for OS X"); @@ -268,7 +269,7 @@ public class Java2D { destroyOGLContextMethod.setAccessible(true); } } - } catch (Exception e) { + } catch (final Exception e) { caught = e; if (DEBUG) { System.err.println("Info: Disabling Java2D/JOGL integration"); @@ -277,9 +278,9 @@ public class Java2D { isOGLPipelineResourceCompatible = false; } } - } catch (HeadlessException e) { + } catch (final HeadlessException e) { // The AWT is running in headless mode, so the Java 2D / JOGL bridge is clearly disabled - } catch (Error e) { + } catch (final Error e) { // issued on OSX Java7: java.lang.Error: Could not find class: sun.awt.HeadlessGraphicsEnvironment caught = e; } @@ -312,9 +313,9 @@ public class Java2D { try { return ((Boolean) isQueueFlusherThreadMethod.invoke(null, (Object[])null)).booleanValue(); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } @@ -322,7 +323,7 @@ public class Java2D { /** Makes current the OpenGL context associated with the passed Graphics object and runs the given Runnable on the Queue Flushing Thread in one atomic action. */ - public static void invokeWithOGLContextCurrent(Graphics g, Runnable r) throws GLException { + public static void invokeWithOGLContextCurrent(final Graphics g, final Runnable r) throws GLException { checkActive(); try { @@ -341,9 +342,9 @@ public class Java2D { } finally { AWTUtil.unlockToolkit(); } - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } @@ -356,7 +357,7 @@ public class Java2D { JOGL must share textures and display lists with it. Returns false if the passed GraphicsConfiguration was not an OpenGL GraphicsConfiguration. */ - public static boolean invokeWithOGLSharedContextCurrent(GraphicsConfiguration g, Runnable r) throws GLException { + public static boolean invokeWithOGLSharedContextCurrent(final GraphicsConfiguration g, final Runnable r) throws GLException { checkCompatible(); try { @@ -366,9 +367,9 @@ public class Java2D { } finally { AWTUtil.unlockToolkit(); } - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } @@ -379,18 +380,18 @@ public class Java2D { call glViewport() with the returned rectangle's bounds in order to get correct rendering results. Should only be called from the Queue Flusher Thread. */ - public static Rectangle getOGLViewport(Graphics g, - int componentWidth, - int componentHeight) { + public static Rectangle getOGLViewport(final Graphics g, + final int componentWidth, + final int componentHeight) { checkCompatible(); try { return (Rectangle) getOGLViewportMethod.invoke(null, new Object[] {g, new Integer(componentWidth), new Integer(componentHeight)}); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } @@ -401,14 +402,14 @@ public class Java2D { method should be called and the resulting rectangle's bounds passed to a call to glScissor(). Should only be called from the Queue Flusher Thread. */ - public static Rectangle getOGLScissorBox(Graphics g) { + public static Rectangle getOGLScissorBox(final Graphics g) { checkCompatible(); try { return (Rectangle) getOGLScissorBoxMethod.invoke(null, new Object[] {g}); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } @@ -419,14 +420,14 @@ public class Java2D { changed and a new external GLDrawable and GLContext should be created (and the old ones destroyed). Should only be called from the Queue Flusher Thread.*/ - public static Object getOGLSurfaceIdentifier(Graphics g) { + public static Object getOGLSurfaceIdentifier(final Graphics g) { checkCompatible(); try { return getOGLSurfaceIdentifierMethod.invoke(null, new Object[] {g}); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } @@ -434,7 +435,7 @@ public class Java2D { /** Returns the underlying surface type for the given Graphics object. This indicates, in particular, whether Java2D is currently rendering into a pbuffer or FBO. */ - public static int getOGLSurfaceType(Graphics g) { + public static int getOGLSurfaceType(final Graphics g) { checkCompatible(); try { @@ -445,9 +446,9 @@ public class Java2D { } return ((Integer) getOGLSurfaceTypeMethod.invoke(null, new Object[] { g })).intValue(); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } @@ -455,7 +456,7 @@ public class Java2D { /** Returns the underlying texture target of the given Graphics object assuming it is rendering to an FBO. Returns either GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB. */ - public static int getOGLTextureType(Graphics g) { + public static int getOGLTextureType(final Graphics g) { checkCompatible(); if (getOGLTextureTypeMethod == null) { @@ -464,9 +465,9 @@ public class Java2D { try { return ((Integer) getOGLTextureTypeMethod.invoke(null, new Object[] { g })).intValue(); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } @@ -477,7 +478,7 @@ public class Java2D { used for rendering. FIXME: may need to alter the API in the future to indicate which GraphicsDevice the source context is associated with. */ - public static GLContext filterShareContext(GLContext shareContext) { + public static GLContext filterShareContext(final GLContext shareContext) { if (isHeadless) return shareContext; @@ -495,7 +496,7 @@ public class Java2D { context", with which all contexts created by JOGL must share textures and display lists when the FBO option is enabled for the Java2D/OpenGL pipeline. */ - public static GLContext getShareContext(GraphicsDevice device) { + public static GLContext getShareContext(final GraphicsDevice device) { initFBOShareContext(device); // FIXME: for full generality probably need to have multiple of // these, one per GraphicsConfiguration seen? @@ -509,41 +510,41 @@ public class Java2D { /** (Mac OS X-specific) Creates a new OpenGL context on the surface associated with the given Graphics object, sharing textures and display lists with the specified (CGLContextObj) share context. */ - public static long createOGLContextOnSurface(Graphics g, long shareCtx) { + public static long createOGLContextOnSurface(final Graphics g, final long shareCtx) { checkCompatible(); try { return ((Long) createOGLContextOnSurfaceMethod.invoke(null, new Object[] { g, new Long(shareCtx) })).longValue(); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } /** (Mac OS X-specific) Makes the given OpenGL context current on the surface associated with the given Graphics object. */ - public static boolean makeOGLContextCurrentOnSurface(Graphics g, long ctx) { + public static boolean makeOGLContextCurrentOnSurface(final Graphics g, final long ctx) { checkCompatible(); try { return ((Boolean) makeOGLContextCurrentOnSurfaceMethod.invoke(null, new Object[] { g, new Long(ctx) })).booleanValue(); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } /** (Mac OS X-specific) Destroys the given OpenGL context. */ - public static void destroyOGLContext(long ctx) { + public static void destroyOGLContext(final long ctx) { checkCompatible(); try { destroyOGLContextMethod.invoke(null, new Object[] { new Long(ctx) }); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new GLException(e.getTargetException()); - } catch (Exception e) { + } catch (final Exception e) { throw (InternalError) new InternalError().initCause(e); } } @@ -565,15 +566,15 @@ public class Java2D { } private static int getOGLUtilitiesIntField(final String name) { - Integer i = AccessController.doPrivileged(new PrivilegedAction<Integer>() { + final Integer i = AccessController.doPrivileged(new PrivilegedAction<Integer>() { @Override public Integer run() { try { - Class<?> utils = Class.forName("sun.java2d.opengl.OGLUtilities"); - Field f = utils.getField(name); + final Class<?> utils = Class.forName("sun.java2d.opengl.OGLUtilities"); + final Field f = utils.getField(name); f.setAccessible(true); return (Integer) f.get(null); - } catch (Exception e) { + } catch (final Exception e) { if (DEBUG) { e.printStackTrace(); } diff --git a/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java b/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java index 9173a38cb..2f87f01a9 100644 --- a/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java +++ b/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java @@ -31,12 +31,12 @@ public class VersionApplet extends Applet { TextArea tareaCaps; GLCanvas canvas; - public static void main(String[] args) { - Frame frame = new Frame("JOGL Version Applet"); + public static void main(final String[] args) { + final Frame frame = new Frame("JOGL Version Applet"); frame.setSize(800, 600); frame.setLayout(new BorderLayout()); - VersionApplet va = new VersionApplet(); + final VersionApplet va = new VersionApplet(); frame.addWindowListener(new ClosingWindowAdapter(frame, va)); va.init(); @@ -50,12 +50,12 @@ public class VersionApplet extends Applet { static class ClosingWindowAdapter extends WindowAdapter { Frame f; VersionApplet va; - public ClosingWindowAdapter(Frame f, VersionApplet va) { + public ClosingWindowAdapter(final Frame f, final VersionApplet va) { this.f = f; this.va = va; } @Override - public void windowClosing(WindowEvent ev) { + public void windowClosing(final WindowEvent ev) { f.setVisible(false); va.stop(); va.destroy(); @@ -70,8 +70,8 @@ public class VersionApplet extends Applet { setEnabled(true); - GLProfile glp = GLProfile.getDefault(); - GLCapabilities glcaps = new GLCapabilities(glp); + final GLProfile glp = GLProfile.getDefault(); + final GLCapabilities glcaps = new GLCapabilities(glp); setLayout(new BorderLayout()); String s; @@ -96,16 +96,16 @@ public class VersionApplet extends Applet { tareaVersion.append(s); tareaCaps = new TextArea(120, 20); - GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(null); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); + final List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(null); for(int i=0; i<availCaps.size(); i++) { - s = ((GLCapabilitiesImmutable) availCaps.get(i)).toString(); + s = availCaps.get(i).toString(); System.err.println(s); tareaCaps.append(s); tareaCaps.append(Platform.getNewline()); } - Container grid = new Container(); + final Container grid = new Container(); grid.setLayout(new GridLayout(2, 1)); grid.add(tareaVersion); grid.add(tareaCaps); @@ -160,23 +160,23 @@ public class VersionApplet extends Applet { class GLInfo implements GLEventListener { @Override - public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - String s = JoglVersion.getGLInfo(gl, null).toString(); + public void init(final GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + final String s = JoglVersion.getGLInfo(gl, null).toString(); System.err.println(s); tareaVersion.append(s); } @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } @Override - public void display(GLAutoDrawable drawable) { + public void display(final GLAutoDrawable drawable) { } @Override - public void dispose(GLAutoDrawable drawable) { + public void dispose(final GLAutoDrawable drawable) { } } |