Esempio n. 1
0
 /**
  * Adding key support. up and down arrows can be used to scroll listbox or dropdownList,up and
  * down, use shift+up/down for faster scrolling, use alt+up/down to jump to the top or bottom.
  *
  * @exclude {@inheritDoc}
  */
 @ControlP5.Invisible
 public void keyEvent(final KeyEvent theEvent) {
   super.keyEvent(theEvent);
   float x = getAbsolutePosition().x;
   float y = getAbsolutePosition().y;
   boolean b =
       (getWindow().mouseX > x
           && getWindow().mouseX < (x + _myWidth)
           && getWindow().mouseY > (y - getBarHeight())
           && getWindow().mouseY < y + _myOriginalBackgroundHeight);
   if (b && isOpen()) {
     float step = (1.0f / (float) items.size());
     if (cp5.isShiftDown()) {
       step *= 10;
     } else if (cp5.isAltDown()) {
       step = 1;
     }
     if (theEvent.getAction() == KeyEvent.PRESSED) {
       switch (theEvent.getKeyCode()) {
         case (PApplet.UP):
           _myScrollbar.setValue(PApplet.constrain(_myScrollbar.getValue() + step, 0, 1));
           break;
         case (PApplet.DOWN):
           _myScrollbar.setValue(PApplet.constrain(_myScrollbar.getValue() - step, 0, 1));
           break;
       }
     }
   }
 }
Esempio n. 2
0
 /** @param color */
 public void setColor(Color color) {
   colorR = color.r;
   colorG = color.g;
   colorB = color.b;
   colorA = color.a;
   if (sliderR != null) {
     sliderR.setValue(colorR * 100);
     sliderG.setValue(colorG * 100);
     sliderB.setValue(colorB * 100);
     sliderA.setValue(colorA * 100);
     setBtnColorSampleColor();
   }
 }
Esempio n. 3
0
 @Override
 protected void setInternalValue(Double newValue) {
   if (newValue != null) {
     super.setInternalValue(newValue);
     slider.setValue(newValue);
   }
 }
Esempio n. 4
0
  void decreaseVolume() {
    if (player == null) return;
    double newVolume = Settings.currentVolume - 0.05;

    if (newVolume < 0.0) newVolume = 0.0;
    Settings.currentVolume = newVolume;
    player.setVolume(newVolume);
    volumeSlider.setValue(newVolume);
  }
Esempio n. 5
0
 protected void updateScroll() {
   _myScrollValue = _myScrollbar.getValue();
   _myScrollbar.setValue(_myScrollValue);
   if (buttons.size() < items.size() && isScrollbarVisible) {
     _myScrollbar.show();
   }
   updateBackground();
   scroll();
 }
 private Slider createPercentSlider() {
   final Slider percentSlider = new Slider(1, 100);
   percentSlider.addListener(
       new Property.ValueChangeListener() {
         @Override
         public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
           percentLabel.setValue(Double.toString(percentSlider.getValue()) + " %");
           changePercentage((int) ((double) percentSlider.getValue()));
         }
       });
   percentSlider.setValue(50d);
   return percentSlider;
 }
Esempio n. 7
0
  public void initialize(URL location, ResourceBundle resources) {
    txtFieldGeldEingabe.textProperty().bindBidirectional(viewModel.geldEingabe());
    txtFieldZeitEingabe.textProperty().bindBidirectional(viewModel.zeitEinagabe());
    labelQualitaet.textProperty().bindBidirectional(viewModel.qualitaetText());
    labelZeit.textProperty().bindBidirectional(viewModel.zeitText());
    labelSkill.textProperty().bindBidirectional(viewModel.skillText());
    labelGehalt.textProperty().bindBidirectional(viewModel.gehaltText());
    labelGeld.textProperty().bindBidirectional(viewModel.geldText());
    labelGesundheit.textProperty().bindBidirectional(viewModel.gesundheitText());
    labelMotivation.textProperty().bindBidirectional(viewModel.motivationText());
    SliderGehalt.valueProperty().bindBidirectional(viewModel.gehaltProperty());
    SliderGehalt.setValue(1500);
    SliderGehalt.setShowTickMarks(false);
    SliderGehalt.setMajorTickUnit(1);
    SliderGehalt.setMinorTickCount(0);
    SliderGehalt.setBlockIncrement(100);
    SliderGehalt.setSnapToTicks(true);

    labelNeuesGehalt.textProperty().bind(SliderGehalt.valueProperty().asString("%.0f"));

    buttonStart.setOnAction(
        event -> {
          buttonNachsteRunde.setDisable(false);
          buttonStart.setDisable(true);
          txtFieldGeldEingabe.setDisable(true);
          txtFieldZeitEingabe.setDisable(true);
          viewModel.startRound();
        });

    buttonNachsteRunde.setOnAction(
        event -> {
          RadioButton rb = (RadioButton) ToggleGroupSelect.getSelectedToggle();
          viewModel.nextRound(rb.getText());
        });

    viewModel.setButtonNaechsteRunde(buttonNachsteRunde);
    viewModel.setButtonStart(buttonStart);
    viewModel.setTxtFieldGeldEingabe(txtFieldGeldEingabe);
    viewModel.setTxtFieldZeitEingabe(txtFieldZeitEingabe);
  }
Esempio n. 8
0
  private void initalize() {

    //
    // Wygenerowanie buttonow
    //
    sliderR = GuiResource.slider(0, 100, 1, "colorDialogSliderR", skin);
    sliderG = GuiResource.slider(0, 100, 1, "colorDialogSliderG", skin);
    sliderB = GuiResource.slider(0, 100, 1, "colorDialogSliderB", skin);
    sliderA = GuiResource.slider(0, 100, 1, "colorDialogSliderA", skin);

    //
    // Fix slider FixScroll
    //
    sliderR.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
          }
        });

    sliderG.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
          }
        });

    sliderB.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
          }
        });

    sliderA.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
          }
        });

    labelTextR = GuiResource.label("R", "colorTextDialogLabelR", skin);
    labelTextG = GuiResource.label("G", "colorTextDialogLabelG", skin);
    labelTextB = GuiResource.label("B", "colorTextDialogLabelB", skin);
    labelTextA = GuiResource.label("A", "colorTextDialogLabelA", skin);

    labelR = GuiResource.label("red", "colorDialogLabelR", skin);
    labelG = GuiResource.label("green", "colorDialogLabelG", skin);
    labelB = GuiResource.label("blue", "colorDialogLabelB", skin);
    labelA = GuiResource.label("alpha", "colorDialogLabelA", skin);

    color = new Color();

    //
    // Tworzenie image textury podgladu
    //
    pixmap = new Pixmap(128, 32, Pixmap.Format.RGBA8888); // Pixmap.Format.RGBA8888);
    pixmap.setColor(1, 1, 1, 1);
    pixmap.fillRectangle(0, 0, 128, 32);
    texture = new Texture(pixmap);
    region = new TextureRegion(texture);
    imageActor = new Image(region);

    //
    // Podpiecie akcji do buttonow i sliderow
    //
    sliderR.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float value = sliderR.getValue();
            colorR = value / 100;
            setBtnColorSampleColor();
          }
        });

    sliderG.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float value = sliderG.getValue();
            colorG = value / 100;
            setBtnColorSampleColor();
          }
        });

    sliderB.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float value = sliderB.getValue();
            colorB = value / 100;
            setBtnColorSampleColor();
          }
        });

    sliderA.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            float value = sliderA.getValue();
            colorA = value / 100;
            setBtnColorSampleColor();
          }
        });

    add(labelTextR).left().width(10);
    add(sliderR).left().fillX().expandX();
    add(labelR).left().width(20);
    row();
    add(labelTextG).left().width(10);
    add(sliderG).left().fillX().expandX();
    add(labelG).left().width(20);
    row();
    add(labelTextB).left().width(10);
    add(sliderB).left().fillX().expandX();
    add(labelB).left().width(20);

    if (alphaChanel) {
      row();
      add(labelTextA).left().width(10);
      add(sliderA).left().fillX().expandX();
      add(labelA).left().width(20);
    }

    row();
    add().left().width(Cfg.gridX1);
    add(imageActor).left().colspan(2);

    //
    // Inicjacja stanów
    //
    if (colorR < 0) {
      colorR = 0;
    }
    if (colorR > 1) {
      colorR = 1;
    }
    if (colorG < 0) {
      colorG = 0;
    }
    if (colorG > 1) {
      colorG = 1;
    }
    if (colorB < 0) {
      colorB = 0;
    }
    if (colorB > 1) {
      colorB = 1;
    }
    if (colorA < 0) {
      colorA = 0;
    }
    if (colorA > 1) {
      colorA = 1;
    }

    sliderR.setValue(colorR * 100);
    sliderG.setValue(colorG * 100);
    sliderB.setValue(colorB * 100);
    sliderA.setValue(colorA * 100);
    setBtnColorSampleColor();
  }
Esempio n. 9
0
  public void draw() {
    background(0);
    // Strings composition
    textFont(createFont("Arial bold", 24));
    fill(c_red);
    stroke(255);
    text("OpenWheels GUI V1.0", 20, 30);
    textSize(16);
    // textAlign(CENTER);
    fill(c_azure);
    text("Acc_RAW:  " + Acc_RAW, 150, 65);
    AccSlider.setValue(Acc_RAW);
    text("Gyro_RAW: " + Gyro_RAW, 150, 90);
    GyroSlider.setValue(Gyro_RAW);
    text("Acc_Angle:  " + Acc_Angle + "\u00b0", 150, 115);
    text("Gyro_Rate: " + Gyro_Rate + "\u00b0/sec", 150, 140);
    text("Drive: " + Drive, 150, 165);
    text("Steer: " + Steer, 150, 190);
    text("BatLevel: " + nf(BatLevel, 1, 1) + "V", 150, 215);
    text("Status: " + statusFlag, 150, 240);
    graphGauge();
    graphGrid();

    // call the function that plot the angular of acc, with few screen settings
    graphRoll(PApplet.parseFloat(Acc_Angle), VideoBuffer2, c_red); // xPos, YPos, YSpan
    // call the function that plot the estimate angular, with few screen settings
    graphRoll(Angle, VideoBuffer1, c_yellow); // xPos, YPos, YSpan

    // call arduino for data every timePolling [msec]
    int timePolling = 50; // 50msec=20Hz
    time1 = millis();
    if (init_com == 1) {
      while (serial.available() > 0) processSerialData();
      if ((time1 - time2) > timePolling) {
        if (requestPID == true) {
          serial.write('E');
          requestPID = false;
        } else if (writePID == true) {
          int P = PApplet.parseInt(conf_KP.value());
          int I = PApplet.parseInt(conf_KI.value());
          int D = PApplet.parseInt(conf_KD.value());
          char data[] = {0, 0, 0, 0, 0};
          data[0] = 'W';
          data[1] = PApplet.parseChar(P);
          data[2] = PApplet.parseChar(I);
          data[3] = PApplet.parseChar(D);
          data[4] = ' ';
          String str = new String(data);
          serial.write(str);
          println(str);
          // println(" P=" + P + " I=" + I + " D=" + D);
          writePID = false;
        }
        // else if (RUN==true ) {serial.write('A');}
        else {
          serial.write('A');
        }
        time2 = time1;
      }
    }
  }
Esempio n. 10
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    AppController.instance = this;
    this.res = resources;

    ObservableList<String> modeItems =
        FXCollections.observableArrayList(
            Settings.MODE_NEXT, Settings.MODE_RANDOM, Settings.MODE_SAME);
    modeList.setItems(modeItems);
    modeList.getSelectionModel().select(Settings.currentMode);
    modeList
        .valueProperty()
        .addListener(
            (ObservableValue ov, Object oldVal, Object newVal) -> {
              Settings.currentMode = (String) newVal;
            });

    setupPlaylistsView();
    setupPlaylistsContextMenu();

    setupTracksView();

    tracksView.setContextMenu(tracksContextMenu);
    tracksView.setOnContextMenuRequested(
        (ContextMenuEvent evt) -> {
          setupTracksContextMenu();
          evt.consume();
        });
    tracksView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (ObservableValue observable, Object oldValue, Object newValue) -> {
              Settings.lastTrackId = newValue != null ? ((Track) newValue).getId() : null;
            });

    playlistsView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (ObservableValue observable, Object oldValue, Object newValue) -> {
              loadSelectedPlaylist();
              Settings.lastPlaylistId = newValue != null ? ((Playlist) newValue).getId() : null;
              searching = false;
              searchText.setText(StringUtils.EMPTY);
            });

    volumeSlider.setCursor(Cursor.HAND);
    volumeSlider
        .valueProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number oldVal, Number newVal) -> {
              if (player != null) {
                player.setVolume(newVal.doubleValue());
              }
              Settings.currentVolume = newVal.doubleValue();
              volumeLabel.setText(
                  String.valueOf((int) Math.ceil(newVal.doubleValue() * 100)) + "%");
            });
    volumeSlider.setValue(Settings.currentVolume);

    imagePlay = new ImageView(new Image(getClass().getResourceAsStream("/images/button_play.png")));
    imagePlay.setScaleX(0.40);
    imagePlay.setScaleY(0.40);
    imagePause =
        new ImageView(new Image(getClass().getResourceAsStream("/images/button_pause.png")));
    imagePause.setScaleX(0.5);
    imagePause.setScaleY(0.5);
    imageSettings =
        new ImageView(new Image(getClass().getResourceAsStream("/images/settings.png")));
    imageSettings.setScaleX(0.5);
    imageSettings.setScaleY(0.5);
    imageUpdate = new ImageView(new Image(getClass().getResourceAsStream("/images/refresh.png")));
    imageUpdate.setScaleX(0.5);
    imageUpdate.setScaleY(0.5);
    imageAdd = new ImageView(new Image(getClass().getResourceAsStream("/images/add.png")));
    imageAdd.setScaleX(0.5);
    imageAdd.setScaleY(0.5);
    imageRename = new ImageView(new Image(getClass().getResourceAsStream("/images/rename.png")));
    imageRename.setScaleX(0.5);
    imageRename.setScaleY(0.5);
    imageDelete = new ImageView(new Image(getClass().getResourceAsStream("/images/delete.png")));
    imageDelete.setScaleX(0.5);
    imageDelete.setScaleY(0.5);

    stateButton.setGraphic(imagePlay);
    settingsButton.setGraphic(imageSettings);
    refreshButton.setGraphic(imageUpdate);
    refreshButton.setTooltip(new Tooltip(res.getString("tooltip_sync")));

    addButton.setGraphic(imageAdd);
    addButton.setOnAction((evt) -> createOfflinePlaylist());
    addButton.setTooltip(new Tooltip(res.getString("tooltip_add_offline")));
    renameButton.setGraphic(imageRename);
    renameButton.setOnAction(evt -> renamePlaylist());
    renameButton.setTooltip(new Tooltip(res.getString("rename_playlist")));
    deleteButton.setGraphic(imageDelete);
    deleteButton.setOnAction(evt -> deletePlaylist());
    deleteButton.setTooltip(new Tooltip(res.getString("delete_playlist")));

    loadProgressBar.setCursor(Cursor.HAND);
    volumeSlider.setCursor(Cursor.HAND);
    updatePlaylists();
    if (Settings.lastPlaylistId != null) {
      currentPlaylist =
          ((ObservableList<Playlist>) playlistsView.getItems())
              .stream()
              .filter((playlist) -> playlist.getId().equals(Settings.lastPlaylistId))
              .findFirst()
              .orElse(null);
      playlistsView.getSelectionModel().select(currentPlaylist);
      playlistsView.scrollTo(currentPlaylist);
      Platform.runLater(
          () -> {
            if (Settings.lastTrackId != null) {
              currentTrack =
                  ((ObservableList<Track>) tracksView.getItems())
                      .stream()
                      .filter((track) -> track.getId().equals(Settings.lastTrackId))
                      .findFirst()
                      .orElse(null);
              tracksView.getSelectionModel().select(currentTrack);
              tracksView.scrollTo(currentTrack);
            }
          });
    }
    new Timer()
        .scheduleAtFixedRate(
            new TimerTask() {
              @Override
              public void run() {
                updatePlayProgress();
              }
            },
            100,
            100);
    setupTracksContextMenu();

    setupShortcuts();

    Platform.runLater(
        () -> {
          tracksView.requestFocus();
        });
  }
Esempio n. 11
0
 /** scroll the scrollList remotely. values must range between 0 and 1. */
 public ListBox scroll(float theValue) {
   if ((items.size()) * _myItemHeight > _myBackgroundHeight) {
     _myScrollbar.setValue(PApplet.abs(1 - PApplet.min(PApplet.max(0, theValue), 1)));
   }
   return this;
 }