diff options
Diffstat (limited to 'src/newt/classes/com/jogamp')
42 files changed, 866 insertions, 866 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 382a5d583..83383d23c 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -114,9 +114,9 @@ public abstract class Display { */ public abstract int removeReference(); - /** - * Return the {@link AbstractGraphicsDevice} used for depending resources lifecycle, - * i.e. {@link Screen} and {@link Window}, as well as the event dispatching (EDT). */ + /** + * Return the {@link AbstractGraphicsDevice} used for depending resources lifecycle, + * i.e. {@link Screen} and {@link Window}, as well as the event dispatching (EDT). */ public abstract AbstractGraphicsDevice getGraphicsDevice(); /** @@ -136,8 +136,8 @@ public abstract class Display { public abstract int getId(); /** - * @return This display connection name as defined at creation time. - * The display connection name is a technical platform specific detail, see {@link AbstractGraphicsDevice#getConnection()}. + * @return This display connection name as defined at creation time. + * The display connection name is a technical platform specific detail, see {@link AbstractGraphicsDevice#getConnection()}. * * @see AbstractGraphicsDevice#getConnection() */ @@ -154,11 +154,11 @@ public abstract class Display { /** * Sets a new {@link EDTUtil} and returns the previous one. * <p> - * If <code>usrEDTUtil</code> is <code>null</code>, + * If <code>usrEDTUtil</code> is <code>null</code>, * the device's default EDTUtil is created and used. * </p> * <p> - * If a previous one exists and it differs from <code>usrEDTUtil</code>, + * If a previous one exists and it differs from <code>usrEDTUtil</code>, * it's being stopped, wait-until-idle. * </p> * <p> @@ -167,7 +167,7 @@ public abstract class Display { * </p> */ public abstract EDTUtil setEDTUtil(EDTUtil usrEDTUtil); - + public abstract EDTUtil getEDTUtil(); /** @@ -176,7 +176,7 @@ public abstract class Display { public abstract boolean isEDTRunning(); public abstract void dispatchMessages(); - + // Global Displays protected static final ArrayList<WeakReference<Display>> displayList = new ArrayList<WeakReference<Display>>(); protected static int displaysActive = 0; @@ -193,12 +193,12 @@ public abstract class Display { } /** - * + * * @param type * @param name * @param fromIndex start index, then increasing until found or end of list - * @paran shared if true, only shared instances are found, otherwise also exclusive - * @return + * @paran shared if true, only shared instances are found, otherwise also exclusive + * @return */ public static Display getFirstDisplayOf(String type, String name, int fromIndex, boolean shared) { return getDisplayOfImpl(type, name, fromIndex, 1, shared); @@ -209,7 +209,7 @@ public abstract class Display { * @param type * @param name * @param fromIndex start index, then decreasing until found or end of list. -1 is interpreted as size - 1. - * @paran shared if true, only shared instances are found, otherwise also exclusive + * @paran shared if true, only shared instances are found, otherwise also exclusive * @return */ public static Display getLastDisplayOf(String type, String name, int fromIndex, boolean shared) { @@ -231,7 +231,7 @@ public abstract class Display { } else { if( display.getType().equals(type) && display.getName().equals(name) && - ( !shared || shared && !display.isExclusive() ) + ( !shared || shared && !display.isExclusive() ) ) { return display; } @@ -241,7 +241,7 @@ public abstract class Display { } return null; } - + protected static void addDisplay2List(Display display) { synchronized(displayList) { // GC before add @@ -256,7 +256,7 @@ public abstract class Display { displayList.add(new WeakReference<Display>(display)); } } - + /** Returns the global display collection */ public static Collection<Display> getAllDisplays() { ArrayList<Display> list; diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 42ac34240..625a7b39f 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.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,12 +20,12 @@ * 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 com.jogamp.newt; import java.util.List; @@ -36,7 +36,7 @@ import javax.media.nativewindow.util.RectangleImmutable; import com.jogamp.common.util.ArrayHashSet; -/** +/** * Visual output device, i.e. a CRT, LED ..consisting of it's components:<br> * <ui> * <li>Immutable @@ -55,7 +55,7 @@ import com.jogamp.common.util.ArrayHashSet; */ public abstract class MonitorDevice { protected final Screen screen; // backref - protected final int nativeId; // unique monitor device ID + protected final int nativeId; // unique monitor device ID protected final DimensionImmutable sizeMM; // in [mm] protected final MonitorMode originalMode; protected final ArrayHashSet<MonitorMode> supportedModes; // FIXME: May need to support mutable mode, i.e. adding modes on the fly! @@ -73,14 +73,14 @@ public abstract class MonitorDevice { this.viewport = viewport; this.modeChanged = false; } - + /** Returns the {@link Screen} owning this monitor. */ public final Screen getScreen() { return screen; } - + /** - * Tests equality of two <code>MonitorDevice</code> objects + * Tests equality of two <code>MonitorDevice</code> objects * by evaluating equality of it's components:<br> * <ul> * <li><code>nativeID</code></li> @@ -105,10 +105,10 @@ public abstract class MonitorDevice { public final int hashCode() { return nativeId; } - + /** @return the immutable unique native Id of this monitor device. */ public final int getId() { return nativeId; } - + /** * @return the immutable monitor size in millimeters. */ @@ -140,11 +140,11 @@ public abstract class MonitorDevice { return supportedModes.getData(); } - /** Returns the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ + /** Returns the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ public final RectangleImmutable getViewport() { return viewport; } - + /** Returns <code>true</code> if given coordinates are contained by this {@link #getViewport() viewport}, otherwise <code>false</code>. */ public final boolean contains(int x, int y) { return x >= viewport.getX() && @@ -152,8 +152,8 @@ public abstract class MonitorDevice { y >= viewport.getY() && y < viewport.getY() + viewport.getHeight() ; } - - /** + + /** * Returns the coverage of given rectangle w/ this this {@link #getViewport() viewport}, i.e. between <code>0.0</code> and <code>1.0</code>. * <p> * Coverage is computed by: @@ -161,12 +161,12 @@ public abstract class MonitorDevice { * isect = viewport.intersection(r); * coverage = area( isect ) / area( viewport ) ; * </pre> - * </p> + * </p> */ public final float coverage(RectangleImmutable r) { return viewport.coverage(r); } - + /** * Returns the union of the given monitor's {@link #getViewport() viewport}. * @param result storage for result, will be returned @@ -186,14 +186,14 @@ public abstract class MonitorDevice { result.set(x1, y1, x2 - x1, y2 - y1); return result; } - + public final boolean isOriginalMode() { return currentMode.hashCode() == originalMode.hashCode(); } - + /** * Returns <code>true</true> if the {@link MonitorMode} - * has been changed programmatic via this API <i>only</i>, otherwise <code>false</code>. + * has been changed programmatic via this API <i>only</i>, otherwise <code>false</code>. * <p> * Note: We cannot guarantee that we won't interfere w/ another running * application's screen mode change or vice versa. @@ -202,7 +202,7 @@ public abstract class MonitorDevice { public final boolean isModeChangedByUs() { return modeChanged && !isOriginalMode(); } - + /** * Returns the cached current {@link MonitorMode} w/o native query. * <p> @@ -212,7 +212,7 @@ public abstract class MonitorDevice { public final MonitorMode getCurrentMode() { return currentMode; } - + /** * Returns the current {@link MonitorMode} resulting from a native query. * <p> diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index 218cd8bd5..175d6e5f2 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -37,7 +37,7 @@ import javax.media.nativewindow.util.SurfaceSize; import com.jogamp.newt.util.MonitorModeUtil; -/** +/** * Immutable MonitorMode Class, consisting of it's read only components:<br> * <ul> * <li>nativeId</li> @@ -79,7 +79,7 @@ import com.jogamp.newt.util.MonitorModeUtil; // Pick the monitor: // Either the one used by a window .. MonitorDevice monitor = window.getMainMonitor(); - + // Or arbitrary from the list .. List<MonitorDevice> allMonitor = getMonitorDevices(); MonitorDevice monitor = allMonitor.get(0); @@ -87,7 +87,7 @@ import com.jogamp.newt.util.MonitorModeUtil; // Current and original modes .. MonitorMode mmCurrent = monitor.queryCurrentMode(); MonitorMode mmOrig = monitor.getOriginalMode(); - + // Target resolution Dimension res = new Dimension(800, 600); @@ -102,7 +102,7 @@ import com.jogamp.newt.util.MonitorModeUtil; monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc monitorModes = MonitorModeUtil.filterByRotation(monitorModes, rot); monitorModes = MonitorModeUtil.filterByResolution(monitorModes, res); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, freq); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, freq); monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); // pick 1st one and set to current .. @@ -111,20 +111,20 @@ import com.jogamp.newt.util.MonitorModeUtil; * </pre> */ public class MonitorMode implements Comparable<MonitorMode> { - + /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the ascending order. */ public static final Comparator<MonitorMode> monitorModeComparator = new Comparator<MonitorMode>() { public int compare(MonitorMode mm1, MonitorMode mm2) { return mm1.compareTo(mm2); } }; - + /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the descending order. */ public static final Comparator<MonitorMode> monitorModeComparatorInv = new Comparator<MonitorMode>() { public int compare(MonitorMode mm1, MonitorMode mm2) { return mm2.compareTo(mm1); } }; - - /** + + /** * Immutable <i>surfaceSize, flags and refreshRate</i> Class, consisting of it's read only components:<br> * <ul> * <li>nativeId</li> @@ -141,7 +141,7 @@ public class MonitorMode implements Comparable<MonitorMode> { /** Vertical refresh rate */ public final float refreshRate; public final int hashCode; - + public SizeAndRRate(SurfaceSize surfaceSize, float refreshRate, int flags) { if(null==surfaceSize) { throw new IllegalArgumentException("surfaceSize must be set ("+surfaceSize+")"); @@ -151,11 +151,11 @@ public class MonitorMode implements Comparable<MonitorMode> { this.refreshRate=refreshRate; this.hashCode = getHashCode(); } - + private final static String STR_INTERLACE = "Interlace"; private final static String STR_DOUBLESCAN = "DoubleScan"; private final static String STR_SEP = ", "; - + public static final StringBuilder flags2String(int flags) { final StringBuilder sb = new StringBuilder(); boolean sp = false; @@ -175,11 +175,11 @@ public class MonitorMode implements Comparable<MonitorMode> { public final String toString() { return new String(surfaceSize+" @ "+refreshRate+" Hz, flags ["+flags2String(flags).toString()+"]"); } - + /** * <p> * Compares {@link SurfaceSize#compareTo(SurfaceSize) surfaceSize} 1st, then {@link #flags}, then {@link #refreshRate}. - * </p> + * </p> * <p> * Flags are compared as follows: * <pre> @@ -196,7 +196,7 @@ public class MonitorMode implements Comparable<MonitorMode> { final int rssz = surfaceSize.compareTo(sszr.surfaceSize); if( 0 != rssz ) { return rssz; - } + } final int tflags = 0 == flags ? Integer.MAX_VALUE : flags; // normalize NONE final int xflags = 0 == sszr.flags ? Integer.MAX_VALUE : sszr.flags; // normalize NONE if( tflags == xflags ) { @@ -218,9 +218,9 @@ public class MonitorMode implements Comparable<MonitorMode> { return 0; } } - + /** - * Tests equality of two {@link SizeAndRRate} objects + * Tests equality of two {@link SizeAndRRate} objects * by evaluating equality of it's components:<br/> * <ul> * <li><code>surfaceSize</code></li> @@ -238,7 +238,7 @@ public class MonitorMode implements Comparable<MonitorMode> { } return false; } - + /** * Returns a combined hash code of it's elements:<br/> * <ul> @@ -249,16 +249,16 @@ public class MonitorMode implements Comparable<MonitorMode> { */ public final int hashCode() { return hashCode; - } + } private final int getHashCode() { // 31 * x == (x << 5) - x int hash = 31 + surfaceSize.hashCode(); hash = ((hash << 5) - hash) + flags; hash = ((hash << 5) - hash) + (int)(refreshRate*100.0f); return hash; - } + } } - + /** zero rotation, compared to normal settings */ public static final int ROTATE_0 = 0; @@ -270,15 +270,15 @@ public class MonitorMode implements Comparable<MonitorMode> { /** 270 degrees CCW rotation */ public static final int ROTATE_270 = 270; - + /** Frame is split into two fields. See {@link #getFlags()}. */ public static final int FLAG_INTERLACE = 1 << 0; - + /** Lines are doubled. See {@link #getFlags()}. */ public static final int FLAG_DOUBLESCAN = 1 << 1; /** The immutable native Id of this instance, which may not be unique. */ - private final int nativeId; + private final int nativeId; private final SizeAndRRate sizeAndRRate; private final int rotation; private final int hashCode; @@ -301,7 +301,7 @@ public class MonitorMode implements Comparable<MonitorMode> { this.rotation = rotation; this.hashCode = getHashCode(); } - + /** * Creates a user instance w/o {@link #getId() identity} to filter our matching modes w/ identity. * <p> @@ -314,16 +314,16 @@ public class MonitorMode implements Comparable<MonitorMode> { */ public MonitorMode(SurfaceSize surfaceSize, float refreshRate, int flags, int rotation) { this(0, new SizeAndRRate(surfaceSize, refreshRate, flags), rotation); - } + } /** @return the immutable native Id of this mode, may not be unique, may be 0. */ public final int getId() { return nativeId; } - + /** Returns the <i>surfaceSize and refreshRate</i> instance. */ - public final SizeAndRRate getSizeAndRRate() { + public final SizeAndRRate getSizeAndRRate() { return sizeAndRRate; } - + /** Returns the unrotated {@link SurfaceSize} */ public final SurfaceSize getSurfaceSize() { return sizeAndRRate.surfaceSize; @@ -338,23 +338,23 @@ public class MonitorMode implements Comparable<MonitorMode> { public final int getFlags() { return sizeAndRRate.flags; } - + /** Returns the CCW rotation of this mode */ public final int getRotation() { return rotation; } - - /** Returns the rotated screen width, + + /** Returns the rotated screen width, * derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code> - * and <code>getRotation()</code> + * and <code>getRotation()</code> */ public final int getRotatedWidth() { return getRotatedWH(true); } - - /** Returns the rotated screen height, + + /** Returns the rotated screen height, * derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code> - * and <code>getRotation()</code> + * and <code>getRotation()</code> */ public final int getRotatedHeight() { return getRotatedWH(false); @@ -367,9 +367,9 @@ public class MonitorMode implements Comparable<MonitorMode> { /** * <p> * Compares {@link SizeAndRRate#compareTo(SizeAndRRate) sizeAndRRate} 1st, then {@link #rotation}. - * </p> + * </p> * <p> - * Rotation is compared inverted, i.e. <code>360 - rotation</code>, + * Rotation is compared inverted, i.e. <code>360 - rotation</code>, * so the lowest rotation reflects a higher value. * </p> * <p> @@ -380,7 +380,7 @@ public class MonitorMode implements Comparable<MonitorMode> { * <li>flags</li> * <li>refresh rate</li> * <li>rotation</li> - * </ul> + * </ul> * </p> * {@inheritDoc} */ @@ -399,9 +399,9 @@ public class MonitorMode implements Comparable<MonitorMode> { } return 0; } - + /** - * Tests equality of two {@link MonitorMode} objects + * Tests equality of two {@link MonitorMode} objects * by evaluating equality of it's components:<br/> * <ul> * <li><code>nativeId</code></li> @@ -438,7 +438,7 @@ public class MonitorMode implements Comparable<MonitorMode> { hash = ((hash << 5) - hash) + getRotation(); return hash; } - + private final int getRotatedWH(boolean width) { final DimensionImmutable d = sizeAndRRate.surfaceSize.getResolution(); final boolean swap = MonitorMode.ROTATE_90 == rotation || MonitorMode.ROTATE_270 == rotation ; @@ -446,5 +446,5 @@ public class MonitorMode implements Comparable<MonitorMode> { return d.getHeight(); } return d.getWidth(); - } + } } diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index e66b2f624..7116877a3 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt; @@ -53,16 +53,16 @@ public class NewtFactory { public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window"); public static final String DRIVER_DEFAULT_ROOT_PACKAGE = "jogamp.newt.driver"; - + static { AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { NativeWindowFactory.initSingleton(); // last resort .. - + // Work-around for initialization order problems on Mac OS X // between native Newt and (apparently) Fmod WindowImpl.init(NativeWindowFactory.getNativeWindowType(true)); - + return null; } } ); } @@ -75,7 +75,7 @@ public class NewtFactory { clazzName = DRIVER_DEFAULT_ROOT_PACKAGE + packageName + "." + classBaseName ; } else { clazzName = packageName + "." + classBaseName ; - } + } try { clazz = Class.forName(clazzName); } catch (Throwable t) { @@ -90,7 +90,7 @@ public class NewtFactory { private static boolean useEDT = true; - /** + /** * Toggles the usage of an EventDispatchThread while creating a Display.<br> * The default is enabled.<br> * The EventDispatchThread is thread local to the Display instance.<br> @@ -108,7 +108,7 @@ public class NewtFactory { * Native creation is lazily done at usage, ie. {@link Display#addReference()}. * </p> * <p> - * An already existing display connection of the same <code>name</code> will be reused. + * An already existing display connection of the same <code>name</code> will be reused. * </p> * @param name the display connection name which is a technical platform specific detail, * see {@link AbstractGraphicsDevice#getConnection()}. Use <code>null</code> for default. diff --git a/src/newt/classes/com/jogamp/newt/NewtVersion.java b/src/newt/classes/com/jogamp/newt/NewtVersion.java index 9adb7aac5..e70d63f88 100644 --- a/src/newt/classes/com/jogamp/newt/NewtVersion.java +++ b/src/newt/classes/com/jogamp/newt/NewtVersion.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,12 +20,12 @@ * 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 com.jogamp.newt; import com.jogamp.common.GlueGenVersion; diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index f56ee344b..1274b3459 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -39,7 +39,7 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; -/** +/** * A screen may span multiple {@link MonitorDevice}s representing their combined virtual size. */ public abstract class Screen { @@ -102,7 +102,7 @@ public abstract class Screen { /** * See {@link Display#addReference()} - * + * * @return number of references post operation * @throws NativeWindowException if the native creation failed. * @see #removeReference() @@ -113,7 +113,7 @@ public abstract class Screen { /** * See {@link Display#removeReference()} - * + * * @return number of references post operation * @see #addReference() * @see #setDestroyWhenUnused(boolean) @@ -132,12 +132,12 @@ public abstract class Screen { * @return the x position of the virtual viewport's top-left origin. */ public abstract int getX(); - + /** * @return the y position of the virtual viewport's top-left origin. */ public abstract int getY(); - + /** * @return the <b>rotated</b> virtual viewport's width. */ @@ -152,19 +152,19 @@ public abstract class Screen { * @return the <b>rotated</b> virtual viewport, i.e. origin and size. */ public abstract RectangleImmutable getViewport(); - + /** * @return the associated Display */ public abstract Display getDisplay(); - /** + /** * @return The screen fully qualified Screen name, * which is a key of {@link com.jogamp.newt.Display#getFQName()} + {@link #getIndex()}. */ public abstract String getFQName(); - /** + /** * Return a list of all {@link MonitorMode}s for all {@link MonitorDevice}s. * <p> * The list is ordered in descending order, @@ -173,23 +173,23 @@ public abstract class Screen { */ public abstract List<MonitorMode> getMonitorModes(); - /** + /** * Return a list of available {@link MonitorDevice}s. */ public abstract List<MonitorDevice> getMonitorDevices(); /** - * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} + * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} * {@link MonitorDevice#coverage(RectangleImmutable) covers} the given rectangle the most. * <p> - * If no coverage is detected the first {@link MonitorDevice} is returned. + * If no coverage is detected the first {@link MonitorDevice} is returned. * </p> */ public final MonitorDevice getMainMonitor(RectangleImmutable r) { MonitorDevice res = null; float maxCoverage = Float.MIN_VALUE; final List<MonitorDevice> monitors = getMonitorDevices(); - for(int i=monitors.size()-1; i>=0; i--) { + for(int i=monitors.size()-1; i>=0; i--) { final MonitorDevice monitor = monitors.get(i); final float coverage = monitor.coverage(r); if( coverage > maxCoverage ) { @@ -207,14 +207,14 @@ public abstract class Screen { * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport}. * <p> * Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()}, - * however, some native toolkits may choose a different virtual screen area. + * however, some native toolkits may choose a different virtual screen area. * </p> * @param result storage for result, will be returned */ public final Rectangle unionOfMonitorViewportSize(final Rectangle result) { return MonitorDevice.unionOfViewports(result, getMonitorDevices()); } - + /** * @param sml {@link MonitorModeListener} to be added for {@link MonitorEvent} */ @@ -274,7 +274,7 @@ public abstract class Screen { } return null; } - + protected static void addScreen2List(Screen screen) { synchronized(screenList) { // GC before add @@ -289,7 +289,7 @@ public abstract class Screen { screenList.add(new WeakReference<Screen>(screen)); } } - + /** Returns the global screen collection */ public static Collection<Screen> getAllScreens() { ArrayList<Screen> list; @@ -308,7 +308,7 @@ public abstract class Screen { } return list; } - + public static int getActiveScreenNumber() { synchronized(screenList) { return screensActive; diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 02727353f..04eb07a25 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -58,8 +58,8 @@ import javax.media.nativewindow.util.RectangleImmutable; * <li>... and more</li> * </ul> * <p> - * One use case is {@link com.jogamp.newt.opengl.GLWindow}, which delegates - * window operation to an instance of this interface while providing OpenGL + * One use case is {@link com.jogamp.newt.opengl.GLWindow}, which delegates + * window operation to an instance of this interface while providing OpenGL * functionality. * </p> */ @@ -90,14 +90,14 @@ public interface Window extends NativeWindow, WindowClosingProtocol { Screen getScreen(); /** - * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} + * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} * {@link MonitorDevice#coverage(RectangleImmutable) covers} this window the most. * <p> - * If no coverage is detected the first {@link MonitorDevice} is returned. + * If no coverage is detected the first {@link MonitorDevice} is returned. * </p> */ MonitorDevice getMainMonitor(); - + /** * Set the CapabilitiesChooser to help determine the native visual type. * @@ -129,7 +129,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * Visibility is set to false. * </p> * <p> - * Method sends out {@link WindowEvent#EVENT_WINDOW_DESTROY_NOTIFY pre-} and + * Method sends out {@link WindowEvent#EVENT_WINDOW_DESTROY_NOTIFY pre-} and * {@link WindowEvent#EVENT_WINDOW_DESTROYED post-} destruction events * to all of it's {@link WindowListener}. * </p> @@ -151,7 +151,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * Set a custom action handling destruction issued by a {@link WindowImpl#windowDestroyNotify(boolean) toolkit triggered window destroy} * replacing the default {@link #destroy()} action. * <p> - * The custom action shall call {@link #destroy()} + * The custom action shall call {@link #destroy()} * but may perform further tasks before and after. * </p> */ @@ -369,7 +369,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * @param x new top-level position, use -1 for default position. * @param y new top-level position, use -1 for default position. * @param forceDestroyCreate if true, uses re-creation strategy for reparenting, default is <code>false</code>. - * + * * @return The issued reparent action type (strategy) as defined in Window.ReparentAction * @see #reparentWindow(NativeWindow) */ @@ -378,7 +378,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Enable or disable fullscreen mode for this window. * <p> - * Fullscreen mode is established on the {@link #getMainMonitor() main monitor}. + * Fullscreen mode is established on the {@link #getMainMonitor() main monitor}. * </p> * @param fullscreen enable or disable fullscreen mode * @return success @@ -393,14 +393,14 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * <p> * Disable fullscreen via {@link #setFullscreen(boolean)}. * </p> - * @param monitors if <code>null</code> fullscreen will be spanned across all {@link MonitorDevice}s, + * @param monitors if <code>null</code> fullscreen will be spanned across all {@link MonitorDevice}s, * otherwise across the given list of {@link MonitorDevice}. * @return success * @see #setFullscreen(boolean) * @see #isFullscreen() */ boolean setFullscreen(List<MonitorDevice> monitors); - + boolean isFullscreen(); static interface FocusRunnable { @@ -429,7 +429,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * and to perform focus traversal with a 3rd party toolkit. * </p> * <p> - * The {@link KeyListener} methods are not invoked for {@link KeyEvent#isAutoRepeat() auto-repeat} events. + * The {@link KeyListener} methods are not invoked for {@link KeyEvent#isAutoRepeat() auto-repeat} events. * </p> * @param l */ @@ -469,7 +469,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Send a {@link WindowEvent} to all {@link WindowListener}. - * @param eventType a {@link WindowEvent} type, e.g. {@link WindowEvent#EVENT_WINDOW_REPAINT}. + * @param eventType a {@link WindowEvent} type, e.g. {@link WindowEvent#EVENT_WINDOW_REPAINT}. */ public void sendWindowEvent(int eventType); @@ -585,8 +585,8 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * Returns all {@link MouseListener} */ MouseListener[] getMouseListeners(); - - /** Enable or disable default {@link GestureHandler}. Default is enabled. */ + + /** Enable or disable default {@link GestureHandler}. Default is enabled. */ void setDefaultGesturesEnabled(boolean enable); /** Return true if default {@link GestureHandler} are enabled. */ boolean areDefaultGesturesEnabled(); @@ -627,5 +627,5 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Removes the given {@link GestureHandler.GestureListener} from the list. */ - void removeGestureListener(GestureHandler.GestureListener gl); + void removeGestureListener(GestureHandler.GestureListener gl); } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 13affdf49..de1b7224f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.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,12 +20,12 @@ * 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 com.jogamp.newt.awt; @@ -84,11 +84,11 @@ import com.jogamp.opengl.util.TileRenderer; /** * AWT {@link java.awt.Canvas Canvas} containing a NEWT {@link Window} using native parenting. - * + * * <h5><A NAME="java2dgl">Offscreen Layer Remarks</A></h5> - * + * * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} - * maybe called to use an offscreen drawable (FBO or PBuffer) allowing + * maybe called to use an offscreen drawable (FBO or PBuffer) allowing * the underlying JAWT mechanism to composite the image, if supported. */ @SuppressWarnings("serial") @@ -104,7 +104,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private AWTParentWindowAdapter awtAdapter = null; private AWTAdapter awtMouseAdapter = null; private AWTAdapter awtKeyAdapter = null; - + private AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { public void run() { @@ -115,7 +115,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( newtChild != null ) { newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); } - } + } } ); /** @@ -147,36 +147,36 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto super(gc); setNEWTChild(child); } - + public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; } - + public final boolean getShallUseOffscreenLayer() { - return shallUseOffscreenLayer; + return shallUseOffscreenLayer; } - - public final boolean isOffscreenLayerSurfaceEnabled() { + + public final boolean isOffscreenLayerSurfaceEnabled() { return jawtWindow.isOffscreenLayerSurfaceEnabled(); } - - /** - * Returns true if the AWT component is parented to an {@link java.applet.Applet}, - * otherwise false. This information is valid only after {@link #addNotify()} is issued, - * ie. before adding the component to the AWT tree and make it visible. + + /** + * Returns true if the AWT component is parented to an {@link java.applet.Applet}, + * otherwise false. This information is valid only after {@link #addNotify()} is issued, + * ie. before adding the component to the AWT tree and make it visible. */ public boolean isApplet() { return jawtWindow.isApplet(); } boolean isParent() { - return null!=newtChild && jawtWindow == newtChild.getParent(); + return null!=newtChild && jawtWindow == newtChild.getParent(); } - + boolean isFullscreen() { return null != newtChild && newtChild.isFullscreen(); } - + class FocusAction implements Window.FocusRunnable { public boolean run() { final boolean isParent = isParent(); @@ -199,7 +199,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } private FocusAction focusAction = new FocusAction(); - + WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { @Override public void windowResized(WindowEvent e) { @@ -224,15 +224,15 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto handleKey(e, true); } } - - void handleKey(KeyEvent evt, boolean onRelease) { + + void handleKey(KeyEvent evt, boolean onRelease) { if(null == keyboardFocusManager) { throw new InternalError("XXX"); } final AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke(evt.getKeyCode(), evt.getModifiers(), onRelease); boolean suppress = false; if(null != ks) { - final Set<AWTKeyStroke> fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); + final Set<AWTKeyStroke> fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); final Set<AWTKeyStroke> bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if(fwdKeys.contains(ks)) { final Component nextFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this, true /* forward */); @@ -253,38 +253,38 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } if(suppress) { - evt.setConsumed(true); + evt.setConsumed(true); } if(DEBUG) { System.err.println("NewtCanvasAWT.focusKey: XXX: "+ks); } } } - private final FocusTraversalKeyListener newtFocusTraversalKeyListener = new FocusTraversalKeyListener(); + private final FocusTraversalKeyListener newtFocusTraversalKeyListener = new FocusTraversalKeyListener(); class FocusPropertyChangeListener implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent evt) { final Object oldF = evt.getOldValue(); final Object newF = evt.getNewValue(); final boolean isParent = isParent(); - final boolean isFullscreen = isFullscreen(); + final boolean isFullscreen = isFullscreen(); if(DEBUG) { System.err.println("NewtCanvasAWT.FocusProperty: "+evt.getPropertyName()+", src "+evt.getSource()+", "+oldF+" -> "+newF+", isParent "+isParent+", isFS "+isFullscreen); } if(isParent && !isFullscreen) { if(newF == NewtCanvasAWT.this) { - if(DEBUG) { + if(DEBUG) { System.err.println("NewtCanvasAWT.FocusProperty: AWT focus -> NEWT focus traversal"); } requestFocusNEWTChild(); } else if(oldF == NewtCanvasAWT.this && newF == null) { // focus traversal to NEWT - NOP - if(DEBUG) { + if(DEBUG) { System.err.println("NewtCanvasAWT.FocusProperty: NEWT focus"); } } else if(null != newF && newF != NewtCanvasAWT.this) { // focus traversal to another AWT component - if(DEBUG) { + if(DEBUG) { System.err.println("NewtCanvasAWT.FocusProperty: lost focus - clear focus"); } if(newtChild.getDelegatedWindow() instanceof DriverClearFocus) { @@ -292,7 +292,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } - } + } } private final FocusPropertyChangeListener focusPropertyChangeListener = new FocusPropertyChangeListener(); private volatile KeyboardFocusManager keyboardFocusManager = null; @@ -300,7 +300,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final void requestFocusNEWTChild() { if(null!=newtChild) { newtChild.setFocusAction(null); - if(isOnscreen) { + if(isOnscreen) { KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); } newtChild.requestFocus(); @@ -308,17 +308,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } - /** + /** * Sets a new NEWT child, provoking reparenting. * <p> * A previously detached <code>newChild</code> will be released to top-level status - * and made invisible. + * and made invisible. * </p> * <p> - * Note: When switching NEWT child's, detaching the previous first via <code>setNEWTChild(null)</code> - * produced much cleaner visual results. + * Note: When switching NEWT child's, detaching the previous first via <code>setNEWTChild(null)</code> + * produced much cleaner visual results. * </p> - * @return the previous attached newt child. + * @return the previous attached newt child. */ public Window setNEWTChild(Window newChild) { final Window prevChild = newtChild; @@ -336,17 +336,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto updateLayoutSize(); // will be done later at paint/display/..: attachNewtChild(cont); - + return prevChild; } - + private final void updateLayoutSize() { if( null != newtChild ) { // use NEWT child's size for min/pref size! java.awt.Dimension minSize = new java.awt.Dimension(newtChild.getWidth(), newtChild.getHeight()); setMinimumSize(minSize); setPreferredSize(minSize); - } + } } /** @return the current NEWT child */ @@ -357,7 +357,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto /** @return this AWT Canvas NativeWindow representation, may be null in case {@link #removeNotify()} has been called, * or {@link #addNotify()} hasn't been called yet.*/ public NativeWindow getNativeWindow() { return jawtWindow; } - + public WindowClosingMode getDefaultCloseOperation() { return awtWindowClosingProtocol.getDefaultCloseOperation(); } @@ -373,16 +373,16 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } else { // before native peer is valid: X11 disableBackgroundErase(); - + // creates the native peer super.addNotify(); - + // after native peer is valid: Windows disableBackgroundErase(); - - jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); + + jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - + if(DEBUG) { // if ( isShowing() == false ) -> Container was not visible yet. // if ( isShowing() == true ) -> Container is already visible. @@ -397,7 +397,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void removeNotify() { awtWindowClosingProtocol.removeClosingListener(); - + if( Beans.isDesignTime() ) { super.removeNotify(); } else { @@ -419,7 +419,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto public final void destroy() { destroyImpl(false /* removeNotify */, false /* windowClosing */); } - + private final void destroyImpl(boolean removeNotify, boolean windowClosing) { if( null !=newtChild ) { java.awt.Container cont = AWTMisc.getContainer(this); @@ -427,7 +427,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.destroy(removeNotify "+removeNotify+", windowClosing "+windowClosing+"): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); } detachNewtChild(cont); - + if( !removeNotify ) { final Window cWin = newtChild; final Window dWin = cWin.getDelegatedWindow(); @@ -437,14 +437,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } else { cWin.destroy(); } - } + } } if( ( removeNotify || windowClosing ) && null!=jawtWindow ) { NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; - } + } } - + @Override public void paint(Graphics g) { if( validateComponent(true) && !printActive ) { @@ -469,9 +469,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } - + private volatile boolean printActive = false; - private GLAnimatorControl printAnimator = null; + private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @@ -481,15 +481,15 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } return null; } - + @Override public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { - printActive = true; + printActive = true; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); - } + } private final Runnable setupPrintOnEDT = new Runnable() { @Override public void run() { @@ -497,14 +497,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); } - printActive = false; + printActive = false; return; // not yet available .. } if( !isVisible() ) { if(DEBUG) { System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); } - printActive = false; + printActive = false; return; // not yet available .. } final GLAutoDrawable glad = getGLAD(); @@ -512,14 +512,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( DEBUG ) { System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); } - printActive = false; + printActive = false; return; } printAnimator = glad.getAnimator(); if( null != printAnimator ) { printAnimator.remove(glad); } - printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD + printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); @@ -527,7 +527,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); final boolean reqNewGLADOnscrn = caps.isOnscreen(); - + // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); @@ -546,8 +546,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto caps.setNumSamples(printNumSamples); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, - printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); @@ -634,7 +634,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("AWT print.X: "+printAWTTiles); } } - + private final boolean validateComponent(boolean attachNewtChild) { if( Beans.isDesignTime() || !isDisplayable() ) { return false; @@ -645,14 +645,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( 0 >= getWidth() || 0 >= getHeight() ) { return false; } - + if( attachNewtChild && !newtChildAttached && null != newtChild ) { attachNewtChild(); } return true; } - + private final void configureNewtChild(boolean attach) { if(null!=awtAdapter) { awtAdapter.removeFrom(this); @@ -670,13 +670,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); keyboardFocusManager = null; } - + if( null != newtChild ) { newtChild.setKeyboardFocusHandler(null); if(attach) { if(null == jawtWindow.getGraphicsConfiguration()) { throw new InternalError("XXX"); - } + } isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! @@ -733,13 +733,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.reparentWindow(jawtWindow); newtChild.addSurfaceUpdatedListener(jawtWindow); if( jawtWindow.isOffscreenLayerSurfaceEnabled() && - 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { + 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { AWTEDTExecutor.singleton.invoke(false, forceRelayout); } newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - + if(DEBUG) { System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } @@ -759,7 +759,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.forceRelayout.X"); } } }; - + private final void detachNewtChild(java.awt.Container cont) { if( null == newtChild || null == jawtWindow || !newtChildAttached ) { return; // nop @@ -773,14 +773,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto ", cont "+cont); } - newtChild.removeSurfaceUpdatedListener(jawtWindow); + newtChild.removeSurfaceUpdatedListener(jawtWindow); newtChildAttached = false; newtChild.setFocusAction(null); // no AWT focus traversal .. configureNewtChild(false); newtChild.setVisible(false); - + newtChild.reparentWindow(null); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer - + if(DEBUG) { System.err.println("NewtCanvasAWT.detachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } @@ -837,7 +837,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } protected static String getThreadName() { return Thread.currentThread().getName(); } - + static String newtWinHandleToHexString(Window w) { return null != w ? toHexString(w.getWindowHandle()) : "nil"; } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index c7153840f..9b1b82297 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -47,12 +47,12 @@ import jogamp.nativewindow.jawt.JAWTUtil; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; -/** +/** * Simple GLEventListener deployment as an applet using JOGL. This demo must be * referenced from a web page via an <applet> tag. - * + * * <p> - * Example of an applet tag using GearsES2 within the applet area (normal case): + * Example of an applet tag using GearsES2 within the applet area (normal case): * <pre> <applet width=100 height=100> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> @@ -65,9 +65,9 @@ import com.jogamp.newt.opengl.GLWindow; </applet>Hello Gears ! * </pre> * </p> - * + * * <p> - * Example of an applet tag using GearsES2 in an undecorated, translucent, closeable and always-on-top window: + * Example of an applet tag using GearsES2 in an undecorated, translucent, closeable and always-on-top window: * <pre> <applet width=1 height=1> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> @@ -95,12 +95,12 @@ import com.jogamp.newt.opengl.GLWindow; @SuppressWarnings("serial") public class JOGLNewtApplet1Run extends Applet { public static final boolean DEBUG = JOGLNewtAppletBase.DEBUG; - + GLWindow glWindow = null; NewtCanvasAWT newtCanvasAWT = null; JOGLNewtAppletBase base = null; /** if valid glStandalone:=true (own window) ! */ - int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; + int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; public void init() { if(DEBUG) { @@ -135,7 +135,7 @@ public class JOGLNewtApplet1Run extends Applet { glCloseable = JOGLNewtAppletBase.str2Bool(getParameter("gl_closeable"), glCloseable); glOpaque = JOGLNewtAppletBase.str2Bool(getParameter("gl_opaque"), glOpaque); glAlphaBits = JOGLNewtAppletBase.str2Int(getParameter("gl_alpha"), glAlphaBits); - glNumMultisampleBuffer = JOGLNewtAppletBase.str2Int(getParameter("gl_multisamplebuffer"), glNumMultisampleBuffer); + glNumMultisampleBuffer = JOGLNewtAppletBase.str2Int(getParameter("gl_multisamplebuffer"), glNumMultisampleBuffer); glXd = JOGLNewtAppletBase.str2Int(getParameter("gl_dx"), glXd); glYd = JOGLNewtAppletBase.str2Int(getParameter("gl_dy"), glYd); glWidth = JOGLNewtAppletBase.str2Int(getParameter("gl_width"), glWidth); @@ -168,8 +168,8 @@ public class JOGLNewtApplet1Run extends Applet { System.err.println("glNumMultisampleBuffer: "+glNumMultisampleBuffer); System.err.println("glNoDefaultKeyListener: "+glNoDefaultKeyListener); } - - base = new JOGLNewtAppletBase(glEventListenerClazzName, + + base = new JOGLNewtAppletBase(glEventListenerClazzName, glSwapInterval, glNoDefaultKeyListener, glCloseable, @@ -252,9 +252,9 @@ public class JOGLNewtApplet1Run extends Applet { System.err.println("GLWindow: "+glWindow); } base.start(); - if( null != newtCanvasAWT && + if( null != newtCanvasAWT && newtCanvasAWT.isOffscreenLayerSurfaceEnabled() && - 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { + 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { // force relayout final int cW = newtCanvasAWT.getWidth(); final int cH = newtCanvasAWT.getHeight(); diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 1004adb8e..a6a30a8bf 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -57,7 +57,7 @@ import com.jogamp.opengl.util.Animator; public class JOGLNewtAppletBase implements KeyListener, GLEventListener { public static final boolean DEBUG = Debug.debug("Applet"); - + String glEventListenerClazzName; int glSwapInterval; boolean noDefaultKeyListener; @@ -71,13 +71,13 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { boolean isValid = false; NativeWindow awtParent; - public JOGLNewtAppletBase(String glEventListenerClazzName, + public JOGLNewtAppletBase(String glEventListenerClazzName, int glSwapInterval, boolean noDefaultKeyListener, boolean glClosable, boolean glDebug, boolean glTrace) { - + this.glEventListenerClazzName=glEventListenerClazzName; this.glSwapInterval=glSwapInterval; this.noDefaultKeyListener = noDefaultKeyListener; @@ -174,8 +174,8 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.reparentWindow(awtParent); } } - }).start(); - } + }).start(); + } } } } ); @@ -203,7 +203,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { if(glEventListener instanceof KeyListener) { glWindow.addKeyListener((KeyListener)glEventListener); } - + if(!noDefaultKeyListener) { glWindow.addKeyListener(this); } @@ -216,7 +216,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glAnimator.setThreadGroup(tg); glAnimator.add(glWindow); glAnimator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, null); - + } catch (Throwable t) { throw new RuntimeException(t); } @@ -262,14 +262,14 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { if(glDebug) { try { _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, _gl, null) ); - } catch (Exception e) {e.printStackTrace();} + } catch (Exception e) {e.printStackTrace();} } if(glTrace) { try { // Trace .. _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, _gl, new Object[] { System.err } ) ); - } catch (Exception e) {e.printStackTrace();} + } catch (Exception e) {e.printStackTrace();} } if(glSwapInterval>=0) { @@ -317,9 +317,9 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { } } } - + @Override - public void keyReleased(KeyEvent e) { + public void keyReleased(KeyEvent e) { } } diff --git a/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java index bc67cbee6..7dda47534 100644 --- a/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java +++ b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java @@ -41,15 +41,15 @@ import jogamp.newt.Debug; * * - touchSlop (scaled in pixels): * - Min. movement w/ 2 pointer within ScaledDoubleTapSlop starting 'scroll' mode - * + * * - Avoid computation if not within gesture, especially for MOVE/DRAG - * + * * - Only allow gesture to start with PRESS - * - * - Leave gesture completely with RELEASE of both/all fingers, or dist-diff exceeds doubleTapSlop - * + * + * - Leave gesture completely with RELEASE of both/all fingers, or dist-diff exceeds doubleTapSlop + * * - Tolerate temporary lift 1 of 2 pointer - * + * * - Always validate pointer-id * </pre> * </p> @@ -74,27 +74,27 @@ public class DoubleTapScrollGesture implements GestureHandler { public static final int SCROLL_SLOP_PIXEL; /** Two pointer 'double tap' slop in pixels (fallback), defaults to 104 pixels. Can be overriden by integer property <code>newt.event.double_tap_slop_pixel</code>.*/ public static final int DOUBLE_TAP_SLOP_PIXEL; - + /** Scroll threshold in millimeter, defaults to 3 mm. Can be overriden by integer property <code>newt.event.scroll_slop_mm</code>.*/ public static final float SCROLL_SLOP_MM; /** Two pointer 'double tap' slop in millimeter, defaults to 20 mm. Can be overriden by integer property <code>newt.event.double_tap_slop_mm</code>.*/ public static final float DOUBLE_TAP_SLOP_MM; - + static { Debug.initSingleton(); - + SCROLL_SLOP_PIXEL = Debug.getIntProperty("newt.event.scroll_slop_pixel", true, 16); DOUBLE_TAP_SLOP_PIXEL = Debug.getIntProperty("newt.event.double_tap_slop_pixel", true, 104); SCROLL_SLOP_MM = Debug.getIntProperty("newt.event.scroll_slop_mm", true, 3); DOUBLE_TAP_SLOP_MM = Debug.getIntProperty("newt.event.double_tap_slop_mm", true, 20); } - + private static final int ST_NONE = 0; private static final int ST_1PRESS = 1; private static final int ST_2PRESS_T = 2; private static final int ST_2PRESS_C = 3; private static final int ST_SCROLL = 4; - + private final int scrollSlop, scrollSlopSquare, doubleTapSlop, doubleTapSlopSquare; private final float[] scrollDistance = new float[] { 0f, 0f }; private int[] pIds = new int[] { -1, -1 }; @@ -104,18 +104,18 @@ public class DoubleTapScrollGesture implements GestureHandler { private int lastX, lastY; private int pointerDownCount; private MouseEvent hitGestureEvent; - + private static final int getSquareDistance(float x1, float y1, float x2, float y2) { final int deltaX = (int) x1 - (int) x2; final int deltaY = (int) y1 - (int) y2; return deltaX * deltaX + deltaY * deltaY; } - + private int gesturePointers(final MouseEvent e, final int excludeIndex) { - int j = 0; + int j = 0; for(int i=e.getPointerCount()-1; i>=0; i--) { if( excludeIndex != i ) { - final int id = e.getPointerId(i); + final int id = e.getPointerId(i); if( pIds[0] == id || pIds[1] == id ) { j++; } @@ -123,10 +123,10 @@ public class DoubleTapScrollGesture implements GestureHandler { } return j; } - + /** * scaledScrollSlop < scaledDoubleTapSlop - * @param scaledScrollSlop Distance a pointer can wander before we think the user is scrolling in <i>pixels</i>. + * @param scaledScrollSlop Distance a pointer can wander before we think the user is scrolling in <i>pixels</i>. * @param scaledDoubleTapSlop Distance in <i>pixels</i> between the first touch and second touch to still be considered a double tap. */ public DoubleTapScrollGesture(int scaledScrollSlop, int scaledDoubleTapSlop) { @@ -137,9 +137,9 @@ public class DoubleTapScrollGesture implements GestureHandler { pointerDownCount = 0; clear(true); if(DEBUG) { - System.err.println("DoubleTapScroll scrollSlop (scaled) "+scrollSlop); - System.err.println("DoubleTapScroll doubleTapSlop (scaled) "+doubleTapSlop); - } + System.err.println("DoubleTapScroll scrollSlop (scaled) "+scrollSlop); + System.err.println("DoubleTapScroll doubleTapSlop (scaled) "+doubleTapSlop); + } } public String toString() { @@ -160,17 +160,17 @@ public class DoubleTapScrollGesture implements GestureHandler { lastY = 0; } } - + @Override public boolean isWithinGesture() { return ST_2PRESS_C <= gestureState; } - + @Override public boolean hasGesture() { return null != hitGestureEvent; } - + @Override public InputEvent getGestureEvent() { if( null != hitGestureEvent ) { @@ -184,17 +184,17 @@ public class DoubleTapScrollGesture implements GestureHandler { modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; } return new MouseEvent(MouseEvent.EVENT_MOUSE_WHEEL_MOVED, ge.getSource(), ge.getWhen(), modifiers, - ge.getAllPointerTypes(), ge.getAllPointerIDs(), - ge.getAllX(), ge.getAllY(), ge.getAllPressures(), ge.getMaxPressure(), + ge.getAllPointerTypes(), ge.getAllPointerIDs(), + ge.getAllX(), ge.getAllY(), ge.getAllPressures(), ge.getMaxPressure(), ge.getButton(), ge.getClickCount(), rotationXYZ, scrollSlop); } return null; } - + public final float[] getScrollDistanceXY() { return scrollDistance; } - + @Override public boolean process(final InputEvent in) { if( null != hitGestureEvent || !(in instanceof MouseEvent) ) { @@ -220,7 +220,7 @@ public class DoubleTapScrollGesture implements GestureHandler { final int y1 = pe.getY(1); final int xm = (x0+x1)/2; final int ym = (y0+y1)/2; - + if( ST_1PRESS == gestureState ) { final int sqDist = getSquareDistance(x0, y0, x1, y1); final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; @@ -254,7 +254,7 @@ public class DoubleTapScrollGesture implements GestureHandler { System.err.println(this+".pressed: gPtr "+gPtr+", this "+lastX+"/"+lastY+", "+pe); } } break; - + case MouseEvent.EVENT_MOUSE_RELEASED: { pointerDownCount--; // lifted final int gPtr = gesturePointers(pe, 0); // w/o lifted pointer @@ -269,7 +269,7 @@ public class DoubleTapScrollGesture implements GestureHandler { System.err.println(this+".released: gPtr "+gPtr+", "+pe); } } break; - + case MouseEvent.EVENT_MOUSE_DRAGGED: { if( 2 == pointerDownCount && ST_1PRESS < gestureState ) { final int gPtr = gesturePointers(pe, -1); @@ -289,11 +289,11 @@ public class DoubleTapScrollGesture implements GestureHandler { gestureState = ST_SCROLL; } } break; - + case ST_2PRESS_C: gestureState = ST_SCROLL; break; - + case ST_SCROLL: scrollDistance[0] = lastX - xm; scrollDistance[1] = lastY - ym; @@ -338,7 +338,7 @@ public class DoubleTapScrollGesture implements GestureHandler { } } } break; - + default: } return null != hitGestureEvent; diff --git a/src/newt/classes/com/jogamp/newt/event/GestureHandler.java b/src/newt/classes/com/jogamp/newt/event/GestureHandler.java index 2c8f29bb7..2e98a8a01 100644 --- a/src/newt/classes/com/jogamp/newt/event/GestureHandler.java +++ b/src/newt/classes/com/jogamp/newt/event/GestureHandler.java @@ -30,7 +30,7 @@ package com.jogamp.newt.event; import jogamp.newt.Debug; /** - * Generic gesture handler interface designed to allow pass-through + * Generic gesture handler interface designed to allow pass-through * filtering of {@link InputEvent}s. * <p> * To avoid negative impact on event processing, @@ -44,18 +44,18 @@ import jogamp.newt.Debug; */ public interface GestureHandler { public static final boolean DEBUG = Debug.debug("Window.MouseEvent"); - + /** A custom gesture event */ @SuppressWarnings("serial") public static class GestureEvent extends InputEvent { /** A gesture has been detected. */ public static final short EVENT_GESTURE_DETECTED = 400; - + private final GestureHandler handler; - + /** * Creates a gesture event with default type {@link #EVENT_GESTURE_DETECTED}. - * + * * @param source * @param when * @param modifiers @@ -65,7 +65,7 @@ public interface GestureHandler { super(EVENT_GESTURE_DETECTED, source, when, modifiers); this.handler = handler; } - + /** * Creates a gesture event with custom <i>event_type</i> ! * @param event_type must lie within [400..599] @@ -78,14 +78,14 @@ public interface GestureHandler { super(event_type, source, when, modifiers); this.handler = handler; } - + /** Return the {@link GestureHandler}, which produced the event. */ public final GestureHandler getHandler() { return handler; } } - + /** * Listener for {@link GestureEvent}s. - * + * * @see GestureEvent */ public static interface GestureListener extends NEWTEventListener @@ -93,50 +93,50 @@ public interface GestureHandler { /** {@link GestureHandler} {@link GestureHandler#hasGesture() has detected} the gesture. */ public void gestureDetected(GestureEvent gh); } - - /** - * Clears state of handler, i.e. resets all states incl. previous detected gesture. + + /** + * Clears state of handler, i.e. resets all states incl. previous detected gesture. * @param clearStarted if true, also clears {@link #isWithinGesture() started} state, * otherwise stay within gesture - if appropriate. - * Staying within a gesture allows fluent continuous gesture sequence, - * e.g. for scrolling. + * Staying within a gesture allows fluent continuous gesture sequence, + * e.g. for scrolling. */ public void clear(boolean clearStarted); - - /** + + /** * Returns true if a previous {@link #process(InputEvent)} command produced a gesture, - * which has not been {@link #clear(boolean) cleared}. + * which has not been {@link #clear(boolean) cleared}. * Otherwise returns false. - */ + */ public boolean hasGesture(); - - /** + + /** * Returns the corresponding {@link InputEvent} for the gesture as detected by * a previous {@link #process(InputEvent)}, which has not been {@link #clear(boolean) cleared}. * Otherwise returns null. * <p> * Only implemented for gestures mapping to {@link InputEvent}s. - * </p> - */ + * </p> + */ public InputEvent getGestureEvent(); - - /** + + /** * Returns true if within a gesture as detected by a previous {@link #process(InputEvent)} command, - * which has not been {@link #clear(boolean) cleared}. + * which has not been {@link #clear(boolean) cleared}. * Otherwise returns false. - */ + */ public boolean isWithinGesture(); /** * Process the given {@link InputEvent} and returns true if it produced the gesture. * Otherwise returns false. * <p> - * If a gesture was already detected previously and has not been cleared, - * method does not process the event and returns true. + * If a gesture was already detected previously and has not been cleared, + * method does not process the event and returns true. * </p> * <p> - * Besides validation of the event's details, - * the handler may also validate the {@link InputEvent.InputClass} and/or {@link InputEvent.InputType}. + * Besides validation of the event's details, + * the handler may also validate the {@link InputEvent.InputClass} and/or {@link InputEvent.InputType}. * </p> */ public boolean process(InputEvent e); diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 1bd67efa5..6520dafcf 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt.event; @@ -43,17 +43,17 @@ public abstract class InputEvent extends NEWTEvent /** Interface marking class of input types */ public static interface InputClass { } - + /** Interface marking type of input devices */ public static interface InputType { } - + public static final int SHIFT_MASK = 1 << 0; public static final int CTRL_MASK = 1 << 1; public static final int META_MASK = 1 << 2; public static final int ALT_MASK = 1 << 3; public static final int ALT_GRAPH_MASK = 1 << 4; - + public static final int BUTTON1_MASK = 1 << 5; public static final int BUTTON2_MASK = 1 << 6; public static final int BUTTON3_MASK = 1 << 7; @@ -63,23 +63,23 @@ public abstract class InputEvent extends NEWTEvent public static final int BUTTON7_MASK = 1 << 11; public static final int BUTTON8_MASK = 1 << 12; public static final int BUTTON9_MASK = 1 << 13; - + public static final int BUTTONLAST_MASK = 1 << 20; // 16 buttons public static final int BUTTONALL_MASK = 0xffff << 5 ; // 16 buttons - + /** Event is caused by auto-repeat. */ public static final int AUTOREPEAT_MASK = 1 << 29; - + /** Pointer is confined, see {@link Window#confinePointer(boolean)}. */ public static final int CONFINED_MASK = 1 << 30; - + /** Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ public static final int INVISIBLE_MASK = 1 << 31; - /** + /** * Returns the corresponding button mask for the given button. * <p> - * In case the given button lies outside + * In case the given button lies outside * of the valid range [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON_COUNT}], * null is returned. * </p> @@ -90,7 +90,7 @@ public abstract class InputEvent extends NEWTEvent } return 0; } - + protected InputEvent(short eventType, Object source, long when, int modifiers) { super(eventType, source, when); this.modifiers=modifiers; @@ -128,11 +128,11 @@ public abstract class InputEvent extends NEWTEvent public boolean isConfined() { return (modifiers&CONFINED_MASK)!=0; } - /** {@link #getModifiers()} contains {@link #INVISIBLE_MASK}. Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ + /** {@link #getModifiers()} contains {@link #INVISIBLE_MASK}. Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ public boolean isInvisible() { return (modifiers&INVISIBLE_MASK)!=0; } - + public StringBuilder getModifiersString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); @@ -141,7 +141,7 @@ public abstract class InputEvent extends NEWTEvent boolean isFirst = true; if(isShiftDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("shift"); } if(isControlDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("ctrl"); } - if(isMetaDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("meta"); } + if(isMetaDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("meta"); } if(isAltDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("alt"); } if(isAltGraphDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("altgr"); } if(isAutoRepeat()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("repeat"); } @@ -151,18 +151,18 @@ public abstract class InputEvent extends NEWTEvent if(isConfined()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("confined"); } if(isInvisible()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("invisible"); } sb.append("]"); - + return sb; } /** * See also {@link MouseEvent}'s section about <i>Multiple-Pointer Events</i>. - * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}]. + * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}]. * If none is down, the resulting array is of length 0. */ public final short[] getButtonsDown() { final int len = getButtonDownCount(); - + final short[] res = new short[len]; int j = 0; for(int i=1; i<=MouseEvent.BUTTON_COUNT; i++) { @@ -174,13 +174,13 @@ public abstract class InputEvent extends NEWTEvent /** * See also {@link MouseEvent}'s section about <i>Multiple-Pointer Events</i>. * @param button the button to test - * @return true if the given button is down + * @return true if the given button is down */ public final boolean isButtonDown(int button) { return ( modifiers & getButtonMask(button) ) != 0; } - /** + /** * Returns the number of pressed buttons by counting the set bits: * <pre> * getBitCount(modifiers & BUTTONALL_MASK); @@ -194,8 +194,8 @@ public abstract class InputEvent extends NEWTEvent public final int getButtonDownCount() { return IntBitfield.getBitCount(modifiers & BUTTONALL_MASK); } - - /** + + /** * Returns true if at least one button is pressed, otherwise false: * <pre> * 0 != ( modifiers & BUTTONALL_MASK ) @@ -209,11 +209,11 @@ public abstract class InputEvent extends NEWTEvent public final boolean isAnyButtonDown() { return 0 != ( modifiers & BUTTONALL_MASK ); } - + public String toString() { return toString(null).toString(); } - + public StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); diff --git a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java index 42ebea722..a89148574 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java @@ -4,14 +4,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 @@ -21,12 +21,12 @@ * 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 com.jogamp.newt.event; public abstract class KeyAdapter implements KeyListener diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 085f598dc..81680bf32 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt.event; @@ -37,8 +37,8 @@ package com.jogamp.newt.event; import com.jogamp.common.util.IntBitfield; /** - * <a name="eventDelivery"><h5>KeyEvent Delivery</h5></a> - * + * <a name="eventDelivery"><h5>KeyEvent Delivery</h5></a> + * * Key events are delivered in the following order: * <p> * <table border="0"> @@ -48,10 +48,10 @@ import com.jogamp.common.util.IntBitfield; * </table> * </p> * In case the native platform does not - * deliver keyboard events in the above order or skip events, - * the NEWT driver will reorder and inject synthetic events if required. + * deliver keyboard events in the above order or skip events, + * the NEWT driver will reorder and inject synthetic events if required. * <p> - * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., + * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected, following above constraints. * </p> * <p> @@ -60,38 +60,38 @@ import com.jogamp.common.util.IntBitfield; P = pressed, R = released 0 = normal, 1 = auto-repeat - P(0), [ R(1), P(1), R(1), ..], R(0) + P(0), [ R(1), P(1), R(1), ..], R(0) * </pre> * The idea is if you mask out auto-repeat in your event listener * you just get one long pressed P/R tuple for {@link #isPrintableKey() printable} and {@link #isActionKey() Action} keys. * </p> * <p> - * {@link #isActionKey() Action} keys will produce {@link #EVENT_KEY_PRESSED pressed} + * {@link #isActionKey() Action} keys will produce {@link #EVENT_KEY_PRESSED pressed} * and {@link #EVENT_KEY_RELEASED released} events including {@link #isAutoRepeat() auto-repeat}. * </p> * <p> * {@link #isPrintableKey() Printable} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events. * </p> * <p> - * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events + * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events * excluding {@link #isAutoRepeat() auto-repeat}. * They will also influence subsequent event's {@link #getModifiers() modifier} bits while pressed. * </p> - * + * * <a name="unicodeMapping"><h5>Unicode Mapping</h5></a> * <p> - * {@link #getKeyChar() Key-chars}, as well as + * {@link #getKeyChar() Key-chars}, as well as * {@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols} - * use the UTF-16 unicode space w/o collision. - * + * use the UTF-16 unicode space w/o collision. + * * </p> * <p> - * Non-{@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols}, + * Non-{@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols}, * i.e. {@link #isModifierKey() modifier-} and {@link #isActionKey() action-}keys, * are mapped to unicode's control and private range and do not collide w/ {@link #isPrintableKey() printable} unicode values * with the following exception. * </p> - * + * * <a name="unicodeCollision"><h5>Unicode Collision</h5></a> * <p> * The following {@link #getKeyCode() Key-code}s and {@link #getKeySymbol() key-symbol}s collide w/ unicode space:<br/> @@ -103,9 +103,9 @@ import com.jogamp.common.util.IntBitfield; * <p> * Collision was chosen for {@link #getKeyCode() Key-code} and {@link #getKeySymbol() key-symbol} mapping * to allow a minimal code range, i.e. <code>[0..255]</code>. - * The reduced code range in turn allows the implementation to utilize fast and small lookup tables, - * e.g. to implement a key-press state tracker. - * </p> + * The reduced code range in turn allows the implementation to utilize fast and small lookup tables, + * e.g. to implement a key-press state tracker. + * </p> * <pre> * http://www.utf8-chartable.de/unicode-utf8-table.pl * http://www.unicode.org/Public/5.1.0/ucd/PropList.txt @@ -136,7 +136,7 @@ public class KeyEvent extends InputEvent } } flags = _flags; - + // // Validate flags // @@ -147,12 +147,12 @@ public class KeyEvent extends InputEvent } } } - + public static KeyEvent create(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) { return new KeyEvent(eventType, source, when, modifiers, keyCode, keySym, getModifierMask(keySym), keyChar); } - /** + /** * Returns the <i>UTF-16</i> character reflecting the {@link #getKeySymbol() key symbol} * incl. active {@link #isModifierKey() modifiers}. * @see #getKeySymbol() @@ -162,12 +162,12 @@ public class KeyEvent extends InputEvent return keyChar; } - /** + /** * Returns the virtual <i>key symbol</i> reflecting the current <i>keyboard layout</i>. * <p> * For {@link #isPrintableKey() printable keys}, the <i>key symbol</i> is the {@link #isModifierKey() unmodified} - * representation of the UTF-16 {@link #getKeyChar() key char}.<br/> - * E.g. symbol [{@link #VK_A}, 'A'] for char 'a'. + * representation of the UTF-16 {@link #getKeyChar() key char}.<br/> + * E.g. symbol [{@link #VK_A}, 'A'] for char 'a'. * </p> * @see #isPrintableKey() * @see #getKeyChar() @@ -176,18 +176,18 @@ public class KeyEvent extends InputEvent public final short getKeySymbol() { return keySym; } - - /** + + /** * Returns the virtual <i>key code</i> using a fixed mapping to the <i>US keyboard layout</i>. * <p> - * In contrast to {@link #getKeySymbol() key symbol}, <i>key code</i> - * uses a fixed <i>US keyboard layout</i> and therefore is keyboard layout independent. + * In contrast to {@link #getKeySymbol() key symbol}, <i>key code</i> + * uses a fixed <i>US keyboard layout</i> and therefore is keyboard layout independent. * </p> * <p> - * E.g. <i>virtual key code</i> {@link #VK_Y} denotes the same physical key - * regardless whether <i>keyboard layout</i> <code>QWERTY</code> or + * E.g. <i>virtual key code</i> {@link #VK_Y} denotes the same physical key + * regardless whether <i>keyboard layout</i> <code>QWERTY</code> or * <code>QWERTZ</code> is active. The {@link #getKeySymbol() key symbol} of the former is - * {@link #VK_Y}, where the latter produces {@link #VK_Y}. + * {@link #VK_Y}, where the latter produces {@link #VK_Y}. * </p> * @see #getKeyChar() * @see #getKeySymbol() @@ -228,9 +228,9 @@ public class KeyEvent extends InputEvent } return (short) keyChar; } - - /** - * Returns <code>true</code> if the given <code>virtualKey</code> represents a modifier key, otherwise <code>false</code>. + + /** + * Returns <code>true</code> if the given <code>virtualKey</code> represents a modifier key, otherwise <code>false</code>. * <p> * A modifier key is one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. * </p> @@ -247,10 +247,10 @@ public class KeyEvent extends InputEvent return false; } } - + /** * If <code>vKey</code> is a {@link #isModifierKey() modifier key}, method returns the corresponding modifier mask, - * otherwise 0. + * otherwise 0. */ public static int getModifierMask(short vKey) { switch (vKey) { @@ -266,10 +266,10 @@ public class KeyEvent extends InputEvent } return 0; } - - /** + + /** * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a modifier key, - * otherwise <code>false</code>. + * otherwise <code>false</code>. * <p> * See {@link #isModifierKey(short)} for details. * </p> @@ -280,8 +280,8 @@ public class KeyEvent extends InputEvent public final boolean isModifierKey() { return 0 != ( F_MODIFIER_MASK & flags ) ; } - - /** + + /** * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a non-printable and * non-{@link #isModifierKey(short) modifier} action key, otherwise <code>false</code>. * <p> @@ -289,12 +289,12 @@ public class KeyEvent extends InputEvent * <code> A = U - ( P + M ) </code> * </p> * @see #isPrintableKey() - * @see #isModifierKey() + * @see #isModifierKey() */ public final boolean isActionKey() { return 0 != ( F_ACTION_MASK & flags ) ; } - + /** * Returns <code>true</code> if given <code>uniChar</code> represents a printable character, * i.e. a value other than {@link #VK_UNDEFINED} and not a control or non-printable private code. @@ -307,7 +307,7 @@ public class KeyEvent extends InputEvent * <p> * Distinction of key character and virtual key code is made due to <a href="#unicodeCollision">unicode collision</a>. * </p> - * + * * @param uniChar the UTF-16 unicode value, which maybe a virtual key code or key character. * @param isKeyChar true if <code>uniChar</code> is a key character, otherwise a virtual key code */ @@ -333,9 +333,9 @@ public class KeyEvent extends InputEvent return VK_UNDEFINED != uniChar; } - /** - * Returns <code>true</code> if {@link #getKeySymbol() key symbol} and {@link #getKeyChar() key char} - * represents a printable character, i.e. a value other than {@link #VK_UNDEFINED} + /** + * Returns <code>true</code> if {@link #getKeySymbol() key symbol} and {@link #getKeyChar() key char} + * represents a printable character, i.e. a value other than {@link #VK_UNDEFINED} * and not a control or non-printable private code. * <p> * A printable character is neither a {@link #isModifierKey(short) modifier key}, nor an {@link #isActionKey(short) action key}. @@ -347,7 +347,7 @@ public class KeyEvent extends InputEvent public final boolean isPrintableKey() { return 0 != ( F_PRINTABLE_MASK & flags ) ; } - + private final short keyCode; private final short keySym; private final char keyChar; @@ -370,7 +370,7 @@ public class KeyEvent extends InputEvent public static class NonPrintableRange { /** min. unicode value, inclusive */ - public short min; + public short min; /** max. unicode value, inclusive */ public short max; /** true if valid for keyChar values as well, otherwise only valid for keyCode and keySym due to collision. */ @@ -381,7 +381,7 @@ public class KeyEvent extends InputEvent this.inclKeyChar = inclKeyChar; } }; - /** + /** * Non printable key ranges, currently fixed to an array of size 4. * <p> * Not included, queried upfront: @@ -390,98 +390,98 @@ public class KeyEvent extends InputEvent * <li>{@link #VK_TAB}</li> * <li>{@link #VK_ENTER}</li> * </ul> - * </p> + * </p> */ - public final static NonPrintableRange[] nonPrintableKeys = { + public final static NonPrintableRange[] nonPrintableKeys = { new NonPrintableRange( (short)0x0000, (short)0x001F, true ), // Unicode: Non printable controls: [0x00 - 0x1F], see exclusion above new NonPrintableRange( (short)0x0061, (short)0x0078, false), // Small 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym - Re-used for Fn (collision) - new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable! + new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable! new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) }; - + // // Unicode: Non printable controls: [0x00 - 0x1F] // - + /** * This value, {@value}, is used to indicate that the keyCode is unknown. */ public static final short VK_UNDEFINED = (short) 0x0; - + static final short VK_FREE01 = (short) 0x01; - + /** Constant for the HOME function key. ASCII: Start Of Text. */ public static final short VK_HOME = (short) 0x02; - + /** Constant for the END function key. ASCII: End Of Text. */ public static final short VK_END = (short) 0x03; - + /** Constant for the END function key. ASCII: End Of Transmission. */ public static final short VK_FINAL = (short) 0x04; /** Constant for the PRINT function key. ASCII: Enquiry. */ public static final short VK_PRINTSCREEN = (short) 0x05; - + static final short VK_FREE06 = (short) 0x06; static final short VK_FREE07 = (short) 0x07; - + /** Constant for the BACK SPACE key "\b", matching ASCII. Printable! */ public static final short VK_BACK_SPACE = (short) 0x08; - + /** Constant for the HORIZ TAB key "\t", matching ASCII. Printable! */ public static final short VK_TAB = (short) 0x09; - + /** LINE_FEED "\n", matching ASCII, n/a on keyboard. */ static final short VK_FREE0A = (short) 0x0A; - + /** Constant for the PAGE DOWN function key. ASCII: Vertical Tabulation. */ public static final short VK_PAGE_DOWN = (short) 0x0B; - + /** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */ public static final short VK_CLEAR = (short) 0x0C; - + /** Constant for the ENTER key, i.e. CARRIAGE RETURN, matching ASCII. Printable! */ public static final short VK_ENTER = (short) 0x0D; - + static final short VK_FREE0E = (short) 0x0E; - + /** Constant for the CTRL function key. ASCII: shift-in. */ public static final short VK_SHIFT = (short) 0x0F; /** Constant for the PAGE UP function key. ASCII: Data Link Escape. */ public static final short VK_PAGE_UP = (short) 0x10; - + /** Constant for the CTRL function key. ASCII: device-ctrl-one. */ public static final short VK_CONTROL = (short) 0x11; - + /** Constant for the left ALT function key. ASCII: device-ctrl-two. */ public static final short VK_ALT = (short) 0x12; - + /** Constant for the ALT_GRAPH function key, i.e. right ALT key. ASCII: device-ctrl-three. */ public static final short VK_ALT_GRAPH = (short) 0x13; - + /** Constant for the CAPS LOCK function key. ASCII: device-ctrl-four. */ public static final short VK_CAPS_LOCK = (short) 0x14; - + static final short VK_FREE15 = (short) 0x15; - + /** Constant for the PAUSE function key. ASCII: sync-idle. */ public static final short VK_PAUSE = (short) 0x16; - + /** <b>scroll lock</b> key. ASCII: End Of Transmission Block. */ public static final short VK_SCROLL_LOCK = (short) 0x17; - + /** Constant for the CANCEL function key. ASCII: Cancel. */ public static final short VK_CANCEL = (short) 0x18; - + static final short VK_FREE19 = (short) 0x19; - + /** Constant for the INSERT function key. ASCII: Substitute. */ public static final short VK_INSERT = (short) 0x1A; - + /** Constant for the ESCAPE function key. ASCII: Escape. */ public static final short VK_ESCAPE = (short) 0x1B; - + /** Constant for the Convert function key, Japanese "henkan". ASCII: File Separator. */ public static final short VK_CONVERT = (short) 0x1C; @@ -496,48 +496,48 @@ public class KeyEvent extends InputEvent // // Unicode: Printable [0x20 - 0x7E] - // NOTE: Collision of 'a' - 'x' [0x61 .. 0x78], used for keyCode/keySym Fn function keys + // NOTE: Collision of 'a' - 'x' [0x61 .. 0x78], used for keyCode/keySym Fn function keys // - + /** Constant for the SPACE function key. ASCII: SPACE. */ public static final short VK_SPACE = (short) 0x20; - + /** Constant for the "!" key. */ public static final short VK_EXCLAMATION_MARK = (short) 0x21; /** Constant for the """ key. */ public static final short VK_QUOTEDBL = (short) 0x22; - + /** Constant for the "#" key. */ public static final short VK_NUMBER_SIGN = (short) 0x23; /** Constant for the "$" key. */ public static final short VK_DOLLAR = (short) 0x24; - + /** Constant for the "%" key. */ public static final short VK_PERCENT = (short) 0x25; - + /** Constant for the "&" key. */ public static final short VK_AMPERSAND = (short) 0x26; - + /** Constant for the "'" key. */ public static final short VK_QUOTE = (short) 0x27; - + /** Constant for the "(" key. */ public static final short VK_LEFT_PARENTHESIS = (short) 0x28; - + /** Constant for the ")" key. */ public static final short VK_RIGHT_PARENTHESIS = (short) 0x29; - + /** Constant for the "*" key */ public static final short VK_ASTERISK = (short) 0x2A; - + /** Constant for the "+" key. */ public static final short VK_PLUS = (short) 0x2B; - + /** Constant for the comma key, "," */ public static final short VK_COMMA = (short) 0x2C; - + /** Constant for the minus key, "-" */ public static final short VK_MINUS = (short) 0x2D; @@ -582,13 +582,13 @@ public class KeyEvent extends InputEvent /** Constant for the equals key, ">" */ public static final short VK_GREATER = (short) 0x3E; - + /** Constant for the equals key, "?" */ public static final short VK_QUESTIONMARK = (short) 0x3F; - + /** Constant for the equals key, "@" */ public static final short VK_AT = (short) 0x40; - + /** VK_A thru VK_Z are the same as Capital UTF16/ASCII 'A' thru 'Z' (0x41 - 0x5A) */ public static final short VK_A = (short) 0x41; /** See {@link #VK_A}. */ @@ -656,17 +656,17 @@ public class KeyEvent extends InputEvent /** Constant for the "_" key */ public static final short VK_UNDERSCORE = (short) 0x5F; - + /** Constant for the "`" key */ public static final short VK_BACK_QUOTE = (short) 0x60; - + /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ - - /** - * Constant for the F<i>n</i> function keys. + + /** + * Constant for the F<i>n</i> function keys. * <p> * F1..F24, i.e. F<i>n</i>, are mapped from on <code>0x60+n</code> -> <code>[0x61 .. 0x78]</code>. - * </p> + * </p> * <p> * <b>Warning:</b> The F<i>n</i> function keys <b>do collide</b> with unicode characters small 'a' thru 'x'!<br/> * See <a href="#unicodeCollision">Unicode Collision</a> for details. @@ -743,26 +743,26 @@ public class KeyEvent extends InputEvent /** Constant for the F24 function key. See {@link #VK_F1}. */ public static final short VK_F24 = (short) ( 0x60+24 ); - + /** Constant for the "{" key */ public static final short VK_LEFT_BRACE = (short) 0x7B; /** Constant for the "|" key */ public static final short VK_PIPE = (short) 0x7C; /** Constant for the "}" key */ public static final short VK_RIGHT_BRACE = (short) 0x7D; - + /** Constant for the "~" key, matching ASCII */ public static final short VK_TILDE = (short) 0x7E; - + // // Unicode: Non printable controls: [0x7F - 0x9F] // // Numpad keys [0x7F - 0x8E] are printable // - + /** Numeric keypad <b>decimal separator</b> key. Non printable UTF control. */ public static final short VK_SEPARATOR = (short) 0x7F; - + /** Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89). Non printable UTF control. */ public static final short VK_NUMPAD0 = (short) 0x80; /** See {@link #VK_NUMPAD0}. */ @@ -783,28 +783,28 @@ public class KeyEvent extends InputEvent public static final short VK_NUMPAD8 = (short) 0x88; /** See {@link #VK_NUMPAD0}. */ public static final short VK_NUMPAD9 = (short) 0x89; - + /** Numeric keypad <b>decimal separator</b> key. Non printable UTF control. */ public static final short VK_DECIMAL = (short) 0x8A; - + /** Numeric keypad <b>add</b> key. Non printable UTF control. */ public static final short VK_ADD = (short) 0x8B; /** Numeric keypad <b>subtract</b> key. Non printable UTF control. */ public static final short VK_SUBTRACT = (short) 0x8C; - + /** Numeric keypad <b>multiply</b> key. Non printable UTF control. */ public static final short VK_MULTIPLY = (short) 0x8D; - + /** Numeric keypad <b>divide</b> key. Non printable UTF control. */ public static final short VK_DIVIDE = (short) 0x8E; - + /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ public static final short VK_DELETE = (short) 0x93; - + /** Numeric keypad <b>num lock</b> key. Non printable UTF control. */ public static final short VK_NUM_LOCK = (short) 0x94; - + /** Constant for the cursor- or numerical-pad <b>left</b> arrow key. Non printable UTF control. */ public static final short VK_LEFT = (short) 0x95; @@ -816,22 +816,22 @@ public class KeyEvent extends InputEvent /** Constant for the cursor- or numerical pad <b>down</b> arrow key. Non printable UTF control. */ public static final short VK_DOWN = (short) 0x98; - + /** Constant for the Context Menu key. Non printable UTF control. */ public static final short VK_CONTEXT_MENU = (short) 0x99; /** * Constant for the MS "Windows" function key. - * It is used for both the left and right version of the key. + * It is used for both the left and right version of the key. */ public static final short VK_WINDOWS = (short) 0x9A; /** Constant for the Meta function key. */ public static final short VK_META = (short) 0x9B; - + /** Constant for the Help function key. */ public static final short VK_HELP = (short) 0x9C; - + /** Constant for the Compose function key. */ public static final short VK_COMPOSE = (short) 0x9D; @@ -840,21 +840,21 @@ public class KeyEvent extends InputEvent /** Constant for the Stop function key. */ public static final short VK_STOP = (short) 0x9F; - + // // Unicode: Printable [0x00A0 - 0xDFFF] // - + /** Constant for the inverted exclamation mark key. */ public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0xA1; - + /** Constant for the Euro currency sign key. */ public static final short VK_EURO_SIGN = (short) 0x20AC; // // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) // - + /* for Sun keyboards */ public static final short VK_CUT = (short) 0xF879; public static final short VK_COPY = (short) 0xF87A; @@ -871,7 +871,7 @@ public class KeyEvent extends InputEvent */ /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ public static final short VK_INPUT_METHOD_ON_OFF = (short) 0xF890; - + /** * Constant for the Code Input function key. */ diff --git a/src/newt/classes/com/jogamp/newt/event/KeyListener.java b/src/newt/classes/com/jogamp/newt/event/KeyListener.java index b3927d81a..4b16ab61e 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyListener.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyListener.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,22 +29,22 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt.event; /** * Listener for {@link KeyEvent}s. - * + * * @see KeyEvent */ public interface KeyListener extends NEWTEventListener { /** A key has been {@link KeyEvent#EVENT_KEY_PRESSED pressed}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ public void keyPressed(KeyEvent e); - - /** + + /** * A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. * <p> * To simulated the removed <code>keyTyped(KeyEvent e)</code> semantics, @@ -52,9 +52,9 @@ public interface KeyListener extends NEWTEventListener * <pre> if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; - } + } * </pre> - * </p> + * </p> */ public void keyReleased(KeyEvent e); } diff --git a/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java index c47936a7a..77c66a2da 100644 --- a/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java @@ -35,19 +35,19 @@ import com.jogamp.newt.MonitorMode; public class MonitorEvent extends OutputEvent { public static final short EVENT_MONITOR_MODE_CHANGE_NOTIFY = 600; public static final short EVENT_MONITOR_MODE_CHANGED = 601; - + private final MonitorMode mode; - + public MonitorEvent (short eventType, MonitorDevice source, long when, MonitorMode mode) { super(eventType, source, when); this.mode = mode; } - + /** Returns the {@link #getSource() source}, which is a {@link MonitorDevice}. */ public final MonitorDevice getMonitor() { return (MonitorDevice)source; } - + public final MonitorMode getMode() { return mode; } - + public static String getEventTypeString(short type) { switch(type) { case EVENT_MONITOR_MODE_CHANGE_NOTIFY: return "EVENT_MONITOR_MODE_CHANGE_NOTIFY"; @@ -55,7 +55,7 @@ public class MonitorEvent extends OutputEvent { default: return "unknown (" + type + ")"; } } - + public final String toString() { return toString(null).toString(); } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java index 3607ae634..652f87d5b 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.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,12 +20,12 @@ * 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 com.jogamp.newt.event; public abstract class MouseAdapter implements MouseListener diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 57dd7e68c..4d7cc3b36 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt.event; @@ -37,12 +37,12 @@ package com.jogamp.newt.event; /** * Pointer event of type {@link PointerType}. * <p> - * The historical misleading class name may change in the future to <code>PointerEvent</code>. + * The historical misleading class name may change in the future to <code>PointerEvent</code>. * </p> * <p> * http://www.w3.org/Submission/pointer-events/#pointerevent-interface * </p> - * <a name="multiPtrEvent"><h5>Multiple-Pointer Events</h5></a> + * <a name="multiPtrEvent"><h5>Multiple-Pointer Events</h5></a> * <p> * In case an instance represents a multiple-pointer event, i.e. {@link #getPointerCount()} is > 1, * the first data element of the multiple-pointer fields represents the pointer triggering this event.<br/> @@ -62,10 +62,10 @@ package com.jogamp.newt.event; * </p> * <p> * If representing a multiple-pointer event, the {@link #getButton() button number} is mapped to the <i>first {@link #getPointerId(int) pointer ID}</i> - * triggering the event and the {@link InputEvent#BUTTON1_MASK button mask bits} in the {@link #getModifiers() modifiers} + * triggering the event and the {@link InputEvent#BUTTON1_MASK button mask bits} in the {@link #getModifiers() modifiers} * field represent the pressed pointer IDs.<br> * Hence users can query the pressed button count as well as the pressed pointer count via {@link InputEvent#getButtonDownCount()} - * or use the simple query {@link InputEvent#isAnyButtonDown()}. + * or use the simple query {@link InputEvent#isAnyButtonDown()}. * </p> */ @SuppressWarnings("serial") @@ -75,7 +75,7 @@ public class MouseEvent extends InputEvent public static enum PointerClass implements InputEvent.InputClass { Offscreen, Onscreen, Undefined; } - + /** Type of pointer devices */ public static enum PointerType implements InputEvent.InputType { /** {@link PointerClass#Offscreen} mouse. Ordinal 0. */ @@ -88,10 +88,10 @@ public class MouseEvent extends InputEvent Pen(PointerClass.Onscreen), /** {@link PointerClass#Undefined} ?. Ordinal 4. */ Undefined(PointerClass.Undefined); - + public PointerClass getPointerClass() { return pc; } - - /** + + /** * Returns the matching PointerType value corresponding to the given PointerType's integer ordinal. * <pre> * given: @@ -108,8 +108,8 @@ public class MouseEvent extends InputEvent } throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of PointerType.values()[0.."+(all.length-1)+"]"); } - - /** + + /** * Returns the PointerType array of matching PointerType values corresponding to the given PointerType's integer ordinal values. * <p> * See {@link #valueOf(int)}. @@ -124,13 +124,13 @@ public class MouseEvent extends InputEvent } return types; } - + private PointerType(PointerClass pc) { this.pc = pc; } PointerClass pc; } - + /** ID for button 1, value <code>1</code> */ public static final short BUTTON1 = 1; /** ID for button 2, value <code>2</code> */ @@ -149,17 +149,17 @@ public class MouseEvent extends InputEvent public static final short BUTTON8 = 8; /** ID for button 6, value <code>9</code> */ public static final short BUTTON9 = 9; - + /** Maximum number of buttons, value <code>16</code> */ public static final short BUTTON_COUNT = 16; - /** + /** * Maximum number of buttons, value <code>16</code>. * @deprecated Use {@link #BUTTON_COUNT} .. semantics. */ public static final short BUTTON_NUMBER = 16; - - /** Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). */ + + /** Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). */ public static final float[] getRotationXYZ(final float rotationXorY, final int mods) { final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; if( 0 != ( mods & InputEvent.SHIFT_MASK ) ) { @@ -169,14 +169,14 @@ public class MouseEvent extends InputEvent } return rotationXYZ; } - - public static final short getClickTimeout() { - return 300; + + public static final short getClickTimeout() { + return 300; } - - /** + + /** * Constructor for traditional one-pointer event. - * + * * @param eventType * @param source * @param when @@ -193,7 +193,7 @@ public class MouseEvent extends InputEvent int modifiers, int x, int y, short clickCount, short button, float[] rotationXYZ, float rotationScale) { - super(eventType, source, when, modifiers); + super(eventType, source, when, modifiers); this.x = new int[]{x}; this.y = new int[]{y}; switch(eventType) { @@ -214,15 +214,15 @@ public class MouseEvent extends InputEvent this.pointerType = constMousePointerTypes; } - /** + /** * Constructor for a multiple-pointer event. * <p> * First element of multiple-pointer arrays represents the pointer which triggered the event! * </p> - * <p> + * <p> * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * </p> - * + * * @param eventType * @param source * @param when @@ -239,12 +239,12 @@ public class MouseEvent extends InputEvent * @param rotationXYZ Rotation of all axis * @param rotationScale Rotation scale */ - public MouseEvent(short eventType, Object source, long when, int modifiers, - PointerType pointerType[], short[] pointerID, - int[] x, int[] y, float[] pressure, float maxPressure, + public MouseEvent(short eventType, Object source, long when, int modifiers, + PointerType pointerType[], short[] pointerID, + int[] x, int[] y, float[] pressure, float maxPressure, short button, short clickCount, float[] rotationXYZ, float rotationScale) { - super(eventType, source, when, modifiers); + super(eventType, source, when, modifiers); this.x = x; this.y = y; final int pointerCount = pointerType.length; @@ -266,12 +266,12 @@ public class MouseEvent extends InputEvent this.rotationScale = rotationScale; this.pointerType = pointerType; } - + public MouseEvent createVariant(short newEventType) { return new MouseEvent(newEventType, source, getWhen(), getModifiers(), pointerType, pointerID, x, y, pressure, maxPressure, button, clickCount, rotationXYZ, rotationScale); } - + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @return the count of pointers involved in this event @@ -279,7 +279,7 @@ public class MouseEvent extends InputEvent public final int getPointerCount() { return pointerType.length; } - + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @return the {@link PointerType} for the data at index or null if index not available. @@ -290,7 +290,7 @@ public class MouseEvent extends InputEvent } return pointerType[index]; } - + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @return array of all {@link PointerType}s for all pointers @@ -298,10 +298,10 @@ public class MouseEvent extends InputEvent public final PointerType[] getAllPointerTypes() { return pointerType; } - + /** * Return the pointer id for the given index or -1 if index not available. - * <p> + * <p> * IDs start w/ 0 and are consecutive numbers. * </p> * <p> @@ -317,7 +317,7 @@ public class MouseEvent extends InputEvent } return pointerID[index]; } - + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @return the pointer index for the given pointer id or -1 if id not available. @@ -332,7 +332,7 @@ public class MouseEvent extends InputEvent } return -1; } - + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @return array of all pointer IDs for all pointers. IDs start w/ 0 and are consecutive numbers. @@ -340,15 +340,15 @@ public class MouseEvent extends InputEvent public final short[] getAllPointerIDs() { return pointerID; } - - /** + + /** * Returns the button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1]. * <p> * A button value of <code>0</code> denotes no button activity, i.e. {@link PointerType#Mouse} move. * </p> * <p> * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. - * </p> + * </p> */ public final short getButton() { return button; @@ -357,16 +357,16 @@ public class MouseEvent extends InputEvent public final short getClickCount() { return clickCount; } - + public final int getX() { return x[0]; } - + public final int getY() { return y[0]; } - /** + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] * @return X-Coord associated with the pointer-index. @@ -376,7 +376,7 @@ public class MouseEvent extends InputEvent return x[index]; } - /** + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] * @return Y-Coord associated with the pointer-index. @@ -385,7 +385,7 @@ public class MouseEvent extends InputEvent public final int getY(int index) { return y[index]; } - + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @return array of all X-Coords for all pointers @@ -393,7 +393,7 @@ public class MouseEvent extends InputEvent public final int[] getAllX() { return x; } - + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @return array of all Y-Coords for all pointers @@ -401,9 +401,9 @@ public class MouseEvent extends InputEvent public final int[] getAllY() { return y; } - + /** - * @param normalized if true, method returns the normalized pressure, i.e. <code>pressure / maxPressure</code> + * @param normalized if true, method returns the normalized pressure, i.e. <code>pressure / maxPressure</code> * @return The pressure associated with the pointer-index 0. * The value of zero is return if not available. * @see #getMaxPressure() @@ -411,11 +411,11 @@ public class MouseEvent extends InputEvent public final float getPressure(boolean normalized){ return normalized ? pressure[0] / maxPressure : pressure[0]; } - + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] - * @param normalized if true, method returns the normalized pressure, i.e. <code>pressure / maxPressure</code> + * @param normalized if true, method returns the normalized pressure, i.e. <code>pressure / maxPressure</code> * @return The pressure associated with the pointer-index. * The value of zero is return if not available. * @see #getMaxPressure() @@ -423,7 +423,7 @@ public class MouseEvent extends InputEvent public final float getPressure(int index, boolean normalized){ return normalized ? pressure[index] / maxPressure : pressure[index]; } - + /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @return array of all raw, un-normalized pressures for all pointers @@ -431,12 +431,12 @@ public class MouseEvent extends InputEvent public final float[] getAllPressures() { return pressure; } - - /** + + /** * Returns the maximum pressure known for the input device generating this event. * <p> * This value may be self calibrating on devices/OS, where no known maximum pressure is known. - * Hence subsequent events may return a higher value. + * Hence subsequent events may return a higher value. * </p> * <p> * Self calibrating maximum pressure is performed on: @@ -448,25 +448,25 @@ public class MouseEvent extends InputEvent public final float getMaxPressure() { return maxPressure; } - + /** * Returns a 3-component float array filled with the values of the rotational axis * in the following order: horizontal-, vertical- and z-axis. - * <p> + * <p> * A vertical rotation of <b>> 0.0f is up</b> and <b>< 0.0f is down</b>. * </p> * <p> - * A horizontal rotation of <b>> 0.0f is left</b> and <b>< 0.0f is right</b>. + * A horizontal rotation of <b>> 0.0f is left</b> and <b>< 0.0f is right</b>. * </p> * <p> - * A z-axis rotation of <b>> 0.0f is back</b> and <b>< 0.0f is front</b>. + * A z-axis rotation of <b>> 0.0f is back</b> and <b>< 0.0f is front</b>. * </p> * <p> * <i>However</i>, on some OS this might be flipped due to the OS <i>default</i> behavior. * The latter is true for OS X 10.7 (Lion) for example. * </p> * <p> - * On PointerClass {@link PointerClass#Onscreen onscreen} devices, i.e. {@link PointerType#TouchScreen touch screens}, + * On PointerClass {@link PointerClass#Onscreen onscreen} devices, i.e. {@link PointerType#TouchScreen touch screens}, * rotation events are usually produced by a 2-finger movement, where horizontal and vertical rotation values are filled. * </p> * <p> @@ -475,13 +475,13 @@ public class MouseEvent extends InputEvent * </p> * <p> * The {@link InputEvent#SHIFT_MASK} modifier is set in case <b>|horizontal| > |vertical|</b> value.<br/> - * This can be utilized to implement only one 2d rotation direction, you may use {@link #isShiftDown()} to query it. + * This can be utilized to implement only one 2d rotation direction, you may use {@link #isShiftDown()} to query it. * </p> * <p> * In case the pointer type is {@link PointerType#Mouse mouse}, * events are usually send in steps of one, ie. <i>-1.0f</i> and <i>1.0f</i>. * Higher values may result due to fast scrolling. - * Fractional values may result due to slow scrolling with high resolution devices.<br/> + * Fractional values may result due to slow scrolling with high resolution devices.<br/> * Here the button number refers to the wheel number. * </p> * <p> @@ -492,24 +492,24 @@ public class MouseEvent extends InputEvent public final float[] getRotation() { return rotationXYZ; } - - /** + + /** * Returns the scale used to determine the {@link #getRotation() rotation value}, * which semantics depends on the {@link #getPointerType() pointer type's} {@link PointerClass}. * <p> * For {@link PointerClass#Offscreen}, the scale is usually <code>1.0f</code> and denominates * an abstract value without association to a physical value. - * </p> + * </p> * <p> * For {@link PointerClass#Onscreen}, the scale varies and denominates - * the divisor of the distance the finger[s] have moved on the screen. - * Hence <code>scale * rotation</code> reproduces the screen distance in pixels the finger[s] have moved. - * </p> + * the divisor of the distance the finger[s] have moved on the screen. + * Hence <code>scale * rotation</code> reproduces the screen distance in pixels the finger[s] have moved. + * </p> */ public final float getRotationScale() { return rotationScale; } - + public final String toString() { return toString(null).toString(); } @@ -533,7 +533,7 @@ public class MouseEvent extends InputEvent .append("p[").append(pressure[i]).append("/").append(maxPressure).append("=").append(pressure[i]/maxPressure).append("]"); } sb.append("]"); - } + } sb.append(", "); return super.toString(sb).append("]"); } @@ -551,14 +551,14 @@ public class MouseEvent extends InputEvent default: return "unknown (" + type + ")"; } } - + /** PointerType for each pointer (multiple pointer) */ private final PointerType pointerType[]; - /** + /** * Pointer-ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. - * <p> + * <p> * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. - * </p> + * </p> */ private final short pointerID[]; /** X-axis for each pointer (multiple pointer) */ @@ -581,11 +581,11 @@ public class MouseEvent extends InputEvent /** Rotation scale */ private final float rotationScale; private final float maxPressure; - + private static final float[] constMousePressure0 = new float[]{0f}; private static final float[] constMousePressure1 = new float[]{1f}; private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; - + public static final short EVENT_MOUSE_CLICKED = 200; public static final short EVENT_MOUSE_ENTERED = 201; public static final short EVENT_MOUSE_EXITED = 202; diff --git a/src/newt/classes/com/jogamp/newt/event/MouseListener.java b/src/newt/classes/com/jogamp/newt/event/MouseListener.java index ce6796081..5378080b9 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseListener.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseListener.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt.event; @@ -38,7 +38,7 @@ import com.jogamp.newt.event.MouseEvent.PointerType; /** * Listener for {@link MouseEvent}s. - * + * * @see MouseEvent */ public interface MouseListener extends NEWTEventListener @@ -50,13 +50,13 @@ public interface MouseListener extends NEWTEventListener public void mouseReleased(MouseEvent e); public void mouseMoved(MouseEvent e); public void mouseDragged(MouseEvent e); - + /** * Traditional event name originally produced by a {@link PointerType#Mouse mouse} pointer type. * <p> * Triggered for any rotational pointer events, see - * {@link MouseEvent#getRotation()} and {@link MouseEvent#getRotationScale()}. - * </p> + * {@link MouseEvent#getRotation()} and {@link MouseEvent#getRotationScale()}. + * </p> */ public void mouseWheelMoved(MouseEvent e); } diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 02bb4f929..022e2d0e1 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt.event; @@ -50,7 +50,7 @@ package com.jogamp.newt.event; */ @SuppressWarnings("serial") public class NEWTEvent extends java.util.EventObject { - /** + /** * See {@link #setConsumed(boolean)} for description. */ public static final Object consumedTag = new Object(); @@ -78,11 +78,11 @@ public class NEWTEvent extends java.util.EventObject { return when; } - /** + /** * Attach the passed object to this event.<br> * If an object was previously attached, it will be replaced.<br> * Attachments to NEWT events allow users to pass on information - * from one custom listener to another, ie custom listener to listener + * from one custom listener to another, ie custom listener to listener * communication. * @param attachment User application specific object */ @@ -90,14 +90,14 @@ public class NEWTEvent extends java.util.EventObject { this.attachment = attachment; } - /** + /** * @return The user application specific attachment, or null */ public final Object getAttachment() { return attachment; } - - /** + + /** * Returns <code>true</code> if this events has been {@link #setConsumed(boolean) consumed}, * otherwise <code>false</code>. * @see #setConsumed(boolean) @@ -105,8 +105,8 @@ public class NEWTEvent extends java.util.EventObject { public final boolean isConsumed() { return consumedTag == attachment; } - - /** + + /** * If <code>consumed</code> is <code>true</code>, this event is marked as consumed, * ie. the event will not be propagated any further to potential <i>other</i> event listener. * Otherwise the event will be propagated to other event listener, the default. @@ -130,7 +130,7 @@ public class NEWTEvent extends java.util.EventObject { setAttachment( null ); } } - + public String toString() { return toString(null).toString(); } diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEventConsumer.java b/src/newt/classes/com/jogamp/newt/event/NEWTEventConsumer.java index 6aa19e5f8..14fba6742 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEventConsumer.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEventConsumer.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,18 +20,18 @@ * 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 com.jogamp.newt.event; public interface NEWTEventConsumer { - /** - * Consume the event + /** + * Consume the event * * @return true if the event has been consumed, * otherwise it returns false for later propagation. diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java b/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java index fe224bba6..7dd56ad1e 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.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,12 +20,12 @@ * 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 com.jogamp.newt.event; import java.util.LinkedList; diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java b/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java index 677136573..f7ee3d739 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt.event; diff --git a/src/newt/classes/com/jogamp/newt/event/OutputEvent.java b/src/newt/classes/com/jogamp/newt/event/OutputEvent.java index 86fa95877..80c7780f8 100644 --- a/src/newt/classes/com/jogamp/newt/event/OutputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/OutputEvent.java @@ -39,7 +39,7 @@ public abstract class OutputEvent extends NEWTEvent public String toString() { return toString(null).toString(); } - + public StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); diff --git a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java index eceea053d..d275eab46 100644 --- a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java +++ b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java @@ -35,7 +35,7 @@ import jogamp.newt.Debug; * 2 pointer zoom, a.k.a. <i>pinch to zoom</i>, gesture handler processing {@link MouseEvent}s * while producing {@link ZoomEvent}s if gesture is completed. * <p> - * Zoom value lies within [0..2], with 1 as <i>1:1</i>. + * Zoom value lies within [0..2], with 1 as <i>1:1</i>. * </p> * <pre> * - choosing the smallest surface edge (width/height -> x/y) @@ -44,7 +44,7 @@ import jogamp.newt.Debug; */ public class PinchToZoomGesture implements GestureHandler { public static final boolean DEBUG = Debug.debug("Window.MouseEvent"); - + /** A {@link GestureHandler.GestureEvent} denominating zoom. */ @SuppressWarnings("serial") public static class ZoomEvent extends GestureEvent { @@ -57,10 +57,10 @@ public class PinchToZoomGesture implements GestureHandler { } /** Triggering {@link MouseEvent} */ public final MouseEvent getTrigger() { return pe; } - /** Zoom value lies within [0..2], with 1 as <i>1:1</i>. */ + /** Zoom value lies within [0..2], with 1 as <i>1:1</i>. */ public final float getZoom() { return zoom; } } - + private final NativeSurface surface; private float zoom; private int zoomLastEdgeDist; @@ -68,7 +68,7 @@ public class PinchToZoomGesture implements GestureHandler { private boolean zoomMode; private ZoomEvent zoomEvent; private short[] pIds = new short[] { -1, -1 }; - + public PinchToZoomGesture(NativeSurface surface) { clear(true); this.surface = surface; @@ -80,10 +80,10 @@ public class PinchToZoomGesture implements GestureHandler { } private int gesturePointers(final MouseEvent e, final int excludeIndex) { - int j = 0; + int j = 0; for(int i=e.getPointerCount()-1; i>=0; i--) { if( excludeIndex != i ) { - final int id = e.getPointerId(i); + final int id = e.getPointerId(i); if( pIds[0] == id || pIds[1] == id ) { j++; } @@ -91,7 +91,7 @@ public class PinchToZoomGesture implements GestureHandler { } return j; } - + @Override public void clear(boolean clearStarted) { zoomEvent = null; @@ -103,31 +103,31 @@ public class PinchToZoomGesture implements GestureHandler { pIds[1] = -1; } } - + @Override public boolean isWithinGesture() { return zoomMode; } - + @Override public boolean hasGesture() { return null != zoomEvent; } - + @Override public InputEvent getGestureEvent() { return zoomEvent; } - - /** Zoom value lies within [0..2], with 1 as <i>1:1</i>. */ + + /** Zoom value lies within [0..2], with 1 as <i>1:1</i>. */ public final float getZoom() { return zoom; } - /** Set zoom value within [0..2], with 1 as <i>1:1</i>. */ + /** Set zoom value within [0..2], with 1 as <i>1:1</i>. */ public final void setZoom(float zoom) { this.zoom=zoom; } - + @Override public boolean process(final InputEvent in) { if( null != zoomEvent || !(in instanceof MouseEvent) ) { @@ -137,15 +137,15 @@ public class PinchToZoomGesture implements GestureHandler { if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen ) { return false; } - + final int pointerDownCount = pe.getPointerCount(); final int eventType = pe.getEventType(); final boolean useY = surface.getWidth() >= surface.getHeight(); // use smallest dimension switch ( eventType ) { case MouseEvent.EVENT_MOUSE_PRESSED: { if( 1 == pointerDownCount ) { - pIds[0] = pe.getPointerId(0); - pIds[1] = -1; + pIds[0] = pe.getPointerId(0); + pIds[1] = -1; } else if ( 2 <= pointerDownCount ) { // && 1 == gesturePointers(pe, 0) /* w/o pressed pointer */) { pIds[0] = pe.getPointerId(0); pIds[1] = pe.getPointerId(1); @@ -155,13 +155,13 @@ public class PinchToZoomGesture implements GestureHandler { System.err.println(this+".pressed: down "+pointerDownCount+", gPtr "+gesturePointers(pe, -1)+", event "+pe); } } break; - + case MouseEvent.EVENT_MOUSE_RELEASED: { final int gPtr = gesturePointers(pe, 0); // w/o lifted pointer if ( 1 == gPtr ) { zoomFirstTouch = true; zoomMode = false; - } else if( 0 == gPtr ) { + } else if( 0 == gPtr ) { // all lifted clear(true); } @@ -169,7 +169,7 @@ public class PinchToZoomGesture implements GestureHandler { System.err.println(this+".released: down "+pointerDownCount+", gPtr "+gPtr+", event "+pe); } } break; - + case MouseEvent.EVENT_MOUSE_DRAGGED: { if( 2 <= pointerDownCount ) { final int gPtr = gesturePointers(pe, -1); @@ -187,13 +187,13 @@ public class PinchToZoomGesture implements GestureHandler { zoomMode = true; } else if( zoomMode ) { final int d = Math.abs(edge0-edge1); - final int dd = d - zoomLastEdgeDist; + final int dd = d - zoomLastEdgeDist; final float screenEdge = useY ? surface.getHeight() : surface.getWidth(); final float incr = (float)dd / screenEdge; // [-1..1] if(DEBUG) { System.err.println("XXX2: id0 "+pIds[0]+" -> idx0 "+p0Idx+", id1 "+pIds[1]+" -> idx1 "+p1Idx); System.err.println("XXX3: d "+d+", ld "+zoomLastEdgeDist+", dd "+dd+", screen "+screenEdge+" -> incr "+incr+", zoom "+zoom+" -> "+(zoom+incr)); - } + } zoom += incr; // clip value if( 2f < zoom ) { @@ -211,7 +211,7 @@ public class PinchToZoomGesture implements GestureHandler { } } } break; - + default: } return null != zoomEvent; diff --git a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java index 629dc50d7..e826f4a6a 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.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,12 +20,12 @@ * 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 com.jogamp.newt.event; public class TraceKeyAdapter implements KeyListener { diff --git a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java index 14ee633a0..d035091c4 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.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,12 +20,12 @@ * 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 com.jogamp.newt.event; public class TraceMouseAdapter implements MouseListener { diff --git a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java index 8542820c4..630e85303 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.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,12 +20,12 @@ * 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 com.jogamp.newt.event; public class TraceWindowAdapter implements WindowListener { diff --git a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java index b9e487e9b..e237c0d80 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.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,12 +20,12 @@ * 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 com.jogamp.newt.event; public abstract class WindowAdapter implements WindowListener diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java index 24b3b380a..8c7abfe99 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt.event; @@ -42,7 +42,7 @@ package com.jogamp.newt.event; @SuppressWarnings("serial") public class WindowEvent extends NEWTEvent { public static final short EVENT_WINDOW_RESIZED = 100; - public static final short EVENT_WINDOW_MOVED = 101; + public static final short EVENT_WINDOW_MOVED = 101; public static final short EVENT_WINDOW_DESTROY_NOTIFY = 102; public static final short EVENT_WINDOW_GAINED_FOCUS = 103; public static final short EVENT_WINDOW_LOST_FOCUS = 104; @@ -65,7 +65,7 @@ public class WindowEvent extends NEWTEvent { default: return "unknown (" + type + ")"; } } - + public String toString() { return toString(null).toString(); } diff --git a/src/newt/classes/com/jogamp/newt/event/WindowListener.java b/src/newt/classes/com/jogamp/newt/event/WindowListener.java index dde182510..e097edf23 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowListener.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowListener.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * */ package com.jogamp.newt.event; @@ -44,17 +44,17 @@ public interface WindowListener extends NEWTEventListener { /** Window has been moved. */ public void windowMoved(WindowEvent e); - /** + /** * Window destruction has been requested. * <p> * Depending on the {@link WindowClosingProtocol#getDefaultCloseOperation() default close operation}, * the window maybe destroyed or not. * </p> - * In case the window will be destroyed (see above), release of resources is recommended. + * In case the window will be destroyed (see above), release of resources is recommended. **/ public void windowDestroyNotify(WindowEvent e); - /** + /** * Window has been destroyed. */ public void windowDestroyed(WindowEvent e); diff --git a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java index a0f6e2cb4..8a204d234 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.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,12 +20,12 @@ * 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 com.jogamp.newt.event; import javax.media.nativewindow.util.Rectangle; diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java index 6de2eee45..e3bf18448 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.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,12 +20,12 @@ * 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 com.jogamp.newt.event.awt; import jogamp.newt.Debug; @@ -48,10 +48,10 @@ import jogamp.newt.Debug; * Common:<br> * <pre> // your demo/render code - javax.media.opengl.GLEvenListener demo1 = new javax.media.opengl.GLEvenListener() { ... } ; + javax.media.opengl.GLEvenListener demo1 = new javax.media.opengl.GLEvenListener() { ... } ; // your AWT agnostic NEWT mouse listener code - com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ; + com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ; * </pre> </p> * <p> * Default NEWT use case, without using the AWTAdapter:<br> @@ -96,7 +96,7 @@ import jogamp.newt.Debug; <br> new AWTMouseAdapter(mouseListener, glWindow).addTo(comp);<br> * </pre> </p> - * + * * Last but not least, the AWTAdapter maybe used as a general AWT event forwarder to NEWT.<br> * * <p> @@ -108,7 +108,7 @@ import jogamp.newt.Debug; <br> new AWTMouseAdapter(glWindow).addTo(comp); // forward all AWT events to glWindow, as NEWT events<br> * </pre> </p> - * + * * @see #attachTo */ public abstract class AWTAdapter implements java.util.EventListener @@ -118,7 +118,7 @@ public abstract class AWTAdapter implements java.util.EventListener com.jogamp.newt.event.NEWTEventListener newtListener; com.jogamp.newt.Window newtWindow; - /** + /** * Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.<br> * The NEWT EventListener will be called when an event happens.<br> */ @@ -130,7 +130,7 @@ public abstract class AWTAdapter implements java.util.EventListener this.newtWindow = null; } - /** + /** * Wrap aroung a NEWT EventListener, exposed as an AWT EventListener,<br> * where the given NEWT Window impersonates as the event's source. * The NEWT EventListener will be called when an event happens.<br> @@ -146,7 +146,7 @@ public abstract class AWTAdapter implements java.util.EventListener this.newtWindow = newtProxy; } - /** + /** * Create a pipeline adapter, AWT EventListener.<br> * Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.<br> * This is only supported with EDT enabled! @@ -162,15 +162,15 @@ public abstract class AWTAdapter implements java.util.EventListener } } - public final com.jogamp.newt.Window getNewtWindow() { - return newtWindow; + public final com.jogamp.newt.Window getNewtWindow() { + return newtWindow; } - + public final com.jogamp.newt.event.NEWTEventListener getNewtEventListener() { - return newtListener; + return newtListener; } - - /** + + /** * Due to the fact that some NEWT {@link com.jogamp.newt.event.NEWTEventListener} * are mapped to more than one {@link java.util.EventListener}, * this method is for your convenience to use this Adapter as a listener for all types.<br> diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index bef2e5d0f..1b53671ba 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.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,18 +20,18 @@ * 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 com.jogamp.newt.event.awt; import jogamp.newt.awt.event.AWTNewtEventFactory; /** - * AWT: + * AWT: * printable: PRESSED (t0), TYPED (t0), RELEASED (t1) * non-printable: PRESSED (t0), RELEASED (t1) */ diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java index 115743a0d..ab4bf7a3f 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.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,17 +20,17 @@ * 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 com.jogamp.newt.event.awt; import jogamp.newt.awt.event.AWTNewtEventFactory; -public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener, +public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener { diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index e91bb2f82..8c9781b77 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.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,20 +20,20 @@ * 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 com.jogamp.newt.event.awt; import java.awt.Dimension; import jogamp.newt.awt.event.AWTNewtEventFactory; -public class AWTWindowAdapter - extends AWTAdapter +public class AWTWindowAdapter + extends AWTAdapter implements java.awt.event.ComponentListener, java.awt.event.WindowListener, java.awt.event.FocusListener { WindowClosingListener windowClosingListener; @@ -63,17 +63,17 @@ public class AWTWindowAdapter if(awtComponent instanceof java.awt.Window) { ((java.awt.Window)awtComponent).addWindowListener(this); } - return this; + return this; } - + public AWTAdapter removeWindowClosingFrom(java.awt.Component awtComponent) { java.awt.Window win = getWindow(awtComponent); if( null != win && null != windowClosingListener ) { win.removeWindowListener(windowClosingListener); } - return this; + return this; } - + public AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeFocusListener(this); awtComponent.removeComponentListener(this); @@ -225,7 +225,7 @@ public class AWTWindowAdapter enqueueEvent(true, event); } } - public void windowClosed(java.awt.event.WindowEvent e) { + public void windowClosed(java.awt.event.WindowEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index cae1a06a2..ac81e8469 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -127,7 +127,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override - public void windowResized(WindowEvent e) { + public void windowResized(WindowEvent e) { defaultWindowResizedOp(getWidth(), getHeight()); } @@ -139,7 +139,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final Object getUpstreamWidget() { return window; } - + /** * Creates a new GLWindow attaching a new Window referencing a * new default Screen and default Display with the given GLCapabilities. @@ -218,7 +218,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind @Override public final CapabilitiesImmutable getChosenCapabilities() { final GLDrawable _drawable = drawable; - return null != _drawable ? _drawable.getChosenGLCapabilities() : window.getChosenCapabilities(); + return null != _drawable ? _drawable.getChosenGLCapabilities() : window.getChosenCapabilities(); } @Override @@ -339,7 +339,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final int getY() { return window.getY(); } - + @Override public final int getWidth() { return window.getWidth(); @@ -349,7 +349,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final int getHeight() { return window.getHeight(); } - + @Override public final void setPosition(int x, int y) { window.setPosition(x, y); @@ -363,7 +363,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final boolean setFullscreen(boolean fullscreen) { return window.setFullscreen(fullscreen); } - + @Override public boolean setFullscreen(List<MonitorDevice> monitors) { return window.setFullscreen(monitors); @@ -418,7 +418,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public void setWindowDestroyNotifyAction(Runnable r) { window.setWindowDestroyNotifyAction(r); } - + @Override public final void setVisible(boolean visible) { window.setVisible(visible); @@ -450,7 +450,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public void preserveGLStateAtDestroy(boolean value) { GLWindow.this.preserveGLStateAtDestroy(value); } - + @Override public synchronized void destroyActionPreLock() { // nop @@ -464,7 +464,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind //Exception e1 = new Exception(msg); //e1.printStackTrace(); } - + destroyImplInLock(); if(Window.DEBUG_IMPLEMENTATION) { @@ -493,7 +493,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } else { t0 = 0; } - + if (null == drawable && visible && 0 != window.getWindowHandle() && 0<getWidth()*getHeight()) { if( ( null != context ) ) { throw new InternalError("GLWindow.LifecycleHook.setVisiblePost: "+WindowImpl.getThreadName()+" - Null drawable, but valid context - "+GLWindow.this); @@ -509,7 +509,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } drawable = (GLDrawableImpl) factory.createGLDrawable(ns); drawable.setRealized(true); - + if( !GLWindow.this.pushGLEventListenerState() ) { context = (GLContextImpl) drawable.createContext(sharedContext); context.setContextCreationFlags(additionalCtxCreationFlags); @@ -538,7 +538,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind savedAnimator.resume(); } } - + @SuppressWarnings("deprecation") @Override public void shutdownRenderingAction() { @@ -572,12 +572,12 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind // private GLContext sharedContext = null; - + @Override protected final RecursiveLock getLock() { return window.getLock(); } - + /** * Specifies an {@link javax.media.opengl.GLContext OpenGL context} to share with.<br> * At native creation, {@link #setVisible(boolean) setVisible(true)}, @@ -619,7 +619,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind setVisible(true); } } - + /** * {@inheritDoc} * <p> @@ -643,7 +643,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final void swapBuffers() throws GLException { defaultSwapBuffers(); } - + //---------------------------------------------------------------------- // NEWTEventConsumer // @@ -807,7 +807,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final void removeGestureListener(GestureHandler.GestureListener gl) { window.removeGestureListener(gl); } - + //---------------------------------------------------------------------- // NativeWindow completion // @@ -893,7 +893,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind _forceGL3 = true; } else if(args[i].equals("-gl4es3")) { _forceGL4ES3 = true; - } + } } } forceES2 = _forceES2; @@ -905,7 +905,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind System.err.println("forceES3 "+forceES3); System.err.println("forceGL3 "+forceGL3); System.err.println("forceGL4ES3 "+forceGL4ES3); - + System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); System.err.println(JoglVersion.getInstance()); diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index a2135273b..a25b43777 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.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,7 +20,7 @@ * 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. @@ -71,9 +71,9 @@ import com.jogamp.newt.util.EDTUtil; public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false); - - private final AbstractGraphicsScreen screen; - + + private final AbstractGraphicsScreen screen; + private WindowClosingMode newtChildCloseOp = WindowClosingMode.DISPOSE_ON_CLOSE; private volatile Rectangle clientArea; @@ -82,22 +82,22 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private volatile boolean newtChildReady = false; // ready if SWTEDTUtil is set and newtChild parented private volatile boolean postSetSize = false; // pending resize - /** - * Creates an instance using {@link #NewtCanvasSWT(Composite, int, Window)} + /** + * Creates an instance using {@link #NewtCanvasSWT(Composite, int, Window)} * on the SWT thread. - * + * * <p> * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation - * via {@link Display#setEDTUtil(EDTUtil)}. + * via {@link Display#setEDTUtil(EDTUtil)}. * </p> - * + * * @param parent the SWT composite - * @param style additional styles to SWT#NO_BACKGROUND - * @param child optional preassigned {@link #Window}, maybe null + * @param style additional styles to SWT#NO_BACKGROUND + * @param child optional preassigned {@link #Window}, maybe null * @return a new instance */ public static NewtCanvasSWT create(final Composite parent, final int style, final Window child) { - final NewtCanvasSWT[] res = new NewtCanvasSWT[] { null }; + final NewtCanvasSWT[] res = new NewtCanvasSWT[] { null }; parent.getDisplay().syncExec( new Runnable() { public void run() { res[0] = new NewtCanvasSWT( parent, style, child); @@ -105,22 +105,22 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { }); return res[0]; } - + /** * Instantiates a NewtCanvas with a NEWT child. - * + * * <p> * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation - * via {@link Display#setEDTUtil(EDTUtil)}. + * via {@link Display#setEDTUtil(EDTUtil)}. * </p> - * + * * @param parent the SWT composite - * @param style additional styles to SWT#NO_BACKGROUND - * @param child optional preassigned {@link #Window}, maybe null + * @param style additional styles to SWT#NO_BACKGROUND + * @param child optional preassigned {@link #Window}, maybe null */ public NewtCanvasSWT(final Composite parent, final int style, Window child) { super(parent, style | SWT.NO_BACKGROUND); - + SWTAccessor.setRealized(this, true); clientArea = getClientArea(); @@ -128,7 +128,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { final AbstractGraphicsDevice device = SWTAccessor.getDevice(this); screen = SWTAccessor.getScreen(device, -1 /* default */); nativeWindow = null; - + if(null != child) { setNEWTChild(child); } @@ -161,12 +161,12 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { addListener (SWT.Paint, listener); addListener (SWT.Dispose, listener); } - + /** assumes nativeWindow == null ! */ protected final boolean validateNative() { updateSizeCheck(); final Rectangle nClientArea = clientArea; - if(0 >= nClientArea.width || 0 >= nClientArea.height) { + if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } screen.getDevice().open(); @@ -177,9 +177,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { final boolean visualIDValid = NativeWindowFactory.isNativeVisualIDValidForProcessing(visualID); if(DEBUG) { System.err.println("NewtCanvasSWT.validateNative() windowHandle 0x"+Long.toHexString(nativeWindowHandle)+", visualID 0x"+Integer.toHexString(visualID)+", valid "+visualIDValid); - } + } if( visualIDValid ) { - /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). + /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). * Note: SWT is owner of the native handle, hence no closing operation will be a NOP. */ final CapabilitiesImmutable caps = new Capabilities(); final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(screen.getDevice(), caps); @@ -187,7 +187,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if(DEBUG) { System.err.println("NewtCanvasSWT.validateNative() factory: "+factory+", windowHandle 0x"+Long.toHexString(nativeWindowHandle)+", visualID 0x"+Integer.toHexString(visualID)+", chosen config: "+config); // Thread.dumpStack(); - } + } if (null == config) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } @@ -198,11 +198,11 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { return null != nativeWindow; } - + protected final void updateSizeCheck() { final Rectangle oClientArea = clientArea; final Rectangle nClientArea = getClientArea(); - if ( nClientArea != null && + if ( nClientArea != null && ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) ) { clientArea = nClientArea; // write back new value @@ -217,12 +217,12 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } } } - + @Override public void update() { // don't paint background etc .. nop avoids flickering } - + /** * Destroys this resource: * <ul> @@ -248,12 +248,12 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } screen.getDevice().close(); nativeWindow = null; - super.dispose(); + super.dispose(); } - + /** @return this SWT Canvas NativeWindow representation, may be null in case it has not been realized. */ public NativeWindow getNativeWindow() { return nativeWindow; } - + public WindowClosingMode getDefaultCloseOperation() { return newtChildCloseOp; // TODO: implement ?! } @@ -264,28 +264,28 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { boolean isParent() { - return null!=newtChild ; + return null!=newtChild ; } boolean isFullscreen() { return null != newtChild && newtChild.isFullscreen(); } - /** + /** * Sets a new NEWT child, provoking reparenting. * <p> * A previously detached <code>newChild</code> will be released to top-level status - * and made invisible. + * and made invisible. * </p> * <p> - * Note: When switching NEWT child's, detaching the previous first via <code>setNEWTChild(null)</code> - * produced much cleaner visual results. + * Note: When switching NEWT child's, detaching the previous first via <code>setNEWTChild(null)</code> + * produced much cleaner visual results. * </p> * <p> * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation - * via {@link Display#setEDTUtil(EDTUtil)}. + * via {@link Display#setEDTUtil(EDTUtil)}. * </p> - * @return the previous attached newt child. + * @return the previous attached newt child. */ public Window setNEWTChild(final Window newChild) { final Window prevChild = newtChild; @@ -302,14 +302,14 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if(null != nativeWindow && null != newChild) { reparentWindow( true ); } - return prevChild; + return prevChild; } - + /** @return the current NEWT child */ public Window getNEWTChild() { return newtChild; } - + @Override public boolean setParent(Composite parent) { return super.setParent(parent); @@ -319,11 +319,11 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChildReady = attach; if( null != newtChild ) { newtChild.setKeyboardFocusHandler(null); - if(attach) { - newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); + if(attach) { + newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); } else { newtChild.setFocusAction(null); - newtChild.setDefaultCloseOperation(newtChildCloseOp); + newtChild.setDefaultCloseOperation(newtChildCloseOp); } } } @@ -335,13 +335,13 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if(DEBUG) { System.err.println("NewtCanvasSWT.reparentWindow.0: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); } - + newtChild.setFocusAction(null); // no AWT focus traversal .. if(add) { updateSizeCheck(); final int w = clientArea.width; final int h = clientArea.height; - + // set SWT EDT and start it { final Display newtDisplay = newtChild.getScreen().getDisplay(); @@ -349,14 +349,14 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { edtUtil.start(); newtDisplay.setEDTUtil( edtUtil ); } - - newtChild.setSize(w, h); + + newtChild.setSize(w, h); newtChild.reparentWindow(nativeWindow); newtChild.setVisible(true); - configureNewtChild(true); + configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - - // force this SWT Canvas to be focus-able, + + // force this SWT Canvas to be focus-able, // since it is completely covered by the newtChild (z-order). setEnabled(true); } else { @@ -375,19 +375,19 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.requestFocus(); } } - + @Override public boolean forceFocus() { final boolean res = NewtCanvasSWT.super.forceFocus(); requestFocusNEWTChild(); - return res; + return res; } - + private class SWTNativeWindow implements NativeWindow { private final AbstractGraphicsConfiguration config; private final long nativeWindowHandle; private final InsetsImmutable insets; // only required to allow proper client position calculation on OSX - + public SWTNativeWindow(AbstractGraphicsConfiguration config, long nativeWindowHandle) { this.config = config; this.nativeWindowHandle = nativeWindowHandle; @@ -397,7 +397,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { this.insets = new Insets(0, 0, 0, 0); } } - + @Override public int lockSurface() throws NativeWindowException, RuntimeException { return NativeSurface.LOCK_SUCCESS; @@ -432,7 +432,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { } @Override - public long getSurfaceHandle() { + public long getSurfaceHandle() { return 0; } @@ -462,7 +462,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } @Override - public void surfaceUpdated(Object updater, NativeSurface ns, long when) { } + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { } @Override public void destroy() { } @@ -497,7 +497,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if( isOSX ) { final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); // top-level position -> client window position - los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); + los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); if(null!=point) { return point.translate(los); } else { @@ -506,7 +506,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } else { // client position on 'normal' windowing systems is 0/0 if(null == point) { - point = new Point(0, 0); + point = new Point(0, 0); } return point; } @@ -515,7 +515,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { @Override public boolean hasFocus() { return isFocusControl(); - } + } }; static String newtWinHandleToHexString(Window w) { diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 52ca95682..582dc3e1f 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -63,17 +63,17 @@ public interface EDTUtil { * @param ms poll period in milliseconds */ public void setPollPeriod(long ms); - + /** * Starts the EDT after it's creation or after {@link #invokeStop(boolean, Runnable) stopping}. * <p> * If the EDT is running, it must be {@link #invokeStop(boolean, Runnable) stopped} first * and the caller should wait {@link #waitUntilStopped() until it's stopped}. * </p> - * + * * @return true if EDT has been successfully restarted, otherwise false * @throws IllegalStateException if EDT is running and not subject to be stopped, i.e. {@link #isRunning()} returns true - * + * * @see #invokeStop(boolean, java.lang.Runnable) * @see #waitUntilStopped() */ @@ -82,11 +82,11 @@ public interface EDTUtil { /** * Returns true if the current thread is the event dispatch thread (EDT). * <p> - * The EDT is the platform specific thread dispatching toolkit-events + * The EDT is the platform specific thread dispatching toolkit-events * and executing toolkit-tasks enqueued via {@link #invoke(boolean, Runnable)}. * </p> * <p> - * Usually it is the same thread as used to dequeue informal {@link NEWTEvent}s (NEDT), see {@link #isCurrentThreadNEDT()}, + * Usually it is the same thread as used to dequeue informal {@link NEWTEvent}s (NEDT), see {@link #isCurrentThreadNEDT()}, * however, this may differ, e.g. SWT and AWT implementation. * </p> */ @@ -95,28 +95,28 @@ public interface EDTUtil { /** * Returns true if the current thread is the internal NEWT event dequeue thread (NEDT). * <p> - * The NEDT is the NEWT thread used to dequeue informal {@link NEWTEvent}s enqueued internally + * The NEDT is the NEWT thread used to dequeue informal {@link NEWTEvent}s enqueued internally * via {@link DisplayImpl#enqueueEvent(boolean, NEWTEvent)}. * </p> * <p> - * Usually it is the same thread as the EDT, see {@link #isCurrentThreadEDT()}, + * Usually it is the same thread as the EDT, see {@link #isCurrentThreadEDT()}, * however, this may differ, e.g. SWT and AWT implementation. * </p> */ public boolean isCurrentThreadNEDT(); - + /** * Returns <code>true</code> if either {@link #isCurrentThreadEDT()} or {@link #isCurrentThreadNEDT()} is <code>true</code>, * otherwise <code>false</code>. */ public boolean isCurrentThreadEDTorNEDT(); - + /** * @return True if EDT is running and not subject to be stopped. */ public boolean isRunning(); - /** + /** * Append the final task to the EDT task queue, * signals EDT to stop. * <p> @@ -133,22 +133,22 @@ public interface EDTUtil { * <li>{@link #start()} may follow immediately, ie creating a new EDT</li> * </ul> * </p> - * @return true if <code>task</code> has been executed or queued for later execution, otherwise false + * @return true if <code>task</code> has been executed or queued for later execution, otherwise false */ public boolean invokeStop(boolean wait, Runnable finalTask); - /** + /** * Appends task to the EDT task queue if current thread is not EDT, - * otherwise execute task immediately. + * otherwise execute task immediately. * <p> * Wait until execution is finished if <code>wait == true</code>. * </p> * Can be issued from within EDT, ie from within an enqueued task.<br> - * @return true if <code>task</code> has been executed or queued for later execution, otherwise false + * @return true if <code>task</code> has been executed or queued for later execution, otherwise false */ public boolean invoke(boolean wait, Runnable task); - /** + /** * Wait until the EDT task queue is empty.<br> * The last task may still be in execution when this method returns. * @return true if waited for idle, otherwise false, i.e. in case of current thread is EDT or NEDT diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index 5e79e9b49..049320b21 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution 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. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,7 +29,7 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. @@ -54,13 +54,13 @@ import jogamp.newt.NEWTJNILibLoader; * NEWT Utility class MainThread<P> * * <p> - * FIXME: Update this documentation! + * FIXME: Update this documentation! * This class just provides a main-thread utility, forking of a main java class * on another thread while being able to continue doing platform specific things * on the main-thread. The latter is essential for eg. MacOSX, where we continue * to run NSApp.run(). * </p> - * + * * This class provides a startup singleton <i>main thread</i>, * from which a new thread with the users main class is launched.<br> * @@ -72,17 +72,17 @@ import jogamp.newt.NEWTJNILibLoader; * use a NEWT multithreaded application with window handling within the different threads, * even on these restricted platforms.<br> * - * To support your NEWT Window platform, + * To support your NEWT Window platform, * you have to pass your <i>main thread</i> actions to {@link #invoke invoke(..)}, * have a look at the {@link jogamp.newt.driver.macosx.WindowDriver NEWT Mac OSX Window} driver implementation.<br> - * <i>TODO</i>: Some hardcoded dependencies exist in this implementation, + * <i>TODO</i>: Some hardcoded dependencies exist in this implementation, * where you have to patch this code or factor it out. <P> - * + * * If your platform is not Mac OS X, but you want to test your code without modifying * this class, you have to set the system property <code>newt.MainThread.force</code> to <code>true</code>.<P> * * The code is compatible with all other platform, which support multithreaded windowing handling. - * Since those platforms won't trigger the <i>main thread</i> serialization, the main method + * Since those platforms won't trigger the <i>main thread</i> serialization, the main method * will be simply executed, in case you haven't set <code>newt.MainThread.force</code> to <code>true</code>.<P> * * Test case on Mac OS X (or any other platform): @@ -96,35 +96,35 @@ public class MainThread { private static final Platform.OSType osType; private static final boolean isMacOSX; private static final ThreadGroup rootThreadGroup; - + /** if true, use the main thread EDT, otherwise AWT's EDT */ public static final boolean HINT_USE_MAIN_THREAD; - + static { NativeWindowFactory.initSingleton(); NEWTJNILibLoader.loadNEWT(); - HINT_USE_MAIN_THREAD = !NativeWindowFactory.isAWTAvailable() || + HINT_USE_MAIN_THREAD = !NativeWindowFactory.isAWTAvailable() || Debug.getBooleanProperty("newt.MainThread.force", true); osType = Platform.getOSType(); isMacOSX = osType == Platform.OSType.MACOS; rootThreadGroup = getRootThreadGroup(); } - + public static boolean useMainThread = false; - + protected static final boolean DEBUG = Debug.debug("MainThread"); private static final MainThread singletonMainThread = new MainThread(); // one singleton MainThread - + private static final ThreadGroup getRootThreadGroup() { ThreadGroup rootGroup = Thread.currentThread( ).getThreadGroup( ); ThreadGroup parentGroup; while ( ( parentGroup = rootGroup.getParent() ) != null ) { rootGroup = parentGroup; } - return rootGroup; + return rootGroup; } - + private static final Thread[] getAllThreads(int[] count) { int tn; Thread[] threads = new Thread[ rootThreadGroup.activeCount() ]; @@ -149,17 +149,17 @@ public class MainThread { t.printStackTrace(); } } - return res; + return res; } private static final int getNonDaemonThreadCount(List<Thread> ignoreThreads) { int res = 0; int[] tn = { 0 }; Thread[] threads = getAllThreads(tn); - + for(int i = tn[0] - 1; i >= 0; i--) { final Thread thread = threads[i]; try { - if(thread.isAlive() && !thread.isDaemon() && !ignoreThreads.contains(thread)) { + if(thread.isAlive() && !thread.isDaemon() && !ignoreThreads.contains(thread)) { res++; if(DEBUG) System.err.println("MainAction.run(): non daemon thread: "+thread); } @@ -167,9 +167,9 @@ public class MainThread { t.printStackTrace(); } } - return res; + return res; } - + static class UserApp extends Thread { private final String mainClassNameShort; private final String mainClassName; @@ -181,7 +181,7 @@ public class MainThread { super(); this.mainClassName=mainClassName; this.mainClassArgs=mainClassArgs; - + final Class<?> mainClass = ReflectionUtil.getClass(mainClassName, true, getClass().getClassLoader()); if(null==mainClass) { throw new ClassNotFoundException("MainAction couldn't find main class "+mainClassName); @@ -192,7 +192,7 @@ public class MainThread { setName(getName()+"-UserApp-"+mainClassNameShort); setDaemon(false); - + if(DEBUG) System.err.println("MainAction(): instantiated: "+getName()+", is daemon "+isDaemon()+", main-class: "+mainClass.getName()); } @@ -230,32 +230,32 @@ public class MainThread { if(isMacOSX) { try { if(DEBUG) { - System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.0"); + System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.0"); } - ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "stopNSApplication", + ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "stopNSApplication", null, null, MainThread.class.getClassLoader()); if(DEBUG) { - System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.X"); + System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.X"); } } catch (Exception e) { e.printStackTrace(); } } else { if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainAction fin - System.exit(0)"); - System.exit(0); - } + System.exit(0); + } } } } private static UserApp mainAction; - /** Your new java application main entry, which pipelines your application - * @throws ClassNotFoundException - * @throws NoSuchMethodException + /** Your new java application main entry, which pipelines your application + * @throws ClassNotFoundException + * @throws NoSuchMethodException * @throws SecurityException */ public static void main(String[] args) throws SecurityException, NoSuchMethodException, ClassNotFoundException { final Thread cur = Thread.currentThread(); - + useMainThread = HINT_USE_MAIN_THREAD; if(DEBUG) { @@ -268,7 +268,7 @@ public class MainThread { if(!useMainThread && !NativeWindowFactory.isAWTAvailable()) { throw new RuntimeException("!USE_MAIN_THREAD and no AWT available"); } - + if(args.length==0) { return; } @@ -282,7 +282,7 @@ public class MainThread { mainAction = new UserApp(mainClassName, mainClassArgs); if(isMacOSX) { - ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "initSingleton", + ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "initSingleton", null, null, MainThread.class.getClassLoader()); } @@ -290,24 +290,24 @@ public class MainThread { try { cur.setName(cur.getName()+"-MainThread"); } catch (Exception e) {} - + // dispatch user's main thread .. mainAction.start(); - + if(isMacOSX) { try { if(DEBUG) { - System.err.println("MainThread.main(): "+cur.getName()+"- runNSApp"); + System.err.println("MainThread.main(): "+cur.getName()+"- runNSApp"); } - ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "runNSApplication", + ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "runNSApplication", null, null, MainThread.class.getClassLoader()); } catch (Exception e) { e.printStackTrace(); } - } - if(DEBUG) { System.err.println("MainThread - wait until last non daemon thread ends ..."); } + } + if(DEBUG) { System.err.println("MainThread - wait until last non daemon thread ends ..."); } } else { - // run user's main in this thread + // run user's main in this thread mainAction.run(); } } diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java index c30b427d6..fdd7985fe 100644 --- a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java @@ -42,7 +42,7 @@ import javax.media.nativewindow.util.SurfaceSize; * filters etc. */ public class MonitorModeUtil { - + public static int getIndex(List<MonitorMode> monitorModes, MonitorMode search) { return monitorModes.indexOf(search); } @@ -69,7 +69,7 @@ public class MonitorModeUtil { } return null; } - + /** Sort the given {@link MonitorMode} collection w/ {@link MonitorMode#compareTo(MonitorMode)} function. */ public static void sort(List<MonitorMode> monitorModes, boolean ascendingOrder) { if( ascendingOrder ) { @@ -78,9 +78,9 @@ public class MonitorModeUtil { Collections.sort(monitorModes, MonitorMode.monitorModeComparatorInv); } } - + /** - * + * * @param monitorModes * @param surfaceSize * @return modes with exact {@link SurfaceSize}. May return zero sized list for non. @@ -99,7 +99,7 @@ public class MonitorModeUtil { } /** - * + * * @param monitorModes * @param rotation * @return modes with exact rotation. May return zero sized list for non. @@ -118,7 +118,7 @@ public class MonitorModeUtil { } /** - * + * * @param monitorModes * @param bitsPerPixel * @return modes with exact bpp. May return zero sized list for non. @@ -137,7 +137,7 @@ public class MonitorModeUtil { } /** - * + * * @param monitorModes * @param flags * @return modes with exact flags. May return zero sized list for non. @@ -165,7 +165,7 @@ public class MonitorModeUtil { if( null!=monitorModes && monitorModes.size()>0 ) { final int resolution_sq = resolution.getHeight()*resolution.getWidth(); int mode_dsq=Integer.MAX_VALUE, mode_dsq_idx=0; - + for (int i=0; null!=monitorModes && i<monitorModes.size(); i++) { final MonitorMode mode = monitorModes.get(i); final DimensionImmutable res = mode.getSurfaceSize().getResolution(); @@ -236,7 +236,7 @@ public class MonitorModeUtil { } /** - * + * * @param monitorModes * @return modes with highest available refresh rate. May return zero sized list for non. */ |