List of usage examples for javafx.scene.layout TilePane setVgap
public final void setVgap(double value)
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 av a 2s . c o m tile.setPrefColumns(4); for (int i = 0; i < 20; i++) { tile.getChildren().add(new CheckBox("CheckBox")); } tile.setVgap(0.6); 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:Main.java
private TilePane addTilePane() { TilePane tile = new TilePane(); tile.setPadding(new Insets(5, 0, 5, 0)); tile.setVgap(4); tile.setHgap(4);//from ww w. j av a 2 s . c o m tile.setPrefColumns(2); tile.setStyle("-fx-background-color: DAE6F3;"); ImageView pages[] = new ImageView[8]; for (int i = 0; i < 8; i++) { pages[i] = new ImageView( new Image(Main.class.getResourceAsStream("graphics/chart_" + (i + 1) + ".png"))); tile.getChildren().add(pages[i]); } return tile; }
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 w w . j a v a 2s. c om*/ 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(); }
From source file:photobooth.views.ExplorerPane.java
private void init(String dir, int offset, int limit, int directoryLevel) { this.getChildren().removeAll(this.getChildren()); this.dir = dir; this.offset = offset; this.limit = limit; this.directoryLevel = directoryLevel; try {/*from w ww. j ava2 s .co m*/ addXButton(); } catch (IOException ex) { Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex); } if (directoryLevel > 0) { try { addUpButton(); } catch (IOException ex) { Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex); } } addLabel(); TilePane tile = new TilePane(); tile.setHgap(12); tile.setVgap(12); File folder = new File(dir); File[] listOfDirs = folder.listFiles(new FileFilter() { @Override public boolean accept(File file) { return file.isDirectory(); } }); File[] allFileAndDiresctoies = new File[0]; if (listOfDirs != null) { Arrays.sort(listOfDirs); File[] listOfImages = folder.listFiles(new FileFilter() { @Override public boolean accept(File file) { String ext = FilenameUtils.getExtension(file.getAbsolutePath()); return ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("png"); } }); Arrays.sort(listOfImages); allFileAndDiresctoies = new File[listOfDirs.length + listOfImages.length]; System.arraycopy(listOfDirs, 0, allFileAndDiresctoies, 0, listOfDirs.length); System.arraycopy(listOfImages, 0, allFileAndDiresctoies, listOfDirs.length, listOfImages.length); File[] subArray = new File[limit]; int countToCopy = limit; if (offset + limit > allFileAndDiresctoies.length) { countToCopy -= offset + limit - allFileAndDiresctoies.length; } System.arraycopy(allFileAndDiresctoies, offset, subArray, 0, countToCopy); for (final File file : subArray) { if (file == null) { break; } if (file.isFile()) { tile.getChildren().add(createImageView(file)); } else { Button button = new Button(file.getName()); button.setMaxSize(100, 100); button.setMinSize(100, 100); button.setWrapText(true); button.getStyleClass().add("folderButton"); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Global.getInstance().setSceneRoot(LoadingPane.getInstance()); Platform.runLater(() -> { new Thread(new Runnable() { @Override public void run() { ExplorerPane.getInstance().setDir(file.getAbsolutePath(), 0, limit, directoryLevel + 1); Global.getInstance().setSceneRoot(ExplorerPane.getInstance()); } }).start(); }); } }); tile.getChildren().add(button); } } } this.getChildren().add(tile); tile.setMinWidth(670); tile.setMaxWidth(670); tile.setLayoutX(65); tile.setLayoutY(70); tile.setMaxHeight(390); if (allFileAndDiresctoies.length > offset + limit) { try { addNextButton(); } catch (IOException ex) { Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex); } } if (offset > 0) { try { addPrevButton(); } catch (IOException ex) { Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex); } } }