Search in sources :

Example 1 with Rectangle2D

use of javafx.geometry.Rectangle2D in project VocabHunter by VocabHunter.

the class EnvironmentManagerImpl method isVisible.

@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;
    }
}
Also used : Screen(javafx.stage.Screen) Rectangle2D(javafx.geometry.Rectangle2D)

Example 2 with Rectangle2D

use of javafx.geometry.Rectangle2D in project Retrospector by NonlinearFruit.

the class Retrospector method showSplash.

private void showSplash(final Stage initStage, Task<?> task, InitCompletionHandler initCompletionHandler) {
    progressText.textProperty().bind(task.messageProperty());
    loadProgress.progressProperty().bind(task.progressProperty());
    task.stateProperty().addListener((observableValue, oldState, newState) -> {
        if (newState == Worker.State.SUCCEEDED) {
            loadProgress.progressProperty().unbind();
            loadProgress.setProgress(1);
            initStage.toFront();
            FadeTransition fadeSplash = new FadeTransition(Duration.seconds(1.2), splashLayout);
            fadeSplash.setFromValue(1.0);
            fadeSplash.setToValue(0.0);
            fadeSplash.setOnFinished(actionEvent -> initStage.hide());
            fadeSplash.play();
            initCompletionHandler.complete();
        }
    // todo add code to gracefully handle other task states.
    });
    Scene splashScene = new Scene(splashLayout, Color.TRANSPARENT);
    final Rectangle2D bounds = Screen.getPrimary().getBounds();
    initStage.setScene(splashScene);
    initStage.setX(bounds.getMinX() + bounds.getWidth() / 2 - SPLASH_WIDTH / 2);
    initStage.setY(bounds.getMinY() + bounds.getHeight() / 2 - SPLASH_HEIGHT / 2);
    initStage.setAlwaysOnTop(true);
    initStage.initStyle(StageStyle.TRANSPARENT);
    initStage.show();
}
Also used : FadeTransition(javafx.animation.FadeTransition) Rectangle2D(javafx.geometry.Rectangle2D) Scene(javafx.scene.Scene)

Example 3 with Rectangle2D

use of javafx.geometry.Rectangle2D in project proxyee-down by monkeyWie.

the class HttpDownApplication method start.

@Override
public void start(Stage stage) throws Exception {
    initHandle();
    this.stage = stage;
    Platform.setImplicitExit(false);
    isSupportBrowser = isSupportBrowser();
    SwingUtilities.invokeLater(this::addTray);
    // webview加载
    if (ContentManager.CONFIG.get().getUiModel() == 1 && isSupportBrowser) {
        initBrowser();
    }
    stage.setTitle("proxyee-down-" + version);
    Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
    ConfigInfo cf = ContentManager.CONFIG.get();
    stage.setX(cf.getGuiX() >= 0 ? cf.getGuiX() : bounds.getMinX());
    stage.setY(cf.getGuiY() >= 0 ? cf.getGuiY() : bounds.getMinY());
    stage.setWidth(cf.getGuiWidth() >= 0 ? cf.getGuiWidth() : bounds.getWidth());
    stage.setHeight(cf.getGuiHeight() >= 0 ? cf.getGuiHeight() : bounds.getHeight());
    stage.getIcons().add(new Image(Thread.currentThread().getContextClassLoader().getResourceAsStream("favicon.png")));
    // 关闭窗口监听
    stage.setOnCloseRequest(event -> {
        event.consume();
        close();
    });
}
Also used : Rectangle2D(javafx.geometry.Rectangle2D) ConfigInfo(lee.study.down.model.ConfigInfo) Image(javafx.scene.image.Image)

Example 4 with Rectangle2D

use of javafx.geometry.Rectangle2D in project jphp by jphp-compiler.

the class UXForm method maximize.

@Signature
public void maximize() {
    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();
    getWrappedObject().setX(bounds.getMinX());
    getWrappedObject().setY(bounds.getMinY());
    getWrappedObject().setWidth(bounds.getWidth());
    getWrappedObject().setHeight(bounds.getHeight());
}
Also used : Rectangle2D(javafx.geometry.Rectangle2D)

Example 5 with Rectangle2D

use of javafx.geometry.Rectangle2D in project Gargoyle by callakrsos.

the class FxUtil method getCenter.

public Point2D getCenter(Stage window) {
    Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
    double centerX = bounds.getMinX() + (bounds.getWidth() - window.getWidth()) * CENTER_ON_SCREEN_X_FRACTION;
    double centerY = bounds.getMinY() + (bounds.getHeight() - window.getHeight()) * CENTER_ON_SCREEN_Y_FRACTION;
    return new Point2D(centerX, centerY);
}
Also used : Point2D(javafx.geometry.Point2D) Rectangle2D(javafx.geometry.Rectangle2D)

Aggregations

Rectangle2D (javafx.geometry.Rectangle2D)76 Image (javafx.scene.image.Image)14 Scene (javafx.scene.Scene)10 Screen (javafx.stage.Screen)10 Stage (javafx.stage.Stage)7 Point2D (javafx.geometry.Point2D)6 IOException (java.io.IOException)5 ImageView (javafx.scene.image.ImageView)5 BufferedImage (java.awt.image.BufferedImage)4 File (java.io.File)4 List (java.util.List)4 Color (javafx.scene.paint.Color)4 Optional (java.util.Optional)3 Level (java.util.logging.Level)3 Application (javafx.application.Application)3 Platform (javafx.application.Platform)3 Menu (javafx.scene.control.Menu)3 MenuBar (javafx.scene.control.MenuBar)3 MenuItem (javafx.scene.control.MenuItem)3 Pane (javafx.scene.layout.Pane)3