Example #1
0
  private String getVolumeCommand(PlexBindingConfig config, Command command) {
    int newVolume = 100;

    PlexSession session = getSessionByMachineId(config.getMachineIdentifier());
    if (session != null) {
      newVolume = session.getVolume();
    }

    if (command.getClass().equals(PercentType.class)) {
      PercentType percentType = (PercentType) command;
      newVolume = percentType.intValue();
    } else if (command.getClass().equals(IncreaseDecreaseType.class)) {
      if (command.equals(IncreaseDecreaseType.DECREASE)) {
        newVolume = Math.max(0, newVolume - VOLUME_STEP);
      } else {
        newVolume = Math.min(100, newVolume + VOLUME_STEP);
      }
    }

    if (session != null) {
      session.setVolume(newVolume);
      callback.updateReceived(session);
    }

    String url = String.format("playback/setParameters?volume=%d", newVolume);
    return url;
  }
Example #2
0
  private String getProgressCommand(PlexBindingConfig config, Command command) {
    PlexSession session = getSessionByMachineId(config.getMachineIdentifier());
    String url = null;

    if (session != null) {
      int offset = 0;

      if (command.getClass().equals(PercentType.class)) {
        PercentType percent = (PercentType) command;
        offset =
            new BigDecimal(session.getDuration())
                .multiply(
                    percent
                        .toBigDecimal()
                        .divide(new BigDecimal("100"), new MathContext(5, RoundingMode.HALF_UP)))
                .intValue();

        offset = Math.max(0, offset);
        offset = Math.min(session.getDuration(), offset);

        url = String.format("playback/seekTo?offset=%d", offset);
      } else if (command.getClass().equals(IncreaseDecreaseType.class)) {
        if (command.equals(IncreaseDecreaseType.DECREASE)) {
          url = PlexProperty.STEP_BACK.getName();
        } else {
          url = PlexProperty.STEP_FORWARD.getName();
        }
      }
    }

    return url;
  }
Example #3
0
    public NGDItem(
        long term1count,
        long term2count,
        String term1,
        String term2,
        List<String[]> term1Array,
        List<String[]> term2Array,
        long combocount,
        boolean useAlias,
        long totalDocCount) {
      this.term1count = term1count;
      this.term2count = term2count;
      this.term1 = term1;
      this.term2 = term2;
      this.combocount = combocount;
      this.term1Array = term1Array;
      this.term2Array = term2Array;
      this.useAlias = useAlias;
      this.totalDocCount = totalDocCount;

      if (this.combocount == 0) {
        this.ngd = -1;
      } else {
        double term1_log = Math.log10(this.term1count);
        double term2_log = Math.log10(this.term2count);
        double combo_log = Math.log10(this.combocount);

        this.ngd =
            (Math.max(term1_log, term2_log) - combo_log)
                / (Math.log10(this.totalDocCount) - Math.min(term1_log, term2_log));
      }
    }