summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-02-17 05:41:45 +0100
committerSven Gothel <[email protected]>2015-02-17 05:41:45 +0100
commit3ec3d5cedd7902b2fe14dc56a3f845cfe0752905 (patch)
tree0d22a4153f3faaf194ace0de1da5d6de513293f2 /src/newt
parent480f4251cf3cf530493611d8924f905cacc349d5 (diff)
MonitorDevice: Add 'throws IllegalStateException' for [query|set]CurrentMode(..) if !screen.isNativeValid()
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/MonitorDevice.java7
-rw-r--r--src/newt/classes/jogamp/newt/MonitorDeviceImpl.java14
2 files changed, 13 insertions, 8 deletions
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
index 9c12dcb58..ec38ce3c3 100644
--- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java
+++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
@@ -35,7 +35,6 @@ import com.jogamp.nativewindow.util.DimensionImmutable;
import com.jogamp.nativewindow.util.Rectangle;
import com.jogamp.nativewindow.util.RectangleImmutable;
import com.jogamp.nativewindow.util.SurfaceSize;
-
import com.jogamp.common.util.ArrayHashSet;
/**
@@ -317,16 +316,18 @@ public abstract class MonitorDevice {
* <p>
* The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}.
* </p>
+ * @throws IllegalStateException if the {@link #getScreen() associated screen} is not {@link Screen#isNativeValid() valid natively}.
* @see #getCurrentMode()
*/
- public abstract MonitorMode queryCurrentMode();
+ public abstract MonitorMode queryCurrentMode() throws IllegalStateException;
/**
* Set the current {@link com.jogamp.newt.MonitorMode}.
* @param mode to be made current, must be element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}.
* @return true if successful, otherwise false
+ * @throws IllegalStateException if the {@link #getScreen() associated screen} is not {@link Screen#isNativeValid() valid natively}.
*/
- public abstract boolean setCurrentMode(MonitorMode mode);
+ public abstract boolean setCurrentMode(MonitorMode mode) throws IllegalStateException;
@Override
public String toString() {
diff --git a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java
index 138aedc29..3f039a9f4 100644
--- a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java
+++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java
@@ -28,8 +28,6 @@
package jogamp.newt;
-import java.util.ArrayList;
-
import com.jogamp.nativewindow.ScalableSurface;
import com.jogamp.nativewindow.util.DimensionImmutable;
import com.jogamp.nativewindow.util.Rectangle;
@@ -59,8 +57,11 @@ public class MonitorDeviceImpl extends MonitorDevice {
}
@Override
- public final MonitorMode queryCurrentMode() {
+ public final MonitorMode queryCurrentMode() throws IllegalStateException {
final ScreenImpl screenImpl = (ScreenImpl)screen;
+ if( !screenImpl.isNativeValid() ) {
+ throw new IllegalStateException("Screen is not created natively: "+screenImpl);
+ }
final ScreenMonitorState sms = screenImpl.getScreenMonitorStatus(true);
sms.lock();
try {
@@ -89,11 +90,14 @@ public class MonitorDeviceImpl extends MonitorDevice {
}
@Override
- public final boolean setCurrentMode(final MonitorMode mode) {
+ public final boolean setCurrentMode(final MonitorMode mode) throws IllegalStateException {
+ final ScreenImpl screenImpl = (ScreenImpl)screen;
+ if( !screenImpl.isNativeValid() ) {
+ throw new IllegalStateException("Screen is not created natively: "+screenImpl);
+ }
if(Screen.DEBUG) {
System.err.println("Screen.setCurrentMode.0: "+this+" -> "+mode);
}
- final ScreenImpl screenImpl = (ScreenImpl)screen;
final ScreenMonitorState sms = screenImpl.getScreenMonitorStatus(true);
sms.lock();
try {