diff options
author | Sven Gothel <[email protected]> | 2014-07-03 16:21:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-03 16:21:36 +0200 |
commit | 556d92b63555a085b25e32b1cd55afce24edd07a (patch) | |
tree | 6be2b02c62a77d5aba81ffbe34c46960608be163 /src/newt/classes/jogamp | |
parent | a90f4a51dffec3247278e3c683ed4462b1dd9ab5 (diff) |
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Add final modifier to private fields
- Add final modifier to method parameters
- Add final modifier to local variables
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
- Remove trailing white spaces on all lines
Diffstat (limited to 'src/newt/classes/jogamp')
57 files changed, 717 insertions, 694 deletions
diff --git a/src/newt/classes/jogamp/newt/Debug.java b/src/newt/classes/jogamp/newt/Debug.java index 7ef2d7ffc..773820c33 100644 --- a/src/newt/classes/jogamp/newt/Debug.java +++ b/src/newt/classes/jogamp/newt/Debug.java @@ -63,7 +63,7 @@ public class Debug extends PropertyAccess { verbose = isPropertyDefined("newt.verbose", true); debugAll = isPropertyDefined("newt.debug", true); if (verbose) { - Package p = Package.getPackage("com.jogamp.newt"); + final Package p = Package.getPackage("com.jogamp.newt"); System.err.println("NEWT specification version " + p.getSpecificationVersion()); System.err.println("NEWT implementation version " + p.getImplementationVersion()); System.err.println("NEWT implementation vendor " + p.getImplementationVendor()); @@ -81,7 +81,7 @@ public class Debug extends PropertyAccess { return debugAll; } - public static final boolean debug(String subcomponent) { + public static final boolean debug(final String subcomponent) { return debugAll() || isPropertyDefined("newt.debug." + subcomponent, true); } } diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index ae72c8c73..ec5126932 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -63,7 +63,7 @@ public class DefaultEDTUtil implements EDTUtil { private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; - public DefaultEDTUtil(ThreadGroup tg, String name, Runnable dispatchMessages) { + public DefaultEDTUtil(final ThreadGroup tg, final String name, final Runnable dispatchMessages) { this.threadGroup = tg; this.name=Thread.currentThread().getName()+"-"+name+"-EDT-"; this.dispatchMessages=dispatchMessages; @@ -77,7 +77,7 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - final public void setPollPeriod(long ms) { + final public void setPollPeriod(final long ms) { pollPeriod = ms; } @@ -141,7 +141,7 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final boolean invokeStop(boolean wait, Runnable task) { + public final boolean invokeStop(final boolean wait, final Runnable task) { if(DEBUG) { System.err.println(Thread.currentThread()+": Default-EDT.invokeStop wait "+wait); Thread.dumpStack(); @@ -149,7 +149,7 @@ public class DefaultEDTUtil implements EDTUtil { return invokeImpl(wait, task, true /* stop */, false /* provokeError */); } - public final boolean invokeAndWaitError(Runnable task) { + public final boolean invokeAndWaitError(final Runnable task) { if(DEBUG) { System.err.println(Thread.currentThread()+": Default-EDT.invokeAndWaitError"); Thread.dumpStack(); @@ -158,7 +158,7 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final boolean invoke(boolean wait, Runnable task) { + public final boolean invoke(final boolean wait, final Runnable task) { return invokeImpl(wait, task, false /* stop */, false /* provokeError */); } @@ -167,7 +167,7 @@ public class DefaultEDTUtil implements EDTUtil { public void run() { } }; - private final boolean invokeImpl(boolean wait, Runnable task, boolean stop, boolean provokeError) { + private final boolean invokeImpl(boolean wait, Runnable task, final boolean stop, final boolean provokeError) { Throwable throwable = null; RunnableTask rTask = null; final Object rTaskLock = new Object(); @@ -235,7 +235,7 @@ public class DefaultEDTUtil implements EDTUtil { if( wait ) { try { rTaskLock.wait(); // free lock, allow execution of rTask - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { throwable = ie; } if(null==throwable) { @@ -271,7 +271,7 @@ public class DefaultEDTUtil implements EDTUtil { try { _edt.tasks.notifyAll(); _edt.tasks.wait(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } @@ -286,7 +286,7 @@ public class DefaultEDTUtil implements EDTUtil { while( edt.isRunning ) { try { edtLock.wait(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } @@ -302,7 +302,7 @@ public class DefaultEDTUtil implements EDTUtil { volatile boolean isRunning = false; final ArrayList<RunnableTask> tasks = new ArrayList<RunnableTask>(); // one shot tasks - public NEDT(ThreadGroup tg, String name) { + public NEDT(final ThreadGroup tg, final String name) { super(tg, name); } @@ -349,7 +349,7 @@ public class DefaultEDTUtil implements EDTUtil { if(!shouldStop && tasks.size()==0) { try { tasks.wait(pollPeriod); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } @@ -379,7 +379,7 @@ public class DefaultEDTUtil implements EDTUtil { } } } while(!shouldStop) ; - } catch (Throwable t) { + } catch (final Throwable t) { // handle errors .. shouldStop = true; if(t instanceof RuntimeException) { diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 952e611f2..84ce45238 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -142,7 +142,7 @@ public abstract class DisplayImpl extends Display { System.err.println("createPointerIconPNG.0: "+res[0]); } } - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } } ); @@ -199,7 +199,7 @@ public abstract class DisplayImpl extends Display { res[0] = new PointerIconImpl(DisplayImpl.this, fpixelrect, new Point(hotX, hotY), handle); } } - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } } ); @@ -222,7 +222,7 @@ public abstract class DisplayImpl extends Display { * @param hotY the PointerIcon's hot-spot x-coord * @return if successful a valid handle (not null), otherwise null. */ - protected final long createPointerIconImplChecked(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + protected final long createPointerIconImplChecked(final PixelFormat pixelformat, final int width, final int height, final ByteBuffer pixels, final int hotX, final int hotY) { if( getNativePointerIconPixelFormat() != pixelformat ) { throw new IllegalArgumentException("Pixelformat no "+getNativePointerIconPixelFormat()+", but "+pixelformat); } @@ -243,17 +243,17 @@ public abstract class DisplayImpl extends Display { * @param hotY the PointerIcon's hot-spot x-coord * @return if successful a valid handle (not null), otherwise null. */ - protected long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + protected long createPointerIconImpl(final PixelFormat pixelformat, final int width, final int height, final ByteBuffer pixels, final int hotX, final int hotY) { return 0; } /** Executed from EDT! */ - protected void destroyPointerIconImpl(final long displayHandle, long piHandle) { } + protected void destroyPointerIconImpl(final long displayHandle, final long piHandle) { } /** Ensure static init has been run. */ /* pp */static void initSingleton() { } - private static Class<?> getDisplayClass(String type) + private static Class<?> getDisplayClass(final String type) throws ClassNotFoundException { final Class<?> displayClass = NewtFactory.getCustomClass(type, "DisplayDriver"); @@ -264,7 +264,7 @@ public abstract class DisplayImpl extends Display { } /** Make sure to reuse a Display with the same name */ - public static Display create(String type, String name, final long handle, boolean reuse) { + public static Display create(final String type, String name, final long handle, final boolean reuse) { try { final Class<?> displayClass = getDisplayClass(type); final DisplayImpl display = (DisplayImpl) displayClass.newInstance(); @@ -294,13 +294,13 @@ public abstract class DisplayImpl extends Display { System.err.println("Display.create() NEW: "+display+" "+getThreadName()); } return display; - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -340,7 +340,7 @@ public abstract class DisplayImpl extends Display { public void run() { f_dpy.createNativeImpl(); }}); - } catch (Throwable t) { + } catch (final Throwable t) { throw new NativeWindowException(t); } if( null == aDevice ) { @@ -409,7 +409,7 @@ public abstract class DisplayImpl extends Display { } } - public void runOnEDTIfAvail(boolean wait, final Runnable task) { + public void runOnEDTIfAvail(final boolean wait, final Runnable task) { final EDTUtil _edtUtil = edtUtil; if( !_edtUtil.isRunning() ) { // start EDT if not running yet synchronized( this ) { @@ -516,7 +516,7 @@ public abstract class DisplayImpl extends Display { } try { Thread.sleep( coopSleep < 50 ? coopSleep : 50 ); - } catch (InterruptedException e) { } + } catch (final InterruptedException e) { } } else { closeNativeTask.run(); } @@ -527,7 +527,7 @@ public abstract class DisplayImpl extends Display { @Override public synchronized final int addReference() { if(DEBUG) { - System.err.println("Display.addReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount+1)); + System.err.println("Display.addReference() ("+Display.getThreadName()+"): "+refCount+" -> "+(refCount+1)); } if ( 0 == refCount ) { createNative(); @@ -542,7 +542,7 @@ public abstract class DisplayImpl extends Display { @Override public synchronized final int removeReference() { if(DEBUG) { - System.err.println("Display.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1)); + System.err.println("Display.removeReference() ("+Display.getThreadName()+"): "+refCount+" -> "+(refCount-1)); } refCount--; // could become < 0, in case of manual destruction without actual creation/addReference if(0>=refCount) { @@ -587,17 +587,17 @@ public abstract class DisplayImpl extends Display { public static final String nilString = "nil" ; - public String validateDisplayName(String name, long handle) { + public String validateDisplayName(String name, final long handle) { if(null==name && 0!=handle) { name="wrapping-"+toHexString(handle); } return ( null == name ) ? nilString : name ; } - private static String getFQName(String type, String name, int id) { + private static String getFQName(String type, String name, final int id) { if(null==type) type=nilString; if(null==name) name=nilString; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(type); sb.append("_"); sb.append(name); @@ -668,7 +668,7 @@ public abstract class DisplayImpl extends Display { } else { throw new RuntimeException("Event source not NEWT: "+source.getClass().getName()+", "+source); } - } catch (Throwable t) { + } catch (final Throwable t) { final RuntimeException re; if(t instanceof RuntimeException) { re = (RuntimeException) t; @@ -689,7 +689,7 @@ public abstract class DisplayImpl extends Display { return; } dispatchMessage(event); - } catch (RuntimeException re) { + } catch (final RuntimeException re) { if( eventTask.isCallerWaiting() ) { // propagate exception to caller eventTask.setException(re); @@ -733,7 +733,7 @@ public abstract class DisplayImpl extends Display { dispatchMessagesNative(); } - public void enqueueEvent(boolean wait, NEWTEvent e) { + public void enqueueEvent(final boolean wait, final NEWTEvent e) { final EDTUtil _edtUtil = edtUtil; if( !_edtUtil.isRunning() ) { // oops .. we are already dead @@ -761,7 +761,7 @@ public abstract class DisplayImpl extends Display { if( wait ) { try { lock.wait(); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { throw new RuntimeException(ie); } if( null != eTask.getException() ) { @@ -774,7 +774,7 @@ public abstract class DisplayImpl extends Display { public interface DisplayRunnable<T> { T run(long dpy); } - public static final <T> T runWithLockedDevice(AbstractGraphicsDevice device, DisplayRunnable<T> action) { + public static final <T> T runWithLockedDevice(final AbstractGraphicsDevice device, final DisplayRunnable<T> action) { T res; device.lock(); try { @@ -784,7 +784,7 @@ public abstract class DisplayImpl extends Display { } return res; } - public final <T> T runWithLockedDisplayDevice(DisplayRunnable<T> action) { + public final <T> T runWithLockedDisplayDevice(final DisplayRunnable<T> action) { final AbstractGraphicsDevice device = getGraphicsDevice(); if(null == device) { throw new RuntimeException("null device - not initialized: "+this); diff --git a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java index e9e41a0ef..72300740f 100644 --- a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java +++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java @@ -38,7 +38,7 @@ import com.jogamp.newt.Screen; public class MonitorDeviceImpl extends MonitorDevice { - public MonitorDeviceImpl(ScreenImpl screen, int nativeId, DimensionImmutable sizeMM, Rectangle viewportPU, Rectangle viewportWU, MonitorMode currentMode, ArrayHashSet<MonitorMode> supportedModes) { + public MonitorDeviceImpl(final ScreenImpl screen, final int nativeId, final DimensionImmutable sizeMM, final Rectangle viewportPU, final Rectangle viewportWU, final MonitorMode currentMode, final ArrayHashSet<MonitorMode> supportedModes) { super(screen, nativeId, sizeMM, viewportPU, viewportWU, currentMode, supportedModes); } @@ -73,7 +73,7 @@ public class MonitorDeviceImpl extends MonitorDevice { } @Override - public final boolean setCurrentMode(MonitorMode mode) { + public final boolean setCurrentMode(final MonitorMode mode) { if(Screen.DEBUG) { System.err.println("Screen.setCurrentMode.0: "+this+" -> "+mode); } @@ -132,7 +132,7 @@ public class MonitorDeviceImpl extends MonitorDevice { } } - private final void setCurrentModeValue(MonitorMode currentMode) { + private final void setCurrentModeValue(final MonitorMode currentMode) { this.currentMode = currentMode; } diff --git a/src/newt/classes/jogamp/newt/MonitorModeProps.java b/src/newt/classes/jogamp/newt/MonitorModeProps.java index 74935977c..0fc0da9bc 100644 --- a/src/newt/classes/jogamp/newt/MonitorModeProps.java +++ b/src/newt/classes/jogamp/newt/MonitorModeProps.java @@ -157,26 +157,26 @@ public class MonitorModeProps { } /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - private static DimensionImmutable streamInResolution(int[] resolutionProperties, int offset) { - Dimension resolution = new Dimension(resolutionProperties[offset++], resolutionProperties[offset++]); + private static DimensionImmutable streamInResolution(final int[] resolutionProperties, int offset) { + final Dimension resolution = new Dimension(resolutionProperties[offset++], resolutionProperties[offset++]); return resolution; } /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - private static SurfaceSize streamInSurfaceSize(DimensionImmutable resolution, int[] sizeProperties, int offset) { - SurfaceSize surfaceSize = new SurfaceSize(resolution, sizeProperties[offset++]); + private static SurfaceSize streamInSurfaceSize(final DimensionImmutable resolution, final int[] sizeProperties, int offset) { + final SurfaceSize surfaceSize = new SurfaceSize(resolution, sizeProperties[offset++]); return surfaceSize; } /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - private static MonitorMode.SizeAndRRate streamInSizeAndRRate(SurfaceSize surfaceSize, int[] sizeAndRRateProperties, int offset) { + private static MonitorMode.SizeAndRRate streamInSizeAndRRate(final SurfaceSize surfaceSize, final int[] sizeAndRRateProperties, int offset) { final float refreshRate = sizeAndRRateProperties[offset++]/100.0f; final int flags = sizeAndRRateProperties[offset++]; return new MonitorMode.SizeAndRRate(surfaceSize, refreshRate, flags); } /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - private static MonitorMode streamInMonitorMode0(MonitorMode.SizeAndRRate sizeAndRate, int[] modeProperties, int offset) { + private static MonitorMode streamInMonitorMode0(final MonitorMode.SizeAndRRate sizeAndRate, final int[] modeProperties, int offset) { final int id = modeProperties[offset++]; final int rotation = modeProperties[offset++]; return new MonitorMode(id, sizeAndRate, rotation); @@ -192,8 +192,8 @@ public class MonitorModeProps { * @return {@link MonitorMode} of the identical (old or new) element in {@link Cache#monitorModes}, * matching the input <code>modeProperties</code>, or null if input could not be processed. */ - public static MonitorMode streamInMonitorMode(int[] mode_idx, Cache cache, - int[] modeProperties, int offset) { + public static MonitorMode streamInMonitorMode(final int[] mode_idx, final Cache cache, + final int[] modeProperties, int offset) { final int count = modeProperties[offset]; if(NUM_MONITOR_MODE_PROPERTIES_ALL != count) { throw new RuntimeException("property count should be "+NUM_MONITOR_MODE_PROPERTIES_ALL+", but is "+count+", len "+(modeProperties.length-offset)); @@ -225,7 +225,7 @@ public class MonitorModeProps { monitorMode = cache.monitorModes.getOrAdd(monitorMode); } if( null != mode_idx && null!=cache) { - int _modeIdx = cache.monitorModes.indexOf(monitorMode); + final int _modeIdx = cache.monitorModes.indexOf(monitorMode); if( 0 > _modeIdx ) { throw new InternalError("Invalid index of current unified mode "+monitorMode); } @@ -235,8 +235,8 @@ public class MonitorModeProps { } /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static int[] streamOutMonitorMode (MonitorMode monitorMode) { - int[] data = new int[NUM_MONITOR_MODE_PROPERTIES_ALL]; + public static int[] streamOutMonitorMode (final MonitorMode monitorMode) { + final int[] data = new int[NUM_MONITOR_MODE_PROPERTIES_ALL]; int idx=0; data[idx++] = NUM_MONITOR_MODE_PROPERTIES_ALL; data[idx++] = monitorMode.getSurfaceSize().getResolution().getWidth(); @@ -264,7 +264,7 @@ public class MonitorModeProps { * @return {@link MonitorDevice} of the identical (old or new) element in {@link Cache#monitorDevices}, * matching the input <code>modeProperties</code>, or null if input could not be processed. */ - public static MonitorDevice streamInMonitorDevice(int[] monitor_idx, Cache cache, ScreenImpl screen, int[] monitorProperties, int offset) { + public static MonitorDevice streamInMonitorDevice(final int[] monitor_idx, final Cache cache, final ScreenImpl screen, final int[] monitorProperties, int offset) { // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ final int count = monitorProperties[offset]; if(MIN_MONITOR_DEVICE_PROPERTIES > count) { @@ -304,7 +304,7 @@ public class MonitorModeProps { monitorDevice = cache.monitorDevices.getOrAdd(monitorDevice); } if( null != monitor_idx ) { - int _monitorIdx = cache.monitorDevices.indexOf(monitorDevice); + final int _monitorIdx = cache.monitorDevices.indexOf(monitorDevice); if( 0 > _monitorIdx ) { throw new InternalError("Invalid index of current unified mode "+monitorDevice); } @@ -312,7 +312,7 @@ public class MonitorModeProps { } return monitorDevice; } - private static MonitorMode getByNativeIdAndRotation(List<MonitorMode> monitorModes, int modeId, int rotation) { + private static MonitorMode getByNativeIdAndRotation(final List<MonitorMode> monitorModes, final int modeId, final int rotation) { if( null!=monitorModes && monitorModes.size()>0 ) { for (int i=0; i<monitorModes.size(); i++) { final MonitorMode mode = monitorModes.get(i); @@ -340,7 +340,7 @@ public class MonitorModeProps { * @return {@link MonitorDevice} of the identical (old or new) element in {@link Cache#monitorDevices}, * matching the input <code>modeProperties</code>, or null if input could not be processed. */ - public static MonitorDevice streamInMonitorDevice(int[] monitor_idx, Cache cache, ScreenImpl screen, ArrayHashSet<MonitorMode> supportedModes, MonitorMode currentMode, int[] monitorProperties, int offset) { + public static MonitorDevice streamInMonitorDevice(final int[] monitor_idx, final Cache cache, final ScreenImpl screen, final ArrayHashSet<MonitorMode> supportedModes, final MonitorMode currentMode, final int[] monitorProperties, int offset) { // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ final int count = monitorProperties[offset]; if(MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES != count) { @@ -362,7 +362,7 @@ public class MonitorModeProps { monitorDevice = cache.monitorDevices.getOrAdd(monitorDevice); } if( null != monitor_idx ) { - int _monitorIdx = cache.monitorDevices.indexOf(monitorDevice); + final int _monitorIdx = cache.monitorDevices.indexOf(monitorDevice); if( 0 > _monitorIdx ) { throw new InternalError("Invalid index of current unified mode "+monitorDevice); } @@ -372,13 +372,13 @@ public class MonitorModeProps { } /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static int[] streamOutMonitorDevice (MonitorDevice monitorDevice) { + public static int[] streamOutMonitorDevice (final MonitorDevice monitorDevice) { // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ - int supportedModeCount = monitorDevice.getSupportedModes().size(); + final int supportedModeCount = monitorDevice.getSupportedModes().size(); if( 0 == supportedModeCount ) { throw new RuntimeException("no supported modes: "+monitorDevice); } - int[] data = new int[MIN_MONITOR_DEVICE_PROPERTIES + supportedModeCount - 1]; + final int[] data = new int[MIN_MONITOR_DEVICE_PROPERTIES + supportedModeCount - 1]; int idx=0; data[idx++] = data.length; data[idx++] = monitorDevice.getId(); @@ -404,7 +404,7 @@ public class MonitorModeProps { return data; } - public final void swapRotatePair(int rotation, int[] pairs, int offset, int numPairs) { + public final void swapRotatePair(final int rotation, final int[] pairs, int offset, final int numPairs) { if( MonitorMode.ROTATE_0 == rotation || MonitorMode.ROTATE_180 == rotation ) { // nop return; diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index 2478b1e5d..749391f1f 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -88,7 +88,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { } @Override - public void setSurfaceHandle(long handle) { + public void setSurfaceHandle(final long handle) { surfaceHandle = handle ; } @@ -98,27 +98,27 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { } @Override - protected void requestFocusImpl(boolean reparented) { + protected void requestFocusImpl(final boolean reparented) { } @Override - public void setPosition(int x, int y) { + public void setPosition(final int x, final int y) { // nop } @Override - public boolean setFullscreen(boolean fullscreen) { + public boolean setFullscreen(final boolean fullscreen) { return false; // nop } @Override - public boolean setFullscreen(List<MonitorDevice> monitors) { + public boolean setFullscreen(final List<MonitorDevice> monitors) { return false; // nop } @Override - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { sizeChanged(false, width, height, false); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); @@ -135,7 +135,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { } @Override - public Point getLocationOnScreen(Point storage) { + public Point getLocationOnScreen(final Point storage) { if(null!=storage) { storage.set(0, 0); return storage; @@ -144,12 +144,12 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { } @Override - protected Point getLocationOnScreenImpl(int x, int y) { + protected Point getLocationOnScreenImpl(final int x, final int y) { return new Point(x,y); } @Override - protected void updateInsetsImpl(Insets insets) { + protected void updateInsetsImpl(final Insets insets) { // nop .. } } diff --git a/src/newt/classes/jogamp/newt/PointerIconImpl.java b/src/newt/classes/jogamp/newt/PointerIconImpl.java index 840799d55..546a463de 100644 --- a/src/newt/classes/jogamp/newt/PointerIconImpl.java +++ b/src/newt/classes/jogamp/newt/PointerIconImpl.java @@ -95,7 +95,7 @@ public class PointerIconImpl implements PointerIcon { try { handle = display.createPointerIconImpl(pixelformat, size.getWidth(), size.getHeight(), pixels, hotspot.getX(), hotspot.getY()); return handle; - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); return 0; } @@ -121,8 +121,8 @@ public class PointerIconImpl implements PointerIcon { @Override public synchronized void destroy() { - if(DisplayImpl.DEBUG) { - System.err.println("PointerIcon.destroy: "+this+", "+display+", "+DisplayImpl.getThreadName()); + if(Display.DEBUG) { + System.err.println("PointerIcon.destroy: "+this+", "+display+", "+Display.getThreadName()); } if( 0 != handle ) { synchronized(display.pointerIconList) { @@ -143,7 +143,7 @@ public class PointerIconImpl implements PointerIcon { handle = 0; try { display.destroyPointerIconImpl(dpy, h); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index a31a1e421..e73e153ad 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -45,6 +45,7 @@ import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.common.util.PropertyAccess; import com.jogamp.newt.Display; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; @@ -59,7 +60,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { static { Debug.initSingleton(); - DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); + DEBUG_TEST_SCREENMODE_DISABLED = PropertyAccess.isPropertyDefined("newt.test.Screen.disableScreenMode", true); } public static final int default_sm_bpp = 32; @@ -89,7 +90,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { private long tCreated; // creationTime - private static Class<?> getScreenClass(String type) throws ClassNotFoundException + private static Class<?> getScreenClass(final String type) throws ClassNotFoundException { final Class<?> screenClass = NewtFactory.getCustomClass(type, "ScreenDriver"); if(null==screenClass) { @@ -98,14 +99,14 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { return screenClass; } - public static Screen create(Display display, int idx) { + public static Screen create(final Display display, int idx) { try { if(!usrSizeQueried) { synchronized (Screen.class) { if(!usrSizeQueried) { usrSizeQueried = true; - final int w = Debug.getIntProperty("newt.ws.swidth", true, 0); - final int h = Debug.getIntProperty("newt.ws.sheight", true, 0); + final int w = PropertyAccess.getIntProperty("newt.ws.swidth", true, 0); + final int h = PropertyAccess.getIntProperty("newt.ws.sheight", true, 0); if(w>0 && h>0) { usrSize = new Dimension(w, h); System.err.println("User screen size "+usrSize); @@ -114,12 +115,12 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } } synchronized(screenList) { - Class<?> screenClass = getScreenClass(display.getType()); + final Class<?> screenClass = getScreenClass(display.getType()); ScreenImpl screen = (ScreenImpl) screenClass.newInstance(); screen.display = (DisplayImpl) display; idx = screen.validateScreenIndex(idx); { - Screen screen0 = ScreenImpl.getLastScreenOf(display, idx, -1); + final Screen screen0 = Screen.getLastScreenOf(display, idx, -1); if(null != screen0) { if(DEBUG) { System.err.println("Screen.create() REUSE: "+screen0+" "+Display.getThreadName()); @@ -138,7 +139,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } return screen; } - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } @@ -152,7 +153,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -181,7 +182,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if(null == aScreen) { if(DEBUG) { tCreated = System.nanoTime(); - System.err.println("Screen.createNative() START ("+DisplayImpl.getThreadName()+", "+this+")"); + System.err.println("Screen.createNative() START ("+Display.getThreadName()+", "+this+")"); } else { tCreated = 0; } @@ -196,7 +197,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { synchronized(screenList) { screensActive++; if(DEBUG) { - System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), active "+screensActive+", total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); + System.err.println("Screen.createNative() END ("+Display.getThreadName()+", "+this+"), active "+screensActive+", total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); } } ScreenMonitorState.getScreenMonitorState(this.getFQName()).addListener(this); @@ -210,7 +211,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { screensActive--; } if(DEBUG) { - System.err.println("Screen.destroy() ("+DisplayImpl.getThreadName()+"): active "+screensActive); + System.err.println("Screen.destroy() ("+Display.getThreadName()+"): active "+screensActive); // Thread.dumpStack(); } } @@ -227,7 +228,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { @Override public synchronized final int addReference() throws NativeWindowException { if(DEBUG) { - System.err.println("Screen.addReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount+1)); + System.err.println("Screen.addReference() ("+Display.getThreadName()+"): "+refCount+" -> "+(refCount+1)); // Thread.dumpStack(); } if ( 0 == refCount ) { @@ -241,7 +242,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { @Override public synchronized final int removeReference() { if(DEBUG) { - System.err.println("Screen.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1)); + System.err.println("Screen.removeReference() ("+Display.getThreadName()+"): "+refCount+" -> "+(refCount-1)); // Thread.dumpStack(); } refCount--; // could become < 0, in case of manual destruction without actual creation/addReference @@ -404,7 +405,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { return null != sms ? sms.getMonitorDevices().getData() : null; } - final ScreenMonitorState getScreenMonitorStatus(boolean throwException) { + final ScreenMonitorState getScreenMonitorStatus(final boolean throwException) { final String key = this.getFQName(); final ScreenMonitorState res = ScreenMonitorState.getScreenMonitorState(key); if(null == res & throwException) { @@ -414,7 +415,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } @Override - public void monitorModeChangeNotify(MonitorEvent me) { + public void monitorModeChangeNotify(final MonitorEvent me) { if(DEBUG) { System.err.println("monitorModeChangeNotify @ "+Thread.currentThread().getName()+": "+me); } @@ -435,7 +436,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } @Override - public void monitorModeChanged(MonitorEvent me, boolean success) { + public void monitorModeChanged(final MonitorEvent me, final boolean success) { if(success) { updateNativeMonitorDevicesViewport(); updateVirtualScreenOriginAndSize(); @@ -449,12 +450,12 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } @Override - public synchronized final void addMonitorModeListener(MonitorModeListener sml) { + public synchronized final void addMonitorModeListener(final MonitorModeListener sml) { refMonitorModeListener.add(sml); } @Override - public synchronized final void removeMonitorModeListener(MonitorModeListener sml) { + public synchronized final void removeMonitorModeListener(final MonitorModeListener sml) { refMonitorModeListener.remove(sml); } @@ -464,7 +465,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { * @param modeId * @return */ - private final MonitorMode getVirtualMonitorMode(MonitorModeProps.Cache cache, int modeId) { + private final MonitorMode getVirtualMonitorMode(final MonitorModeProps.Cache cache, final int modeId) { final int[] props = new int[MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; @@ -488,7 +489,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { * @param currentMode * @return */ - private final MonitorDevice getVirtualMonitorDevice(MonitorModeProps.Cache cache, int monitorId, MonitorMode currentMode) { + private final MonitorDevice getVirtualMonitorDevice(final MonitorModeProps.Cache cache, final int monitorId, final MonitorMode currentMode) { final int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES]; int i = 0; props[i++] = MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES; @@ -516,7 +517,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { * Utilizes {@link #getCurrentMonitorModeImpl()}, if the latter returns null it uses * the current screen size and dummy values. */ - protected final MonitorMode queryCurrentMonitorModeIntern(MonitorDevice monitor) { + protected final MonitorMode queryCurrentMonitorModeIntern(final MonitorDevice monitor) { MonitorMode res; if(DEBUG_TEST_SCREENMODE_DISABLED) { res = null; @@ -536,7 +537,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { long t0; if(DEBUG) { t0 = System.nanoTime(); - System.err.println("Screen.initMonitorState() START ("+DisplayImpl.getThreadName()+", "+this+")"); + System.err.println("Screen.initMonitorState() START ("+Display.getThreadName()+", "+this+")"); } else { t0 = 0; } @@ -558,20 +559,20 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } // Sort MonitorModes (all and per device) in descending order - default! MonitorModeUtil.sort(cache.monitorModes.getData(), false ); // descending order - for(Iterator<MonitorDevice> iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); ) { + for(final Iterator<MonitorDevice> iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); ) { MonitorModeUtil.sort(iMonitor.next().getSupportedModes(), false ); // descending order } if(DEBUG) { int i=0; - for(Iterator<MonitorMode> iMode=cache.monitorModes.iterator(); iMode.hasNext(); i++) { + for(final Iterator<MonitorMode> iMode=cache.monitorModes.iterator(); iMode.hasNext(); i++) { System.err.println("All["+i+"]: "+iMode.next()); } i=0; - for(Iterator<MonitorDevice> iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); i++) { + for(final Iterator<MonitorDevice> iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); i++) { final MonitorDevice crt = iMonitor.next(); System.err.println("["+i+"]: "+crt); int j=0; - for(Iterator<MonitorMode> iMode=crt.getSupportedModes().iterator(); iMode.hasNext(); j++) { + for(final Iterator<MonitorMode> iMode=crt.getSupportedModes().iterator(); iMode.hasNext(); j++) { System.err.println("["+i+"]["+j+"]: "+iMode.next()); } } @@ -598,7 +599,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { * Collects {@link MonitorDevice}s and {@link MonitorMode}s within the given cache. * </p> */ - private final int collectNativeMonitorModes(MonitorModeProps.Cache cache) { + private final int collectNativeMonitorModes(final MonitorModeProps.Cache cache) { if(!DEBUG_TEST_SCREENMODE_DISABLED) { collectNativeMonitorModesAndDevicesImpl(cache); } @@ -646,7 +647,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("Screen.destroy(): Reset "+monitor); try { monitor.setCurrentMode(monitor.getOriginalMode()); - } catch (Throwable t) { + } catch (final Throwable t) { // be verbose but continue t.printStackTrace(); } @@ -664,7 +665,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } private final void shutdown() { - ScreenMonitorState sms = ScreenMonitorState.getScreenMonitorStateUnlocked(getFQName()); + final ScreenMonitorState sms = ScreenMonitorState.getScreenMonitorStateUnlocked(getFQName()); if(null != sms) { final ArrayList<MonitorDevice> monitorDevices = sms.getMonitorDevices().getData(); for(int i=0; i<monitorDevices.size(); i++) { @@ -673,7 +674,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("Screen.shutdown(): Reset "+monitor); try { monitor.setCurrentMode(monitor.getOriginalMode()); - } catch (Throwable t) { + } catch (final Throwable t) { // be quiet .. shutdown } } diff --git a/src/newt/classes/jogamp/newt/ScreenMonitorState.java b/src/newt/classes/jogamp/newt/ScreenMonitorState.java index 01e6cfee9..ae982414b 100644 --- a/src/newt/classes/jogamp/newt/ScreenMonitorState.java +++ b/src/newt/classes/jogamp/newt/ScreenMonitorState.java @@ -46,15 +46,15 @@ public class ScreenMonitorState { private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final ArrayHashSet<MonitorDevice> allMonitors; private final ArrayHashSet<MonitorMode> allMonitorModes; - private ArrayList<MonitorModeListener> listener = new ArrayList<MonitorModeListener>(); + private final ArrayList<MonitorModeListener> listener = new ArrayList<MonitorModeListener>(); private static HashMap<String, ScreenMonitorState> screenFQN2ScreenMonitorState = new HashMap<String, ScreenMonitorState>(); private static RecursiveLock screen2ScreenMonitorState = LockFactory.createRecursiveLock(); - protected static void mapScreenMonitorState(String screenFQN, ScreenMonitorState sms) { + protected static void mapScreenMonitorState(final String screenFQN, final ScreenMonitorState sms) { screen2ScreenMonitorState.lock(); try { - ScreenMonitorState _sms = screenFQN2ScreenMonitorState.get(screenFQN); + final ScreenMonitorState _sms = screenFQN2ScreenMonitorState.get(screenFQN); if( null != _sms ) { throw new RuntimeException("ScreenMonitorState "+_sms+" already mapped to "+screenFQN); } @@ -71,7 +71,7 @@ public class ScreenMonitorState { * @param screen the prev user * @return true if mapping is empty, ie no more usage of the mapped ScreenMonitorState */ - protected static void unmapScreenMonitorState(String screenFQN) { + protected static void unmapScreenMonitorState(final String screenFQN) { screen2ScreenMonitorState.lock(); try { unmapScreenMonitorStateUnlocked(screenFQN); @@ -79,14 +79,14 @@ public class ScreenMonitorState { screen2ScreenMonitorState.unlock(); } } - protected static void unmapScreenMonitorStateUnlocked(String screenFQN) { - ScreenMonitorState sms = screenFQN2ScreenMonitorState.remove(screenFQN); + protected static void unmapScreenMonitorStateUnlocked(final String screenFQN) { + final ScreenMonitorState sms = screenFQN2ScreenMonitorState.remove(screenFQN); if(DEBUG) { System.err.println("ScreenMonitorState.unmap "+screenFQN+" -> "+sms); } } - protected static ScreenMonitorState getScreenMonitorState(String screenFQN) { + protected static ScreenMonitorState getScreenMonitorState(final String screenFQN) { screen2ScreenMonitorState.lock(); try { return getScreenMonitorStateUnlocked(screenFQN); @@ -94,7 +94,7 @@ public class ScreenMonitorState { screen2ScreenMonitorState.unlock(); } } - protected static ScreenMonitorState getScreenMonitorStateUnlocked(String screenFQN) { + protected static ScreenMonitorState getScreenMonitorStateUnlocked(final String screenFQN) { return screenFQN2ScreenMonitorState.get(screenFQN); } @@ -106,8 +106,8 @@ public class ScreenMonitorState { screen2ScreenMonitorState.unlock(); } - public ScreenMonitorState(ArrayHashSet<MonitorDevice> allMonitors, - ArrayHashSet<MonitorMode> allMonitorModes) { + public ScreenMonitorState(final ArrayHashSet<MonitorDevice> allMonitors, + final ArrayHashSet<MonitorMode> allMonitorModes) { this.allMonitors = allMonitors; this.allMonitorModes = allMonitorModes; } @@ -120,7 +120,7 @@ public class ScreenMonitorState { return allMonitorModes; } - protected final int addListener(MonitorModeListener l) { + protected final int addListener(final MonitorModeListener l) { lock(); try { listener.add(l); @@ -133,7 +133,7 @@ public class ScreenMonitorState { } } - protected final int removeListener(MonitorModeListener l) { + protected final int removeListener(final MonitorModeListener l) { lock(); try { if(!listener.remove(l)) { @@ -148,18 +148,18 @@ public class ScreenMonitorState { } } - protected final MonitorDevice getMonitor(MonitorDevice monitor) { + protected final MonitorDevice getMonitor(final MonitorDevice monitor) { return allMonitors.get(monitor); } - protected final void validateMonitor(MonitorDevice monitor) { + protected final void validateMonitor(final MonitorDevice monitor) { final MonitorDevice md = allMonitors.get(monitor); if( null == md ) { throw new InternalError("Monitor unknown: "+monitor); } } - protected final void fireMonitorModeChangeNotify(MonitorDevice monitor, MonitorMode desiredMode) { + protected final void fireMonitorModeChangeNotify(final MonitorDevice monitor, final MonitorMode desiredMode) { lock(); try { validateMonitor(monitor); @@ -172,7 +172,7 @@ public class ScreenMonitorState { } } - protected void fireMonitorModeChanged(MonitorDevice monitor, MonitorMode currentMode, boolean success) { + protected void fireMonitorModeChanged(final MonitorDevice monitor, final MonitorMode currentMode, final boolean success) { lock(); try { validateMonitor(monitor); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 61fa7af6b..29a0b1e21 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -65,6 +65,7 @@ import jogamp.nativewindow.SurfaceUpdatedHelper; import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.IntBitfield; +import com.jogamp.common.util.PropertyAccess; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; @@ -96,7 +97,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer static { Debug.initSingleton(); - DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true); + DEBUG_TEST_REPARENT_INCOMPATIBLE = PropertyAccess.isPropertyDefined("newt.test.Window.reparent.incompatible", true); ScreenImpl.initSingleton(); } @@ -120,7 +121,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } - private static void addWindow2List(WindowImpl window) { + private static void addWindow2List(final WindowImpl window) { synchronized(windowList) { // GC before add int i=0, gced=0; @@ -242,7 +243,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final Point[] movePositions = new Point[] { new Point(), new Point(), new Point(), new Point(), new Point(), new Point(), new Point(), new Point() }; - final Point getMovePosition(int id) { + final Point getMovePosition(final int id) { if( 0 <= id && id < movePositions.length ) { return movePositions[id]; } @@ -271,7 +272,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Construction Methods // - private static Class<?> getWindowClass(String type) + private static Class<?> getWindowClass(final String type) throws ClassNotFoundException { final Class<?> windowClass = NewtFactory.getCustomClass(type, "WindowDriver"); @@ -281,7 +282,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return windowClass; } - public static WindowImpl create(NativeWindow parentWindow, long parentWindowHandle, Screen screen, CapabilitiesImmutable caps) { + public static WindowImpl create(final NativeWindow parentWindow, final long parentWindowHandle, final Screen screen, final CapabilitiesImmutable caps) { try { Class<?> windowClass; if(caps.isOnscreen()) { @@ -289,7 +290,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else { windowClass = OffscreenWindow.class; } - WindowImpl window = (WindowImpl) windowClass.newInstance(); + final WindowImpl window = (WindowImpl) windowClass.newInstance(); window.parentWindow = parentWindow; window.parentWindowHandle = parentWindowHandle; window.screen = (ScreenImpl) screen; @@ -297,30 +298,30 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer window.instantiationFinished(); addWindow2List(window); return window; - } catch (Throwable t) { + } catch (final Throwable t) { t.printStackTrace(); throw new NativeWindowException(t); } } - public static WindowImpl create(Object[] cstrArguments, Screen screen, CapabilitiesImmutable caps) { + public static WindowImpl create(final Object[] cstrArguments, final Screen screen, final CapabilitiesImmutable caps) { try { - Class<?> windowClass = getWindowClass(screen.getDisplay().getType()); - Class<?>[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass); + final Class<?> windowClass = getWindowClass(screen.getDisplay().getType()); + final Class<?>[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass); if(null==cstrArgumentTypes) { throw new NativeWindowException("WindowClass "+windowClass+" doesn't support custom arguments in constructor"); } - int argsChecked = verifyConstructorArgumentTypes(cstrArgumentTypes, cstrArguments); + final int argsChecked = verifyConstructorArgumentTypes(cstrArgumentTypes, cstrArguments); if ( argsChecked < cstrArguments.length ) { throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments)); } - WindowImpl window = (WindowImpl) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ; + final WindowImpl window = (WindowImpl) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ; window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); window.instantiationFinished(); addWindow2List(window); return window; - } catch (Throwable t) { + } catch (final Throwable t) { throw new NativeWindowException(t); } } @@ -339,7 +340,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer parentWindowHandle = 0; } - protected final void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg) { + protected final void setGraphicsConfiguration(final AbstractGraphicsConfiguration cfg) { config = cfg; } @@ -507,7 +508,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return true; } - private static long getNativeWindowHandle(NativeWindow nativeWindow) { + private static long getNativeWindowHandle(final NativeWindow nativeWindow) { long handle = 0; if(null!=nativeWindow) { boolean wasLocked = false; @@ -518,7 +519,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(0==handle) { throw new NativeWindowException("Parent native window handle is NULL, after succesful locking: "+nativeWindow); } - } catch (NativeWindowException nwe) { + } catch (final NativeWindowException nwe) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.getNativeWindowHandle: not successful yet: "+nwe); } @@ -556,9 +557,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { + public final WindowClosingMode setDefaultCloseOperation(final WindowClosingMode op) { synchronized (closingListenerLock) { - WindowClosingMode _op = defaultCloseOperation; + final WindowClosingMode _op = defaultCloseOperation; defaultCloseOperation = op; return _op; } @@ -656,18 +657,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * Default is all but {@link #FLAG_IS_FULLSCREEN_SPAN} * </p> */ - protected boolean isReconfigureFlagSupported(int changeFlags) { + protected boolean isReconfigureFlagSupported(final int changeFlags) { return 0 == ( changeFlags & FLAG_IS_FULLSCREEN_SPAN ); } - protected int getReconfigureFlags(int changeFlags, boolean visible) { + protected int getReconfigureFlags(int changeFlags, final boolean visible) { return changeFlags |= ( ( 0 != getParentWindowHandle() ) ? FLAG_HAS_PARENT : 0 ) | ( isUndecorated() ? FLAG_IS_UNDECORATED : 0 ) | ( isFullscreen() ? FLAG_IS_FULLSCREEN : 0 ) | ( isAlwaysOnTop() ? FLAG_IS_ALWAYSONTOP : 0 ) | ( visible ? FLAG_IS_VISIBLE : 0 ) ; } - protected static String getReconfigureFlagsAsString(StringBuilder sb, int flags) { + protected static String getReconfigureFlagsAsString(StringBuilder sb, final int flags) { if(null == sb) { sb = new StringBuilder(); } sb.append("["); @@ -711,7 +712,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return sb.toString(); } - protected void setTitleImpl(String title) {} + protected void setTitleImpl(final String title) {} /** * Translates the given window client-area coordinates with top-left origin @@ -738,9 +739,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ protected abstract void updateInsetsImpl(Insets insets); - protected boolean setPointerVisibleImpl(boolean pointerVisible) { return false; } - protected boolean confinePointerImpl(boolean confine) { return false; } - protected void warpPointerImpl(int x, int y) { } + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { return false; } + protected boolean confinePointerImpl(final boolean confine) { return false; } + protected void warpPointerImpl(final int x, final int y) { } protected void setPointerIconImpl(final PointerIconImpl pi) { } //---------------------------------------------------------------------- @@ -819,22 +820,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { + public final void addSurfaceUpdatedListener(final SurfaceUpdatedListener l) { surfaceUpdatedHelper.addSurfaceUpdatedListener(l); } @Override - public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { + public final void addSurfaceUpdatedListener(final int index, final SurfaceUpdatedListener l) throws IndexOutOfBoundsException { surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); } @Override - public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { + public final void removeSurfaceUpdatedListener(final SurfaceUpdatedListener l) { surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); } @Override - public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { + public final void surfaceUpdated(final Object updater, final NativeSurface ns, final long when) { surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); } @@ -919,7 +920,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return screen; } - protected void setScreen(ScreenImpl newScreen) { // never null ! + protected void setScreen(final ScreenImpl newScreen) { // never null ! removeScreenReference(); screen = newScreen; } @@ -936,10 +937,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param width client-area size in window units, or <=0 if unchanged * @param height client-area size in window units, or <=0 if unchanged */ - protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) { + protected final void setVisibleImpl(final boolean visible, final int x, final int y, final int width, final int height) { reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible)); } - final void setVisibleActionImpl(boolean visible) { + final void setVisibleActionImpl(final boolean visible) { boolean nativeWindowCreated = false; boolean madeVisible = false; @@ -949,7 +950,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!visible && null!=childWindows && childWindows.size()>0) { synchronized(childWindowsLock) { for(int i = 0; i < childWindows.size(); i++ ) { - NativeWindow nw = childWindows.get(i); + final NativeWindow nw = childWindows.get(i); if(nw instanceof WindowImpl) { ((WindowImpl)nw).setVisible(false); } @@ -980,7 +981,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(isNativeValid() && visible && null!=childWindows && childWindows.size()>0) { synchronized(childWindowsLock) { for(int i = 0; i < childWindows.size(); i++ ) { - NativeWindow nw = childWindows.get(i); + final NativeWindow nw = childWindows.get(i); if(nw instanceof WindowImpl) { ((WindowImpl)nw).setVisible(true); } @@ -1003,7 +1004,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class VisibleAction implements Runnable { boolean visible; - private VisibleAction(boolean visible) { + private VisibleAction(final boolean visible) { this.visible = visible; } @@ -1014,7 +1015,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void setVisible(boolean wait, boolean visible) { + public final void setVisible(final boolean wait, final boolean visible) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); } @@ -1022,7 +1023,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void setVisible(boolean visible) { + public final void setVisible(final boolean visible) { setVisible(true, visible); } @@ -1030,7 +1031,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int width, height; boolean force; - private SetSizeAction(int w, int h, boolean disregardFS) { + private SetSizeAction(final int w, final int h, final boolean disregardFS) { this.width = w; this.height = h; this.force = disregardFS; @@ -1118,9 +1119,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(childWindows.size()>0) { // avoid ConcurrentModificationException: parent -> child -> parent.removeChild(this) @SuppressWarnings("unchecked") + final ArrayList<NativeWindow> clonedChildWindows = (ArrayList<NativeWindow>) childWindows.clone(); while( clonedChildWindows.size() > 0 ) { - NativeWindow nw = clonedChildWindows.remove(0); + final NativeWindow nw = clonedChildWindows.remove(0); if(nw instanceof WindowImpl) { ((WindowImpl)nw).windowDestroyNotify(true); } else { @@ -1145,7 +1147,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setGraphicsConfiguration(null); } removeScreenReference(); - Display dpy = screen.getDisplay(); + final Display dpy = screen.getDisplay(); if(null != dpy) { dpy.validateEDTStopped(); } @@ -1200,7 +1202,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer runOnEDTIfAvail(true, destroyAction); } - protected void destroy(boolean preserveResources) { + protected void destroy(final boolean preserveResources) { if( null != lifecycleHook ) { lifecycleHook.preserveGLStateAtDestroy( preserveResources ); } @@ -1212,7 +1214,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param pWin parent window, may be null * @return true if at least one of both window's configurations is offscreen */ - protected static boolean isOffscreenInstance(NativeWindow cWin, NativeWindow pWin) { + protected static boolean isOffscreenInstance(final NativeWindow cWin, final NativeWindow pWin) { boolean ofs = false; final AbstractGraphicsConfiguration cWinCfg = cWin.getGraphicsConfiguration(); if( null != cWinCfg ) { @@ -1233,7 +1235,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final int hints; ReparentOperation operation; - private ReparentAction(NativeWindow newParentWindow, int topLevelX, int topLevelY, int hints) { + private ReparentAction(final NativeWindow newParentWindow, final int topLevelX, final int topLevelY, int hints) { this.newParentWindow = newParentWindow; this.topLevelX = topLevelX; this.topLevelY = topLevelY; @@ -1452,7 +1454,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.waitForVisible(false, false); // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, // even though we do exactly that (KDE+Composite) - try { Thread.sleep(100); } catch (InterruptedException e) { } + try { Thread.sleep(100); } catch (final InterruptedException e) { } display.dispatchMessagesNative(); // status up2date } @@ -1587,15 +1589,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } }; @Override - public final ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints) { + public final ReparentOperation reparentWindow(final NativeWindow newParent, final int x, final int y, final int hints) { final ReparentAction reparentAction = new ReparentAction(newParent, x, y, hints); runOnEDTIfAvail(true, reparentAction); return reparentAction.getOp(); } @Override - public final CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser) { - CapabilitiesChooser old = this.capabilitiesChooser; + public final CapabilitiesChooser setCapabilitiesChooser(final CapabilitiesChooser chooser) { + final CapabilitiesChooser old = this.capabilitiesChooser; this.capabilitiesChooser = chooser; return old; } @@ -1613,7 +1615,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class DecorationAction implements Runnable { boolean undecorated; - private DecorationAction(boolean undecorated) { + private DecorationAction(final boolean undecorated) { this.undecorated = undecorated; } @@ -1633,7 +1635,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final int width = getWidth(); final int height = getHeight(); - DisplayImpl display = (DisplayImpl) screen.getDisplay(); + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_DECORATION, isVisible())); display.dispatchMessagesNative(); // status up2date @@ -1647,7 +1649,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void setUndecorated(boolean value) { + public final void setUndecorated(final boolean value) { runOnEDTIfAvail(true, new DecorationAction(value)); } @@ -1659,7 +1661,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class AlwaysOnTopAction implements Runnable { boolean alwaysOnTop; - private AlwaysOnTopAction(boolean alwaysOnTop) { + private AlwaysOnTopAction(final boolean alwaysOnTop) { this.alwaysOnTop = alwaysOnTop; } @@ -1679,7 +1681,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final int width = getWidth(); final int height = getHeight(); - DisplayImpl display = (DisplayImpl) screen.getDisplay(); + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); display.dispatchMessagesNative(); // status up2date @@ -1693,7 +1695,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void setAlwaysOnTop(boolean value) { + public final void setAlwaysOnTop(final boolean value) { if( isFullscreen() ) { nfs_alwaysOnTop = value; } else { @@ -1738,7 +1740,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } private boolean setPointerVisibleIntern(final boolean pointerVisible) { - boolean res = setOffscreenPointerVisible(pointerVisible, pointerIcon); + final boolean res = setOffscreenPointerVisible(pointerVisible, pointerIcon); return setPointerVisibleImpl(pointerVisible) || res; // accept onscreen or offscreen positive result! } /** @@ -1768,7 +1770,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final OffscreenLayerSurface ols = (OffscreenLayerSurface) parent; try { return ols.hideCursor(); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -1824,7 +1826,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else { return ols.setCursor(null, null); // default } - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -1836,7 +1838,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return pointerConfined; } @Override - public final void confinePointer(boolean confine) { + public final void confinePointer(final boolean confine) { if(this.pointerConfined != confine) { boolean setVal = 0 == getWindowHandle(); if(!setVal) { @@ -1850,7 +1852,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // this allows user listener to sync previous position value to the new centered position try { Thread.sleep(3 * screen.getDisplay().getEDTUtil().getPollPeriod()); - } catch (InterruptedException e) { } + } catch (final InterruptedException e) { } } } if(setVal) { @@ -1860,7 +1862,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void warpPointer(int x, int y) { + public final void warpPointer(final int x, final int y) { if(0 != getWindowHandle()) { warpPointerImpl(x, y); } @@ -1976,7 +1978,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected final boolean autoPosition() { return autoPosition; } /** Sets the position fields {@link #x} and {@link #y} in window units to the given values and {@link #autoPosition} to false. */ - protected final void definePosition(int x, int y) { + protected final void definePosition(final int x, final int y) { if(DEBUG_IMPLEMENTATION) { System.err.println("definePosition: "+this.x+"/"+this.y+" -> "+x+"/"+y); // Thread.dumpStack(); @@ -1989,7 +1991,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * Sets the size fields {@link #winWidth} and {@link #winHeight} in window units to the given values * and {@link #pixWidth} and {@link #pixHeight} in pixel units according to {@link #convertToPixelUnits(int[])}. */ - protected final void defineSize(int winWidth, int winHeight) { + protected final void defineSize(final int winWidth, final int winHeight) { final int pixWidth = winWidth * getPixelScaleX(); // FIXME HiDPI: Shortcut, may need to adjust if we change scaling methodology final int pixHeight = winHeight * getPixelScaleY(); if(DEBUG_IMPLEMENTATION) { @@ -2036,8 +2038,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return lifecycleHook; } - public final LifecycleHook setLifecycleHook(LifecycleHook hook) { - LifecycleHook old = lifecycleHook; + public final LifecycleHook setLifecycleHook(final LifecycleHook hook) { + final LifecycleHook old = lifecycleHook; lifecycleHook = hook; return old; } @@ -2051,7 +2053,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void setWindowDestroyNotifyAction(Runnable r) { + public final void setWindowDestroyNotifyAction(final Runnable r) { windowDestroyNotifyAction = r; } @@ -2061,7 +2063,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final String toString() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()+"[Config "+config+ ",\n "+screen+ @@ -2100,12 +2102,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return sb.toString(); } - protected final void setWindowHandle(long handle) { + protected final void setWindowHandle(final long handle) { windowHandle = handle; } @Override - public final void runOnEDTIfAvail(boolean wait, final Runnable task) { + public final void runOnEDTIfAvail(final boolean wait, final Runnable task) { if( windowLock.isOwner( Thread.currentThread() ) ) { task.run(); } else { @@ -2143,11 +2145,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void requestFocus(boolean wait) { + public final void requestFocus(final boolean wait) { requestFocus(wait /* wait */, false /* skipFocusAction */, brokenFocusChange /* force */); } - private void requestFocus(boolean wait, boolean skipFocusAction, boolean force) { + private void requestFocus(final boolean wait, final boolean skipFocusAction, final boolean force) { if( isNativeValid() && ( force || !hasFocus() ) && ( skipFocusAction || !focusAction() ) ) { @@ -2156,7 +2158,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Internally forcing request focus on current thread */ - private void requestFocusInt(boolean skipFocusAction) { + private void requestFocusInt(final boolean skipFocusAction) { if( skipFocusAction || !focusAction() ) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.RequestFocusInt: forcing - ("+getThreadName()+"): skipFocusAction "+skipFocusAction+", focus "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); @@ -2166,7 +2168,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void setFocusAction(FocusRunnable focusAction) { + public final void setFocusAction(final FocusRunnable focusAction) { this.focusAction = focusAction; } @@ -2186,19 +2188,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return res; } - protected final void setBrokenFocusChange(boolean v) { + protected final void setBrokenFocusChange(final boolean v) { brokenFocusChange = v; } @Override - public final void setKeyboardFocusHandler(KeyListener l) { + public final void setKeyboardFocusHandler(final KeyListener l) { keyboardFocusHandler = l; } private class SetPositionAction implements Runnable { int x, y; - private SetPositionAction(int x, int y) { + private SetPositionAction(final int x, final int y) { this.x = x; this.y = y; } @@ -2231,20 +2233,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void setPosition(int x, int y) { + public void setPosition(final int x, final int y) { autoPosition = false; runOnEDTIfAvail(true, new SetPositionAction(x, y)); } @Override - public final void setTopLevelPosition(int x, int y) { + public final void setTopLevelPosition(final int x, final int y) { setPosition(x + getInsets().getLeftWidth(), y + getInsets().getTopHeight()); } private class FullScreenAction implements Runnable { boolean _fullscreen; - private boolean init(boolean fullscreen) { + private boolean init(final boolean fullscreen) { if(isNativeValid()) { this._fullscreen = fullscreen; return isFullscreen() != fullscreen; @@ -2349,7 +2351,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( tempInvisible ) { setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); WindowImpl.this.waitForVisible(false, false); - try { Thread.sleep(100); } catch (InterruptedException e) { } + try { Thread.sleep(100); } catch (final InterruptedException e) { } display.dispatchMessagesNative(); // status up2date } @@ -2387,7 +2389,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(wasVisible) { if( NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { // Give sluggy WM's (e.g. Unity) a chance to properly restore window .. - try { Thread.sleep(100); } catch (InterruptedException e) { } + try { Thread.sleep(100); } catch (final InterruptedException e) { } display.dispatchMessagesNative(); // status up2date } setVisibleImpl(true, x, y, w, h); @@ -2417,16 +2419,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private final FullScreenAction fullScreenAction = new FullScreenAction(); @Override - public boolean setFullscreen(boolean fullscreen) { + public boolean setFullscreen(final boolean fullscreen) { return setFullscreenImpl(fullscreen, true, null); } @Override - public boolean setFullscreen(List<MonitorDevice> monitors) { + public boolean setFullscreen(final List<MonitorDevice> monitors) { return setFullscreenImpl(true, false, monitors); } - private boolean setFullscreenImpl(boolean fullscreen, boolean useMainMonitor, List<MonitorDevice> monitors) { + private boolean setFullscreenImpl(final boolean fullscreen, final boolean useMainMonitor, final List<MonitorDevice> monitors) { synchronized(fullScreenAction) { fullscreenMonitors = monitors; fullscreenUseMainMonitor = useMainMonitor; @@ -2454,7 +2456,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Notify WindowDriver about the finished monitor mode change. */ - protected void monitorModeChanged(MonitorEvent me, boolean success) { + protected void monitorModeChanged(final MonitorEvent me, final boolean success) { } private class MonitorModeListenerImpl implements MonitorModeListener { @@ -2466,7 +2468,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer boolean _fullscreenUseMainMonitor = true; @Override - public void monitorModeChangeNotify(MonitorEvent me) { + public void monitorModeChangeNotify(final MonitorEvent me) { hadFocus = hasFocus(); final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(true); final boolean quirkFSPause = fullscreen && isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN); @@ -2496,7 +2498,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void monitorModeChanged(MonitorEvent me, boolean success) { + public void monitorModeChanged(final MonitorEvent me, final boolean success) { if(!animatorPaused && success && null!=lifecycleHook) { // Didn't pass above notify method. probably detected screen change after it happened. animatorPaused = lifecycleHook.pauseRenderingAction(); @@ -2572,14 +2574,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // @Override - public final boolean removeChild(NativeWindow win) { + public final boolean removeChild(final NativeWindow win) { synchronized(childWindowsLock) { return childWindows.remove(win); } } @Override - public final boolean addChild(NativeWindow win) { + public final boolean addChild(final NativeWindow win) { if (win == null) { return false; } @@ -2591,7 +2593,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer //---------------------------------------------------------------------- // Generic Event Support // - private void doEvent(boolean enqueue, boolean wait, com.jogamp.newt.event.NEWTEvent event) { + private void doEvent(final boolean enqueue, boolean wait, final com.jogamp.newt.event.NEWTEvent event) { boolean done = false; if(!enqueue) { @@ -2605,14 +2607,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) { + public final void enqueueEvent(final boolean wait, final com.jogamp.newt.event.NEWTEvent event) { if(isNativeValid()) { ((DisplayImpl)screen.getDisplay()).enqueueEvent(wait, event); } } @Override - public final boolean consumeEvent(NEWTEvent e) { + public final boolean consumeEvent(final NEWTEvent e) { switch(e.getEventType()) { // special repaint treatment case WindowEvent.EVENT_WINDOW_REPAINT: @@ -2744,7 +2746,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final PointerType[] pTypes, final short eventType, final int modifiers, final int actionIdx, final boolean normalPNames, final int[] pNames, final int[] pX, final int[] pY, final float[] pPressure, - float maxPressure, final float[] rotationXYZ, final float rotationScale) { + final float maxPressure, final float[] rotationXYZ, final float rotationScale) { final int pCount = pNames.length; final short[] pIDs = new short[pCount]; for(int i=0; i<pCount; i++) { @@ -3044,7 +3046,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer doEvent(enqueue, wait, e); // actual mouse event } - private static int step(int lower, int edge, int value) { + private static int step(final int lower, final int edge, final int value) { return value < edge ? lower : value; } @@ -3274,16 +3276,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void addMouseListener(MouseListener l) { + public final void addMouseListener(final MouseListener l) { addMouseListener(-1, l); } @Override - public final void addMouseListener(int index, MouseListener l) { + public final void addMouseListener(int index, final MouseListener l) { if(l == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<MouseListener> clonedListeners = (ArrayList<MouseListener>) mouseListeners.clone(); if(0>index) { index = clonedListeners.size(); @@ -3293,11 +3296,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void removeMouseListener(MouseListener l) { + public final void removeMouseListener(final MouseListener l) { if (l == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<MouseListener> clonedListeners = (ArrayList<MouseListener>) mouseListeners.clone(); clonedListeners.remove(l); mouseListeners = clonedListeners; @@ -3306,6 +3310,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final MouseListener getMouseListener(int index) { @SuppressWarnings("unchecked") + final ArrayList<MouseListener> clonedListeners = (ArrayList<MouseListener>) mouseListeners.clone(); if(0>index) { index = clonedListeners.size()-1; @@ -3319,7 +3324,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void setDefaultGesturesEnabled(boolean enable) { + public final void setDefaultGesturesEnabled(final boolean enable) { defaultGestureHandlerEnabled = enable; } @Override @@ -3328,15 +3333,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void addGestureHandler(GestureHandler gh) { + public final void addGestureHandler(final GestureHandler gh) { addGestureHandler(-1, gh); } @Override - public final void addGestureHandler(int index, GestureHandler gh) { + public final void addGestureHandler(int index, final GestureHandler gh) { if(gh == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<GestureHandler> cloned = (ArrayList<GestureHandler>) pointerGestureHandler.clone(); if(0>index) { index = cloned.size(); @@ -3345,25 +3351,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pointerGestureHandler = cloned; } @Override - public final void removeGestureHandler(GestureHandler gh) { + public final void removeGestureHandler(final GestureHandler gh) { if (gh == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<GestureHandler> cloned = (ArrayList<GestureHandler>) pointerGestureHandler.clone(); cloned.remove(gh); pointerGestureHandler = cloned; } @Override - public final void addGestureListener(GestureHandler.GestureListener gl) { + public final void addGestureListener(final GestureHandler.GestureListener gl) { addGestureListener(-1, gl); } @Override - public final void addGestureListener(int index, GestureHandler.GestureListener gl) { + public final void addGestureListener(int index, final GestureHandler.GestureListener gl) { if(gl == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<GestureHandler.GestureListener> cloned = (ArrayList<GestureHandler.GestureListener>) gestureListeners.clone(); if(0>index) { index = cloned.size(); @@ -3372,17 +3380,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer gestureListeners = cloned; } @Override - public final void removeGestureListener(GestureHandler.GestureListener gl) { + public final void removeGestureListener(final GestureHandler.GestureListener gl) { if (gl == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<GestureHandler.GestureListener> cloned = (ArrayList<GestureHandler.GestureListener>) gestureListeners.clone(); cloned.remove(gl); gestureListeners= cloned; } - private final void dispatchMouseEvent(MouseEvent e) { + private final void dispatchMouseEvent(final MouseEvent e) { for(int i = 0; !e.isConsumed() && i < mouseListeners.size(); i++ ) { final MouseListener l = mouseListeners.get(i); switch(e.getEventType()) { @@ -3431,7 +3440,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param pressed true if pressed, otherwise false * @return the previus pressed value */ - protected final boolean setKeyPressed(short keyCode, boolean pressed) { + protected final boolean setKeyPressed(final short keyCode, final boolean pressed) { final int v = 0xFFFF & keyCode; if( v <= keyTrackingRange ) { return keyPressedState.put(v, pressed); @@ -3442,7 +3451,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param keyCode the keyCode to test pressed state * @return true if pressed, otherwise false */ - protected final boolean isKeyPressed(short keyCode) { + protected final boolean isKeyPressed(final short keyCode) { final int v = 0xFFFF & keyCode; if( v <= keyTrackingRange ) { return keyPressedState.get(v); @@ -3450,18 +3459,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return false; } - public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + public void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) { // Always add currently pressed mouse buttons to modifier mask consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState1.buttonPressedMask, keyCode, keySym, keyChar) ); } - public void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + public void enqueueKeyEvent(final boolean wait, final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) { // Always add currently pressed mouse buttons to modifier mask enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState1.buttonPressedMask, keyCode, keySym, keyChar) ); } @Override - public final void setKeyboardVisible(boolean visible) { + public final void setKeyboardVisible(final boolean visible) { if(isNativeValid()) { // We don't skip the impl. if it seems that there is no state change, // since we cannot assume the impl. reliably gives us it's current state. @@ -3485,11 +3494,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * hence even if an invisible operation failed, the keyboard is considered invisible! * </p> */ - protected boolean setKeyboardVisibleImpl(boolean visible) { + protected boolean setKeyboardVisibleImpl(final boolean visible) { return false; // nop } /** Triggered by implementation's WM events to update the virtual on-screen keyboard's visibility state. */ - protected void keyboardVisibilityChanged(boolean visible) { + protected void keyboardVisibilityChanged(final boolean visible) { if(keyboardVisible != visible) { if(DEBUG_IMPLEMENTATION || DEBUG_KEY_EVENT) { System.err.println("keyboardVisibilityChanged: "+keyboardVisible+" -> "+visible); @@ -3500,16 +3509,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected boolean keyboardVisible = false; @Override - public final void addKeyListener(KeyListener l) { + public final void addKeyListener(final KeyListener l) { addKeyListener(-1, l); } @Override - public final void addKeyListener(int index, KeyListener l) { + public final void addKeyListener(int index, final KeyListener l) { if(l == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<KeyListener> clonedListeners = (ArrayList<KeyListener>) keyListeners.clone(); if(0>index) { index = clonedListeners.size(); @@ -3519,11 +3529,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void removeKeyListener(KeyListener l) { + public final void removeKeyListener(final KeyListener l) { if (l == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<KeyListener> clonedListeners = (ArrayList<KeyListener>) keyListeners.clone(); clonedListeners.remove(l); keyListeners = clonedListeners; @@ -3532,6 +3543,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final KeyListener getKeyListener(int index) { @SuppressWarnings("unchecked") + final ArrayList<KeyListener> clonedListeners = (ArrayList<KeyListener>) keyListeners.clone(); if(0>index) { index = clonedListeners.size()-1; @@ -3544,7 +3556,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return keyListeners.toArray(new KeyListener[keyListeners.size()]); } - private final boolean propagateKeyEvent(KeyEvent e, KeyListener l) { + private final boolean propagateKeyEvent(final KeyEvent e, final KeyListener l) { switch(e.getEventType()) { case KeyEvent.EVENT_KEY_PRESSED: l.keyPressed(e); @@ -3558,7 +3570,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return e.isConsumed(); } - protected void consumeKeyEvent(KeyEvent e) { + protected void consumeKeyEvent(final KeyEvent e) { boolean consumedE = false; if( null != keyboardFocusHandler && !e.isAutoRepeat() ) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); @@ -3582,27 +3594,28 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // WindowListener/Event Support // @Override - public final void sendWindowEvent(int eventType) { + public final void sendWindowEvent(final int eventType) { consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); } - public final void enqueueWindowEvent(boolean wait, int eventType) { + public final void enqueueWindowEvent(final boolean wait, final int eventType) { enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); } @Override - public final void addWindowListener(WindowListener l) { + public final void addWindowListener(final WindowListener l) { addWindowListener(-1, l); } @Override - public final void addWindowListener(int index, WindowListener l) + public final void addWindowListener(int index, final WindowListener l) throws IndexOutOfBoundsException { if(l == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<WindowListener> clonedListeners = (ArrayList<WindowListener>) windowListeners.clone(); if(0>index) { index = clonedListeners.size(); @@ -3612,11 +3625,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void removeWindowListener(WindowListener l) { + public final void removeWindowListener(final WindowListener l) { if (l == null) { return; } @SuppressWarnings("unchecked") + final ArrayList<WindowListener> clonedListeners = (ArrayList<WindowListener>) windowListeners.clone(); clonedListeners.remove(l); windowListeners = clonedListeners; @@ -3625,6 +3639,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final WindowListener getWindowListener(int index) { @SuppressWarnings("unchecked") + final ArrayList<WindowListener> clonedListeners = (ArrayList<WindowListener>) windowListeners.clone(); if(0>index) { index = clonedListeners.size()-1; @@ -3637,13 +3652,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return windowListeners.toArray(new WindowListener[windowListeners.size()]); } - protected void consumeWindowEvent(WindowEvent e) { + protected void consumeWindowEvent(final WindowEvent e) { if(DEBUG_IMPLEMENTATION) { System.err.println("consumeWindowEvent: "+e+", visible "+isVisible()+" "+getX()+"/"+getY()+", win["+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+ "], pixel["+getSurfaceWidth()+"x"+getSurfaceHeight()+"]"); } for(int i = 0; !e.isConsumed() && i < windowListeners.size(); i++ ) { - WindowListener l = windowListeners.get(i); + final WindowListener l = windowListeners.get(i); switch(e.getEventType()) { case WindowEvent.EVENT_WINDOW_RESIZED: l.windowResized(e); @@ -3675,7 +3690,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Triggered by implementation's WM events to update the focus state. */ - protected void focusChanged(boolean defer, boolean focusGained) { + protected void focusChanged(final boolean defer, final boolean focusGained) { if(brokenFocusChange || hasFocus != focusGained) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.focusChanged: ("+getThreadName()+"): (defer: "+defer+") "+this.hasFocus+" -> "+focusGained+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); @@ -3691,7 +3706,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Triggered by implementation's WM events to update the visibility state. */ - protected final void visibleChanged(boolean defer, boolean visible) { + protected final void visibleChanged(final boolean defer, final boolean visible) { if(this.visible != visible) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.visibleChanged ("+getThreadName()+"): (defer: "+defer+") "+this.visible+" -> "+visible+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); @@ -3701,17 +3716,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Returns -1 if failed, otherwise remaining time until {@link #TIMEOUT_NATIVEWINDOW}, maybe zero. */ - private long waitForVisible(boolean visible, boolean failFast) { + private long waitForVisible(final boolean visible, final boolean failFast) { return waitForVisible(visible, failFast, TIMEOUT_NATIVEWINDOW); } /** Returns -1 if failed, otherwise remaining time until <code>timeOut</code>, maybe zero. */ - private long waitForVisible(boolean visible, boolean failFast, long timeOut) { + private long waitForVisible(final boolean visible, final boolean failFast, final long timeOut) { final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date long remaining; for(remaining = timeOut; 0<remaining && this.visible != visible; remaining-=10 ) { - try { Thread.sleep(10); } catch (InterruptedException ie) {} + try { Thread.sleep(10); } catch (final InterruptedException ie) {} display.dispatchMessagesNative(); // status up2date } if(this.visible != visible) { @@ -3731,7 +3746,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Triggered by implementation's WM events to update the client-area size in window units w/o insets/decorations. */ - protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { + protected void sizeChanged(final boolean defer, final int newWidth, final int newHeight, final boolean force) { if(force || getWidth() != newWidth || getHeight() != newHeight) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+ @@ -3752,12 +3767,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - private boolean waitForSize(int w, int h, boolean failFast, long timeOut) { + private boolean waitForSize(final int w, final int h, final boolean failFast, final long timeOut) { final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date long sleep; for(sleep = timeOut; 0<sleep && w!=getWidth() && h!=getHeight(); sleep-=10 ) { - try { Thread.sleep(10); } catch (InterruptedException ie) {} + try { Thread.sleep(10); } catch (final InterruptedException ie) {} display.dispatchMessagesNative(); // status up2date } if(0 >= sleep) { @@ -3775,7 +3790,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Triggered by implementation's WM events to update the position. */ - protected final void positionChanged(boolean defer, int newX, int newY) { + protected final void positionChanged(final boolean defer, final int newX, final int newY) { if ( getX() != newX || getY() != newY ) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.positionChanged: ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); @@ -3797,7 +3812,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * Since WM may not obey our positional request exactly, we allow a tolerance of 2 times insets[left/top], or 64 pixels, whatever is greater. * </p> */ - private boolean waitForPosition(boolean useCustomPosition, int x, int y, long timeOut) { + private boolean waitForPosition(final boolean useCustomPosition, final int x, final int y, final long timeOut) { final DisplayImpl display = (DisplayImpl) screen.getDisplay(); final int maxDX, maxDY; { @@ -3814,7 +3829,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ok = !autoPosition; } if( !ok ) { - try { Thread.sleep(10); } catch (InterruptedException ie) {} + try { Thread.sleep(10); } catch (final InterruptedException ie) {} display.dispatchMessagesNative(); // status up2date remaining-=10; } @@ -3838,7 +3853,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @see #getInsets() * @see #updateInsetsImpl(Insets) */ - protected void insetsChanged(boolean defer, int left, int right, int top, int bottom) { + protected void insetsChanged(final boolean defer, final int left, final int right, final int top, final int bottom) { if ( left >= 0 && right >= 0 && top >= 0 && bottom >= 0 ) { if( blockInsetsChange || isUndecorated() ) { if(DEBUG_IMPLEMENTATION) { @@ -3862,7 +3877,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * and hence force destruction. Otherwise is follows the user settings. * @return true if this window is no more valid and hence has been destroyed, otherwise false. */ - public final boolean windowDestroyNotify(boolean force) { + public final boolean windowDestroyNotify(final boolean force) { final WindowClosingMode defMode = getDefaultCloseOperation(); final WindowClosingMode mode = force ? WindowClosingMode.DISPOSE_ON_CLOSE : defMode; if(DEBUG_IMPLEMENTATION) { @@ -3906,7 +3921,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final void windowRepaint(int x, int y, int width, int height) { + public final void windowRepaint(final int x, final int y, final int width, final int height) { windowRepaint(false, x, y, width, height); } @@ -3918,7 +3933,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param width dirty-region width in pixel units * @param height dirty-region height in pixel units */ - protected final void windowRepaint(boolean defer, int x, int y, int width, int height) { + protected final void windowRepaint(final boolean defer, final int x, final int y, int width, int height) { width = ( 0 >= width ) ? getSurfaceWidth() : width; height = ( 0 >= height ) ? getSurfaceHeight() : height; if(DEBUG_IMPLEMENTATION) { @@ -3926,7 +3941,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(isNativeValid()) { - NEWTEvent e = new WindowUpdateEvent(WindowEvent.EVENT_WINDOW_REPAINT, this, System.currentTimeMillis(), + final NEWTEvent e = new WindowUpdateEvent(WindowEvent.EVENT_WINDOW_REPAINT, this, System.currentTimeMillis(), new Rectangle(x, y, width, height)); doEvent(defer, false, e); } @@ -3936,16 +3951,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Reflection helper .. // - private static Class<?>[] getCustomConstructorArgumentTypes(Class<?> windowClass) { + private static Class<?>[] getCustomConstructorArgumentTypes(final Class<?> windowClass) { Class<?>[] argTypes = null; try { - Method m = windowClass.getDeclaredMethod("getCustomConstructorArgumentTypes"); + final Method m = windowClass.getDeclaredMethod("getCustomConstructorArgumentTypes"); argTypes = (Class[]) m.invoke(null, (Object[])null); - } catch (Throwable t) {} + } catch (final Throwable t) {} return argTypes; } - private static int verifyConstructorArgumentTypes(Class<?>[] types, Object[] args) { + private static int verifyConstructorArgumentTypes(final Class<?>[] types, final Object[] args) { if(types.length != args.length) { return -1; } @@ -3957,8 +3972,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return args.length; } - private static String getArgsStrList(Object[] args) { - StringBuilder sb = new StringBuilder(); + private static String getArgsStrList(final Object[] args) { + final StringBuilder sb = new StringBuilder(); for(int i=0; i<args.length; i++) { sb.append(args[i].getClass()); if(i<args.length) { @@ -3968,8 +3983,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return sb.toString(); } - private static String getTypeStrList(Class<?>[] types) { - StringBuilder sb = new StringBuilder(); + private static String getTypeStrList(final Class<?>[] types) { + final StringBuilder sb = new StringBuilder(); for(int i=0; i<types.length; i++) { sb.append(types[i]); if(i<types.length) { @@ -3983,11 +3998,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return Display.getThreadName(); } - public static String toHexString(int hex) { + public static String toHexString(final int hex) { return Display.toHexString(hex); } - public static String toHexString(long hex) { + public static String toHexString(final long hex) { return Display.toHexString(hex); } } diff --git a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java index 2ba5b3460..682313ef4 100644 --- a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java +++ b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java @@ -55,7 +55,7 @@ public class NewtFactoryAWT extends NewtFactory { * * @param awtCompObject must be of type java.awt.Component */ - public static JAWTWindow getNativeWindow(Object awtCompObject, CapabilitiesImmutable capsRequested) { + public static JAWTWindow getNativeWindow(final Object awtCompObject, final CapabilitiesImmutable capsRequested) { if(null==awtCompObject) { throw new NativeWindowException("Null AWT Component"); } @@ -65,9 +65,9 @@ public class NewtFactoryAWT extends NewtFactory { return getNativeWindow( (java.awt.Component) awtCompObject, capsRequested ); } - public static JAWTWindow getNativeWindow(java.awt.Component awtComp, CapabilitiesImmutable capsRequested) { - AWTGraphicsConfiguration config = AWTGraphicsConfiguration.create(awtComp, null, capsRequested); - NativeWindow nw = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow + public static JAWTWindow getNativeWindow(final java.awt.Component awtComp, final CapabilitiesImmutable capsRequested) { + final AWTGraphicsConfiguration config = AWTGraphicsConfiguration.create(awtComp, null, capsRequested); + final NativeWindow nw = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow if(! ( nw instanceof JAWTWindow ) ) { throw new NativeWindowException("Not an AWT NativeWindow: "+nw); } @@ -77,7 +77,7 @@ public class NewtFactoryAWT extends NewtFactory { return (JAWTWindow)nw; } - public static void destroyNativeWindow(JAWTWindow jawtWindow) { + public static void destroyNativeWindow(final JAWTWindow jawtWindow) { final AbstractGraphicsConfiguration config = jawtWindow.getGraphicsConfiguration(); jawtWindow.destroy(); config.getScreen().getDevice().close(); diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index b04fd98f4..31ee92ca4 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -101,7 +101,7 @@ public class AWTNewtEventFactory { } } - public static final short eventTypeAWT2NEWT(int awtType) { + public static final short eventTypeAWT2NEWT(final int awtType) { switch( awtType ) { // n/a case java.awt.event.WindowEvent.WINDOW_OPENED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED; case java.awt.event.WindowEvent.WINDOW_CLOSING: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY; @@ -136,7 +136,7 @@ public class AWTNewtEventFactory { return (short)0; } - private static int getAWTButtonDownMaskImpl(int button) { + private static int getAWTButtonDownMaskImpl(final int button) { /** * java.awt.event.InputEvent.getMaskForButton(button); * @@ -173,7 +173,7 @@ public class AWTNewtEventFactory { * @param button * @return */ - public static int getAWTButtonDownMask(int button) { + public static int getAWTButtonDownMask(final int button) { if( 0 < button && button <= awtButtonDownMasks.length ) { return awtButtonDownMasks[button-1]; } else { @@ -181,7 +181,7 @@ public class AWTNewtEventFactory { } } - public static final short awtButton2Newt(int awtButton) { + public static final short awtButton2Newt(final int awtButton) { if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { return (short)awtButton; } else { diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index 770502326..93cdd7e56 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -46,14 +46,14 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt { NativeWindow downstreamParent; - public AWTParentWindowAdapter(NativeWindow downstreamParent, com.jogamp.newt.Window downstream) { + public AWTParentWindowAdapter(final NativeWindow downstreamParent, final com.jogamp.newt.Window downstream) { super(downstream); this.downstreamParent = downstreamParent; } public AWTParentWindowAdapter() { super(); } - public AWTParentWindowAdapter setDownstream(NativeWindow downstreamParent, com.jogamp.newt.Window downstream) { + public AWTParentWindowAdapter setDownstream(final NativeWindow downstreamParent, final com.jogamp.newt.Window downstream) { setDownstream(downstream); this.downstreamParent = downstreamParent; return this; @@ -67,19 +67,19 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } @Override - public synchronized AWTAdapter addTo(java.awt.Component awtComponent) { + public synchronized AWTAdapter addTo(final java.awt.Component awtComponent) { awtComponent.addHierarchyListener(this); return super.addTo(awtComponent); } @Override - public synchronized AWTAdapter removeFrom(java.awt.Component awtComponent) { + public synchronized AWTAdapter removeFrom(final java.awt.Component awtComponent) { awtComponent.removeHierarchyListener(this); return super.removeFrom(awtComponent); } @Override - public synchronized void focusGained(java.awt.event.FocusEvent e) { + public synchronized void focusGained(final java.awt.event.FocusEvent e) { if( !isSetup ) { return; } // forward focus to NEWT child final com.jogamp.newt.Window newtChild = getNewtWindow(); @@ -100,7 +100,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } @Override - public synchronized void focusLost(java.awt.event.FocusEvent e) { + public synchronized void focusLost(final java.awt.event.FocusEvent e) { if( !isSetup ) { return; } if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusLost: "+ e); @@ -108,7 +108,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } @Override - public synchronized void componentResized(java.awt.event.ComponentEvent e) { + public synchronized void componentResized(final java.awt.event.ComponentEvent e) { if( !isSetup ) { return; } // Need to resize the NEWT child window // the resized event will be send via the native window feedback. @@ -139,7 +139,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } @Override - public synchronized void componentMoved(java.awt.event.ComponentEvent e) { + public synchronized void componentMoved(final java.awt.event.ComponentEvent e) { if( !isSetup ) { return; } if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentMoved: "+e); @@ -151,17 +151,17 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } @Override - public synchronized void windowActivated(java.awt.event.WindowEvent e) { + public synchronized void windowActivated(final java.awt.event.WindowEvent e) { // no propagation to NEWT child window } @Override - public synchronized void windowDeactivated(java.awt.event.WindowEvent e) { + public synchronized void windowDeactivated(final java.awt.event.WindowEvent e) { // no propagation to NEWT child window } @Override - public synchronized void hierarchyChanged(java.awt.event.HierarchyEvent e) { + public synchronized void hierarchyChanged(final java.awt.event.HierarchyEvent e) { if( !isSetup ) { return; } final Window newtChild = getNewtWindow(); if( null != newtChild && null == getNewtEventListener() ) { diff --git a/src/newt/classes/jogamp/newt/driver/PNGIcon.java b/src/newt/classes/jogamp/newt/driver/PNGIcon.java index 967acd413..43cfa9b25 100644 --- a/src/newt/classes/jogamp/newt/driver/PNGIcon.java +++ b/src/newt/classes/jogamp/newt/driver/PNGIcon.java @@ -71,7 +71,7 @@ public class PNGIcon { * @throws IOException * @throws MalformedURLException */ - public static ByteBuffer arrayToX11BGRAImages(IOUtil.ClassResources resources, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + public static ByteBuffer arrayToX11BGRAImages(final IOUtil.ClassResources resources, final int[] data_size, final int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { if( avail ) { return jogamp.newt.driver.opengl.JoglUtilPNGIcon.arrayToX11BGRAImages(resources, data_size, elem_bytesize); } diff --git a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java index 32bd970a1..a5f4fc769 100644 --- a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java @@ -56,7 +56,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice.open(); } - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/android/MD.java b/src/newt/classes/jogamp/newt/driver/android/MD.java index f2f30937b..e6316004b 100644 --- a/src/newt/classes/jogamp/newt/driver/android/MD.java +++ b/src/newt/classes/jogamp/newt/driver/android/MD.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,13 +20,15 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ package jogamp.newt.driver.android; +import jogamp.common.os.PlatformPropsImpl; + import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; @@ -34,22 +36,22 @@ import com.jogamp.opengl.JoglVersion; public class MD { public static final String TAG = "JogAmp.NEWT"; - - public static String getInfo() { - StringBuilder sb = new StringBuilder(); - - sb.append(VersionUtil.getPlatformInfo()).append(Platform.NEWLINE) - .append(GlueGenVersion.getInstance()).append(Platform.NEWLINE) - .append(JoglVersion.getInstance()).append(Platform.NEWLINE) - .append(Platform.NEWLINE); - + + public static String getInfo() { + final StringBuilder sb = new StringBuilder(); + + sb.append(VersionUtil.getPlatformInfo()).append(PlatformPropsImpl.NEWLINE) + .append(GlueGenVersion.getInstance()).append(PlatformPropsImpl.NEWLINE) + .append(JoglVersion.getInstance()).append(PlatformPropsImpl.NEWLINE) + .append(PlatformPropsImpl.NEWLINE); + JoglVersion.getDefaultOpenGLInfo(null, sb, true); - return sb.toString(); + return sb.toString(); } - - public static void main(String args[]) { - + + public static void main(final String args[]) { + System.err.println(getInfo()); } } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 27c570722..68d43ac75 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -57,7 +57,7 @@ public class NewtBaseActivity extends Activity { Activity rootActivity; boolean setThemeCalled = false; - protected void startAnimation(boolean start) { + protected void startAnimation(final boolean start) { if(null != animator) { final boolean res; if( start ) { @@ -95,7 +95,7 @@ public class NewtBaseActivity extends Activity { rootActivity = this; } - public void setRootActivity(Activity rootActivity) { + public void setRootActivity(final Activity rootActivity) { this.rootActivity = rootActivity; this.isDelegatedActivity = this != rootActivity; } @@ -194,11 +194,11 @@ public class NewtBaseActivity extends Activity { } private final GLStateKeeper.Listener glStateKeeperListener = new GLStateKeeper.Listener() { @Override - public void glStatePreserveNotify(GLStateKeeper glsk) { + public void glStatePreserveNotify(final GLStateKeeper glsk) { Log.d(MD.TAG, "GLStateKeeper Preserving: 0x"+Integer.toHexString(glsk.hashCode())); } @Override - public void glStateRestored(GLStateKeeper glsk) { + public void glStateRestored(final GLStateKeeper glsk) { Log.d(MD.TAG, "GLStateKeeper Restored: 0x"+Integer.toHexString(glsk.hashCode())); startAnimation(true); } @@ -212,7 +212,7 @@ public class NewtBaseActivity extends Activity { * @param androidWindow * @param newtWindow */ - public void layoutForNEWTWindow(android.view.Window androidWindow, Window newtWindow) { + public void layoutForNEWTWindow(final android.view.Window androidWindow, final Window newtWindow) { if(null == androidWindow || null == newtWindow) { throw new IllegalArgumentException("Android or NEWT Window null"); } @@ -241,7 +241,7 @@ public class NewtBaseActivity extends Activity { * @param androidWindow * @param newtWindow */ - public void setFullscreenFeature(android.view.Window androidWindow, boolean fullscreen) { + public void setFullscreenFeature(final android.view.Window androidWindow, final boolean fullscreen) { if(null == androidWindow) { throw new IllegalArgumentException("Android or Window null"); } @@ -262,7 +262,7 @@ public class NewtBaseActivity extends Activity { * Must be called before creating the view and adding any content, i.e. setContentView() ! * </p> */ - protected void adaptTheme4Transparency(CapabilitiesImmutable caps) { + protected void adaptTheme4Transparency(final CapabilitiesImmutable caps) { if(!caps.isBackgroundOpaque()) { setTransparencyTheme(); } @@ -308,7 +308,7 @@ public class NewtBaseActivity extends Activity { * @see #setContentView(android.view.Window, Window) * @see #addContentView(android.view.Window, Window, android.view.ViewGroup.LayoutParams) */ - public void setAnimator(GLAnimatorControl animator) { + public void setAnimator(final GLAnimatorControl animator) { this.animator = animator; if(!animator.isStarted()) { animator.start(); @@ -326,7 +326,7 @@ public class NewtBaseActivity extends Activity { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { Log.d(MD.TAG, "onCreate.0"); if(!isDelegatedActivity()) { super.onCreate(savedInstanceState); diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index 09de62326..4dd96c9a0 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -33,6 +33,8 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; +import jogamp.common.os.PlatformPropsImpl; + import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; @@ -49,7 +51,7 @@ import android.widget.TextView; public class NewtVersionActivity extends NewtBaseActivity { @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setFullscreenFeature(getWindow(), true); @@ -62,7 +64,7 @@ public class NewtVersionActivity extends NewtBaseActivity { scroller.addView(tv); viewGroup.addView(scroller, new android.widget.FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.TOP|Gravity.LEFT)); - final String info1 = "JOGL Version Info"+Platform.NEWLINE+VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE; + final String info1 = "JOGL Version Info"+PlatformPropsImpl.NEWLINE+VersionUtil.getPlatformInfo()+PlatformPropsImpl.NEWLINE+GlueGenVersion.getInstance()+PlatformPropsImpl.NEWLINE+JoglVersion.getInstance()+PlatformPropsImpl.NEWLINE; Log.d(MD.TAG, info1); tv.setText(info1); @@ -77,8 +79,8 @@ public class NewtVersionActivity extends NewtBaseActivity { } if( null != glp ) { // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) - GLCapabilities caps = new GLCapabilities(glp); - GLWindow glWindow = GLWindow.create(caps); + final GLCapabilities caps = new GLCapabilities(glp); + final GLWindow glWindow = GLWindow.create(caps); glWindow.setUndecorated(true); glWindow.setSize(32, 32); glWindow.setPosition(0, 0); @@ -87,14 +89,14 @@ public class NewtVersionActivity extends NewtBaseActivity { registerNEWTWindow(glWindow); glWindow.addGLEventListener(new GLEventListener() { - public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + public void init(final GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); final StringBuilder sb = new StringBuilder(); - sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); - sb.append("Requested: ").append(Platform.NEWLINE); - sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); - sb.append("Chosen: ").append(Platform.NEWLINE); - sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + sb.append(JoglVersion.getGLInfo(gl, null, true)).append(PlatformPropsImpl.NEWLINE); + sb.append("Requested: ").append(PlatformPropsImpl.NEWLINE); + sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(PlatformPropsImpl.NEWLINE).append(PlatformPropsImpl.NEWLINE); + sb.append("Chosen: ").append(PlatformPropsImpl.NEWLINE); + sb.append(drawable.getChosenGLCapabilities()).append(PlatformPropsImpl.NEWLINE).append(PlatformPropsImpl.NEWLINE); final String info2 = sb.toString(); // Log.d(MD.TAG, info2); // too big! System.err.println(info2); @@ -105,13 +107,13 @@ public class NewtVersionActivity extends NewtBaseActivity { } } ); } - 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) { } - public void display(GLAutoDrawable drawable) { + public void display(final GLAutoDrawable drawable) { } - public void dispose(GLAutoDrawable drawable) { + public void dispose(final GLAutoDrawable drawable) { } }); glWindow.setVisible(true); diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java index 553900f6a..190f55e71 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java @@ -8,7 +8,7 @@ import android.util.Log; public class NewtVersionActivityLauncher extends Activity { @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test&jogamp.debug=all&nativewindow.debug=all&jogl.debug=all&newt.debug=all"); diff --git a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java index a4c70343d..b28cdcbed 100644 --- a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java @@ -60,11 +60,11 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { protected void closeNativeImpl() { } @Override - protected int validateScreenIndex(int idx) { + protected int validateScreenIndex(final int idx) { return 0; // FIXME: only one screen available ? } - private final MonitorMode getModeImpl(final Cache cache, final android.view.Display aDisplay, DisplayMetrics outMetrics, int modeIdx, int screenSizeNRot, int nrot) { + private final MonitorMode getModeImpl(final Cache cache, final android.view.Display aDisplay, final DisplayMetrics outMetrics, final int modeIdx, final int screenSizeNRot, final int nrot) { final int[] props = new int[MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; @@ -78,7 +78,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } @Override - protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { + protected void collectNativeMonitorModesAndDevicesImpl(final Cache cache) { // FIXME: Multi Monitor Implementation missing [for newer Android version ?] final Context ctx = jogamp.common.os.android.StaticContext.getContext(); @@ -94,7 +94,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { MonitorMode currentMode = null; for(int r=0; r<4; r++) { // for all rotations final int nrot_i = r*MonitorMode.ROTATE_90; - MonitorMode mode = getModeImpl(cache, aDisplay, outMetrics, modeIdx, 0, nrot_i); + final MonitorMode mode = getModeImpl(cache, aDisplay, outMetrics, modeIdx, 0, nrot_i); if( nrot == nrot_i ) { currentMode = mode; } @@ -117,7 +117,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } @Override - protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { final Context ctx = jogamp.common.os.android.StaticContext.getContext(); final WindowManager wmgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); final DisplayMetrics outMetrics = new DisplayMetrics(); @@ -129,14 +129,14 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } @Override - protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { return false; } //---------------------------------------------------------------------- // Internals only // - static int androidRotation2NewtRotation(int arot) { + static int androidRotation2NewtRotation(final int arot) { switch(arot) { case Surface.ROTATION_270: return MonitorMode.ROTATE_270; case Surface.ROTATION_180: return MonitorMode.ROTATE_180; @@ -145,7 +145,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } return MonitorMode.ROTATE_0; } - static int getScreenSize(DisplayMetrics outMetrics, int nrot, int[] props, int offset) { + static int getScreenSize(final DisplayMetrics outMetrics, final int nrot, final int[] props, int offset) { // swap width and height, since Android reflects rotated dimension, we don't if (MonitorMode.ROTATE_90 == nrot || MonitorMode.ROTATE_270 == nrot) { props[offset++] = outMetrics.heightPixels; @@ -156,7 +156,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } return offset; } - static int getBpp(android.view.Display aDisplay, int[] props, int offset) { + static int getBpp(final android.view.Display aDisplay, final int[] props, int offset) { int bpp; switch(aDisplay.getPixelFormat()) { case PixelFormat.RGBA_8888: bpp=32; break; @@ -171,7 +171,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { props[offset++] = bpp; return offset; } - static int getScreenSizeMM(DisplayMetrics outMetrics, int[] props, int offset) { + static int getScreenSizeMM(final DisplayMetrics outMetrics, final int[] props, int offset) { final float inW = outMetrics.widthPixels / outMetrics.xdpi; final float inH = outMetrics.heightPixels / outMetrics.ydpi; final float mmpi = 25.4f; diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index db530cb7e..786ebb31c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -50,6 +50,7 @@ import javax.media.opengl.GLException; import com.jogamp.common.os.AndroidVersion; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.Window; import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLDisplayUtil; @@ -87,7 +88,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { * @param rCaps requested Capabilities * @return An Android PixelFormat number suitable for {@link SurfaceHolder#setFormat(int)}. */ - public static final int getSurfaceHolderFormat(CapabilitiesImmutable rCaps) { + public static final int getSurfaceHolderFormat(final CapabilitiesImmutable rCaps) { int fmt = PixelFormat.UNKNOWN; if( !rCaps.isBackgroundOpaque() ) { @@ -121,7 +122,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { * @param androidPixelFormat An Android PixelFormat delivered via {@link Callback2#surfaceChanged(SurfaceHolder, int, int, int)} params. * @return A native Android PixelFormat number suitable for {@link #setSurfaceVisualID0(long, int)}. */ - public static final int getANativeWindowFormat(int androidPixelFormat) { + public static final int getANativeWindowFormat(final int androidPixelFormat) { final int nativePixelFormat; switch(androidPixelFormat) { case PixelFormat.RGBA_8888: @@ -155,8 +156,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { * @param rCaps requested Capabilities * @return The fixed Capabilities */ - public static final CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { - PixelFormat pf = new PixelFormat(); + public static final CapabilitiesImmutable fixCaps(final boolean matchFormatPrecise, final int format, final CapabilitiesImmutable rCaps) { + final PixelFormat pf = new PixelFormat(); PixelFormat.getPixelFormatInfo(format, pf); final CapabilitiesImmutable res; int r, g, b, a; @@ -178,7 +179,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { rCaps.getAlphaBits() > a ; if(change) { - Capabilities nCaps = (Capabilities) rCaps.cloneMutable(); + final Capabilities nCaps = (Capabilities) rCaps.cloneMutable(); nCaps.setRedBits(r); nCaps.setGreenBits(g); nCaps.setBlueBits(b); @@ -194,7 +195,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return res; } - public static final boolean isAndroidFormatTransparent(int aFormat) { + public static final boolean isAndroidFormatTransparent(final int aFormat) { switch (aFormat) { case PixelFormat.TRANSLUCENT: case PixelFormat.TRANSPARENT: @@ -211,7 +212,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { reset(); } - public void registerActivity(Activity activity) { + public void registerActivity(final Activity activity) { this.activity = activity; } protected Activity activity = null; @@ -253,7 +254,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } } - private final void setupAndroidView(Context ctx) { + private final void setupAndroidView(final Context ctx) { androidView = new MSurfaceView(ctx); final SurfaceHolder sh = androidView.getHolder(); @@ -280,7 +281,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { @Override protected final boolean canCreateNativeImpl() { Log.d(MD.TAG, "canCreateNativeImpl.0: surfaceHandle ready "+(0!=surfaceHandle)+" - on thread "+Thread.currentThread().getName()); - if(WindowImpl.DEBUG_IMPLEMENTATION) { + if(Window.DEBUG_IMPLEMENTATION) { Thread.dumpStack(); } @@ -308,7 +309,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "canCreateNativeImpl: added to static ViewGroup - on thread "+Thread.currentThread().getName()); } }); for(long sleep = TIMEOUT_NATIVEWINDOW; 0<sleep && 0 == surfaceHandle; sleep-=10 ) { - try { Thread.sleep(10); } catch (InterruptedException ie) {} + try { Thread.sleep(10); } catch (final InterruptedException ie) {} } b = 0 != surfaceHandle; Log.d(MD.TAG, "canCreateNativeImpl: surfaceHandle ready(2) "+b+" - on thread "+Thread.currentThread().getName()); @@ -384,7 +385,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { ", format [a "+androidFormat+", n "+nativeFormat+"], win["+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+ "], pixel["+getSurfaceWidth()+"x"+getSurfaceHeight()+"],"+ " - on thread "+Thread.currentThread().getName()); - if(WindowImpl.DEBUG_IMPLEMENTATION) { + if(Window.DEBUG_IMPLEMENTATION) { Thread.dumpStack(); } @@ -395,7 +396,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) { throw new GLException("Error destroying window surface (eglDestroySurface)"); } - } catch (Throwable t) { + } catch (final Throwable t) { Log.d(MD.TAG, "closeNativeImpl: Catch exception "+t.getMessage()); t.printStackTrace(); } finally { @@ -437,12 +438,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { * {@inheritDoc} */ @Override - public final void focusChanged(boolean defer, boolean focusGained) { + public final void focusChanged(final boolean defer, final boolean focusGained) { super.focusChanged(defer, focusGained); } @Override - protected final void requestFocusImpl(boolean reparented) { + protected final void requestFocusImpl(final boolean reparented) { if(null != androidView) { Log.d(MD.TAG, "requestFocusImpl: reparented "+reparented); androidView.post(new Runnable() { @@ -455,7 +456,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } @Override - protected final boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected final boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { boolean res = true; if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { @@ -485,12 +486,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } @Override - protected final Point getLocationOnScreenImpl(int x, int y) { + protected final Point getLocationOnScreenImpl(final int x, final int y) { return new Point(x,y); } @Override - protected final void updateInsetsImpl(Insets insets) { + protected final void updateInsetsImpl(final Insets insets) { // nop .. } @@ -504,7 +505,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } @Override - public void onReceiveResult(int r, Bundle data) { + public void onReceiveResult(final int r, final Bundle data) { boolean v = false; switch(r) { @@ -524,7 +525,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { private final KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); @Override - protected final boolean setKeyboardVisibleImpl(boolean visible) { + protected final boolean setKeyboardVisibleImpl(final boolean visible) { if(null != androidView) { final InputMethodManager imm = (InputMethodManager) getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); final IBinder winid = getAndroidView().getWindowToken(); @@ -547,15 +548,15 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { // @Override - public final void surfaceCreated(SurfaceHolder holder) { + public final void surfaceCreated(final SurfaceHolder holder) { Log.d(MD.TAG, "surfaceCreated: win["+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+ "], pixels["+" "+getSurfaceWidth()+"x"+getSurfaceHeight()+"] - on thread "+Thread.currentThread().getName()); } @Override - public final void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) { + public final void surfaceChanged(final SurfaceHolder aHolder, final int aFormat, final int aWidth, final int aHeight) { Log.d(MD.TAG, "surfaceChanged: f "+nativeFormat+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)+" - on thread "+Thread.currentThread().getName()); - if(WindowImpl.DEBUG_IMPLEMENTATION) { + if(Window.DEBUG_IMPLEMENTATION) { Thread.dumpStack(); } if(0!=surfaceHandle && androidFormat != aFormat ) { @@ -607,19 +608,19 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } @Override - public final void surfaceDestroyed(SurfaceHolder holder) { + public final void surfaceDestroyed(final SurfaceHolder holder) { Log.d(MD.TAG, "surfaceDestroyed - on thread "+Thread.currentThread().getName()); windowDestroyNotify(true); // actually too late .. however .. Thread.dumpStack(); } @Override - public final void surfaceRedrawNeeded(SurfaceHolder holder) { + public final void surfaceRedrawNeeded(final SurfaceHolder holder) { Log.d(MD.TAG, "surfaceRedrawNeeded - on thread "+Thread.currentThread().getName()); windowRepaint(0, 0, getSurfaceWidth(), getSurfaceHeight()); } - protected boolean handleKeyCodeBack(KeyEvent.DispatcherState state, android.view.KeyEvent event) { + protected boolean handleKeyCodeBack(final KeyEvent.DispatcherState state, final android.view.KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { Log.d(MD.TAG, "handleKeyCodeBack.0 : "+event); state.startTracking(event, this); @@ -646,7 +647,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } return false; // continue w/ further processing } - private void enqueueAKey2NKeyUpDown(android.view.KeyEvent aEvent, short newtKeyCode) { + private void enqueueAKey2NKeyUpDown(final android.view.KeyEvent aEvent, final short newtKeyCode) { final com.jogamp.newt.event.KeyEvent eDown = AndroidNewtEventFactory.createKeyEvent(aEvent, newtKeyCode, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, this); final com.jogamp.newt.event.KeyEvent eUp = AndroidNewtEventFactory.createKeyEvent(aEvent, newtKeyCode, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, this); enqueueEvent(false, eDown); @@ -654,7 +655,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } @Override - protected void consumeKeyEvent(com.jogamp.newt.event.KeyEvent e) { + protected void consumeKeyEvent(final com.jogamp.newt.event.KeyEvent e) { super.consumeKeyEvent(e); // consume event, i.e. call all KeyListener if( com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED == e.getEventType() && !e.isConsumed() ) { if( com.jogamp.newt.event.KeyEvent.VK_ESCAPE == e.getKeyCode() ) { @@ -667,11 +668,11 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } } private void triggerHome() { - Context ctx = StaticContext.getContext(); + final Context ctx = StaticContext.getContext(); if(null == ctx) { throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); } - Intent showOptions = new Intent(Intent.ACTION_MAIN); + final Intent showOptions = new Intent(Intent.ACTION_MAIN); showOptions.addCategory(Intent.CATEGORY_HOME); ctx.startActivity(showOptions); } @@ -686,14 +687,14 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { private long eglSurface; class MSurfaceView extends SurfaceView { - public MSurfaceView (Context ctx) { + public MSurfaceView (final Context ctx) { super(ctx); setBackgroundDrawable(null); // setBackgroundColor(Color.TRANSPARENT); } @Override - public boolean onKeyPreIme(int keyCode, KeyEvent event) { + public boolean onKeyPreIme(final int keyCode, final KeyEvent event) { Log.d(MD.TAG, "onKeyPreIme : "+event); if ( event.getKeyCode() == KeyEvent.KEYCODE_BACK ) { final KeyEvent.DispatcherState state = getKeyDispatcherState(); diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index aef822262..05191e200 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -43,7 +43,7 @@ public class AndroidNewtEventFactory { /** API Level 12: {@link android.view.MotionEvent#ACTION_SCROLL} = {@value} */ private static final int ACTION_SCROLL = 8; - private static final com.jogamp.newt.event.MouseEvent.PointerType aToolType2PointerType(int aToolType) { + private static final com.jogamp.newt.event.MouseEvent.PointerType aToolType2PointerType(final int aToolType) { switch( aToolType ) { case MotionEvent.TOOL_TYPE_FINGER: return com.jogamp.newt.event.MouseEvent.PointerType.TouchScreen; @@ -57,7 +57,7 @@ public class AndroidNewtEventFactory { } } - private static final short aMotionEventType2Newt(int aType) { + private static final short aMotionEventType2Newt(final int aType) { switch( aType ) { case android.view.MotionEvent.ACTION_DOWN: case android.view.MotionEvent.ACTION_POINTER_DOWN: @@ -79,7 +79,7 @@ public class AndroidNewtEventFactory { return (short)0; } - private static final short aAccessibilityEventType2Newt(int aType) { + private static final short aAccessibilityEventType2Newt(final int aType) { switch( aType ) { case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; @@ -87,7 +87,7 @@ public class AndroidNewtEventFactory { return (short)0; } - private static final short aKeyEventType2NewtEventType(int androidKeyAction) { + private static final short aKeyEventType2NewtEventType(final int androidKeyAction) { switch(androidKeyAction) { case android.view.KeyEvent.ACTION_DOWN: case android.view.KeyEvent.ACTION_MULTIPLE: @@ -98,7 +98,7 @@ public class AndroidNewtEventFactory { return (short)0; } - private static final short aKeyCode2NewtKeyCode(int androidKeyCode, boolean inclSysKeys) { + private static final short aKeyCode2NewtKeyCode(final int androidKeyCode, final boolean inclSysKeys) { if(android.view.KeyEvent.KEYCODE_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_9) { return (short) ( com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) ); } @@ -156,7 +156,7 @@ public class AndroidNewtEventFactory { return com.jogamp.newt.event.KeyEvent.VK_UNDEFINED; } - private static final int aKeyModifiers2Newt(int androidMods) { + private static final int aKeyModifiers2Newt(final int androidMods) { int newtMods = 0; if ((androidMods & android.view.KeyEvent.META_SYM_ON) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; if ((androidMods & android.view.KeyEvent.META_SHIFT_ON) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; @@ -165,7 +165,7 @@ public class AndroidNewtEventFactory { return newtMods; } - public static com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) { + public static com.jogamp.newt.event.WindowEvent createWindowEvent(final android.view.accessibility.AccessibilityEvent event, final com.jogamp.newt.Window newtSource) { final int aType = event.getEventType(); final short nType = aAccessibilityEventType2Newt(aType); @@ -176,7 +176,7 @@ public class AndroidNewtEventFactory { } - public static com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent aEvent, com.jogamp.newt.Window newtSource, boolean inclSysKeys) { + public static com.jogamp.newt.event.KeyEvent createKeyEvent(final android.view.KeyEvent aEvent, final com.jogamp.newt.Window newtSource, final boolean inclSysKeys) { final com.jogamp.newt.event.KeyEvent res; final short newtType = aKeyEventType2NewtEventType(aEvent.getAction()); if( (short)0 != newtType) { @@ -191,7 +191,7 @@ public class AndroidNewtEventFactory { return res; } - public static com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent aEvent, short newtType, com.jogamp.newt.Window newtSource, boolean inclSysKeys) { + public static com.jogamp.newt.event.KeyEvent createKeyEvent(final android.view.KeyEvent aEvent, final short newtType, final com.jogamp.newt.Window newtSource, final boolean inclSysKeys) { final short newtKeyCode = aKeyCode2NewtKeyCode(aEvent.getKeyCode(), inclSysKeys); final com.jogamp.newt.event.KeyEvent res = createKeyEventImpl(aEvent, newtType, newtKeyCode, newtSource); if(DEBUG_KEY_EVENT) { @@ -200,7 +200,7 @@ public class AndroidNewtEventFactory { return res; } - public static com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent aEvent, short newtKeyCode, short newtType, com.jogamp.newt.Window newtSource) { + public static com.jogamp.newt.event.KeyEvent createKeyEvent(final android.view.KeyEvent aEvent, final short newtKeyCode, final short newtType, final com.jogamp.newt.Window newtSource) { final com.jogamp.newt.event.KeyEvent res = createKeyEventImpl(aEvent, newtType, newtKeyCode, newtSource); if(DEBUG_KEY_EVENT) { System.err.println("createKeyEvent2: newtType "+NEWTEvent.toHexString(newtType)+", "+aEvent+" -> "+res); @@ -208,7 +208,7 @@ public class AndroidNewtEventFactory { return res; } - private static com.jogamp.newt.event.KeyEvent createKeyEventImpl(android.view.KeyEvent aEvent, short newtType, short newtKeyCode, com.jogamp.newt.Window newtSource) { + private static com.jogamp.newt.event.KeyEvent createKeyEventImpl(final android.view.KeyEvent aEvent, final short newtType, final short newtKeyCode, final com.jogamp.newt.Window newtSource) { if( (short)0 != newtType && com.jogamp.newt.event.KeyEvent.VK_UNDEFINED != newtKeyCode ) { final Object src = null==newtSource ? null : newtSource; final long unixTime = System.currentTimeMillis() + ( aEvent.getEventTime() - android.os.SystemClock.uptimeMillis() ); @@ -243,7 +243,7 @@ public class AndroidNewtEventFactory { } private final int touchSlop; - public AndroidNewtEventFactory(android.content.Context context, android.os.Handler handler) { + public AndroidNewtEventFactory(final android.content.Context context, final android.os.Handler handler) { final android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); final int doubleTapSlop = configuration.getScaledDoubleTapSlop(); @@ -253,7 +253,7 @@ public class AndroidNewtEventFactory { } } - private static void collectPointerData(MotionEvent e, int count, final int[] x, final int[] y, final float[] pressure, + private static void collectPointerData(final MotionEvent e, final int count, final int[] x, final int[] y, final float[] pressure, final short[] pointerIds, final MouseEvent.PointerType[] pointerTypes) { for(int i=0; i < count; i++) { x[i] = (int)e.getX(i); @@ -270,8 +270,8 @@ public class AndroidNewtEventFactory { } } - public boolean sendPointerEvent(boolean enqueue, boolean wait, boolean setFocusOnDown, boolean isOnTouchEvent, - android.view.MotionEvent event, jogamp.newt.driver.android.WindowDriver newtSource) { + public boolean sendPointerEvent(final boolean enqueue, final boolean wait, final boolean setFocusOnDown, final boolean isOnTouchEvent, + final android.view.MotionEvent event, final jogamp.newt.driver.android.WindowDriver newtSource) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: isOnTouchEvent "+isOnTouchEvent+", "+event); } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java index 5a4743f73..8d20ef448 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -6,35 +6,35 @@ import android.view.View; public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTouchListener, View.OnFocusChangeListener, View.OnGenericMotionListener { private final WindowDriver newtWindow; private final AndroidNewtEventFactory factory; - - public AndroidNewtEventTranslator(WindowDriver newtWindow, android.content.Context context, android.os.Handler handler) { + + public AndroidNewtEventTranslator(final WindowDriver newtWindow, final android.content.Context context, final android.os.Handler handler) { this.newtWindow = newtWindow; - this.factory = new AndroidNewtEventFactory(context, handler); + this.factory = new AndroidNewtEventFactory(context, handler); } - - private final boolean processTouchMotionEvents(View v, android.view.MotionEvent event, boolean isOnTouchEvent) { - final boolean eventSent = factory.sendPointerEvent(true /*enqueue*/, false /*wait*/, true /*setFocusOnDown*/, + + private final boolean processTouchMotionEvents(final View v, final android.view.MotionEvent event, final boolean isOnTouchEvent) { + final boolean eventSent = factory.sendPointerEvent(true /*enqueue*/, false /*wait*/, true /*setFocusOnDown*/, isOnTouchEvent, event, newtWindow); if( eventSent ) { try { Thread.sleep((long) (100.0F/3.0F)); } // 33 ms - FIXME ?? - catch(InterruptedException e) { } + catch(final InterruptedException e) { } return true; // consumed/handled, further interest in events } - return false; // no mapping, no further interest in the event! + return false; // no mapping, no further interest in the event! } - + @Override - public boolean onTouch(View v, android.view.MotionEvent event) { + public boolean onTouch(final View v, final android.view.MotionEvent event) { return processTouchMotionEvents(v, event, true); } @Override - public boolean onGenericMotion(View v, android.view.MotionEvent event) { + public boolean onGenericMotion(final View v, final android.view.MotionEvent event) { return processTouchMotionEvents(v, event, false); } - + @Override - public boolean onKey(View v, int keyCode, android.view.KeyEvent event) { + public boolean onKey(final View v, final int keyCode, final android.view.KeyEvent event) { final com.jogamp.newt.event.KeyEvent newtEvent = AndroidNewtEventFactory.createKeyEvent(event, newtWindow, false /* no system keys */); if(null != newtEvent) { newtWindow.enqueueEvent(false, newtEvent); @@ -42,9 +42,9 @@ public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTo } return false; } - + @Override - public void onFocusChange(View v, boolean hasFocus) { + public void onFocusChange(final View v, final boolean hasFocus) { newtWindow.focusChanged(false, hasFocus); } } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index 540d9b7e8..eccdd63cf 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -75,7 +75,7 @@ public class AWTCanvas extends Canvas { private boolean displayConfigChanged=false; - public AWTCanvas(CapabilitiesImmutable capabilities, CapabilitiesChooser chooser, UpstreamScalable upstreamScale) { + public AWTCanvas(final CapabilitiesImmutable capabilities, final CapabilitiesChooser chooser, final UpstreamScalable upstreamScale) { super(); if(null==capabilities) { @@ -95,7 +95,7 @@ public class AWTCanvas extends Canvas { * canvas from interfering with the OpenGL rendering. */ @Override - public void update(Graphics g) { + public void update(final Graphics g) { // paint(g); } @@ -105,11 +105,11 @@ public class AWTCanvas extends Canvas { properly. */ @Override - public void paint(Graphics g) { + public void paint(final Graphics g) { } public boolean hasDeviceChanged() { - boolean res = displayConfigChanged; + final boolean res = displayConfigChanged; displayConfigChanged=false; return res; } @@ -152,7 +152,7 @@ public class AWTCanvas extends Canvas { jawtWindow.unlockSurface(); } - GraphicsConfiguration gc = super.getGraphicsConfiguration(); + final GraphicsConfiguration gc = super.getGraphicsConfiguration(); if(null!=gc) { device = gc.getDevice(); } @@ -188,12 +188,12 @@ public class AWTCanvas extends Canvas { jawtWindow=null; } if(null != awtConfig) { - AbstractGraphicsDevice adevice = awtConfig.getNativeGraphicsConfiguration().getScreen().getDevice(); + final AbstractGraphicsDevice adevice = awtConfig.getNativeGraphicsConfiguration().getScreen().getDevice(); String adeviceMsg=null; if(Window.DEBUG_IMPLEMENTATION) { adeviceMsg = adevice.toString(); } - boolean closed = adevice.close(); + final boolean closed = adevice.close(); if(Window.DEBUG_IMPLEMENTATION) { System.err.println(getThreadName()+": AWTCanvas.dispose(): closed GraphicsDevice: "+adeviceMsg+", result: "+closed); } @@ -255,11 +255,11 @@ public class AWTCanvas extends Canvas { * block, both devices should have the same visual list, and the * same configuration should be selected here. */ - AWTGraphicsConfiguration config = chooseGraphicsConfiguration( + final AWTGraphicsConfiguration config = chooseGraphicsConfiguration( awtConfig.getChosenCapabilities(), awtConfig.getRequestedCapabilities(), chooser, gc.getDevice()); final GraphicsConfiguration compatible = (null!=config)?config.getAWTGraphicsConfiguration():null; if(Window.DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Info: Call Stack: "+Thread.currentThread().getName()); + final Exception e = new Exception("Info: Call Stack: "+Thread.currentThread().getName()); e.printStackTrace(); System.err.println("Created Config (n): HAVE GC "+chosen); System.err.println("Created Config (n): THIS GC "+gc); @@ -307,14 +307,14 @@ public class AWTCanvas extends Canvas { return gc; } - private static AWTGraphicsConfiguration chooseGraphicsConfiguration(CapabilitiesImmutable capsChosen, - CapabilitiesImmutable capsRequested, - CapabilitiesChooser chooser, - GraphicsDevice device) { + private static AWTGraphicsConfiguration chooseGraphicsConfiguration(final CapabilitiesImmutable capsChosen, + final CapabilitiesImmutable capsRequested, + final CapabilitiesChooser chooser, + final GraphicsDevice device) { final AbstractGraphicsScreen aScreen = null != device ? AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT): AWTGraphicsScreen.createDefault(); - AWTGraphicsConfiguration config = (AWTGraphicsConfiguration) + final AWTGraphicsConfiguration config = (AWTGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, capsChosen.getClass()).chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, aScreen, VisualIDHolder.VID_UNDEFINED); @@ -346,16 +346,16 @@ public class AWTCanvas extends Canvas { clazz.getDeclaredMethod("disableBackgroundErase", new Class[] { Canvas.class }); disableBackgroundEraseMethod.setAccessible(true); - } catch (Exception e) { + } catch (final Exception e) { clazz = clazz.getSuperclass(); } } - } catch (Exception e) { + } catch (final Exception e) { } return null; } }); - } catch (Exception e) { + } catch (final Exception e) { } disableBackgroundEraseInitialized = true; if(Window.DEBUG_IMPLEMENTATION) { @@ -367,7 +367,7 @@ public class AWTCanvas extends Canvas { Throwable t=null; try { disableBackgroundEraseMethod.invoke(getToolkit(), new Object[] { this }); - } catch (Exception e) { + } catch (final Exception e) { // FIXME: workaround for 6504460 (incorrect backport of 6333613 in 5.0u10) // throw new GLException(e); t = e; diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 407d3abf9..c961669e8 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -49,7 +49,7 @@ public class AWTEDTUtil implements EDTUtil { private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; - public AWTEDTUtil(ThreadGroup tg, String name, Runnable dispatchMessages) { + public AWTEDTUtil(final ThreadGroup tg, final String name, final Runnable dispatchMessages) { this.threadGroup = tg; this.name=Thread.currentThread().getName()+"-"+name+"-EDT-"; this.dispatchMessages=dispatchMessages; @@ -63,7 +63,7 @@ public class AWTEDTUtil implements EDTUtil { } @Override - final public void setPollPeriod(long ms) { + final public void setPollPeriod(final long ms) { pollPeriod = ms; } @@ -121,16 +121,16 @@ public class AWTEDTUtil implements EDTUtil { } @Override - public final boolean invokeStop(boolean wait, Runnable task) { + public final boolean invokeStop(final boolean wait, final Runnable task) { return invokeImpl(wait, task, true); } @Override - public final boolean invoke(boolean wait, Runnable task) { + public final boolean invoke(final boolean wait, final Runnable task) { return invokeImpl(wait, task, false); } - private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { + private final boolean invokeImpl(boolean wait, final Runnable task, final boolean stop) { Throwable throwable = null; RunnableTask rTask = null; final Object rTaskLock = new Object(); @@ -187,7 +187,7 @@ public class AWTEDTUtil implements EDTUtil { if( wait ) { try { rTaskLock.wait(); // free lock, allow execution of rTask - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { throwable = ie; } if(null==throwable) { @@ -218,7 +218,7 @@ public class AWTEDTUtil implements EDTUtil { @Override public void run() { } }); - } catch (Exception e) { } + } catch (final Exception e) { } return true; } @@ -229,7 +229,7 @@ public class AWTEDTUtil implements EDTUtil { while( nedt.isRunning ) { try { edtLock.wait(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } @@ -245,7 +245,7 @@ public class AWTEDTUtil implements EDTUtil { volatile boolean isRunning = false; Object sync = new Object(); - public NEDT(ThreadGroup tg, String name) { + public NEDT(final ThreadGroup tg, final String name) { super(tg, name); } @@ -284,13 +284,13 @@ public class AWTEDTUtil implements EDTUtil { if(!shouldStop) { try { sync.wait(pollPeriod); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } } } while(!shouldStop) ; - } catch (Throwable t) { + } catch (final Throwable t) { // handle errors .. shouldStop = true; if(t instanceof RuntimeException) { diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index d9a4a48e5..23da69dba 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -51,7 +51,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = AWTGraphicsDevice.createDefault(); } - protected void setAWTGraphicsDevice(AWTGraphicsDevice d) { + protected void setAWTGraphicsDevice(final AWTGraphicsDevice d) { aDevice = d; } @@ -70,7 +70,7 @@ public class DisplayDriver extends DisplayImpl { } @Override - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java index 128c94e87..57948cfc3 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java @@ -54,7 +54,7 @@ public class ScreenDriver extends ScreenImpl { aScreen = new AWTGraphicsScreen((AWTGraphicsDevice)display.getGraphicsDevice()); } - protected void setAWTGraphicsScreen(AWTGraphicsScreen s) { + protected void setAWTGraphicsScreen(final AWTGraphicsScreen s) { aScreen = s; } @@ -70,11 +70,11 @@ public class ScreenDriver extends ScreenImpl { protected void closeNativeImpl() { } @Override - protected int validateScreenIndex(int idx) { + protected int validateScreenIndex(final int idx) { return idx; // pass through ... } - private static MonitorMode getModeProps(Cache cache, DisplayMode mode) { + private static MonitorMode getModeProps(final Cache cache, final DisplayMode mode) { int rate = mode.getRefreshRate(); if( DisplayMode.REFRESH_RATE_UNKNOWN == rate ) { rate = ScreenImpl.default_sm_rate; @@ -83,7 +83,7 @@ public class ScreenDriver extends ScreenImpl { if( DisplayMode.BIT_DEPTH_MULTI == bpp ) { bpp= ScreenImpl.default_sm_bpp; } - int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + final int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; props[i++] = mode.getWidth(); @@ -97,7 +97,7 @@ public class ScreenDriver extends ScreenImpl { } @Override - protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { + protected void collectNativeMonitorModesAndDevicesImpl(final Cache cache) { final GraphicsDevice awtGD = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice(); final DisplayMode[] awtModes = awtGD.getDisplayModes(); for(int i=0; i<awtModes.length; i++) { @@ -123,12 +123,12 @@ public class ScreenDriver extends ScreenImpl { } @Override - protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { return null; } @Override - protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { return false; } diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index 4064fdb05..06dcb8ff5 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -72,7 +72,7 @@ public class WindowDriver extends WindowImpl { return new Class<?>[] { Container.class } ; } - public WindowDriver(Container container) { + public WindowDriver(final Container container) { super(); this.awtContainer = container; if(container instanceof Frame) { @@ -87,7 +87,7 @@ public class WindowDriver extends WindowImpl { private AWTCanvas awtCanvas; @Override - protected void requestFocusImpl(boolean reparented) { + protected void requestFocusImpl(final boolean reparented) { awtContainer.requestFocus(); } @@ -174,7 +174,7 @@ public class WindowDriver extends WindowImpl { @Override public boolean hasDeviceChanged() { - boolean res = awtCanvas.hasDeviceChanged(); + final boolean res = awtCanvas.hasDeviceChanged(); if(res) { final AWTGraphicsConfiguration cfg = awtCanvas.getAWTGraphicsConfiguration(); if (null == cfg) { @@ -192,12 +192,12 @@ public class WindowDriver extends WindowImpl { } @Override - protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { + protected void updateInsetsImpl(final javax.media.nativewindow.util.Insets insets) { final Insets contInsets = awtContainer.getInsets(); insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); } - private void setCanvasSizeImpl(int width, int height) { + private void setCanvasSizeImpl(final int width, final int height) { final Dimension szClient = new Dimension(width, height); final java.awt.Window awtWindow = AWTMisc.getWindow(awtCanvas); final Container c= null != awtWindow ? awtWindow : awtContainer; @@ -217,7 +217,7 @@ public class WindowDriver extends WindowImpl { awtContainer.validate(); } } - private void setFrameSizeImpl(int width, int height) { + private void setFrameSizeImpl(final int width, final int height) { final Insets insets = awtContainer.getInsets(); final Dimension szContainer = new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom); @@ -231,7 +231,7 @@ public class WindowDriver extends WindowImpl { } @Override - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("AWTWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); @@ -284,8 +284,8 @@ public class WindowDriver extends WindowImpl { } @Override - protected Point getLocationOnScreenImpl(int x, int y) { - java.awt.Point ap = awtCanvas.getLocationOnScreen(); + protected Point getLocationOnScreenImpl(final int x, final int y) { + final java.awt.Point ap = awtCanvas.getLocationOnScreen(); ap.translate(x, y); return new Point((int)(ap.getX()+0.5),(int)(ap.getY()+0.5)); } @@ -297,13 +297,13 @@ public class WindowDriver extends WindowImpl { class LocalWindowListener implements com.jogamp.newt.event.WindowListener { @Override - public void windowMoved(com.jogamp.newt.event.WindowEvent e) { + public void windowMoved(final com.jogamp.newt.event.WindowEvent e) { if(null!=awtContainer) { WindowDriver.this.positionChanged(false, awtContainer.getX(), awtContainer.getY()); } } @Override - public void windowResized(com.jogamp.newt.event.WindowEvent e) { + public void windowResized(final com.jogamp.newt.event.WindowEvent e) { if(null!=awtCanvas) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window Resized: "+awtCanvas); @@ -313,23 +313,23 @@ public class WindowDriver extends WindowImpl { } } @Override - public void windowDestroyNotify(WindowEvent e) { + public void windowDestroyNotify(final WindowEvent e) { WindowDriver.this.windowDestroyNotify(false); } @Override - public void windowDestroyed(WindowEvent e) { + public void windowDestroyed(final WindowEvent e) { // Not fwd by AWTWindowAdapter, synthesized by NEWT } @Override - public void windowGainedFocus(WindowEvent e) { + public void windowGainedFocus(final WindowEvent e) { WindowDriver.this.focusChanged(false, true); } @Override - public void windowLostFocus(WindowEvent e) { + public void windowLostFocus(final WindowEvent e) { WindowDriver.this.focusChanged(false, false); } @Override - public void windowRepaint(WindowUpdateEvent e) { + public void windowRepaint(final WindowUpdateEvent e) { if(null!=awtCanvas) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window Repaint: "+awtCanvas); diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java index d1b30f7cc..ceb337150 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -70,7 +70,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { } @Override - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { DestroyDisplay(aDevice.getHandle()); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java index efedf7c7a..fab3fe882 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -62,12 +62,12 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { protected void closeNativeImpl() { } @Override - protected int validateScreenIndex(int idx) { + protected int validateScreenIndex(final int idx) { return 0; // only one screen available } @Override - protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + protected final void collectNativeMonitorModesAndDevicesImpl(final MonitorModeProps.Cache cache) { int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; @@ -108,7 +108,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } @Override - protected void calcVirtualScreenOriginAndSize(Rectangle viewport, Rectangle viewportInWindowUnits) { + protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(0, 0, fixedWidth, fixedHeight); // FIXME } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java index 64b856707..aec85f875 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java @@ -82,9 +82,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } @Override - protected void requestFocusImpl(boolean reparented) { } + protected void requestFocusImpl(final boolean reparented) { } - protected void setSizeImpl(int width, int height) { + protected void setSizeImpl(final int width, final int height) { if(0!=getWindowHandle()) { // n/a in BroadcomEGL System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); @@ -94,7 +94,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } @Override - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { if(0!=getWindowHandle()) { if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { @@ -123,12 +123,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } @Override - protected Point getLocationOnScreenImpl(int x, int y) { + protected Point getLocationOnScreenImpl(final int x, final int y) { return new Point(x,y); } @Override - protected void updateInsetsImpl(Insets insets) { + protected void updateInsetsImpl(final Insets insets) { // nop .. } @@ -148,11 +148,11 @@ public class WindowDriver extends jogamp.newt.WindowImpl { private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle); - private long realizeWindow(boolean chromaKey, int width, int height) { + private long realizeWindow(final boolean chromaKey, final int width, final int height) { if(DEBUG_IMPLEMENTATION) { System.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+getGraphicsConfiguration()); } - long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height); + final long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height); if (0 == handle) { throw new NativeWindowException("Error native Window Handle is null"); } @@ -160,9 +160,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl { return handle; } - private void windowCreated(int cfgID, int width, int height) { + private void windowCreated(final int cfgID, final int width, final int height) { defineSize(width, height); - GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities(); + final GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities(); final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID); if (null == cfg) { throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this); diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java index 178bb70f7..1b67fa755 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -69,7 +69,7 @@ public class DisplayDriver extends DisplayImpl { try { final URLConnection urlConn = res.resolve(0); image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.BGRA8888, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -106,7 +106,7 @@ public class DisplayDriver extends DisplayImpl { private PointerIconImpl defaultPointerIcon = null; @Override - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { aDevice.close(); CloseBCMDisplay0(bcmHandle); bcmHandle = 0; @@ -123,12 +123,12 @@ public class DisplayDriver extends DisplayImpl { // public final PixelFormat getNativePointerIconPixelFormat() { return PixelFormat.BGRA8888; } @Override - protected final long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + protected final long createPointerIconImpl(final PixelFormat pixelformat, final int width, final int height, final ByteBuffer pixels, final int hotX, final int hotY) { return CreatePointerIcon(bcmHandle, pixels, width, height, hotX, hotY); } @Override - protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + protected final void destroyPointerIconImpl(final long displayHandle, final long piHandle) { DestroyPointerIcon0(piHandle); } @@ -187,7 +187,7 @@ public class DisplayDriver extends DisplayImpl { private static native long OpenBCMDisplay0(); private static native void CloseBCMDisplay0(long handle); - private static long CreatePointerIcon(long bcmHandle, Buffer pixels, int width, int height, int hotX, int hotY) { + private static long CreatePointerIcon(final long bcmHandle, final Buffer pixels, final int width, final int height, final int hotX, final int hotY) { final boolean pixels_is_direct = Buffers.isDirect(pixels); return CreatePointerIcon0(pixels_is_direct ? pixels : Buffers.getArray(pixels), pixels_is_direct ? Buffers.getDirectBufferByteOffset(pixels) : Buffers.getIndirectBufferByteOffset(pixels), diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java index 404f03eed..5c1c08ca8 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -55,12 +55,12 @@ public class ScreenDriver extends ScreenImpl { protected void closeNativeImpl() { } @Override - protected int validateScreenIndex(int idx) { + protected int validateScreenIndex(final int idx) { return 0; // only one screen available } @Override - protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + protected final void collectNativeMonitorModesAndDevicesImpl(final MonitorModeProps.Cache cache) { int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; @@ -101,12 +101,12 @@ public class ScreenDriver extends ScreenImpl { } @Override - protected void calcVirtualScreenOriginAndSize(Rectangle viewport, Rectangle viewportInWindowUnits) { + protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(0, 0, cachedWidth, cachedHeight); } /** Called from {@link #initNative()}. */ - protected void setScreenSize(int width, int height) { + protected void setScreenSize(final int width, final int height) { cachedWidth = width; cachedHeight = height; } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index b5e874f65..ad6d0b688 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -149,23 +149,23 @@ public class WindowDriver extends WindowImpl { } @Override - protected void requestFocusImpl(boolean reparented) { + protected void requestFocusImpl(final boolean reparented) { focusChanged(false, true); } @Override - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { reconfigure0(nativeWindowHandle, x, y, width, height, flags); return true; } @Override - protected Point getLocationOnScreenImpl(int x, int y) { + protected Point getLocationOnScreenImpl(final int x, final int y) { return new Point(x,y); } @Override - protected void updateInsetsImpl(Insets insets) { + protected void updateInsetsImpl(final Insets insets) { // nop .. } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java index cc435540f..1d43017c3 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -74,7 +74,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { } @Override - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { if(0==displayHandle) { throw new NativeWindowException("displayHandle null; initCnt "+initCounter); } @@ -96,7 +96,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { } } - protected void setFocus(WindowDriver focus) { + protected void setFocus(final WindowDriver focus) { focusedWindow = focus; } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java index 89d7540da..b5400c386 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -55,7 +55,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { @Override protected void createNativeImpl() { - AbstractGraphicsDevice adevice = getDisplay().getGraphicsDevice(); + final AbstractGraphicsDevice adevice = getDisplay().getGraphicsDevice(); GetScreenInfo(adevice.getHandle(), screen_idx); aScreen = new DefaultGraphicsScreen(adevice, screen_idx); } @@ -64,12 +64,12 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { protected void closeNativeImpl() { } @Override - protected int validateScreenIndex(int idx) { + protected int validateScreenIndex(final int idx) { return 0; // only one screen available } @Override - protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + protected final void collectNativeMonitorModesAndDevicesImpl(final MonitorModeProps.Cache cache) { int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; @@ -110,7 +110,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } @Override - protected void calcVirtualScreenOriginAndSize(Rectangle viewport, Rectangle viewportInWindowUnits) { + protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(0, 0, cachedWidth, cachedHeight); } @@ -122,7 +122,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { private native void GetScreenInfo(long displayHandle, int screen_idx); // called by GetScreenInfo() .. - private void screenCreated(int width, int height) { + private void screenCreated(final int width, final int height) { cachedWidth = width; cachedHeight = height; } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java index cf169f1c7..d7bd17e42 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java @@ -86,8 +86,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } @Override - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - ScreenDriver screen = (ScreenDriver) getScreen(); + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, final int flags) { + final ScreenDriver screen = (ScreenDriver) getScreen(); // Note for GDL: window units == pixel units if(width>screen.getWidth()) { @@ -118,7 +118,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } @Override - protected void requestFocusImpl(boolean reparented) { + protected void requestFocusImpl(final boolean reparented) { ((DisplayDriver)getScreen().getDisplay()).setFocus(this); } @@ -128,12 +128,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } @Override - protected Point getLocationOnScreenImpl(int x, int y) { + protected Point getLocationOnScreenImpl(final int x, final int y) { return new Point(x,y); } @Override - protected void updateInsetsImpl(Insets insets) { + protected void updateInsetsImpl(final Insets insets) { // nop .. } @@ -146,7 +146,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { private native void CloseSurface(long displayHandle, long surfaceHandle); private native void SetBounds0(long surfaceHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); - private void updateBounds(int x, int y, int width, int height) { + private void updateBounds(final int x, final int y, final int width, final int height) { definePosition(x, y); defineSize(width, height); } diff --git a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java index 6c706148a..e72ddbc11 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java @@ -67,7 +67,7 @@ public class DisplayDriver extends DisplayImpl { } @Override - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java index 6245f3207..06485ccef 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -60,12 +60,12 @@ public class ScreenDriver extends ScreenImpl { protected void closeNativeImpl() { } @Override - protected int validateScreenIndex(int idx) { + protected int validateScreenIndex(final int idx) { return 0; // only one screen available } @Override - protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + protected final void collectNativeMonitorModesAndDevicesImpl(final MonitorModeProps.Cache cache) { int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; @@ -106,11 +106,11 @@ public class ScreenDriver extends ScreenImpl { } @Override - protected void calcVirtualScreenOriginAndSize(Rectangle viewport, Rectangle viewportInWindowUnits) { + protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(0, 0, cachedWidth, cachedHeight); } - protected void sizeChanged(int w, int h) { + protected void sizeChanged(final int w, final int h) { cachedWidth = w; cachedHeight = h; } diff --git a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java index 158e6ab2f..d53ef00cd 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java @@ -68,9 +68,9 @@ public class WindowDriver extends WindowImpl { } setGraphicsConfiguration(cfg); - GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) cfg.getChosenCapabilities(); - int eglConfigID = eglCaps.getVisualID(VIDType.EGL_CONFIG); - long eglConfig = EGLGraphicsConfiguration.EGLConfigId2EGLConfig(getDisplayHandle(), eglConfigID); + final GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) cfg.getChosenCapabilities(); + final int eglConfigID = eglCaps.getVisualID(VIDType.EGL_CONFIG); + final long eglConfig = EGLGraphicsConfiguration.EGLConfigId2EGLConfig(getDisplayHandle(), eglConfigID); eglWindowHandle = CreateWindow(getDisplayHandle(), eglConfig); if (eglWindowHandle == 0) { @@ -93,10 +93,10 @@ public class WindowDriver extends WindowImpl { } @Override - protected void requestFocusImpl(boolean reparented) { } + protected void requestFocusImpl(final boolean reparented) { } @Override - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected boolean reconfigureWindowImpl(final int x, final int y, int width, int height, final int flags) { if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { setVisible0(eglWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); @@ -130,12 +130,12 @@ public class WindowDriver extends WindowImpl { } @Override - protected Point getLocationOnScreenImpl(int x, int y) { + protected Point getLocationOnScreenImpl(final int x, final int y) { return new Point(x,y); } @Override - protected void updateInsetsImpl(Insets insets) { + protected void updateInsetsImpl(final Insets insets) { // nop .. } @@ -151,12 +151,12 @@ public class WindowDriver extends WindowImpl { private native void setSize0(long eglWindowHandle, int width, int height); private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); - private void windowCreated(long userData) { + private void windowCreated(final long userData) { windowUserData=userData; } @Override - protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { + protected void sizeChanged(final boolean defer, final int newWidth, final int newHeight, final boolean force) { if(isFullscreen()) { ((ScreenDriver)getScreen()).sizeChanged(getWidth(), getHeight()); } diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index b7c86a26d..49a815cb6 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -72,7 +72,7 @@ public class LinuxEventDeviceTracker implements WindowListener { } private WindowImpl focusedWindow = null; - private EventDeviceManager eventDeviceManager = new EventDeviceManager(); + private final EventDeviceManager eventDeviceManager = new EventDeviceManager(); /* The devices are in /dev/input: @@ -85,56 +85,56 @@ public class LinuxEventDeviceTracker implements WindowListener { And so on up to event31. */ - private EventDevicePoller[] eventDevicePollers = new EventDevicePoller[32]; + private final EventDevicePoller[] eventDevicePollers = new EventDevicePoller[32]; @Override - public void windowResized(WindowEvent e) { } + public void windowResized(final WindowEvent e) { } @Override - public void windowMoved(WindowEvent e) { } + public void windowMoved(final WindowEvent e) { } @Override - public void windowDestroyNotify(WindowEvent e) { - Object s = e.getSource(); + public void windowDestroyNotify(final WindowEvent e) { + final Object s = e.getSource(); if(focusedWindow == s) { focusedWindow = null; } } @Override - public void windowDestroyed(WindowEvent e) { } + public void windowDestroyed(final WindowEvent e) { } @Override - public void windowGainedFocus(WindowEvent e) { - Object s = e.getSource(); + public void windowGainedFocus(final WindowEvent e) { + final Object s = e.getSource(); if(s instanceof WindowImpl) { focusedWindow = (WindowImpl) s; } } @Override - public void windowLostFocus(WindowEvent e) { - Object s = e.getSource(); + public void windowLostFocus(final WindowEvent e) { + final Object s = e.getSource(); if(focusedWindow == s) { focusedWindow = null; } } - public static void main(String[] args ){ + public static void main(final String[] args ){ System.setProperty("newt.debug.Window.KeyEvent", "true"); LinuxEventDeviceTracker.getSingleton(); try { while(true) { Thread.sleep(1000); } - } catch (InterruptedException e) { + } catch (final InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override - public void windowRepaint(WindowUpdateEvent e) { } + public void windowRepaint(final WindowUpdateEvent e) { } class EventDeviceManager implements Runnable { @@ -142,17 +142,17 @@ public class LinuxEventDeviceTracker implements WindowListener { @Override public void run() { - File f = new File("/dev/input/"); + final File f = new File("/dev/input/"); int number; while(!stop){ - for(String path:f.list()){ + for(final String path:f.list()){ if(path.startsWith("event")) { - String stringNumber = path.substring(5); + final String stringNumber = path.substring(5); number = Integer.parseInt(stringNumber); if(number<32&&number>=0) { if(eventDevicePollers[number]==null){ eventDevicePollers[number] = new EventDevicePoller(number); - Thread t = new Thread(eventDevicePollers[number], "NEWT-LinuxEventDeviceTracker-event"+number); + final Thread t = new Thread(eventDevicePollers[number], "NEWT-LinuxEventDeviceTracker-event"+number); t.setDaemon(true); t.start(); } else if(eventDevicePollers[number].stop) { @@ -163,7 +163,7 @@ public class LinuxEventDeviceTracker implements WindowListener { } try { Thread.sleep(2000); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -174,9 +174,9 @@ public class LinuxEventDeviceTracker implements WindowListener { class EventDevicePoller implements Runnable { private volatile boolean stop = false; - private String eventDeviceName; + private final String eventDeviceName; - public EventDevicePoller(int eventDeviceNumber){ + public EventDevicePoller(final int eventDeviceNumber){ this.eventDeviceName="/dev/input/event"+eventDeviceNumber; } @@ -194,14 +194,14 @@ public class LinuxEventDeviceTracker implements WindowListener { * unsigned int value; * }; */ - ByteBuffer bb = ByteBuffer.wrap(b); - StructAccessor s = new StructAccessor(bb); + final ByteBuffer bb = ByteBuffer.wrap(b); + final StructAccessor s = new StructAccessor(bb); final File f = new File(eventDeviceName); f.setReadOnly(); InputStream fis; try { fis = new FileInputStream(f); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { stop=true; return; } @@ -224,7 +224,7 @@ public class LinuxEventDeviceTracker implements WindowListener { int read = 0; try { read = fis.read(b, 0, remaining); - } catch (IOException e) { + } catch (final IOException e) { stop = true; break loop; } @@ -369,13 +369,13 @@ public class LinuxEventDeviceTracker implements WindowListener { if(null != fis) { try { fis.close(); - } catch (IOException e) { + } catch (final IOException e) { } } stop=true; } - private char NewtVKey2Unicode(short VK, int modifiers) { + private char NewtVKey2Unicode(final short VK, final int modifiers) { if( KeyEvent.isPrintableKey(VK, true) ) { if((modifiers & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { return (char)VK; @@ -387,7 +387,7 @@ public class LinuxEventDeviceTracker implements WindowListener { } @SuppressWarnings("unused") - private char LinuxEVKey2Unicode(short EVKey) { + private char LinuxEVKey2Unicode(final short EVKey) { // This is the stuff normally mapped by a system keymap switch(EVKey) { @@ -443,7 +443,7 @@ public class LinuxEventDeviceTracker implements WindowListener { return 0; } - private short LinuxEVKey2NewtVKey(short EVKey) { + private short LinuxEVKey2NewtVKey(final short EVKey) { switch(EVKey) { case 1: // ESC diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java index 3663ef0d4..1d9377563 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java @@ -79,40 +79,40 @@ public class LinuxMouseTracker implements WindowListener { public final int getLastY() { return lastFocusedY; } @Override - public void windowResized(WindowEvent e) { } + public void windowResized(final WindowEvent e) { } @Override - public void windowMoved(WindowEvent e) { } + public void windowMoved(final WindowEvent e) { } @Override - public void windowDestroyNotify(WindowEvent e) { - Object s = e.getSource(); + public void windowDestroyNotify(final WindowEvent e) { + final Object s = e.getSource(); if(focusedWindow == s) { focusedWindow = null; } } @Override - public void windowDestroyed(WindowEvent e) { } + public void windowDestroyed(final WindowEvent e) { } @Override - public void windowGainedFocus(WindowEvent e) { - Object s = e.getSource(); + public void windowGainedFocus(final WindowEvent e) { + final Object s = e.getSource(); if(s instanceof WindowImpl) { focusedWindow = (WindowImpl) s; } } @Override - public void windowLostFocus(WindowEvent e) { - Object s = e.getSource(); + public void windowLostFocus(final WindowEvent e) { + final Object s = e.getSource(); if(focusedWindow == s) { focusedWindow = null; } } @Override - public void windowRepaint(WindowUpdateEvent e) { } + public void windowRepaint(final WindowUpdateEvent e) { } class MouseDevicePoller implements Runnable { @Override @@ -123,7 +123,7 @@ public class LinuxMouseTracker implements WindowListener { InputStream fis; try { fis = new FileInputStream(f); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); return; @@ -137,7 +137,7 @@ public class LinuxMouseTracker implements WindowListener { int read = 0; try { read = fis.read(b, 0, remaining); - } catch (IOException e) { + } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -222,7 +222,7 @@ public class LinuxMouseTracker implements WindowListener { if(null != fis) { try { fis.close(); - } catch (IOException e) { + } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index d850a18af..4ecc2fdcf 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -71,7 +71,7 @@ public class DisplayDriver extends DisplayImpl { final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); final URLConnection urlConn = iconRes.resolve(iconRes.resourceCount()-1); image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.BGRA8888, true /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -107,7 +107,7 @@ public class DisplayDriver extends DisplayImpl { } @Override - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { aDevice.close(); } @@ -121,14 +121,14 @@ public class DisplayDriver extends DisplayImpl { public final boolean getNativePointerIconForceDirectNIO() { return true; } @Override - protected final long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + protected final long createPointerIconImpl(final PixelFormat pixelformat, final int width, final int height, final ByteBuffer pixels, final int hotX, final int hotY) { return createPointerIcon0( pixels, Buffers.getDirectBufferByteOffset(pixels), true /* pixels_is_direct */, width, height, hotX, hotY); } @Override - protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + protected final void destroyPointerIconImpl(final long displayHandle, final long piHandle) { destroyPointerIcon0(piHandle); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java index a89150d7c..d80d43e8f 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java @@ -231,7 +231,7 @@ public class MacKeyUtil { private static final char NSModeSwitchFunctionKey = 0xF747; */ - static short validateKeyCode(short keyCode, char keyChar) { + static short validateKeyCode(final short keyCode, final char keyChar) { // OS X Virtual Keycodes switch(keyCode) { // diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index fe7411f29..c0f7d3859 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -128,13 +128,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - protected void setScreen(ScreenImpl newScreen) { // never null ! + protected void setScreen(final ScreenImpl newScreen) { // never null ! super.setScreen(newScreen); updatePixelScaleByScreenIdx(false /* sendEvent*/); // caller (reparent, ..) will send reshape event } @Override - protected void monitorModeChanged(MonitorEvent me, boolean success) { + protected void monitorModeChanged(final MonitorEvent me, final boolean success) { updatePixelScaleByWindowHandle(false /* sendEvent*/); // send reshape event itself } @@ -210,9 +210,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl close0( handle ); } }); } - } catch (Throwable t) { + } catch (final Throwable t) { if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNative failed - "+Thread.currentThread().getName(), t); + final Exception e = new Exception("Warning: closeNative failed - "+Thread.currentThread().getName(), t); e.printStackTrace(); } } @@ -255,7 +255,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - public void setSurfaceHandle(long surfaceHandle) { + public void setSurfaceHandle(final long surfaceHandle) { if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); } @@ -324,10 +324,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } - private boolean useParent(NativeWindow parent) { return null != parent && 0 != parent.getWindowHandle(); } + private boolean useParent(final NativeWindow parent) { return null != parent && 0 != parent.getWindowHandle(); } @Override - public void updatePosition(int x, int y) { + public void updatePosition(final int x, final int y) { final long handle = getWindowHandle(); if( 0 != handle && !isOffscreenInstance ) { final NativeWindow parent = getParent(); @@ -348,7 +348,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { + protected void sizeChanged(final boolean defer, final int newWidth, final int newHeight, final boolean force) { final long handle = getWindowHandle(); if( 0 != handle && !isOffscreenInstance ) { final NativeWindow parent = getParent(); @@ -370,7 +370,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - protected boolean reconfigureWindowImpl(int x, int y, final int width, final int height, int flags) { + protected boolean reconfigureWindowImpl(int x, int y, final int width, final int height, final int flags) { final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent()); isOffscreenInstance = 0 != sscSurfaceHandle || _isOffscreenInstance; final PointImmutable pClientLevelOnSreen; @@ -471,7 +471,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - protected Point getLocationOnScreenImpl(int x, int y) { + protected Point getLocationOnScreenImpl(final int x, final int y) { final NativeWindow parent = getParent(); final boolean useParent = useParent(parent); return getLocationOnScreenImpl(x, y, parent, useParent); @@ -490,12 +490,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - protected void updateInsetsImpl(Insets insets) { + protected void updateInsetsImpl(final Insets insets) { // nop - using event driven insetsChange(..) } /** Callback for native screen position change event of the client area. */ - protected void screenPositionChanged(boolean defer, int newX, int newY) { + protected void screenPositionChanged(final boolean defer, final int newX, final int newY) { // passed coordinates are in screen position of the client area if(getWindowHandle()!=0) { final NativeWindow parent = getParent(); @@ -506,8 +506,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl positionChanged(defer, newX, newY); } else { // screen position -> rel child window position - Point absPos = new Point(newX, newY); - Point parentOnScreen = parent.getLocationOnScreen(null); + final Point absPos = new Point(newX, newY); + final Point parentOnScreen = parent.getLocationOnScreen(null); absPos.translate( parentOnScreen.scale(-1, -1) ); if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.positionChanged.1 (Screen Pos - CHILD): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> absPos "+newX+"/"+newY+", parentOnScreen "+parentOnScreen+" -> "+absPos); @@ -567,22 +567,22 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + public final void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } @Override - public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short _keyCode, short _keySym, char keyChar) { + public final void enqueueKeyEvent(final boolean wait, final short eventType, final int modifiers, final short _keyCode, final short _keySym, final char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } - protected final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short _keyCode, char keyChar, char keySymChar) { + protected final void enqueueKeyEvent(final boolean wait, final short eventType, int modifiers, final short _keyCode, final char keyChar, final char keySymChar) { // Note that we send the key char for the key code on this // platform -- we do not get any useful key codes out of the system final short keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); final short keySym; { - short _keySym = KeyEvent.NULL_CHAR != keySymChar ? KeyEvent.utf16ToVKey(keySymChar) : KeyEvent.VK_UNDEFINED; + final short _keySym = KeyEvent.NULL_CHAR != keySymChar ? KeyEvent.utf16ToVKey(keySymChar) : KeyEvent.VK_UNDEFINED; keySym = KeyEvent.VK_UNDEFINED != _keySym ? _keySym : keyCode; } /** @@ -682,7 +682,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl setAlwaysOnTop0(getWindowHandle(), alwaysOnTop); } } }); - } catch (Exception ie) { + } catch (final Exception ie) { ie.printStackTrace(); } } diff --git a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java index 551929b8d..5e703f690 100644 --- a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java +++ b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java @@ -41,7 +41,7 @@ import com.jogamp.opengl.util.PNGPixelRect; public class JoglUtilPNGIcon { - public static ByteBuffer arrayToX11BGRAImages(IOUtil.ClassResources resources, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + public static ByteBuffer arrayToX11BGRAImages(final IOUtil.ClassResources resources, final int[] data_size, final int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { final PNGPixelRect[] images = new PNGPixelRect[resources.resourceCount()]; data_size[0] = 0; for(int i=0; i<resources.resourceCount(); i++) { diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index a30431788..8973ae7ed 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -62,7 +62,7 @@ public class DisplayDriver extends DisplayImpl { static { NEWTJNILibLoader.loadNEWT(); { - long[] _defaultIconHandle = { 0, 0 }; + final long[] _defaultIconHandle = { 0, 0 }; if( DisplayImpl.isPNGUtilAvailable() ) { try { final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); @@ -76,7 +76,7 @@ public class DisplayDriver extends DisplayImpl { final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.BGRA8888, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); _defaultIconHandle[1] = DisplayDriver.createBGRA8888Icon0(image.getPixels(), image.getSize().getWidth(), image.getSize().getHeight(), false, 0, 0); } - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -110,7 +110,7 @@ public class DisplayDriver extends DisplayImpl { } @Override - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { sharedClassFactory.releaseSharedClass(); aDevice.close(); } @@ -125,12 +125,12 @@ public class DisplayDriver extends DisplayImpl { } @Override - protected final long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + protected final long createPointerIconImpl(final PixelFormat pixelformat, final int width, final int height, final ByteBuffer pixels, final int hotX, final int hotY) { return createBGRA8888Icon0(pixels, width, height, true, hotX, hotY); } @Override - protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + protected final void destroyPointerIconImpl(final long displayHandle, final long piHandle) { destroyIcon0(piHandle); } @@ -139,7 +139,7 @@ public class DisplayDriver extends DisplayImpl { // private static native void DispatchMessages0(); - static long createBGRA8888Icon0(Buffer pixels, int width, int height, boolean isCursor, int hotX, int hotY) { + static long createBGRA8888Icon0(final Buffer pixels, final int width, final int height, final boolean isCursor, final int hotX, final int hotY) { if( null == pixels ) { throw new IllegalArgumentException("data buffer/size"); } diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java index af265cfd3..1cba421bc 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -156,7 +156,7 @@ public class ScreenDriver extends ScreenImpl { } @Override - protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, Rectangle viewportInWindowUnits) { + protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { viewport.set(getVirtualOriginX0(), getVirtualOriginY0(), getVirtualWidthImpl0(), getVirtualHeightImpl0()); } diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index bda844bb5..1c5c34457 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -116,7 +116,7 @@ public class WindowDriver extends WindowImpl { @Override public boolean hasDeviceChanged() { if(0!=getWindowHandle()) { - long _hmon = MonitorFromWindow0(getWindowHandle()); + final long _hmon = MonitorFromWindow0(getWindowHandle()); if (hmon != _hmon) { if(DEBUG_IMPLEMENTATION) { System.err.println("Info: Window Device Changed "+Thread.currentThread().getName()+ @@ -154,7 +154,7 @@ public class WindowDriver extends WindowImpl { windowHandleClose = _windowHandle; if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ + final Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ " (Parent HWND "+toHexString(getParentWindowHandle())+ ") : HWND "+toHexString(_windowHandle)+", "+Thread.currentThread()); e.printStackTrace(); @@ -167,18 +167,18 @@ public class WindowDriver extends WindowImpl { if ( 0 != hdc ) { try { GDI.ReleaseDC(windowHandleClose, hdc); - } catch (Throwable t) { + } catch (final Throwable t) { if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); + final Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); e.printStackTrace(); } } } try { GDI.DestroyWindow(windowHandleClose); - } catch (Throwable t) { + } catch (final Throwable t) { if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); + final Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); e.printStackTrace(); } } @@ -189,7 +189,7 @@ public class WindowDriver extends WindowImpl { } @Override - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, final int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("WindowsWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); @@ -217,7 +217,7 @@ public class WindowDriver extends WindowImpl { } @Override - protected void requestFocusImpl(boolean force) { + protected void requestFocusImpl(final boolean force) { requestFocus0(getWindowHandle(), force); } @@ -273,12 +273,12 @@ public class WindowDriver extends WindowImpl { } @Override - protected Point getLocationOnScreenImpl(int x, int y) { + protected Point getLocationOnScreenImpl(final int x, final int y) { return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); } @Override - protected void updateInsetsImpl(Insets insets) { + protected void updateInsetsImpl(final Insets insets) { // nop - using event driven insetsChange(..) } @@ -295,9 +295,9 @@ public class WindowDriver extends WindowImpl { * for details. * </p> */ - public final void sendTouchScreenEvent(short eventType, int modifiers, - int pActionIdx, int[] pNames, - int[] pX, int[] pY, float[] pPressure, float maxPressure) { + public final void sendTouchScreenEvent(final short eventType, final int modifiers, + final int pActionIdx, final int[] pNames, + final int[] pX, final int[] pY, final float[] pPressure, final float maxPressure) { final int pCount = pNames.length; final MouseEvent.PointerType[] pTypes = new MouseEvent.PointerType[pCount]; for(int i=pCount-1; i>=0; i--) { pTypes[i] = PointerType.TouchScreen; } @@ -311,7 +311,7 @@ public class WindowDriver extends WindowImpl { // private short repeatedKey = KeyEvent.VK_UNDEFINED; - private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, int modifiers, short keyCode, short keySym, char keyChar) { + private final boolean handlePressTypedAutoRepeat(final boolean isModifierKey, int modifiers, final short keyCode, final short keySym, final char keyChar) { if( setKeyPressed(keyCode, true) ) { // AR: Key was already pressed: Either [enter | within] AR mode final boolean withinAR = repeatedKey == keyCode; @@ -331,7 +331,7 @@ public class WindowDriver extends WindowImpl { } @Override - public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + public final void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) { final boolean isModifierKey = KeyEvent.isModifierKey(keySym); // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+ // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode, false)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); @@ -359,7 +359,7 @@ public class WindowDriver extends WindowImpl { } @Override - public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + public final void enqueueKeyEvent(final boolean wait, final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 5c2820dab..759c27450 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -69,7 +69,7 @@ public class DisplayDriver extends DisplayImpl { } @Override - public String validateDisplayName(String name, long handle) { + public String validateDisplayName(final String name, final long handle) { return X11Util.validateDisplayName(name, handle); } @@ -81,21 +81,21 @@ public class DisplayDriver extends DisplayImpl { @Override protected void createNativeImpl() { X11Util.setX11ErrorHandler(true, DEBUG ? false : true); // make sure X11 error handler is set - long handle = X11Util.openDisplay(name); + final long handle = X11Util.openDisplay(name); if( 0 == handle ) { throw new RuntimeException("Error creating display(Win): "+name); } aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); try { CompleteDisplay0(aDevice.getHandle()); - } catch(RuntimeException e) { + } catch(final RuntimeException e) { closeNativeImpl(aDevice); throw e; } } @Override - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(final AbstractGraphicsDevice aDevice) { DisplayRelease0(aDevice.getHandle(), javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now javaObjectAtom = 0; windowDeleteAtom = 0; @@ -128,12 +128,12 @@ public class DisplayDriver extends DisplayImpl { public final PixelFormat getNativePointerIconPixelFormat() { return PixelFormat.RGBA8888; } @Override - protected final long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + protected final long createPointerIconImpl(final PixelFormat pixelformat, final int width, final int height, final ByteBuffer pixels, final int hotX, final int hotY) { return createPointerIcon(getHandle(), pixels, width, height, hotX, hotY); } @Override - protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + protected final void destroyPointerIconImpl(final long displayHandle, final long piHandle) { destroyPointerIcon0(displayHandle, piHandle); } @@ -145,7 +145,7 @@ public class DisplayDriver extends DisplayImpl { private native void CompleteDisplay0(long handle); - private void displayCompleted(long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle */) { + private void displayCompleted(final long javaObjectAtom, final long windowDeleteAtom /*, long kbdHandle */) { this.javaObjectAtom=javaObjectAtom; this.windowDeleteAtom=windowDeleteAtom; // this.kbdHandle = kbdHandle; // XKB disabled for now @@ -154,7 +154,7 @@ public class DisplayDriver extends DisplayImpl { private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom /* , long kbdHandle */); // XKB disabled for now - private static long createPointerIcon(long display, Buffer pixels, int width, int height, int hotX, int hotY) { + private static long createPointerIcon(final long display, final Buffer pixels, final int width, final int height, final int hotX, final int hotY) { final boolean pixels_is_direct = Buffers.isDirect(pixels); return createPointerIcon0(display, pixels_is_direct ? pixels : Buffers.getArray(pixels), diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java index 23fd0f80f..4803852f9 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -35,6 +35,7 @@ import jogamp.newt.ScreenImpl; import com.jogamp.common.util.VersionNumber; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.Screen; class RandR11 implements RandR { private static final boolean DEBUG = ScreenDriver.DEBUG; @@ -59,7 +60,7 @@ class RandR11 implements RandR { private int[] idx_rate = null, idx_res = null; @Override - public boolean beginInitialQuery(long dpy, ScreenDriver screen) { + public boolean beginInitialQuery(final long dpy, final ScreenDriver screen) { // initialize iterators and static data final int screen_idx = screen.getIndex(); resolutionCount = getNumScreenResolutions0(dpy, screen_idx); @@ -96,7 +97,7 @@ class RandR11 implements RandR { } @Override - public void endInitialQuery(long dpy, ScreenDriver screen) { + public void endInitialQuery(final long dpy, final ScreenDriver screen) { idx_rate=null; idx_res=null; nrates=null; @@ -153,7 +154,7 @@ class RandR11 implements RandR { } } - int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + final int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; props[i++] = res[0]; // width @@ -210,14 +211,14 @@ class RandR11 implements RandR { return null; } final int screen_idx = screen.getIndex(); - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + final long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); if(0 == screenConfigHandle) { return null; } int[] res; final int nres_idx; try { - int resNumber = getNumScreenResolutions0(dpy, screen_idx); + final int resNumber = getNumScreenResolutions0(dpy, screen_idx); if(0==resNumber) { return null; } @@ -239,7 +240,7 @@ class RandR11 implements RandR { } finally { freeScreenConfiguration0(screenConfigHandle); } - int[] props = new int[4]; + final int[] props = new int[4]; int i = 0; props[i++] = 0; props[i++] = 0; @@ -255,7 +256,7 @@ class RandR11 implements RandR { return null; } final int screen_idx = screen.getIndex(); - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + final long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); if(0 == screenConfigHandle) { return null; } @@ -263,7 +264,7 @@ class RandR11 implements RandR { int rate, rot; final int nres_idx; try { - int resNumber = getNumScreenResolutions0(dpy, screen_idx); + final int resNumber = getNumScreenResolutions0(dpy, screen_idx); if(0==resNumber) { return null; } @@ -293,7 +294,7 @@ class RandR11 implements RandR { } finally { freeScreenConfiguration0(screenConfigHandle); } - int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + final int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; props[i++] = res[0]; // width @@ -310,11 +311,11 @@ class RandR11 implements RandR { } @Override - public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode) { + public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, final MonitorDevice monitor, final MonitorMode mode) { final long t0 = System.currentTimeMillis(); boolean done = false; final int screen_idx = screen.getIndex(); - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + final long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); if(0 == screenConfigHandle) { return Boolean.valueOf(done); } @@ -327,10 +328,10 @@ class RandR11 implements RandR { final int r = mode.getRotation(); if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resId, f, r) ) { - while(!done && System.currentTimeMillis()-t0 < ScreenImpl.SCREEN_MODE_CHANGE_TIMEOUT) { + while(!done && System.currentTimeMillis()-t0 < Screen.SCREEN_MODE_CHANGE_TIMEOUT) { done = setCurrentScreenModePollEnd0(dpy, screen_idx, resId, f, r); if(!done) { - try { Thread.sleep(10); } catch (InterruptedException e) { } + try { Thread.sleep(10); } catch (final InterruptedException e) { } } } } @@ -341,7 +342,7 @@ class RandR11 implements RandR { } @Override - public final void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport) { + public final void updateScreenViewport(final long dpy, final ScreenDriver screen, final RectangleImmutable viewport) { // nop } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java index a08741d9e..7a409bba1 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -58,7 +58,7 @@ class RandR13 implements RandR { @Override public void dumpInfo(final long dpy, final int screen_idx) { - long screenResources = getScreenResources0(dpy, screen_idx); + final long screenResources = getScreenResources0(dpy, screen_idx); if(0 == screenResources) { return; } @@ -73,7 +73,7 @@ class RandR13 implements RandR { IntLongHashMap crtInfoHandleMap = null; @Override - public boolean beginInitialQuery(long dpy, ScreenDriver screen) { + public boolean beginInitialQuery(final long dpy, final ScreenDriver screen) { final int screen_idx = screen.getIndex(); sessionScreenResources = getScreenResources0(dpy, screen_idx); if( 0 != sessionScreenResources ) { @@ -86,9 +86,9 @@ class RandR13 implements RandR { } @Override - public void endInitialQuery(long dpy, ScreenDriver screen) { + public void endInitialQuery(final long dpy, final ScreenDriver screen) { if( null != crtInfoHandleMap ) { - for(Iterator<IntLongHashMap.Entry> iter = crtInfoHandleMap.iterator(); iter.hasNext(); ) { + for(final Iterator<IntLongHashMap.Entry> iter = crtInfoHandleMap.iterator(); iter.hasNext(); ) { final IntLongHashMap.Entry entry = iter.next(); freeMonitorInfoHandle0(entry.value); } @@ -113,7 +113,7 @@ class RandR13 implements RandR { } } - private final long getMonitorInfoHandle(final long dpy, final int screen_idx, long screenResources, final int monitor_idx) { + private final long getMonitorInfoHandle(final long dpy, final int screen_idx, final long screenResources, final int monitor_idx) { if( null != crtInfoHandleMap ) { long h = crtInfoHandleMap.get(monitor_idx); if( 0 == h ) { @@ -174,7 +174,7 @@ class RandR13 implements RandR { } @Override - public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx) { + public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, final MonitorModeProps.Cache cache, final int crt_idx) { final int screen_idx = screen.getIndex(); final long screenResources = getScreenResourceHandle(dpy, screen_idx); try { @@ -222,7 +222,7 @@ class RandR13 implements RandR { } @Override - public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode) { + public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, final MonitorDevice monitor, final MonitorMode mode) { final int screen_idx = screen.getIndex(); final long screenResources = getScreenResourceHandle(dpy, screen_idx); final boolean res; diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 2d7c6509d..7ae68e510 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -48,6 +48,7 @@ import jogamp.newt.DisplayImpl.DisplayRunnable; import jogamp.newt.ScreenImpl; import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.common.util.PropertyAccess; import com.jogamp.common.util.VersionNumber; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; @@ -59,7 +60,7 @@ public class ScreenDriver extends ScreenImpl { static { Debug.initSingleton(); - DEBUG_TEST_RANDR13_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableRandR13", true); + DEBUG_TEST_RANDR13_DISABLED = PropertyAccess.isPropertyDefined("newt.test.Screen.disableRandR13", true); DisplayDriver.initSingleton(); } @@ -73,9 +74,9 @@ public class ScreenDriver extends ScreenImpl { @Override protected void createNativeImpl() { // validate screen index - Long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Long>() { + final Long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Long>() { @Override - public Long run(long dpy) { + public Long run(final long dpy) { return new Long(GetScreen0(dpy, screen_idx)); } } ); if (handle.longValue() == 0) { @@ -85,7 +86,7 @@ public class ScreenDriver extends ScreenImpl { final long dpy = x11dev.getHandle(); aScreen = new X11GraphicsScreen(x11dev, screen_idx); { - int v[] = getRandRVersion0(dpy); + final int v[] = getRandRVersion0(dpy); randrVersion = new VersionNumber(v[0], v[1], 0); } { @@ -169,7 +170,7 @@ public class ScreenDriver extends ScreenImpl { final AbstractGraphicsDevice device = getDisplay().getGraphicsDevice(); device.lock(); try { - int[] viewportProps = rAndR.getMonitorDeviceViewport(device.getHandle(), this, monitor.getId()); + final int[] viewportProps = rAndR.getMonitorDeviceViewport(device.getHandle(), this, monitor.getId()); viewportPU.set(viewportProps[0], viewportProps[1], viewportProps[2], viewportProps[3]); viewportWU.set(viewportProps[0], viewportProps[1], viewportProps[2], viewportProps[3]); // equal window-units and pixel-units return true; @@ -184,7 +185,7 @@ public class ScreenDriver extends ScreenImpl { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<MonitorMode>() { @Override - public MonitorMode run(long dpy) { + public MonitorMode run(final long dpy) { final int[] currentModeProps = rAndR.getCurrentMonitorModeProps(dpy, ScreenDriver.this, monitor.getId()); return MonitorModeProps.streamInMonitorMode(null, null, currentModeProps, 0); } } ); @@ -195,9 +196,9 @@ public class ScreenDriver extends ScreenImpl { if( null == rAndR ) { return false; } final long t0 = System.currentTimeMillis(); - boolean done = runWithOptTempDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() { + final boolean done = runWithOptTempDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() { @Override - public Boolean run(long dpy) { + public Boolean run(final long dpy) { return Boolean.valueOf( rAndR.setCurrentMonitorMode(dpy, ScreenDriver.this, monitor, mode) ); } }).booleanValue(); @@ -211,7 +212,7 @@ public class ScreenDriver extends ScreenImpl { private final DisplayImpl.DisplayRunnable<Boolean> xineramaEnabledQueryWithTemp = new DisplayImpl.DisplayRunnable<Boolean>() { @Override - public Boolean run(long dpy) { + public Boolean run(final long dpy) { return new Boolean(X11Util.XineramaIsEnabled(dpy)); } }; @@ -227,7 +228,7 @@ public class ScreenDriver extends ScreenImpl { } @Override - protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, Rectangle viewportInWindowUnits) { + protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) { final RectangleImmutable ov = DEBUG ? (RectangleImmutable) getViewport().cloneMutable() : null; /** if( null != rAndR && rAndR.getVersion().compareTo(RandR.version130) >= 0 && getMonitorDevices().size()>0 ) { @@ -243,7 +244,7 @@ public class ScreenDriver extends ScreenImpl { } else */ { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() { @Override - public Object run(long dpy) { + public Object run(final long dpy) { viewport.set(0, 0, getWidth0(dpy, screen_idx), getHeight0(dpy, screen_idx)); return null; } } ); diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 0eda37eac..4a3b9442d 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -80,7 +80,7 @@ public class WindowDriver extends WindowImpl { _icon_data = PNGIcon.arrayToX11BGRAImages(NewtFactory.getWindowIcons(), data_size, elem_bytesize); _icon_data_size = data_size[0]; _icon_elem_bytesize = elem_bytesize[0]; - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -143,15 +143,15 @@ public class WindowDriver extends WindowImpl { @Override protected void closeNativeImpl() { if(0!=windowHandleClose && null!=getScreen() ) { - DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice(); edtDevice.lock(); try { CloseWindow0(edtDevice.getHandle(), windowHandleClose, display.getJavaObjectAtom(), display.getWindowDeleteAtom() /* , display.getKbdHandle() */); // XKB disabled for now - } catch (Throwable t) { + } catch (final Throwable t) { if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); + final Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); e.printStackTrace(); } } finally { @@ -172,7 +172,7 @@ public class WindowDriver extends WindowImpl { * {@inheritDoc} */ @Override - protected boolean isReconfigureFlagSupported(int changeFlags) { + protected boolean isReconfigureFlagSupported(final int changeFlags) { return true; // all flags! } @@ -208,7 +208,7 @@ public class WindowDriver extends WindowImpl { final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() { @Override - public Object run(long dpy) { + public Object run(final long dpy) { reconfigureWindow0( dpy, getScreenIndex(), getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), _x, _y, width, height, fflags); @@ -226,7 +226,7 @@ public class WindowDriver extends WindowImpl { * {@inheritDoc} */ @Override - protected void focusChanged(boolean defer, boolean focusGained) { + protected void focusChanged(final boolean defer, final boolean focusGained) { if( isNativeValid() && isFullscreen() && tempFSAlwaysOnTop && hasFocus() != focusGained ) { final int flags = getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible()) | ( focusGained ? FLAG_IS_ALWAYSONTOP : 0 ); if(DEBUG_IMPLEMENTATION) { @@ -235,7 +235,7 @@ public class WindowDriver extends WindowImpl { final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() { @Override - public Object run(long dpy) { + public Object run(final long dpy) { reconfigureWindow0( dpy, getScreenIndex(), getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), getX(), getY(), getWidth(), getHeight(), flags); @@ -246,7 +246,7 @@ public class WindowDriver extends WindowImpl { super.focusChanged(defer, focusGained); } - protected void reparentNotify(long newParentWindowHandle) { + protected void reparentNotify(final long newParentWindowHandle) { if(DEBUG_IMPLEMENTATION) { final long p0 = getParentWindowHandle(); System.err.println("Window.reparentNotify ("+getThreadName()+"): "+toHexString(p0)+" -> "+toHexString(newParentWindowHandle)); @@ -257,7 +257,7 @@ public class WindowDriver extends WindowImpl { protected void requestFocusImpl(final boolean force) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() { @Override - public Object run(long dpy) { + public Object run(final long dpy) { requestFocus0(dpy, getWindowHandle(), force); return null; } @@ -268,7 +268,7 @@ public class WindowDriver extends WindowImpl { protected void setTitleImpl(final String title) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() { @Override - public Object run(long dpy) { + public Object run(final long dpy) { setTitle0(dpy, getWindowHandle(), title); return null; } @@ -279,10 +279,10 @@ public class WindowDriver extends WindowImpl { protected void setPointerIconImpl(final PointerIconImpl pi) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() { @Override - public Object run(long dpy) { + public Object run(final long dpy) { try { setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.validatedHandle() : 0); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } return null; @@ -294,7 +294,7 @@ public class WindowDriver extends WindowImpl { protected boolean setPointerVisibleImpl(final boolean pointerVisible) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Boolean>() { @Override - public Boolean run(long dpy) { + public Boolean run(final long dpy) { final PointerIconImpl pi = (PointerIconImpl)getPointerIcon(); final boolean res; if( pointerVisible && null != pi ) { @@ -312,7 +312,7 @@ public class WindowDriver extends WindowImpl { protected boolean confinePointerImpl(final boolean confine) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Boolean>() { @Override - public Boolean run(long dpy) { + public Boolean run(final long dpy) { return Boolean.valueOf(confinePointer0(dpy, getWindowHandle(), confine)); } }).booleanValue(); @@ -322,7 +322,7 @@ public class WindowDriver extends WindowImpl { protected void warpPointerImpl(final int x, final int y) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Object>() { @Override - public Object run(long dpy) { + public Object run(final long dpy) { warpPointer0(dpy, getWindowHandle(), x, y); return null; } @@ -333,20 +333,20 @@ public class WindowDriver extends WindowImpl { protected Point getLocationOnScreenImpl(final int x, final int y) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable<Point>() { @Override - public Point run(long dpy) { + public Point run(final long dpy) { return X11Lib.GetRelativeLocation(dpy, getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); } } ); } @Override - protected void updateInsetsImpl(Insets insets) { + protected void updateInsetsImpl(final Insets insets) { // nop - using event driven insetsChange(..) } @Override - protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, - int x, int y, short button, float[] rotationXYZ, float rotationScale) { + protected final void doMouseEvent(final boolean enqueue, final boolean wait, short eventType, int modifiers, + final int x, final int y, short button, final float[] rotationXYZ, final float rotationScale) { switch(eventType) { case MouseEvent.EVENT_MOUSE_PRESSED: switch(button) { @@ -390,10 +390,10 @@ public class WindowDriver extends WindowImpl { } /** Called by native TK */ - protected final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar0, String keyString) { + protected final void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar0, final String keyString) { // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); - final boolean isAutoRepeat = 0 != ( KeyEvent.AUTOREPEAT_MASK & modifiers ); + final boolean isAutoRepeat = 0 != ( InputEvent.AUTOREPEAT_MASK & modifiers ); final char keyChar = ( null != keyString ) ? keyString.charAt(0) : keyChar0; // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar0+">/<"+keyChar+">, keyString "+keyString+", mods "+toHexString(modifiers)+ // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isAutoRepeat+", [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); @@ -412,11 +412,11 @@ public class WindowDriver extends WindowImpl { } @Override - public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + public final void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } @Override - public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + public final void enqueueKeyEvent(final boolean wait, final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } @@ -426,16 +426,16 @@ public class WindowDriver extends WindowImpl { private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - private final <T> T runWithLockedDisplayDevice(DisplayRunnable<T> action) { + private final <T> T runWithLockedDisplayDevice(final DisplayRunnable<T> action) { return ((DisplayDriver) getScreen().getDisplay()).runWithLockedDisplayDevice(action); } protected static native boolean initIDs0(); - private long CreateWindow(long parentWindowHandle, long display, int screen_index, - int visualID, long javaObjectAtom, long windowDeleteAtom, - int x, int y, int width, int height, boolean autoPosition, int flags, - int pixelDataSize, Buffer pixels) { + private long CreateWindow(final long parentWindowHandle, final long display, final int screen_index, + final int visualID, final long javaObjectAtom, final long windowDeleteAtom, + final int x, final int y, final int width, final int height, final boolean autoPosition, final int flags, + final int pixelDataSize, final Buffer pixels) { // NOTE: MUST BE DIRECT BUFFER, since _NET_WM_ICON Atom uses buffer directly! if( !Buffers.isDirect(pixels) ) { throw new IllegalArgumentException("data buffer is not direct "+pixels); diff --git a/src/newt/classes/jogamp/newt/event/NEWTEventTask.java b/src/newt/classes/jogamp/newt/event/NEWTEventTask.java index 38a434279..2bdab2796 100644 --- a/src/newt/classes/jogamp/newt/event/NEWTEventTask.java +++ b/src/newt/classes/jogamp/newt/event/NEWTEventTask.java @@ -35,18 +35,18 @@ import com.jogamp.newt.event.NEWTEvent; * which notifies after sending the event for the <code>invokeAndWait()</code> semantics. */ public class NEWTEventTask { - private NEWTEvent event; - private Object notifyObject; + private final NEWTEvent event; + private final Object notifyObject; private RuntimeException exception; - public NEWTEventTask(NEWTEvent event, Object notifyObject) { + public NEWTEventTask(final NEWTEvent event, final Object notifyObject) { this.event = event ; this.notifyObject = notifyObject ; this.exception = null; } public final NEWTEvent get() { return event; } - public final void setException(RuntimeException e) { exception = e; } + public final void setException(final RuntimeException e) { exception = e; } public final RuntimeException getException() { return exception; } public final boolean isCallerWaiting() { return null != notifyObject; } diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index 91c18f023..4d5d9724a 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -50,7 +50,7 @@ public class SWTEDTUtil implements EDTUtil { private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; - public SWTEDTUtil(final com.jogamp.newt.Display newtDisplay, org.eclipse.swt.widgets.Display swtDisplay) { + public SWTEDTUtil(final com.jogamp.newt.Display newtDisplay, final org.eclipse.swt.widgets.Display swtDisplay) { this.threadGroup = Thread.currentThread().getThreadGroup(); this.name=Thread.currentThread().getName()+"-SWTDisplay-"+newtDisplay.getFQName()+"-EDT-"; this.dispatchMessages = new Runnable() { @@ -73,7 +73,7 @@ public class SWTEDTUtil implements EDTUtil { } @Override - public void setPollPeriod(long ms) { + public void setPollPeriod(final long ms) { pollPeriod = ms; } @@ -142,16 +142,16 @@ public class SWTEDTUtil implements EDTUtil { } @Override - public final boolean invokeStop(boolean wait, Runnable task) { + public final boolean invokeStop(final boolean wait, final Runnable task) { return invokeImpl(wait, task, true); } @Override - public final boolean invoke(boolean wait, Runnable task) { + public final boolean invoke(final boolean wait, final Runnable task) { return invokeImpl(wait, task, false); } - private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { + private final boolean invokeImpl(boolean wait, final Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; final Object rTaskLock = new Object(); @@ -221,7 +221,7 @@ public class SWTEDTUtil implements EDTUtil { if( wait ) { try { rTaskLock.wait(); // free lock, allow execution of rTask - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { throwable = ie; } if(null==throwable) { @@ -253,7 +253,7 @@ public class SWTEDTUtil implements EDTUtil { @Override public void run() { } }); - } catch (Exception e) { } + } catch (final Exception e) { } return true; } @@ -267,7 +267,7 @@ public class SWTEDTUtil implements EDTUtil { while( nedt.isRunning ) { try { edtLock.wait(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } @@ -283,7 +283,7 @@ public class SWTEDTUtil implements EDTUtil { volatile boolean isRunning = false; Object sync = new Object(); - public NEDT(ThreadGroup tg, String name) { + public NEDT(final ThreadGroup tg, final String name) { super(tg, name); } @@ -326,13 +326,13 @@ public class SWTEDTUtil implements EDTUtil { if(!shouldStop) { try { sync.wait(pollPeriod); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } } } while(!shouldStop) ; - } catch (Throwable t) { + } catch (final Throwable t) { // handle errors .. shouldStop = true; if(t instanceof RuntimeException) { diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 386149b22..a989345dd 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -46,7 +46,7 @@ import com.jogamp.newt.event.MouseEvent; */ public class SWTNewtEventFactory { - public static final short eventTypeSWT2NEWT(int swtType) { + public static final short eventTypeSWT2NEWT(final int swtType) { switch( swtType ) { // case SWT.MouseXXX: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED; case SWT.MouseDown: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; @@ -63,7 +63,7 @@ public class SWTNewtEventFactory { return (short)0; } - public static final int swtModifiers2Newt(int awtMods, boolean mouseHint) { + public static final int swtModifiers2Newt(final int awtMods, final boolean mouseHint) { int newtMods = 0; if ((awtMods & SWT.SHIFT) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; if ((awtMods & SWT.CTRL) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; @@ -202,7 +202,7 @@ public class SWTNewtEventFactory { } - public static final com.jogamp.newt.event.InputEvent createInputEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder) { + public static final com.jogamp.newt.event.InputEvent createInputEvent(final org.eclipse.swt.widgets.Event event, final NativeSurfaceHolder sourceHolder) { com.jogamp.newt.event.InputEvent res = createMouseEvent(event, sourceHolder); if(null == res) { res = createKeyEvent(event, sourceHolder); @@ -210,7 +210,7 @@ public class SWTNewtEventFactory { return res; } - public static final com.jogamp.newt.event.MouseEvent createMouseEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder) { + public static final com.jogamp.newt.event.MouseEvent createMouseEvent(final org.eclipse.swt.widgets.Event event, final NativeSurfaceHolder sourceHolder) { switch(event.type) { case SWT.MouseDown: case SWT.MouseUp: @@ -257,7 +257,7 @@ public class SWTNewtEventFactory { return null; // no mapping .. } - public static final com.jogamp.newt.event.KeyEvent createKeyEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder) { + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(final org.eclipse.swt.widgets.Event event, final NativeSurfaceHolder sourceHolder) { switch(event.type) { case SWT.KeyDown: case SWT.KeyUp: @@ -290,8 +290,8 @@ public class SWTNewtEventFactory { dragButtonDown = 0; } - public final boolean dispatchMouseEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder, com.jogamp.newt.event.MouseListener l) { - com.jogamp.newt.event.MouseEvent res = createMouseEvent(event, sourceHolder); + public final boolean dispatchMouseEvent(final org.eclipse.swt.widgets.Event event, final NativeSurfaceHolder sourceHolder, final com.jogamp.newt.event.MouseListener l) { + final com.jogamp.newt.event.MouseEvent res = createMouseEvent(event, sourceHolder); if(null != res) { if(null != l) { switch(event.type) { @@ -341,8 +341,8 @@ public class SWTNewtEventFactory { return false; } - public final boolean dispatchKeyEvent(org.eclipse.swt.widgets.Event event, NativeSurfaceHolder sourceHolder, com.jogamp.newt.event.KeyListener l) { - com.jogamp.newt.event.KeyEvent res = createKeyEvent(event, sourceHolder); + public final boolean dispatchKeyEvent(final org.eclipse.swt.widgets.Event event, final NativeSurfaceHolder sourceHolder, final com.jogamp.newt.event.KeyListener l) { + final com.jogamp.newt.event.KeyEvent res = createKeyEvent(event, sourceHolder); if(null != res) { if(null != l) { switch(event.type) { @@ -372,7 +372,7 @@ public class SWTNewtEventFactory { if( null != ml ) { final Listener listener = new Listener () { @Override - public void handleEvent (Event event) { + public void handleEvent (final Event event) { dispatchMouseEvent( event, sourceHolder, ml ); } }; ctrl.addListener(SWT.MouseDown, listener); @@ -385,7 +385,7 @@ public class SWTNewtEventFactory { if( null != kl ) { final Listener listener = new Listener () { @Override - public void handleEvent (Event event) { + public void handleEvent (final Event event) { dispatchKeyEvent( event, sourceHolder, kl ); } }; ctrl.addListener(SWT.KeyDown, listener); |