feed the automation settings into the movers
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package wtf.beatrice.autosqueal.util;
|
||||
|
||||
import wtf.beatrice.autosqueal.config.ScreenArea;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class RunnerUtil {
|
||||
@@ -8,9 +10,35 @@ public class RunnerUtil {
|
||||
throw new AssertionError("The RunnerUtil class is not intended to be instantiated.");
|
||||
}
|
||||
|
||||
public static final int SECONDS_BETWEEN_MOVES = 10;
|
||||
|
||||
public static final int SCREEN_HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;
|
||||
public static final int SCREEN_WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
|
||||
|
||||
/**
|
||||
* The bounds of the screens the cursor may travel to, according to the
|
||||
* given setting. Fetched on every call, so that a change of setting, or
|
||||
* a screen plugged in while the app runs, is picked up by the next
|
||||
* movement.
|
||||
*
|
||||
* The result is never empty: when no screen is found, the main screen
|
||||
* is returned, because it always exists.
|
||||
*/
|
||||
public static Rectangle screenBounds(ScreenArea area) {
|
||||
Rectangle bounds = new Rectangle();
|
||||
|
||||
if (area == ScreenArea.ALL) {
|
||||
for (GraphicsDevice device : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
|
||||
bounds.add(device.getDefaultConfiguration().getBounds());
|
||||
}
|
||||
}
|
||||
|
||||
if (bounds.isEmpty()) {
|
||||
// the main screen was requested, or no other screen was found
|
||||
bounds = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration().getBounds();
|
||||
}
|
||||
|
||||
// defensive copy: the callers treat the rectangle as theirs
|
||||
return new Rectangle(bounds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user