Exemplo n.º 1
0
 public FloatControlBoundedRangeModel(FloatControl control) {
   this.control = control;
   float range = 100;
   float steps = range / 100;
   factor = range / steps;
   int min = (int) (control.getMinimum() * factor);
   int max = (int) (control.getMaximum() * factor);
   int value = (int) (control.getValue() * factor);
   setRangeProperties(value, 0, min, max, false);
 }
Exemplo n.º 2
0
  private void fade(FloatControl control, double to) {
    //noinspection SynchronizationOnLocalVariableOrMethodParameter
    synchronized (control) {
      int steps = FADE_DURATION / FADE_STEP_DURATION;

      to = (to <= 0.0) ? 0.0001 : ((to > 1.0) ? 1.0 : to);

      float currDB = control.getValue();
      float toDB = getDb(to);

      float diffStep = (toDB - currDB) / (float) steps;
      for (int i = 0; i < steps; i++) {
        currDB += diffStep;
        currDB = (Math.abs(currDB - toDB) < Math.abs(diffStep * 1.5)) ? toDB : currDB;
        control.setValue(currDB);
        try {
          Thread.sleep(FADE_STEP_DURATION);
        } catch (Exception ignored) {
          ignored.printStackTrace();
        }
      }
    }
  }
Exemplo n.º 3
0
 // Возвращает текущую громкость (число от 0 до 1)
 public float getVolume() {
   float v = volumeC.getValue();
   float min = volumeC.getMinimum();
   float max = volumeC.getMaximum();
   return (v - min) / (max - min);
 }
Exemplo n.º 4
0
 public int getValue() {
   return (int) (control.getValue() * getScaleFactor());
 }