本文整理汇总了Java中javafx.stage.Screen.getScreensForRectangle方法的典型用法代码示例。如果您正苦于以下问题:Java Screen.getScreensForRectangle方法的具体用法?Java Screen.getScreensForRectangle怎么用?Java Screen.getScreensForRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.stage.Screen
的用法示例。
在下文中一共展示了Screen.getScreensForRectangle方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: centerDialogOnScreen
import javafx.stage.Screen; //导入方法依赖的package包/类
/**
* Utility method to center a Dialog/Alert on the middle of the current
* screen. Used to workaround a "bug" with the current version of JavaFX (or
* the SWT/JavaFX embedding?) where alerts always show on the primary
* screen, not necessarily the current one.
*
* @param dialog
* The dialog to reposition. It must be already shown, or else
* this will do nothing.
* @param referenceNode
* The dialog should be moved to the same screen as this node's
* window.
*/
public static void centerDialogOnScreen(Dialog<?> dialog, Node referenceNode) {
Window window = referenceNode.getScene().getWindow();
if (window == null) {
return;
}
Rectangle2D windowRectangle = new Rectangle2D(window.getX(), window.getY(), window.getWidth(), window.getHeight());
List<Screen> screens = Screen.getScreensForRectangle(windowRectangle);
Screen screen = screens.stream()
.findFirst()
.orElse(Screen.getPrimary());
Rectangle2D screenBounds = screen.getBounds();
dialog.setX((screenBounds.getWidth() - dialog.getWidth()) / 2 + screenBounds.getMinX());
// dialog.setY((screenBounds.getHeight() - dialog.getHeight()) / 2 + screenBounds.getMinY());
}
示例2: isVisible
import javafx.stage.Screen; //导入方法依赖的package包/类
@Override
public boolean isVisible(final Placement placement) {
ObservableList<Screen> screens = Screen.getScreensForRectangle(rectangle(placement));
if (screens.size() == 1) {
Screen screen = screens.get(0);
Rectangle2D bounds = screen.getVisualBounds();
if (placement.isPositioned()) {
return bounds.contains(placement.getX(), placement.getY(), placement.getWidth(), placement.getHeight());
} else {
return bounds.getWidth() >= placement.getWidth() && bounds.getHeight() >= placement.getHeight();
}
} else {
return false;
}
}
示例3: setY
import javafx.stage.Screen; //导入方法依赖的package包/类
/**
* Sets the Y position of the given stage, if possible.
*
* @param pStage the stage
* @param pY the calculated new Y position
*/
private void setY(Stage pStage, double pY)
{
try
{
ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(pStage.getX(), pStage.getY(), pStage.getWidth(), pStage.getHeight());
if (screensForRectangle.size() > 0)
{
Screen screen = screensForRectangle.get(0);
Rectangle2D visualBounds = screen.getVisualBounds();
if (pY < visualBounds.getHeight() - pane.getActiveShadowSize() * 2 && pY + pane.getActiveShadowSize() >= visualBounds.getMinY())
{
pStage.setY(pY);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例4: findPopOverArrowLocation
import javafx.stage.Screen; //导入方法依赖的package包/类
public static ArrowLocation findPopOverArrowLocation(Node view) {
Bounds localBounds = view.getBoundsInLocal();
Bounds entryBounds = view.localToScreen(localBounds);
ObservableList<Screen> screens = Screen.getScreensForRectangle(
entryBounds.getMinX(), entryBounds.getMinY(),
entryBounds.getWidth(), entryBounds.getHeight());
Rectangle2D screenBounds = screens.get(0).getVisualBounds();
double spaceLeft = entryBounds.getMinX();
double spaceRight = screenBounds.getWidth() - entryBounds.getMaxX();
double spaceTop = entryBounds.getMinY();
double spaceBottom = screenBounds.getHeight() - entryBounds.getMaxY();
if (spaceLeft > spaceRight) {
if (spaceTop > spaceBottom) {
return ArrowLocation.RIGHT_BOTTOM;
}
return ArrowLocation.RIGHT_TOP;
}
if (spaceTop > spaceBottom) {
return ArrowLocation.LEFT_BOTTOM;
}
return ArrowLocation.LEFT_TOP;
}
示例5: moveStateToFullScreen
import javafx.stage.Screen; //导入方法依赖的package包/类
private void moveStateToFullScreen() {
// Get current screen of the stage
ObservableList<Screen> screens = Screen.getScreensForRectangle(new Rectangle2D(stageFloatable.getX(), stageFloatable.getY(), stageFloatable.getWidth(), stageFloatable.getHeight()));
// Change stage properties
Rectangle2D bounds = screens.get(0).getBounds();
stageFloatable.setX(bounds.getMinX() - FLOATING_NODE_DROPSHADOW_RADIUS);
stageFloatable.setY(bounds.getMinY() - FLOATING_NODE_DROPSHADOW_RADIUS);
stageFloatable.setWidth(bounds.getWidth() + FLOATING_NODE_DROPSHADOW_RADIUS * 2);
stageFloatable.setHeight(bounds.getHeight() + FLOATING_NODE_DROPSHADOW_RADIUS * 2);
}
示例6: getStageHomeScreen
import javafx.stage.Screen; //导入方法依赖的package包/类
private Optional<Screen> getStageHomeScreen(Stage stage) {
final double dpiScaleFactor = ShootOFFController.getDpiScaleFactorForScreen();
final ObservableList<Screen> stageHomeScreens = Screen.getScreensForRectangle(stage.getX() / dpiScaleFactor,
stage.getY() / dpiScaleFactor, 1, 1);
if (stageHomeScreens.isEmpty()) {
final StringBuilder message = new StringBuilder(
String.format("Didn't find screen for stage with title %s at (%f, %f)." + " Existing screens:%n",
stage.getTitle(), stage.getX() / dpiScaleFactor, stage.getY() / dpiScaleFactor));
final Iterator<Screen> it = Screen.getScreens().iterator();
while (it.hasNext()) {
final Screen s = it.next();
message.append(String.format("(w = %f, h = %f, x = %f, y = %f, dpi = %f)", s.getBounds().getWidth(),
s.getBounds().getHeight(), s.getBounds().getMinX(), s.getBounds().getMinY(), s.getDpi()));
if (it.hasNext()) {
message.append("\n");
}
}
logger.error(message.toString());
return Optional.empty();
} else if (stageHomeScreens.size() > 1) {
logger.warn("Found multiple screens as the possible arena home screen, this is unexpected: {}",
stageHomeScreens.size());
}
return Optional.of(stageHomeScreens.get(0));
}
示例7: handle
import javafx.stage.Screen; //导入方法依赖的package包/类
public void handle(MouseEvent e) {
if (currentMoveNode.equals(added)) {
Point2D delta = new Point2D(e.getScreenX() - moveStartPoint.getX(), e.getScreenY() - moveStartPoint.getY());
double stageX = getScene().getWindow().getX();
double stageY = getScene().getWindow().getY();
stageX += delta.getX();
stageY += delta.getY();
Rectangle2D newBounds = new Rectangle2D(stageX, stageY, getScene().getWindow().getWidth(), getScene().getWindow().getHeight());
// check screen bounds
for (Screen screen : Screen.getScreensForRectangle(newBounds)) {
// Limit dragging over menu bar
if (screen.getVisualBounds().equals(Screen.getPrimary().getVisualBounds())
&& OperatingSystem.getOS().isMac()
&& stageY < screen.getVisualBounds().getMinY()) {
stageY = screen.getVisualBounds().getMinY();
}
}
getScene().getWindow().setX(stageX);
getScene().getWindow().setY(stageY);
moveStartPoint = new Point2D(e.getScreenX(), e.getScreenY());
e.consume();
}
}
示例8: isValidBounds
import javafx.stage.Screen; //导入方法依赖的package包/类
/**
* Returns if the given rectangle has a valid position for a primary move
* node.<br/>
* Conditions are:
* <ul>
* <li>at least 10 vertical pixels must be visible</li>
* <li>the whole height must be visible</li>
* </ul>
*
* @param bounds
* the rectangle that should be checked
* @return
*/
public boolean isValidBounds(Rectangle2D bounds) {
ObservableList<Screen> screens = Screen.getScreensForRectangle(bounds);
if (screens.size() == 0) {
return false;
}
for (Screen screen : Screen.getScreensForRectangle(bounds)) {
Rectangle2D vis = screen.getVisualBounds();
if (bounds.getMinY() < vis.getMinY() || bounds.getMaxY() > vis.getMaxY()) {
return false;
}
}
return true;
}
示例9: setStageY
import javafx.stage.Screen; //导入方法依赖的package包/类
/**
* Under Windows, the undecorator Stage could be been dragged below the Task
* bar and then no way to grab it again... On Mac, do not drag under the
* menu bar
*
* @param y
*/
void setStageY(Stage stage, double y) {
try {
ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
if (screensForRectangle.size() > 0) {
Screen screen = screensForRectangle.get(0);
Rectangle2D visualBounds = screen.getVisualBounds();
if (y < visualBounds.getHeight() - 30 && y + SHADOW_WIDTH >= visualBounds.getMinY()) {
stage.setY(y);
}
}
} catch (Exception e) {
Undecorator.LOGGER.log(Level.SEVERE, "setStageY issue", e);
}
}
示例10: getScreenFor
import javafx.stage.Screen; //导入方法依赖的package包/类
private Screen getScreenFor(double x, double y) {
ObservableList<Screen> screens = Screen.getScreensForRectangle(x, y, 1, 1);
if (screens.isEmpty()) {
return Screen.getPrimary();
}
return screens.get(0);
}