@Override
  public void init() {
    // allow multiple rows selection
    tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    // listener for items selection change
    tableView
        .getSelectionModel()
        .getSelectedIndices()
        .addListener(
            (ListChangeListener<Integer>)
                change -> {
                  if (change.getList().size() > 0) {
                    setContextMenuState(true, true, true, true);
                  } else {
                    setContextMenuState(false, false, false, false);
                  }
                });

    // prevent table columns reordering
    tableView
        .getColumns()
        .addListener(
            (ListChangeListener<TableColumn<FileItem, ?>>)
                change -> {
                  change.next();
                  if (change.wasReplaced()) {
                    tableView.getColumns().clear();
                    tableView.getColumns().addAll(selectColumn, filenameColumn, filepathColumn);
                  }
                });

    // set column as a CheckBox column
    selectColumn.setCellFactory(
        cellData -> {
          CheckBoxTableCell<FileItem, Boolean> checkBoxTableCell = new CheckBoxTableCell<>();
          // set value changed listener
          checkBoxTableCell.setSelectedStateCallback(
              index -> tableView.getItems().get(index).selectedProperty());
          return checkBoxTableCell;
        });

    // add checkbox to column heading
    selectFilesCheckBox = new CheckBox();
    selectFilesCheckBox.setDisable(true);
    selectColumn.setGraphic(selectFilesCheckBox);
    selectFilesCheckBox
        .selectedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              synchronized (LOCK) {
                tableView.getItems().forEach(fileItem -> fileItem.setSelected(newValue));
              }
            });

    // set value of cells in column
    selectColumn.setCellValueFactory(cellData -> cellData.getValue().selectedProperty());
    filenameColumn.setCellValueFactory(cellData -> cellData.getValue().filenameProperty());
    filepathColumn.setCellValueFactory(cellData -> cellData.getValue().filepathProperty());
  }
Esempio n. 2
0
  private TitledPane createTitledPane(CreditRequest creditRequest) {
    TitledPane titledPane = new TitledPane();
    titledPane.setText("UserId: " + creditRequest.getUserId());
    VBox vBox = new VBox();
    TextFlow textFlow = new TextFlow();

    Label label = new Label(creditRequest.toString());
    label.setWrapText(true);
    textFlow.getChildren().add(label);

    textFlow.getChildren().add(new Label("Validate: "));
    CheckBox isValidCheckBox = new CheckBox();
    CheckBox rejectCheckBox = new CheckBox();

    isValidCheckBox
        .selectedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue == true) {
                rejectCheckBox.setSelected(false);
                creditRequest.setValidated(true);
              } else {
                creditRequest.setValidated(null);
              }
            });
    textFlow.getChildren().add(isValidCheckBox);

    textFlow.getChildren().add(new Label("Reject: "));
    rejectCheckBox
        .selectedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue == true) {
                isValidCheckBox.setSelected(false);
                creditRequest.setValidated(false);
              } else {
                creditRequest.setValidated(null);
              }
            });
    textFlow.getChildren().add(rejectCheckBox);

    Button creditHistoryButton = new Button("View Credit History");
    creditHistoryButton.setOnAction(
        e -> {
          session.setUserUnderValidationId(creditRequest.getUserId());
          screens.toCreditHistoryPage();
        });
    vBox.getChildren().add(textFlow);
    vBox.getChildren().add(creditHistoryButton);

    titledPane.setContent(vBox);

    return titledPane;
  }
Esempio n. 3
0
 /** {@inheritDoc} */
 @Override
 protected Modello buildEntity() {
   Modello modello = new Modello();
   try {
     if (id != 0) {
       modello.setId(id);
     }
     modello.setTipoCarburante(tipoCarburante.getSelectionModel().getSelectedItem());
     modello.setCapacitàBagagliaio(Integer.parseInt(capacitàBagagliaio.getText()));
     modello.setNumeroPorte(Integer.parseInt(numeroPorte.getText()));
     modello.setMarca(marca.getText());
     modello.setNome(nome.getText());
     modello.setEmissioniCO2(Double.parseDouble(emissioniCO2.getText()));
     modello.setNumeroPosti(Integer.parseInt(numeroPosti.getText()));
     modello.setPotenza(Integer.parseInt(potenza.getText()));
     modello.setPeso(Integer.parseInt(peso.getText()));
     modello.setTrasmissioneAutomatica(trasmissioneAutomatica.selectedProperty().get());
     if (!fascia.getText().isEmpty())
       modello.setFascia((Fascia) controller.processRequest("ReadFascia", fascia.getText()));
     else modello.setFascia(null);
     return modello;
   } catch (Exception e) {
     return null;
   }
 }
 public SettingsPane() {
   draw();
   model =
       new SettingsModel(
           preloadLogtalkCheckBox.selectedProperty(), entryFilePathText.textProperty());
   style();
 }
Esempio n. 5
0
  public FileTreePane() {
    loadDynamicComponentFxml(FileTreePane.class, this);
    rootFileTreeItem = new RootFileTreeItem(this);

    // The root here is *not* the real root of the file system and should be hidden, because
    // (1) we might want to have 'virtual' visible roots like "Home", "Desktop", "Drives" and
    // (2) even if we displayed only the real file system without any shortcuts like "Desktop",
    // we'd still have multiple roots on a crappy pseudo-OS like Windows still having these shitty
    // drive letters.
    treeTableView.setShowRoot(false);
    treeTableView.setRoot(rootFileTreeItem);
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    treeTableView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (ChangeListener<TreeItem<FileTreeItem<?>>>)
                (observable, o, n) -> updateSelectedFiles());
    treeTableView
        .getSelectionModel()
        .getSelectedItems()
        .addListener((InvalidationListener) observable -> updateSelectedFiles());

    selectedFiles.addListener(selectedFilesChangeListener);
    showHiddenFilesCheckBox.selectedProperty().bindBidirectional(showHiddenFilesProperty);

    // TODO remove the following line - preferably replace by proper, use-case-dependent management!
    selectedFiles.add(IOUtil.getUserHome());
    updateDisable();
  }
  public void setAccountTypeFilter(final AccountTypeFilter filter) {

    // Bind the buttons to the filter
    bankAccountCheckBox
        .selectedProperty()
        .bindBidirectional(filter.getAccountTypesVisibleProperty());
    incomeAccountCheckBox
        .selectedProperty()
        .bindBidirectional(filter.getIncomeTypesVisibleProperty());
    expenseAccountCheckBox
        .selectedProperty()
        .bindBidirectional(filter.getExpenseTypesVisibleProperty());
    hiddenAccountCheckBox
        .selectedProperty()
        .bindBidirectional(filter.getHiddenTypesVisibleProperty());
  }
 @FXML
 public void handleAsyncMode(ActionEvent e) {
   try {
     ((RemoteOrderDisplay) service).setAsyncMode(asyncMode.selectedProperty().getValue());
   } catch (JposException e1) {
     JOptionPane.showMessageDialog(null, e1.getMessage());
     e1.printStackTrace();
   }
 }
Esempio n. 8
0
  @Override
  public Pane getVisSettings() {

    GridPane pane = new GridPane();
    pane.setPadding(new Insets(10, 0, 0, 0));
    pane.setHgap(5);
    pane.setVgap(5);

    // Dimension selection box
    ComboBox<String> dimCombo = new ComboBox<>();
    ObservableList<String> dimensions = FXCollections.observableArrayList();
    dimensions.add("X");
    dimensions.add("Y");
    dimensions.add("Z");
    dimCombo.setItems(dimensions);
    dimCombo.setValue(dimensions.get(2));
    dimCombo
        .valueProperty()
        .addListener(
            (ov, oldStr, newStr) -> {
              if (newStr.equals("X")) {
                renderer.setViewingDimension(0);
              } else if (newStr.equals("Y")) {
                renderer.setViewingDimension(1);
              } else {
                renderer.setViewingDimension(2);
              }
              renderer.render();
              Controller.getInstance().updateHistogram();
            });

    Label dimLabel = new Label();
    dimLabel.setText("Projection dimension: ");
    dimLabel.setLabelFor(dimCombo);

    pane.add(dimLabel, 0, 0);
    pane.add(dimCombo, 1, 0);

    // Scale checkbox
    CheckBox scaleBox = new CheckBox("Scale: ");
    scaleBox.setSelected(true);
    scaleBox
        .selectedProperty()
        .addListener(
            (ov, old_val, new_val) -> {
              renderer.setScaling(new_val);
              renderer.render();
            });
    pane.add(scaleBox, 0, 1);

    return pane;
  }
Esempio n. 9
0
 /** {@inheritDoc} */
 @Override
 public void initModifica(Modello entity) {
   edit = true;
   id = entity.getId();
   capacitàBagagliaio.setText(Integer.toString(entity.getCapacitàBagagliaio()));
   numeroPorte.setText(Integer.toString(entity.getNumeroPorte()));
   numeroPosti.setText(Integer.toString(entity.getNumeroPosti()));
   marca.setText(entity.getMarca());
   nome.setText(entity.getNome());
   emissioniCO2.setText(Double.toString(entity.getEmissioniCO2()));
   potenza.setText(Integer.toString(entity.getPotenza()));
   peso.setText(Integer.toString(entity.getPeso()));
   fascia.setText(Integer.toString(entity.getFascia().getId()));
   trasmissioneAutomatica.selectedProperty().set(entity.isTrasmissioneAutomatica());
 }
Esempio n. 10
0
 @Override
 @SuppressWarnings("unchecked")
 public void updateItem(Boolean checked, boolean empty) {
   super.updateItem(checked, empty);
   if (checked != null && getTableRow() != null) {
     checkBox.setSelected(checked);
     checkBox
         .selectedProperty()
         .addListener(
             (check, oldValue, newValue) -> {
               Object item = getTableRow().getItem();
               setBoolean((S) item, newValue);
             });
     setGraphic(checkBox);
     setStyle("-fx-alignment: CENTER;");
   }
 }
 public void initialize(URL location, ResourceBundle resources) {
   autoRefreshCheckBox
       .selectedProperty()
       .addListener(
           new ChangeListener<Boolean>() {
             @Override
             public void changed(
                 ObservableValue<? extends Boolean> observable,
                 Boolean oldValue,
                 Boolean newValue) {
               lastAutoRefresh = autoRefreshCheckBox.isSelected();
               // Only refresh when auto-refresh enabled
               if (lastAutoRefresh) {
                 refresh();
               }
             }
           });
 }
Esempio n. 12
0
  @FXML
  private void initialize() {

    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    if (engine != null) {
      accountSeparatorTextField.setText(engine.getAccountSeparator());

      accountSeparatorTextField
          .textProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                if (newValue != null && newValue.length() > 0) {
                  engine.setAccountSeparator(newValue);
                }
              });
    } else {
      accountSeparatorTextField.setDisable(true);
    }

    useAccountingTermsCheckBox
        .selectedProperty()
        .bindBidirectional(Options.useAccountingTermsProperty());

    switch (AccountBalanceDisplayManager.getDisplayMode()) {
      case NONE:
        noAccountsRadioButton.setSelected(true);
        break;
      case REVERSE_CREDIT:
        creditAccountsRadioButton.setSelected(true);
        break;
      case REVERSE_INCOME_EXPENSE:
        incomeExpenseAccountsRadioButton.setSelected(true);
        break;
    }

    noAccountsRadioButton
        .selectedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue) {
                AccountBalanceDisplayManager.setDisplayMode(AccountBalanceDisplayMode.NONE);
              }
            });

    creditAccountsRadioButton
        .selectedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue) {
                AccountBalanceDisplayManager.setDisplayMode(
                    AccountBalanceDisplayMode.REVERSE_CREDIT);
              }
            });

    incomeExpenseAccountsRadioButton
        .selectedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue) {
                AccountBalanceDisplayManager.setDisplayMode(
                    AccountBalanceDisplayMode.REVERSE_INCOME_EXPENSE);
              }
            });
  }
Esempio n. 13
0
  public MyPortfolioTab(MyPortfolioProc p) {
    mpProc = p;
    root.getChildren().addAll(toolBar, mainTable, kmPanel);
    VBox.setVgrow(mainTable, Priority.ALWAYS);
    toolBar.getItems().addAll(portfolioBtn, ckShowGraphBox);
    splitPane.setOrientation(Orientation.VERTICAL);
    splitPane.getItems().addAll(root);
    final Stage parent = CandySimpleGuiMain.getInstance().getPrimaryStage();
    portfolioBtn.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            if (portfolioDlg == null) {
              portfolioDlg = new PortfolioDlg(parent, true, "Edit Portfolio List");
            }
            portfolioDlg.sizeToScene();
            portfolioDlg.showAndWait();
            ArrayList<String> lst = portfolioDlg.getSymbolLst();
            if (lst != null) {
              processPortfolioLst(lst);
            }
          }
        });
    ckShowGraphBox.setSelected(false);
    ckShowGraphBox
        .selectedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              public void changed(
                  ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean newVal) {
                if (newVal) {
                  splitPane.getItems().addAll(chartBox);
                } else {
                  splitPane.getItems().remove(chartBox);
                }
              }
            });
    ckKeyStathBox.setSelected(false);
    ckKeyStathBox
        .selectedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              public void changed(
                  ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean newVal) {
                if (newVal) {
                  splitPane.getItems().addAll(chartBox);
                } else {
                  splitPane.getItems().remove(chartBox);
                }
              }
            });

    chartBox.getChildren().addAll(pieChart.getGUI(), lcChart);
    chartBox.setStyle("-fx-border-color: gray");
    HBox.setHgrow(lcChart, Priority.ALWAYS);

    setText(TAB_NAME);
    setContent(splitPane);
    setClosable(false);
    updateGuiData(mpProc.getGuiData());
    updatePieChart(mpProc.getPieChartData());
    updateLcChart(mpProc.getLcXData(), mpProc.getLcYData());
  }
Esempio n. 14
0
  @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();
  }
  public void init(Model model, Terminal terminal) {

    // ==============================================//
    // ================ DECODING SETUP ==============//
    // ==============================================//

    // Populate decoding options combobox
    layoutOptionsComboBox.getItems().setAll(Display.LayoutOptions.values());

    // Add listener to combobox
    layoutOptionsComboBox.setOnAction(
        event -> {

          // Bind the decoder decoding option to what has been selected in the
          // combobox
          terminal.txRx.display.selLayoutOption.set(
              layoutOptionsComboBox.getSelectionModel().getSelectedItem());
        });

    // Set default
    layoutOptionsComboBox.getSelectionModel().select(terminal.txRx.display.selLayoutOption.get());

    TooltipUtil.addDefaultTooltip(
        layoutOptionsComboBox,
        "Separate mode displays a separate pane for RX data (top), and TX data (bottom). Combined mode shows one pane for both RX and TX data (if local echo is enabled). Combined mode with local echo turned on behaves similarly to a terminal.");

    // ==============================================//
    // ============= SETUP LOCAL TX ECHO ============//
    // ==============================================//

    // Bind the model boolean to the checkbox
    terminal.txRx.display.localTxEcho.bind(localTxEchoCheckBox.selectedProperty());

    TooltipUtil.addDefaultTooltip(
        localTxEchoCheckBox,
        "If enabled, sent TX data will be copied (echoed) into the RX display.");

    // ==============================================//
    // =============== BACKSPACE SETUP ==============//
    // ==============================================//

    Bindings.bindBidirectional(
        backspaceRemovesLastTypedCharCheckBox.selectedProperty(),
        terminal.txRx.display.backspaceRemovesLastTypedChar);

    // Enable this checkbox only if the selected TX sending option is
    // on press on the "enter" key (this is the only way that this functionality makes sense)
    ChangeListener<Formatting.TxCharSendingOptions> changeListener =
        (observable, oldValue, newValue) -> {
          switch (newValue) {
            case SEND_TX_CHARS_IMMEDIATELY:
              backspaceRemovesLastTypedCharCheckBox.setDisable(true);
              break;
            case SEND_TX_CHARS_ON_ENTER:
              backspaceRemovesLastTypedCharCheckBox.setDisable(false);
              break;
            default:
              throw new RuntimeException("TxCharSendingOptions option not recognised.");
          }
        };
    terminal.txRx.formatting.selTxCharSendingOption.addListener(changeListener);

    // Update disabled state to default
    changeListener.changed(
        terminal.txRx.formatting.selTxCharSendingOption,
        terminal.txRx.formatting.selTxCharSendingOption.get(),
        terminal.txRx.formatting.selTxCharSendingOption.get());

    TooltipUtil.addDefaultTooltip(
        backspaceRemovesLastTypedCharCheckBox,
        "Enabling this will allow you to use backspace to delete TX chars before they are sent (on applicable if 'Send TX chars on enter' is selected). Disabling this will instead send the backspace character to the COM port.");

    // ==============================================//
    // ================ SETUP WRAPPING ==============//
    // ==============================================//

    // Bind "wrapping enabled" checkbox to model
    terminal.txRx.display.wrappingEnabled.bind(wrappingCheckBox.selectedProperty());

    TooltipUtil.addDefaultTooltip(
        wrappingCheckBox,
        "Enable this to wrap at a certain pixel width (as defined below). If this is disabled, long lines of TX/RX text will cause horizontal scroll-bars to appear.");

    // Upon pressing enter or loosing focus, try and convert the wrapping width value and
    // update the model
    wrappingWidthTextField.onApply.addListener(
        (observable, oldValue, newValue) -> {
          // Convert wrapping width string into double, and then perform
          // sanity checks
          Double wrappingWidth;
          try {
            wrappingWidth = Double.parseDouble(newValue);
          } catch (NumberFormatException e) {
            model.status.addErr("Wrapping width was not a valid number.");
            wrappingWidth = 0.0;
          }

          if (wrappingWidth <= 0.0) {
            model.status.addErr("Wrapping width must be greater than 0.");
            wrappingWidth = 0.0;
          }

          terminal.txRx.display.wrappingWidth.set(wrappingWidth);
        });

    // Set default value from model
    // (we assume the value in the model to be valid and no checking needed)
    wrappingWidthTextField
        .textProperty()
        .set(Double.toString(terminal.txRx.display.wrappingWidth.get()));

    // Disable the wrapping width textfield if wrapping is disabled.
    terminal.txRx.display.wrappingEnabled.addListener(
        (observable, oldValue, newValue) -> {
          wrappingWidthTextField.setDisable(!newValue);
        });

    // Set default state
    wrappingWidthTextField.setDisable(!terminal.txRx.display.wrappingEnabled.get());

    TooltipUtil.addDefaultTooltip(
        wrappingWidthTextField, "The width (in pixels) that you want TX/RX data to wrap at.");

    // ==============================================//
    // ============== BUFFER-SIZE SETUP =============//
    // ==============================================//

    // Perform a bi-directional bind, with custom string-to-number conversion which takes care
    // of any errors.
    Bindings.bindBidirectional(
        bufferSizeTextField.onApply,
        terminal.txRx.display.bufferSizeChars,
        new NumberStringConverter() {
          @Override
          public Number fromString(String value) {

            // Convert wrapping width string into double, and then perform
            // sanity checks
            Integer intValue;
            try {
              intValue = Integer.parseInt(value);
            } catch (NumberFormatException e) {
              model.status.addErr("Buffer size is not a valid integer.");
              return terminal.txRx.display.DEFAULT_BUFFER_SIZE_CHARS;
            }

            if (intValue <= 0.0) {
              model.status.addErr("Buffer size must be greater than 0.");
              return terminal.txRx.display.DEFAULT_BUFFER_SIZE_CHARS;
            }

            return intValue;
          }

          @Override
          public String toString(Number value) {
            return ((Integer) value).toString();
          }
        });

    // Add validation support for the buffer size
    ValidationSupport support = new ValidationSupport();

    Validator<String> validator =
        (Control control, String value) -> {
          boolean condition;
          try {
            Integer.parseInt(value);
            condition = false;
          } catch (RuntimeException e) {
            condition = true;
          }

          return ValidationResult.fromMessageIf(
              control, "Not a valid integer", Severity.ERROR, condition);
        };

    support.registerValidator(bufferSizeTextField, true, validator);

    TooltipUtil.addDefaultTooltip(
        bufferSizeTextField,
        "The max. number of characters to store in the TX and RX panes. Once the num. of characters exceeds this limit, the oldest characters are removed from the UI (this does not affect logging).");

    // ==============================================//
    // =========== SCROLL BEHAVIOUR SETUP ===========//
    // ==============================================//

    //        ToggleGroupValue<Display.ScrollBehaviour> scrollBehaviourToggleGroup = new
    // ToggleGroupValue();
    //        scrollBehaviourToggleGroup.add(scrollBehaviourStandardRadioButton,
    // Display.ScrollBehaviour.STANDARD);
    //        scrollBehaviourToggleGroup.add(scrollBehaviourSmartRadioButton,
    // Display.ScrollBehaviour.SMART);
    //
    //        Bindings.bindBidirectional(scrollBehaviourToggleGroup.valueProperty(),
    // terminal.txRx.display.scrollBehaviour);
    //
    //        TooltipUtil.addDefaultTooltip(scrollBehaviourStandardRadioButton, "When the RX buffer
    // is full, the RX pane will not scroll automatically to keep the same lines of RX text in
    // view.");
    //        TooltipUtil.addDefaultTooltip(scrollBehaviourSmartRadioButton, "When the RX buffer is
    // full, the RX pane will scroll automatically to keep the same lines of RX text in view (only
    // when scroll-to-bottom is not currently active).");

  }
Esempio n. 16
0
 public BooleanProperty getAnimatedCheckboxSelectedProperty() {
   return animateCheckbox.selectedProperty();
 }
  /**
   * 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()));
  }
Esempio n. 18
-1
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX layouts samples");

    Tab hboxTab = new Tab();
    hboxTab.setText("HBox");
    hboxTab.setClosable(false);
    hboxLayout.setBackground(createBackground(Color.LIGHTGREEN));
    hboxTab.setContent(hboxLayout);

    Tab vboxTab = new Tab();
    vboxTab.setText("VBox");
    vboxTab.setClosable(false);
    vboxLayout.setBackground(createBackground(Color.ORANGE));
    vboxTab.setContent(vboxLayout);

    Tab flowPaneTab = new Tab();
    flowPaneTab.setText("FlowPane");
    flowPaneTab.setClosable(false);
    flowLayout.setBackground(createBackground(Color.LIGHTSKYBLUE));
    flowPaneTab.setContent(flowLayout);

    Tab gridPaneTab = new Tab("GridPane");
    gridPaneTab.setClosable(false);
    gridLayout.setBackground(createBackground(Color.LIGHTCORAL));
    gridLayout.setGridLinesVisible(true);
    gridPaneTab.setContent(gridLayout);

    Tab borderPaneTab = new Tab();
    borderPaneTab.setText("BorderPane");
    borderPaneTab.setClosable(false);
    borderLayout.setBackground(createBackground(Color.LIGHTYELLOW));
    borderPaneTab.setContent(borderLayout);

    Tab stackPaneTab = new Tab();
    stackPaneTab.setText("StackPane");
    stackPaneTab.setClosable(false);
    stackLayout.setBackground(createBackground(Color.YELLOW));
    stackPaneTab.setContent(stackLayout);

    Tab tilePaneTab = new Tab("TilePane");
    tilePaneTab.setClosable(false);
    tileLayout.setBackground(createBackground(Color.LIGHTGOLDENRODYELLOW));
    tilePaneTab.setContent(tileLayout);

    updateChildren(false);
    TabPane tabPane = new TabPane();
    tabPane
        .getTabs()
        .addAll(
            hboxTab, vboxTab, flowPaneTab, gridPaneTab, borderPaneTab, stackPaneTab, tilePaneTab);

    VBox optionsPanel = new VBox();
    CheckBox componentType = new CheckBox("Use Buttons instead of Rectangles");
    componentType
        .selectedProperty()
        .addListener((observable, oldValue, newValue) -> updateChildren(newValue));
    optionsPanel.getChildren().add(componentType);
    optionsPanel.setPadding(new Insets(10));

    BorderPane mainLayout = new BorderPane();
    mainLayout.setCenter(tabPane);
    mainLayout.setLeft(optionsPanel);

    // show the generated scene graph
    Scene scene = new Scene(mainLayout);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Esempio n. 19
-1
  public GameController() {
    logger.debug("Instantiating model");
    board = new Board();

    logger.debug("Instantiating views");
    boardView = new BoardView(Block.COUNT);

    // instantiate click event handler only one time to save instantiation time
    EventHandler<MouseEvent> onCellViewClicked =
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            boardView.requestFocus();
            CellView cellView = (CellView) event.getSource();
            moveFocusTo(cellView.row, cellView.col);
          }
        };

    // apply click event handler to all cells
    board.forEach(cell -> boardView.getCellView(cell).setOnMouseClicked(onCellViewClicked));

    // apply key press handler to the board (not each individual cell)
    boardView.setOnKeyPressed(this);

    // instantiate timer
    timer = new TimerWidget();

    // init check box for toggling hint mode
    hintMode = new CheckBox("Pencil (SHIFT)");
    hintMode.setFocusTraversable(false);
    autoMode = new CheckBox("Automation");
    autoMode.setFocusTraversable(false);
    autoMode.setSelected(true);
    remainMode = new CheckBox("Show remaining sum");
    remainMode.setFocusTraversable(false);
    remainMode.setSelected(true);

    // listener for hint mode and remain mode
    hintMode
        .selectedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue) {
                  boardView.setHintsCursor();
                } else {
                  boardView.setValueCursor();
                }
              }
            });

    remainMode
        .selectedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                toggleGroupSumMode(newValue);
              }
            });

    VBox controlBox = new VBox(hintMode, autoMode, remainMode);
    controlBox.setPadding(new Insets(0, 10, 0, 50));
    controlBox.setSpacing(4);

    // init combination list view
    combinationView = new CombinationView();

    // init combinator view
    combinator = new CombinatorWidget();

    // organize all components in grid style
    view = new GridPane();
    view.setBackground(BackgroundFactory.create(Color.rgb(200, 230, 200)));
    view.add(boardView, 0, 0);
    controlPanel = new VBox(timer, controlBox, combinationView, combinator);
    controlPanel.setAlignment(Pos.TOP_CENTER);
    view.add(controlPanel, 1, 0);
  }