Java Code Examples for javafx.stage.Window#getHeight()

The following examples show how to use javafx.stage.Window#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DockTools.java    From FxDock with Apache License 2.0 6 votes vote down vote up
public static boolean contains(Window w, double screenx, double screeny)
{
	double x = w.getX();
	if(screenx < x)
	{
		return false;
	}
	else if(screenx > (x + w.getWidth()))
	{
		return false;
	}
	
	double y = w.getY();
	if(screeny < y)
	{
		return false;
	}
	else if(screeny > (y + w.getHeight()))
	{
		return false;
	}
	
	return true;
}
 
Example 2
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void layout() {
    if (owner == null)
        owner = MainView.getRootContainer();
    Scene rootScene = owner.getScene();
    if (rootScene != null) {
        Window window = rootScene.getWindow();
        double titleBarHeight = window.getHeight() - rootScene.getHeight();
        if (Utilities.isWindows())
            titleBarHeight -= 9;
        stage.setX(Math.round(window.getX() + (owner.getWidth() - stage.getWidth()) / 2));

        if (type.animationType == AnimationType.SlideDownFromCenterTop)
            stage.setY(Math.round(window.getY() + titleBarHeight));
        else
            stage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - stage.getHeight()) / 2));
    }
}
 
Example 3
Source File: DataViewWindow.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private void dragFinish(final MouseEvent mevt) {
    if (isMinimised() || getParentView() == null || getParentView().getMinimisedChildren().contains(this)) {
        return;
    }
    if (!mouseFilter.test(mevt)) {
        return;
    }
    uninstallCursor();

    if (!isDetachableWindow()) {
        return;
    }
    // detach only if window is dragged outside Scene
    if (getScene() == null) {
        return;
    }
    final Point2D mouseLoc = new Point2D(mevt.getScreenX(), mevt.getScreenY());
    final Window window = getScene().getWindow();
    final Bounds sceneBounds = new BoundingBox(window.getX(), window.getY(), window.getWidth(), window.getHeight());

    final Bounds screenBounds = localToScreen(WindowDecoration.FRAME.equals(getWindowDecoration()) ? this.getBoundsInLocal() : getWindowDecorationBar().getBoundsInLocal());
    if (MouseUtils.mouseOutsideBoundaryBoxDistance(screenBounds, mouseLoc) > MIN_DRAG_BORDER_WIDTH && MouseUtils.mouseOutsideBoundaryBoxDistance(sceneBounds, mouseLoc) > MIN_DRAG_BORDER_WIDTH) {
        // mouse move outside window and surrounding stage detected -- launch dialog
        if (!dialog.isShowing()) {
            dialog.show(this, mevt);
            return;
        }
        dialog.setX(mevt.getScreenX() - xOffset);
        dialog.setY(mevt.getScreenY() - yOffset);
        return;
    }

    if (!dialog.isShowing()) {
        return;
    }
    dialog.setX(mevt.getScreenX() - xOffset);
    dialog.setY(mevt.getScreenY() - yOffset);
}
 
Example 4
Source File: LoadDialog.java    From Animu-Downloaderu with MIT License 5 votes vote down vote up
public static void showDialog(Window owner, String title, Message message) {
	alert = new Alert(AlertType.NONE);
	alert.initOwner(owner);
	alert.setTitle(title);
	ObservableMap<String, String> messages = message.getMessages();
	StringBuilder msg = new StringBuilder();
	messages.forEach((key, value) -> msg.append(String.format("%s\t: %s%n", key, value)));
	alert.getDialogPane().setMinHeight(messages.size() * 30d);
	alert.setContentText(msg.toString());

	// Run with small delay on each change
	messages.addListener((Change<? extends String, ? extends String> change) -> Platform.runLater(() -> {
		StringBuilder msgChange = new StringBuilder();
		messages.forEach((key, value) -> msgChange.append(String.format("%s\t: %s%n", key, value)));
		alert.setContentText(msgChange.toString());
		if (messages.values().stream().allMatch(val -> val.startsWith(Message.processed))) {
			stopDialog();
			message.clearMessages();
		}
	}));

	alert.initModality(Modality.APPLICATION_MODAL);
	alert.getDialogPane().getStylesheets()
			.add(LoadDialog.class.getResource("/css/application.css").toExternalForm());
	// Calculate the center position of the parent Stage
	double centerXPosition = owner.getX() + owner.getWidth() / 2d;
	double centerYPosition = owner.getY() + owner.getHeight() / 2d;

	alert.setOnShowing(e -> {
		alert.setX(centerXPosition - alert.getDialogPane().getWidth() / 2d);
		alert.setY(centerYPosition - alert.getDialogPane().getHeight() / 2d);
	});
	alert.show();
}
 
Example 5
Source File: FX.java    From FxDock with Apache License 2.0 5 votes vote down vote up
/** returns window decoration insets */
public static Insets getDecorationInsets(Window w)
{
	Scene s = w.getScene();
	double left = s.getX();
	double top = s.getY();
	double right = w.getWidth() - s.getWidth() - left;
	double bottom = w.getHeight() - s.getHeight() - top;
	return new Insets(top, right, bottom, left);
}
 
Example 6
Source File: FX.java    From FxDock with Apache License 2.0 5 votes vote down vote up
/** 
 * returns margin between the node and its containing window.
 * WARNING: does not check if window is indeed a right one. 
 */ 
public static Insets getInsetsInWindow(Window w, Node n)
{
	Bounds b = n.localToScreen(n.getBoundsInLocal());
	
	double left = b.getMinX() - w.getX();
	double top = b.getMinY() - w.getY();
	double right = w.getX() + w.getWidth() - b.getMaxX();
	double bottom = w.getY() + w.getHeight() - b.getMaxY();

	return new Insets(top, right, bottom, left);
}
 
Example 7
Source File: FxDialog.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public FxDialog(Object owner, String name)
{
	super(name);
	
	initModality(Modality.APPLICATION_MODAL);

	Window win = FX.getParentWindow(owner);
	initOwner(win);
	
	// TODO center around parent window, but not outside of the current device
	double x = win.getX();
	double y = win.getY();
	double w = win.getWidth();
	double h = win.getHeight();
}
 
Example 8
Source File: DockTools.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public static Insets getWindowInsets(Window w)
{
	Scene s = w.getScene();
	
	double left = s.getX();
	double top = s.getY();
	double right = w.getWidth() - s.getWidth() - left;
	double bottom = w.getHeight() - s.getHeight() - top;
	
	return new Insets(top, right, bottom, left);
}
 
Example 9
Source File: Notification.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void layout() {
    Window window = owner.getScene().getWindow();
    double titleBarHeight = window.getHeight() - owner.getScene().getHeight();
    double shadowInset = 44;
    stage.setX(Math.round(window.getX() + window.getWidth() + shadowInset - stage.getWidth()));
    stage.setY(Math.round(window.getY() + titleBarHeight - shadowInset));
}
 
Example 10
Source File: DockStation.java    From AnchorFX with GNU Lesser General Public License v3.0 4 votes vote down vote up
public boolean isInnerPosition(double x, double y) {

        Window window = getStationWindow();
        Rectangle bounds = new Rectangle(window.getX(), window.getY(), window.getWidth(), window.getHeight());
        return bounds.contains(x, y);
    }