List of usage examples for javafx.geometry Insets Insets
public Insets(@NamedArg("top") double top, @NamedArg("right") double right, @NamedArg("bottom") double bottom, @NamedArg("left") double left)
From source file:statos2_0.MainA.java
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle(nameseller + "[" + storename + "]"); primaryStage.show();/*from ww w. j a v a 2 s. co 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:mesclasses.view.JourneeController.java
/** * dessine la grid sanctions/*from ww w. j a v a 2 s. co m*/ * @param eleve * @param rowIndex */ private void drawSanctions(Eleve eleve, int rowIndex) { EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve); drawEleveName(sanctionsGrid, eleve, rowIndex); if (!eleve.isInClasse(currentDate.getValue())) { return; } HBox punitionsBox = new HBox(); punitionsBox.setAlignment(Pos.CENTER_LEFT); TextFlow nbPunitions = new TextFlow(); Label nbPunitionLabel = new Label( "" + eleve.getPunitions().stream().filter(p -> p.getSeance() == seanceSelect.getValue()).count()); nbPunitionLabel.setPrefHeight(20); nbPunitions.getChildren().add(new Label(" (")); nbPunitions.getChildren().add(nbPunitionLabel); nbPunitions.getChildren().add(new Label(")")); nbPunitions.visibleProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0")); nbPunitions.managedProperty().bind(nbPunitionLabel.textProperty().isNotEqualTo("0")); Button punitionBtn = Btns.punitionBtn(); punitionBtn.setOnAction((event) -> { if (openPunitionDialog(eleve)) { int nbPunition = Integer.parseInt(nbPunitionLabel.getText()); nbPunitionLabel.setText("" + (nbPunition + 1)); } }); punitionsBox.getChildren().add(punitionBtn); punitionsBox.getChildren().add(nbPunitions); sanctionsGrid.add(punitionsBox, 3, rowIndex, HPos.LEFT); CheckBox motCarnet = new CheckBox(); Label cumulMot = new Label(); motCarnet.setSelected(model.getMotForSeance(eleve, seanceSelect.getValue()) != null); motCarnet.selectedProperty().addListener((ob, o, checked) -> { Mot mot = model.getMotForSeance(eleve, seanceSelect.getValue()); if (checked && mot == null) { model.createMot(eleve, seanceSelect.getValue()); } else if (mot != null) { model.delete(mot); } writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3); }); sanctionsGrid.add(motCarnet, 4, rowIndex, null); writeAndMarkInRed(cumulMot, stats.getMotsUntil(eleve, currentDate.getValue()).size(), 3); sanctionsGrid.add(cumulMot, 5, rowIndex, null); CheckBox exclus = new CheckBox(); TextField motif = new TextField(); Bindings.bindBidirectional(exclus.selectedProperty(), eleveData.exclusProperty()); sanctionsGrid.add(exclus, 6, rowIndex, null); exclus.selectedProperty().addListener((o, oldV, newV) -> { if (!newV && StringUtils.isNotBlank(motif.getText()) && ModalUtil.confirm("Effacer le motif ?", "Effacer le motif ?")) { motif.clear(); } }); Bindings.bindBidirectional(motif.textProperty(), eleveData.MotifProperty()); motif.textProperty().addListener((o, oldV, newV) -> { if (StringUtils.isNotBlank(newV)) { exclus.setSelected(true); } }); GridPane.setMargin(motif, new Insets(0, 10, 0, 0)); sanctionsGrid.add(motif, 7, rowIndex, HPos.LEFT); }
From source file:com.chart.SwingChart.java
/** * Background edition//from w w w .j a va2 s. c o m */ final public void backgroundEdition() { final ColorPicker colorPickerChartBackground = new ColorPicker( javafx.scene.paint.Color.web(strChartBackgroundColor)); colorPickerChartBackground.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerGridline = new ColorPicker(javafx.scene.paint.Color.web(strGridlineColor)); colorPickerGridline.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerBackground = new ColorPicker(javafx.scene.paint.Color.web(strBackgroundColor)); colorPickerBackground.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerTick = new ColorPicker(javafx.scene.paint.Color.web(strTickColor)); colorPickerTick.setMaxWidth(Double.MAX_VALUE); final TextField tfFontSize = new TextField(); tfFontSize.setMaxWidth(Double.MAX_VALUE); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); grid.add(new Label("Background color"), 0, 0); grid.add(colorPickerChartBackground, 1, 0); grid.add(new Label("Gridline color"), 0, 1); grid.add(colorPickerGridline, 1, 1); grid.add(new Label("Frame color"), 0, 2); grid.add(colorPickerBackground, 1, 2); grid.add(new Label("Tick color"), 0, 3); grid.add(colorPickerTick, 1, 3); grid.add(new Label("Font size"), 0, 4); grid.add(tfFontSize, 1, 4); tfFontSize.setText(String.valueOf(fontSize)); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { fontSize = Float.valueOf(tfFontSize.getText().replace(",", ".")); strBackgroundColor = colorPickerBackground.getValue().toString().replace("0x", "#"); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; } } chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder( scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))))); chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); legendFrame.setStyle("marco: " + colorPickerBackground.getValue().toString().replace("0x", "#") + ";-fx-background-color: marco;"); strChartBackgroundColor = colorPickerChartBackground.getValue().toString().replace("0x", "#"); plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor))); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { ((Label) nn).setStyle("fondo: " + colorPickerChartBackground.getValue().toString().replace("0x", "#") + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: " + String.valueOf(fontSize) + "px"); } } } } strGridlineColor = colorPickerGridline.getValue().toString().replace("0x", "#"); plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); strTickColor = colorPickerTick.getValue().toString().replace("0x", "#"); abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); abcissaAxis.setTickLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); for (NumberAxis ejeOrdenada : AxesList) { ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); ejeOrdenada.setTickLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); } return true; } }.show(); }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private Pane createSidePane() { BorderPane pane = new BorderPane(); TabPane tabPane = new TabPane(); kmDisplay = new KaplanMeierDisplay(null, null, null, null); BorderPane paneKaplanMeier = new BorderPane(); paneKaplanMeier.setCenter(kmDisplay.getView()); paneKaplanMeier.setPadding(new Insets(10, 10, 10, 10)); // comboMainMeasurement.prefWidthProperty().bind(paneKaplanMeier.widthProperty()); comboMainMeasurement.setMaxWidth(Double.MAX_VALUE); comboMainMeasurement.setTooltip(new Tooltip("Measurement thresholded to create survival curves etc.")); GridPane kmTop = new GridPane(); kmTop.add(new Label("Score"), 0, 0); kmTop.add(comboMainMeasurement, 1, 0); kmTop.add(new Label("Survival type"), 0, 1); kmTop.add(comboSurvival, 1, 1);/* ww w .ja v a 2 s .c o m*/ comboSurvival.setTooltip(new Tooltip("Specify overall or recurrence-free survival (if applicable)")); comboSurvival.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(comboMainMeasurement, Priority.ALWAYS); GridPane.setHgrow(comboSurvival, Priority.ALWAYS); kmTop.setHgap(5); paneKaplanMeier.setTop(kmTop); // kmDisplay.setOrientation(Orientation.VERTICAL); histogramDisplay = new HistogramDisplay(model, false); comboMainMeasurement.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshCombo(); histogramDisplay.showHistogram(n); updateSurvivalCurves(); }); comboMeasurementMethod.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshHistogram(); scatterPane.updateChart(); updateSurvivalCurves(); }); comboSurvival.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { updateSurvivalCurves(); }); // Create a Tab for showing images BorderPane paneImages = new BorderPane(); CheckBox cbShowOverlay = new CheckBox("Show overlay"); imageAvailability.addListener((c, v, n) -> { if (n == ImageAvailability.OVERLAY_ONLY) cbShowOverlay.setSelected(true); else if (n == ImageAvailability.IMAGE_ONLY) cbShowOverlay.setSelected(false); cbShowOverlay.setDisable(n != ImageAvailability.BOTH); }); ListView<TMAEntry> listImages = new ListView<>(); listImages.setCellFactory(v -> new ImageListCell(cbShowOverlay.selectedProperty(), imageCache)); listImages.widthProperty().addListener((v, o, n) -> listImages.refresh()); listImages.setStyle("-fx-control-inner-background-alt: -fx-control-inner-background ;"); table.getSelectionModel().getSelectedItems().addListener((Change<? extends TreeItem<TMAEntry>> e) -> { List<TMAEntry> entries = new ArrayList<>(); for (TreeItem<TMAEntry> item : e.getList()) { if (item.getChildren().isEmpty()) { if (item.getValue().hasImage() || item.getValue().hasOverlay()) entries.add(item.getValue()); } else { for (TreeItem<TMAEntry> item2 : item.getChildren()) { if (item2.getValue().hasImage() || item2.getValue().hasOverlay()) entries.add(item2.getValue()); } } listImages.getItems().setAll(entries); } }); cbShowOverlay.setAlignment(Pos.CENTER); cbShowOverlay.setMaxWidth(Double.MAX_VALUE); cbShowOverlay.setPadding(new Insets(5, 5, 5, 5)); cbShowOverlay.selectedProperty().addListener((v, o, n) -> listImages.refresh()); paneImages.setCenter(listImages); paneImages.setTop(cbShowOverlay); // Determine visibility based upon whether there are any images to show // Tab tabImages = new Tab("Images", paneImages); ScrollPane scrollPane = new ScrollPane(paneKaplanMeier); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED); Tab tabSurvival = new Tab("Survival", scrollPane); tabPane.getTabs().addAll(new Tab("Table", getCustomizeTablePane()), // tabImages, new Tab("Histogram", histogramDisplay.getPane()), new Tab("Scatterplot", scatterPane.getPane()), tabSurvival); tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); // if (imageAvailability.get() != ImageAvailability.NONE) // tabPane.getTabs().add(1, tabImages); // // imageAvailability.addListener((c, v, n) -> { // if (n == ImageAvailability.NONE) // tabPane.getTabs().remove(tabImages); // else if (!tabPane.getTabs().contains(tabImages)) // tabPane.getTabs().add(1, tabImages); // }); // tabSurvival.visibleProperty().bind( // Bindings.createBooleanBinding(() -> !survivalColumns.isEmpty(), survivalColumns) // ); pane.setCenter(tabPane); pane.setMinWidth(350); return pane; }
From source file:com.chart.SwingChart.java
/** * Set lower and upper limits for an ordinate * @param axis Axis to configure//w w w . ja va 2s. co m */ void setOrdinateRange(final NumberAxis axis) { axis.setAutoRange(false); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); final TextField tfMax; final TextField tfMin; final TextField tfTick; final TextField tfFuente; grid.add(new Label("Axis"), 0, 0); grid.add(new Label(axis.getLabel()), 1, 0); grid.add(new Label("Lower"), 0, 1); grid.add(tfMin = new TextField(), 1, 1); grid.add(new Label("Upper"), 0, 2); grid.add(tfMax = new TextField(), 1, 2); grid.add(new Label("Space"), 0, 3); grid.add(tfTick = new TextField(), 1, 3); tfMin.setText(String.valueOf(axis.getLowerBound())); tfMax.setText(String.valueOf(axis.getUpperBound())); tfTick.setText(String.valueOf(axis.getTickUnit().getSize())); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { axis.setLowerBound(Double.valueOf(tfMin.getText())); axis.setUpperBound(Double.valueOf(tfMax.getText())); axis.setTickUnit(new NumberTickUnit(Double.valueOf(tfTick.getText()))); return true; } }.show(); }
From source file:Main.java
private TitledPane getEffectTitledPane() { noneEffect.setToggleGroup(effectGroup); noneEffect.setSelected(true);/*from www .ja va 2 s .co m*/ dropshadowEffect.setToggleGroup(effectGroup); reflectionEffect.setToggleGroup(effectGroup); glowEffect.setToggleGroup(effectGroup); HBox hBox = new HBox(); hBox.setPadding(new Insets(5, 5, 5, 5)); hBox.getChildren().addAll(noneEffect, dropshadowEffect, reflectionEffect, glowEffect); TitledPane effectsPane = new TitledPane("Effect", hBox); return effectsPane; }
From source file:qupath.lib.gui.panels.survival.KaplanMeierDisplay.java
@SuppressWarnings("unchecked") private void generatePlot() { KaplanMeierDisplay.ScoreData newScoreData = scoreData; // If we have a hierarchy, update the scores with the most recent data if (hierarchy != null) { List<TMACoreObject> cores = PathObjectTools.getTMACoreObjects(hierarchy, false); double[] survival = new double[cores.size()]; boolean[] censored = new boolean[cores.size()]; double[] scores = new double[cores.size()]; // // Optionally sort by scores... helps a bit when debugging e.g. p-values, Hazard ratios etc. // cores.sort((c1, c2) -> Double.compare(c1.getMeasurementList().getMeasurementValue(scoreColumn), c2.getMeasurementList().getMeasurementValue(scoreColumn))); // scoreColumn = "Positive %"; // scoreColumn = "RoughScore"; for (int i = 0; i < cores.size(); i++) { TMACoreObject core = cores.get(i); MeasurementList ml = core.getMeasurementList(); survival[i] = core.getMeasurementList().getMeasurementValue(survivalColumn); double censoredValue = core.getMeasurementList().getMeasurementValue(censoredColumn); boolean hasCensoredValue = !Double.isNaN(censoredValue) && (censoredValue == 0 || censoredValue == 1); censored[i] = censoredValue != 0; if (!hasCensoredValue) { // If we don't have a censored value, ensure we mask out everything else scores[i] = Double.NaN; survival[i] = Double.NaN; } else if (ml.containsNamedMeasurement(scoreColumn)) // Get the score if we can scores[i] = ml.getMeasurementValue(scoreColumn); else { // // Try to compute score if we need to // Map<String, Number> map = ROIMeaningfulMeasurements.getPathClassSummaryMeasurements(core.getChildObjects(), true); // Number value = map.get(scoreColumn); // if (value == null) scores[i] = Double.NaN; // else // scores[i] = value.doubleValue(); }/*www .j ava2 s. com*/ } // Mask out any scores that don't have associated survival data for (int i = 0; i < survival.length; i++) { if (Double.isNaN(survival[i])) scores[i] = Double.NaN; } newScoreData = new ScoreData(scores, survival, censored); } if (newScoreData == null || newScoreData.scores.length == 0) return; // KaplanMeier kmHigh = new KaplanMeier("Above threshold"); // KaplanMeier kmLow = new KaplanMeier("Below threshold"); double[] quartiles = StatisticsHelper.getQuartiles(newScoreData.scores); double q1 = quartiles[0]; double median = quartiles[1]; double q3 = quartiles[2]; double[] thresholds; if (params != null) { Object thresholdMethod = params.getChoiceParameterValue("scoreThresholdMethod"); if (thresholdMethod.equals("Median")) { // panelParams.setNumericParameterValue("scoreThreshold", median); // ((DoubleParameter)params.getParameters().get("scoreThreshold")).setValue(median); // TODO: UPDATE DIALOG! thresholds = new double[] { median }; } else if (thresholdMethod.equals("Tertiles")) { // ((DoubleParameter)params.getParameters().get("scoreThreshold")).setValue(median); // TODO: UPDATE DIALOG! thresholds = StatisticsHelper.getTertiles(newScoreData.scores); } else if (thresholdMethod.equals("Quartiles")) { // ((DoubleParameter)params.getParameters().get("scoreThreshold")).setValue(median); // TODO: UPDATE DIALOG! thresholds = new double[] { q1, median, q3 }; } else if (thresholdMethod.equals("Manual (1)")) { thresholds = new double[] { params.getDoubleParameterValue("threshold1") }; } else if (thresholdMethod.equals("Manual (2)")) { thresholds = new double[] { params.getDoubleParameterValue("threshold1"), params.getDoubleParameterValue("threshold2") }; } else //if (thresholdMethod.equals("Manual (3)")) { thresholds = new double[] { params.getDoubleParameterValue("threshold1"), params.getDoubleParameterValue("threshold2"), params.getDoubleParameterValue("threshold3") }; } else thresholds = new double[] { median }; double minVal = Double.POSITIVE_INFINITY; double maxVal = Double.NEGATIVE_INFINITY; int numNonNaN = 0; for (double d : newScoreData.scores) { if (Double.isNaN(d)) continue; if (d < minVal) minVal = d; if (d > maxVal) maxVal = d; numNonNaN++; } boolean scoresValid = maxVal > minVal; // If not this, we don't have valid scores that we can work with double maxTimePoint = 0; for (double d : newScoreData.survival) { if (Double.isNaN(d)) continue; if (d > maxTimePoint) maxTimePoint = d; } if (panelParams != null && maxTimePoint > ((IntParameter) params.getParameters().get("censorTimePoints")).getUpperBound()) { panelParams.setNumericParameterValueRange("censorTimePoints", 0, Math.ceil(maxTimePoint)); } // Optionally censor at specified time double censorThreshold = params == null ? maxTimePoint : params.getIntParameterValue("censorTimePoints"); // Compute log-rank p-values for *all* possible thresholds // Simultaneously determine the threshold that yields the lowest p-value, // resolving ties in favour of a more even split between high/low numbers of events boolean pValuesChanged = false; if (calculateAllPValues) { if (!(pValues != null && pValueThresholds != null && newScoreData.equals(scoreData) && censorThreshold == lastPValueCensorThreshold)) { Map<Double, Double> mapLogRank = new TreeMap<>(); Set<Double> setObserved = new HashSet<>(); for (int i = 0; i < newScoreData.scores.length; i++) { Double d = newScoreData.scores[i]; boolean observed = !newScoreData.censored[i] && newScoreData.survival[i] < censorThreshold; if (observed) setObserved.add(d); if (mapLogRank.containsKey(d)) continue; List<KaplanMeierData> kmsTemp = splitByThresholds(newScoreData, new double[] { d }, censorThreshold, false); // if (kmsTemp.get(1).nObserved() == 0 || kmsTemp.get(1).nObserved() == 0) // continue; LogRankResult test = LogRankTest.computeLogRankTest(kmsTemp.get(0), kmsTemp.get(1)); double pValue = test.getPValue(); // double pValue = test.hazardRatio < 1 ? test.hazardRatio : 1.0/test.hazardRatio; // Checking usefulness of Hazard ratios... if (!Double.isFinite(pValue)) continue; // if (!Double.isFinite(test.getHazardRatio())) { //// continue; // pValue = Double.NaN; // } mapLogRank.put(d, pValue); } pValueThresholds = new double[mapLogRank.size()]; pValues = new double[mapLogRank.size()]; pValueThresholdsObserved = new boolean[mapLogRank.size()]; int count = 0; for (Entry<Double, Double> entry : mapLogRank.entrySet()) { pValueThresholds[count] = entry.getKey(); pValues[count] = entry.getValue(); if (setObserved.contains(entry.getKey())) pValueThresholdsObserved[count] = true; count++; } // Find the longest 'significant' stretch int maxSigCount = 0; int maxSigInd = -1; int sigCurrent = 0; int[] sigCount = new int[pValues.length]; for (int i = 0; i < pValues.length; i++) { if (pValues[i] < 0.05) { sigCurrent++; sigCount[i] = sigCurrent; if (sigCurrent > maxSigCount) { maxSigCount = sigCurrent; maxSigInd = i; } } else sigCurrent = 0; } if (maxSigCount == 0) { logger.info("No p-values < 0.05"); } else { double minThresh = maxSigInd - maxSigCount < 0 ? pValueThresholds[0] - 0.0000001 : pValueThresholds[maxSigInd - maxSigCount]; double maxThresh = pValueThresholds[maxSigInd]; int nBetween = 0; int nBetweenObserved = 0; for (int i = 0; i < newScoreData.scores.length; i++) { if (newScoreData.scores[i] > minThresh && newScoreData.scores[i] <= maxThresh) { nBetween++; if (newScoreData.survival[i] < censorThreshold && !newScoreData.censored[i]) nBetweenObserved++; } } logger.info("Longest stretch of p-values < 0.05: {} - {} ({} entries, {} observed)", minThresh, maxThresh, nBetween, nBetweenObserved); } pValuesSmoothed = new double[pValues.length]; Arrays.fill(pValuesSmoothed, Double.NaN); int n = (pValues.length / 20) * 2 + 1; logger.info("Smoothing log-rank test p-values by " + n); for (int i = n / 2; i < pValues.length - n / 2; i++) { double sum = 0; for (int k = i - n / 2; k < i - n / 2 + n; k++) { sum += pValues[k]; } pValuesSmoothed[i] = sum / n; } // for (int i = 0; i < pValues.length; i++) { // double sum = 0; // for (int k = Math.max(0, i-n/2); k < Math.min(pValues.length, i-n/2+n); k++) { // sum += pValues[k]; // } // pValuesSmoothed[i] = sum/n; // } // pValues = pValuesSmoothed; lastPValueCensorThreshold = censorThreshold; pValuesChanged = true; } } else { lastPValueCensorThreshold = Double.NaN; pValueThresholds = null; pValues = null; } // if (params != null && !Double.isNaN(bestThreshold) && (params.getChoiceParameterValue("scoreThresholdMethod").equals("Lowest p-value"))) if (params != null && (params.getChoiceParameterValue("scoreThresholdMethod").equals("Lowest p-value"))) { int bestIdx = -1; double bestPValue = Double.POSITIVE_INFINITY; for (int i = pValueThresholds.length / 10; i < pValueThresholds.length * 9 / 10; i++) { if (pValues[i] < bestPValue) { bestIdx = i; bestPValue = pValues[i]; } } thresholds = bestIdx >= 0 ? new double[] { pValueThresholds[bestIdx] } : new double[0]; } else if (params != null && (params.getChoiceParameterValue("scoreThresholdMethod").equals("Lowest smoothed p-value"))) { int bestIdx = -1; double bestPValue = Double.POSITIVE_INFINITY; for (int i = pValueThresholds.length / 10; i < pValueThresholds.length * 9 / 10; i++) { if (pValuesSmoothed[i] < bestPValue) { bestIdx = i; bestPValue = pValuesSmoothed[i]; } } thresholds = bestIdx >= 0 ? new double[] { pValueThresholds[bestIdx] } : new double[0]; } // Split into different curves using the provided thresholds List<KaplanMeierData> kms = splitByThresholds(newScoreData, thresholds, censorThreshold, params != null && "Quartiles".equals(params.getChoiceParameterValue("scoreThresholdMethod"))); // for (KaplanMeier km : kms) // km.censorAtTime(censorThreshold); //// kmHigh.censorAtTime(censorThreshold); //// kmLow.censorAtTime(censorThreshold); // logger.info("High: " + kmHigh.toString()); // logger.info("Low: " + kmLow.toString()); // logger.info("Log rank comparison: {}", LogRankTest.computeLogRankTest(kmLow, kmHigh)); if (plotter == null) { plotter = new KaplanMeierChartWrapper(survivalColumn + " time"); // plotter.setBorder(BorderFactory.createTitledBorder("Survival plot")); // plotter.getCanvas().setWidth(300); // plotter.getCanvas().setHeight(300); } KaplanMeierData[] kmArray = new KaplanMeierData[kms.size()]; plotter.setKaplanMeierCurves(survivalColumn + " time", kms.toArray(kmArray)); tableModel.setSurvivalCurves(thresholds, params != null && params.getChoiceParameterValue("scoreThresholdMethod").equals("Lowest p-value"), kmArray); // Bar width determined using 'Freedman and Diaconis' rule' (but overridden if this gives < 16 bins...) double barWidth = (2 * q3 - q1) * Math.pow(numNonNaN, -1.0 / 3.0); int nBins = 100; if (!Double.isNaN(barWidth)) barWidth = (int) Math.max(16, Math.ceil((maxVal - minVal) / barWidth)); Histogram histogram = scoresValid ? new Histogram(newScoreData.scores, nBins) : null; if (histogramPanel == null) { GridPane paneHistogram = new GridPane(); histogramPanel = new HistogramPanelFX(); histogramPanel.getChart().setAnimated(false); histogramWrapper = new ThresholdedChartWrapper(histogramPanel.getChart()); for (ObservableNumberValue val : threshProperties) histogramWrapper.addThreshold(val, ColorToolsFX.getCachedColor(240, 0, 0, 128)); histogramWrapper.getPane().setPrefHeight(150); paneHistogram.add(histogramWrapper.getPane(), 0, 0); Tooltip.install(histogramPanel.getChart(), new Tooltip("Distribution of scores")); GridPane.setHgrow(histogramWrapper.getPane(), Priority.ALWAYS); GridPane.setVgrow(histogramWrapper.getPane(), Priority.ALWAYS); NumberAxis xAxis = new NumberAxis(); xAxis.setLabel("Score threshold"); NumberAxis yAxis = new NumberAxis(); yAxis.setLowerBound(0); yAxis.setUpperBound(1); yAxis.setTickUnit(0.1); yAxis.setAutoRanging(false); yAxis.setLabel("P-value"); chartPValues = new LineChart<>(xAxis, yAxis); chartPValues.setAnimated(false); chartPValues.setLegendVisible(false); // Make chart so it can be navigated ChartToolsFX.makeChartInteractive(chartPValues, xAxis, yAxis); pValuesChanged = true; Tooltip.install(chartPValues, new Tooltip( "Distribution of p-values (log-rank test) comparing low vs. high for all possible score thresholds")); // chartPValues.getYAxis().setAutoRanging(false); pValuesWrapper = new ThresholdedChartWrapper(chartPValues); for (ObservableNumberValue val : threshProperties) pValuesWrapper.addThreshold(val, ColorToolsFX.getCachedColor(240, 0, 0, 128)); pValuesWrapper.getPane().setPrefHeight(150); paneHistogram.add(pValuesWrapper.getPane(), 0, 1); GridPane.setHgrow(pValuesWrapper.getPane(), Priority.ALWAYS); GridPane.setVgrow(pValuesWrapper.getPane(), Priority.ALWAYS); ContextMenu popup = new ContextMenu(); ChartToolsFX.addChartExportMenu(chartPValues, popup); RadioMenuItem miZoomY1 = new RadioMenuItem("0-1"); miZoomY1.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(1); yAxis.setTickUnit(0.2); }); RadioMenuItem miZoomY05 = new RadioMenuItem("0-0.5"); miZoomY05.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.5); yAxis.setTickUnit(0.1); }); RadioMenuItem miZoomY02 = new RadioMenuItem("0-0.2"); miZoomY02.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.2); yAxis.setTickUnit(0.05); }); RadioMenuItem miZoomY01 = new RadioMenuItem("0-0.1"); miZoomY01.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.1); yAxis.setTickUnit(0.05); }); RadioMenuItem miZoomY005 = new RadioMenuItem("0-0.05"); miZoomY005.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.05); yAxis.setTickUnit(0.01); }); RadioMenuItem miZoomY001 = new RadioMenuItem("0-0.01"); miZoomY001.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.01); yAxis.setTickUnit(0.005); }); ToggleGroup tgZoom = new ToggleGroup(); miZoomY1.setToggleGroup(tgZoom); miZoomY05.setToggleGroup(tgZoom); miZoomY02.setToggleGroup(tgZoom); miZoomY01.setToggleGroup(tgZoom); miZoomY005.setToggleGroup(tgZoom); miZoomY001.setToggleGroup(tgZoom); Menu menuZoomY = new Menu("Set y-axis range"); menuZoomY.getItems().addAll(miZoomY1, miZoomY05, miZoomY02, miZoomY01, miZoomY005, miZoomY001); MenuItem miCopyData = new MenuItem("Copy chart data"); miCopyData.setOnAction(e -> { String dataString = ChartToolsFX.getChartDataAsString(chartPValues); ClipboardContent content = new ClipboardContent(); content.putString(dataString); Clipboard.getSystemClipboard().setContent(content); }); popup.getItems().addAll(miCopyData, menuZoomY); chartPValues.setOnContextMenuRequested(e -> { popup.show(chartPValues, e.getScreenX(), e.getScreenY()); }); for (int col = 0; col < tableModel.getColumnCount(); col++) { TableColumn<Integer, String> column = new TableColumn<>(tableModel.getColumnName(col)); int colNumber = col; column.setCellValueFactory( new Callback<CellDataFeatures<Integer, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<Integer, String> p) { return new SimpleStringProperty( (String) tableModel.getValueAt(p.getValue(), colNumber)); } }); column.setCellFactory(new Callback<TableColumn<Integer, String>, TableCell<Integer, String>>() { @Override public TableCell<Integer, String> call(TableColumn<Integer, String> param) { TableCell<Integer, String> cell = new TableCell<Integer, String>() { @Override protected void updateItem(String item, boolean empty) { super.updateItem(item, empty); setText(item); setTooltip(new Tooltip(item)); } }; return cell; } }); table.getColumns().add(column); } table.setPrefHeight(250); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); table.maxHeightProperty().bind(table.prefHeightProperty()); params = new ParameterList(); // maxTimePoint = 0; // for (TMACoreObject core : hierarchy.getTMAGrid().getTMACoreList()) { // double os = core.getMeasurementList().getMeasurementValue(TMACoreObject.KEY_OVERALL_SURVIVAL); // double rfs = core.getMeasurementList().getMeasurementValue(TMACoreObject.KEY_RECURRENCE_FREE_SURVIVAL); // if (os > maxTimePoint) // maxTimePoint = os; // if (rfs > maxTimePoint) // maxTimePoint = rfs; // } params.addIntParameter("censorTimePoints", "Max censored time", (int) (censorThreshold + 0.5), null, 0, (int) Math.ceil(maxTimePoint), "Latest time point beyond which data will be censored"); // params.addChoiceParameter("scoreThresholdMethod", "Threshold method", "Manual", Arrays.asList("Manual", "Median", "Log-rank test")); if (calculateAllPValues) // Don't include "Lowest smoothed p-value" - it's not an established method and open to misinterpretation... params.addChoiceParameter("scoreThresholdMethod", "Threshold method", "Median", Arrays.asList("Manual (1)", "Manual (2)", "Manual (3)", "Median", "Tertiles", "Quartiles", "Lowest p-value")); // params.addChoiceParameter("scoreThresholdMethod", "Threshold method", "Median", Arrays.asList("Manual (1)", "Manual (2)", "Manual (3)", "Median", "Tertiles", "Quartiles", "Lowest p-value", "Lowest smoothed p-value")); else params.addChoiceParameter("scoreThresholdMethod", "Threshold method", "Median", Arrays.asList("Manual (1)", "Manual (2)", "Manual (3)", "Median", "Tertiles", "Quartiles")); params.addDoubleParameter("threshold1", "Threshold 1", thresholds.length > 0 ? thresholds[0] : (minVal + maxVal) / 2, null, "Threshold to distinguish between patient groups"); params.addDoubleParameter("threshold2", "Threshold 2", thresholds.length > 1 ? thresholds[1] : (minVal + maxVal) / 2, null, "Threshold to distinguish between patient groups"); params.addDoubleParameter("threshold3", "Threshold 3", thresholds.length > 2 ? thresholds[2] : (minVal + maxVal) / 2, null, "Threshold to distinguish between patient groups"); params.addBooleanParameter("showAtRisk", "Show at risk", plotter.getShowAtRisk(), "Show number of patients at risk below the plot"); params.addBooleanParameter("showTicks", "Show censored ticks", plotter.getShowCensoredTicks(), "Show ticks to indicate censored data"); params.addBooleanParameter("showKey", "Show key", plotter.getShowKey(), "Show key indicating display of each curve"); // params.addBooleanParameter("useColor", "Use color", plotter.getUseColor(), "Show each curve in a different color"); // params.addBooleanParameter("useStrokes", "Use strokes", plotter.getUseStrokes(), "Show each curve with a differed line stroke"); // Hide threshold parameters if threshold can't be used if (!scoresValid) { // params.setHiddenParameters(true, "scoreThresholdMethod", "scoreThreshold"); histogramPanel.getChart().setVisible(false); } panelParams = new ParameterPanelFX(params); panelParams.addParameterChangeListener(this); updateThresholdsEnabled(); for (int i = 0; i < threshProperties.length; i++) { String p = "threshold" + (i + 1); threshProperties[i].addListener((v, o, n) -> { if (interactiveThresholds()) { // Need to do a decent double check with tolerance to text field value changing while typing if (!GeneralTools.almostTheSame(params.getDoubleParameterValue(p), n.doubleValue(), 0.0001)) panelParams.setNumericParameterValue(p, n); } }); } BorderPane paneBottom = new BorderPane(); TitledPane paneOptions = new TitledPane("Options", panelParams.getPane()); // paneOptions.setCollapsible(false); Pane paneCanvas = new StackPane(); paneCanvas.getChildren().add(plotter.getCanvas()); GridPane paneLeft = new GridPane(); paneLeft.add(paneOptions, 0, 0); paneLeft.add(table, 0, 1); GridPane.setHgrow(paneOptions, Priority.ALWAYS); GridPane.setHgrow(table, Priority.ALWAYS); paneBottom.setLeft(paneLeft); paneBottom.setCenter(paneHistogram); paneMain.setCenter(paneCanvas); paneMain.setBottom(paneBottom); paneMain.setPadding(new Insets(10, 10, 10, 10)); } else if (thresholds.length > 0) { // Ensure the sliders/text fields are set sensibly if (!GeneralTools.almostTheSame(thresholds[0], params.getDoubleParameterValue("threshold1"), 0.0001)) { panelParams.setNumericParameterValue("threshold1", thresholds[0]); } if (thresholds.length > 1 && !GeneralTools.almostTheSame(thresholds[1], params.getDoubleParameterValue("threshold2"), 0.0001)) { panelParams.setNumericParameterValue("threshold2", thresholds[1]); } if (thresholds.length > 2 && !GeneralTools.almostTheSame(thresholds[2], params.getDoubleParameterValue("threshold3"), 0.0001)) { panelParams.setNumericParameterValue("threshold3", thresholds[2]); } } if (histogram != null) { histogramPanel.getHistogramData() .setAll(HistogramPanelFX.createHistogramData(histogram, false, (Color) null)); histogramPanel.getChart().getXAxis().setLabel(scoreColumn); histogramPanel.getChart().getYAxis().setLabel("Count"); ChartToolsFX.addChartExportMenu(histogramPanel.getChart(), null); // histogramWrapper.setVerticalLines(thresholds, ColorToolsFX.getCachedColor(240, 0, 0, 128)); // Deal with threshold adjustment // histogramWrapper.getThresholds().addListener((Observable o) -> generatePlot()); } if (pValues != null) { // TODO: Raise earlier where p-value calculation is if (pValuesChanged) { ObservableList<XYChart.Data<Number, Number>> data = FXCollections.observableArrayList(); for (int i = 0; i < pValueThresholds.length; i++) { double pValue = pValues[i]; if (Double.isNaN(pValue)) continue; data.add(new XYChart.Data<>(pValueThresholds[i], pValue, pValueThresholdsObserved[i])); } ObservableList<XYChart.Data<Number, Number>> dataSmoothed = null; if (pValuesSmoothed != null) { dataSmoothed = FXCollections.observableArrayList(); for (int i = 0; i < pValueThresholds.length; i++) { double pValueSmoothed = pValuesSmoothed[i]; if (Double.isNaN(pValueSmoothed)) continue; dataSmoothed.add(new XYChart.Data<>(pValueThresholds[i], pValueSmoothed)); } } // Don't bother showing the smoothed data... it tends to get in the way... // if (dataSmoothed != null) // chartPValues.getData().setAll(new XYChart.Series<>("P-values", data), new XYChart.Series<>("Smoothed P-values", dataSmoothed)); // else chartPValues.getData().setAll(new XYChart.Series<>("P-values", data)); // Add line to show 0.05 significance threshold if (pValueThresholds.length > 1) { Data<Number, Number> sigData1 = new Data<>(pValueThresholds[0], 0.05); Data<Number, Number> sigData2 = new Data<>(pValueThresholds[pValueThresholds.length - 1], 0.05); XYChart.Series<Number, Number> dataSignificant = new XYChart.Series<>("Signficance 0.05", FXCollections.observableArrayList(sigData1, sigData2)); chartPValues.getData().add(dataSignificant); sigData1.getNode().setVisible(false); sigData2.getNode().setVisible(false); } // chartPValues.getData().get(0).getNode().setVisible(true); // pValuesWrapper.clearThresholds(); for (XYChart.Data<Number, Number> dataPoint : data) { if (!Boolean.TRUE.equals(dataPoint.getExtraValue())) dataPoint.getNode().setVisible(false); } // if (dataSmoothed != null) { // for (XYChart.Data<Number, Number> dataPoint : dataSmoothed) { // dataPoint.getNode().setVisible(false); // } // chartPValues.getData().get(1).getNode().setOpacity(0.5); // } // int count = 0; // for (int i = 0; i < pValueThresholds.length; i++) { // double pValue = pValues[i]; // if (Double.isNaN(pValue)) // continue; // boolean observed = pValueThresholdsObserved[i]; //// if (observed) //// pValuesWrapper.addThreshold(new ReadOnlyDoubleWrapper(pValueThresholds[i]), Color.rgb(0, 0, 0, 0.05)); // // if (!observed) { //// StackPane pane = (StackPane)data.get(count).getNode(); //// pane.setEffect(new DropShadow()); // data.get(count).getNode().setVisible(false); // } // count++; // } } for (int i = 0; i < threshProperties.length; i++) { if (i < thresholds.length) threshProperties[i].set(thresholds[i]); else threshProperties[i].set(Double.NaN); } boolean isInteractive = interactiveThresholds(); histogramWrapper.setIsInteractive(isInteractive); pValuesWrapper.setIsInteractive(isInteractive); chartPValues.setVisible(true); } // else // chartPValues.setVisible(false); // Store values for next time scoreData = newScoreData; }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private Pane getCustomizeTablePane() { TableView<TreeTableColumn<TMAEntry, ?>> tableColumns = new TableView<>(); tableColumns.setPlaceholder(new Text("No columns available")); tableColumns.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); tableColumns.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); SortedList<TreeTableColumn<TMAEntry, ?>> sortedColumns = new SortedList<>( table.getColumns().filtered(p -> !p.getText().trim().isEmpty())); sortedColumns.setComparator((c1, c2) -> c1.getText().compareTo(c2.getText())); tableColumns.setItems(sortedColumns); sortedColumns.comparatorProperty().bind(tableColumns.comparatorProperty()); // sortedColumns.comparatorProperty().bind(tableColumns.comparatorProperty()); TableColumn<TreeTableColumn<TMAEntry, ?>, String> columnName = new TableColumn<>("Column"); columnName.setCellValueFactory(v -> v.getValue().textProperty()); TableColumn<TreeTableColumn<TMAEntry, ?>, Boolean> columnVisible = new TableColumn<>("Visible"); columnVisible.setCellValueFactory(v -> v.getValue().visibleProperty()); // columnVisible.setCellValueFactory(col -> { // SimpleBooleanProperty prop = new SimpleBooleanProperty(col.getValue().isVisible()); // prop.addListener((v, o, n) -> col.getValue().setVisible(n)); // return prop; // });/*from w w w . j ava 2s. c o m*/ tableColumns.setEditable(true); columnVisible.setCellFactory(v -> new CheckBoxTableCell<>()); tableColumns.getColumns().add(columnName); tableColumns.getColumns().add(columnVisible); ContextMenu contextMenu = new ContextMenu(); Action actionShowSelected = new Action("Show selected", e -> { for (TreeTableColumn<?, ?> col : tableColumns.getSelectionModel().getSelectedItems()) { if (col != null) col.setVisible(true); else { // Not sure why this happens...? logger.trace("Selected column is null!"); } } }); Action actionHideSelected = new Action("Hide selected", e -> { for (TreeTableColumn<?, ?> col : tableColumns.getSelectionModel().getSelectedItems()) { if (col != null) col.setVisible(false); else { // Not sure why this happens...? logger.trace("Selected column is null!"); } } }); contextMenu.getItems().addAll(ActionUtils.createMenuItem(actionShowSelected), ActionUtils.createMenuItem(actionHideSelected)); tableColumns.setContextMenu(contextMenu); tableColumns.setTooltip( new Tooltip("Show or hide table columns - right-click to change multiple columns at once")); BorderPane paneColumns = new BorderPane(tableColumns); paneColumns.setBottom(PanelToolsFX.createColumnGridControls(ActionUtils.createButton(actionShowSelected), ActionUtils.createButton(actionHideSelected))); VBox paneRows = new VBox(); // Create a box to filter on some metadata text ComboBox<String> comboMetadata = new ComboBox<>(); comboMetadata.setItems(metadataNames); comboMetadata.getSelectionModel().getSelectedItem(); comboMetadata.setPromptText("Select column"); TextField tfFilter = new TextField(); CheckBox cbExact = new CheckBox("Exact"); // Set listeners cbExact.selectedProperty().addListener( (v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(), tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected())); tfFilter.textProperty().addListener( (v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(), tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected())); comboMetadata.getSelectionModel().selectedItemProperty().addListener( (v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(), tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected())); GridPane paneMetadata = new GridPane(); paneMetadata.add(comboMetadata, 0, 0); paneMetadata.add(tfFilter, 1, 0); paneMetadata.add(cbExact, 2, 0); paneMetadata.setPadding(new Insets(10, 10, 10, 10)); paneMetadata.setVgap(2); paneMetadata.setHgap(5); comboMetadata.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(tfFilter, Priority.ALWAYS); GridPane.setFillWidth(comboMetadata, Boolean.TRUE); GridPane.setFillWidth(tfFilter, Boolean.TRUE); TitledPane tpMetadata = new TitledPane("Metadata filter", paneMetadata); tpMetadata.setExpanded(false); // tpMetadata.setCollapsible(false); Tooltip tooltipMetadata = new Tooltip( "Enter text to filter entries according to a selected metadata column"); Tooltip.install(paneMetadata, tooltipMetadata); tpMetadata.setTooltip(tooltipMetadata); paneRows.getChildren().add(tpMetadata); // Add measurement predicate TextField tfCommand = new TextField(); tfCommand.setTooltip(new Tooltip("Predicate used to filter entries for inclusion")); TextFields.bindAutoCompletion(tfCommand, e -> { int ind = tfCommand.getText().lastIndexOf("\""); if (ind < 0) return Collections.emptyList(); String part = tfCommand.getText().substring(ind + 1); return measurementNames.stream().filter(n -> n.startsWith(part)).map(n -> "\"" + n + "\" ") .collect(Collectors.toList()); }); String instructions = "Enter a predicate to filter entries.\n" + "Only entries passing the test will be included in any results.\n" + "Examples of predicates include:\n" + " \"Num Tumor\" > 200\n" + " \"Num Tumor\" > 100 && \"Num Stroma\" < 1000"; // labelInstructions.setTooltip(new Tooltip("Note: measurement names must be in \"inverted commands\" and\n" + // "&& indicates 'and', while || indicates 'or'.")); BorderPane paneMeasurementFilter = new BorderPane(tfCommand); Label label = new Label("Predicate: "); label.setAlignment(Pos.CENTER); label.setMaxHeight(Double.MAX_VALUE); paneMeasurementFilter.setLeft(label); Button btnApply = new Button("Apply"); btnApply.setOnAction(e -> { TablePredicate predicateNew = new TablePredicate(tfCommand.getText()); if (predicateNew.isValid()) { predicateMeasurements.set(predicateNew); } else { DisplayHelpers.showErrorMessage("Invalid predicate", "Current predicate '" + tfCommand.getText() + "' is invalid!"); } e.consume(); }); TitledPane tpMeasurementFilter = new TitledPane("Measurement filter", paneMeasurementFilter); tpMeasurementFilter.setExpanded(false); Tooltip tooltipInstructions = new Tooltip(instructions); tpMeasurementFilter.setTooltip(tooltipInstructions); Tooltip.install(paneMeasurementFilter, tooltipInstructions); paneMeasurementFilter.setRight(btnApply); paneRows.getChildren().add(tpMeasurementFilter); logger.info("Predicate set to: {}", predicateMeasurements.get()); VBox pane = new VBox(); // TitledPane tpColumns = new TitledPane("Select column", paneColumns); // tpColumns.setMaxHeight(Double.MAX_VALUE); // tpColumns.setCollapsible(false); pane.getChildren().addAll(paneColumns, new Separator(), paneRows); VBox.setVgrow(paneColumns, Priority.ALWAYS); return pane; }
From source file:net.sourceforge.entrainer.gui.EntrainerFX.java
private void layoutComponents() { mainPanel = new JFXPanel(); int v = 0;// ww w . ja va2 s . co m GridPane.setConstraints(sliderControlPane, 0, v++); GridPane.setMargin(sliderControlPane, new Insets(20, 0, 0, 0)); GridPane.setConstraints(pictures, 0, v++); GridPane.setConstraints(animations, 0, v++); GridPane.setConstraints(shimmerOptions, 0, v++); GridPane.setConstraints(neuralizer, 0, v++); gp.setPadding(new Insets(5, 13, 5, 5)); gp.getChildren().addAll(sliderControlPane, animations, shimmerOptions, pictures, neuralizer); hiddenSidesPane = new HiddenSidesPane(); hiddenSidesPane.setContent(gp); hiddenSidesPane.setTop(soundControlPane); hiddenSidesPane.setTriggerDistance(25); final URI css = JFXUtils.getEntrainerCSS(); JFXUtils.runLater(new Runnable() { @Override public void run() { group = new Group(); shimmer.setInUse(true); group.getChildren().addAll(background.getPane(), shimmer, hiddenSidesPane); Scene scene = new Scene(group); if (css != null) scene.getStylesheets().add(css.toString()); mainPanel.setScene(scene); } }); getContentPane().add(mainPanel); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param lstPano//from ww w .ja v a2s . c om * @param numPano * @return */ public Pane affichageHS(String lstPano, int numPano) { Pane panneauHotSpots = new Pane(); panneauHotSpots.setTranslateY(10); panneauHotSpots.setTranslateX(30); VBox vb1 = new VBox(5); panneauHotSpots.getChildren().add(vb1); Label lblPoint; Label sep = new Label(" "); Label sep1 = new Label(" "); int o; for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspots(); o++) { VBox vbPanneauHS = new VBox(); double deplacement = 20; vbPanneauHS.setLayoutX(deplacement); Pane pannneauHS = new Pane(vbPanneauHS); pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;"); panneauHotSpots.setId("HS" + o); lblPoint = new Label("Point n" + (o + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.setTranslateX(-deplacement); lblPoint.setStyle("-fx-background-color : #333;"); lblPoint.setTextFill(Color.WHITE); Separator sp = new Separator(Orientation.HORIZONTAL); sp.setTranslateX(-deplacement); sp.setPrefWidth(300); pannneauHS.setPrefWidth(300); pannneauHS.setTranslateX(5); vbPanneauHS.getChildren().addAll(lblPoint, sp); if (lstPano != null) { Label lblLien = new Label("Panoramique de destination"); ComboBox cbDestPano = new ComboBox(); String[] liste = lstPano.split(";"); cbDestPano.getItems().addAll(Arrays.asList(liste)); cbDestPano.valueProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue ov, String t, String t1) { valideHS(); } }); cbDestPano.setTranslateX(60); cbDestPano.setId("cbpano" + o); String f1XML = panoramiquesProjet[numPano].getHotspot(o).getFichierXML(); if (f1XML != null) { cbDestPano.setValue(f1XML.split("\\.")[0]); } int num = cbDestPano.getSelectionModel().getSelectedIndex(); vbPanneauHS.getChildren().addAll(lblLien, cbDestPano, sep); } Label lblTexteHS = new Label("Texte du Hotspot"); TextArea txtTexteHS = new TextArea(); if (panoramiquesProjet[numPano].getHotspot(o).getInfo() != null) { txtTexteHS.setText(panoramiquesProjet[numPano].getHotspot(o).getInfo()); } txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); txtTexteHS.setId("txtHS" + o); txtTexteHS.setPrefSize(200, 25); txtTexteHS.setMaxSize(200, 20); txtTexteHS.setTranslateX(60); CheckBox cbAnime = new CheckBox("HostSpot Anim"); cbAnime.setId("anime" + o); cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable, final Boolean oldValue, final Boolean newValue) -> { valideHS(); }); if (panoramiquesProjet[numPano].getHotspot(o).isAnime()) { cbAnime.setSelected(true); } cbAnime.setPadding(new Insets(5)); cbAnime.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1); vb1.getChildren().addAll(pannneauHS, sep); } int nbHS = o; for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspotImage(); o++) { VBox vbPanneauHS = new VBox(); Pane pannneauHS = new Pane(vbPanneauHS); pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;"); panneauHotSpots.setId("HSImg" + o); lblPoint = new Label("Image n" + (o + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.setStyle("-fx-background-color : #666;"); lblPoint.setTextFill(Color.WHITE); Separator sp = new Separator(Orientation.HORIZONTAL); sp.setPrefWidth(300); pannneauHS.setPrefWidth(300); pannneauHS.setTranslateX(5); vbPanneauHS.getChildren().addAll(lblPoint, sp); Label lblLien = new Label("Image choisie :"); String f1XML = panoramiquesProjet[numPano].getHotspotImage(o).getLienImg(); ImageView IMChoisie = new ImageView( new Image("file:" + repertTemp + File.separator + "images" + File.separator + f1XML, 100, -1, true, true)); IMChoisie.setTranslateX(100); vbPanneauHS.getChildren().addAll(lblLien, IMChoisie, sep); Label lblTexteHS = new Label("Texte du Hotspot"); TextArea txtTexteHS = new TextArea(); if (panoramiquesProjet[numPano].getHotspotImage(o).getInfo() != null) { txtTexteHS.setText(panoramiquesProjet[numPano].getHotspotImage(o).getInfo()); } txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); txtTexteHS.setId("txtHSImage" + o); txtTexteHS.setPrefSize(200, 25); txtTexteHS.setMaxSize(200, 20); txtTexteHS.setTranslateX(60); CheckBox cbAnime = new CheckBox("HostSpot Anim"); cbAnime.setId("animeImage" + o); cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable, final Boolean oldValue, final Boolean newValue) -> { valideHS(); }); if (panoramiquesProjet[numPano].getHotspotImage(o).isAnime()) { cbAnime.setSelected(true); } cbAnime.setPadding(new Insets(5)); cbAnime.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1); vb1.getChildren().addAll(pannneauHS, sep); } valideHS(); nbHS += o; // if (nbHS == 0) { // } else { // btnValider.setVisible(true); // } return panneauHotSpots; }