List of usage examples for javafx.scene.layout Pane Pane
public Pane()
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(() -> {// ww w.j av a2 s .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:be.makercafe.apps.makerbench.editors.JFXMillEditor.java
public JFXMillEditor(String tabText, Path path) { super(tabText); this.viewGroup = new Group(); this.editorContainer = new BorderPane(); this.viewContainer = new Pane(); this.caCodeArea = new CodeArea(""); this.caCodeArea.setEditable(true); this.caCodeArea.setParagraphGraphicFactory(LineNumberFactory.get(caCodeArea)); this.caCodeArea.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE); this.caCodeArea.getStylesheets().add(this.getClass().getResource("java-keywords.css").toExternalForm()); this.caCodeArea.richChanges().subscribe(change -> { caCodeArea.setStyleSpans(0, computeHighlighting(caCodeArea.getText())); });//w w w . jav a 2s . co m addContextMenu(this.caCodeArea); EventStream<Change<String>> textEvents = EventStreams.changesOf(caCodeArea.textProperty()); textEvents.reduceSuccessions((a, b) -> b, Duration.ofMillis(3000)).subscribe(code -> { if (autoCompile) { compile(code.getNewValue()); } }); try { this.caCodeArea.replaceText(FileUtils.readFileToString(path.toFile())); } catch (IOException ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error reading file.", ex); } SplitPane editorPane = new SplitPane(caCodeArea, viewContainer); editorPane.setOrientation(Orientation.HORIZONTAL); BorderPane rootPane = new BorderPane(); toolBar = createToolBar(); rootPane.setTop(toolBar); rootPane.setCenter(editorPane); this.getTab().setContent(rootPane); }
From source file:be.makercafe.apps.makerbench.editors.JFXScadEditor.java
public JFXScadEditor(String tabText, Path path) { super(tabText); this.viewGroup = new Group(); this.editorContainer = new BorderPane(); this.viewContainer = new Pane(); this.caCodeArea = new CodeArea(""); this.caCodeArea.setEditable(true); this.caCodeArea.setParagraphGraphicFactory(LineNumberFactory.get(caCodeArea)); this.caCodeArea.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE); this.caCodeArea.getStylesheets().add(this.getClass().getResource("java-keywords.css").toExternalForm()); this.caCodeArea.richChanges().subscribe(change -> { caCodeArea.setStyleSpans(0, computeHighlighting(caCodeArea.getText())); });/*from w w w . jav a2 s . c om*/ addContextMenu(this.caCodeArea); EventStream<Change<String>> textEvents = EventStreams.changesOf(caCodeArea.textProperty()); textEvents.reduceSuccessions((a, b) -> b, Duration.ofMillis(3000)).subscribe(code -> { if (autoCompile) { compile(code.getNewValue()); } }); if (path == null) { this.caCodeArea.replaceText("CSG cube = new Cube(2).toCSG()\n" + "CSG sphere = new Sphere(1.25).toCSG()\n" + "\n" + "cube.difference(sphere)"); } else { try { this.caCodeArea.replaceText(FileUtils.readFileToString(path.toFile())); } catch (IOException ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error reading file.", ex); } } //editorContainer.setCenter(this.codeArea); subScene = new SubScene(viewGroup, 100, 100, true, SceneAntialiasing.BALANCED); subScene.widthProperty().bind(viewContainer.widthProperty()); subScene.heightProperty().bind(viewContainer.heightProperty()); PerspectiveCamera subSceneCamera = new PerspectiveCamera(false); subScene.setCamera(subSceneCamera); viewContainer.getChildren().add(subScene); SplitPane editorPane = new SplitPane(caCodeArea, viewContainer); editorPane.setOrientation(Orientation.HORIZONTAL); BorderPane rootPane = new BorderPane(); BorderPane pane = (BorderPane) this.getTab().getContent(); toolBar = createToolBar(); rootPane.setTop(toolBar); rootPane.setCenter(editorPane); this.getTab().setContent(rootPane); subScene.setOnScroll(new EventHandler<ScrollEvent>() { @Override public void handle(ScrollEvent event) { System.out .println(String.format("deltaX: %.3f deltaY: %.3f", event.getDeltaX(), event.getDeltaY())); double z = subSceneCamera.getTranslateZ(); double newZ = z + event.getDeltaY(); subSceneCamera.setTranslateZ(newZ); } }); }
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
public GCodeEditor(String tabText, Path path) { super(tabText); this.viewGroup = new Group(); this.editorContainer = new BorderPane(); this.viewContainer = new Pane(); this.caCodeArea = new CodeArea(""); this.caCodeArea.setEditable(true); this.caCodeArea.setParagraphGraphicFactory(LineNumberFactory.get(caCodeArea)); this.caCodeArea.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE); // this.caCodeArea.getStylesheets().add(this.getClass().getResource("java-keywords.css").toExternalForm()); // this.caCodeArea.richChanges().subscribe(change -> { // caCodeArea.setStyleSpans(0, // computeHighlighting(caCodeArea.getText())); // });//w w w . j a v a 2 s .co m addContextMenu(this.caCodeArea); EventStream<Change<String>> textEvents = EventStreams.changesOf(caCodeArea.textProperty()); textEvents.reduceSuccessions((a, b) -> b, Duration.ofMillis(3000)).subscribe(code -> { if (autoCompile) { compile(code.getNewValue()); } }); if (path == null) { this.caCodeArea.replaceText("#empty"); } else { try { this.caCodeArea.replaceText(FileUtils.readFileToString(path.toFile())); } catch (IOException ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error reading file.", ex); } } // editorContainer.setCenter(this.codeArea); subScene = new SubScene(viewGroup, 100, 100, true, SceneAntialiasing.BALANCED); subScene.widthProperty().bind(viewContainer.widthProperty()); subScene.heightProperty().bind(viewContainer.heightProperty()); PerspectiveCamera subSceneCamera = new PerspectiveCamera(false); subScene.setCamera(subSceneCamera); viewContainer.getChildren().add(subScene); SplitPane editorPane = new SplitPane(caCodeArea, viewContainer); editorPane.setOrientation(Orientation.HORIZONTAL); BorderPane rootPane = new BorderPane(); BorderPane pane = (BorderPane) this.getTab().getContent(); toolBar = createToolBar(); rootPane.setTop(toolBar); rootPane.setCenter(editorPane); this.getTab().setContent(rootPane); subScene.setOnScroll(new EventHandler<ScrollEvent>() { @Override public void handle(ScrollEvent event) { System.out .println(String.format("deltaX: %.3f deltaY: %.3f", event.getDeltaX(), event.getDeltaY())); double z = subSceneCamera.getTranslateZ(); double newZ = z + event.getDeltaY(); subSceneCamera.setTranslateZ(newZ); } }); }
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 ww w . jav a2 s. c om*/ 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:Main.java
@Override public void start(Stage stage) { BorderPane root = new BorderPane(); Pane parentContainer = new Pane(); parentContainer.setPrefSize(500, 500); parentContainer.setPickOnBounds(false); //Pane parent = new Pane(); Group parent = new Group(); boundsLayoutNode = parent;/*from w w w . j ava 2 s . c o m*/ //parent.setPrefSize(300, 200); parent.setLayoutX(200); parent.setLayoutY(200); parent.setStyle("-fx-background-color:white;"); parent.getChildren().addAll(new Group(localXAxisGroup, localYAxisGroup), new Group(parentXAxisGroup, parentYAxisGroup), new Group(parentBoundsRect, PARENT_BOUNDS_PATH_CIRCLE), new Group(localBoundsRect, LOCAL_BOUNDS_PATH_CIRCLE), new Group(layoutBoundsRect, LAYOUT_BOUNDS_PATH_CIRCLE), new Group(mainRect)); parentContainer.getChildren().addAll(parent); VBox transformsControls = getTransformationControls(); VBox resultsControls = getResultsControls(); BorderPane nestedPane = new BorderPane(); nestedPane.setCenter(parentContainer); nestedPane.setBottom(resultsControls); //nestedPane.setTop(printDataTextArea); //printDataTextArea.setPrefColumnCount(40); //printDataTextArea.setPrefRowCount(3); root.setCenter(nestedPane); root.setRight(transformsControls); //root.setBottom(resultsControls); //root.setCenter(parentContainer); // Attach event handlers attachEventHandlers(); Scene scene = new Scene(root); //, 600, 400); stage.setScene(scene); stage.setTitle("Bounds of a Node"); Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds(); stage.setX(visualBounds.getMinX()); stage.setY(visualBounds.getMinY()); stage.setWidth(visualBounds.getWidth()); stage.setHeight(visualBounds.getHeight()); stage.show(); // Make sure everything is in sync relayout(); }
From source file:org.mskcc.shenkers.view.IntervalViewNGTest.java
public Node get(RangeSet<Integer> intervals, int start, int end) { RangeSet<Integer> view = intervals.subRangeSet(Range.closed(start, end)); double l = end - start + 1.; Pane p = new Pane(); for (Range<Integer> interval : view.asRanges()) { Rectangle r = new Rectangle(); r.widthProperty().bind(/*from w w w .ja va2 s. c om*/ p.widthProperty().multiply(interval.upperEndpoint() - interval.lowerEndpoint() + 1).divide(l)); r.heightProperty().bind(p.heightProperty()); r.xProperty().bind(p.widthProperty().multiply(interval.lowerEndpoint()).divide(l)); // System.out.println(r); p.getChildren().add(r); } return p; }
From source file:jp.co.heppokoact.autocapture.FXMLDocumentController.java
/** * ???????????//from w w w .ja v a 2 s . c om * ???????? * ???ESC???????? * * @return ??????? * @throws IOException ????? */ private Stage createTransparentStage() throws IOException { // ?????????? Stage transparentStage = new Stage(StageStyle.TRANSPARENT); transparentStage.initOwner(anchorPane.getScene().getWindow()); transparentStage.initModality(Modality.APPLICATION_MODAL); transparentStage.setResizable(false); Rectangle2D rect = Screen.getPrimary().getVisualBounds(); transparentStage.setWidth(rect.getWidth()); transparentStage.setHeight(rect.getHeight()); // ??? java.awt.Rectangle awtRect = new java.awt.Rectangle((int) rect.getWidth(), (int) rect.getHeight()); BufferedImage captureImage = robot.createScreenCapture(awtRect); // ?????? ByteArrayInputStream in = ImageUtil.convToInputStream(captureImage); BackgroundImage bgImage = new BackgroundImage(new Image(in), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT); Pane pane = new Pane(); pane.setBackground(new Background(bgImage)); pane.setStyle("-fx-border-color: rgba(255, 255, 0, 0.5); -fx-border-style: solid; -fx-border-width: 15;"); // ???ESC????? Scene scene = new Scene(pane); transparentStage.setScene(scene); scene.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ESCAPE) { transparentStage.close(); } }); return transparentStage; }
From source file:editeurpanovisu.EquiCubeDialogController.java
/** * * @param strTypeTransf/*from w w w . j a v a2 s. c o m*/ * @throws Exception Exceptions */ public void afficheFenetre(String strTypeTransf) throws Exception { lvListeFichier.getItems().clear(); stTransformations = new Stage(StageStyle.UTILITY); apTransformations = new AnchorPane(); stTransformations.initModality(Modality.APPLICATION_MODAL); stTransformations.setResizable(true); apTransformations.setStyle("-fx-background-color : #ff0000;"); VBox vbFenetre = new VBox(); HBox hbChoix = new HBox(); Pane paneChoixFichier = new Pane(); btnAjouteFichiers = new Button("Ajouter des Fichiers"); paneChoixTypeFichier = new Pane(); Label lblType = new Label("Type des Fichiers de sortie"); rbJpeg = new RadioButton("JPEG (.jpg)"); rbBmp = new RadioButton("BMP (.bmp)"); rbTiff = new RadioButton("TIFF (.tif)"); cbSharpen = new CheckBox("Masque de nettet"); cbSharpen.setSelected(EditeurPanovisu.isbNetteteTransf()); slSharpen = new Slider(0, 2, EditeurPanovisu.getNiveauNetteteTransf()); lblSharpen = new Label(); double lbl = (Math.round(EditeurPanovisu.getNiveauNetteteTransf() * 20.d) / 20.d); lblSharpen.setText(lbl + ""); slSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf()); lblSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf()); Pane paneboutons = new Pane(); btnAnnuler = new Button("Fermer la fentre"); btnValider = new Button("Lancer le traitement"); strTypeTransformation = strTypeTransf; Image imgTransf; if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) { stTransformations.setTitle("Transformation d'quirectangulaire en faces de cube"); imgTransf = new Image( "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/equi2cube.png"); } else { stTransformations.setTitle("Transformation de faces de cube en quirectangulaire"); imgTransf = new Image( "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/cube2equi.png"); } ImageView ivTypeTransfert = new ImageView(imgTransf); ivTypeTransfert.setLayoutX(35); ivTypeTransfert.setLayoutY(280); paneChoixTypeFichier.getChildren().add(ivTypeTransfert); apTransformations.setPrefHeight(EditeurPanovisu.getHauteurE2C()); apTransformations.setPrefWidth(EditeurPanovisu.getLargeurE2C()); paneChoixFichier.setPrefHeight(350); paneChoixFichier.setPrefWidth(410); paneChoixFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;"); paneChoixTypeFichier.setPrefHeight(350); paneChoixTypeFichier.setPrefWidth(180); paneChoixTypeFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;"); hbChoix.getChildren().addAll(paneChoixFichier, paneChoixTypeFichier); vbFenetre.setPrefHeight(400); vbFenetre.setPrefWidth(600); apTransformations.getChildren().add(vbFenetre); hbChoix.setPrefHeight(350); hbChoix.setPrefWidth(600); hbChoix.setStyle("-fx-background-color: #d0d0d0;"); paneboutons.setPrefHeight(50); paneboutons.setPrefWidth(600); paneboutons.setStyle("-fx-background-color: #d0d0d0;"); vbFenetre.setStyle("-fx-background-color: #d0d0d0;"); btnAnnuler.setLayoutX(296); btnAnnuler.setLayoutY(10); btnValider.setLayoutX(433); btnValider.setLayoutY(10); lvListeFichier.setPrefHeight(290); lvListeFichier.setPrefWidth(380); lvListeFichier.setEditable(true); lvListeFichier.setLayoutX(14); lvListeFichier.setLayoutY(14); btnAjouteFichiers.setLayoutX(259); btnAjouteFichiers.setLayoutY(319); paneChoixFichier.getChildren().addAll(lvListeFichier, btnAjouteFichiers); if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) { lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropE2C")); } else { lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropC2E")); } lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight()); lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight()); lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth()); lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth()); lblDragDropE2C.setLayoutX(14); lblDragDropE2C.setLayoutY(14); lblDragDropE2C.setAlignment(Pos.CENTER); lblDragDropE2C.setTextFill(Color.web("#c9c7c7")); lblDragDropE2C.setTextAlignment(TextAlignment.CENTER); lblDragDropE2C.setWrapText(true); lblDragDropE2C.setStyle("-fx-font-size : 24px"); lblDragDropE2C.setStyle("-fx-background-color : rgba(128,128,128,0.1)"); paneChoixFichier.getChildren().add(lblDragDropE2C); lblType.setLayoutX(14); lblType.setLayoutY(14); rbBmp.setLayoutX(43); rbBmp.setLayoutY(43); rbBmp.setUserData("bmp"); if (EditeurPanovisu.getStrTypeFichierTransf().equals("bmp")) { rbBmp.setSelected(true); } rbBmp.setToggleGroup(tgTypeFichier); rbJpeg.setLayoutX(43); rbJpeg.setLayoutY(71); rbJpeg.setUserData("jpg"); if (EditeurPanovisu.getStrTypeFichierTransf().equals("jpg")) { rbJpeg.setSelected(true); } rbJpeg.setToggleGroup(tgTypeFichier); if (EditeurPanovisu.getStrTypeFichierTransf().equals("tif")) { rbTiff.setSelected(true); } rbTiff.setLayoutX(43); rbTiff.setLayoutY(99); rbTiff.setToggleGroup(tgTypeFichier); rbTiff.setUserData("tif"); tgTypeFichier.selectedToggleProperty().addListener((ov, old_toggle, new_toggle) -> { EditeurPanovisu.setStrTypeFichierTransf(tgTypeFichier.getSelectedToggle().getUserData().toString()); }); cbSharpen.setLayoutX(43); cbSharpen.setLayoutY(127); cbSharpen.selectedProperty().addListener((ov, old_val, new_val) -> { slSharpen.setDisable(!new_val); lblSharpen.setDisable(!new_val); EditeurPanovisu.setbNetteteTransf(new_val); }); slSharpen.setShowTickMarks(true); slSharpen.setShowTickLabels(true); slSharpen.setMajorTickUnit(0.5f); slSharpen.setMinorTickCount(4); slSharpen.setBlockIncrement(0.05f); slSharpen.setSnapToTicks(true); slSharpen.setLayoutX(23); slSharpen.setLayoutY(157); slSharpen.setTooltip(new Tooltip("Choisissez le niveau d'accentuation de l'image")); slSharpen.valueProperty().addListener((observableValue, oldValue, newValue) -> { if (newValue == null) { lblSharpen.setText(""); return; } DecimalFormat dfArrondi = new DecimalFormat(); dfArrondi.setMaximumFractionDigits(2); //arrondi 2 chiffres apres la virgules dfArrondi.setMinimumFractionDigits(2); dfArrondi.setDecimalSeparatorAlwaysShown(true); lblSharpen.setText(dfArrondi.format(Math.round(newValue.floatValue() * 20.f) / 20.f) + ""); EditeurPanovisu.setNiveauNetteteTransf(newValue.doubleValue()); }); slSharpen.setPrefWidth(120); lblSharpen.setLayoutX(150); lblSharpen.setLayoutY(150); lblSharpen.setMinWidth(30); lblSharpen.setMaxWidth(30); lblSharpen.setTextAlignment(TextAlignment.RIGHT); paneChoixTypeFichier.getChildren().addAll(lblType, rbBmp, rbJpeg, rbTiff, cbSharpen, slSharpen, lblSharpen); pbBarreImage.setLayoutX(40); pbBarreImage.setLayoutY(190); pbBarreImage.setStyle("-fx-accent : #0000bb"); pbBarreImage.setVisible(false); paneChoixTypeFichier.getChildren().add(pbBarreImage); pbBarreAvancement = new ProgressBar(); pbBarreAvancement.setLayoutX(40); pbBarreAvancement.setLayoutY(220); pbBarreImage.setStyle("-fx-accent : #00bb00"); paneChoixTypeFichier.getChildren().add(pbBarreAvancement); pbBarreAvancement.setVisible(false); paneboutons.getChildren().addAll(btnAnnuler, btnValider); vbFenetre.getChildren().addAll(hbChoix, paneboutons); Scene scnTransformations = new Scene(apTransformations); stTransformations.setScene(scnTransformations); stTransformations.show(); btnAnnuler.setOnAction((e) -> { annulerE2C(); }); btnValider.setOnAction((e) -> { if (!bTraitementEffectue) { validerE2C(); } }); btnAjouteFichiers.setOnAction((e) -> { lblTermine.setText(""); fileLstFichier = choixFichiers(); if (fileLstFichier != null) { if (bTraitementEffectue) { lvListeFichier.getItems().clear(); bTraitementEffectue = false; } for (File fileLstFichier1 : fileLstFichier) { String strNomFich = fileLstFichier1.getAbsolutePath(); lvListeFichier.getItems().add(strNomFich); } } }); lvListeFichier.setCellFactory(new Callback<ListView<String>, ListCell<String>>() { @Override public ListCell<String> call(ListView<String> list) { return new ListeTransformationCouleur(); } }); apTransformations.setOnDragOver((event) -> { Dragboard dbFichiersTransformation = event.getDragboard(); if (dbFichiersTransformation.hasFiles()) { event.acceptTransferModes(TransferMode.ANY); } else { event.consume(); } }); stTransformations.widthProperty().addListener((arg0, arg1, arg2) -> { EditeurPanovisu.setLargeurE2C(stTransformations.getWidth()); apTransformations.setPrefWidth(stTransformations.getWidth()); vbFenetre.setPrefWidth(stTransformations.getWidth()); btnAnnuler.setLayoutX(stTransformations.getWidth() - 314); btnValider.setLayoutX(stTransformations.getWidth() - 157); paneChoixFichier.setPrefWidth(stTransformations.getWidth() - 200); lvListeFichier.setPrefWidth(stTransformations.getWidth() - 240); lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth()); lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth()); btnAjouteFichiers.setLayoutX(stTransformations.getWidth() - 341); }); stTransformations.heightProperty().addListener((arg0, arg1, arg2) -> { EditeurPanovisu.setHauteurE2C(stTransformations.getHeight()); apTransformations.setPrefHeight(stTransformations.getHeight()); vbFenetre.setPrefHeight(stTransformations.getHeight()); paneChoixFichier.setPrefHeight(stTransformations.getHeight() - 80); hbChoix.setPrefHeight(stTransformations.getHeight() - 80); lvListeFichier.setPrefHeight(stTransformations.getHeight() - 140); lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight()); lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight()); btnAjouteFichiers.setLayoutY(stTransformations.getHeight() - 121); }); stTransformations.setWidth(EditeurPanovisu.getLargeurE2C()); stTransformations.setHeight(EditeurPanovisu.getHauteurE2C()); apTransformations.setOnDragDropped((event) -> { Dragboard dbFichiersTransformation = event.getDragboard(); boolean bSucces = false; File[] fileLstFich; fileLstFich = null; if (dbFichiersTransformation.hasFiles()) { lblTermine.setText(""); bSucces = true; String[] stringFichiersPath = new String[200]; int i = 0; for (File file1 : dbFichiersTransformation.getFiles()) { stringFichiersPath[i] = file1.getAbsolutePath(); i++; } int iNb = i; i = 0; boolean bAttention = false; File[] fileLstFich1 = new File[stringFichiersPath.length]; for (int j = 0; j < iNb; j++) { String strNomfich = stringFichiersPath[j]; File fileTransf = new File(strNomfich); String strExtension = strNomfich.substring(strNomfich.lastIndexOf(".") + 1, strNomfich.length()) .toLowerCase(); if (strExtension.equals("bmp") || strExtension.equals("jpg") || strExtension.equals("tif")) { if (i == 0) { strRepertFichier = fileTransf.getParent(); } Image img = null; if (strExtension != "tif") { img = new Image("file:" + fileTransf.getAbsolutePath()); } else { try { img = ReadWriteImage.readTiff(strNomfich); } catch (ImageReadException ex) { Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null, ex); } } if (strTypeTransformation.equals(EquiCubeDialogController.EQUI2CUBE)) { if (img.getWidth() == 2 * img.getHeight()) { fileLstFich1[i] = fileTransf; i++; } else { bAttention = true; } } else { if (img.getWidth() == img.getHeight()) { String strNom = fileTransf.getAbsolutePath().substring(0, fileTransf.getAbsolutePath().length() - 6); boolean bTrouve = false; for (int ik = 0; ik < i; ik++) { String strNom1 = fileLstFich1[ik].getAbsolutePath().substring(0, fileTransf.getAbsolutePath().length() - 6); if (strNom.equals(strNom1)) { bTrouve = true; } } if (!bTrouve) { fileLstFich1[i] = fileTransf; i++; } } else { bAttention = true; } } } } if (bAttention) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle(rbLocalisation.getString("transformation.traiteImages")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("transformation.traiteImagesType")); alert.showAndWait(); } fileLstFichier = new File[i]; System.arraycopy(fileLstFich1, 0, fileLstFichier, 0, i); } if (fileLstFichier != null) { if (bTraitementEffectue) { lvListeFichier.getItems().clear(); bTraitementEffectue = false; } for (File lstFichier1 : fileLstFichier) { String nomFich = lstFichier1.getAbsolutePath(); lvListeFichier.getItems().add(nomFich); } } lblDragDropE2C.setVisible(false); event.setDropCompleted(bSucces); event.consume(); }); }
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void addCloseButton() { closeButton = new Button(closeButtonText == null ? "Close" : closeButtonText); closeButton.setOnAction(event -> doClose()); if (actionHandlerOptional.isPresent() || actionButtonText != null) { actionButton = new Button(actionButtonText == null ? "Ok" : actionButtonText); actionButton.setDefaultButton(true); //TODO app wide focus //actionButton.requestFocus(); actionButton.setOnAction(event -> { hide();// ww w . j a v a 2 s . co m actionHandlerOptional.ifPresent(Runnable::run); }); Pane spacer = new Pane(); HBox hBox = new HBox(); hBox.setSpacing(10); hBox.getChildren().addAll(spacer, closeButton, actionButton); HBox.setHgrow(spacer, Priority.ALWAYS); GridPane.setHalignment(hBox, HPos.RIGHT); GridPane.setRowIndex(hBox, ++rowIndex); GridPane.setColumnSpan(hBox, 2); GridPane.setMargin(hBox, new Insets(buttonDistance, 0, 0, 0)); gridPane.getChildren().add(hBox); } else if (!hideCloseButton) { closeButton.setDefaultButton(true); GridPane.setHalignment(closeButton, HPos.RIGHT); if (!showReportErrorButtons) GridPane.setMargin(closeButton, new Insets(buttonDistance, 0, 0, 0)); GridPane.setRowIndex(closeButton, ++rowIndex); GridPane.setColumnIndex(closeButton, 1); gridPane.getChildren().add(closeButton); } }