示例#1
0
  @Override
  public void start(Stage pPrimaryStage) {
    aText.setText(PART_1);
    pPrimaryStage.setTitle("Welcome to COMP303");
    aButton.setOnAction(this);

    aSkin.selectedToggleProperty().addListener(this);

    RadioButton rb1 = new RadioButton("Plain");
    rb1.setToggleGroup(aSkin);
    rb1.setUserData("Plain");
    rb1.setSelected(true);

    RadioButton rb2 = new RadioButton("Floral");
    rb2.setUserData("Floral");
    rb2.setToggleGroup(aSkin);

    RadioButton rb3 = new RadioButton("Chintz");
    rb3.setUserData("Chintz");
    rb3.setToggleGroup(aSkin);

    VBox centerPanel = new VBox(MARGIN);
    centerPanel.setPadding(new Insets(MARGIN));
    centerPanel.setAlignment(Pos.CENTER);
    centerPanel.getChildren().addAll(aText, aButton);

    BorderPane root = new BorderPane();
    root.setCenter(centerPanel);

    HBox bottomPanel = new HBox(MARGIN);
    bottomPanel.setPadding(new Insets(MARGIN));
    bottomPanel.setAlignment(Pos.CENTER);
    bottomPanel.getChildren().addAll(rb1, rb2, rb3);
    root.setBottom(bottomPanel);

    aScene = new Scene(root, WIDTH, HEIGHT);
    pPrimaryStage.setResizable(false);
    pPrimaryStage.setScene(aScene);
    pPrimaryStage.show();
  }
示例#2
0
  @Override
  public void initialize(URL arg0, ResourceBundle arg1) {
    textTrackName.setText(track.getName());
    textDynamicRange.setText(String.format("%.2f dB", track.getDynamicRange()));

    drawTrack();

    radioButtonActiveTrack.setToggleGroup(toggleGroup);
    radioButtonActiveTrack.setUserData(new WeakReference<>(track));
    if (toggleGroup.getSelectedToggle() == null) {
      radioButtonActiveTrack.setSelected(true);
    }

    textAreaComment.textProperty().bindBidirectional(track.commentProperty());
  }
示例#3
0
  /**
   * When the component is created, it initialize the component representation and adding listener
   * and MouseEvent
   *
   * @param location type URL
   * @param resources type ResourceBundle
   */
  @Override
  public void initialize(final URL location, final ResourceBundle resources) {
    super.initialize(location, resources);

    // Configure exponential potentiometer
    expFrequency
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              vcoa.setExponentialFrequency((double) newValue);
              updateScreen();
              linFrequency.setMinValue(
                  String.valueOf(
                      (int) (vcoa.getLinearFrequencyMin() * vcoa.getExponentialFrequency())));
              linFrequency.setMaxValue(
                  String.valueOf(
                      (int) (vcoa.getLinearFrequencyMax() * vcoa.getExponentialFrequency())));
            });
    expFrequency.setTitle("Exp. Freq.");
    expFrequency.setMinValue(0);
    expFrequency.setMaxValue(16);

    // Configure linear potentiometer
    linFrequency
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              vcoa.setLinearFrequency((Double) newValue);
              updateScreen();
            });
    linFrequency.setTitle("Linear Freq.");

    // Configure amplitude potentiometer
    amplitude
        .valueProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              vcoa.setAmplitudeOscillator((Double) newValue);
            });
    amplitude.setTitle("Amplitude");
    amplitude.setMinValue("0%");
    amplitude.setMaxValue("100%");

    sineRadio.setToggleGroup(groupRadio);
    squareRadio.setToggleGroup(groupRadio);
    triangleRadio.setToggleGroup(groupRadio);
    sawtoothRadio.setToggleGroup(groupRadio);

    sineRadio.setUserData("sineWave");
    squareRadio.setUserData("squareWave");
    triangleRadio.setUserData("triangleWave");
    sawtoothRadio.setUserData("sawtoothWave");

    groupRadio
        .selectedToggleProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (groupRadio.getSelectedToggle() != null) {
                final Image image =
                    new Image(
                        getClass()
                            .getResourceAsStream(
                                "/ui/images/"
                                    + groupRadio.getSelectedToggle().getUserData()
                                    + ".png"));
                oscillatorImage.setImage(image);

                switch (groupRadio.getSelectedToggle().getUserData().toString()) {
                  case "sineWave":
                    vcoa.setOscillatorType(OscillatorType.SINE);
                    break;
                  case "squareWave":
                    vcoa.setOscillatorType(OscillatorType.SQUARE);
                    break;
                  case "triangleWave":
                    vcoa.setOscillatorType(OscillatorType.TRIANGLE);
                    break;
                  case "sawtoothWave":
                    vcoa.setOscillatorType(OscillatorType.SAWTOOTH);
                    break;
                  default:
                    break;
                }
              }
            });

    squareRadio.setSelected(true);
  }