/**
  * Sets the right handle icon to a given resource.
  *
  * <p>The resource should refer to a Drawable object, or use 0 to remove the icon.
  *
  * @param iconId the resource ID of the icon drawable
  * @param targetId the resource of the target drawable
  * @param barId the resource of the bar drawable (stateful)
  * @param tabId the resource of the
  */
 public void setRightTabResources(int iconId, int targetId, int barId, int tabId) {
   mRightSlider.setIcon(iconId);
   mRightSlider.setTarget(targetId);
   mRightSlider.setBarBackgroundResource(barId);
   mRightSlider.setTabBackgroundResource(tabId);
   mRightSlider.updateDrawableStates();
 }
 /**
  * Reset the tabs to their original state and stop any existing animation. Animate them back into
  * place if animate is true.
  *
  * @param animate
  */
 public void reset(boolean animate) {
   mLeftSlider.reset(animate);
   mRightSlider.reset(animate);
   if (!animate) {
     mAnimating = false;
   }
 }
示例#3
0
文件: ListBox.java 项目: star003/sb
 /**
  * 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;
       }
     }
   }
 }
  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
    if (!changed) return;

    // Center the widgets in the view
    mLeftSlider.layout(l, t, r, b, isHorizontal() ? Slider.ALIGN_LEFT : Slider.ALIGN_BOTTOM);
    mRightSlider.layout(l, t, r, b, isHorizontal() ? Slider.ALIGN_RIGHT : Slider.ALIGN_TOP);
  }
示例#5
0
文件: ListBox.java 项目: star003/sb
 protected void updateScroll() {
   _myScrollValue = _myScrollbar.getValue();
   _myScrollbar.setValue(_myScrollValue);
   if (buttons.size() < items.size() && isScrollbarVisible) {
     _myScrollbar.show();
   }
   updateBackground();
   scroll();
 }
 private void cancelGrab() {
   mTracking = false;
   mTriggered = false;
   mOtherSlider.show(true);
   mCurrentSlider.reset(false);
   mCurrentSlider.hideTarget();
   mCurrentSlider = null;
   mOtherSlider = null;
   setGrabbedState(OnTriggerListener.NO_HANDLE);
 }
示例#7
0
  public void scrollByUnit(int direction) {
    float size;
    if (orientation == VERTICAL) {
      direction *= -1;
      size = scrollSpace + slider.getThumbButton().getHeight() / slider.getHeight();
    } else size = scrollSpace + slider.getThumbButton().getWidth() / slider.getWidth();

    if (direction == DECREMENT) setValue(getValue() - size);
    else setValue(getValue() + size);
  }
示例#8
0
文件: ListBox.java 项目: star003/sb
 protected void updateBackground() {
   if (items.size() * (_myItemHeight + spacing) < _myOriginalBackgroundHeight) {
     _myBackgroundHeight = items.size() * (_myItemHeight + spacing);
   }
   if (buttons.size() < items.size()) {
     _myScrollbar.setHeight(_myBackgroundHeight - spacing);
     _myScrollbar.show();
   } else {
     _myScrollbar.hide();
   }
   updateButtonWidth();
 }
示例#9
0
 public boolean touchDown(float x, float y, int pointer, int button) {
   for (Slider slider : getBlocksOfType(Slider.class)) {
     if (slider.getRect().contains(x, y)) {
       //                final Vector2 v = new Vector2();
       //                slider.getRect().getCenter(v);
       //                v.sub(x, y);
       //                slider.target.add(v);
       draggedMap.put(pointer, slider);
     }
   }
   return true;
 }
示例#10
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();
   }
 }
示例#11
0
 public PercentageSliderField() {
   slider = new Slider();
   slider.setMin(0);
   slider.setMax(100);
   slider.setSizeFull();
   slider.addValueChangeListener(
       new ValueChangeListener() {
         @Override
         public void valueChange(Property.ValueChangeEvent event) {
           setPercentageValue((Double) event.getProperty().getValue());
         }
       });
 }
 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;
 }
  @Override
  public boolean onInterceptTouchEvent(MotionEvent event) {
    final int action = event.getAction();
    final float x = event.getX();
    final float y = event.getY();

    if (mAnimating) {
      return false;
    }

    View leftHandle = mLeftSlider.tab;
    leftHandle.getHitRect(mTmpRect);
    boolean leftHit = mTmpRect.contains((int) x, (int) y);

    View rightHandle = mRightSlider.tab;
    rightHandle.getHitRect(mTmpRect);
    boolean rightHit = mTmpRect.contains((int) x, (int) y);

    if (!mTracking && !(leftHit || rightHit)) {
      return false;
    }

    switch (action) {
      case MotionEvent.ACTION_DOWN:
        {
          mTracking = true;
          mTriggered = false;
          vibrate(VIBRATE_SHORT);
          if (leftHit) {
            mCurrentSlider = mLeftSlider;
            mOtherSlider = mRightSlider;
            mThreshold = isHorizontal() ? THRESHOLD : 1.0f - THRESHOLD;
            setGrabbedState(OnTriggerListener.LEFT_HANDLE);
          } else {
            mCurrentSlider = mRightSlider;
            mOtherSlider = mLeftSlider;
            mThreshold = isHorizontal() ? 1.0f - THRESHOLD : THRESHOLD;
            setGrabbedState(OnTriggerListener.RIGHT_HANDLE);
          }
          mCurrentSlider.setState(Slider.STATE_PRESSED);
          mCurrentSlider.showTarget();
          mOtherSlider.hide();
          break;
        }
    }

    return true;
  }
示例#14
0
文件: ListBox.java 项目: star003/sb
 public ListBox showScrollbar() {
   isScrollbarVisible = true;
   if ((items.size()) * _myItemHeight > _myBackgroundHeight && isScrollbarVisible) {
     _myScrollbar.show();
   }
   return this;
 }
示例#15
0
 @Override
 protected void setInternalValue(Double newValue) {
   if (newValue != null) {
     super.setInternalValue(newValue);
     slider.setValue(newValue);
   }
 }
示例#16
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);
  }
示例#17
0
文件: ListBox.java 项目: star003/sb
 protected void scroll() {
   itemOffset = 0;
   if (buttons.size() < items.size() && isScrollbarVisible) {
     _myScrollbar.show();
     itemOffset = (int) Math.abs(_myScrollValue * (items.size() - buttons.size()));
   } else {
     _myScrollbar.hide();
   }
   if (!bulkadding) {
     for (int i = 0; i < buttons.size(); i++) {
       ListBoxItem item = items.get(itemOffset + i);
       Button b = buttons.get(i);
       b.getCaptionLabel().toUpperCase(isToUpperCase);
       b.setColor(item.getColor());
       b.getCaptionLabel().set(item.getText());
       b._myValue = item.getValue();
     }
   }
 }
示例#18
0
文件: ListBox.java 项目: star003/sb
  protected ListBox(
      ControlP5 theControlP5,
      ControllerGroup<?> theGroup,
      String theName,
      int theX,
      int theY,
      int theW,
      int theH) {
    super(theControlP5, theGroup, theName, theX, theY, theW, 9);

    items = new ArrayList<ListBoxItem>();

    buttons = new ArrayList<Button>();

    _myWidth = theW;

    _myName = theName;

    // workaround fix see code.goode.com/p/controlp5 issue 7
    _myBackgroundHeight = theH < 10 ? 10 : theH;

    _myScrollbar =
        new Slider(
            cp5,
            _myParent,
            theName + "Scroller",
            0,
            1,
            1,
            _myWidth - _myScrollbarWidth,
            0,
            _myScrollbarWidth,
            _myBackgroundHeight);
    _myScrollbar.setBroadcast(false);
    _myScrollbar.setSliderMode(Slider.FLEXIBLE);
    _myScrollbar.setMoveable(false);
    _myScrollbar.setLabelVisible(false);
    _myScrollbar.setParent(this);
    _myScrollbar.addListener(this);
    _myScrollbar.setVisible(false);
    _myScrollbar.hide();
    _myScrollbar.updateDisplayMode(DEFAULT);
    add(_myScrollbar);
    setHeight(_myBackgroundHeight);
  }
示例#19
0
  protected void init() {
    super.init();

    // populate grid
    for (LinPos p : grid.getLinGrid()) {
      grid.set(p.i, new Square());
    }

    {
      Block block = new Block().setPos(2.3f, 3);
      blocks.add(block);
    }
    {
      follower = new Follower();
      follower.textureRegion = T.blockTextureRegion.get(4);
      follower.setPos(8f, 3);
      blocks.add(follower);
    }
    {
      Slider slider = new Slider();
      slider.textureRegion = T.blockTextureRegion.get(3);
      slider.setPos(5, 6.4f);
      slider.target.set(5, 6);
      blocks.add(slider);
    }

    {
      Slider slider = new Slider();
      slider.textureRegion = T.blockTextureRegion.get(3);
      slider.setPos(5, 6.4f);
      slider.target.set(2, 6);
      blocks.add(slider);
    }
  }
  @FXML
  public void compute() {
    double[][] transformedTrajectory = getTransformedTrajectory();
    if (transformedTrajectory == null) return;

    // compute and display RP
    BufferedImage rp =
        DRQA.getRPImage(
            transformedTrajectory, transformedTrajectory, recurrenceThresholdSlider.getValue());
    rpImageView.setImage(SwingFXUtils.toFXImage(rp, null));
    applyImageScale();

    // compute and display CRT
    DRQA.conditional_ww_limit = Integer.parseInt(crtLimit.getText());
    DRQA.CRT_LOG_SCALE = logScaleCheckBox.isSelected();
    drqa =
        new DRQA(
            transformedTrajectory, transformedTrajectory, recurrenceThresholdSlider.getValue());
    BufferedImage crt = drqa.getCRTImage(DRQA.conditional_ww_limit, drqa.conditional_ww);
    crtImageView.setImage(SwingFXUtils.toFXImage(crt, null));
    String[] stats = drqa.crtStatistics().split("\t");
    crtStats.setText(
        String.format(
            "mean row: %.2f\tmean col: %.2f\ncorrelation: %.2f\nmax row: %s\tmax col: %s\nlocal maxima: %s\nentropy: %.2f",
            Double.parseDouble(stats[0]),
            Double.parseDouble(stats[1]),
            Double.parseDouble(stats[2]),
            stats[3],
            stats[4],
            stats[5],
            Double.parseDouble(stats[6])));

    drqa.computeRQA(2, 2, 2);
    rqaMeasures.setText(drqa.printableString(DRQA.STANDARD_RQA));

    updateTimeSeriesChart();
    updateDistanceDistributionChart();
    updateLineLengthHistogram(
        null, null, lineLengthTypeSelector.getSelectionModel().getSelectedIndex());
  }
 /** Initializes the Slider */
 private void initializeSlider() {
   sliderSubsToRemove
       .valueProperty()
       .addListener(
           new ChangeListener<Number>() {
             @Override
             public void changed(
                 ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
               percentageToRemove = (int) sliderSubsToRemove.getValue();
               labelEffectivePercent.setText(Integer.toString(percentageToRemove) + " %");
               pieChartSubsToRemove.getData().get(0).setPieValue(100 - percentageToRemove);
               pieChartSubsToRemove.getData().get(1).setPieValue(percentageToRemove);
             }
           });
 }
示例#22
0
  public GUICommPack() {
    super(null, "CommPack");

    this.xSize = 248;
    this.ySize = 193;
    this.offsy = -45;
    launchButton.clickAction =
        new Runnable() {
          public void run() {}
        };

    power.state = 99;
    focus.state = 99;

    addClickable(power);
    addClickable(focus);
    addClickable(rate);

    addClickable(ptf);
    addClickable(dtf);
    addClickable(rtf);
    power.clickAction = new Adjustor.StateToNumberText(power, ptf);
    //		ptf.clickAction= new Adjustor.NumberTextToState(ptf, power);
    focus.clickAction = new Adjustor.StateToNumberText(focus, dtf);
    //		dtf.clickAction= new Adjustor.NumberTextToState(dtf, dispersion);
    rate.clickAction = new Adjustor.StateToNumberText(rate, rtf);
    //		rtf.clickAction= new Adjustor.NumberTextToState(rtf, rate);

    addClickable(launchButton);

    launchButton.clickAction = calldown;

    power.clickAction.run();
    focus.clickAction.run();
    rate.clickAction.run();
  }
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (mTracking) {
      final int action = event.getAction();
      final float x = event.getX();
      final float y = event.getY();

      switch (action) {
        case MotionEvent.ACTION_MOVE:
          if (withinView(x, y, this)) {
            moveHandle(x, y);
            float position = isHorizontal() ? x : y;
            float target = mThreshold * (isHorizontal() ? getWidth() : getHeight());
            boolean thresholdReached;
            if (isHorizontal()) {
              thresholdReached =
                  mCurrentSlider == mLeftSlider ? position > target : position < target;
            } else {
              thresholdReached =
                  mCurrentSlider == mLeftSlider ? position < target : position > target;
            }
            if (!mTriggered && thresholdReached) {
              mTriggered = true;
              mTracking = false;
              mCurrentSlider.setState(Slider.STATE_ACTIVE);
              boolean isLeft = mCurrentSlider == mLeftSlider;
              dispatchTriggerEvent(
                  isLeft ? OnTriggerListener.LEFT_HANDLE : OnTriggerListener.RIGHT_HANDLE);

              startAnimating(isLeft ? mHoldLeftOnTransition : mHoldRightOnTransition);
              setGrabbedState(OnTriggerListener.NO_HANDLE);
            }
            break;
          }
          // Intentionally fall through - we're outside tracking rectangle

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
          cancelGrab();
          break;
      }
    }

    return mTracking || super.onTouchEvent(event);
  }
示例#24
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);
  }
示例#25
0
 private void updateHeight() {
   if (getHeight() == 0) {
     setHeight(DEFAULT_SIZE);
     return;
   }
   if (orientation == HORIZONTAL) {
     incButton.setHeight(Math.min(getHeight(), incButton.getHeight()));
     decButton.setHeight(Math.min(getHeight(), decButton.getHeight()));
     slider.setHeight(Math.min(getHeight(), slider.getHeight()));
     slider.setY(getHeight() / 2f - slider.getHeight() / 2f);
     incButton.setY(getHeight() / 2f - incButton.getHeight() / 2f);
     decButton.setY(getHeight() / 2f - incButton.getHeight() / 2f);
   } else { // VERTICAL
     decButton.setY(getHeight() - decButton.getHeight());
     slider.setY(incButton.getHeight());
     slider.setHeight(getHeight() - (incButton.getHeight() + decButton.getHeight()));
   }
 }
示例#26
0
 private void updateWidth() {
   if (getWidth() == 0) {
     setWidth(DEFAULT_SIZE);
     return;
   }
   if (orientation == HORIZONTAL) {
     incButton.setX(getWidth() - incButton.getWidth());
     slider.setX(decButton.getWidth());
     slider.setWidth(getWidth() - (incButton.getWidth() + decButton.getWidth()));
   } else { // VERTICAL
     incButton.setWidth(Math.min(getWidth(), incButton.getWidth()));
     decButton.setWidth(Math.min(getWidth(), decButton.getWidth()));
     slider.setWidth(Math.min(getWidth(), slider.getWidth()));
     slider.setX(getWidth() / 2f - slider.getWidth() / 2f);
     incButton.setX(getWidth() / 2f - incButton.getWidth() / 2f);
     decButton.setX(getWidth() / 2f - incButton.getWidth() / 2f);
   }
 }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
    int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);

    int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);

    if (DBG) {
      if (widthSpecMode == MeasureSpec.UNSPECIFIED || heightSpecMode == MeasureSpec.UNSPECIFIED) {
        Log.e(
            "SlidingTab",
            "SlidingTab cannot have UNSPECIFIED MeasureSpec"
                + "(wspec="
                + widthSpecMode
                + ", hspec="
                + heightSpecMode
                + ")",
            new RuntimeException(LOG_TAG + "stack:"));
      }
    }

    mLeftSlider.measure(widthMeasureSpec, heightMeasureSpec);
    mRightSlider.measure(widthMeasureSpec, heightMeasureSpec);
    final int leftTabWidth = mLeftSlider.getTabWidth();
    final int rightTabWidth = mRightSlider.getTabWidth();
    final int leftTabHeight = mLeftSlider.getTabHeight();
    final int rightTabHeight = mRightSlider.getTabHeight();
    final int width;
    final int height;
    if (isHorizontal()) {
      width = Math.max(widthSpecSize, leftTabWidth + rightTabWidth);
      height = Math.max(leftTabHeight, rightTabHeight);
    } else {
      width = Math.max(leftTabWidth, rightTabHeight);
      height = Math.max(heightSpecSize, leftTabHeight + rightTabHeight);
    }
    setMeasuredDimension(width, height);
  }
示例#28
0
  /**
   * Sets the appearance for this scroll bar. If <code>appearance</code> is not an instance of
   * ScrollBarAppearance, an <code>IllegalArgumentException</code> is thrown.
   *
   * @param appearance the new appearance to set
   */
  public void setAppearance(ComponentAppearance appearance) {
    if (appearance == null)
      throw new IllegalStateException("null appearance not allowed with ScrollBar");
    if (!(appearance instanceof ScrollBarAppearance)) {
      throw new IllegalArgumentException("appearance must be instance of ScrollBarAppearance");
    }
    super.setAppearance(appearance);

    // de-init components
    if (slider != null) {
      remove(slider);
      slider.removeMouseWheelListener(incDecListener);
      slider.getThumbButton().removeMouseWheelListener(incDecListener);
      // slider.getDelayTimer().removeActionListener(delayListener);

    }
    if (incButton != null) {
      remove(incButton);
      incButton.removeActionListener(incDecListener);
    }
    if (decButton != null) {
      remove(decButton);
      decButton.removeActionListener(incDecListener);
    }

    // re-init components

    // gets the current appearance
    ScrollBarAppearance a = (ScrollBarAppearance) this.getAppearance();
    if (a == null) {
      throw new IllegalStateException("no appearance set for this scroll bar");
    }

    // creates scroll & thumb buttons
    // skins can choose how they should be created
    incButton = a.createScrollButton(this, INCREMENT);
    decButton = a.createScrollButton(this, DECREMENT);
    slider = a.createSlider(this, orientation);

    if (incButton == null || decButton == null || slider == null)
      throw new NullPointerException("null components passed to scroll bar");
    if (slider.getOrientation() != orientation)
      throw new IllegalArgumentException("passed slider doesn't match orientation of scroll bar");

    // add scroll listeners buttons
    incButton.addActionListener(incDecListener);
    decButton.addActionListener(incDecListener);
    // slider.getDelayTimer().addActionListener(delayListener);

    // add the new components to this bar
    add(slider);
    add(incButton);
    add(decButton);

    incButton.addMouseWheelListener(incDecListener);
    decButton.addMouseWheelListener(incDecListener);
    slider.addMouseWheelListener(incDecListener);
    slider.getThumbButton().addMouseWheelListener(incDecListener);
    addMouseWheelListener(incDecListener);

    updateWidth();
    updateHeight();
  }
 /**
  * Sets the left handle hint text to a given resource string.
  *
  * @param resId
  */
 public void setLeftHintText(int resId) {
   if (isHorizontal()) {
     mLeftSlider.setHintText(resId);
   }
 }
 /**
  * Sets the left handle hint text to a given resource string.
  *
  * @param resId
  */
 public void setRightHintText(int resId) {
   if (isHorizontal()) {
     mRightSlider.setHintText(resId);
   }
 }