(final PApplet sketch)
| 285 | |
| 286 | |
| 287 | @Override |
| 288 | public void initFrame(final PApplet sketch) {/*, int backgroundColor, |
| 289 | int deviceIndex, boolean fullScreen, boolean spanDisplays) {*/ |
| 290 | this.sketch = sketch; |
| 291 | |
| 292 | GraphicsEnvironment environment = |
| 293 | GraphicsEnvironment.getLocalGraphicsEnvironment(); |
| 294 | GraphicsDevice defaultDevice = |
| 295 | environment.getDefaultScreenDevice(); |
| 296 | |
| 297 | int displayNum = sketch.sketchDisplay(); |
| 298 | // System.out.println("display from sketch is " + displayNum); |
| 299 | if (displayNum > 0) { // if -1, use the default device |
| 300 | GraphicsDevice[] devices = environment.getScreenDevices(); |
| 301 | if (displayNum <= devices.length) { |
| 302 | displayDevice = devices[displayNum - 1]; |
| 303 | } else { |
| 304 | System.err.format("Display %d does not exist, " + |
| 305 | "using the default display instead.%n", displayNum); |
| 306 | if (devices.length > 1) { |
| 307 | System.err.println("Available displays:"); |
| 308 | // The code below is cribbed from the version in PreferencesFrame, |
| 309 | // though it uses \u00d7 and removes the space between because |
| 310 | // it's printing in a monospace font to the console. |
| 311 | for (int i = 0; i < devices.length; i++) { |
| 312 | DisplayMode mode = devices[i].getDisplayMode(); |
| 313 | // \u00d7 supported more widely than \u2715 (and a better size) |
| 314 | String title = String.format("%d (%d\u00d7%d)", |
| 315 | i + 1, mode.getWidth(), mode.getHeight()); |
| 316 | if (devices[i] == defaultDevice) { |
| 317 | title += " default"; |
| 318 | } |
| 319 | System.err.println(title); |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | if (displayDevice == null) { |
| 325 | displayDevice = defaultDevice; |
| 326 | } |
| 327 | |
| 328 | // Need to save the window bounds at full screen, |
| 329 | // because pack() will cause the bounds to go to zero. |
| 330 | // https://download.processing.org/bugzilla/923.html |
| 331 | boolean spanDisplays = sketch.sketchDisplay() == PConstants.SPAN; |
| 332 | screenRect = spanDisplays ? getDisplaySpan() : |
| 333 | displayDevice.getDefaultConfiguration().getBounds(); |
| 334 | // DisplayMode doesn't work here, because we can't get the upper-left |
| 335 | // corner of the display, which is important for multi-display setups. |
| 336 | |
| 337 | // Set the displayWidth/Height variables inside PApplet, so that they're |
| 338 | // usable and can even be returned by the sketchWidth()/Height() methods. |
| 339 | sketch.displayWidth = screenRect.width; |
| 340 | sketch.displayHeight = screenRect.height; |
| 341 | |
| 342 | // windowScaleFactor = PApplet.platform == PConstants.MACOS ? |
| 343 | // 1 : sketch.pixelDensity; |
| 344 |
nothing calls this directly
no test coverage detected