List of usage examples for javafx.scene.layout Pane getChildren
@Override
public ObservableList<Node> getChildren()
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private void addSpecialRequestNote(final Pane content, final BookingBean be) { final VBox b = new VBox(); b.getChildren().add(new Text("Special Requests")); final TextArea ta0 = new TextArea(be.getSpecialRequestNote()); ta0.setWrapText(true);//from w w w .j a va 2s .c om ta0.setPrefHeight(80); b.getChildren().add(ta0); booking2SpecialRequestNote.put(be, ta0); content.getChildren().add(b); }
From source file:io.github.moosbusch.permagon.configuration.builder.spi.AbstractPermagonBuilder.java
protected void buildPane(Pane pane) { if (containsKey(NODE_CHILDREN_PROPERTY)) { Object obj = Objects.requireNonNull(get(NODE_CHILDREN_PROPERTY)); if (obj instanceof ObservableMap) { ObservableMap propertiesMap = (ObservableMap) obj; Object childrenObj = Objects.requireNonNull(propertiesMap.get(NODE_CHILDREN_PROPERTY)); if (childrenObj instanceof ObservableList) { pane.getChildren().addAll((ObservableList) childrenObj); }//from ww w. j a va 2 s . c o m } } }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private void addRow1(final Pane content, final BookingBean be) { final VBox box = new VBox(); final HBox box0 = new HBox(); final HBox box1 = new HBox(); final HBox box2 = new HBox(); box.setFillWidth(true);/*from w w w . jav a 2 s . c om*/ box0.setFillHeight(true); box1.setFillHeight(true); box2.setFillHeight(true); addCheckInNote(box0, be); addCheckOutNote(box1, be); addSpecialRequestNote(box2, be); box.getChildren().addAll(box0, box1, box2); final TitledPane pane = new TitledPane("Notes", box); pane.setExpanded(false); content.getChildren().add(pane); }
From source file:de.ifsr.adam.ImageGenerator.java
/** * Takes a snapshot of the Pane and prints it to a pdf. * * @return True if no IOException occurred *//*from ww w . ja va 2 s.c o m*/ private boolean printToPDF(String filePath, Pane pane) { //Scene set up Group root = new Group(); Scene printScene = new Scene(root); printScene.getStylesheets().add(this.stylesheetURI.toString()); //Snapshot generation ArrayList<WritableImage> images = new ArrayList<>(); try { ObservableList<Node> panes = pane.getChildren(); for (int i = 0; i < panes.size(); i++) { GridPane gridPane = (GridPane) panes.get(i); ((Group) printScene.getRoot()).getChildren().clear(); ((Group) printScene.getRoot()).getChildren().addAll(gridPane); images.add(printScene.snapshot(null)); panes.add(i, gridPane); } } catch (Exception e) { log.error(e); return false; } //PDF Setup File outFile = new File(filePath + "." + "pdf"); Iterator<WritableImage> iterImages = images.iterator(); PDDocument doc = new PDDocument(); try { while (iterImages.hasNext()) { //Page setup PDPage page = new PDPage(); doc.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, false); //Image setup BufferedImage bufImage = SwingFXUtils.fromFXImage(iterImages.next(), null); PDPixelMap pixelMap = new PDPixelMap(doc, bufImage); int width = (int) (page.getMediaBox().getWidth()); int height = (int) (page.getMediaBox().getHeight()); Dimension dim = new Dimension(width, height); contentStream.drawXObject(pixelMap, 0, 0, dim.width, dim.height); contentStream.close(); } doc.save(outFile); return true; } catch (IOException | COSVisitorException e) { log.error(e); return false; } }
From source file:nl.rivm.cib.episim.model.disease.infection.MSEIRSPlot.java
@Override public void start(final Stage stage) { final SIRConfig conf = ConfigFactory.create(SIRConfig.class); final double[] t = conf.t(); final long[] pop = conf.population(); final double n0 = Arrays.stream(pop).sum(); final String[] colors = conf.colors(), colors2 = conf.colors2(); final Pane plot = new Pane(); plot.setPrefSize(400, 300);//from w w w . ja v a2 s .c o m plot.setMinSize(50, 50); final NumberAxis xAxis = new NumberAxis(t[0], t[1], (t[1] - t[0]) / 10); final NumberAxis yAxis = new NumberAxis(0, n0, n0 / 10); final Pane axes = new Pane(); axes.prefHeightProperty().bind(plot.heightProperty()); axes.prefWidthProperty().bind(plot.widthProperty()); xAxis.setSide(Side.BOTTOM); xAxis.setMinorTickVisible(false); xAxis.setPrefWidth(axes.getPrefWidth()); xAxis.prefWidthProperty().bind(axes.widthProperty()); xAxis.layoutYProperty().bind(axes.heightProperty()); yAxis.setSide(Side.LEFT); yAxis.setMinorTickVisible(false); yAxis.setPrefHeight(axes.getPrefHeight()); yAxis.prefHeightProperty().bind(axes.heightProperty()); yAxis.layoutXProperty().bind(Bindings.subtract(1, yAxis.widthProperty())); axes.getChildren().setAll(xAxis, yAxis); final Label lbl = new Label(String.format("R0=%.1f, recovery=%.1ft\nSIR(0)=%s", conf.reproduction(), conf.recovery(), Arrays.toString(pop))); lbl.setTextAlignment(TextAlignment.CENTER); lbl.setTextFill(Color.WHITE); final Path[] deterministic = { new Path(), new Path(), new Path() }; IntStream.range(0, pop.length).forEach(i -> { final Color color = Color.valueOf(colors[i]); final Path path = deterministic[i]; path.setStroke(color.deriveColor(0, 1, 1, 0.6)); path.setStrokeWidth(2); path.setClip(new Rectangle(0, 0, plot.getPrefWidth(), plot.getPrefHeight())); }); plot.getChildren().setAll(axes); // fill paths with integration estimates final double xl = xAxis.getLowerBound(), sx = plot.getPrefWidth() / (xAxis.getUpperBound() - xl), yh = plot.getPrefHeight(), sy = yh / (yAxis.getUpperBound() - yAxis.getLowerBound()); final TreeMap<Double, Integer> iDeterministic = new TreeMap<>(); MSEIRSTest.deterministic(conf, () -> new DormandPrince853Integrator(1.0E-8, 10, 1.0E-20, 1.0E-20)) .subscribe(yt -> { iDeterministic.put(yt.getKey(), deterministic[0].getElements().size()); final double[] y = yt.getValue(); final double x = (yt.getKey() - xl) * sx; for (int i = 0; i < y.length; i++) { final double yi = yh - y[i] * sy; final PathElement di = deterministic[i].getElements().isEmpty() ? new MoveTo(x, yi) : new LineTo(x, yi); deterministic[i].getElements().add(di); } }, e -> LOG.error("Problem", e), () -> plot.getChildren().addAll(deterministic)); final Path[] stochasticTau = { new Path(), new Path(), new Path() }; IntStream.range(0, pop.length).forEach(i -> { final Color color = Color.valueOf(colors[i]); final Path path = stochasticTau[i]; path.setStroke(color); path.setStrokeWidth(1); path.setClip(new Rectangle(0, 0, plot.getPrefWidth(), plot.getPrefHeight())); }); final TreeMap<Double, Integer> iStochasticTau = new TreeMap<>(); MSEIRSTest.stochasticGillespie(conf).subscribe(yt -> { final double x = (yt.getKey() - xl) * sx; iStochasticTau.put(yt.getKey(), stochasticTau[0].getElements().size()); final long[] y = yt.getValue(); for (int i = 0; i < y.length; i++) { final double yi = yh - y[i] * sy; final ObservableList<PathElement> path = stochasticTau[i].getElements(); if (path.isEmpty()) { path.add(new MoveTo(x, yi)); // first } else { final PathElement last = path.get(path.size() - 1); final double y_prev = last instanceof MoveTo ? ((MoveTo) last).getY() : ((LineTo) last).getY(); path.add(new LineTo(x, y_prev)); path.add(new LineTo(x, yi)); } } }, e -> LOG.error("Problem", e), () -> plot.getChildren().addAll(stochasticTau)); final Path[] stochasticRes = { new Path(), new Path(), new Path() }; IntStream.range(0, pop.length).forEach(i -> { final Color color = Color.valueOf(colors2[i]); final Path path = stochasticRes[i]; path.setStroke(color); path.setStrokeWidth(1); path.setClip(new Rectangle(0, 0, plot.getPrefWidth(), plot.getPrefHeight())); }); final TreeMap<Double, Integer> iStochasticRes = new TreeMap<>(); MSEIRSTest.stochasticSellke(conf).subscribe(yt -> { final double x = (yt.getKey() - xl) * sx; iStochasticRes.put(yt.getKey(), stochasticRes[0].getElements().size()); final long[] y = yt.getValue(); for (int i = 0; i < y.length; i++) { final double yi = yh - y[i] * sy; final ObservableList<PathElement> path = stochasticRes[i].getElements(); if (path.isEmpty()) { path.add(new MoveTo(x, yi)); // first } else { final PathElement last = path.get(path.size() - 1); final double y_prev = last instanceof MoveTo ? ((MoveTo) last).getY() : ((LineTo) last).getY(); path.add(new LineTo(x, y_prev)); path.add(new LineTo(x, yi)); } } }, e -> LOG.error("Problem", e), () -> plot.getChildren().addAll(stochasticRes)); // auto-scale on stage/plot resize // FIXME scaling around wrong origin, use ScatterChart? // xAxis.widthProperty() // .addListener( (ChangeListener<Number>) ( observable, // oldValue, newValue ) -> // { // final double scale = ((Double) newValue) // / plot.getPrefWidth(); // plot.getChildren().filtered( n -> n instanceof Path ) // .forEach( n -> // { // final Path path = (Path) n; // path.setScaleX( scale ); // path.setTranslateX( (path // .getBoundsInParent().getWidth() // - path.getLayoutBounds().getWidth()) // / 2 ); // } ); // } ); // plot.heightProperty() // .addListener( (ChangeListener<Number>) ( observable, // oldValue, newValue ) -> // { // final double scale = ((Double) newValue) // / plot.getPrefHeight(); // plot.getChildren().filtered( n -> n instanceof Path ) // .forEach( n -> // { // final Path path = (Path) n; // path.setScaleY( scale ); // path.setTranslateY( // (path.getBoundsInParent() // .getHeight() * (scale - 1)) // / 2 ); // } ); // } ); final StackPane layout = new StackPane(lbl, plot); layout.setAlignment(Pos.TOP_CENTER); layout.setPadding(new Insets(50)); layout.setStyle("-fx-background-color: rgb(35, 39, 50);"); final Line vertiCross = new Line(); vertiCross.setStroke(Color.SILVER); vertiCross.setStrokeWidth(1); vertiCross.setVisible(false); axes.getChildren().add(vertiCross); final Tooltip tip = new Tooltip(""); tip.setAutoHide(false); tip.hide(); axes.setOnMouseExited(ev -> tip.hide()); axes.setOnMouseMoved(ev -> { final Double x = (Double) xAxis.getValueForDisplay(ev.getX()); if (x > xAxis.getUpperBound() || x < xAxis.getLowerBound()) { tip.hide(); vertiCross.setVisible(false); return; } final Double y = (Double) yAxis.getValueForDisplay(ev.getY()); if (y > yAxis.getUpperBound() || y < yAxis.getLowerBound()) { tip.hide(); vertiCross.setVisible(false); return; } final double xs = xAxis.getDisplayPosition(x); vertiCross.setStartX(xs); vertiCross.setStartY(yAxis.getDisplayPosition(0)); vertiCross.setEndX(xs); vertiCross.setEndY(yAxis.getDisplayPosition(yAxis.getUpperBound())); vertiCross.setVisible(true); final int i = (iDeterministic.firstKey() > x ? iDeterministic.firstEntry() : iDeterministic.floorEntry(x)).getValue(); final Object[] yi = Arrays.stream(deterministic).mapToDouble(p -> getY(p, i)) .mapToObj(yAxis::getValueForDisplay).map(n -> DecimalUtil.toScale(n, 1)).toArray(); final int j = (iStochasticTau.firstKey() > x ? iStochasticTau.firstEntry() : iStochasticTau.floorEntry(x)).getValue(); final Object[] yj = Arrays.stream(stochasticTau).mapToDouble(p -> getY(p, j)) .mapToObj(yAxis::getValueForDisplay).map(n -> DecimalUtil.toScale(n, 0)).toArray(); final int k = (iStochasticRes.firstKey() > x ? iStochasticRes.firstEntry() : iStochasticRes.floorEntry(x)).getValue(); final Object[] yk = Arrays.stream(stochasticRes).mapToDouble(p -> getY(p, k)) .mapToObj(yAxis::getValueForDisplay).map(n -> DecimalUtil.toScale(n, 0)).toArray(); final String txt = String.format("SIR(t=%.1f)\n" + "~det%s\n" + "~tau%s\n" + "~res%s", x, Arrays.toString(yi), Arrays.toString(yj), Arrays.toString(yk)); tip.setText(txt); tip.show(axes, ev.getScreenX() - ev.getSceneX() + xs, ev.getScreenY() + 15); }); try { stage.getIcons().add(new Image(FileUtil.toInputStream("icon.jpg"))); } catch (final IOException e) { LOG.error("Problem", e); } stage.setTitle("Deterministic vs. Stochastic"); stage.setScene(new Scene(layout, Color.rgb(35, 39, 50))); // stage.setOnHidden( ev -> tip.hide() ); stage.show(); }
From source file:edu.kit.trufflehog.view.jung.visualization.FXVisualizationViewer.java
public FXVisualizationViewer(INetworkViewPort port) { this.port = port; // create canvas this.setStyle("-fx-background-color: #213245"); for (double divide = .25; divide < 1; divide += .25) { final Line line = new Line(0, 200, this.getWidth(), this.getHeight()); line.setFill(null);//from w ww . jav a 2 s. com line.setStroke(Color.web("0x385172")); line.setStrokeWidth(1.3); line.getStrokeDashArray().addAll(5d, 10d); line.startYProperty().bind(this.heightProperty().multiply(divide)); line.endXProperty().bind(this.widthProperty()); line.endYProperty().bind(this.heightProperty().multiply(divide)); this.getChildren().add(line); } for (double divide = .25; divide < 1; divide += .25) { final Line line = new Line(0, 0, this.getWidth(), this.getHeight()); line.setFill(null); line.setStroke(Color.web("0x385172")); line.setStrokeWidth(1.3); line.getStrokeDashArray().addAll(5d, 10d); line.startXProperty().bind(this.widthProperty().multiply(divide)); line.endXProperty().bind(this.widthProperty().multiply(divide)); line.endYProperty().bind(this.heightProperty()); this.getChildren().add(line); } //StackPane spane = new StackPane(); //spane.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); Pane ghost = new Pane(); canvas = new PannableCanvas(ghost); Pane parent = new Pane(); parent.getChildren().add(ghost); parent.getChildren().add(canvas); SceneGestures sceneGestures = new SceneGestures(parent, canvas); addEventFilter(MouseEvent.MOUSE_PRESSED, sceneGestures.getOnMousePressedEventHandler()); addEventFilter(MouseEvent.MOUSE_DRAGGED, sceneGestures.getOnMouseDraggedEventHandler()); addEventFilter(ScrollEvent.ANY, sceneGestures.getOnScrollEventHandler()); new RubberBandSelection(this); // TODO make canvas transparent //canvas.setStyle("-fx-background-color: #1d1d1d"); // we don't want the canvas on the top/left in this example => just // translate it a bit //canvas.setTranslateX(100); //canvas.setTranslateY(100); // create sample nodes which can be dragged nodeGestures = new NodeGestures(); //this.getChildren().add(spane); this.getChildren().add(parent); this.layout = port.getDelegate(); //this.layout.getGraph().getVertices().forEach(v -> Platform.runLater(() -> this.initVertex(v))); //this.layout.getGraph().getEdges().forEach(e -> Platform.runLater(() -> this.initEdge(e))); this.layout.getObservableGraph().addGraphEventListener(e -> { //Platform.runLater(() -> { switch (e.getType()) { case VERTEX_ADDED: final INode node = ((GraphEvent.Vertex<INode, IConnection>) e).getVertex(); Platform.runLater(() -> initVertex(node)); break; case EDGE_ADDED: final IConnection edge = ((GraphEvent.Edge<INode, IConnection>) e).getEdge(); Platform.runLater(() -> initEdge(edge)); break; case VERTEX_CHANGED: break; case EDGE_CHANGED: final IConnection changedEdge = ((GraphEvent.Edge<INode, IConnection>) e).getEdge(); Platform.runLater(() -> changedEdge.getComponent(ViewComponent.class).getRenderer().animate()); break; } //}); }); }
From source file:ui.ChoseFonctionnalite.java
private void initUI() { Pane root = new Pane(); root.setBackground(new Background(new BackgroundImage(new Image("resource/background.jpg"), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, new BackgroundSize(530, 400, true, true, true, true)))); JFXButton serveur = new JFXButton("SERVEUR"); serveur.setCursor(Cursor.HAND); serveur.setMinSize(171, 57);//from w w w . j a v a 2s. c o m serveur.setLayoutX(179); serveur.setLayoutY(90); serveur.setFont(new Font(27)); serveur.setStyle("-fx-background-color: #9E21FF;"); serveur.setOnAction(event -> { startServerMode(); }); JFXButton client = new JFXButton("CLIENT"); client.setCursor(Cursor.HAND); client.setMinSize(171, 57); client.setLayoutX(179); client.setLayoutY(197); client.setFont(new Font(27)); client.setStyle("-fx-background-color: #9E21FF;"); client.setOnAction(event -> { startClientMode(event); }); Label info = new Label("choisir la maniere d'utiliser virtual remote"); info.setMinSize(529, 43); info.setLayoutX(10); info.setLayoutY(14); info.setFont(new Font("Algerian", 20)); root.getChildren().add(client); root.getChildren().add(serveur); root.getChildren().add(info); Scene scene = new Scene(root, 530, 400); stage.setTitle("Fontionnalit"); stage.setScene(scene); stage.setResizable(false); stage.initStyle(StageStyle.DECORATED); stage.setOnCloseRequest(event -> { System.exit(1); }); stage.show(); }
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(() -> {/*w ww. j a v a 2s .c o 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)); 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:ui.ChoseFonctionnalite.java
private void startClientMode(ActionEvent eventT) { //File config = new File("resource/config.json"); String host = ""; String port = "8000"; Stage stageModal = new Stage(); Pane root = new Pane(); root.setBackground(new Background(new BackgroundImage(new Image("resource/background.jpg"), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, new BackgroundSize(530, 400, true, true, true, true)))); stageModal.setScene(new Scene(root, 200, 200)); stageModal.initStyle(StageStyle.UTILITY); Label adresse = new Label("Adresse serveur:"); adresse.setLayoutX(10);/*from ww w . java 2 s .co m*/ adresse.setLayoutY(10); adresse.setFont(Font.font("Arial", 16)); JFXTextField adresseInput = new JFXTextField("127.0.0.1"); adresseInput.setPrefWidth(180); adresseInput.setLayoutX(10); adresseInput.setLayoutY(40); JFXButton valider = new JFXButton("Se connecter"); valider.setCursor(Cursor.HAND); valider.setMinSize(100, 30); valider.setLayoutX(20); valider.setLayoutY(130); valider.setFont(new Font(20)); valider.setStyle("-fx-background-color: #9E21FF;"); valider.setOnAction(event -> { if (adresseInput.getText() != "") { stageModal.close(); InitClient initializeClient = new InitClient(stage, adresseInput.getText(), port); } }); root.getChildren().add(valider); root.getChildren().add(adresse); root.getChildren().add(adresseInput); stageModal.setTitle("Adresse serveur"); stageModal.initModality(Modality.WINDOW_MODAL); stageModal.initOwner(((Node) eventT.getSource()).getScene().getWindow()); stageModal.show(); }
From source file:de.micromata.mgc.javafx.launcher.gui.AbstractConfigDialog.java
private Tab createTab(LocalSettingsConfigModel configModel, Pair<Pane, ? extends AbstractConfigTabController<?>> wc) { AbstractConfigTabController<?> contrl = wc.getSecond(); contrl.setConfigDialog(this); Pane tabPane = wc.getFirst(); contrl.setTabPane(tabPane);/*from ww w.j a v a2 s .c o m*/ Tab tabB = new Tab(); AnchorPane tabContentPane = new AnchorPane(); tabContentPane.setMaxHeight(Integer.MAX_VALUE); // tabContentPane.setPrefHeight(500); FeedbackPanel feedback = new FeedbackPanel(); feedback.setPrefHeight(100); feedback.setMinHeight(100); FXEvents.get().addEventHandler(this, feedback, FeedbackPanelEvents.CLEAR, event -> { feedback.clearMessages(); }); contrl.setFeedback(feedback); tabContentPane.getChildren().add(tabPane); tabContentPane.getChildren().add(feedback); AnchorPane.setTopAnchor(tabPane, 2.0); AnchorPane.setRightAnchor(tabPane, 0.0); AnchorPane.setLeftAnchor(tabPane, 0.0); AnchorPane.setBottomAnchor(tabPane, 70.0); AnchorPane.setBottomAnchor(feedback, 0.0); tabB.setContent(tabContentPane); AnchorPane.setTopAnchor(tabContentPane, 0.0); AnchorPane.setRightAnchor(tabContentPane, 0.0); AnchorPane.setLeftAnchor(tabContentPane, 0.0); AnchorPane.setBottomAnchor(tabContentPane, 0.0); Node scrollPane = tabPane.getChildren().get(0); AnchorPane.setTopAnchor(scrollPane, 0.0); AnchorPane.setRightAnchor(scrollPane, 0.0); AnchorPane.setLeftAnchor(scrollPane, 0.0); AnchorPane.setBottomAnchor(scrollPane, 0.0); configurationTabs.getTabs().add(tabB); tabController.add(contrl); contrl.setTab(tabB); ((ModelController) contrl).setModel(configModel); contrl.initializeWithModel(); contrl.addToolTips(); tabB.setText(contrl.getTabTitle()); contrl.registerValMessageReceivers(); return tabB; }