Ejemplo n.º 1
0
  @Override
  public void refresh() {
    getRoot()
        .getScene()
        .addEventFilter(
            KeyEvent.KEY_PRESSED,
            new EventHandler<KeyEvent>() {

              @Override
              public void handle(KeyEvent event) {
                if (event.getCode().equals(KeyCode.ESCAPE)) {
                  cancel();
                } else if (event.getCode().equals(KeyCode.ENTER)) {
                  save();
                }
              }
            });
    languages.getItems().clear();
    languages.getItems().addAll(ResourceUtil.LOCALES);
    languages.setConverter(
        new StringConverter<Locale>() {

          @Override
          public Locale fromString(String string) {
            return null;
          }

          @Override
          public String toString(Locale object) {
            return object.getDisplayLanguage();
          }
        });
    languages.getSelectionModel().select(getPresenter().getLanguage());
  }
Ejemplo n.º 2
0
  @Override
  public void initialize() {
    currencyComboBox = new ComboBox<>();
    currencyComboBox.setPromptText("Select currency");
    currencyComboBox.setConverter(
        new StringConverter<TradeCurrency>() {
          @Override
          public String toString(TradeCurrency tradeCurrency) {
            return tradeCurrency.getCodeAndName();
          }

          @Override
          public TradeCurrency fromString(String s) {
            return null;
          }
        });

    Label currencyLabel = new Label("Currency:");
    HBox currencyHBox = new HBox();
    currencyHBox.setSpacing(5);
    currencyHBox.setPadding(new Insets(10, -20, 0, 20));
    currencyHBox.setAlignment(Pos.CENTER_LEFT);
    currencyHBox.getChildren().addAll(currencyLabel, currencyComboBox);

    createChart();

    Tuple2<TableView<Offer>, VBox> tupleBuy = getOfferTable(Offer.Direction.BUY);
    Tuple2<TableView<Offer>, VBox> tupleSell = getOfferTable(Offer.Direction.SELL);
    buyOfferTableView = tupleBuy.first;
    sellOfferTableView = tupleSell.first;

    HBox hBox = new HBox();
    hBox.setSpacing(30);
    hBox.setAlignment(Pos.CENTER);
    hBox.getChildren().addAll(tupleBuy.second, tupleSell.second);

    root.getChildren().addAll(currencyHBox, areaChart, hBox);
  }
Ejemplo n.º 3
0
  /** 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();
        });
  }
Ejemplo n.º 4
0
  @FXML
  private void initialize() {
    duringInitialization = true;

    ResourceBundle bundle = util.getBundle();
    EmulationSection emulationSection = util.getConfig().getEmulationSection();

    mainFilters = FXCollections.<String>observableArrayList();
    mainFilter.setItems(mainFilters);
    secondFilters = FXCollections.<String>observableArrayList();
    secondFilter.setItems(secondFilters);
    thirdFilters = FXCollections.<String>observableArrayList();
    thirdFilter.setItems(thirdFilters);

    NumberToString<Double> doubleToString = new NumberToString<Double>(1);
    mainBalance.setValue(util.getConfig().getAudioSection().getMainBalance());
    mainBalance.setLabelFormatter(doubleToString);
    mainBalance
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              util.getConfig().getAudioSection().setMainBalance(newValue.floatValue());
              util.getPlayer().configureMixer(m -> m.setBalance(0, newValue.floatValue()));
            });
    secondBalance.setValue(util.getConfig().getAudioSection().getSecondBalance());
    secondBalance.setLabelFormatter(doubleToString);
    secondBalance
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              util.getConfig().getAudioSection().setSecondBalance(newValue.floatValue());
              util.getPlayer().configureMixer(m -> m.setBalance(1, newValue.floatValue()));
            });
    thirdBalance.setValue(util.getConfig().getAudioSection().getThirdBalance());
    thirdBalance.setLabelFormatter(doubleToString);
    thirdBalance
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              util.getConfig().getAudioSection().setThirdBalance(newValue.floatValue());
              util.getPlayer().configureMixer(m -> m.setBalance(2, newValue.floatValue()));
            });

    mainVolume.setValue(util.getConfig().getAudioSection().getMainVolume());
    mainVolume
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              util.getConfig().getAudioSection().setMainVolume(newValue.floatValue());
              util.getPlayer().configureMixer(m -> m.setVolume(0, newValue.floatValue()));
            });
    secondVolume.setValue(util.getConfig().getAudioSection().getSecondVolume());
    secondVolume
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              util.getConfig().getAudioSection().setSecondVolume(newValue.floatValue());
              util.getPlayer().configureMixer(b -> b.setVolume(1, newValue.floatValue()));
            });
    thirdVolume.setValue(util.getConfig().getAudioSection().getThirdVolume());
    thirdVolume
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              util.getConfig().getAudioSection().setThirdVolume(newValue.floatValue());
              util.getPlayer().configureMixer(b -> b.setVolume(2, newValue.floatValue()));
            });

    stereoModes = FXCollections.<StereoMode>observableArrayList(StereoMode.values());
    stereoMode.setConverter(new EnumToString<StereoMode>(bundle));
    stereoMode.setItems(stereoModes);

    baseAddress.setText(String.format("0x%4x", emulationSection.getDualSidBase()));
    thirdAddress.setText(String.format("0x%4x", emulationSection.getThirdSIDBase()));

    sidReads = FXCollections.<SidReads>observableArrayList(SidReads.values());
    sidToRead.setConverter(new EnumToString<SidReads>(bundle));
    sidToRead.setItems(sidReads);
    sidToRead.getSelectionModel().select(emulationSection.getSidNumToRead());

    sid1Emulations = FXCollections.<Emulation>observableArrayList(Emulation.values());
    sid1Emulation.setConverter(new EnumToString<Emulation>(bundle));
    sid1Emulation.setItems(sid1Emulations);
    sid1Emulation.getSelectionModel().select(emulationSection.getUserEmulation());

    sid2Emulations = FXCollections.<Emulation>observableArrayList(Emulation.values());
    sid2Emulation.setConverter(new EnumToString<Emulation>(bundle));
    sid2Emulation.setItems(sid2Emulations);
    sid2Emulation.getSelectionModel().select(emulationSection.getStereoEmulation());

    sid3Emulations = FXCollections.<Emulation>observableArrayList(Emulation.values());
    sid3Emulation.setConverter(new EnumToString<Emulation>(bundle));
    sid3Emulation.setItems(sid3Emulations);
    sid3Emulation.getSelectionModel().select(emulationSection.getThirdEmulation());

    sid1Models = FXCollections.<ChipModel>observableArrayList(ChipModel.values());
    sid1Model.setConverter(new EnumToString<ChipModel>(bundle));
    sid1Model.setItems(sid1Models);
    sid1Model.getSelectionModel().select(emulationSection.getUserSidModel());

    sid2Models = FXCollections.<ChipModel>observableArrayList(ChipModel.values());
    sid2Model.setConverter(new EnumToString<ChipModel>(bundle));
    sid2Model.setItems(sid2Models);
    sid2Model.getSelectionModel().select(emulationSection.getStereoSidModel());

    sid3Models = FXCollections.<ChipModel>observableArrayList(ChipModel.values());
    sid3Model.setConverter(new EnumToString<ChipModel>(bundle));
    sid3Model.setItems(sid3Models);
    sid3Model.getSelectionModel().select(emulationSection.getThirdSIDModel());

    defaultModels =
        FXCollections.<ChipModel>observableArrayList(ChipModel.MOS6581, ChipModel.MOS8580);
    defaultModel.setConverter(new EnumToString<ChipModel>(bundle));
    defaultModel.setItems(defaultModels);
    defaultModel.getSelectionModel().select(emulationSection.getDefaultSidModel());

    defaultEmulations =
        FXCollections.<Emulation>observableArrayList(Emulation.RESID, Emulation.RESIDFP);
    defaultEmulation.setConverter(new EnumToString<Emulation>(bundle));
    defaultEmulation.setItems(defaultEmulations);
    defaultEmulation.getSelectionModel().select(emulationSection.getDefaultEmulation());

    boosted8580.setSelected(emulationSection.isDigiBoosted8580());

    emulationChange = new EmulationChange();
    util.getPlayer().stateProperty().addListener(emulationChange);

    Platform.runLater(
        () -> {
          updateSettingsForTune(util.getPlayer().getTune());
          duringInitialization = false;
        });
  }
Ejemplo n.º 5
0
  @FXML
  private void initialize() {
    m_combo.setItems(Person.DEFAULT_DATA);
    m_combo.setConverter(
        new StringConverter<Person>() {

          @Override
          public String toString(Person p) {
            return p.getFirstName().get()
                + " "
                + p.getLastName().get()
                + " ("
                + p.getAge().get()
                + ")";
          }

          @Override
          public Person fromString(String string) {
            for (Person p : m_combo.getItems()) {
              String current =
                  p.getFirstName().get()
                      + " "
                      + p.getLastName().get()
                      + " ("
                      + p.getAge().get()
                      + ")";
              if (current.equals(string)) {
                return p;
              }
            }
            return null;
          }
        });

    m_slider.setMin(0);
    m_slider.setMax(100);
    m_slider.setValue(50);

    m_spinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 100, 0, 1));

    m_list.setItems(Person.DEFAULT_DATA);
    m_list.setCellFactory(
        new Callback<ListView<Person>, ListCell<Person>>() {

          @Override
          public ListCell<Person> call(ListView<Person> p) {

            return new ListCell<Person>() {
              @Override
              protected void updateItem(Person p1, boolean bln) {
                super.updateItem(p1, bln);
                if (p1 != null) {
                  String current =
                      p1.getFirstName().get()
                          + " "
                          + p1.getLastName().get()
                          + " ("
                          + p1.getAge().get()
                          + ")";
                  setText(current);
                }
              }
            };
          }
        });
  }