pixelDensity (FX): clean up placement code

This commit is contained in:
Jakub Valtar
2017-04-13 15:01:05 +02:00
parent b0c5575d2c
commit 19e7bcf315
+4 -49
View File
@@ -301,17 +301,8 @@ public class PSurfaceFX implements PSurface {
maxY = Math.max(maxY, bounds.getMaxY());
}
}
if (minY < 0) {
// FX can't handle this
System.err.format("FX can't place window at negative Y coordinate " +
"[x=%d, y=%d]. Please make sure that your secondary " +
"display does not extend above the main display.",
(int) minX, (int) minY);
screenRect = primaryScreenRect;
} else {
screenRect = new Rectangle((int) minX, (int) minY,
(int) (maxX - minX), (int) (maxY - minY));
}
screenRect = new Rectangle((int) minX, (int) minY,
(int) (maxX - minX), (int) (maxY - minY));
}
// Set the displayWidth/Height variables inside PApplet, so that they're
@@ -558,10 +549,6 @@ public class PSurfaceFX implements PSurface {
return;
}
//Dimension window = setFrameSize();
// int contentW = Math.max(sketchWidth, MIN_WINDOW_WIDTH);
// int contentH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT);
// System.out.println("stage size is " + stage.getWidth() + " " + stage.getHeight());
int wide = sketch.width; // stage.getWidth() is NaN here
int high = sketch.height; // stage.getHeight()
@@ -581,42 +568,10 @@ public class PSurfaceFX implements PSurface {
stage.setY(locationY);
} else { // doesn't fit
// // if it fits inside the editor window,
// // offset slightly from upper lefthand corner
// // so that it's plunked inside the text area
// locationX = editorLocation[0] + 66;
// locationY = editorLocation[1] + 66;
//
// if ((locationX + stage.getWidth() > sketch.displayWidth - 33) ||
// (locationY + stage.getHeight() > sketch.displayHeight - 33)) {
// // otherwise center on screen
// locationX = (int) ((sketch.displayWidth - wide) / 2);
// locationY = (int) ((sketch.displayHeight - high) / 2);
// }
locationX = (sketch.displayWidth - wide) / 2;
locationY = (sketch.displayHeight - high) / 2;
stage.setX(locationX);
stage.setY(locationY);
stage.centerOnScreen();
}
} else { // just center on screen
//setFrameCentered();
}
if (stage.getY() < 0) {
// Windows actually allows you to place frames where they can't be
// closed. Awesome. http://dev.processing.org/bugs/show_bug.cgi?id=1508
//frame.setLocation(frameLoc.x, 30);
stage.setY(30);
}
//canvas.setBounds((contentW - sketchWidth)/2,
// (contentH - sketchHeight)/2,
// sketchWidth, sketchHeight);
// handle frame resizing events
//setupFrameResizeListener();
if (sketch.getGraphics().displayable()) {
setVisible(true);
stage.centerOnScreen();
}
}