@FXML protected void playlistsButton() { addAlbumButton.disableProperty().set(true); addPlaylistButton.disableProperty().set(false); flowPane.getChildren().clear(); drawPlaylists(); }
@FXML private void initialize() { deleteButton.setDisable(true); reconcileButton.setDisable(true); initializeTreeTableView(); Platform.runLater(this::loadAccountTree); MessageBus.getInstance() .registerListener( this, MessageChannel.SYSTEM, MessageChannel.ACCOUNT, MessageChannel.TRANSACTION); // Register invalidation listeners to force a reload typeFilter.addListener(observable -> reload()); selectedAccountProperty.addListener( (observable, oldValue, newValue) -> { updateButtonStates(); }); modifyButton.disableProperty().bind(selectedAccountProperty.isNull()); AccountBalanceDisplayManager.getAccountBalanceDisplayModeProperty() .addListener( (observable, oldValue, newValue) -> { treeTableView.refresh(); }); }
@FXML @Override public void initialize() { super.initialize(); enterButton.disableProperty().bind(amountField.textProperty().isEmpty()); }
@Override public void initialize(URL location, ResourceBundle resources) { albumList = FXCollections.observableArrayList(); playlistList = FXCollections.observableArrayList(); fileList = new ArrayList<>(); // obs³uga zamykania okna Platform.runLater( new Runnable() { @Override public void run() { root.getScene() .getWindow() .setOnCloseRequest( e -> { clearData(); }); } }); // wczytanie albumów i playlist loadAlbums(); loadPlaylists(); // domyœlnie pokazuje albumy drawAlbums(); addPlaylistButton.disableProperty().set(true); }
@Override public void initialize(URL location, ResourceBundle resources) { exportBtn.disableProperty().bind(validationRegistry.invalidProperty()); filePath .textProperty() .bindBidirectional( exportFile, new StringConverter<File>() { @Override public String toString(File object) { if (object == null) { return null; } return object.getPath(); } @Override public File fromString(String string) { try { return new File(string); } catch (Exception e) { return null; } } }); validationRegistry.registerValidator(filePath, true, new NotEmptyValidator()); validationRegistry.registerValidator(filePath, true, new ValidFilePathValidator()); validationRegistry.registerValidator(filePath, true, new FileExtensionValidator(".xlsx")); progress.setProgress(-1D); }
// Add new account form private void addNewAccount() { paymentAccountsListView.getSelectionModel().clearSelection(); removeAccountRows(); addAccountButton.setDisable(true); accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, "Create new account", Layout.GROUP_DISTANCE); if (paymentMethodForm != null) { FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1); GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1); } gridRow = 2; paymentMethodForm = getPaymentMethodForm(PaymentMethod.BLOCK_CHAINS); if (paymentMethodForm != null) { paymentMethodForm.addFormForAddAccount(); gridRow = paymentMethodForm.getGridRow(); Tuple2<Button, Button> tuple2 = add2ButtonsAfterGroup(root, ++gridRow, "Save new account", "Cancel"); saveNewAccountButton = tuple2.first; saveNewAccountButton.setOnAction( event -> onSaveNewAccount(paymentMethodForm.getPaymentAccount())); saveNewAccountButton.disableProperty().bind(paymentMethodForm.allInputsValidProperty().not()); Button cancelButton = tuple2.second; cancelButton.setOnAction(event -> onCancelNewAccount()); GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1); } }
@Override public void initialize(final URL url, final ResourceBundle bundle) { exitItem.setOnAction(e -> Platform.exit()); roomSelection.setItems(FXCollections.observableArrayList("arduino", "java", "groovy", "scala")); roomSelection.getSelectionModel().select(1); model.userName.bindBidirectional(userNameTextfield.textProperty()); model.roomName.bind(roomSelection.getSelectionModel().selectedItemProperty()); model.readyToChat.bind( model.userName.isNotEmpty().and(roomSelection.selectionModelProperty().isNotNull())); chatButton.disableProperty().bind(model.connected.not()); messageTextField.disableProperty().bind(model.connected.not()); messageTextField.textProperty().bindBidirectional(model.currentMessage); connectButton.disableProperty().bind(model.readyToChat.not()); chatListView.setItems(model.chatHistory); messageTextField.setOnAction( event -> { handleSendMessage(); }); chatButton.setOnAction( evt -> { handleSendMessage(); }); connectButton.setOnAction( evt -> { try { clientEndPoint = new ChatClientEndpoint( new URI("ws://quevedo2dam.azurewebsites.net/chat/" + model.roomName.get())); clientEndPoint.addMessageHandler( responseString -> { Platform.runLater( () -> { model.chatHistory.add( jsonMessageToString(responseString, model.roomName.get())); }); }); model.connected.set(true); } catch (Exception e) { showDialog("Error: " + e.getMessage()); } }); aboutMenuItem.setOnAction( event -> { showDialog( "Example websocket chat bot written in JavaFX.\n\n Please feel free to visit my blog at www.hascode.com for the full tutorial!\n\n2014 Micha Kops"); }); }
@Override public void initialize(URL arg0, ResourceBundle arg1) { btScan.disableProperty().bind(viewModel.scanAllowedProperty().not()); lbScan.textProperty().bind(viewModel.messageProperty()); tfScan.textProperty().bindBidirectional(viewModel.scannedValueProperty()); btScan.setDefaultButton(true); }
private void createFirebugButton() { firebugButton = new Button(FontAwesome.ICON_BUG); firebugButton.setFont(Font.font("FontAwesome", 14)); firebugButton.setTextFill(Color.RED); firebugButton.setTooltip(new Tooltip("Launch Firebug.")); firebugButton.disableProperty().bind(webEngine.getLoadWorker().runningProperty()); firebugButton.setOnAction(observable -> webEngine.executeScript(firebugScript)); }
/** Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { logger.entry(); OkButton.disableProperty() .bind( Bindings.isEmpty(FederationExecutionName.textProperty()) .or(Bindings.isEmpty(FederateType.textProperty()))); logger.exit(); }
private void setFileDependingButtonBindings() { // MenuItems pyrpurItem.disableProperty().bind(model.fileLoadedProperty().not()); augcItem.disableProperty().bind(model.fileLoadedProperty().not()); meshItem.disableProperty().bind(model.fileLoadedProperty().not()); stickItem.disableProperty().bind(model.fileLoadedProperty().not()); ballItem.disableProperty().bind(model.fileLoadedProperty().not()); // Buttons on the side colorPyrpur.disableProperty().bind(model.fileLoadedProperty().not()); colorAugc.disableProperty().bind(model.fileLoadedProperty().not()); structureMesh.disableProperty().bind(model.fileLoadedProperty().not()); structureStick.disableProperty().bind(model.fileLoadedProperty().not()); structureBall.disableProperty().bind(model.fileLoadedProperty().not()); playRotate.disableProperty().bind(model.fileLoadedProperty().not()); rotateLeft.disableProperty().bind(model.fileLoadedProperty().not()); rotateRight.disableProperty().bind(model.fileLoadedProperty().not()); zoomIn.disableProperty().bind(model.fileLoadedProperty().not()); zoomOut.disableProperty().bind(model.fileLoadedProperty().not()); centerObject.disableProperty().bind(model.fileLoadedProperty().not()); }
/** * Get the spell checker button. * * <p> * * @return the spell checker button. */ private Button getDictButton() { Button button = new Button("", new ImageView(new Image("file:icons/dictionary.png", 24, 24, false, true))); button.setTooltip( new Tooltip(LabelGrabber.INSTANCE.getLabel("run.spellcheck.label") + " (F7)")); button.setOnAction( new EventHandler<javafx.event.ActionEvent>() { @Override public void handle(javafx.event.ActionEvent t) { lyricsArea.runSpellCheck(); } }); button.disableProperty().bind(lyricsArea.spellingOkProperty()); Utils.setToolbarButtonStyle(button); return button; }
/** Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { logger.entry(); OkButton.disableProperty().bind(ObjectInstanceDesignator.textProperty().isEmpty()); logger.exit(); }
@FXML void initialize() { assert syncUserName != null : "fx:id=\"syncUserName\" was not injected: check your FXML file 'AddUser.fxml'."; assert cancelButton != null : "fx:id=\"cancelButton\" was not injected: check your FXML file 'AddUser.fxml'."; assert password != null : "fx:id=\"password\" was not injected: check your FXML file 'AddUser.fxml'."; assert fullNameUnique != null : "fx:id=\"fullNameUnique\" was not injected: check your FXML file 'AddUser.fxml'."; assert roles != null : "fx:id=\"roles\" was not injected: check your FXML file 'AddUser.fxml'."; assert layoutPane != null : "fx:id=\"layoutPane\" was not injected: check your FXML file 'AddUser.fxml'."; assert fullName != null : "fx:id=\"fullName\" was not injected: check your FXML file 'AddUser.fxml'."; assert okButton != null : "fx:id=\"okButton\" was not injected: check your FXML file 'AddUser.fxml'."; assert userName != null : "fx:id=\"userName\" was not injected: check your FXML file 'AddUser.fxml'."; assert workflowUserName != null : "fx:id=\"workflowUserName\" was not injected: check your FXML file 'AddUser.fxml'."; assert uuid != null : "fx:id=\"uuid\" was not injected: check your FXML file 'AddUser.fxml'."; for (RoleOption ro : RoleOption.values()) { roles.getItems().add(ro.value()); } upm_ = AppContext.getService(UserProfileManager.class); uuidValid_ = new ValidBooleanBinding() { { bind(uuid.textProperty()); } @Override protected boolean computeValue() { if (uuid.getText().length() == 0 || Utility.isUUID(uuid.getText())) { if (uuid.getText().length() > 0 && AppContext.getService(TerminologyStoreDI.class) .hasUuid(UUID.fromString(uuid.getText()))) { setInvalidReason("If a UUID is specified, it must be unique"); return false; } else { clearInvalidReason(); return true; } } else { setInvalidReason("Invalid uuid"); return false; } } }; ErrorMarkerUtils.setupErrorMarkerAndSwap(uuid, layoutPane, uuidValid_); userNameValid_ = new ValidBooleanBinding() { { bind(userName.textProperty()); } @Override protected boolean computeValue() { if (userName.getText().length() > 0 && !upm_.doesProfileExist(userName.getText())) { clearInvalidReason(); return true; } else { setInvalidReason("The user name is required, and must be unique"); return false; } } }; ErrorMarkerUtils.setupErrorMarkerAndSwap(userName, layoutPane, userNameValid_); fullNameUniqueValid_ = new ValidBooleanBinding() { { bind(fullNameUnique.textProperty(), uuid.textProperty()); } @Override protected boolean computeValue() { if (fullNameUnique.getText().length() > 0) { UUID userUuid; if (uuid.getText().length() > 0) { if (uuidValid_.get()) { userUuid = UUID.fromString(uuid.getText()); } else { setInvalidReason("If a UUID is specified, it must be valid."); return false; } } else { userUuid = GenerateUsers.calculateUserUUID(fullNameUnique.getText()); } if (AppContext.getService(TerminologyStoreDI.class).hasUuid(userUuid)) { setInvalidReason("The full name must be unique"); return false; } else { clearInvalidReason(); return true; } } else { setInvalidReason( "The Full Name is required, and must be unique. If a UUID is specified, it must be valid, and unique"); return false; } } }; ErrorMarkerUtils.setupErrorMarkerAndSwap(fullNameUnique, layoutPane, fullNameUniqueValid_); okButton.disableProperty().bind(fullNameUniqueValid_.and(userNameValid_).and(uuidValid_).not()); cancelButton.setCancelButton(true); // JavaFX is silly: https://javafx-jira.kenai.com/browse/RT-39145#comment-434189 cancelButton.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { event.consume(); cancelButton.fire(); } } }); cancelButton.setOnAction( (event) -> { layoutPane.getScene().getWindow().hide(); }); okButton.setDefaultButton(true); okButton.setOnAction( (event) -> { try { User u = new User(); u.setFullName(fullName.getText()); u.setPassword(password.getText()); u.setSyncUserName(syncUserName.getText()); u.setWorkflowUserName(workflowUserName.getText()); u.setUniqueFullName(fullNameUnique.getText()); u.setUniqueLogonName(userName.getText()); u.setUUID(uuid.getText()); for (String roleName : roles.getSelectionModel().getSelectedItems()) { u.getRoles().add(RoleOption.fromValue(roleName)); } upm_.createNewUser(u); layoutPane.getScene().getWindow().hide(); } catch (Exception e) { logger.error("Error creating user", e); AppContext.getCommonDialogs().showErrorDialog("Unexpected error adding user", e); } }); }
public void bindDrawButtonDisability(ObservableValue<? extends Boolean> property) { drawButton.disableProperty().bind(property); }
private Parent createContent() throws IOException { dealer = new Hand(dealerCards.getChildren()); player = new Hand(playerCards.getChildren()); Pane root = new Pane(); root.setPrefSize(windowWidth, windowHeight); Region background = new Region(); background.setPrefSize(windowWidth, windowHeight); background.setStyle("-fx-background-image: url('res/images/casino.jpg')"); HBox rootLayout = new HBox(5); rootLayout.setPadding(new Insets(5, 5, 5, 5)); // Rectangle leftBG = new Rectangle(550, 560); // leftBG.setArcWidth(50); // leftBG.setArcHeight(50); // leftBG.setFill(Color.GREEN); // Canvas canvas = new Canvas(560, 560); BufferedImage imgi; GraphicsContext gcfx = canvas.getGraphicsContext2D(); // Graphics gc = canvas.getGraphics(); Image zbyszek = new Image("/res/images/table.png", 560, 560, true, false); gcfx.setFill(DARKSLATEGRAY); gcfx.fillRoundRect(0, 0, 550, 300, 10, 100); gcfx.setFill(BLACK); gcfx.drawImage(zbyszek, 0, 280); // try { // imgi = ImageIO.read(Card.class.getResource("/res/images/table.png")); // // gcfx.drawImage(imgi, 300, 300, null); // canvas.setVisible(true); // } catch (Exception e) { // } Rectangle rightBG = new Rectangle(230, 560); rightBG.setArcWidth(50); rightBG.setArcHeight(50); rightBG.setFill(Color.ORANGE); // LEFT VBox leftVBox = new VBox(50); leftVBox.setAlignment(Pos.TOP_CENTER); Text dealerScore = new Text("Dealer: "); Text playerScore = new Text("Player: "); leftVBox.getChildren().addAll(dealerScore, dealerCards, message, playerCards, playerScore); // RIGHT VBox rightVBox = new VBox(20); rightVBox.setAlignment(Pos.CENTER); // final TextField bet = new TextField("BET"); // bet.setDisable(true); // bet.setMaxWidth(50); // Text money = new Text("MONEY"); Button btnPlay = new Button("PLAY"); Button btnHit = new Button("HIT"); Button btnStand = new Button("STAND"); HBox buttonsHBox = new HBox(15, btnHit, btnStand); buttonsHBox.setAlignment(Pos.CENTER); // rightVBox.getChildren().addAll(bet, btnPlay, money, buttonsHBox); rightVBox.getChildren().addAll(btnPlay, buttonsHBox); // ADD BOTH STACKS TO ROOT LAYOUT rootLayout .getChildren() .addAll(new StackPane(canvas, leftVBox), new StackPane(rightBG, rightVBox)); root.getChildren().addAll(background, rootLayout); // BIND PROPERTIES btnPlay.disableProperty().bind(playable); btnHit.disableProperty().bind(playable.not()); btnStand.disableProperty().bind(playable.not()); playerScore .textProperty() .bind(new SimpleStringProperty("Player: ").concat(player.valueProperty().asString())); dealerScore .textProperty() .bind(new SimpleStringProperty("Dealer: ").concat(dealer.valueProperty().asString())); player .valueProperty() .addListener( (obs, old, newValue) -> { if (newValue.intValue() >= 21) { endGame(); } }); dealer .valueProperty() .addListener( (obs, old, newValue) -> { if (newValue.intValue() >= 21) { endGame(); } }); // INIT BUTTONS btnPlay.setOnAction( event -> { startNewGame(); }); btnHit.setOnAction( event -> { player.takeCard(deck.drawCard()); }); btnStand.setOnAction( event -> { while (dealer.valueProperty().get() < 17) { dealer.takeCard(deck.drawCard()); } endGame(); }); return root; }
@Override public void start(Stage primaryStage) { CheckBox wrapToggle = new CheckBox("Wrap"); wrapToggle.setSelected(true); area.wrapTextProperty().bind(wrapToggle.selectedProperty()); Button undoBtn = createButton("undo", () -> area.undo()); Button redoBtn = createButton("redo", () -> area.redo()); Button cutBtn = createButton("cut", () -> area.cut()); Button copyBtn = createButton("copy", () -> area.copy()); Button pasteBtn = createButton("paste", () -> area.paste()); Button boldBtn = createButton("bold", () -> toggleBold()); Button italicBtn = createButton("italic", () -> toggleItalic()); Button underlineBtn = createButton("underline", () -> toggleUnderline()); Button strikeBtn = createButton("strikethrough", () -> toggleStrikethrough()); ComboBox<Integer> sizeCombo = new ComboBox<>( FXCollections.observableArrayList( 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 48, 56, 64, 72)); sizeCombo.getSelectionModel().select(Integer.valueOf(12)); ComboBox<String> familyCombo = new ComboBox<>(FXCollections.observableList(Font.getFamilies())); familyCombo.getSelectionModel().select("Serif"); ColorPicker textColorPicker = new ColorPicker(Color.BLACK); ColorPicker backgroundColorPicker = new ColorPicker(); sizeCombo.setOnAction(evt -> updateFontSize(sizeCombo.getValue())); familyCombo.setOnAction(evt -> updateFontFamily(familyCombo.getValue())); textColorPicker.valueProperty().addListener((o, old, color) -> updateTextColor(color)); backgroundColorPicker .valueProperty() .addListener((o, old, color) -> updateBackgroundColor(color)); undoBtn.disableProperty().bind(Bindings.not(area.undoAvailableProperty())); redoBtn.disableProperty().bind(Bindings.not(area.redoAvailableProperty())); BooleanBinding selectionEmpty = new BooleanBinding() { { bind(area.selectionProperty()); } @Override protected boolean computeValue() { return area.getSelection().getLength() == 0; } }; cutBtn.disableProperty().bind(selectionEmpty); copyBtn.disableProperty().bind(selectionEmpty); area.beingUpdatedProperty() .addListener( (o, old, beingUpdated) -> { if (!beingUpdated) { boolean bold, italic, underline, strike; Integer fontSize; String fontFamily; Color textColor; Color backgroundColor; IndexRange selection = area.getSelection(); if (selection.getLength() != 0) { StyleSpans<StyleInfo> styles = area.getStyleSpans(selection); bold = styles.styleStream().anyMatch(s -> s.bold.orElse(false)); italic = styles.styleStream().anyMatch(s -> s.italic.orElse(false)); underline = styles.styleStream().anyMatch(s -> s.underline.orElse(false)); strike = styles.styleStream().anyMatch(s -> s.strikethrough.orElse(false)); int[] sizes = styles .styleStream() .mapToInt(s -> s.fontSize.orElse(-1)) .distinct() .toArray(); fontSize = sizes.length == 1 ? sizes[0] : -1; String[] families = styles .styleStream() .map(s -> s.fontFamily.orElse(null)) .distinct() .toArray(i -> new String[i]); fontFamily = families.length == 1 ? families[0] : null; Color[] colors = styles .styleStream() .map(s -> s.textColor.orElse(null)) .distinct() .toArray(i -> new Color[i]); textColor = colors.length == 1 ? colors[0] : null; Color[] backgrounds = styles .styleStream() .map(s -> s.backgroundColor.orElse(null)) .distinct() .toArray(i -> new Color[i]); backgroundColor = backgrounds.length == 1 ? backgrounds[0] : null; } else { int p = area.getCurrentParagraph(); int col = area.getCaretColumn(); StyleInfo style = area.getStyleAtPosition(p, col); bold = style.bold.orElse(false); italic = style.italic.orElse(false); underline = style.underline.orElse(false); strike = style.strikethrough.orElse(false); fontSize = style.fontSize.orElse(-1); fontFamily = style.fontFamily.orElse(null); textColor = style.textColor.orElse(null); backgroundColor = style.backgroundColor.orElse(null); } updatingToolbar.suspendWhile( () -> { if (bold) { if (!boldBtn.getStyleClass().contains("pressed")) { boldBtn.getStyleClass().add("pressed"); } } else { boldBtn.getStyleClass().remove("pressed"); } if (italic) { if (!italicBtn.getStyleClass().contains("pressed")) { italicBtn.getStyleClass().add("pressed"); } } else { italicBtn.getStyleClass().remove("pressed"); } if (underline) { if (!underlineBtn.getStyleClass().contains("pressed")) { underlineBtn.getStyleClass().add("pressed"); } } else { underlineBtn.getStyleClass().remove("pressed"); } if (strike) { if (!strikeBtn.getStyleClass().contains("pressed")) { strikeBtn.getStyleClass().add("pressed"); } } else { strikeBtn.getStyleClass().remove("pressed"); } if (fontSize != -1) { sizeCombo.getSelectionModel().select(fontSize); } else { sizeCombo.getSelectionModel().clearSelection(); } if (fontFamily != null) { familyCombo.getSelectionModel().select(fontFamily); } else { familyCombo.getSelectionModel().clearSelection(); } if (textColor != null) { textColorPicker.setValue(textColor); } backgroundColorPicker.setValue(backgroundColor); }); } }); HBox panel1 = new HBox(3.0); HBox panel2 = new HBox(3.0); panel1 .getChildren() .addAll( wrapToggle, undoBtn, redoBtn, cutBtn, copyBtn, pasteBtn, boldBtn, italicBtn, underlineBtn, strikeBtn); panel2.getChildren().addAll(sizeCombo, familyCombo, textColorPicker, backgroundColorPicker); VBox vbox = new VBox(); VBox.setVgrow(area, Priority.ALWAYS); vbox.getChildren().addAll(panel1, panel2, area); Scene scene = new Scene(vbox, 600, 400); scene.getStylesheets().add(RichText.class.getResource("rich-text.css").toExternalForm()); primaryStage.setScene(scene); area.requestFocus(); primaryStage.setTitle("Rich Text Demo"); primaryStage.show(); }
@Override protected void onConfigure() { cfg = Configuration.getDefault(); flinger = new Flinger(); flinger.gapProperty().set(4); flinger .directionProperty() .setValue(cfg.isVertical() ? Direction.VERTICAL : Direction.HORIZONTAL); slideLeft.disableProperty().bind(flinger.leftOrUpDisableProperty()); slideRight.disableProperty().bind(flinger.rightOrDownDisableProperty()); shortcuts.getChildren().add(flinger); AnchorPane.setTopAnchor(flinger, 0d); AnchorPane.setBottomAnchor(flinger, 0d); AnchorPane.setLeftAnchor(flinger, 0d); AnchorPane.setRightAnchor(flinger, 0d); networkResources.setTooltip( UIHelpers.createDockButtonToolTip(resources.getString("network.toolTip"))); networkResources.selectedProperty().bindBidirectional(cfg.showNetworkProperty()); ssoResources.setTooltip(UIHelpers.createDockButtonToolTip(resources.getString("sso.toolTip"))); ssoResources.selectedProperty().bindBidirectional(cfg.showSSOProperty()); browserResources.setTooltip( UIHelpers.createDockButtonToolTip(resources.getString("web.toolTip"))); browserResources.selectedProperty().bindBidirectional(cfg.showWebProperty()); status.setTooltip(UIHelpers.createDockButtonToolTip(status.getTooltip().getText())); exit.setTooltip(UIHelpers.createDockButtonToolTip(exit.getTooltip().getText())); signIn.setTooltip(UIHelpers.createDockButtonToolTip(signIn.getTooltip().getText())); options.setTooltip(UIHelpers.createDockButtonToolTip(options.getTooltip().getText())); fileResources.setTooltip( UIHelpers.createDockButtonToolTip(resources.getString("files.toolTip"))); fileResources.selectedProperty().bindBidirectional(cfg.showFilesProperty()); // Button size changes sizeChangeListener = new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { flinger.recentre(); sizeButtons(); } }; cfg.sizeProperty().addListener(sizeChangeListener); // Colour changes colorChangeListener = new ChangeListener<Color>() { @Override public void changed( ObservableValue<? extends Color> observable, Color oldValue, Color newValue) { // styleToolTips(); } }; cfg.colorProperty().addListener(colorChangeListener); // Border changes borderChangeListener = new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { flinger .directionProperty() .setValue(cfg.isVertical() ? Direction.VERTICAL : Direction.HORIZONTAL); configurePull(); } } }; cfg.topProperty().addListener(borderChangeListener); cfg.bottomProperty().addListener(borderChangeListener); cfg.leftProperty().addListener(borderChangeListener); cfg.rightProperty().addListener(borderChangeListener); dockContent.prefWidthProperty().bind(dockStack.widthProperty()); // Hide the pull tab initially pull.setVisible(false); if (context.getBridge().isServiceUpdating()) { setMode(Mode.UPDATE); } rebuildResources(); rebuildIcons(); // styleToolTips(); sizeButtons(); setAvailable(); configurePull(); if (cfg.autoHideProperty().get()) maybeHideDock(INITIAL_AUTOHIDE_HIDE_TIME); }
public MasterGUI(Stage stage) { parentStage = stage; // JsonHelpExtractor ujextractor = new JsonHelpExtractor(); // HashMap<String,String> dataSetTab_tooltipHelp = // ujextractor.extractToolTipFile("TestJson.json"); // HashMap<String, ExtensiveHelp> dataSetTab_extensiveHelp = // ujextractor.extractExtensiveHelpFile("DataSetExtensiveHelp.json"); // final HelpDataStore dataSetTab_HelpStore = new // HelpDataStore("DataSetTab",dataSetTab_tooltipHelp,dataSetTab_extensiveHelp); // ujextractor.writeExtensiveHelpFile("C:\\Users\\user\\Desktop\\ExtensiveSectionTest.json"); experiment = new Experiment(); tabPane = new TabPane(); final Tab tab1 = new DataSetTab(parentStage, experiment); tab1.setText("Dataset"); final Tab tab2 = new PreprocessingTab(parentStage, experiment); tab2.setText("Preprocessing"); final Tab tab3 = new FeatureSelectionTab(parentStage, experiment); tab3.setText("Feature Selection"); final Tab tab4 = new AlgorithmTab(parentStage, experiment); tab4.setText("Preference Learning Methods"); tabPane.tabClosingPolicyProperty().set(TabPane.TabClosingPolicy.UNAVAILABLE); tabPane.getTabs().addAll(tab1, tab2, tab3, tab4); BorderPane bottomPane = new BorderPane(); final Button btnBack = new Button(); btnBack.setPrefSize(200, 20); btnBack.setVisible(false); Label lblBackBtn = new Label("BACK"); ImageView imgViewBkBtn = new ImageView(new Image(DataSetTab.class.getResourceAsStream("bkButton.png"))); BorderPane backBtnInnerBPane = new BorderPane(); backBtnInnerBPane.setLeft(imgViewBkBtn); backBtnInnerBPane.setCenter(lblBackBtn); btnBack.setGraphic(backBtnInnerBPane); btnBack.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { if (tabPane.getSelectionModel().getSelectedIndex() > 0) { tabPane .selectionModelProperty() .get() .select(tabPane.selectionModelProperty().get().getSelectedIndex() - 1); } } }); final Button btnNext = new Button(); btnNext.setPrefSize(200, 20); Label lblNextBtn = new Label("NEXT"); ImageView imgViewNextBtn = new ImageView(new Image(DataSetTab.class.getResourceAsStream("nxtButton.png"))); BorderPane nextBtnInnerBPane = new BorderPane(); nextBtnInnerBPane.setCenter(lblNextBtn); nextBtnInnerBPane.setRight(imgViewNextBtn); btnNext.setGraphic(nextBtnInnerBPane); btnNext.disableProperty().bind(this.experiment.isReadyToUseDataSetProperty().not()); tabPane.selectionModelProperty(); btnNext.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { if (!tab4.selectedProperty().get()) { tabPane .selectionModelProperty() .get() .select(tabPane.selectionModelProperty().get().getSelectedIndex() + 1); } else if (tab4.selectedProperty().get()) { // Perform safety checks. boolean allClear = true; int numOfIgnoredFeatures = 0; boolean[] tmpIgArr = experiment.ignoredFeaturesProperty().get(); for (int i = 0; i < tmpIgArr.length; i++) { if (tmpIgArr[i]) { numOfIgnoredFeatures++; } } if (numOfIgnoredFeatures == experiment.dataSetProperty().get().getNumberOfFeatures()) { // You must include at least one feature. ModalPopup notification = new ModalPopup(); notification.show( new Label("ERROR: You must include at least one feature from the dataset."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } else if (experiment.featureSelectionProperty().get() != null) { if (experiment.featureSelectionProperty().get() instanceof NBest) { NBest castNBest = (NBest) experiment.featureSelectionProperty().get(); int numOfUserIncludedFeatures = (experiment.dataSetProperty().get().getNumberOfFeatures() - numOfIgnoredFeatures); if (castNBest.getN() > numOfUserIncludedFeatures) { // N val should always be less than or equal to the number of user included // features. ModalPopup notification = new ModalPopup(); notification.show( new Label( "ERROR: N-Best N value cannot be greater than the number of included features. \n Current N Value = " + castNBest.getN() + " \n Current Num of Included Features = " + numOfUserIncludedFeatures), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 600, false); allClear = false; } } if (experiment.algorithmForFeatureSelectionProperty().get() == null) { // You cannot select a feature selection type without stating an algorithm. ModalPopup notification = new ModalPopup(); notification.show( new Label( "ERROR: You must state an algorithm to work with " + experiment.featureSelectionProperty().get().getFSelName() + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (experiment.algorithmForFeatureSelectionProperty().get() != null) { if (experiment.algorithmForFeatureSelectionProperty().get() instanceof PLNeuroEvolution) { PLNeuroEvolution castPLNE = (PLNeuroEvolution) experiment.algorithmForFeatureSelectionProperty().get(); PLNeuroEvolutionConfigurator neConfig = castPLNE.getConfigurator(); GeneticAlgorithmConfigurator gaConfig = neConfig.getGeneticAlgorithmConfigurator(); if (gaConfig.getNumberOfParents() > gaConfig.getPopulationSize()) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "GA ERROR: The number of parents is greater than the GA population size."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } if (gaConfig.getElitSize() > gaConfig.getPopulationSize()) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "GA ERROR: The elitism size is greater than the GA population size."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (experiment.algorithmProperty().get() instanceof PLRankSvm) { PLRankSvm castPLRS = (PLRankSvm) experiment.algorithmProperty().get(); PLRankSvmConfigurator svmConfig = castPLRS.getConfigurator(); if ((svmConfig.gammaRequired()) && (svmConfig.getGamma() == 0)) { ModalPopup notification = new ModalPopup(); notification.show( new Label("SVM ERROR: Gamma cannot be set to 0."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } if (svmConfig.degreeRequired()) { try { Integer.parseInt(svmConfig.getDegreeTextboxContents()); } catch (Exception NumberFormatException) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "SVM ERROR: Invalid Degree value \\" + svmConfig.getDegreeTextboxContents() + "\\" + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (svmConfig.betaRequired()) { try { Integer.parseInt(svmConfig.getBetaTextboxContents()); } catch (Exception NumberFormatException) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "SVM ERROR: Invalid Beta value \\" + svmConfig.getBetaTextboxContents() + "\\" + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } } } if (experiment.algorithmProperty().get() instanceof PLNeuroEvolution) { PLNeuroEvolution castPLNE = (PLNeuroEvolution) experiment.algorithmProperty().get(); PLNeuroEvolutionConfigurator neConfig = castPLNE.getConfigurator(); GeneticAlgorithmConfigurator gaConfig = neConfig.getGeneticAlgorithmConfigurator(); int numParents = gaConfig.getNumberOfParents(); int popSize = gaConfig.getPopulationSize(); if (numParents > popSize) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "GA ERROR: The number of parents is greater than the GA population size."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } if (gaConfig.getElitSize() > gaConfig.getPopulationSize()) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "GA ERROR: The elitism size is greater than the GA population size."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (experiment.algorithmProperty().get() instanceof PLRankSvm) { PLRankSvm castPLRS = (PLRankSvm) experiment.algorithmProperty().get(); PLRankSvmConfigurator svmConfig = castPLRS.getConfigurator(); if ((svmConfig.gammaRequired()) && (svmConfig.getGamma() == 0)) { ModalPopup notification = new ModalPopup(); notification.show( new Label("SVM ERROR: Gamma cannot be set to 0."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } if (svmConfig.degreeRequired()) { try { Integer.parseInt(svmConfig.getDegreeTextboxContents()); } catch (Exception NumberFormatException) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "SVM ERROR: Invalid Degree value \\" + svmConfig.getDegreeTextboxContents() + "\\" + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (svmConfig.betaRequired()) { try { Integer.parseInt(svmConfig.getBetaTextboxContents()); } catch (Exception NumberFormatException) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "SVM ERROR: Invalid Beta value \\" + svmConfig.getBetaTextboxContents() + "\\" + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } } if (allClear) { Execution e = new Execution(experiment); e.show(parentStage); } } } }); tab4.selectedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) { if (t1) { Label lblNextBtn = new Label("RUN EXPERIMENT"); ImageView imgViewNextBtn = new ImageView( new Image( DataSetTab.class.getResourceAsStream("runExperimentButton.png"))); BorderPane nextBtnInnerBPane = new BorderPane(); nextBtnInnerBPane.setCenter(lblNextBtn); nextBtnInnerBPane.setRight(imgViewNextBtn); btnNext.setGraphic(nextBtnInnerBPane); } else { Label lblNextBtn = new Label("NEXT"); ImageView imgViewNextBtn = new ImageView( new Image(DataSetTab.class.getResourceAsStream("nxtButton.png"))); BorderPane nextBtnInnerBPane = new BorderPane(); nextBtnInnerBPane.setCenter(lblNextBtn); nextBtnInnerBPane.setRight(imgViewNextBtn); btnNext.setGraphic(nextBtnInnerBPane); } } }); tab1.selectedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) { if (t1) { btnBack.setVisible(false); btnNext.setVisible(true); } else { btnBack.setVisible(true); } } }); Button helpButton = new Button(); helpButton.setVisible(true); helpButton.setGraphic( new ImageView(new Image(DataSetTab.class.getResourceAsStream("helpButton.png")))); helpButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { if (tab1.selectedProperty().get()) { Tab1Help h = new Tab1Help(); h.show(parentStage.getScene().getRoot(), null); } else if (tab2.selectedProperty().get()) { Tab2Help h = new Tab2Help(); h.show(parentStage.getScene().getRoot(), null); } else if (tab3.selectedProperty().get()) { Tab3Help h = new Tab3Help(); h.show(parentStage.getScene().getRoot(), null); } else if (tab4.selectedProperty().get()) { Tab4Help h = new Tab4Help(); h.show(parentStage.getScene().getRoot(), null); } } }); /*helpButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { if (tab1.selectedProperty().get()) { ArrayList<String> itemsToInclude = new ArrayList<String>(); itemsToInclude.add("Loading a dataset"); itemsToInclude.add("Button: Import Object File"); itemsToInclude.add("Button: Import Ranking File"); String reqHTML = dataSetTab_HelpStore.constructHtml(itemsToInclude); HelpPopup hPopup = new HelpPopup(reqHTML); hPopup.show(parentStage.getScene().getRoot(), null); //Tab1Help h = new Tab1Help(); //h.show(parentStage.getScene().getRoot(), null); } if (tab2.selectedProperty().get()) { Tab2Help h = new Tab2Help(); h.show(parentStage.getScene().getRoot(), null); } } });*/ // helpButton.visibleProperty().bind(tab1.selectedProperty().or(tab2.selectedProperty())); HBox navBtnBox = new HBox(10); navBtnBox.getChildren().addAll(btnBack, btnNext); bottomPane.setPadding(new Insets(10, 10, 10, 10)); bottomPane.setStyle("-fx-background-color: #336699;"); bottomPane.setLeft(helpButton); bottomPane.setRight(navBtnBox); this.setCenter(tabPane); this.setBottom(bottomPane); disableTabs(new ArrayList<Integer>(Arrays.asList(1, 2, 3))); }
/** Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { super.initialize(url, rb); summaryData = new SimpleObjectProperty<>(); summaryController.summaryDataProperty().bind(summaryData); currentTarget = new SimpleObjectProperty<>(FXCollections.emptyObservableList()); summaryController.currentTargetProperty().bind(currentTarget); histogramController.currentTargetProperty().bind(currentTarget); snapshotController.currentTargetProperty().bind(currentTarget); currentClassNameSet = new SimpleObjectProperty<>(); summaryController.currentClassNameSetProperty().bind(currentClassNameSet); histogramController.currentClassNameSetProperty().bind(currentClassNameSet); histogramController.instanceGraphProperty().bind(radioInstance.selectedProperty()); snapshotController.instanceGraphProperty().bind(radioInstance.selectedProperty()); snapshotSelectionModel = new SimpleObjectProperty<>(); snapshotSelectionModel.bind(snapshotController.snapshotSelectionModelProperty()); histogramController.snapshotSelectionModelProperty().bind(snapshotSelectionModel); histogramController.setDrawRebootSuspectLine(this::drawRebootSuspectLine); topNList = new SimpleObjectProperty<>(); topNList.bind(histogramController.topNListProperty()); snapshotController.topNListProperty().bind(topNList); currentSnapShotHeader = new SimpleObjectProperty<>(); currentSnapShotHeader.bind( snapshotController.snapshotSelectionModelProperty().get().selectedItemProperty()); reftreeController.currentSnapShotHeaderProperty().bind(currentSnapShotHeader); currentObjectTag = new SimpleLongProperty(); // TODO: // Why can I NOT use binding? // First binding is enabled. But second binding is disabled. // So I use ChangeListener to avoid this issue. // currentObjectTag.bind(histogramController.currentObjectTagProperty()); // currentObjectTag.bind(snapshotController.currentObjectTagProperty()); histogramController .currentObjectTagProperty() .addListener( (v, o, n) -> Optional.ofNullable(n).ifPresent(m -> currentObjectTag.set((Long) m))); snapshotController .currentObjectTagProperty() .addListener( (v, o, n) -> Optional.ofNullable(n).ifPresent(m -> currentObjectTag.set((Long) m))); reftreeController.currentObjectTagProperty().bind(currentObjectTag); snapshotMain.getSelectionModel().selectedItemProperty().addListener(this::onTabChanged); startCombo.setConverter(new SnapShotHeaderConverter()); endCombo.setConverter(new SnapShotHeaderConverter()); okBtn .disableProperty() .bind( startCombo .getSelectionModel() .selectedIndexProperty() .greaterThanOrEqualTo(endCombo.getSelectionModel().selectedIndexProperty())); setOnWindowResize( (v, o, n) -> Platform.runLater( () -> Stream.of( summaryController.getHeapChart(), summaryController.getInstanceChart(), summaryController.getGcTimeChart(), summaryController.getMetaspaceChart(), histogramController.getTopNChart()) .forEach(c -> Platform.runLater(() -> drawRebootSuspectLine(c))))); histogramController.setTaskExecutor( t -> { bindTask(t); (new Thread(t)).start(); }); }
private void removeNewAccountForm() { saveNewAccountButton.disableProperty().unbind(); removeAccountRows(); addAccountButton.setDisable(false); }
/** * Called after the controls have been parsed from the XML. Sets up logic and components that * could not be set up using the GUI builder. */ @Override public void initialize(URL url, ResourceBundle rb) { // the transformedTrajectory provides a view of the trajectory that reflects the selected // transformedTrajectory transformedTrajectory = new Cacheable<double[][]>() { private int eachKthPoint; private int embeddingDimension, embeddingDelay; private double noiseRatio; private int getSubsampleLength() { int prefixLength = (int) (subsampleLengthSlider.getValue() * trajectory[0].length); // per started block of k elements, one output element will be generated int k = getEachKthPoint(); // full blocks + 1 block if there is a fractional block return prefixLength / k + (prefixLength % k > 0 ? 1 : 0); } @Override public synchronized boolean isValid() { if (cachedValue == null) return false; if (eachKthPoint != getEachKthPoint()) return false; // any embedding dimension <= 0 signifies that no embedding should be used, thus the // actual dimension does not matter if (getEmbeddingDimension() > 0 && (embeddingDimension != getEmbeddingDimension())) return false; // for an embedding dimension of <= 1, the delay is insignificant if (getEmbeddingDimension() > 1 && (embeddingDelay != getEmbeddingDelay())) return false; if (getNoiseRatio() != noiseRatio) return false; return trajectory == null || cachedValue == null || getSubsampleLength() == cachedValue[0].length; } @Override public synchronized void recompute() { if (trajectory == null) cachedValue = null; else { // create an empty array with the desired number of dimensions cachedValue = new double[trajectory.length][]; eachKthPoint = getEachKthPoint(); // crop to sampling size int newLength = getSubsampleLength(); for (int dimIdx = 0; dimIdx < trajectory.length; dimIdx++) { cachedValue[dimIdx] = new double[newLength]; // Arrays.copyOf(trajectory[dimIdx], newLength); for (int i = 0, t = 0; i < newLength; i++, t += eachKthPoint) { cachedValue[dimIdx][i] = trajectory[dimIdx][t]; } } int dim = getEmbeddingDimension(); int tau = getEmbeddingDelay(); double noiseRatio = getNoiseRatio(); if (dim > 0 && tau > 0) { cachedValue = PhaseSpaceReconstructed.embed(cachedValue[0], dim, tau); } cachedValue = TimeSeriesGenerator.addNoise(cachedValue, 0.05, noiseRatio); this.noiseRatio = noiseRatio; this.embeddingDimension = dim; this.embeddingDelay = tau; } } }; // sync recurrence threshold slider and text field Bindings.bindBidirectional( recurrenceThresholdTextField.textProperty(), recurrenceThresholdSlider.valueProperty(), DecimalFormat.getInstance()); // sync GUI and model recurrence threshold Bindings.bindBidirectional( recurrenceThresholdTextField.textProperty(), recurrenceThresholdProperty(), DecimalFormat.getInstance()); // sync GUI and model embedding parameters Bindings.bindBidirectional( embeddingDimensionTextField.textProperty(), embeddingDimensionProperty(), DecimalFormat.getIntegerInstance()); Bindings.bindBidirectional( embeddingDelayTextField.textProperty(), embeddingDelayProperty(), DecimalFormat.getIntegerInstance()); // sync GUI and noise parameter Bindings.bindBidirectional(noiseSlider.valueProperty(), noiseRatioProperty()); Bindings.bindBidirectional( eachKthPointTextField.textProperty(), eachKthPointProperty(), DecimalFormat.getIntegerInstance()); // enable the compute button only if the auto-update checkbox is not on. computeRPButton.disableProperty().bind(sliderAutoUpdate.selectedProperty()); // recompute RP on parameter changes subsampleLengthSlider.valueProperty().addListener(this::parametersChanged); eachKthPointTextField .textProperty() .addListener( (obs, ov, nv) -> { parametersChanged(null, null, null); }); recurrenceThresholdProperty().addListener(this::parametersChanged); embeddingDimensionProperty().addListener(this::parametersChanged); embeddingDelayProperty().addListener(this::parametersChanged); noiseRatioProperty().addListener(this::parametersChanged); // Make CRT controls update the computation // size of the CRT histogram crtLimit .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { parametersChanged(null, Integer.parseInt(oldValue), Integer.parseInt(newValue)); } }); // CRT log scale option logScaleCheckBox .selectedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (oldValue != newValue) parametersChanged(null, 0, 0); } }); // make the CRT image use all the available vertical space crtImageView.fitWidthProperty().bind(crtTabPane.widthProperty().subtract(20)); crtImageView.fitHeightProperty().bind(crtTabPane.heightProperty()); // swap the data of the line length histogram upon selecting another line type lineLengthTypeSelector.setItems( FXCollections.observableArrayList( "DIAGONAL", "VERTICAL", "WHITE_VERTICAL", "ORTHOGONAL")); // DRQA.LineType.DIAGONAL, DRQA.LineType.VERTICAL, // DRQA.LineType.WHITE_VERTICAL, DRQA.LineType.ORTHOGONAL lineLengthTypeSelector .getSelectionModel() .selectedIndexProperty() .addListener(this::updateLineLengthHistogram); lineLengthTypeSelector.getSelectionModel().select(0); distanceDistributionSelector.setItems(FXCollections.observableArrayList("SUBSEQ", "PAIRWISE")); distanceDistributionSelector .getSelectionModel() .selectedIndexProperty() .addListener((obs, ov, nv) -> updateDistanceDistributionChart()); distanceDistributionSelector.getSelectionModel().select(0); useDRQA .selectedProperty() .addListener( (obs, ov, nv) -> updateLineLengthHistogram( null, null, lineLengthTypeSelector.getSelectionModel().getSelectedIndex())); }
private void setButtonDisabled(boolean val) { MainButton.disableProperty().setValue(val); }