(final PApplet sketch)
| 386 | |
| 387 | |
| 388 | @Override |
| 389 | public void initFrame(final PApplet sketch) {/*, int backgroundColor, |
| 390 | int deviceIndex, boolean fullScreen, boolean spanDisplays) {*/ |
| 391 | this.sketch = sketch; |
| 392 | |
| 393 | GraphicsEnvironment environment = |
| 394 | GraphicsEnvironment.getLocalGraphicsEnvironment(); |
| 395 | |
| 396 | int displayNum = sketch.sketchDisplay(); |
| 397 | // System.out.println("display from sketch is " + displayNum); |
| 398 | if (displayNum > 0) { // if -1, use the default device |
| 399 | GraphicsDevice[] devices = environment.getScreenDevices(); |
| 400 | if (displayNum <= devices.length) { |
| 401 | displayDevice = devices[displayNum - 1]; |
| 402 | } else { |
| 403 | System.err.format("Display %d does not exist, " + |
| 404 | "using the default display instead.%n", displayNum); |
| 405 | for (int i = 0; i < devices.length; i++) { |
| 406 | System.err.format("Display %d is %s%n", (i+1), devices[i]); |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | if (displayDevice == null) { |
| 411 | displayDevice = environment.getDefaultScreenDevice(); |
| 412 | } |
| 413 | |
| 414 | // Need to save the window bounds at full screen, |
| 415 | // because pack() will cause the bounds to go to zero. |
| 416 | // http://dev.processing.org/bugs/show_bug.cgi?id=923 |
| 417 | boolean spanDisplays = sketch.sketchDisplay() == PConstants.SPAN; |
| 418 | screenRect = spanDisplays ? getDisplaySpan() : |
| 419 | displayDevice.getDefaultConfiguration().getBounds(); |
| 420 | // DisplayMode doesn't work here, because we can't get the upper-left |
| 421 | // corner of the display, which is important for multi-display setups. |
| 422 | |
| 423 | // Set the displayWidth/Height variables inside PApplet, so that they're |
| 424 | // usable and can even be returned by the sketchWidth()/Height() methods. |
| 425 | sketch.displayWidth = screenRect.width; |
| 426 | sketch.displayHeight = screenRect.height; |
| 427 | |
| 428 | windowScaleFactor = PApplet.platform == PConstants.MACOSX ? |
| 429 | 1 : sketch.pixelDensity; |
| 430 | |
| 431 | sketchWidth = sketch.sketchWidth() * windowScaleFactor; |
| 432 | sketchHeight = sketch.sketchHeight() * windowScaleFactor; |
| 433 | |
| 434 | boolean fullScreen = sketch.sketchFullScreen(); |
| 435 | // Removing the section below because sometimes people want to do the |
| 436 | // full screen size in a window, and it also breaks insideSettings(). |
| 437 | // With 3.x, fullScreen() is so easy, that it's just better that way. |
| 438 | // https://github.com/processing/processing/issues/3545 |
| 439 | /* |
| 440 | // Sketch has already requested to be the same as the screen's |
| 441 | // width and height, so let's roll with full screen mode. |
| 442 | if (screenRect.width == sketchWidth && |
| 443 | screenRect.height == sketchHeight) { |
| 444 | fullScreen = true; |
| 445 | sketch.fullScreen(); // won't change the renderer |
nothing calls this directly
no test coverage detected