diff options
author | Sven Gothel <[email protected]> | 2023-01-31 22:39:47 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-01-31 22:39:47 +0100 |
commit | 97de7b52b8c0ca7f1afff394321a15e7f3df293d (patch) | |
tree | 7b644f0f1fb04a4f6793b7d2f266cf4f03601ab8 /src/newt/classes/com | |
parent | 1632172369d0d6fee2ab21788582033dc316c7af (diff) |
NEWT Screen: Cleanup get*Monitor*() methods
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/Screen.java | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 7f6ffeb13..d670c0d83 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -228,9 +228,7 @@ public abstract class Screen { MonitorDevice res = null; float maxCoverage = Float.MIN_VALUE; final List<MonitorDevice> monitors = getMonitorDevices(); - final int monitorCount = monitors.size(); - for(int i=0; i<monitorCount; i++) { - final MonitorDevice monitor = monitors.get(i); + for(final MonitorDevice monitor : monitors) { if( !monitor.isClone() ) { final float coverage = monitor.getViewportInWindowUnits().coverage(r); if( coverage > maxCoverage ) { @@ -245,11 +243,17 @@ public abstract class Screen { return monitors.get(0); } + /** + * Returns the {@link MonitorDevice} which completely which {@link MonitorDevice#getViewportInWindowUnits() viewport} + * completely {@link RectangleImmutable#contains(RectangleImmutable) coverage} the given rectangle in window units, + * which is not a {@link MonitorDevice#isClone() clone}. + * <p> + * If no match is found, null is being returned + * </p> + * @param r arbitrary rectangle in window units + */ public final MonitorDevice getFullyEnteredMonitor(final RectangleImmutable r) { - final List<MonitorDevice> monitors = getMonitorDevices(); - final int monitorCount = monitors.size(); - for(int i=0; i<monitorCount; i++) { - final MonitorDevice monitor = monitors.get(i); + for(final MonitorDevice monitor : getMonitorDevices()) { if( !monitor.isClone() && monitor.getViewportInWindowUnits().contains(r) ) { return monitor; } @@ -257,11 +261,14 @@ public abstract class Screen { return null; } + /** + * Returns the {@link MonitorDevice} which matches the given integer monitorId. + * <p> + * If no match is found, null is being returned + * </p> + */ public final MonitorDevice getMonitorById(final int monitorId) { - final List<MonitorDevice> monitors = getMonitorDevices(); - final int monitorCount = monitors.size(); - for(int i=0; i<monitorCount; i++) { - final MonitorDevice monitor = monitors.get(i); + for(final MonitorDevice monitor : getMonitorDevices()) { if( monitor.getId() == monitorId ) { return monitor; } @@ -269,11 +276,14 @@ public abstract class Screen { return null; } + /** + * Returns the {@link MonitorDevice} which matches the given long monitorHandle. + * <p> + * If no match is found, null is being returned + * </p> + */ public final MonitorDevice getMonitorByHandle(final long monitorHandle) { - final List<MonitorDevice> monitors = getMonitorDevices(); - final int monitorCount = monitors.size(); - for(int i=0; i<monitorCount; i++) { - final MonitorDevice monitor = monitors.get(i); + for(final MonitorDevice monitor : getMonitorDevices()) { if( monitor.getHandle() == monitorHandle ) { return monitor; } |