summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-02-26 22:41:04 +0100
committerSven Gothel <[email protected]>2011-02-26 22:41:04 +0100
commit10c696f7e908ccbf150838f86b286b7c383058c6 (patch)
treec39fb70e8223ae86be61c4926fdf4c91a6734c73 /src/newt/classes/jogamp
parent76444dce2b678a7f6769564abac4f8a73f414609 (diff)
Code cleanup: override, imports, StringBuilder, ..
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/DisplayImpl.java26
-rw-r--r--src/newt/classes/jogamp/newt/OffscreenWindow.java7
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java19
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java23
-rw-r--r--src/newt/classes/jogamp/newt/awt/AWTEDTUtil.java2
-rw-r--r--src/newt/classes/jogamp/newt/awt/AWTWindow.java6
-rw-r--r--src/newt/classes/jogamp/newt/awt/opengl/VersionApplet.java2
-rw-r--r--src/newt/classes/jogamp/newt/intel/gdl/Window.java1
-rw-r--r--src/newt/classes/jogamp/newt/macosx/MacDisplay.java3
-rw-r--r--src/newt/classes/jogamp/newt/macosx/MacWindow.java6
-rw-r--r--src/newt/classes/jogamp/newt/opengl/broadcom/egl/Window.java1
-rw-r--r--src/newt/classes/jogamp/newt/opengl/kd/KDWindow.java1
-rw-r--r--src/newt/classes/jogamp/newt/windows/WindowsWindow.java6
-rw-r--r--src/newt/classes/jogamp/newt/x11/X11Window.java1
14 files changed, 87 insertions, 17 deletions
diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java
index 0485c4603..83f4ca47c 100644
--- a/src/newt/classes/jogamp/newt/DisplayImpl.java
+++ b/src/newt/classes/jogamp/newt/DisplayImpl.java
@@ -108,6 +108,27 @@ public abstract class DisplayImpl extends Display {
}
}
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final DisplayImpl other = (DisplayImpl) obj;
+ if (this.id != other.id) {
+ return false;
+ }
+ if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
+ return false;
+ }
+ if ((this.type == null) ? (other.type != null) : !this.type.equals(other.type)) {
+ return false;
+ }
+ return true;
+ }
+
public int hashCode() {
return hashCode;
}
@@ -289,10 +310,10 @@ public abstract class DisplayImpl extends Display {
return ( null == name ) ? nilString : name ;
}
- private static final String getFQName(String type, String name, int id) {
+ private static String getFQName(String type, String name, int id) {
if(null==type) type=nilString;
if(null==name) name=nilString;
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(type);
sb.append("_");
sb.append(name);
@@ -323,6 +344,7 @@ public abstract class DisplayImpl extends Display {
return false;
}
+ @Override
public String toString() {
return "NEWT-Display["+getFQName()+", refCount "+refCount+", hasEDT "+(null!=edtUtil)+", edtRunning "+isEDTRunning()+", "+aDevice+"]";
}
diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java
index 1465e084c..a79b1a5a1 100644
--- a/src/newt/classes/jogamp/newt/OffscreenWindow.java
+++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java
@@ -69,11 +69,13 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
// nop
}
+ @Override
protected void invalidate(boolean unrecoverable) {
super.invalidate(unrecoverable);
surfaceHandle = 0;
}
+ @Override
public synchronized void destroy() {
super.destroy();
surfaceHandle = 0;
@@ -83,6 +85,7 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
surfaceHandle = handle ;
}
+ @Override
public long getSurfaceHandle() {
return surfaceHandle;
}
@@ -95,14 +98,17 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
protected void requestFocusImpl(boolean reparented) {
}
+ @Override
public void setSize(int width, int height) {
if(!visible) {
sizeChanged(width, height, false);
}
}
+ @Override
public void setPosition(int x, int y) {
// nop
}
+ @Override
public boolean setFullscreen(boolean fullscreen) {
// nop
return false;
@@ -112,6 +118,7 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
return false;
}
+ @Override
public Point getLocationOnScreen(Point storage) {
if(null!=storage) {
storage.setX(0);
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index e940512a3..065cd88eb 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -126,6 +126,24 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
}
}
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ScreenImpl other = (ScreenImpl) obj;
+ if (this.display != other.display && (this.display == null || !this.display.equals(other.display))) {
+ return false;
+ }
+ if (this.screen_idx != other.screen_idx) {
+ return false;
+ }
+ return true;
+ }
+
public int hashCode() {
return hashCode;
}
@@ -239,6 +257,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
return (usrHeight>0) ? usrHeight : (height>0) ? height : 480;
}
+ @Override
public String toString() {
return "NEWT-Screen["+getFQName()+", idx "+screen_idx+", refCount "+refCount+", "+getWidth()+"x"+getHeight()+", "+aScreen+", "+display+"]";
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 815fd705e..391f918cf 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -692,7 +692,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
if(DEBUG_IMPLEMENTATION) {
- String msg = new String("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)/*+", "+this*/);
+ String msg = "Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow);
System.err.println(msg);
Thread.dumpStack();
}
@@ -717,7 +717,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
try {
if ( !fullscreen && ( width != WindowImpl.this.width || WindowImpl.this.height != height ) ) {
if(DEBUG_IMPLEMENTATION) {
- String msg = new String("Window setSize: START "+WindowImpl.this.width+"x"+WindowImpl.this.height+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible);
+ String msg = "Window setSize: START "+WindowImpl.this.width+"x"+WindowImpl.this.height+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible;
System.err.println(msg);
}
if ( 0 != windowHandle && 0>=width*height && visible ) {
@@ -803,7 +803,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
public void destroy() {
if( isValid() ) {
if(DEBUG_IMPLEMENTATION) {
- String msg = new String("Window.destroy() START "+getThreadName()/*+", "+this*/);
+ String msg = "Window.destroy() START "+getThreadName();
System.err.println(msg);
//Exception ee = new Exception(msg);
//ee.printStackTrace();
@@ -839,7 +839,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
windowLock.lock();
try {
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- String msg = new String("!!! Window Invalidate(unrecoverable: "+unrecoverable+") "+getThreadName());
+ String msg = "!!! Window Invalidate(unrecoverable: "+unrecoverable+") "+getThreadName();
System.err.println(msg);
// Throwable t = new Throwable(msg);
// t.printStackTrace();
@@ -915,7 +915,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return reparentAction;
}
- private final void setScreen(ScreenImpl newScreen) {
+ private void setScreen(ScreenImpl newScreen) {
WindowImpl.this.removeScreenReference();
screen = newScreen;
}
@@ -1381,8 +1381,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return parentWindowHandle;
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(getClass().getName()+"[Config "+config+
"\n, "+screen+
@@ -1422,11 +1423,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
public void runOnEDTIfAvail(boolean wait, final Runnable task) {
- Screen screen = getScreen();
- if(null==screen) {
+ Screen scrn = getScreen();
+ if(null==scrn) {
throw new RuntimeException("Null screen of inner class: "+this);
}
- DisplayImpl d = (DisplayImpl) screen.getDisplay();
+ DisplayImpl d = (DisplayImpl) scrn.getDisplay();
d.runOnEDTIfAvail(wait, task);
}
@@ -2208,7 +2209,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
private static String getArgsStrList(Object[] args) {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for(int i=0; i<args.length; i++) {
sb.append(args[i].getClass());
if(i<args.length) {
@@ -2219,7 +2220,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
private static String getTypeStrList(Class[] types) {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for(int i=0; i<types.length; i++) {
sb.append(types[i]);
if(i<types.length) {
diff --git a/src/newt/classes/jogamp/newt/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/awt/AWTEDTUtil.java
index 914a73f4d..7b638af31 100644
--- a/src/newt/classes/jogamp/newt/awt/AWTEDTUtil.java
+++ b/src/newt/classes/jogamp/newt/awt/AWTEDTUtil.java
@@ -38,7 +38,7 @@ public class AWTEDTUtil implements EDTUtil {
private static AWTEDTUtil singletonMainThread = new AWTEDTUtil(); // one singleton MainThread
- public static final AWTEDTUtil getSingleton() {
+ public static AWTEDTUtil getSingleton() {
return singletonMainThread;
}
diff --git a/src/newt/classes/jogamp/newt/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/awt/AWTWindow.java
index ae18fcfa6..b07a9e313 100644
--- a/src/newt/classes/jogamp/newt/awt/AWTWindow.java
+++ b/src/newt/classes/jogamp/newt/awt/AWTWindow.java
@@ -80,6 +80,7 @@ public class AWTWindow extends WindowImpl {
container.requestFocus();
}
+ @Override
protected void setTitleImpl(final String title) {
if (frame != null) {
frame.setTitle(title);
@@ -141,6 +142,7 @@ public class AWTWindow extends WindowImpl {
}
}
+ @Override
public boolean hasDeviceChanged() {
boolean res = canvas.hasDeviceChanged();
if(res) {
@@ -179,6 +181,7 @@ public class AWTWindow extends WindowImpl {
}
+ @Override
public javax.media.nativewindow.util.Insets getInsets() {
final int insets[] = new int[] { 0, 0, 0, 0 };
Insets contInsets = container.getInsets();
@@ -217,17 +220,20 @@ public class AWTWindow extends WindowImpl {
return new Point((int)(ap.getX()+0.5),(int)(ap.getY()+0.5));
}
+ @Override
public Object getWrappedWindow() {
return canvas;
}
class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter {
+ @Override
public void windowMoved(com.jogamp.newt.event.WindowEvent e) {
if(null!=container) {
x = container.getX();
y = container.getY();
}
}
+ @Override
public void windowResized(com.jogamp.newt.event.WindowEvent e) {
if(null!=canvas) {
width = canvas.getWidth();
diff --git a/src/newt/classes/jogamp/newt/awt/opengl/VersionApplet.java b/src/newt/classes/jogamp/newt/awt/opengl/VersionApplet.java
index 7f234a0f8..18524d0ba 100644
--- a/src/newt/classes/jogamp/newt/awt/opengl/VersionApplet.java
+++ b/src/newt/classes/jogamp/newt/awt/opengl/VersionApplet.java
@@ -156,7 +156,7 @@ public class VersionApplet extends Applet {
class GLInfo implements GLEventListener {
public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
- String s = JoglVersion.getInstance().getGLInfo(gl, null).toString();
+ String s = JoglVersion.getGLInfo(gl, null).toString();
System.err.println(s);
tareaVersion.append(s);
}
diff --git a/src/newt/classes/jogamp/newt/intel/gdl/Window.java b/src/newt/classes/jogamp/newt/intel/gdl/Window.java
index 8ba861c7d..d6003beae 100644
--- a/src/newt/classes/jogamp/newt/intel/gdl/Window.java
+++ b/src/newt/classes/jogamp/newt/intel/gdl/Window.java
@@ -119,6 +119,7 @@ public class Window extends jogamp.newt.WindowImpl {
((Display)getScreen().getDisplay()).setFocus(this);
}
+ @Override
public final long getSurfaceHandle() {
return surfaceHandle;
}
diff --git a/src/newt/classes/jogamp/newt/macosx/MacDisplay.java b/src/newt/classes/jogamp/newt/macosx/MacDisplay.java
index e4639080e..49f2ff5d8 100644
--- a/src/newt/classes/jogamp/newt/macosx/MacDisplay.java
+++ b/src/newt/classes/jogamp/newt/macosx/MacDisplay.java
@@ -35,10 +35,8 @@ package jogamp.newt.macosx;
import javax.media.nativewindow.*;
import javax.media.nativewindow.macosx.*;
-import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.newt.*;
import jogamp.newt.*;
-import com.jogamp.newt.util.EDTUtil;
import com.jogamp.newt.util.MainThread;
public class MacDisplay extends DisplayImpl {
@@ -73,6 +71,7 @@ public class MacDisplay extends DisplayImpl {
protected void closeNativeImpl() { }
+ @Override
protected void createEDTUtil() {
if(NewtFactory.useEDT()) {
final Display f_dpy = this;
diff --git a/src/newt/classes/jogamp/newt/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/macosx/MacWindow.java
index 62f0cf458..a27f04797 100644
--- a/src/newt/classes/jogamp/newt/macosx/MacWindow.java
+++ b/src/newt/classes/jogamp/newt/macosx/MacWindow.java
@@ -168,10 +168,12 @@ public class MacWindow extends WindowImpl {
}
}
+ @Override
public final long getSurfaceHandle() {
return surfaceHandle;
}
+ @Override
public Insets getInsets() {
// in order to properly calculate insets we need the window to be
// created
@@ -186,11 +188,13 @@ public class MacWindow extends WindowImpl {
private RecursiveLock nsViewLock = new RecursiveLock();
+ @Override
protected int lockSurfaceImpl() {
nsViewLock.lock();
return LOCK_SUCCESS;
}
+ @Override
protected void unlockSurfaceImpl() {
nsViewLock.unlock();
}
@@ -214,6 +218,7 @@ public class MacWindow extends WindowImpl {
}
}
+ @Override
protected void setTitleImpl(final String title) {
// FIXME: move nsViewLock up to window lock
nsViewLock.lock();
@@ -364,6 +369,7 @@ public class MacWindow extends WindowImpl {
return keyChar;
}
+ @Override
public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) {
int key = convertKeyChar(keyChar);
if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName());
diff --git a/src/newt/classes/jogamp/newt/opengl/broadcom/egl/Window.java b/src/newt/classes/jogamp/newt/opengl/broadcom/egl/Window.java
index 0db21c3be..9532178f3 100644
--- a/src/newt/classes/jogamp/newt/opengl/broadcom/egl/Window.java
+++ b/src/newt/classes/jogamp/newt/opengl/broadcom/egl/Window.java
@@ -120,6 +120,7 @@ public class Window extends jogamp.newt.WindowImpl {
}
+ @Override
public boolean surfaceSwap() {
SwapWindow(getDisplayHandle(), getWindowHandle());
return true;
diff --git a/src/newt/classes/jogamp/newt/opengl/kd/KDWindow.java b/src/newt/classes/jogamp/newt/opengl/kd/KDWindow.java
index b902441d3..9cfa13cd9 100644
--- a/src/newt/classes/jogamp/newt/opengl/kd/KDWindow.java
+++ b/src/newt/classes/jogamp/newt/opengl/kd/KDWindow.java
@@ -134,6 +134,7 @@ public class KDWindow extends WindowImpl {
windowUserData=userData;
}
+ @Override
protected void sizeChanged(int newWidth, int newHeight, boolean force) {
if(fullscreen) {
((KDScreen)getScreen()).setScreenSize(width, height);
diff --git a/src/newt/classes/jogamp/newt/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/windows/WindowsWindow.java
index 05d169c5e..653de295d 100644
--- a/src/newt/classes/jogamp/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/jogamp/newt/windows/WindowsWindow.java
@@ -55,6 +55,7 @@ public class WindowsWindow extends WindowImpl {
public WindowsWindow() {
}
+ @Override
protected int lockSurfaceImpl() {
if (0 != hdc) {
throw new InternalError("surface not released");
@@ -64,6 +65,7 @@ public class WindowsWindow extends WindowImpl {
return ( 0 != hdc ) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY;
}
+ @Override
protected void unlockSurfaceImpl() {
if (0 == hdc) {
throw new InternalError("surface not acquired");
@@ -72,10 +74,12 @@ public class WindowsWindow extends WindowImpl {
hdc=0;
}
+ @Override
public final long getSurfaceHandle() {
return hdc;
}
+ @Override
public boolean hasDeviceChanged() {
if(0!=getWindowHandle()) {
long _hmon = MonitorFromWindow0(getWindowHandle());
@@ -158,10 +162,12 @@ public class WindowsWindow extends WindowImpl {
requestFocus0(getWindowHandle(), force);
}
+ @Override
protected void setTitleImpl(final String title) {
setTitle0(getWindowHandle(), title);
}
+ @Override
public Insets getInsets() {
return (Insets)insets.clone();
}
diff --git a/src/newt/classes/jogamp/newt/x11/X11Window.java b/src/newt/classes/jogamp/newt/x11/X11Window.java
index 6f8eb0380..8f9455629 100644
--- a/src/newt/classes/jogamp/newt/x11/X11Window.java
+++ b/src/newt/classes/jogamp/newt/x11/X11Window.java
@@ -106,6 +106,7 @@ public class X11Window extends WindowImpl {
requestFocus0(getDisplayHandle(), getWindowHandle(), force);
}
+ @Override
protected void setTitleImpl(String title) {
setTitle0(getDisplayHandle(), getWindowHandle(), title);
}