Example usage for javafx.scene.layout TilePane prefTileHeightProperty

List of usage examples for javafx.scene.layout TilePane prefTileHeightProperty

Introduction

In this page you can find the example usage for javafx.scene.layout TilePane prefTileHeightProperty.

Prototype

public final DoubleProperty prefTileHeightProperty() 

Source Link

Document

The preferred height of each tile.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);

    TilePane tile = new TilePane();
    tile.setHgap(8);/*from   w  w  w .  j a v  a  2  s  . c  o  m*/
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }
    System.out.println(tile.prefTileHeightProperty());
    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(hbox);
    stage.setScene(scene);
    stage.show();
}

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/*  w ww.j  a  v  a2s.  c  o  m*/
        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();
}