Example usage for javafx.scene.shape Rectangle setVisible

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

Introduction

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

Prototype

public final void setVisible(boolean value) 

Source Link

Usage

From source file:snpviewer.SnpViewer.java

private void showHideSavedRegions() {
    for (Rectangle rect : savedRegionsDisplay) {
        rect.setVisible(!hideSavedRegionsMenu.isSelected());
    }// w ww  . ja  v a2  s.  c o m

}

From source file:snpviewer.SnpViewer.java

private void drawSavedRegions(String chrom) {
    selectionOverlayPane.getChildren().clear();
    if (savedRegions.isEmpty()) {
        selectionOverlayPane.getChildren().add(dragSelectRectangle);
        return;//w  w  w .j  ava  2 s  . c o m
    }
    for (RegionSummary r : savedRegions) {
        if (r.getChromosome() == null) {
            selectionOverlayPane.getChildren().add(dragSelectRectangle);
            return;
        }
        if (r.getChromosome().equalsIgnoreCase(chrom)) {
            drawRegionSummary(r, chrom);
        }
    }
    int rectCounter = 0;
    for (final Rectangle rect : savedRegionsDisplay) {
        final int counter = rectCounter;
        final ContextMenu scm = new ContextMenu();
        final MenuItem scmItem1 = new MenuItem("Display Flanking SNP IDs");
        scmItem1.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                /* get coordinates of selection and report back
                 * flanking snp ids and coordinates
                 */
                displayFlankingSnpIDs(rect);

            }
        });
        final MenuItem scmItem2 = new MenuItem("Write Region to File");
        scmItem2.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        /* get coordinates of selection and 
                         * write SNPs in region to file
                         */
                        writeRegionToFile(rect);
                    }
                });
            }
        });
        final MenuItem scmItem3 = new MenuItem("Remove this Saved Region");
        scmItem3.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                /* get coordinates of selection and 
                 * write SNPs in region to file
                 */
                removeSavedRegion(counter);

            }
        });
        final MenuItem scmItem4 = new MenuItem("Show/Hide Saved Regions");
        scmItem4.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                /* get coordinates of selection and report back
                 * write SNPs in region to file
                 */
                hideSavedRegionsMenu.selectedProperty().setValue(!hideSavedRegionsMenu.isSelected());
                hideSavedRegionsMenu.fire();
            }
        });
        final MenuItem scmItem5 = new MenuItem("Zoom Region");
        scmItem5.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                /* get coordinates of selection and report back
                 * write SNPs in region to file
                 */
                zoomRegion(rect);
            }
        });
        final MenuItem scmItem6 = new MenuItem("Write Saved Regions to File");
        scmItem6.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        /* get coordinates of selection and report back
                         * write SNPs in region to file
                         */
                        writeSavedRegionsToFile();
                    }
                });
            }
        });

        scm.getItems().add(scmItem1);
        scm.getItems().add(scmItem2);
        scm.getItems().add(scmItem3);
        scm.getItems().add(scmItem4);
        scm.getItems().add(scmItem5);
        scm.getItems().add(scmItem6);
        rect.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent e) {
                ocm.hide();

                if (scm.isShowing()) {
                    scm.hide();
                }
                if (e.getButton() == MouseButton.SECONDARY) {
                    if (chromosomeSelector.getSelectionModel().isEmpty()) {
                        for (MenuItem mi : scm.getItems()) {
                            mi.setDisable(true);
                        }
                    } else {
                        for (MenuItem mi : scm.getItems()) {
                            mi.setDisable(false);
                        }
                    }

                    scm.show(selectionOverlayPane, e.getScreenX(), e.getScreenY());
                }
            }

        });
        rect.setVisible(true);
        selectionOverlayPane.getChildren().add(rect);
        rectCounter++;
    }
    selectionOverlayPane.getChildren().add(dragSelectRectangle);
}