Example usage for javafx.scene.shape Rectangle widthProperty

List of usage examples for javafx.scene.shape Rectangle widthProperty

Introduction

In this page you can find the example usage for javafx.scene.shape Rectangle widthProperty.

Prototype

public final DoubleProperty widthProperty() 

Source Link

Usage

From source file:Main.java

public static void startValueSetAnimation(final Pane parent) {
    final javafx.scene.shape.Rectangle rectangle = new javafx.scene.shape.Rectangle();
    Insets margin = BorderPane.getMargin(parent);
    if (margin == null) {
        margin = new Insets(0);
    }//from   www  .  j  av  a 2 s.co  m
    rectangle.widthProperty().bind(parent.widthProperty().subtract(margin.getLeft() + margin.getRight()));
    rectangle.heightProperty().bind(parent.heightProperty().subtract(margin.getTop() + margin.getBottom()));
    rectangle.setFill(Color.rgb(0, 150, 201));
    parent.getChildren().add(rectangle);

    BoxBlur bb = new BoxBlur();
    bb.setWidth(5);
    bb.setHeight(5);
    bb.setIterations(3);
    rectangle.setEffect(bb);

    FadeTransition ft = new FadeTransition(Duration.millis(250), rectangle);
    ft.setFromValue(0.2);
    ft.setToValue(0.8);
    ft.setCycleCount(2);
    ft.setAutoReverse(true);
    ft.play();
    ft.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            parent.getChildren().remove(rectangle);
        }
    });
}

From source file:uk.ac.bris.cs.scotlandyard.ui.controller.BaseGame.java

BaseGame(ResourceManager manager, Stage stage) {
    this.resourceManager = manager;
    this.stage = stage;
    Controller.bind(this);

    // initialise all controllers
    travelLog = new TravelLog(resourceManager, config);
    ticketsCounter = new TicketsCounter(resourceManager, config);
    notifications = new Notifications(resourceManager, config);
    status = new Status(resourceManager, config);
    board = new Board(resourceManager, notifications, config);

    Rectangle clip = new Rectangle();
    clip.widthProperty().bind(gamePane.widthProperty());
    clip.heightProperty().bind(gamePane.heightProperty());
    gamePane.setClip(clip);/*  w  w  w. j a va 2  s .c  o m*/

    // system menu
    menu.setUseSystemMenuBar(true);

    // add all views
    mapPane.getChildren().add(board.root());
    roundsPane.getChildren().add(travelLog.root());
    playersPane.getChildren().add(ticketsCounter.root());
    notificationPane.getChildren().add(notifications.root());
    statusPane.getChildren().add(status.root());

    close.setOnAction(e -> stage.close());
    debug.setOnAction(evt -> {
        try {
            Debug.showDebugger(stage);
        } catch (Exception e) {
            Utils.handleFatalException(e);
        }
    });
    about.setOnAction(e -> {
        Alert alert = new Alert(AlertType.INFORMATION,
                "ScotlandYard is part of the CW-MODEL coursework prepared for University of Bristol course COMS100001",
                ButtonType.OK);
        ImageView logo = new ImageView(resourceManager.getImage(ImageResource.UOB_LOGO));
        logo.setPreserveRatio(true);
        logo.setSmooth(true);
        logo.setFitHeight(100);
        alert.setGraphic(logo);
        alert.setTitle("About ScotlandYard");
        alert.setHeaderText("ScotlandYard v0.1");
        alert.show();
    });

    findNode.setOnAction(e -> {
        Stage s = new Stage();
        s.setTitle("Find node");
        s.setScene(new Scene(new FindNode(config, s, resourceManager).root()));
        s.show();
    });
    manual.setOnAction(e -> {
        Stage s = new Stage();
        s.setTitle("Manual");
        s.setScene(new Scene(new Manual(s).root()));
        s.show();
    });

    license.setOnAction(e -> {
        Stage s = new Stage();
        s.setTitle("License");
        s.setScene(new Scene(new License(s).root()));
        s.show();
    });

    // bind all menu values
    resetViewport.setOnAction(e -> {
        board.resetViewport();
    });

    setAndBind(travelLog.root().visibleProperty(), travelLogToggle.selectedProperty());
    setAndBind(ticketsCounter.root().visibleProperty(), ticketToggle.selectedProperty());
    setAndBind(config.scrollPanProperty(), scrollToggle.selectedProperty());
    setAndBind(config.historyProperty(), historyToggle.selectedProperty());
    setAndBind(config.focusPlayerProperty(), focusToggle.selectedProperty());

    if (SystemUtils.IS_OS_WINDOWS)
        config.scrollPanProperty().setValue(false);

}

From source file:org.mskcc.shenkers.view.IntervalViewNGTest.java

public Node get(RangeSet<Integer> intervals, int start, int end) {
    RangeSet<Integer> view = intervals.subRangeSet(Range.closed(start, end));
    double l = end - start + 1.;
    Pane p = new Pane();
    for (Range<Integer> interval : view.asRanges()) {
        Rectangle r = new Rectangle();
        r.widthProperty().bind(
                p.widthProperty().multiply(interval.upperEndpoint() - interval.lowerEndpoint() + 1).divide(l));
        r.heightProperty().bind(p.heightProperty());
        r.xProperty().bind(p.widthProperty().multiply(interval.lowerEndpoint()).divide(l));
        //            System.out.println(r);
        p.getChildren().add(r);// w ww  . j a  v  a  2s  .c  om
    }
    return p;
}

From source file:Pages.LandingPage.java

public void profilePicture(String picture, Stage theStage) {
    // <editor-fold defaultstate="collapsed" desc="Circle Image">

    profile_pic = (new ImageView(new Image(picture)));
    Rectangle square = new Rectangle();
    square.setWidth(150);/* w w w  . ja va2 s  .  c  o m*/
    square.setHeight(150);
    profile_pic.setClip(square);
    Circle clip = new Circle();
    clip.setCenterX(75);
    clip.setCenterY(75);
    clip.setRadius(75);
    profile_pic.fitWidthProperty().bind(square.widthProperty());
    profile_pic.fitHeightProperty().bind(square.heightProperty());
    profile_pic.setClip(clip);

    profile_pic.setOnMouseClicked(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent arg0) {
            createProfilePicture(theStage);
        }

    });

    userbox.getChildren().add(profile_pic);
    // </editor-fold>  
}

From source file:view.FXApplicationController.java

final public void computeKCfeatures() {

    overlay4.getChildren().clear();//from   w w w.j  a v a2  s .  co m

    kcDetector.detect(displayBuffer[featureModel.getFeatureChannel()]);
    double percentageSum = kcDetector.getPercentageSum();
    Set<Range<Integer>> kcPlotRanges = kcDetector.getKcRanges();

    kComplexLabel.setVisible(true);
    kComplexLabel.setText("K-Complex: " + Math.round(percentageSum) + "%");

    //draw yellow rectangles for every pair of coordinates in kcPlotRanges
    double start;
    double stop;

    for (Range<Integer> next : kcPlotRanges) {
        start = next.lowerEndpoint();
        stop = next.upperEndpoint();

        Rectangle r = new Rectangle();
        r.layoutXProperty()
                .bind(this.xAxis.widthProperty().multiply((start + 1.) / (double) this.displayBuffer[0].length)
                        .add(this.xAxis.layoutXProperty()));

        r.setLayoutY(0);
        r.widthProperty()
                .bind(xAxis.widthProperty().multiply((stop - start) / (double) this.displayBuffer[0].length));

        r.heightProperty().bind(overlay4.heightProperty());
        r.fillProperty().setValue(Color.LIGHTBLUE);
        r.opacityProperty().set(0.5);

        overlay4.getChildren().add(r);

    }

    lineChart.requestFocus();
}

From source file:com.github.vatbub.tictactoe.view.Main.java

@FXML
// This method is called by the FXMLLoader when initialization is complete
void initialize() {
    // modify the default exception handler to show a good error message on every uncaught exception
    final Thread.UncaughtExceptionHandler currentUncaughtExceptionHandler = Thread
            .getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> {
        if (currentUncaughtExceptionHandler != null) {
            // execute current handler as we only want to append it
            currentUncaughtExceptionHandler.uncaughtException(thread, exception);
        }/*w w  w .ja va2  s.co  m*/
        Platform.runLater(() -> new ExceptionAlert(exception).showAndWait());
    });

    opponentsTurnHBox.heightProperty()
            .addListener((observable, oldValue, newValue) -> updateOpponentsTurnHBox(false));

    aiLevelLabelClipRectangle = new Rectangle(0, 0, 0, 0);
    aiLevelLabelClipRectangle.setEffect(new MotionBlur(0, 10));
    aiLevelLabelPane.setClip(aiLevelLabelClipRectangle);
    aiLevelLabelClipRectangle.heightProperty().bind(aiLevelLabelPane.heightProperty());
    aiLevelLabelPane.widthProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel(true));

    Rectangle menuSubBoxClipRectangle = new Rectangle(0, 0, 0, 0);
    menuSubBox.setClip(menuSubBoxClipRectangle);
    menuSubBoxClipRectangle.heightProperty().bind(menuSubBox.heightProperty());
    menuSubBoxClipRectangle.widthProperty().bind(menuSubBox.widthProperty());

    Rectangle playOnlineClipRectangle = new Rectangle(0, 0, 0, 0);
    playOnlineClipAnchorPane.setClip(playOnlineClipRectangle);
    playOnlineClipRectangle.heightProperty().bind(playOnlineClipAnchorPane.heightProperty());
    playOnlineClipRectangle.widthProperty().bind(playOnlineClipAnchorPane.widthProperty());

    player1SetSampleName();
    player2SetSampleName();

    gameTable.heightProperty()
            .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(gameTable.getWidth(),
                    oldValue.doubleValue(), gameTable.getWidth(), newValue.doubleValue()));
    gameTable.widthProperty()
            .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(oldValue.doubleValue(),
                    gameTable.getHeight(), newValue.doubleValue(), gameTable.getHeight()));

    player1AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> {
        showHideAILevelSlider(newValue, player2AIToggle.isSelected());
        player1SetSampleName();
    });
    player2AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> {
        showHideAILevelSlider(player1AIToggle.isSelected(), newValue);
        player2SetSampleName();
    });

    gameTable.setSelectionModel(null);
    gameTable.heightProperty().addListener((observable, oldValue, newValue) -> {
        Pane header = (Pane) gameTable.lookup("TableHeaderRow");
        if (header.isVisible()) {
            header.setMaxHeight(0);
            header.setMinHeight(0);
            header.setPrefHeight(0);
            header.setVisible(false);
        }
        renderRows();
    });
    gameTable.setRowFactory(param -> {
        TableRow<Row> row = new TableRow<>();
        row.styleProperty().bind(style);

        if (rowFont == null) {
            rowFont = new SimpleObjectProperty<>();
            rowFont.bind(row.fontProperty());
        }

        return row;
    });

    looseImage.fitHeightProperty().bind(looserPane.heightProperty());
    looseImage.fitWidthProperty().bind(looserPane.widthProperty());
    looseImage.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage,
            getClass().getResource("loose.png").toString(), looseImage.getFitWidth(), newValue.doubleValue()));
    looseImage.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage,
            getClass().getResource("loose.png").toString(), newValue.doubleValue(), looseImage.getFitWidth()));

    confetti.fitHeightProperty().bind(winPane.heightProperty());
    confetti.fitWidthProperty().bind(winPane.widthProperty());
    confetti.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti,
            getClass().getResource("confetti.png").toString(), confetti.getFitWidth(), newValue.doubleValue()));
    confetti.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti,
            getClass().getResource("confetti.png").toString(), newValue.doubleValue(), confetti.getFitWidth()));

    aiLevelSlider.valueProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel());

    playOnlineHyperlink.widthProperty().addListener((observable, oldValue, newValue) -> {
        if (playOnlineAnchorPane.isVisible()) {
            setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true);
        }
    });
    playOnlineHyperlink.heightProperty().addListener((observable, oldValue, newValue) -> {
        if (playOnlineAnchorPane.isVisible()) {
            setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true);
        }
    });
    playOnlineHyperlink.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.equals(oldValue)) {
            if (newValue.contains("ff")) {
                setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, 1);
            } else {
                setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, -1);
            }
        }
    });

    // Kunami code
    root.setOnKeyPressed(event -> {
        if (KunamiCode.isCompleted(event.getCode())) {
            if (root.getEffect() != null && root.getEffect() instanceof Blend) {
                BlendMode currentMode = ((Blend) root.getEffect()).getMode();
                BlendMode nextMode;
                if (currentMode == BlendMode.values()[BlendMode.values().length - 1]) {
                    nextMode = BlendMode.values()[0];
                } else {
                    nextMode = BlendMode.values()[Arrays.asList(BlendMode.values()).indexOf(currentMode) + 1];
                }
                ((Blend) root.getEffect()).setMode(nextMode);
            } else {
                root.setEffect(new Blend(BlendMode.EXCLUSION));
            }
        }
    });

    // prompt text of the my username field in the online multiplayer menu
    onlineMyUsername.promptTextProperty().bind(player1Name.promptTextProperty());
    onlineMyUsername.textProperty().bindBidirectional(player1Name.textProperty());

    setAccessibleTextsForNodesThatDoNotChange();
    updateAccessibleTexts();

    initBoard();
    initNewGame();
}

From source file:snpviewer.SnpViewer.java

private void drawRegionSummary(RegionSummary reg, String currentChrom) {
    if (currentChrom == null) {
        if (reg.getChromosome() != null) {
            currentChrom = reg.getChromosome();
        } else {//from w  w w  .j a  v a 2s.c  o m
            return;
        }
    }
    ChromosomeLength chromLength;
    try {
        chromLength = new ChromosomeLength(genomeVersion);
    } catch (Exception ex) {
        chromLength = new ChromosomeLength();
    }
    double x;
    double width;
    double cLength;
    try {
        cLength = chromLength.getLength(currentChrom);
    } catch (Exception ex) {
        ex.printStackTrace();
        return;
    }
    int startPos = reg.getStartPos();
    int rLength = reg.getLength();
    x = chromSplitPane.getWidth() / cLength * startPos;
    width = chromSplitPane.getWidth() / cLength * rLength;

    Rectangle regionRectangle = new Rectangle();
    regionRectangle.setX(x);
    regionRectangle.setWidth(width);
    regionRectangle.setY(0);
    regionRectangle.xProperty().bind(selectionOverlayPane.widthProperty().divide(cLength).multiply(startPos));
    regionRectangle.heightProperty().bind(selectionOverlayPane.heightProperty());
    regionRectangle.widthProperty()
            .bind(selectionOverlayPane.widthProperty().divide(cLength).multiply(rLength));
    regionRectangle.strokeProperty().set(colorComp.get(Colors.saveLine.value));
    regionRectangle.fillProperty().set(colorComp.get(Colors.saveFill.value));
    regionRectangle.setOpacity(0.40);
    regionRectangle.setStrokeWidth(2);
    savedRegionsDisplay.add(regionRectangle);
    savedRegionsReference.add(reg);
}