Java 类javafx.geometry.Rectangle2D 实例源码

项目:stvs    文件:StvsPreloader.java   
@Override
public void start(Stage stage) {
  this.stage = stage;

  stage.initStyle(StageStyle.TRANSPARENT);

  VBox box = new VBox(20);
  box.setMaxWidth(Region.USE_PREF_SIZE);
  box.setMaxHeight(Region.USE_PREF_SIZE);
  box.setBackground(Background.EMPTY);
  String style = "-fx-background-color: rgba(255, 255, 255, 0.5);";
  box.setStyle(style);

  box.setPadding(new Insets(50));
  BorderPane root = new BorderPane(box);
  root.setStyle(style);
  root.setBackground(Background.EMPTY);
  Scene scene = new Scene(root);
  scene.setFill(Color.TRANSPARENT);
  stage.setScene(scene);

  ImageView splashView = new ImageView(splashImage);
  box.getChildren().addAll(splashView, new Label("ST Verification Studio is loading.."));
  stage.show();
  Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds();
  stage.setX((primScreenBounds.getWidth() - stage.getWidth()) / 2);
  stage.setY((primScreenBounds.getHeight() - stage.getHeight()) / 2);
}
项目:Mafia-TCoS-CS319-Group2A    文件:Main.java   
@Override
public void start(Stage primaryStage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("menuSample.fxml"));
    primaryStage.setTitle("Hello World");

    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();
    primaryStage.setX(bounds.getMinX());
    primaryStage.setY(bounds.getMinY());
    primaryStage.setWidth(bounds.getWidth());
    primaryStage.setHeight(bounds.getHeight());
    primaryStage.setMaximized(true);
    Scene menuScene = new Scene(root, 1080, 720);
    //primaryStage.setFullScreen(true);
    primaryStage.setScene(menuScene);


    //primaryStage.setFullScreen(true);
    primaryStage.show();
}
项目:CapsLock    文件:OverLayWindow.java   
void Exe(int i) {
    if(i==1) {
        warnmesse="プレイ開始から5分経過しました\n混雑している場合は次の人に\n交代してください";
        fontsize=25;
    }else if(i==2) {
        warnmesse="プレイ開始から10分経過しました\n混雑している場合は次の人に\n交代してください";
        fontsize=25;
    }else if(i==-1) {
        warnmesse="user timer is reset";
        fontsize=35;
    }

    final Stage primaryStage = new Stage(StageStyle.TRANSPARENT);
    primaryStage.initModality(Modality.NONE);
    final StackPane root = new StackPane();

    final Scene scene = new Scene(root, 350, 140);
    scene.setFill(null);

    final Label label = new Label(warnmesse);
    label.setFont(new Font("Arial", fontsize));
    BorderPane borderPane = new BorderPane();
    borderPane.setCenter(label);
    borderPane.setStyle("-fx-background-radius: 10;-fx-background-color: rgba(0,0,0,0.3);");

    root.getChildren().add(borderPane);

    final Rectangle2D d = Screen.getPrimary().getVisualBounds();
    primaryStage.setScene(scene);
    primaryStage.setAlwaysOnTop(true);
    primaryStage.setX(d.getWidth()-350);
    primaryStage.setY(d.getHeight()-300);

    primaryStage.show();

    final Timeline timer = new Timeline(new KeyFrame(Duration.seconds(CLOSE_SECONDS), (ActionEvent event) -> primaryStage.close()));
    timer.setCycleCount(Timeline.INDEFINITE);
    timer.play();
}
项目:Conan    文件:InferenceRuleView.java   
/**
 * Adds the content for showing the inference rules to the TabPane in the proof
 * @param tabPane
 *
 */
public InferenceRuleView(TabPane tabPane) {


    //load the image
    Image image = new Image("inferenceRules.png");
    ImageView iv1 = new ImageView();
    iv1.setImage(image);
    iv1.setSmooth(true);
    iv1.setPreserveRatio(true);

    //putting the image on a scrollpane
    ScrollPane sp=new ScrollPane();
    sp.getStyleClass().add("rulesView");
    tab = new ViewTab("Inference Rules",this);
    sp.setContent(iv1);
    tabPane.getTabs().add(tab);
    tab.setContent(sp);
    tabPane.getSelectionModel().select(tab);

    //used for getting screensize
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //Avoids scaling too much
    double w=primaryScreenBounds.getWidth()/2;
    iv1.setFitWidth(w);
}
项目:Conan    文件:ParseInfoView.java   
/**
 * Adds the content for showing the parser info to the TabPane
 * @param tabPane
 *
 */
public ParseInfoView(TabPane tabPane) {

    Label label = new Label(loadInstructions());
    label.getStyleClass().add("infoText");

    //putting the image on a scrollpane
    ScrollPane sp = new ScrollPane();
    sp.getStyleClass().add("rulesView");
    tab = new ViewTab("Input format",this);
    sp.setContent(label);
    tabPane.getTabs().add(tab);
    tab.setContent(sp);
    tabPane.getSelectionModel().select(tab);

    //used for getting screensize
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //Avoids scaling too much
    double w=primaryScreenBounds.getWidth();
    label.setPrefWidth(w); 
}
项目:JHosts    文件:Main.java   
@Override
public void start(Stage stage) throws Exception {
    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);

    double width = 700;
    double height = 200;
    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(Main.class.getResource("/css/jfoenix-fonts.css").toExternalForm(),
            Main.class.getResource("/css/jfoenix-design.css").toExternalForm(),
            Main.class.getResource("/css/jhosts-main.css").toExternalForm());
    stage.setScene(scene);
    stage.show();
}
项目:Drones-Simulator    文件:SpriteAnimation.java   
/**
 * Creates an animation that will run for indefinite time.
 * Use setCycleCount(1) to run animation only once. Remember to remove the imageView afterwards.
 *
 * @param imageView - the imageview of the sprite
 * @param duration - How long should one animation cycle take
 * @param count - Number of frames
 * @param columns - Number of colums the sprite has
 * @param offsetX - Offset x
 * @param offsetY - Offset y
 * @param width - Width of each frame
 * @param height - Height of each frame
 */
public SpriteAnimation(
        ImageView imageView,
        Duration duration,
        int count, int columns,
        int offsetX, int offsetY,
        int width, int height
) {
    this.imageView = imageView;
    this.count = count;
    this.columns = columns;
    this.offsetX = offsetX;
    this.offsetY = offsetY;
    this.width = width;
    this.height = height;
    setCycleDuration(duration);
    setCycleCount(Animation.INDEFINITE);
    setInterpolator(Interpolator.LINEAR);
    this.imageView.setViewport(new Rectangle2D(offsetX, offsetY, width, height));

}
项目:MineIDE    文件:MineIDEPreloader.java   
@Override
public void start(final Stage primaryStage) throws Exception
{

    this.preloaderStage = primaryStage;

    final ImageView splash = new ImageView(new Image(Constant.IMG_DIR + "banner.png"));

    this.loadProgressPhase = new JFXProgressBar();
    this.loadProgressPhase.setPrefWidth(Constant.SPLASH_WIDTH);

    this.splashLayout = new VBox();
    this.splashLayout.getChildren().addAll(splash, this.loadProgressPhase);

    this.splashLayout.setStyle("-fx-padding: 5; " + "-fx-background-color: gainsboro; " + "-fx-border-width:2; "
            + "-fx-border-color: " + "linear-gradient(" + "to bottom, " + "MediumSeaGreen, "
            + "derive(MediumSeaGreen, 50%)" + ");");
    this.splashLayout.setEffect(new DropShadow());

    final Scene splashScene = new Scene(this.splashLayout, Color.TRANSPARENT);
    final Rectangle2D bounds = Screen.getPrimary().getBounds();

    primaryStage.setScene(splashScene);
    primaryStage.setX(bounds.getMinX() + bounds.getWidth() / 2 - Constant.SPLASH_WIDTH / 2);
    primaryStage.setY(bounds.getMinY() + bounds.getHeight() / 2 - Constant.SPLASH_HEIGHT / 2);
    primaryStage.getIcons().add(new Image(Constant.IMG_DIR + "icon.png"));
    primaryStage.setTitle(Constant.APP_NAME);

    primaryStage.initStyle(StageStyle.UNDECORATED);
    primaryStage.setAlwaysOnTop(true);
    primaryStage.show();

}
项目:Higher-Cloud-Computing-Project    文件:Main.java   
@Override
    public void start(Stage primaryStage) throws Exception{
        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(getClass().getResource("sample.fxml"));
        Parent root = fxmlLoader.load();
        Screen screen = Screen.getPrimary ();

//        界面初始化
        Controller controller = fxmlLoader.getController();
        controller.init(primaryStage);

        Rectangle2D bounds = screen.getVisualBounds ();

        double minX = bounds.getMinX ();
        double minY = bounds.getMinY ();
        double maxX = bounds.getMaxX ();
        double maxY = bounds.getMaxY ();

        screenWidth = maxX - minX;
        screenHeight = maxY - minY;

        Scene scene = new Scene(root, (maxX - minX) * 0.6, (maxY - minY) * 0.6);

        primaryStage.setTitle ("Higher Cloud Compute Platform");
        primaryStage.setScene (scene);
        primaryStage.setFullScreen(true);
        primaryStage.show ();

    }
项目:DeskChan    文件:OverlayStage.java   
static Rectangle2D getDesktopSize() {
    Rectangle2D rect = Screen.getPrimary().getBounds();
    double minX = rect.getMinX(), minY = rect.getMinY();
    double maxX = rect.getMaxX(), maxY = rect.getMaxY();
    for (Screen screen : Screen.getScreens()) {
        Rectangle2D screenRect = screen.getBounds();
        if (minX > screenRect.getMinX()) {
            minX = screenRect.getMinX();
        }
        if (minY > screenRect.getMinY()) {
            minY = screenRect.getMinY();
        }
        if (maxX < screenRect.getMaxX()) {
            maxX = screenRect.getMaxX();
        }
        if (maxY < screenRect.getMaxY()) {
            maxY = screenRect.getMaxY();
        }
    }
    return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
项目:DeskChan    文件:MovablePane.java   
private static Rectangle2D snapRect(Rectangle2D bounds, Rectangle2D screenBounds) {
    double x1 = bounds.getMinX(), y1 = bounds.getMinY();
    double x2 = bounds.getMaxX(), y2 = bounds.getMaxY();
    if (Math.abs(x1 - screenBounds.getMinX()) < SNAP_DISTANCE) {
        x1 = screenBounds.getMinX();
    }
    if (Math.abs(y1 - screenBounds.getMinY()) < SNAP_DISTANCE) {
        y1 = screenBounds.getMinY();
    }
    if (Math.abs(x2 - screenBounds.getMaxX()) < SNAP_DISTANCE) {
        x1 = screenBounds.getMaxX() - bounds.getWidth();
    }
    if (Math.abs(y2 - screenBounds.getMaxY()) < SNAP_DISTANCE) {
        y1 = screenBounds.getMaxY() - bounds.getHeight();
    }
    return new Rectangle2D(x1, y1, bounds.getWidth(), bounds.getHeight());
}
项目:DeskChan    文件:MovablePane.java   
private String getCurrentPositionStorageKey() {
    if (positionStorageID == null) {
        return null;
    }
    final StringBuilder key = new StringBuilder();
    final Rectangle2D desktopSize = OverlayStage.getDesktopSize();
    key.append(positionStorageID);
    if (positionRelativeToDesktopSize) {
        key.append('.');
        key.append(desktopSize.getMinX());
        key.append('_');
        key.append(desktopSize.getMinY());
        key.append('_');
        key.append(desktopSize.getWidth());
        key.append('_');
        key.append(desktopSize.getHeight());
    }
    return key.toString();
}
项目:DeskChan    文件:MovablePane.java   
protected void loadPositionFromStorage() {
    try {
        final String key = getCurrentPositionStorageKey();
        if (key != null) {
            final String value = Main.getProperties().getString(key);
            if (value != null) {
                String[] coords = value.split(";");
                if (coords.length == 2) {
                    double x = Double.parseDouble(coords[0]);
                    double y = Double.parseDouble(coords[1]);
                    Rectangle2D desktop = OverlayStage.getDesktopSize();
                    if(desktop.getWidth() == 0 || desktop.getHeight() == 0) return;
                    if (x + getHeight() > desktop.getMaxX() || x < -getHeight())
                        x = desktop.getMaxX() - getHeight();
                    if (y + getWidth() > desktop.getMaxY() || y < -getWidth()) y = desktop.getMaxY() - getWidth();
                    setPosition(new Point2D(x, y));
                    return;
                }
            }
        }
    } catch (Exception e){ Main.log(e); }
    setDefaultPosition();
}
项目:fwm    文件:DraggableTab.java   
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;
}
项目:incubator-netbeans    文件:Bat.java   
public void changeSize(int newSize) {
    this.size = newSize;
    width = size * 12 + 45;
    double rightWidth = RIGHT.getWidth() - Config.SHADOW_WIDTH;
    double centerWidth = width - LEFT.getWidth() - rightWidth;
    centerImageView.setViewport(new Rectangle2D(
        (CENTER.getWidth() - centerWidth) / 2, 0, centerWidth, CENTER.getHeight()));
    rightImageView.setTranslateX(width - rightWidth);
}
项目:plep    文件:Main.java   
@Override
public void start(final Stage primaryStage) throws Exception{
    System.out.println(Main.class.getResource("/interface.fxml"));
    FXMLLoader loader = new FXMLLoader(getClass().getResource
            ("/interface.fxml"));

    Parent root = loader.load();

    //used to invoke a setup method in controller which needs the stage
    Controller controller = loader.getController();
    controller.setDayChangeListener(primaryStage);

    primaryStage.setTitle("Plep");
    primaryStage.setScene(new Scene(root, 0, 0));

    //set a size relative to screen
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    primaryStage.setX(primaryScreenBounds.getMinX());
    primaryStage.setY(primaryScreenBounds.getMinY());
    primaryStage.setWidth(primaryScreenBounds.getWidth()/2);
    primaryStage.setHeight(primaryScreenBounds.getHeight());

    String treeViewCSS = this.getClass().getResource("/css/treeview.css").toExternalForm();
    String generalCSS = this.getClass().getResource("/css/general.css").toExternalForm();
    String buttonCSS = this.getClass().getResource("/css/button.css").toExternalForm();
    String spinnerCSS = this.getClass().getResource("/css/spinner.css").toExternalForm();
    String checkboxCSS = this.getClass().getResource("/css/checkbox.css").toExternalForm();
    String dropdownCSS = this.getClass().getResource("/css/dropdown.css").toExternalForm();
    String colorPickerCSS = this.getClass().getResource("/css/colorpicker.css").toExternalForm();

    primaryStage.getScene().getStylesheets().addAll(treeViewCSS, generalCSS, buttonCSS, spinnerCSS, checkboxCSS, dropdownCSS, colorPickerCSS);

    // check if running in debug mode
    // to display the default java icon so we can distinguish between
    // the program we are testing and the one we are actually using
    // (the latter has the plep logo)
    boolean isDebug = java.lang.management.ManagementFactory.getRuntimeMXBean().
            getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
    if (!isDebug) {
        primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("/icon.png")));
    }

    primaryStage.show();

}
项目:marathonv5    文件:Bat.java   
public void changeSize(int newSize) {
    this.size = newSize;
    width = size * 12 + 45;
    double rightWidth = RIGHT.getWidth() - Config.SHADOW_WIDTH;
    double centerWidth = width - LEFT.getWidth() - rightWidth;
    centerImageView.setViewport(new Rectangle2D(
        (CENTER.getWidth() - centerWidth) / 2, 0, centerWidth, CENTER.getHeight()));
    rightImageView.setTranslateX(width - rightWidth);
}
项目:marathonv5    文件:ImagePropertiesSample.java   
public ImagePropertiesSample() {
    //we can set image properties directly during creation
    ImageView sample1 = new ImageView(new Image(url, 30, 70, false, true));

    ImageView sample2 = new ImageView(new Image(url));
    //image can be resized to preferred width
    sample2.setFitWidth(200);
    sample2.setPreserveRatio(true);

    ImageView sample3 = new ImageView(new Image(url));
    //image can be resized to preferred height
    sample3.setFitHeight(20);
    sample3.setPreserveRatio(true);

    ImageView sample4 = new ImageView(new Image(url));
    //one can resize image without preserving ratio between height and width
    sample4.setFitWidth(40);
    sample4.setFitHeight(80);
    sample4.setPreserveRatio(false);
    sample4.setSmooth(true); //the usage of the better filter

    ImageView sample5 = new ImageView(new Image(url));
    sample5.setFitHeight(60);
    sample5.setPreserveRatio(true);
    //viewport is used for displaying the part of image
    Rectangle2D rectangle2D = new Rectangle2D(50, 200, 120, 60);
    sample5.setViewport(rectangle2D);

    //add the imageviews to layout
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(sample1, sample3, sample4, sample5);

    //show the layout
    VBox vb = new VBox(10);
    vb.getChildren().addAll(hBox, sample2);
    getChildren().add(vb);
}
项目:marathonv5    文件:ImagePropertiesSample.java   
public static Node createIconContent() {
    //TODO better icon?
    ImageView iv = new ImageView(BRIDGE);
    iv.setFitWidth(80);
    iv.setFitHeight(80);
    iv.setViewport(new Rectangle2D(0, 85, 330, 330));
    return iv;
}
项目:marathonv5    文件:SepiaToneSample.java   
public static Node createIconContent() {
    ImageView iv = new ImageView(BOAT);
    iv.setFitWidth(80);
    iv.setFitHeight(80);
    iv.setViewport(new Rectangle2D(90,0,332,332));
    final SepiaTone SepiaTone = new SepiaTone();
    SepiaTone.setLevel(1);
    iv.setEffect(SepiaTone);
    return iv;
}
项目:marathonv5    文件:AnnotateScreenCapture.java   
@Override protected Parent getContentPane() {
    BorderPane borderPane = new BorderPane();
    borderPane.setCenter(imagePanel);
    borderPane.setBottom(buttonBar);
    Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
    borderPane.setPrefSize(visualBounds.getWidth() * 0.75, visualBounds.getHeight() * 0.75);
    return borderPane;

}
项目:marathonv5    文件:ImagePropertiesSample.java   
public static Node createIconContent() {
    //TODO better icon?
    ImageView iv = new ImageView(BRIDGE);
    iv.setFitWidth(80);
    iv.setFitHeight(80);
    iv.setViewport(new Rectangle2D(0, 85, 330, 330));
    return iv;
}
项目:GazePlay    文件:SecondScreen.java   
private static void makeLighting(Group root, Rectangle2D RScreen) {

        int width = (int) RScreen.getWidth();
        int height = (int) RScreen.getHeight();

        T = new Lighting[width / pixelWidth][height / pixelWidth];
        for (int i = 0; i < T.length; i++)
            for (int j = 0; j < T[i].length; j++) {

                T[i][j] = new Lighting(i * pixelWidth, j * pixelWidth, pixelWidth, lightingLength, lightingColor);
                root.getChildren().add(T[i][j]);
            }
    }
项目:DeskChan    文件:MovablePane.java   
void setPosition(Point2D topLeft) {
    if (topLeft == null) {
        setDefaultPosition();
        return;
    }
    Bounds bounds = getLayoutBounds();
    Rectangle2D rect = new Rectangle2D(topLeft.getX(), topLeft.getY(),
            bounds.getWidth(), bounds.getHeight());
    for (Screen screen : Screen.getScreens()) {
        rect = snapRect(rect, screen.getBounds());
        rect = snapRect(rect, screen.getVisualBounds());
    }
    relocate(rect.getMinX(), rect.getMinY());
}
项目:MineIDE    文件:DraggableTab.java   
private Rectangle2D getAbsoluteRect(final Control node)
{
    return new Rectangle2D(
            node.localToScene(node.getLayoutBounds().getMinX(), node.getLayoutBounds().getMinY()).getX()
                    + node.getScene().getWindow().getX(),
            node.localToScene(node.getLayoutBounds().getMinX(), node.getLayoutBounds().getMinY()).getY()
                    + node.getScene().getWindow().getY(),
            node.getWidth(), node.getHeight());
}
项目:cyoastudio    文件:Image.java   
public Image trim(Rectangle2D r) {
    try {
        BufferedImage subimage;
        subimage = toBufferedImage().getSubimage((int) r.getMinX(), (int) r.getMinY(), (int) r.getWidth(),
                (int) r.getHeight());
        return Image.fromData(subimage);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
项目:cyoastudio    文件:ImageEditor.java   
@FXML
void trim() {
    if (image != null && snapshotView.isSelectionActive()) {
        Rectangle2D area = snapshotView.transformSelectionToNodeCoordinates();
        replaceImage(image.trim(area));
    }
}
项目:recruitervision    文件:CustomStage.java   
public CustomStage(AnchorPane ap, StageStyle style) {
    initStyle(style);

    setSize(ap.getPrefWidth(), ap.getPrefHeight());

    Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
    double x = screenBounds.getMinX() + screenBounds.getWidth() - ap.getPrefWidth() - 2;
    double y = screenBounds.getMinY() + screenBounds.getHeight() - ap.getPrefHeight() - 2;

    bottomRight = Location.at(x, y);
}
项目:GazePlay    文件:GameSizingComputer.java   
public GameSizing computeGameSizing(Rectangle2D bounds) {

        double sceneWidth = bounds.getWidth();
        double sceneHeight = bounds.getHeight();

        if (sceneWidth == 0 || sceneHeight == 0) {
            throw new IllegalStateException("Invalid gaming area size : bounds = " + bounds);
        }

        final double width;
        final double height;
        final double shift;

        log.info("16/9 or 16/10 screen ? = " + ((sceneWidth / sceneHeight) - (16.0 / 9.0)));

        if (fourThree && ((sceneWidth / sceneHeight) - (16.0 / 9.0)) < 0.1) {
            width = 4 * sceneHeight / 3;
            height = sceneHeight;
            shift = (sceneWidth - width) / 2;
        } else {
            width = sceneWidth;
            height = sceneHeight;
            shift = 0;
        }

        GameSizing gameSizing = new GameSizing(width / nbColumns, height / nbLines, shift);
        log.info("gameSizing = {}", gameSizing);
        return gameSizing;
    }
项目:DeskChan    文件:OverlayStage.java   
NormalStage(){
    super();
    setOnShowing(handler);
    setOnHiding(handler);
    resizeToDesktopSize();
    Screen.getScreens().addListener((ListChangeListener<Screen>) change -> {
        resizeToDesktopSize();
        Rectangle2D rect = getDesktopSize();
        Main.log("Desktop rect is " + rect.getMinX() + "," + rect.getMinY() +
                "," + rect.getMaxX() + "," + rect.getMaxY());
    });
}
项目:candlelight    文件:Renderer.java   
public static void drawExportArea(GraphicsContext g, Rectangle2D area)
{
    g.setStroke(COLOR_EXPORT_AREA);
    g.setLineWidth(EXPORT_LINE_WIDTH);
    g.strokeRect(area.getMinX(), area.getMinY(),
            area.getWidth(), area.getHeight());
}
项目:puzzlefx    文件:SwapHandler.java   
private Piece findClickedPiece(MouseEvent event) {
    for (Piece piece : controller.getPiecesInNormalOrder()) {
        Rectangle2D pieceRect = new Rectangle2D(piece.getXPos(), piece.getYPos(), piece.getWidth(), piece.getHeight());
        if (pieceRect.contains(event.getSceneX(), event.getSceneY())) {
            return piece;
        }
    }
    return null;
}
项目:candlelight    文件:LayeredCanvasPane.java   
@Override
public WritableImage toWritableImage(Rectangle2D viewport)
{
    SnapshotParameters params = new SnapshotParameters();
    params.setViewport(viewport);
    params.setFill(Color.TRANSPARENT);
    return this.snapshot(params, null);
}
项目:GazePlay    文件:GameSizingComputer.java   
public GameSizing computeGameSizing(Scene scene) {
    Rectangle2D bounds = new Rectangle2D(0, 0, scene.getWidth(), scene.getHeight());

    return computeGameSizing(bounds);
}
项目:EistReturns    文件:Utils.java   
private boolean isSlotAllowed(Rectangle2D nearestSquare) {

        int top_left_color = pixelReader.getArgb((int) nearestSquare.getMinX(), (int) nearestSquare.getMinY());
        int top_right_color = pixelReader.getArgb((int) nearestSquare.getMaxX(), (int) nearestSquare.getMinY());
        int bottom_left_color = pixelReader.getArgb((int) nearestSquare.getMinX(), (int) nearestSquare.getMaxY());
        int bottom_right_color = pixelReader.getArgb((int) nearestSquare.getMaxX(), (int) nearestSquare.getMaxY());

        return top_left_color != -16777216 && top_right_color != -16777216 &&
                bottom_left_color != -16777216 && bottom_right_color != -16777216;
    }
项目:DeskChan    文件:OverlayStage.java   
protected void resizeToDesktopSize() {
    Rectangle2D rect = getDesktopSize();
    setX(rect.getMinX());
    setY(rect.getMinY());
    setWidth(rect.getWidth());
    setHeight(rect.getHeight());
}
项目:CalendarFX    文件:ViewHelper.java   
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;
}
项目:CalendarFX    文件:IntroPaneSkin.java   
private void snapshotNode(Scene scene, Node node) {
    SnapshotParameters params = new SnapshotParameters();
    Bounds layoutBounds = node.getLayoutBounds();
    Bounds bounds = node.localToScene(layoutBounds);

    if (!(bounds.getWidth() > 0 && bounds.getHeight() > 0)) {
        return;
    }

    params.setViewport(new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
    WritableImage writable = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
    writable = scene.getRoot().snapshot(params, writable);

    ImageView imageView = new ImageView(writable);
    imageView.getStyleClass().add("snapshot-image");
    imageView.setManaged(false);
    imageView.setLayoutX(bounds.getMinX());
    imageView.setLayoutY(bounds.getMinY());
    imageView.setFitWidth(bounds.getWidth());
    imageView.setFitHeight(bounds.getHeight());

    Region rect = new Region();
    rect.getStyleClass().add("snapshot-background");
    rect.setLayoutX(bounds.getMinX() - 5);
    rect.setLayoutY(bounds.getMinY() - 5);
    rect.resize(bounds.getWidth() + 10, bounds.getHeight() + 10);
    rect.setManaged(false);

    Line line = new Line();
    line.setStartX(bounds.getMaxX() + 4);
    line.setStartY(bounds.getMaxY() + 4);
    line.setEndX(bounds.getMaxX() + 200);
    line.setEndY(bounds.getMaxY() + 200);
    line.setStroke(imagePattern);
    line.setStrokeWidth(5);
    line.setManaged(false);

    getChildren().addAll(rect, imageView); //, line);
}
项目:fwm    文件:DraggableTab.java   
private Rectangle2D getAbsoluteRect(Control node) {
    return new Rectangle2D(node.localToScene(node.getLayoutBounds().getMinX(), node.getLayoutBounds().getMinY()).getX() + node.getScene().getWindow().getX(),
            node.localToScene(node.getLayoutBounds().getMinX(), node.getLayoutBounds().getMinY()).getY() + node.getScene().getWindow().getY(),
            node.getWidth(),
            node.getHeight());
}
项目:fwm    文件:DraggableTab.java   
private Rectangle2D getAbsoluteRect(Tab tab) {
    Control node = ((DraggableTab) tab).getLabel();
    return getAbsoluteRect(node);
}