List of usage examples for javafx.scene.layout Pane minHeightProperty
public final DoubleProperty minHeightProperty()
From source file:net.rptools.layercontrol.LayerStackLayer.java
/** * Add a layer.// w w w. j a va 2s . co m * @param i index to add at * @param layer layer to add */ @ThreadPolicy(ThreadPolicy.ThreadId.ANY) public synchronized void addLayer(final int i, final Layer layer) { if (!Platform.isFxApplicationThread()) { Platform.runLater(new Runnable() { @Override public void run() { addLayer(i, layer); } }); } // Now on JFX thread Pane pane = new Pane(); final String resource = "layer" + layer.getName() + ".fxml"; try { pane = component.getFramework().getFXMLLoader(layer.getClass().getResource(resource)).load(); } catch (final Exception e) { LOGGER.warn("no layer pane found resource={}", resource); } pane.getStyleClass().add(layer.getName().toLowerCase()); pane.setId(StringUtils.uncapitalize(layer.getName())); pane.minWidthProperty().bind(getDrawable().widthProperty()); pane.minHeightProperty().bind(getDrawable().heightProperty()); final int size = getDrawable().getChildren().size(); getDrawable().getChildren().add(size - i, pane); layer.setDrawable(pane); }
From source file:snpviewer.SnpViewer.java
private void clearSplitPanes() { for (Iterator it = chromSplitPane.getItems().iterator(); it.hasNext();) { Object child = it.next(); if (child instanceof Pane) { Pane p = (Pane) child; for (Iterator pit = p.getChildren().iterator(); pit.hasNext();) { Object pChild = pit.next(); if (pChild instanceof ImageView) { ImageView i = (ImageView) pChild; i.fitHeightProperty().unbind(); i.fitWidthProperty().unbind(); } else if (pChild instanceof Line) { Line l = (Line) pChild; l.startXProperty().unbind(); l.endXProperty().unbind(); l.startYProperty().unbind(); l.endYProperty().unbind(); }//from w w w .j a v a 2 s . com } p.minWidthProperty().unbind(); p.minHeightProperty().unbind(); } } for (Iterator it = labelSplitPane.getItems().iterator(); it.hasNext();) { Object child = it.next(); if (child instanceof Pane) { Pane p = (Pane) child; p.minWidthProperty().unbind(); p.minHeightProperty().unbind(); } } chromSplitPane.getItems().clear(); labelSplitPane.getItems().clear(); }
From source file:snpviewer.SnpViewer.java
public void drawCoordinatesWithIterator(final SnpFile sfile, final Pane pane, final String pngPath, final Iterator<SnpFile> sIter, final Iterator<Pane> pIter, final int currentFile, final int totalFiles, final String chrom, final Double start, final Double end, final boolean forceRedraw, final SplitPane splitPane) { Stage stage = (Stage) splitPane.getScene().getWindow(); fixStageSize(stage, true);// w ww.jav a 2 s.c om //stage.setResizable(false);//we have to disable this when using windows due to a bug (in javafx?) File pngFile = new File(sfile.getOutputDirectoryName() + "/" + chrom + ".png"); if (pngPath != null && pngPath.length() > 0) { pngFile = new File(sfile.getOutputDirectoryName() + "/" + pngPath + "/" + chrom + ".png"); } if (!forceRedraw && pngFile.exists()) { try { progressBar.progressProperty().unbind(); progressBar.setProgress((double) currentFile / (double) totalFiles); BufferedImage bufferedImage = ImageIO.read(pngFile); Image image = SwingFXUtils.toFXImage(bufferedImage, null); ImageView chromImage = new ImageView(image); //chromImage.setCache(true); pane.getChildren().clear(); pane.getChildren().add(chromImage); //pane.setCache(true); chromImage.fitWidthProperty().bind(pane.widthProperty()); chromImage.fitHeightProperty().bind(pane.heightProperty()); pane.minHeightProperty().bind(splitPane.heightProperty().divide(totalFiles)); pane.minWidthProperty().bind(splitPane.widthProperty()); if (sIter.hasNext()) { SnpFile nextFile = sIter.next(); Pane nextPane = pIter.next(); drawCoordinatesWithIterator(nextFile, nextPane, pngPath, sIter, pIter, currentFile + 1, totalFiles, chrom, start, end, forceRedraw, splitPane); } else { progressBar.progressProperty().unbind(); progressBar.setProgress(0); setProgressMode(false); fixStageSize(stage, false);//for windows only stage.setResizable(true); } } catch (IOException ex) { Dialogs.showErrorDialog(null, "IO error reading cached image", "Error displaying chromosome image", "SnpViewer", ex); return; } } else { final DrawSnpsToPane draw = new DrawSnpsToPane(pane, sfile, chrom, Colors.aa.value, Colors.bb.value, Colors.ab.value, start, end); progressBar.progressProperty().unbind(); //progressBar.setProgress(0); //progressBar.progressProperty().bind(draw.progressProperty()); progressTitle.setText("Drawing " + currentFile + " of " + totalFiles); progressMessage.textProperty().bind(draw.messageProperty()); cancelButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { draw.cancel(); } }); draw.setOnCancelled(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent t) { progressBar.progressProperty().unbind(); progressBar.setProgress(0); progressTitle.setText("Drawing Cancelled"); progressMessage.textProperty().unbind(); progressMessage.setText("Drawing Cancelled"); setProgressMode(false); selectionOverlayPane.getChildren().clear(); selectionOverlayPane.getChildren().add(dragSelectRectangle); Stage stage = (Stage) splitPane.getScene().getWindow(); stage.setResizable(true); fixStageSize(stage, false);//for windows only } }); draw.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent t) { ArrayList<HashMap<String, Double>> result = (ArrayList<HashMap<String, Double>>) t.getSource() .getValue(); progressBar.progressProperty().unbind(); progressBar.setProgress((double) currentFile / (2 * (double) totalFiles)); progressTitle.setText(""); progressMessage.textProperty().unbind(); progressMessage.setText(""); /*if (pane.getMinHeight() < 200){ pane.setMinHeight(200); } if (pane.getMinWidth() < 800){ pane.setMinWidth(800); }*/ if (result != null) { List<Line> lines = drawLinesToPane(pane, result); pane.getChildren().addAll(lines); pane.setVisible(true); convertSampleViewToImage(sfile, pane, chrom, pngPath); /*for (Line l: lines){ l.startXProperty().unbind(); l.startYProperty().unbind(); l.endXProperty().unbind(); l.endYProperty().unbind(); }*/ lines.clear(); } progressBar.setProgress((double) currentFile / (double) totalFiles); pane.minWidthProperty().bind(splitPane.widthProperty()); pane.minHeightProperty().bind(splitPane.heightProperty().divide(totalFiles)); // pane.setCache(true); if (sIter.hasNext()) { SnpFile nextFile = sIter.next(); Pane nextPane = pIter.next(); drawCoordinatesWithIterator(nextFile, nextPane, pngPath, sIter, pIter, currentFile + 1, totalFiles, chrom, start, end, forceRedraw, splitPane); } else { setProgressMode(false); progressBar.progressProperty().unbind(); progressBar.setProgress(0); Stage stage = (Stage) splitPane.getScene().getWindow(); stage.setResizable(true); fixStageSize(stage, false);//for windows only } } }); draw.setOnFailed(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent t) { draw.reset(); progressBar.progressProperty().unbind(); progressBar.setProgress(0); progressTitle.setText("ERROR!"); progressMessage.textProperty().unbind(); progressMessage.setText("Drawing failed!"); setProgressMode(false); selectionOverlayPane.getChildren().clear(); selectionOverlayPane.getChildren().add(dragSelectRectangle); // Stage stage = (Stage) chromSplitPane.getScene().getWindow(); // stage.setResizable(true); } }); draw.start(); } }