Example usage for javafx.stage Stage setOnHidden

List of usage examples for javafx.stage Stage setOnHidden

Introduction

In this page you can find the example usage for javafx.stage Stage setOnHidden.

Prototype

public final void setOnHidden(EventHandler<WindowEvent> value) 

Source Link

Usage

From source file:com.omicronware.streamlet.Main.java

@Override
public void start(Stage stage) throws Exception {
    //register the different type of lists on ObjectFactory

    stage.setTitle("StreamLET - Omicronware Software (C)");
    stage.getIcons().add(new Image(
            getClass().getResource("/com/omicronware/streamlet/fxml/images/icon_96_96.png").toExternalForm()));
    stage.setOnHidden((WindowEvent event) -> {
        if (DATABASE != null) {
            DATABASE.close();//  w ww .j av a 2s.  c  o  m
        }
        if (SETTINGS != null) {
            StoreObjectManager.getInstance().storeObject(SETTINGS);
        }
        Platform.exit();
        System.exit(0);
    });
    this.stage = stage;
    openDatabase();
}

From source file:com.jf.javafx.Application.java

/**
 * Start the application/*  w  ww.  j  av a  2  s . co  m*/
 *
 * @param primaryStage
 * @throws java.lang.Exception
 */
@Override
public void start(Stage primaryStage) throws Exception {
    Application.sapp = this;
    this.pStage = primaryStage;

    // set env variables
    _initVars();
    // load properties
    _initConfigurations();

    _initStartupServices();

    // handle on closing window
    primaryStage.setOnHidden((WindowEvent event) -> {
        _commitProperties();
    });
    primaryStage.initStyle(StageStyle.TRANSPARENT);
    primaryStage.setTitle(getResourceBundle().getString("app.title"));
    primaryStage.show();
}

From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java

private void onTrajectoryFileChoosed(File selectedFile) {

    textFileParserFrameController.setColumnAssignment(true);
    textFileParserFrameController.setColumnAssignmentValues("Ignore", "Easting", "Northing", "Elevation",
            "Time");

    textFileParserFrameController.setColumnAssignmentDefaultSelectedIndex(0, 1);
    textFileParserFrameController.setColumnAssignmentDefaultSelectedIndex(1, 2);
    textFileParserFrameController.setColumnAssignmentDefaultSelectedIndex(2, 3);
    textFileParserFrameController.setColumnAssignmentDefaultSelectedIndex(3, 4);

    if (trajectoryFile != null) {
        textFileParserFrameController.setHeaderExtractionEnabled(trajectoryFile.containsHeader());
        textFileParserFrameController.setSeparator(trajectoryFile.getColumnSeparator());
        trajectoryFile.setColumnAssignment(trajectoryFile.getColumnAssignment());
    } else {/*  w w  w  . j ava 2 s . c  om*/
        textFileParserFrameController.setHeaderExtractionEnabled(true);
        textFileParserFrameController.setSeparator(",");
    }

    try {
        textFileParserFrameController.setTextFile(selectedFile);
    } catch (IOException ex) {
        showErrorDialog(ex);
        return;
    }

    Stage textFileParserFrame = textFileParserFrameController.getStage();
    textFileParserFrame.show();

    textFileParserFrame.setOnHidden(new EventHandler<WindowEvent>() {

        @Override
        public void handle(WindowEvent event) {

            trajectoryFile = new CSVFile(selectedFile.getAbsolutePath());
            trajectoryFile.setColumnSeparator(textFileParserFrameController.getSeparator());
            trajectoryFile.setColumnAssignment(textFileParserFrameController.getAssignedColumnsItemsMap());
            trajectoryFile.setNbOfLinesToRead(textFileParserFrameController.getNumberOfLines());
            trajectoryFile.setNbOfLinesToSkip(textFileParserFrameController.getSkipLinesNumber());
            trajectoryFile.setContainsHeader(textFileParserFrameController.getHeaderIndex() != -1);
            trajectoryFile.setHeaderIndex(textFileParserFrameController.getHeaderIndex());

            textFieldTrajectoryFileALS.setText(selectedFile.getAbsolutePath());
        }
    });
}

From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java

private PointCloudFilterPaneComponent addPointcloudFilterComponent() {

    final PointCloudFilterPaneComponent pcfpc = new PointCloudFilterPaneComponent();

    pcfpc.getButtonRemovePointCloudFilter().setOnAction(new EventHandler<ActionEvent>() {

        @Override//  w w w .jav  a 2s  . com
        public void handle(ActionEvent event) {

            vBoxPointCloudFiltering.getChildren().remove(pcfpc);
        }
    });

    pcfpc.getButtonOpenPointCloudFile().setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            if (lastFCOpenPointCloudFile != null) {
                fileChooserOpenPointCloudFile.setInitialDirectory(lastFCOpenPointCloudFile.getParentFile());
            }

            File selectedFile = fileChooserOpenPointCloudFile.showOpenDialog(stage);
            if (selectedFile != null) {

                lastFCOpenPointCloudFile = selectedFile;

                textFileParserFrameController.setColumnAssignment(true);
                textFileParserFrameController.setColumnAssignmentValues("Ignore", "X", "Y", "Z");

                textFileParserFrameController.setColumnAssignmentDefaultSelectedIndex(0, 1);
                textFileParserFrameController.setColumnAssignmentDefaultSelectedIndex(1, 2);
                textFileParserFrameController.setColumnAssignmentDefaultSelectedIndex(2, 3);
                textFileParserFrameController.setColumnAssignmentDefaultSelectedIndex(3, 4);

                textFileParserFrameController.setHeaderExtractionEnabled(true);
                textFileParserFrameController.setSeparator(",");

                try {
                    textFileParserFrameController.setTextFile(selectedFile);
                } catch (IOException ex) {
                    showErrorDialog(ex);
                    return;
                }

                Stage textFileParserFrame = textFileParserFrameController.getStage();
                textFileParserFrame.show();

                textFileParserFrame.setOnHidden(new EventHandler<WindowEvent>() {

                    @Override
                    public void handle(WindowEvent event) {

                        CSVFile file = new CSVFile(selectedFile.getAbsolutePath());

                        file.setColumnSeparator(textFileParserFrameController.getSeparator());
                        file.setColumnAssignment(textFileParserFrameController.getAssignedColumnsItemsMap());
                        file.setNbOfLinesToRead(textFileParserFrameController.getNumberOfLines());
                        file.setNbOfLinesToSkip(textFileParserFrameController.getSkipLinesNumber());
                        file.setContainsHeader(textFileParserFrameController.getHeaderIndex() != -1);
                        file.setHeaderIndex(textFileParserFrameController.getHeaderIndex());

                        pcfpc.setCSVFile(file);
                    }
                });

            }
        }
    });

    pcfpc.disableContent(!checkboxUsePointcloudFilter.isSelected());

    vBoxPointCloudFiltering.getChildren().add(pcfpc);

    return pcfpc;
}

From source file:org.mskcc.shenkers.control.track.fasta.FastaViewNGTest.java

@Test
public void testGetGraphic() throws InterruptedException {
    String title = "";
    CountDownLatch l = new CountDownLatch(1);
    Platform.runLater(() -> {/* ww  w . j  av  a 2 s  .com*/
        String st = "CGATCGCCATTGAGCAAGTAAGCCAACTTTCGGCTCGCGTGTACGCGATAAGTAGGTGCCCTCTGCATCCGACGCACTTCAGCCGAACCACTTGCGGGAATTTGGGGGAGTGCTGATACGACGGCATAGGAATGGAGCTCTTTAAGTGCGTCTACACACGGACCGTACTTGGCCAAATCGGCAGTCAGTTGTATT";
        FastaView tp = new FastaView();
        tp.flip.setValue(true);
        tp.setSequence(0, st);

        Scene scene = new Scene(tp, 300, 300, Color.GRAY);
        Stage stage = new Stage();
        stage.setScene(scene);

        stage.setOnHidden(e -> {
            l.countDown();
        });
        stage.show();

    });
    l.await();
}

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

public void testRangeSetIntervalView() throws InterruptedException {
    System.out.println("testIntervalView");

    CountDownLatch l = new CountDownLatch(1);
    System.out.println("before");
    Platform.runLater(() -> {/*from  w  ww  .j  ava2 s  . co  m*/
        System.out.println("running");
        double[][] intervals = { { .1, .2 } };
        //                    Range r = null;
        RangeSet<Double> rs = TreeRangeSet.create();
        rs.add(Range.closed(.1, .2));
        rs.add(Range.closed(.2, .3));
        rs.add(Range.closed(.32, .35));
        rs.add(Range.closed(.6, .8));

        RangeSetIntervalView p = new RangeSetIntervalView(0, 100);
        p.setData(Arrays.asList(new Pair(10, 20), new Pair(20, 30), new Pair(32, 35), new Pair(60, 80)));

        //                    p.prefTileHeightProperty().bind(p.heightProperty());
        Stage stage = new Stage();
        stage.setOnHidden(e -> {
            l.countDown();
            System.out.println("count " + l.getCount());
        });
        Scene scene = new Scene(p, 300, 300, Color.GRAY);
        stage.setTitle("SimpleIntervalView");
        stage.setScene(scene);
        stage.show();

    });
    System.out.println("after");
    l.await();
    Thread.sleep(1000);
}

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

public void testIntervalView() throws InterruptedException {
    System.out.println("testIntervalView");
    Pane p = new Pane();

    CountDownLatch l = new CountDownLatch(1);
    System.out.println("before");
    Platform.runLater(() -> {//from   w w w . ja v  a2s .  c om
        System.out.println("running");
        double[][] intervals = { { .1, .2 } };
        //                    Range r = null;
        RangeSet<Double> rs = TreeRangeSet.create();
        rs.add(Range.closed(.1, .2));
        rs.add(Range.closed(.2, .3));
        rs.add(Range.closed(.32, .35));
        rs.add(Range.closed(.6, .8));

        for (Range<Double> r : rs.asRanges()) {
            System.out.println(r.lowerEndpoint() + " - " + r.upperEndpoint());
        }
        for (Range<Double> interval : rs.asRanges()) {
            Rectangle r = new Rectangle();
            r.widthProperty()
                    .bind(p.widthProperty().multiply(interval.upperEndpoint() - interval.lowerEndpoint()));
            r.heightProperty().bind(p.heightProperty());
            r.xProperty().bind(p.widthProperty().multiply(interval.lowerEndpoint()));
            p.getChildren().add(r);
        }
        //                    p.prefTileHeightProperty().bind(p.heightProperty());
        Stage stage = new Stage();
        stage.setOnHidden(e -> {
            l.countDown();
            System.out.println("count " + l.getCount());
        });
        Scene scene = new Scene(p, 300, 300, Color.GRAY);
        stage.setTitle("JavaFX Scene Graph Demo");
        stage.setScene(scene);
        stage.show();

    });
    System.out.println("after");
    l.await();
    Thread.sleep(1000);
}

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

@Test
public void testGenericStackedIntervalView() throws InterruptedException {
    List<Pair<Integer, Integer>> intervals = Arrays.asList(new Pair(0, 1), new Pair(1, 2), new Pair(2, 3),
            new Pair(3, 4), new Pair(4, 5), new Pair(5, 6));
    List<Pane> nodes = intervals.stream().map(i -> new RectangleIntervalNode()).collect(Collectors.toList());
    GenericStackedIntervalView p = new GenericStackedIntervalView(0, 6);
    p.setData(intervals, nodes);/*from ww  w .  j a  v a2s .c o m*/

    ScrollPane sp = new ScrollPane(p);
    ScrollBar sb = new ScrollBar();
    sb.maxProperty().bind(sp.vmaxProperty());
    sb.minProperty().bind(sp.vminProperty());
    sb.visibleAmountProperty().bind(sp.heightProperty().divide(p.prefHeightProperty()));
    sb.setOrientation(Orientation.VERTICAL);
    sp.vvalueProperty().bindBidirectional(sb.valueProperty());
    HiddenSidesPane hsp = new HiddenSidesPane();
    hsp.setContent(sp);
    hsp.setRight(sb);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    p.setOrientation(Orientation.VERTICAL);
    p.prefTileHeightProperty().bind(new SimpleDoubleProperty(40));
    //        p.minHeightProperty().bind(new SimpleDoubleProperty(20).multiply(Bindings.size(p.getChildren())));
    p.prefTileWidthProperty().bind(sp.widthProperty());
    p.prefHeightProperty()
            .bind(new SimpleDoubleProperty(50).multiply(Bindings.size(p.getChildren())).subtract(10));
    p.prefWidthProperty().bind(sp.widthProperty());
    sp.setPadding(Insets.EMPTY);
    p.setVgap(10);

    CountDownLatch l = new CountDownLatch(1);
    Platform.runLater(() -> {

        Stage stage = new Stage();
        stage.setOnHidden(e -> {
            l.countDown();
        });
        Scene scene = new Scene(hsp, 300, 300, Color.GRAY);
        stage.setTitle("GenericStackedPaneTest");
        stage.setScene(scene);
        stage.show();

    });
    l.await();
}

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

public void testStackedIntervalView() throws InterruptedException {
    StackedIntervalView p = new StackedIntervalView(0, 6);
    p.setData(Arrays.asList(new Pair(0, 1), new Pair(1, 2), new Pair(2, 3), new Pair(3, 4), new Pair(4, 5),
            new Pair(5, 6)
    //, {8, 10}, {1, 2}, {3, 7},
    //            {9, 10}, {1, 2}, {3, 5}, {6, 7}, {8, 10}, {2, 5}, {8, 10}
    ));/* w  w  w.jav a  2s  . c om*/

    ScrollPane sp = new ScrollPane(p);
    ScrollBar sb = new ScrollBar();
    sb.maxProperty().bind(sp.vmaxProperty());
    sb.minProperty().bind(sp.vminProperty());
    sb.visibleAmountProperty().bind(sp.heightProperty().divide(p.prefHeightProperty()));
    sb.setOrientation(Orientation.VERTICAL);
    sp.vvalueProperty().bindBidirectional(sb.valueProperty());
    HiddenSidesPane hsp = new HiddenSidesPane();
    hsp.setContent(sp);
    hsp.setRight(sb);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    p.setOrientation(Orientation.VERTICAL);
    p.prefTileHeightProperty().bind(new SimpleDoubleProperty(40));
    //        p.minHeightProperty().bind(new SimpleDoubleProperty(20).multiply(Bindings.size(p.getChildren())));
    p.prefTileWidthProperty().bind(sp.widthProperty());
    p.prefHeightProperty()
            .bind(new SimpleDoubleProperty(50).multiply(Bindings.size(p.getChildren())).subtract(10));
    p.prefWidthProperty().bind(sp.widthProperty());
    sp.setPadding(Insets.EMPTY);
    p.setVgap(10);

    CountDownLatch l = new CountDownLatch(1);
    Platform.runLater(() -> {

        Stage stage = new Stage();
        stage.setOnHidden(e -> {
            l.countDown();
        });
        Scene scene = new Scene(hsp, 300, 300, Color.GRAY);
        stage.setTitle("StackedPaneTest");
        stage.setScene(scene);
        stage.show();

    });
    l.await();
}

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

public void testStackIntervalView() throws InterruptedException {
    System.out.println("testStackIntervalView");
    int[][] d = new int[][] { { 2, 6 }, { 7, 10 }, { 1, 3 }, { 4, 6 }, { 8, 10 }, { 1, 2 }, { 3, 7 }, { 9, 10 },
            { 1, 2 }, { 3, 5 }, { 6, 7 }, { 8, 10 }, { 2, 5 }, { 8, 10 } };
    List<int[]> asList = Arrays.asList(d);
    Collections.sort(asList, new Comparator<int[]>() {

        @Override/*from   ww  w.ja va2s. com*/
        public int compare(int[] o1, int[] o2) {
            return o1[0] - o2[0];
        }
    });
    List<TreeRangeSet<Integer>> rows = new ArrayList<>();
    rows.add(TreeRangeSet.create());
    for (int[] r : d) {
        Range<Integer> R = Range.closed(r[0], r[1]);
        int i = 0;
        added: {
            while (i < rows.size()) {
                TreeRangeSet<Integer> set = rows.get(i);
                RangeSet<Integer> intersection = set.subRangeSet(Range.closed(r[0] - 1, r[1] + 1));
                if (intersection.isEmpty()) {
                    set.add(R);
                    break added;
                }
                i++;
            }
            //                Stri i = ;
            TreeRangeSet<Integer> row = TreeRangeSet.create();
            row.add(R);
            rows.add(row);
        }
    }
    TilePane p = new TilePane();
    p.setSnapToPixel(false);
    for (int i = 0; i < rows.size(); i++) {
        p.getChildren().add(get(rows.get(i), 0, 11));
        System.out.println(rows.get(i).toString());
        StringBuilder sb = new StringBuilder(11);
        sb.append(StringUtils.repeat(".", 11));
        for (int j = 0; j < 11; j++) {
            if (rows.get(i).contains(j)) {
                sb.setCharAt(j, 'X');
            }
        }
        System.out.println(sb.toString());
    }
    //        p.prefWidth(100);
    //        p.prefHeight(100);
    ScrollPane sp = new ScrollPane(p);
    ScrollBar sb = new ScrollBar();
    sb.maxProperty().bind(sp.vmaxProperty());
    sb.minProperty().bind(sp.vminProperty());
    sb.visibleAmountProperty().bind(sp.heightProperty().divide(p.prefHeightProperty()));
    sb.setOrientation(Orientation.VERTICAL);
    sp.vvalueProperty().bindBidirectional(sb.valueProperty());
    HiddenSidesPane hsp = new HiddenSidesPane();
    hsp.setContent(sp);
    hsp.setRight(sb);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    p.setOrientation(Orientation.VERTICAL);
    p.prefTileHeightProperty().bind(new SimpleDoubleProperty(40));
    //        p.minHeightProperty().bind(new SimpleDoubleProperty(20).multiply(Bindings.size(p.getChildren())));
    p.prefTileWidthProperty().bind(sp.widthProperty());
    p.prefHeightProperty()
            .bind(new SimpleDoubleProperty(50).multiply(Bindings.size(p.getChildren())).subtract(10));
    p.prefWidthProperty().bind(sp.widthProperty());
    sp.setPadding(Insets.EMPTY);
    p.setVgap(10);

    CountDownLatch l = new CountDownLatch(1);
    Platform.runLater(() -> {

        Stage stage = new Stage();
        stage.setOnHidden(e -> {
            l.countDown();
        });
        Scene scene = new Scene(hsp, 300, 300, Color.GRAY);
        stage.setTitle("JavaFX Scene Graph Demo");
        stage.setScene(scene);
        stage.show();

    });
    l.await();
}