use of javafx.geometry.Rectangle2D in project loinc2hpo by monarch-initiative.
the class PopUps method adjustStagePosition.
/**
* Ensure that popup Stage will be displayed on the same monitor as the parent Stage
*
* @param childStage
* @param parentStage
* @return
*/
private static Stage adjustStagePosition(Stage childStage, Stage parentStage) {
ObservableList<Screen> screensForParentWindow = Screen.getScreensForRectangle(parentStage.getX(), parentStage.getY(), parentStage.getWidth(), parentStage.getHeight());
Screen actual = screensForParentWindow.get(0);
Rectangle2D bounds = actual.getVisualBounds();
// set top left position to 35%/25% of screen/monitor width & height
childStage.setX(bounds.getWidth() * 0.35);
childStage.setY(bounds.getHeight() * 0.25);
return childStage;
}
use of javafx.geometry.Rectangle2D in project jphp by jphp-compiler.
the class DraggableTab method getInsertData.
private InsertData getInsertData(Point2D screenPoint) {
for (TabPane tabPane : tabPanes) {
Rectangle2D tabAbsolute = getAbsoluteRect(tabPane);
if (tabAbsolute.contains(screenPoint)) {
int tabInsertIndex = 0;
if (!tabPane.getTabs().isEmpty()) {
Rectangle2D firstTabRect = getAbsoluteRect(tabPane.getTabs().get(0));
if (firstTabRect.getMaxY() + 60 < screenPoint.getY() || firstTabRect.getMinY() > screenPoint.getY()) {
return null;
}
Rectangle2D lastTabRect = getAbsoluteRect(tabPane.getTabs().get(tabPane.getTabs().size() - 1));
if (screenPoint.getX() < (firstTabRect.getMinX() + firstTabRect.getWidth() / 2)) {
tabInsertIndex = 0;
} else if (screenPoint.getX() > (lastTabRect.getMaxX() - lastTabRect.getWidth() / 2)) {
tabInsertIndex = tabPane.getTabs().size();
} else {
for (int i = 0; i < tabPane.getTabs().size() - 1; i++) {
Tab leftTab = tabPane.getTabs().get(i);
Tab rightTab = tabPane.getTabs().get(i + 1);
if (leftTab instanceof DraggableTab && rightTab instanceof DraggableTab) {
Rectangle2D leftTabRect = getAbsoluteRect(leftTab);
Rectangle2D rightTabRect = getAbsoluteRect(rightTab);
if (betweenX(leftTabRect, rightTabRect, screenPoint.getX())) {
tabInsertIndex = i + 1;
break;
}
}
}
}
}
return new InsertData(tabInsertIndex, tabPane);
}
}
return null;
}
use of javafx.geometry.Rectangle2D in project jphp by jphp-compiler.
the class CustomStage method reinit.
protected void reinit() {
Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
double x = screenBounds.getMinX() + screenBounds.getWidth() - ap.getPrefWidth() - horGap;
double y = screenBounds.getMinY() + screenBounds.getHeight() - ap.getPrefHeight() - verGap;
bottomRight = new Location(x, y);
bottomLeft = new Location(horGap, y);
topLeft = new Location(horGap, verGap);
topRight = new Location(x, verGap);
}
use of javafx.geometry.Rectangle2D in project JFoenix by jfoenixadmin.
the class MainDemo method start.
@Override
public void start(Stage stage) throws Exception {
new Thread(() -> {
try {
SVGGlyphLoader.loadGlyphsFont(MainDemo.class.getResourceAsStream("/fonts/icomoon.svg"), "icomoon.svg");
} catch (IOException ioExc) {
ioExc.printStackTrace();
}
}).start();
Flow flow = new Flow(MainController.class);
DefaultFlowContainer container = new DefaultFlowContainer();
flowContext = new ViewFlowContext();
flowContext.register("Stage", stage);
flow.createHandler(flowContext).start(container);
JFXDecorator decorator = new JFXDecorator(stage, container.getView());
decorator.setCustomMaximize(true);
decorator.setGraphic(new SVGGlyph(""));
stage.setTitle("JFoenix Demo");
double width = 800;
double height = 600;
try {
Rectangle2D bounds = Screen.getScreens().get(0).getBounds();
width = bounds.getWidth() / 2.5;
height = bounds.getHeight() / 1.35;
} catch (Exception e) {
}
Scene scene = new Scene(decorator, width, height);
final ObservableList<String> stylesheets = scene.getStylesheets();
stylesheets.addAll(JFoenixResources.load("css/jfoenix-fonts.css").toExternalForm(), JFoenixResources.load("css/jfoenix-design.css").toExternalForm(), MainDemo.class.getResource("/css/jfoenix-main-demo.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
use of javafx.geometry.Rectangle2D in project JFoenix by jfoenixadmin.
the class JFXDecorator method maximize.
private void maximize(SVGGlyph resizeMin, SVGGlyph resizeMax) {
if (!isCustomMaximize()) {
primaryStage.setMaximized(!primaryStage.isMaximized());
maximized = primaryStage.isMaximized();
if (primaryStage.isMaximized()) {
btnMax.setGraphic(resizeMin);
btnMax.setTooltip(new Tooltip("Restore Down"));
} else {
btnMax.setGraphic(resizeMax);
btnMax.setTooltip(new Tooltip("Maximize"));
}
} else {
if (!maximized) {
// store original bounds
originalBox = new BoundingBox(primaryStage.getX(), primaryStage.getY(), primaryStage.getWidth(), primaryStage.getHeight());
// get the max stage bounds
Screen screen = Screen.getScreensForRectangle(primaryStage.getX(), primaryStage.getY(), primaryStage.getWidth(), primaryStage.getHeight()).get(0);
Rectangle2D bounds = screen.getVisualBounds();
maximizedBox = new BoundingBox(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
// maximized the stage
primaryStage.setX(maximizedBox.getMinX());
primaryStage.setY(maximizedBox.getMinY());
primaryStage.setWidth(maximizedBox.getWidth());
primaryStage.setHeight(maximizedBox.getHeight());
btnMax.setGraphic(resizeMin);
btnMax.setTooltip(new Tooltip("Restore Down"));
} else {
// restore stage to its original size
primaryStage.setX(originalBox.getMinX());
primaryStage.setY(originalBox.getMinY());
primaryStage.setWidth(originalBox.getWidth());
primaryStage.setHeight(originalBox.getHeight());
originalBox = null;
btnMax.setGraphic(resizeMax);
btnMax.setTooltip(new Tooltip("Maximize"));
}
maximized = !maximized;
}
}
Aggregations