List of usage examples for javafx.scene.control Button setPrefSize
public void setPrefSize(double prefWidth, double prefHeight)
From source file:Main.java
@Override public void start(Stage primaryStage) { FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL, 20, 20); flowPane.setPrefWrapLength(210);/* www . ja v a 2 s . c om*/ Button btn = new Button(); for (int i = 0; i < 8; i++) { btn = new Button("Button"); btn.setPrefSize(100, 50); flowPane.getChildren().add(btn); } System.out.println(flowPane.getAlignment()); Scene scene = new Scene(flowPane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL, 20, 20); flowPane.setPrefWrapLength(210);/*from www .j a va 2 s . c om*/ Button btn = new Button(); for (int i = 0; i < 8; i++) { btn = new Button("Button"); btn.setPrefSize(100, 50); flowPane.getChildren().add(btn); } System.out.println(flowPane.getRowValignment()); Scene scene = new Scene(flowPane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL, 20, 20); flowPane.setPrefWrapLength(210);//from www . j a va 2 s. co m Button btn = new Button(); for (int i = 0; i < 8; i++) { btn = new Button("Button"); btn.setPrefSize(100, 50); flowPane.getChildren().add(btn); } System.out.println(flowPane.getContentBias()); Scene scene = new Scene(flowPane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("FlowPane example"); FlowPane flowPane = new FlowPane(); flowPane.setPadding(new Insets(10, 10, 10, 10)); flowPane.setVgap(4);/*from www.ja va 2 s. co m*/ flowPane.setHgap(4); flowPane.setPrefWrapLength(210); Button btn = new Button(); for (int i = 0; i < 8; i++) { btn = new Button("Button"); btn.setPrefSize(100, 50); flowPane.getChildren().add(btn); } Scene scene = new Scene(flowPane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
private HBox addHBox() { HBox hbox = new HBox(); hbox.setPadding(new Insets(15, 12, 15, 12)); hbox.setSpacing(10); // Gap between nodes hbox.setStyle("-fx-background-color: #336699;"); Button buttonCurrent = new Button("Current"); buttonCurrent.setPrefSize(100, 20); Button buttonProjected = new Button("Projected"); buttonProjected.setPrefSize(100, 20); hbox.getChildren().addAll(buttonCurrent, buttonProjected); return hbox;/*w w w. j a va 2 s . c o m*/ }
From source file:statos2_0.MainA.java
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle(nameseller + "[" + storename + "]"); primaryStage.show();//from w ww. j a v a 2 s.c o m primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { public void handle(WindowEvent we) { updsel(m, 1); } }); GridPane grid = new GridPane(); grid.setHgap(14); grid.setVgap(14); grid.setPadding(new Insets(5, 5, 5, 5)); //System.out.println("****"+m); txg3.setVisible(false); // , 1 sp1.setValueFactory(spfd); spb1.setValueFactory(sfi); sp2.setValueFactory(sfi2); sp3.setValueFactory(sfi3); p1.setId("firstlab"); p2.setId("firstlab"); p3.setId("firstlab"); kasnbn.setId("secondlab"); kasvnbn.setId("secondlab"); sumnbn.setId("secondlab"); vyr.setId("vyr"); sumvnbn.setId("secondlab"); JSONParser jP5 = new JSONParser(); JSONObject jsons5 = new JSONObject(); List<NameValuePair> para5 = new ArrayList<NameValuePair>(); para5.add(new BasicNameValuePair("idm", String.valueOf(m))); jsons5 = jP5.makeHttpRequest(url_cashgetm, "POST", para5); int success = jsons5.getInt("success"); if (!jsons5.isNull("success")) { //res=true; // System.out.println("TRUE"); double all = jsons5.getDouble("all"); double dayall = Double.parseDouble(jsons5.get("dayall").toString()); double daybn = Double.parseDouble(jsons5.get("daybn").toString()); days = dayall + daybn; if (days <= 7999 & days > 0) { smvyr += (days / 100) * 3; } else if (days > 7999) { smvyr += (days / 100) * 4; } vyr.setText(":" + smvyr); sumnbn.setText(all + " ."); sumvnbn.setText(dayall + " / " + daybn); } litg.setText(":"); {// sp1.setVisible(false); spb1.setVisible(false); lb1.setVisible(false); t1.setVisible(false); bt1.setVisible(false); lbb1.setVisible(false); cbx4.setVisible(false); } {// , sp2.setVisible(false); lb2.setVisible(false); t2.setVisible(false); bt2.setVisible(false); } {// sp3.setVisible(false); lb3.setVisible(false); t3.setVisible(false); bt3.setVisible(false); } res.editableProperty().setValue(Boolean.FALSE); t1.editableProperty().setValue(Boolean.FALSE); t2.editableProperty().setValue(Boolean.FALSE); t3.editableProperty().setValue(Boolean.FALSE); titg.editableProperty().setValue(Boolean.FALSE); //cbx1.setItems(GetByTag(TAG_NAME, "1")); //cbx2.setItems(GetByTag(TAG_NAME, "2")); //cbx3.setItems(GetByTag(TAG_NAME, "3")); //cbx4.setItems(GetByTag(TAG_NAME, "4")); //cbx1.valueProperty().addListener(new ); cbx1.setId("comboprod"); cbx2.setId("comboprod"); cbx3.setId("comboprod"); txg3.setPrefSize(70, 80); sp1.setPrefSize(75, 80); sp2.setPrefSize(75, 80); sp3.setPrefSize(75, 80); spb1.setPrefSize(75, 80); lb1.setId("labl"); lb2.setId("labl"); lb3.setId("labl"); lbb1.setId("labl"); t1.setId("textost"); t2.setId("textost"); t3.setId("textost"); bt1.setId("btitg"); bt2.setId("btitg"); bt3.setId("btitg"); cbx4.setId("combbot"); //lb1.setPrefSize(25, 40); //lb2.setPrefSize(25, 40); //lb3.setPrefSize(25, 40); //t1.setPrefSize(150, 40); //t2.setPrefSize(150, 40); //t3.setPrefSize(150, 40); //cbx4.setPrefSize(160,40); //bt2.setPrefSize(40, 40); //bt3.setPrefSize(40, 40); //spb1.setPrefSize(80, 40); //lbb1.setPrefSize(40,40); //bt1.setPrefSize(40, 40); titg.setPrefSize(120, 80); litg.setId("itgl"); res.setPrefSize(300, 300); lb1.setText(""); lb2.setText(""); lb3.setText(""); bt1.setText("+"); bt2.setText("+"); bt3.setText("+"); lbb1.setText(""); bres.setText(""); bitg.setText(""); bdlg.setText(""); bbn.setText("/"); //sp1.setValueFactory(); grid.add(p1, 0, 0); grid.add(p2, 0, 1); grid.add(p3, 0, 2); grid.add(cbx1, 1, 0); grid.add(cbx2, 1, 1); grid.add(cbx3, 1, 2); grid.add(sp1, 2, 0); grid.add(sp2, 2, 1); grid.add(sp3, 2, 2); grid.add(txg3, 2, 2); grid.add(lb1, 3, 0); grid.add(lb2, 3, 1); grid.add(lb3, 3, 2); grid.add(t1, 4, 0); grid.add(t2, 4, 1); grid.add(t3, 4, 2); grid.add(cbx4, 5, 0); grid.add(bt2, 5, 1); grid.add(bt3, 5, 2); grid.add(spb1, 6, 0); grid.add(lbb1, 7, 0); grid.add(bt1, 8, 0); //grid.add(res, 1, 4, 3, 3); grid.add(res, 0, 3, 2, 3); litg.setAlignment(Pos.BASELINE_RIGHT); grid.add(litg, 2, 3); grid.add(titg, 3, 3, 2, 1); grid.add(bitg, 2, 4); grid.add(btcl, 4, 4); grid.add(kasnbn, 10, 0); grid.add(sumnbn, 10, 1); grid.add(kasvnbn, 10, 2); grid.add(sumvnbn, 10, 3); grid.add(vyr, 10, 4); grid.add(close, 10, 8); close.setOnAction(event -> { /** Dialog<Void> dialog = new Dialog<>(); dialog.initModality(Modality.WINDOW_MODAL); dialog.initOwner(primaryStage);//stage here is the stage of your webview //dialog.initStyle(StageStyle.TRANSPARENT); Label loader = new Label("LOADING"); //loader.setContentDisplay(ContentDisplay.DOWN); loader.setGraphic(new ProgressIndicator()); dialog.getDialogPane().setGraphic(loader); DropShadow ds = new DropShadow(); ds.setOffsetX(1.3); ds.setOffsetY(1.3); ds.setColor(Color.DARKGRAY); dialog.getDialogPane().setEffect(ds); //ButtonType btn = new ButtonType("OK",ButtonData.CANCEL_CLOSE); //dialog.getDialogPane().getButtonTypes().add(btn); dialog.show(); runJsons(); dialog.hide(); dialog.close(); **/ Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(""); alert.setHeaderText(" "); alert.setContentText(" ?"); ButtonType buttonTypeOne = new ButtonType(""); ButtonType buttonTypeCancel = new ButtonType("", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel); Optional<ButtonType> result2 = alert.showAndWait(); if (result2.get() == buttonTypeOne) { updsel(m, 1); cashday(m); System.exit(0); } }); btcl.setOnAction(event -> { jsares.clear(); res.setText(""); titg.setText(""); itog = 0; chcount = 1; cbx1.getSelectionModel().clearSelection(); cbx2.getSelectionModel().clearSelection(); cbx3.getSelectionModel().clearSelection(); cbx4.getSelectionModel().clearSelection(); cbx4.setVisible(false); sp1.getValueFactory().setValue(0.0); sp2.getValueFactory().setValue(0); sp3.getValueFactory().setValue(0); spb1.getValueFactory().setValue(0); sp1.setVisible(false); sp2.setVisible(false); sp3.setVisible(false); spb1.setVisible(false); lb1.setVisible(false); lb2.setVisible(false); lb3.setVisible(false); lbb1.setVisible(false); t1.setVisible(false); t2.setVisible(false); t3.setVisible(false); bt1.setVisible(false); bt2.setVisible(false); bt3.setVisible(false); }); bitg.setOnAction(event -> { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(""); alert.setHeaderText(" "); alert.setContentText(" ?"); ButtonType buttonOK = new ButtonType(""); ButtonType buttonCancel = new ButtonType("", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonOK, buttonCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonOK) { alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(""); alert.setHeaderText(" "); alert.setContentText(" "); ButtonType buttonTypeOne = new ButtonType(""); ButtonType buttonTypeTwo = new ButtonType(""); //ButtonType buttonTypeThree = new ButtonType("Three"); ButtonType buttonTypeCancel = new ButtonType("", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeTwo, /*buttonTypeThree,*/ buttonTypeCancel); Optional<ButtonType> result2 = alert.showAndWait(); if (result2.get() == buttonTypeOne) { // ... user chose "One" typepay = ""; finishnal(titg.getText(), res.getText(), 1); } else if (result2.get() == buttonTypeTwo) { // ... user chose "Two" typepay = ""; finishnal(titg.getText(), res.getText(), 2); } /* else if (result2.get() == buttonTypeThree) { // ... user chose "Three" }*/ else { // ... user chose CANCEL or closed the dialog } } else { // ... user chose CANCEL or closed the dialog } }); txg3.setOnMouseClicked(event -> { Dialog dialog = new Dialog(); GridPane gr = new GridPane(); gr.setHgap(3); gr.setVgap(5); gr.setPadding(new Insets(10, 10, 10, 10)); Button b1 = new Button("1"); b1.setPrefSize(50, 50); Button b2 = new Button("2"); b2.setPrefSize(50, 50); Button b3 = new Button("3"); b3.setPrefSize(50, 50); Button b4 = new Button("4"); b4.setPrefSize(50, 50); Button b5 = new Button("5"); b5.setPrefSize(50, 50); Button b6 = new Button("6"); b6.setPrefSize(50, 50); Button b7 = new Button("7"); b7.setPrefSize(50, 50); Button b8 = new Button("8"); b8.setPrefSize(50, 50); Button b9 = new Button("9"); b9.setPrefSize(50, 50); Button b0 = new Button("0"); b0.setPrefSize(50, 50); Button bd = new Button("."); bd.setPrefSize(50, 50); Button bc = new Button("C"); bc.setPrefSize(50, 50); Button bok = new Button(""); bc.setPrefSize(50, 50); Button bno = new Button(""); bc.setPrefSize(50, 50); gr.add(b1, 0, 0); gr.add(b2, 1, 0); gr.add(b3, 2, 0); gr.add(b4, 0, 1); gr.add(b5, 1, 1); gr.add(b6, 2, 1); gr.add(b7, 0, 2); gr.add(b8, 1, 2); gr.add(b9, 2, 2); gr.add(bd, 0, 3); gr.add(b0, 1, 3); gr.add(bc, 2, 3); //gr.add(bok, 0, 4); //gr.add(bno, 3, 4); b1.setOnAction(even -> { txg3.setText(txg3.getText() + "1"); }); b2.setOnAction(even -> { txg3.setText(txg3.getText() + "2"); }); b3.setOnAction(even -> { txg3.setText(txg3.getText() + "3"); }); b4.setOnAction(even -> { txg3.setText(txg3.getText() + "4"); }); b5.setOnAction(even -> { txg3.setText(txg3.getText() + "5"); }); b6.setOnAction(even -> { txg3.setText(txg3.getText() + "6"); }); b7.setOnAction(even -> { txg3.setText(txg3.getText() + "7"); }); b8.setOnAction(even -> { txg3.setText(txg3.getText() + "8"); }); b9.setOnAction(even -> { txg3.setText(txg3.getText() + "9"); }); bc.setOnAction(even -> { txg3.setText(""); }); bd.setOnAction(even -> { txg3.setText(txg3.getText() + "."); }); b0.setOnAction(even -> { txg3.setText(txg3.getText() + "0"); }); ButtonType okk = new ButtonType("OK", ButtonData.OK_DONE); ButtonType no = new ButtonType("", ButtonData.CANCEL_CLOSE); //gr.add(okk, 0, 4); dialog.getDialogPane().setContent(gr); dialog.getDialogPane().getButtonTypes().addAll(no, okk); dialog.setX(350); dialog.setY(260); Optional res = dialog.showAndWait(); runJsons(); // dialog.setResult(ButtonData.CANCEL_CLOSE); //dialog.showAndWait(); }); txg3.lengthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { if (newValue.intValue() > oldValue.intValue()) { char ch = txg3.getText().charAt(oldValue.intValue()); // Check if the new character is the number or other's if ((!(ch >= '0' && ch <= '9'))) { // if it's not number then just setText to previous one if (ch == '.') { } else { txg3.setText(txg3.getText().substring(0, txg3.getText().length() - 1)); } } double res; if (cbx3.getSelectionModel().getSelectedIndex() >= 0) { res = Double.parseDouble(txg3.getText()); res = res / 1000; //System.out.println("RES-"+res+"balanc"+balancech(cbx3.getSelectionModel().getSelectedItem().toString())+"BASE"+Double.parseDouble(getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(),MT))); if ((res + balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3)) > Double .parseDouble( getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT))) { txg3.setText(""); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); } } } } }); cbx1.setOnMouseClicked(new EventHandler() { @Override public void handle(Event event) { spb1.getValueFactory().setValue(0); sp1.getValueFactory().setValue(0.0); runJsons(); cbx1.setItems(GetByTag(TAG_NAME, "1")); //cbx1.getSelectionModel().clearSelection(); int[] remove = new int[cbx1.getItems().size()]; for (int i = 0; i < cbx1.getItems().size(); i++) { //System.out.println("****"+m); if (!isHave(cbx1.getItems().get(i).toString(), 1)) { // } else { } } cbx1.show(); } }); sp1.setOnMouseClicked(event -> { if (cbx1.getSelectionModel().getSelectedItem() != null) { double spres = Double.parseDouble(sp1.getEditor().getText().toString().replace(",", ".")); double salesres = balancech(cbx1.getSelectionModel().getSelectedItem().toString(), 1); double balancestore = Double .parseDouble(getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, MT)); // System.out.println(balancestore+" "+spres+" "+salesres); if ((balancestore - (spres + salesres)) >= 0) { } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); sp1.getValueFactory().setValue(0.0); } } }); sp2.setOnMouseClicked(event -> { if (cbx2.getSelectionModel().getSelectedIndex() >= 0) { double spres = Double.parseDouble(sp2.getEditor().getText().toString()); double salesres = balancech(cbx2.getSelectionModel().getSelectedItem().toString(), 2); double balancestore = Double .parseDouble(getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, MT)); if ((balancestore - (spres + salesres)) >= 0) { } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); sp2.getValueFactory().setValue(0); } } }); spb1.setOnMouseClicked(event -> { if (cbx4.getSelectionModel().getSelectedIndex() >= 0) { double spres = Double.parseDouble(spb1.getEditor().getText().toString()); double salesres = balancech(cbx4.getSelectionModel().getSelectedItem().toString(), 4); double balancestore = Double .parseDouble(getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, MT)); if ((balancestore - (spres + salesres)) >= 0) { } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); spb1.getValueFactory().setValue(0); } } }); sp3.setOnMouseClicked(event -> { if (cbx3.getSelectionModel().getSelectedIndex() >= 0) { double spres = Double.parseDouble(sp3.getEditor().getText().toString()); double salesres = balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3); double balancestore = Double .parseDouble(getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT)); if ((balancestore - (spres + salesres)) >= 0) { } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); sp3.getValueFactory().setValue(0); } } }); cbx4.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (observable.getValue() == null) { } else { if (!isHave(cbx4.getSelectionModel().getSelectedItem().toString(), 4)) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText( cbx4.getSelectionModel().getSelectedItem().toString() + " !"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { cbx4.getSelectionModel().clearSelection(); } else { cbx4.getSelectionModel().clearSelection(); } } else { } } } }); cbx1.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (observable.getValue() == null) { } else { if (!isHave(cbx1.getSelectionModel().getSelectedItem().toString(), 1)) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText( cbx1.getSelectionModel().getSelectedItem().toString() + " !"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { sp1.setVisible(false); sp1.getValueFactory().setValue(0.0); lb1.setVisible(false); t1.setVisible(false); cbx4.setVisible(false); spb1.setVisible(false); spb1.getValueFactory().setValue(0); lbb1.setVisible(false); bt1.setVisible(false); cbx1.getSelectionModel().clearSelection(); } else { sp1.setVisible(false); sp1.getValueFactory().setValue(0.0); lb1.setVisible(false); t1.setVisible(false); cbx4.setVisible(false); spb1.setVisible(false); spb1.getValueFactory().setValue(0); lbb1.setVisible(false); bt1.setVisible(false); cbx1.getSelectionModel().clearSelection(); } } else { sp2.setVisible(false); lb2.setVisible(false); t2.setVisible(false); bt2.setVisible(false); sp2.getValueFactory().setValue(0); cbx2.getSelectionModel().clearSelection(); txg3.setVisible(false); sp3.setVisible(false); lb3.setVisible(false); t3.setVisible(false); bt3.setVisible(false); sp3.getValueFactory().setValue(0); cbx3.getSelectionModel().clearSelection(); double curbal = Double.parseDouble( getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, MT)) - balancech(cbx1.getSelectionModel().getSelectedItem().toString(), 1); t1.setText(ost + " " + curbal + " ."); cbx4.setItems(GetByTag(TAG_NAME, "4")); sp1.setVisible(true); lb1.setVisible(true); t1.setVisible(true); cbx4.setVisible(true); spb1.setVisible(true); lbb1.setVisible(true); bt1.setVisible(true); if (cbx1.getSelectionModel().getSelectedItem().toString().matches("")) { sp1.setVisible(false); t1.setVisible(false); lb1.setVisible(false); } } } } }); bt1.setOnAction(event -> { if (cbx1.getSelectionModel().getSelectedItem().toString().matches("")) { if (spb1.getValueFactory().getValue() < 1) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else { double bottlprice = Double.parseDouble( getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "price")); int bottlc = spb1.getValueFactory().getValue(); double bottleitg = bottlc * bottlprice; res.setText(res.getText() + printCh2(cbx4.getSelectionModel().getSelectedItem().toString(), "", bottlc, bottlprice) + "\n"); itog = itog + bottleitg; titg.setText(String.valueOf(itog)); jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "id")); jsores.put(TCOUNT, bottlc); jsores.put(TRES, bottleitg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID SimpleDateFormat fff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, fff.format(System.currentTimeMillis())); jsores.put(TAG_CHECK, checkcheck()); jsares.add(jsores); sp1.setVisible(!true); lb1.setVisible(!true); t1.setVisible(!true); cbx4.setVisible(!true); spb1.setVisible(!true); lbb1.setVisible(!true); bt1.setVisible(!true); spb1.getValueFactory().setValue(0); sp1.getValueFactory().setValue(0.0); cbx1.getSelectionModel().clearSelection(); cbx4.getSelectionModel().clearSelection(); } } else { if (sp1.getValueFactory().getValue() < 0.5) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (cbx4.getSelectionModel().getSelectedItem() == null) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (spb1.getValueFactory().getValue() < 1) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } /*else if(cbx4.getSelectionModel().getSelectedItem().toString().matches("")){ Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); }*/else { double liters = sp1.getValueFactory().getValue(); double bottlc = spb1.getValueFactory().getValue(); String sb = cbx4.getSelectionModel().getSelectedItem().toString(); double bottlsz = 0; if (sb.contains("0.5") | sb.contains("0,5")) { bottlsz = 0.5; } else if (sb.contains("1.0") | sb.contains("1,0")) { bottlsz = 1.0; } else if (sb.contains("1.5") | sb.contains("1,5")) { bottlsz = 1.5; } else if (sb.contains("2,0") | sb.contains("2.0") | sb.contains("2")) { bottlsz = 2.0; } else if (sb.contains("3,0") | sb.contains("3.0") | sb.contains("3")) { bottlsz = 3.0; } else if (sb.contains("")) { bottlsz = 0.5; } if ((bottlsz * bottlc) == liters) { double price = Double.parseDouble( getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, TAG_PRICE)); String prodn = cbx1.getSelectionModel().getSelectedItem().toString(); double itg = 0; if (getTwotag(prodn, 1, "sales").matches("1")) { if (liters % 3 == 0) { price = ((liters * price) - ((liters / 3) * price)) / liters; itg = liters * price; } else { itg = liters * price; } } else { itg = liters * price; } double bottlprice = 0; if (sp1.isVisible() & !cbx4.getSelectionModel().getSelectedItem().toString().contains("")) { bottlprice = Double.parseDouble( getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "price")); } else if (sp1.isVisible() & cbx4.getSelectionModel().getSelectedItem().toString().contains("")) { bottlprice = 0; } else if (!sp1.isVisible() & cbx4.getSelectionModel().getSelectedItem().toString().contains("")) { bottlprice = 0; } res.setText(res.getText() + printCh2(cbx1.getSelectionModel().getSelectedItem().toString(), "", liters, price) + "\n"); res.setText(res.getText() + printCh2(cbx4.getSelectionModel().getSelectedItem().toString(), "", bottlc, bottlprice) + "\n"); itog += itg; jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, "id")); jsores.put(TCOUNT, String.valueOf(liters)); jsores.put(TRES, itg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID //jsores.put("balance", (balance1.get(cbx1.getSelectionModel().getSelectedIndex()) - coun)); SimpleDateFormat ff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, ff.format(System.currentTimeMillis())); //jsores.put("seltype","1"); //jsores.put("dolgid","1"); jsores.put(TAG_CHECK, checkcheck()); jsares.add(jsores); double bottleitg = bottlprice * bottlc; itog = itog + bottleitg; titg.setText(String.valueOf(itog)); jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "id")); jsores.put(TCOUNT, bottlc); jsores.put(TRES, bottleitg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID //jsores.put("balance", (balanceb.get(cbx4.getSelectionModel().getSelectedIndex()) - counb)); SimpleDateFormat fff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, fff.format(System.currentTimeMillis())); //jsores.put("seltype",1); ! //jsores.put("dolgid",1); jsores.put(TAG_CHECK, checkcheck()); jsares.add(jsores); //System.out.println(jsares); sp1.setVisible(!true); lb1.setVisible(!true); t1.setVisible(!true); cbx4.setVisible(!true); spb1.setVisible(!true); lbb1.setVisible(!true); bt1.setVisible(!true); spb1.getValueFactory().setValue(0); sp1.getValueFactory().setValue(0.0); cbx1.getSelectionModel().clearSelection(); cbx4.getSelectionModel().clearSelection(); } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } } } }); cbx2.setOnMouseClicked(new EventHandler() { @Override public void handle(Event event) { runJsons(); cbx2.setItems(GetByTag(TAG_NAME, "2")); cbx2.show(); } }); cbx2.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (observable.getValue() == null) { } else { if (!isHave(cbx2.getSelectionModel().getSelectedItem().toString(), 2)) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText( cbx2.getSelectionModel().getSelectedItem().toString() + " !"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { sp2.setVisible(false); sp2.getValueFactory().setValue(0); lb2.setVisible(false); t2.setVisible(false); bt2.setVisible(false); cbx2.getSelectionModel().clearSelection(); } else { sp2.setVisible(false); sp2.getValueFactory().setValue(0); lb2.setVisible(false); t2.setVisible(false); bt2.setVisible(false); cbx2.getSelectionModel().clearSelection(); } } else { txg3.setVisible(false); sp3.setVisible(!true); lb3.setVisible(!true); t3.setVisible(!true); bt3.setVisible(!true); sp3.getValueFactory().setValue(0); cbx3.getSelectionModel().clearSelection(); cbx4.setVisible(!true); sp1.setVisible(!true); lb1.setVisible(!true); t1.setVisible(!true); spb1.setVisible(!true); lbb1.setVisible(!true); bt1.setVisible(!true); sp1.getValueFactory().setValue(0.0); spb1.getValueFactory().setValue(0); cbx1.getSelectionModel().clearSelection(); sp2.setVisible(true); lb2.setVisible(true); t2.setVisible(true); bt2.setVisible(true); sp2.getValueFactory().setValue(0); //System.out.println("////////"+newValue+"/////"); double curbal = Double.parseDouble( getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, MT)) - balancech(cbx2.getSelectionModel().getSelectedItem().toString(), 2); t2.setText(ost + " " + curbal + " ."); } } } }); bt2.setOnAction(event -> { if (sp2.getValueFactory().getValue() < 1) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else { int coun = Integer.parseInt(sp2.getEditor().getText()); double price = Double.parseDouble( getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, TAG_PRICE)); double itg = coun * price; res.setText(res.getText() + printCh2(cbx2.getSelectionModel().getSelectedItem().toString(), "", coun, price) + "\n"); itog = itog + itg; titg.setText(String.valueOf(itog)); jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, TAG_ID)); jsores.put(TCOUNT, String.valueOf(coun)); jsores.put(TRES, itg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID //jsores.put("balance", (balance2.get(cbx2.getSelectionModel().getSelectedIndex()) - coun)); SimpleDateFormat ff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, ff.format(System.currentTimeMillis())); //jsores.put("seltype","1"); !!!!!! //jsores.put("dolgid","1"); jsores.put(TAG_CHECK, checkcheck()); jsares.add(jsores); sp2.setVisible(!true); lb2.setVisible(!true); t2.setVisible(!true); bt2.setVisible(!true); sp2.getValueFactory().setValue(0); cbx2.getSelectionModel().clearSelection(); } }); cbx3.setOnMouseClicked(new EventHandler() { @Override public void handle(Event event) { sp3.getValueFactory().setValue(0); runJsons(); cbx3.setItems(GetByTag(TAG_NAME, "3")); cbx3.show(); } }); cbx3.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (observable.getValue() == null) { } else { if (!isHave(cbx3.getSelectionModel().getSelectedItem().toString(), 3)) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText( cbx3.getSelectionModel().getSelectedItem().toString() + " !"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { sp3.setVisible(false); sp3.getValueFactory().setValue(0); lb3.setVisible(false); t3.setVisible(false); bt3.setVisible(false); cbx3.getSelectionModel().clearSelection(); } else { sp3.setVisible(false); sp3.getValueFactory().setValue(0); lb3.setVisible(false); t3.setVisible(false); bt3.setVisible(false); cbx3.getSelectionModel().clearSelection(); } } else { sp1.setVisible(!true); lb1.setVisible(!true); t1.setVisible(!true); cbx4.setVisible(!true); spb1.setVisible(!true); lbb1.setVisible(!true); bt1.setVisible(!true); //spb1.getEditor().setText("0"); //sp1.getEditor().setText("0"); cbx1.getSelectionModel().clearSelection(); sp2.setVisible(!true); lb2.setVisible(!true); t2.setVisible(!true); bt2.setVisible(!true); sp2.getValueFactory().setValue(0); cbx2.getSelectionModel().clearSelection(); sp3.setVisible(true); lb3.setVisible(true); t3.setVisible(true); bt3.setVisible(true); sp3.getValueFactory().setValue(0); if (getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, TAG_ZT) .equals("2")) { double curbal = Double.parseDouble( getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT)) - (balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3)); String pattern = "##0.00"; DecimalFormat decimalFormat = new DecimalFormat(pattern); String format = decimalFormat.format(curbal); t3.setText(ost + " " + format + " ."); lb3.setText(""); sp3.setVisible(false); txg3.setVisible(true); txg3.setText(""); } else { double curbal = Double.parseDouble( getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT)) - balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3); t3.setText(ost + " " + curbal + " ."); lb3.setText(""); txg3.setVisible(false); sp3.setVisible(true); } } } } }); bt3.setOnAction(event -> { int typez = Integer.parseInt(getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, "zt")); if (sp3.isVisible() & sp3.getValueFactory().getValue() < 1) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (txg3.isVisible() & txg3.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!!"); alert.setContentText(" !"); alert.showAndWait(); } else { double coun = 0; double price = Double.parseDouble( getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, TAG_PRICE)); double itg = 0; double itgcoun = 0; if (lb3.getText().equals("")) { //System.out.println(lb3.getText()); coun = sp3.getValueFactory().getValue(); itg = coun * price; itgcoun = coun; // System.out.println("SPINNER" + coun); res.setText(res.getText() + printCh2(cbx3.getSelectionModel().getSelectedItem().toString(), "", coun, price) + "\n"); } else if (lb3.getText().equals("")) { // System.out.println(lb3.getText()); coun = Double.parseDouble(txg3.getText()); itg = ((price * coun) / 100); // System.out.println("!!!???!!!"+coun+" "+price); res.setText(res.getText() + printCh3(cbx3.getSelectionModel().getSelectedItem().toString(), "", coun, price) + "\n"); itgcoun = (double) coun / 1000; //System.out.println("TEXT" + coun+" "+itgcoun); } String pattern = "##0.0"; DecimalFormat decimalFormat = new DecimalFormat(pattern); String format = decimalFormat.format(itg); itog = itog + itg; titg.setText(String.valueOf(itog)); jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, TAG_ID)); jsores.put(TCOUNT, Double.parseDouble(String.valueOf(itgcoun))); jsores.put(TRES, itg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID //jsores.put("balance", (balance3.get(cbx3.getSelectionModel().getSelectedIndex()) - coun)); SimpleDateFormat ff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, ff.format(System.currentTimeMillis())); //jsores.put("seltype","1"); !!!!! //jsores.put("dolgid","1"); jsores.put(TAG_CHECK, checkcheck()); //System.out.println(jsores); jsares.add(jsores); sp3.setVisible(!true); lb3.setVisible(!true); t3.setVisible(!true); bt3.setVisible(!true); sp3.getValueFactory().setValue(0); cbx3.getSelectionModel().clearSelection(); txg3.setVisible(false); // } } }); Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); Scene scene = new Scene(grid, sSize.width, sSize.height); primaryStage.setScene(scene); scene.getStylesheets().add(MainA.class.getResource("main.css").toExternalForm()); primaryStage.show(); }
From source file:editeurpanovisu.EditeurPanovisu.java
public static void creerEditerDiaporama(String strDiaporama) { apCreationDiaporama.getChildren().clear(); apCreationDiaporama.setStyle("-fx-background-color : -fx-base;" + "-fx-border-color: derive(-fx-base,10%);" + "-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.5) , 8, 0.0 , 0 , 8 );" + "-fx-border-width: 1px;"); mbarPrincipal.setDisable(true);//from w w w .jav a2 s .c o m bbarPrincipal.setDisable(true); hbBarreBouton.setDisable(true); tpEnvironnement.setDisable(true); Rectangle2D tailleEcran = Screen.getPrimary().getBounds(); int iLargeurEcran = (int) tailleEcran.getWidth(); int iHauteurEcran = (int) tailleEcran.getHeight() - 100; final int iLargeur = 800; final int iHauteur = 630; Label lblNomDiapo = new Label(rbLocalisation.getString("main.nomDiapo")); lblNomDiapo.setLayoutX(30); lblNomDiapo.setLayoutY(45); ComboBox cbListeDiapo = new ComboBox(); cbListeDiapo.setLayoutX(150); cbListeDiapo.setLayoutY(40); cbListeDiapo.setValue(""); for (int i = 0; i < getiNombreDiapo(); i++) { cbListeDiapo.getItems().add(diaporamas[i].getStrNomDiaporama()); } Button btnNouveauDiapo = new Button(rbLocalisation.getString("diapo.nouveau")); btnNouveauDiapo.setLayoutX(iLargeur - 330); btnNouveauDiapo.setLayoutY(20); btnNouveauDiapo.setPrefSize(140, 60); Button btnEffaceDiapo = new Button(rbLocalisation.getString("diapo.efface")); btnEffaceDiapo.setLayoutX(iLargeur - 170); btnEffaceDiapo.setLayoutY(20); btnEffaceDiapo.setPrefSize(140, 60); gestDiapo = new GestionnaireDiaporamaController(); gestDiapo.initDiaporama(); apCreationDiaporama.getChildren().addAll(lblNomDiapo, cbListeDiapo, btnEffaceDiapo, btnNouveauDiapo, gestDiapo.apDiaporama); apCreationDiaporama.setPrefWidth(iLargeur); apCreationDiaporama.setMinWidth(iLargeur); apCreationDiaporama.setMaxWidth(iLargeur); apCreationDiaporama.setPrefHeight(iHauteur); apCreationDiaporama.setMinHeight(iHauteur); apCreationDiaporama.setMaxHeight(iHauteur); apCreationDiaporama.setLayoutX((iLargeurEcran - iLargeur) / 2); apCreationDiaporama.setLayoutY((iHauteurEcran - iHauteur) / 2); apCreationDiaporama.setVisible(true); gestDiapo.addPropertyChangeListener("valideDiapo", (e) -> { mbarPrincipal.setDisable(false); bbarPrincipal.setDisable(false); hbBarreBouton.setDisable(false); tpEnvironnement.setDisable(false); apCreationDiaporama.setVisible(false); gestDiapo.diapoSauve = true; boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(cbListeDiapo.getValue())) { bTrouve = true; iTrouve = i; } } if (bTrouve) { diaporamas[iTrouve] = gestDiapo.getDiaporama(); try { creeDiaporamaHTML(diaporamas[iTrouve], iTrouve); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } gestDiapo.reInit(new Diaporama()); }); gestDiapo.addPropertyChangeListener("visualiseDiapo", (e) -> { try { creeDiaporamaHTML(gestDiapo.getDiaporama(), -1); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } String strNomFichier = getStrRepertTemp() + File.separator + "diaporama" + File.separator + "diapo-1.html"; webEngine.load("file:///" + strNomFichier); apWebview.getChildren().clear(); browser.setPrefSize(apWebview.getPrefWidth() - 20, apWebview.getPrefHeight() - 50); browser.setTranslateX(10); browser.setTranslateY(10); apWebview.getChildren().add(browser); Button btnOk = new Button("Ok"); btnOk.setPrefSize(100, 20); btnOk.setLayoutX(apWebview.getPrefWidth() - 110); btnOk.setLayoutY(apWebview.getPrefHeight() - 30); apWebview.getChildren().add(btnOk); apWebview.setVisible(true); btnOk.setOnMouseClicked((me) -> { apWebview.setVisible(false); apWebview.getChildren().clear(); }); }); gestDiapo.addPropertyChangeListener("annuleDiapo", (e) -> { mbarPrincipal.setDisable(false); bbarPrincipal.setDisable(false); hbBarreBouton.setDisable(false); tpEnvironnement.setDisable(false); apCreationDiaporama.setVisible(false); gestDiapo.diapoSauve = true; gestDiapo.reInit(new Diaporama()); }); cbListeDiapo.valueProperty().addListener((ov, old_val, new_val) -> { if (new_val != null) { ButtonType reponse = null; ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui")); ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non")); if (!gestDiapo.diapoSauve) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(rbLocalisation.getString("diapo.sauver")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("diapo.sauverTexte")); alert.getButtonTypes().clear(); alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon); Optional<ButtonType> actReponse = alert.showAndWait(); reponse = actReponse.get(); } if (reponse == buttonTypeOui) { boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(old_val)) { bTrouve = true; iTrouve = i; } } if (bTrouve) { diaporamas[iTrouve] = gestDiapo.getDiaporama(); try { creeDiaporamaHTML(diaporamas[iTrouve], iTrouve); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } } gestDiapo.diapoSauve = true; boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(new_val)) { bTrouve = true; iTrouve = i; } } if (bTrouve) { gestDiapo.setbDisabled(false); gestDiapo.reInit(diaporamas[iTrouve]); } } }); btnNouveauDiapo.setOnMouseClicked((me) -> { ButtonType reponse = null; ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui")); ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non")); if (!gestDiapo.diapoSauve) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(rbLocalisation.getString("diapo.sauver")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("diapo.sauverTexte")); alert.getButtonTypes().clear(); alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon); Optional<ButtonType> actReponse = alert.showAndWait(); reponse = actReponse.get(); } if (reponse == buttonTypeOui) { gestDiapo.diapoSauve = true; boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(cbListeDiapo.getValue())) { bTrouve = true; iTrouve = i; } } if (bTrouve) { diaporamas[iTrouve] = gestDiapo.getDiaporama(); try { creeDiaporamaHTML(diaporamas[iTrouve], iTrouve); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } } TextInputDialog dialog = new TextInputDialog(""); dialog.setTitle(rbLocalisation.getString("main.nomDiapo")); dialog.setHeaderText(null); dialog.setContentText(rbLocalisation.getString("diapo.entrerNom")); Optional<String> resultat = dialog.showAndWait(); if (resultat.isPresent()) { String nomDiapo = resultat.get(); boolean bTrouve = false; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(nomDiapo)) { bTrouve = true; } } if (!bTrouve) { diaporamas[getiNombreDiapo()] = new Diaporama(); diaporamas[getiNombreDiapo()].setStrNomDiaporama(nomDiapo); cbListeDiapo.getItems().add(nomDiapo); cbListeDiapo.setValue(nomDiapo); gestDiapo.setbDisabled(false); gestDiapo.reInit(diaporamas[getiNombreDiapo()]); setiNombreDiapo(getiNombreDiapo() + 1); } else { Alert alert = new Alert(AlertType.ERROR); alert.setTitle(rbLocalisation.getString("diapo.erreur")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("diapo.erreurNom")); alert.showAndWait(); } } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param stPrimaryStage// w w w .j a v a 2 s .c o m * @param iLargeur * @param iHauteur * @throws Exception Exceptions */ private static void creeEnvironnement(Stage stPrimaryStage, int iLargeur, int iHauteur) throws Exception { popUp = new PopUpDialogController(); stPrimaryStage.setMaximized(true); stPrimaryStage.setMinWidth(1280); stPrimaryStage.setMinHeight(720); iHauteurInterface = iHauteur; iLargeurInterface = iLargeur; /** * Cration des lments constitutifs de l'cran */ vbRacine = new VBox(); AnchorPane panePrincipale = new AnchorPane(vbRacine); setScnPrincipale(new Scene(panePrincipale, iLargeur, iHauteur, Color.rgb(221, 221, 221))); if (!fileRepertConfig.exists()) { fileRepertConfig.mkdirs(); setLocale(new Locale("fr", "FR")); File f = new File("css/clair.css"); getScnPrincipale().getStylesheets().add("file:///" + f.getAbsolutePath().replace("\\", "/")); setStrRepertoireProjet(getStrRepertAppli()); } else { lisFichierConfig(); } creeMenu(vbRacine); tpEnvironnement = new TabPane(); tpEnvironnement.setMinHeight(iHauteur - 60); tpEnvironnement.setMaxHeight(iHauteur - 60); tpEnvironnement.setMinWidth(iLargeur); tpEnvironnement.setMaxWidth(iLargeur); Pane paneBarreStatus = new Pane(); paneBarreStatus.setPrefSize(iLargeur + 20, 30); paneBarreStatus.setTranslateY(25); paneBarreStatus.setStyle("-fx-background-color:#c00;-fx-border-color:#aaa"); tabVisite = new Tab(); Pane paneVisualiseur; Pane panePlan; setTabInterface(new Tab()); setTabPlan(new Tab()); getGestionnaireInterface().creeInterface(iLargeur, iHauteur - 78); paneVisualiseur = getGestionnaireInterface().paneTabInterface; getGestionnairePlan().creeInterface(iLargeur, iHauteur - 78); panePlan = getGestionnairePlan().getPaneInterface(); getTabInterface().setContent(paneVisualiseur); getTabPlan().setContent(panePlan); HBox hbEnvironnement = new HBox(); TextField tfTitrePano; TextField tfTitreVisite; tpEnvironnement.getTabs().addAll(tabVisite, getTabInterface(), getTabPlan()); tpEnvironnement.setSide(Side.TOP); tpEnvironnement.getSelectionModel().selectedItemProperty() .addListener((ObservableValue<? extends Tab> ov, Tab t, Tab t1) -> { if (getGestionnaireInterface().navigateurCarteOL == null && isbInternet()) { getGestionnaireInterface().navigateurCarteOL = new NavigateurOpenLayersSeul(); getGestionnaireInterface().apNavigateurCarte = getGestionnaireInterface().navigateurCarteOL .afficheNavigateurOpenLayer(); } getGestionnaireInterface().rafraichit(); }); tabInterface.disableProperty().addListener((ov, av, nv) -> { if (!nv && getGestionnaireInterface().navigateurCarteOL == null && isbInternet()) { getGestionnaireInterface().navigateurCarteOL = new NavigateurOpenLayersSeul(); getGestionnaireInterface().navigateurCarteOL.setBingApiKey(getStrBingAPIKey()); getGestionnaireInterface().apNavigateurCarte = getGestionnaireInterface().navigateurCarteOL .afficheNavigateurOpenLayer(); } }); tabVisite.setText(rbLocalisation.getString("main.creationVisite")); tabVisite.setClosable(false); getTabInterface().setText(rbLocalisation.getString("main.creationInterface")); getTabInterface().setClosable(false); getTabPlan().setText(rbLocalisation.getString("main.tabPlan")); getTabPlan().setClosable(false); getTabPlan().setDisable(true); if (isbInternet()) { getTabInterface().setDisable(true); } tabVisite.setContent(hbEnvironnement); double largeur; String strLabelStyle = "-fx-color : white;-fx-background-color : #fff;-fx-padding : 5px; -fx-border : 1px solid #777;-fx-width : 100px;-fx-margin : 5px; "; vbRacine.setStyle("-fx-font-size : 9pt;-fx-font-family: Arial;"); vbRacine.setTranslateY(15); spPanneauOutils = new ScrollPane(); spPanneauOutils.setId("panOutils"); vbOutils = new VBox(-5); vbOutils.setPrefWidth(largeurOutils - 20); setVbChoixPanoramique(new VBox()); getVbChoixPanoramique().setId("choixPanoramique"); double largeurOutil = vbOutils.getPrefWidth(); apPanovisu = new AnchorPane(); apPanovisu.setPrefHeight(50); apPanovisu.setMinHeight(50); apPanovisu.setMaxHeight(50); apPanovisu.setMaxWidth(380); apPanovisu.setPrefWidth(380); apPanovisu.setMinWidth(380); apPanovisu.setLayoutX(iLargeur - 380); if (isMac()) { apPanovisu.setLayoutY(0); } else { apPanovisu.setLayoutY(45); } apPanovisu.setStyle("-fx-background-color : derive(-fx-base,20%);"); ImageView ivPanoVisu = new ImageView(new Image( "file:" + getStrRepertAppli() + File.separator + "images/panovisu.png", 48, 48, true, true)); ivPanoVisu.setLayoutX(40); ivPanoVisu.setLayoutY(1); Label lblPanoVisu = new Label("panoVisu Vers. : " + strNumVersion); lblPanoVisu.setStyle( "-fx-font-weight : bold;-fx-font-family : Verdana,Arial,sans-serif;-fx-font-size : 1.2em;"); lblPanoVisu.setLayoutX(108); lblPanoVisu.setLayoutY(5); Label lblPanoVisu2 = new Label("Laurent LANG (2014-2015)"); lblPanoVisu2.setLayoutX(108); lblPanoVisu2.setLayoutY(35); lblPanoVisu2.setStyle("-fx-font-family : Verdana,Arial,sans-serif;-fx-font-size : 0.8em;"); apPanovisu.getChildren().addAll(ivPanoVisu, lblPanoVisu, lblPanoVisu2); panePrincipale.getChildren().add(apPanovisu); panePrincipale.getChildren().add(apWebview); apWebview.setVisible(false); apWebview.setStyle("-fx-background-color : #333;"); apWebview.setPrefSize(iLargeur - 75, iHauteur - 80); apWebview.setMinSize(iLargeur - 75, iHauteur - 80); apWebview.setMaxSize(iLargeur - 75, iHauteur - 80); apWebview.setTranslateX(25); apWebview.setTranslateY(5); /* Paramtres de la visite */ apParametresVisite = new AnchorPane(); apParametresVisite.setLayoutY(40); Label lblTitreVisite = new Label(rbLocalisation.getString("main.titreVisite")); lblTitreVisite.setStyle("-fx-font-size : 10pt;-fx-font-weight : bold;"); lblTitreVisite.setLayoutX(10); lblTitreVisite.setLayoutY(5); tfTitreVisite = new TextField(); tfTitreVisite.setId("titreVisite"); tfTitreVisite.setPrefSize(200, 25); tfTitreVisite.setMaxSize(250, 25); tfTitreVisite.setLayoutX(60); tfTitreVisite.setLayoutY(25); cbIntroPetitePlanete = new CheckBox(rbLocalisation.getString("main.introPetitePlanete")); cbIntroPetitePlanete.setSelected(false); cbIntroPetitePlanete.setLayoutX(10); cbIntroPetitePlanete.setLayoutY(60); Label lblChoixPanoramiqueEntree = new Label(rbLocalisation.getString("main.panoEntree")); lblChoixPanoramiqueEntree.setStyle("-fx-font-size : 1em;"); lblChoixPanoramiqueEntree.setLayoutX(10); lblChoixPanoramiqueEntree.setLayoutY(90); lblChoixPanoramiqueEntree.setMaxWidth(largeurOutils - 40); lblChoixPanoramiqueEntree.setPrefHeight(35); lblChoixPanoramiqueEntree.setWrapText(true); apParametresVisite.setPrefHeight(120); apParametresVisite.getChildren().addAll(lblTitreVisite, tfTitreVisite, cbIntroPetitePlanete, lblChoixPanoramiqueEntree); PaneOutil poParametresVisite = new PaneOutil(rbLocalisation.getString("main.parametresVisite"), apParametresVisite, largeurOutil); setApPVIS(new AnchorPane(poParametresVisite.getApPaneOutil())); poParametresVisite.setbValide(isbIntroPetitePlanete()); AnchorPane apAutoRotation = new AnchorPane(); apAutoRotation.setPrefHeight(270); apAutoRotation.setLayoutY(40); PaneOutil poAutoRotation = new PaneOutil(rbLocalisation.getString("main.autoTourRotation"), apAutoRotation, largeurOutil); setApAR(new AnchorPane(poAutoRotation.getApPaneOutil())); poAutoRotation.setbValide(isbAutoRotationDemarre() || isbAutoTourDemarre()); cbAutoRotationDemarrage = new CheckBox(rbLocalisation.getString("main.autoRotationDemarrage")); cbAutoRotationDemarrage.setSelected(false); cbAutoRotationDemarrage.setLayoutX(10); cbAutoRotationDemarrage.setLayoutY(10); Label lblVitesse = new Label(rbLocalisation.getString("main.autoRotationVitesse")); lblVitesse.setLayoutX(10); lblVitesse.setLayoutY(40); cbAutoRotationVitesse = new ComboBox(); cbAutoRotationVitesse.getItems().add(0, "10 " + rbLocalisation.getString("main.parTour")); cbAutoRotationVitesse.getItems().add(1, "20 " + rbLocalisation.getString("main.parTour")); cbAutoRotationVitesse.getItems().add(2, "30 " + rbLocalisation.getString("main.parTour")); cbAutoRotationVitesse.getItems().add(3, "Autre n " + rbLocalisation.getString("main.parTour")); cbAutoRotationVitesse.getSelectionModel().select(2); cbAutoRotationVitesse.setLayoutX(30); cbAutoRotationVitesse.setLayoutY(70); cbAutoRotationVitesse.setMaxWidth(170); bdfAutoRotationVitesse = new BigDecimalField(new BigDecimal(40)); bdfAutoRotationVitesse.setDisable(true); bdfAutoRotationVitesse.setLayoutX(210); bdfAutoRotationVitesse.setLayoutY(70); bdfAutoRotationVitesse.setMaxWidth(70); lblVitesse.disableProperty().bind(cbAutoRotationDemarrage.selectedProperty().not()); cbAutoRotationVitesse.disableProperty().bind(cbAutoRotationDemarrage.selectedProperty().not()); Label lblUnites = new Label(rbLocalisation.getString("main.parTour")); lblUnites.setLayoutX(290); lblUnites.setLayoutY(75); Separator spAutotour = new Separator(Orientation.HORIZONTAL); spAutotour.setLayoutX(0); spAutotour.setLayoutY(100); spAutotour.setMinWidth(380); cbAutoTourDemarrage = new CheckBox(rbLocalisation.getString("main.autoTour")); cbAutoTourDemarrage.setSelected(false); cbAutoTourDemarrage.setLayoutX(10); cbAutoTourDemarrage.setLayoutY(120); Label lblDemarrageAutoTour = new Label(rbLocalisation.getString("main.autoTourDemarrage")); lblDemarrageAutoTour.setLayoutX(10); lblDemarrageAutoTour.setLayoutY(150); bdfAutoTourDemarrage = new BigDecimalField(new BigDecimal(1)); bdfAutoTourDemarrage.setLayoutX(240); bdfAutoTourDemarrage.setLayoutY(180); bdfAutoTourDemarrage.setMaxWidth(70); Label lblVitesseAutoTour = new Label(rbLocalisation.getString("main.autoTourChange")); lblVitesseAutoTour.setLayoutX(10); lblVitesseAutoTour.setLayoutY(210); cbAutoTourType = new ComboBox(); cbAutoTourType.getItems().add(rbLocalisation.getString("main.nTours")); cbAutoTourType.getItems().add(rbLocalisation.getString("main.nSecondes")); cbAutoTourType.getSelectionModel().select(1); cbAutoTourType.setLayoutX(30); cbAutoTourType.setLayoutY(240); cbAutoTourType.setMaxWidth(140); bdfAutoTourLimite = new BigDecimalField(new BigDecimal(1)); bdfAutoTourLimite.setLayoutX(240); bdfAutoTourLimite.setLayoutY(240); bdfAutoTourLimite.setMaxWidth(70); Label lblN = new Label("n="); lblN.setLayoutX(210); lblN.setLayoutY(245); cbAutoTourType.disableProperty().bind(cbAutoTourDemarrage.selectedProperty().not()); bdfAutoTourLimite.disableProperty().bind(cbAutoTourDemarrage.selectedProperty().not()); cbAutoRotationVitesse.getSelectionModel().selectedIndexProperty().addListener((ov, av, nv) -> { if (cbAutoRotationVitesse.getSelectionModel().getSelectedIndex() == 3) { bdfAutoRotationVitesse.setDisable(false); setiAutoRotationVitesse(bdfAutoRotationVitesse.getNumber().toBigInteger().intValue()); } else { bdfAutoRotationVitesse.setDisable(true); setiAutoRotationVitesse(10 * (cbAutoRotationVitesse.getSelectionModel().getSelectedIndex() + 1)); } }); cbIntroPetitePlanete.selectedProperty().addListener((ov, av, nv) -> { setbIntroPetitePlanete(nv); poParametresVisite.setbValide(isbIntroPetitePlanete()); }); cbAutoRotationDemarrage.selectedProperty().addListener((ov, av, nv) -> { setbAutoRotationDemarre(nv); poAutoRotation.setbValide(isbAutoRotationDemarre() || isbAutoTourDemarre()); }); bdfAutoRotationVitesse.numberProperty().addListener((ov, av, nv) -> { setiAutoRotationVitesse(nv.toBigInteger().intValue()); }); cbAutoTourType.getSelectionModel().selectedIndexProperty().addListener((ov, av, nv) -> { if (cbAutoTourType.getSelectionModel().getSelectedIndex() == 0) { setStrAutoTourType("tours"); } else { setStrAutoTourType("secondes"); } }); cbAutoTourDemarrage.selectedProperty().addListener((ov, av, nv) -> { setbAutoTourDemarre(nv); poAutoRotation.setbValide(isbAutoRotationDemarre() || isbAutoTourDemarre()); getGestionnaireInterface().getApBtnVA().setDisable(!nv); }); bdfAutoTourLimite.numberProperty().addListener((ov, av, nv) -> { setiAutoTourLimite(nv.toBigInteger().intValue()); }); bdfAutoTourDemarrage.numberProperty().addListener((ov, av, nv) -> { setiAutoTourDemarrage(nv.toBigInteger().intValue()); }); apAutoRotation.getChildren().addAll(cbAutoRotationDemarrage, lblVitesse, cbAutoRotationVitesse, bdfAutoRotationVitesse, lblUnites, spAutotour, cbAutoTourDemarrage, lblDemarrageAutoTour, bdfAutoTourDemarrage, lblVitesseAutoTour, cbAutoTourType, lblN, bdfAutoTourLimite); AnchorPane apParametresPano = new AnchorPane(); apParametresPano.setPrefHeight(340); apParametresPano.setLayoutY(40); ImageView ivSupprPanoramique = new ImageView( new Image("file:" + getStrRepertAppli() + File.separator + "images/suppr.png", 48, 48, true, true)); ImageView ivModifPanoramique = new ImageView(new Image( "file:" + getStrRepertAppli() + File.separator + "images/modifie.png", 48, 48, true, true)); Button btnSupprimePano = new Button(rbLocalisation.getString("main.supprimePanoCourant"), ivSupprPanoramique); btnSupprimePano.setLayoutX(190); btnSupprimePano.setLayoutY(70); btnSupprimePano.setPrefSize(160, 60); btnSupprimePano.setMinSize(160, 60); btnSupprimePano.setMaxSize(160, 60); btnSupprimePano.setWrapText(true); btnSupprimePano.setOnAction((e) -> { retirePanoCourant(); }); Button btnModifiePano = new Button(rbLocalisation.getString("main.modifiePanoCourant"), ivModifPanoramique); btnModifiePano.setLayoutX(20); btnModifiePano.setLayoutY(70); btnModifiePano.setPrefSize(160, 60); btnModifiePano.setMinSize(160, 60); btnModifiePano.setMaxSize(160, 60); btnModifiePano.setWrapText(true); btnModifiePano.setOnAction((e) -> { String strRepertPano = getPanoramiquesProjet()[getiPanoActuel()].getStrNomFichier().substring(0, getPanoramiquesProjet()[getiPanoActuel()].getStrNomFichier().lastIndexOf(File.separator)); FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilterImage = new FileChooser.ExtensionFilter( "Fichiers Image (JPG,BMP,TIFF)", "*.jpg", "*.bmp", "*.tif"); FileChooser.ExtensionFilter extFilterJpeg = new FileChooser.ExtensionFilter("Fichiers JPEG (*.jpg)", "*.jpg"); FileChooser.ExtensionFilter extFilterBmp = new FileChooser.ExtensionFilter("Fichiers BMP (*.bmp)", "*.bmp"); FileChooser.ExtensionFilter extFilterTiff = new FileChooser.ExtensionFilter("Fichiers TIFF (*.tif)", "*.tif"); File fileRepert = new File(strRepertPano + File.separator); fileChooser.setInitialDirectory(fileRepert); fileChooser.getExtensionFilters().addAll(extFilterJpeg, extFilterTiff, extFilterBmp, extFilterImage); File filePano = fileChooser.showOpenDialog(null); if (filePano != null) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); String strFilePano = filePano.getAbsolutePath(); String strExtension = strFilePano.substring(strFilePano.length() - 3, strFilePano.length()); Image imgPano = null; if ("tif".equals(strExtension)) { try { imgPano = ReadWriteImage.readTiff(strFilePano); } catch (IOException | ImageReadException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } else { imgPano = new Image("file:" + strFilePano); } if (imgPano != null) { if (imgPano.getWidth() == imgPano.getHeight()) { try { rechargePanoramiqueProjet(strFilePano, Panoramique.CUBE); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } else { try { rechargePanoramiqueProjet(strFilePano, Panoramique.SPHERE); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } affichePanoChoisit(getiPanoActuel()); if (apListePanoTriable != null) { apParametresVisite.getChildren().remove(apListePanoTriable); } ordPano.rafraichitListe(); ordPano.ajouteNouveauxPanos(); apListePanoTriable = ordPano.getApListePanoramiques(); apListePanoTriable.setMaxHeight(apListePanoTriable.getPrefHeight()); apListePanoTriable.setMinHeight(apListePanoTriable.getPrefHeight()); apListePanoTriable.setVisible(true); apParametresVisite.getChildren().remove(apListePanoTriable); apParametresVisite.getChildren().add(apListePanoTriable); apListePanoTriable.setLayoutX(40); apListePanoTriable.setLayoutY(130); apParametresVisite.setPrefHeight(120 + apListePanoTriable.getPrefHeight() + 20); if (apParametresVisite.isVisible()) { apParametresVisite.setMinHeight(120 + apListePanoTriable.getPrefHeight() + 20); apParametresVisite.setMaxHeight(120 + apListePanoTriable.getPrefHeight() + 20); } rafraichitListePano(); } } }); Label lblTitrePano = new Label(rbLocalisation.getString("main.titrePano")); lblTitrePano.setStyle("-fx-font-size : 1em;"); lblTitrePano.setPadding(new Insets(5, 5, 5, 0)); lblTitrePano.setLayoutX(10); lblTitrePano.setLayoutY(10); tfTitrePano = new TextField(); tfTitrePano.setId("txttitrepano"); tfTitrePano.setPrefSize(220, 25); tfTitrePano.setMaxSize(250, 25); tfTitrePano.setLayoutX(60); tfTitrePano.setLayoutY(40); tfTitrePano.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { clickBtnValidePano(); }); slMinLat = new Slider(-90, -45, -90); slMinLat.setDisable(true); slMaxLat = new Slider(45, 90, 90); slMaxLat.setDisable(true); cbMinLat = new CheckBox(rbLocalisation.getString("main.blocageNadir")); cbMaxLat = new CheckBox(rbLocalisation.getString("main.blocageZenith")); slMinFov = new Slider(5, 70, 12); slMaxFov = new Slider(5, 70, 70); Label lblMinFov = new Label("min. hFOV : 12"); Label lblMaxFov = new Label("max. hFOV : 70"); slMinLat.disableProperty().bind(cbMinLat.selectedProperty().not()); slMaxLat.disableProperty().bind(cbMaxLat.selectedProperty().not()); slMinLat.setLayoutX(10); slMinLat.setLayoutY(160); cbMinLat.setLayoutX(190); cbMinLat.setLayoutY(160); slMaxLat.setLayoutX(10); slMaxLat.setLayoutY(190); cbMaxLat.setLayoutX(190); cbMaxLat.setLayoutY(190); slMinFov.setLayoutX(10); slMinFov.setLayoutY(220); lblMinFov.setLayoutX(190); lblMinFov.setLayoutY(220); slMaxFov.setLayoutX(10); slMaxFov.setLayoutY(250); lblMaxFov.setLayoutX(190); lblMaxFov.setLayoutY(250); Button btnBlocage = new Button(rbLocalisation.getString("main.blocage")); btnBlocage.setLayoutX(190); btnBlocage.setLayoutY(300); ligNadir = new Line(); ligNadir.setVisible(false); ligNadir.setStroke(Color.YELLOW); ligNadir.setStrokeWidth(2); ligZenith = new Line(); ligZenith.setVisible(false); ligZenith.setStroke(Color.YELLOW); ligZenith.setStrokeWidth(2); ligNadir.visibleProperty().bind(cbMinLat.selectedProperty()); ligZenith.visibleProperty().bind(cbMaxLat.selectedProperty()); slMinFov.valueProperty().addListener((observableValue, oldValue, newValue) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); getPanoramiquesProjet()[iPanoActuel].setFovMin((double) newValue); double val1 = Math.round((double) newValue * 10) / 10; lblMinFov.setText("min. FOV : " + val1 + ""); slMaxFov.setMin(val1); navigateurPanoramique.setMinFov(val1); if (navigateurPanoramique.getFov() < val1) { navigateurPanoramique.setFov(val1); } if (navigateurPanoramique.getChoixFov() < val1) { navigateurPanoramique.setChoixFov(val1); } }); slMaxFov.valueProperty().addListener((observableValue, oldValue, newValue) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); getPanoramiquesProjet()[iPanoActuel].setFovMax((double) newValue); double val1 = Math.round((double) newValue * 10) / 10; lblMaxFov.setText("max. FOV : " + val1 + ""); slMinFov.setMax(val1); navigateurPanoramique.setMaxFov(val1); if (navigateurPanoramique.getFov() > val1) { navigateurPanoramique.setFov(val1); } if (navigateurPanoramique.getChoixFov() > val1) { navigateurPanoramique.setChoixFov(val1); } }); slMinLat.valueProperty().addListener((observableValue, oldValue, newValue) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); double largeurImage1 = panePanoramique.getPrefWidth(); double X11 = ivImagePanoramique.getLayoutX(); double Y1 = (90.0d - (double) newValue) * largeurImage1 / 360.0d; ligNadir.setStartX(X11); ligNadir.setStartY(Y1); ligNadir.setEndX(X11 + largeurImage1); ligNadir.setEndY(Y1); getPanoramiquesProjet()[iPanoActuel].setMinLat((double) newValue); }); slMaxLat.valueProperty().addListener((observableValue, oldValue, newValue) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); double largeurImage1 = panePanoramique.getPrefWidth(); double X11 = ivImagePanoramique.getLayoutX(); double Y1 = (90.0d - (double) newValue) * largeurImage1 / 360.0d; ligZenith.setStartX(X11); ligZenith.setStartY(Y1); ligZenith.setEndX(X11 + largeurImage1); ligZenith.setEndY(Y1); getPanoramiquesProjet()[iPanoActuel].setMaxLat((double) newValue); }); cbMinLat.selectedProperty().addListener((ov, av, nv) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); double largeurImage1 = panePanoramique.getPrefWidth(); double X11 = ivImagePanoramique.getLayoutX(); double Y1 = (90.0d - (double) slMinLat.getValue()) * largeurImage1 / 360.0d; ligNadir.setStartX(X11); ligNadir.setStartY(Y1); ligNadir.setEndX(X11 + largeurImage1); ligNadir.setEndY(Y1); getPanoramiquesProjet()[iPanoActuel].setbMinLat(nv); }); cbMaxLat.selectedProperty().addListener((ov, av, nv) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); double largeurImage1 = panePanoramique.getPrefWidth(); double X11 = ivImagePanoramique.getLayoutX(); double Y1 = (90.0d - (double) (double) slMaxLat.getValue()) * largeurImage1 / 360.0d; ligZenith.setStartX(X11); ligZenith.setStartY(Y1); ligZenith.setEndX(X11 + largeurImage1); ligZenith.setEndY(Y1); getPanoramiquesProjet()[iPanoActuel].setbMaxLat(nv); }); btnBlocage.setOnAction((e) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); for (int i = 0; i < iNombrePanoramiques; i++) { getPanoramiquesProjet()[i].setbMaxLat(getPanoramiquesProjet()[iPanoActuel].isbMaxLat()); getPanoramiquesProjet()[i].setbMinLat(getPanoramiquesProjet()[iPanoActuel].isbMinLat()); getPanoramiquesProjet()[i].setMaxLat(getPanoramiquesProjet()[iPanoActuel].getMaxLat()); getPanoramiquesProjet()[i].setMinLat(getPanoramiquesProjet()[iPanoActuel].getMinLat()); getPanoramiquesProjet()[i].setFovMax(getPanoramiquesProjet()[iPanoActuel].getFovMax()); getPanoramiquesProjet()[i].setFovMin(getPanoramiquesProjet()[iPanoActuel].getFovMin()); } }); apParametresPano.getChildren().addAll(btnModifiePano, btnSupprimePano, lblTitrePano, tfTitrePano, slMaxLat, cbMaxLat, slMinLat, cbMinLat, slMinFov, lblMinFov, slMaxFov, lblMaxFov, btnBlocage); setApPPAN(new AnchorPane( new PaneOutil(true, rbLocalisation.getString("main.parametresPano"), apParametresPano, largeurOutil) .getApPaneOutil())); setApGEO(new AnchorPane()); apOpenLayers = new AnchorPane(); apOpenLayers.setVisible(false); if (isbInternet()) { navigateurOpenLayers = new NavigateurOpenLayers(); navigateurOpenLayers.setBingApiKey(getStrBingAPIKey()); tfLongitude = new TextField(); tfLatitude = new TextField(); apOpenLayers = navigateurOpenLayers.afficheNavigateurOpenLayer(tfLongitude, tfLatitude, true); apOpenLayers.setPrefSize(800, 600); Button btnGeolocalise = new Button(rbLocalisation.getString("main.geolocalisation")); btnGeolocalise.setLayoutX(10); btnGeolocalise.setLayoutY(25); btnGeolocalise.setPrefWidth(120); btnGeolocalise.setOnAction((e) -> { navigateurOpenLayers.retireMarqueur(0); if (navigateurOpenLayers.getBingApiKey().equals("")) { navigateurOpenLayers.afficheCartesOpenlayer(); } else { navigateurOpenLayers.valideBingApiKey(navigateurOpenLayers.getBingApiKey()); } if (panoramiquesProjet[getiPanoActuel()].getMarqueurGeolocatisation() != null) { navigateurOpenLayers.allerCoordonnees( panoramiquesProjet[getiPanoActuel()].getMarqueurGeolocatisation(), 17); navigateurOpenLayers .setMarqueur(panoramiquesProjet[getiPanoActuel()].getMarqueurGeolocatisation()); String strFichierPano = getPanoramiquesProjet()[getiPanoActuel()].getStrNomFichier() .substring( getPanoramiquesProjet()[getiPanoActuel()].getStrNomFichier() .lastIndexOf(File.separator) + 1, getPanoramiquesProjet()[getiPanoActuel()].getStrNomFichier().length()) .split("\\.")[0]; String strHTML = "<span style='font-family : Verdana,Arial,sans-serif;font-weight:bold;font-size : 12px;'>" + getPanoramiquesProjet()[getiPanoActuel()].getStrTitrePanoramique() + "</span><br/>" + "<span style='font-family : Verdana,Arial,sans-serif;bold;font-size : 10px;'>" + strFichierPano + "</span>"; strHTML = strHTML.replace("\\", "/"); navigateurOpenLayers.ajouteMarqueur(0, panoramiquesProjet[getiPanoActuel()].getMarqueurGeolocatisation(), strHTML); } apOpenLayers.setVisible(true); }); tfLatitude.setLayoutX(140); tfLatitude.setLayoutY(10); tfLongitude.setLayoutX(140); tfLongitude.setLayoutY(40); apOpenLayers.setLayoutX(200); apOpenLayers.setLayoutY(150); apOpenLayers.setVisible(false); AnchorPane apGeolocalise = new AnchorPane(); apGeolocalise.setPrefHeight(75); apGeolocalise.getChildren().addAll(btnGeolocalise, tfLatitude, tfLongitude); apGeolocalise.setLayoutX(10); apGeolocalise.setLayoutY(40); setPoGeolocalisation( new PaneOutil(rbLocalisation.getString("main.geolocalisation"), apGeolocalise, largeurOutil)); setApGEO(new AnchorPane(getPoGeolocalisation().getApPaneOutil())); apOpenLayers.setLayoutX((iLargeur - apOpenLayers.getPrefWidth()) / 2); apOpenLayers.setLayoutY((iHauteur - apOpenLayers.getPrefHeight()) / 2); apOpenLayers.visibleProperty().addListener((ov, av, nv) -> { mbarPrincipal.setDisable(nv); hbBarreBouton.setDisable(nv); tpEnvironnement.setDisable(nv); }); } apVisuPanoramique.setLayoutY(40); apVisuPanoramique.setPrefWidth(340); apVisuPanoramique.setPrefHeight(295); setApVISU(new AnchorPane( new PaneOutil(true, rbLocalisation.getString("main.visualisation"), apVisuPanoramique, largeurOutil) .getApPaneOutil())); vbVisuHotspots = new VBox(); apVisuHS = new AnchorPane(vbVisuHotspots); apVisuHS.setLayoutY(40); apHS1 = new PaneOutil(true, "Hotspots", apVisuHS, largeurOutil); setApHS(new AnchorPane(apHS1.getApPaneOutil())); getVbChoixPanoramique().getChildren().addAll(getApPVIS(), getApAR(), getApPPAN(), getApGEO(), getApVISU(), getApHS()); getVbChoixPanoramique().setSpacing(-5); vbOutils.getChildren().addAll(getVbChoixPanoramique()); getVbChoixPanoramique().setVisible(false); /* Cration du panneau d'info du panoramique */ spVuePanoramique = new ScrollPane(); hbCoordonnees = new HBox(); panePanoramique = new Pane(); apPanneauPrincipal = new AnchorPane(); lblLong = new Label(""); lblLat = new Label(""); ivImagePanoramique = new ImageView(); stPrimaryStage.setScene(getScnPrincipale()); /** * */ spVuePanoramique.setPrefSize(iLargeur - largeurOutils - 20, iHauteur - 110); spVuePanoramique.setMaxSize(iLargeur - largeurOutils - 20, iHauteur - 110); spVuePanoramique.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spVuePanoramique.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spVuePanoramique.setTranslateY(5); /** * */ AnchorPane apPanneauOutils = new AnchorPane(); apPanneauOutils.getChildren().addAll(spPanneauOutils); apPanneauOutils.setTranslateY(3); apPanneauOutils.setTranslateX(20); spPanneauOutils.setContent(vbOutils); spPanneauOutils.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); spPanneauOutils.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spPanneauOutils.setPrefSize(largeurOutils, iHauteur - 112); spPanneauOutils.setMaxWidth(largeurOutils); spPanneauOutils.setMaxHeight(iHauteur - 112); spPanneauOutils.setLayoutY(0); spPanneauOutils.setLayoutX(0); /** * */ panePanoramique.setCursor(Cursor.CROSSHAIR); vbOutils.setPrefWidth(largeurOutils - 20); vbOutils.minHeight(iHauteur - 110); vbOutils.setLayoutX(3); lblLong.setPrefSize(100, 15); lblLat.setPrefSize(100, 15); lblLat.setTranslateX(50); apPanneauPrincipal.setPrefSize(iLargeur - largeurOutils - 20, iHauteur - 110); apListeImagesPanoramiques = new AnchorPane(); apListeImagesPanoramiques.setPrefWidth(iLargeurVignettes + 40); apListeImagesPanoramiques.setMinWidth(iLargeurVignettes + 40); apListeImagesPanoramiques.setMaxWidth(iLargeurVignettes + 40); apListeImagesPanoramiques.setPrefHeight(iHauteur - 140); apListeImagesPanoramiques.setLayoutX(-iLargeurVignettes - 30); apListeImagesPanoramiques.setLayoutY(0); apListeImagesPanoramiques.setStyle("-fx-background-color :rgba(0,0,0,0);"); apListeImagesPanoramiques.setOnMouseEntered((e) -> { apListeImagesPanoramiques.setLayoutX(0); }); apListeImagesPanoramiques.setOnMouseExited((e) -> { apListeImagesPanoramiques.setLayoutX(-iLargeurVignettes - 30); }); Label lblVignettes = new Label(rbLocalisation.getString("main.vignettes")); lblVignettes.setPrefSize(70, 20); lblVignettes.setTextAlignment(TextAlignment.CENTER); lblVignettes.setStyle("-fx-background-color:-fx-base;" + "-fx-border-color: derive(-fx-base,10%);" + "-fx-border-width: 1px;"); lblVignettes.setTranslateX(-lblVignettes.getPrefWidth() / 2 + lblVignettes.getPrefHeight() / 2); lblVignettes.setTranslateY(lblVignettes.getPrefWidth() / 2 - lblVignettes.getPrefHeight() / 2); lblVignettes.setRotate(270); lblVignettes.setLayoutX(iLargeurVignettes + 30); apVignettesPano = new AnchorPane(); apVignettesPano.setPrefWidth(iLargeurVignettes + 10); apVignettesPano.setMinHeight(iHauteur - 140); apVignettesPano.setStyle("-fx-background-color:-fx-base;"); rectVignettePano = new Rectangle(0, 0, iLargeurVignettes, iLargeurVignettes / 2.d); rectVignettePano.setLayoutX(5); rectVignettePano.setLayoutY(10); rectVignettePano.setFill(Color.web("#fff", 0.5)); rectVignettePano.setStroke(Color.WHITE); rectVignettePano.setStrokeWidth(2.0); rectVignettePano.setVisible(false); apVignettesPano.getChildren().add(rectVignettePano); ScrollPane spListeImagesPanoramiques = new ScrollPane(apVignettesPano); spListeImagesPanoramiques.setPrefWidth(iLargeurVignettes + 30); spListeImagesPanoramiques.setPrefHeight(iHauteur - 130); spListeImagesPanoramiques.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); spListeImagesPanoramiques .setStyle("-fx-background-color:-fx-base;" + "-fx-border-color: derive(-fx-base,10%);" + "-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.2) , 8, 0.0 , 0 , 8 );" + "-fx-border-width: 1px;"); apListeImagesPanoramiques.getChildren().addAll(spListeImagesPanoramiques, lblVignettes); ivImagePanoramique.setCache(true); largeur = largeurMax - 60; ivImagePanoramique.setFitWidth(largeur); ivImagePanoramique.setFitHeight(largeur / 2.0d); ivImagePanoramique.setLayoutX((largeurMax - largeur) / 2.d); panePanoramique.getChildren().add(ivImagePanoramique); panePanoramique.setPrefSize(ivImagePanoramique.getFitWidth(), ivImagePanoramique.getFitHeight()); panePanoramique.setMaxSize(ivImagePanoramique.getFitWidth(), ivImagePanoramique.getFitHeight()); panePanoramique.setLayoutY(20); lblLong.setTranslateX(50); lblLat.setTranslateX(80); hbCoordonnees.getChildren().setAll(lblLong, lblLat); spVuePanoramique.setContent(apPanneauPrincipal); hbEnvironnement.getChildren().setAll(spVuePanoramique, apPanneauOutils); apEnvironnement = new AnchorPane(); setApAttends(new AnchorPane()); getApAttends().setPrefHeight(250); getApAttends().setPrefWidth(600); getApAttends().setMaxWidth(600); getApAttends().setStyle("-fx-background-color : -fx-base;" + "-fx-border-color: derive(-fx-base,10%);" + "-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.5) , 8, 0.0 , 0 , 8 );" + "-fx-border-width: 1px;"); getApAttends().setLayoutX((iLargeur - getApAttends().getPrefWidth()) / 2.d); getApAttends().setLayoutY((iHauteur - getApAttends().getPrefHeight()) / 2.d - 55); pbarAvanceChargement = new ProgressBar(); pbarAvanceChargement.setPrefSize(400, 30); pbarAvanceChargement.setLayoutX((getApAttends().getPrefWidth() - pbarAvanceChargement.getPrefWidth()) / 2); pbarAvanceChargement.setLayoutY(70); Label lblAttends = new Label(rbLocalisation.getString("main.attendsChargement")); lblAttends.setMinWidth(600); lblAttends.setAlignment(Pos.CENTER); lblAttends.setStyle("-fx-background-color : #777;"); lblAttends.setTextFill(Color.WHITE); lblAttends.setLayoutY(5); lblAttends.setFont(Font.font(14)); lblCharge = new Label(); lblCharge.setMinWidth(600); lblCharge.setLayoutY(150); lblCharge.setAlignment(Pos.CENTER); lblNiveaux = new Label(); lblNiveaux.setMinWidth(600); lblNiveaux.setLayoutY(180); lblNiveaux.setAlignment(Pos.CENTER); getApAttends().getChildren().addAll(lblAttends, pbarAvanceChargement, lblCharge, lblNiveaux); getApAttends().setVisible(false); apEnvironnement.getChildren().addAll(tpEnvironnement, getApAttends()); if (isMac()) { apEnvironnement.setTranslateY(-30); } vbRacine.getChildren().addAll(apEnvironnement); apPanneauPrincipal.getChildren().setAll(hbCoordonnees, panePanoramique); stPrimaryStage.show(); popUp.affichePopup(); lblDragDrop = new Label(rbLocalisation.getString("main.dragDrop")); lblDragDrop.setMinHeight(spVuePanoramique.getPrefHeight()); lblDragDrop.setMaxHeight(spVuePanoramique.getPrefHeight()); lblDragDrop.setMinWidth(spVuePanoramique.getPrefWidth()); lblDragDrop.setMaxWidth(spVuePanoramique.getPrefWidth()); lblDragDrop.setAlignment(Pos.CENTER); lblDragDrop.setTextFill(Color.web("#c9c7c7")); lblDragDrop.setTextAlignment(TextAlignment.CENTER); lblDragDrop.setWrapText(true); lblDragDrop.setStyle("-fx-font-size:72px"); lblDragDrop.setTranslateY(-100); apLoupe.setLayoutX(35); apLoupe.setLayoutY(35); apLoupe.setVisible(false); apPanneauPrincipal.getChildren().addAll(lblDragDrop, spAfficheLegende(), apLoupe, apListeImagesPanoramiques); apCreationBarre = new AnchorPane(); apCreationBarre.setVisible(false); apCreationDiaporama = new AnchorPane(); apCreationDiaporama.setVisible(false); apEnvironnement.getChildren().addAll(apCreationBarre, apCreationDiaporama, apOpenLayers); }