Exemplo n.º 1
0
 /**
  * Set value of the threshold.
  *
  * @param thresholdName the threshold name which should be one of {@link Threshold}
  * @param value the value to set
  */
 public void setThresholdValue(Threshold thresholdName, double value) {
   switch (thresholdName) {
     case HIHI:
       hihi.value = value;
       break;
     case HI:
       hi.value = value;
       break;
     case LO:
       lo.value = value;
       break;
     case LOLO:
       lolo.value = value;
     default:
       break;
   }
   setDirty(true);
 }
Exemplo n.º 2
0
  /** update the the position for each threshold, and other parameters related to the positions. */
  private void updateThresholdPosition() {
    if (dirty) {
      // get normal value
      double lowLimit;
      double upLimit;
      if (lo.visible) lowLimit = lo.value;
      else if (lolo.visible) lowLimit = lolo.value;
      else lowLimit = scale.getRange().getLower();

      if (hi.visible) upLimit = hi.value;
      else if (hihi.visible) upLimit = hihi.value;
      else upLimit = scale.getRange().getUpper();

      // update normal
      normal.value = (lowLimit + upLimit) / 2;
      normal.absolutePosition = (int) scale.getCoercedValuePosition(normal.value, false);
      normal.relativePosition = (int) scale.getCoercedValuePosition(normal.value, true);
      normal.rightPoint =
          new PolarPoint(
                  bounds.width / 2, (normal.absolutePosition - OVERLAP_DEGREE) * Math.PI / 180)
              .toAbsolutePoint(bounds);
      normal.leftPoint =
          new PolarPoint(
                  bounds.width / 2, (normal.absolutePosition + OVERLAP_DEGREE) * Math.PI / 180)
              .toAbsolutePoint(bounds);

      // update min, max
      if (scale.getRange().isMinBigger()) {
        min.value = scale.getRange().getUpper();
        max.value = scale.getRange().getLower();
      } else {
        min.value = scale.getRange().getLower();
        max.value = scale.getRange().getUpper();
      }
      min.absolutePosition = (int) scale.getCoercedValuePosition(min.value, false);
      min.relativePosition = (int) scale.getCoercedValuePosition(min.value, true);
      max.absolutePosition = (int) scale.getCoercedValuePosition(max.value, false);
      max.relativePosition = (int) scale.getCoercedValuePosition(max.value, true);

      // update lolo, lo, hi, hihi
      if (lolo.visible) {
        lolo.absolutePosition = (int) scale.getCoercedValuePosition(lolo.value, false);
        lolo.relativePosition = (int) scale.getCoercedValuePosition(lolo.value, true);
        lolo.rightPoint =
            new PolarPoint(
                    bounds.width / 2, (lolo.absolutePosition - OVERLAP_DEGREE) * Math.PI / 180)
                .toAbsolutePoint(bounds);
        lolo.leftPoint =
            new PolarPoint(
                    bounds.width / 2, (lolo.absolutePosition + OVERLAP_DEGREE) * Math.PI / 180)
                .toAbsolutePoint(bounds);
      }
      if (lo.visible) {
        lo.absolutePosition = (int) scale.getCoercedValuePosition(lo.value, false);
        lo.relativePosition = (int) scale.getCoercedValuePosition(lo.value, true);
        lo.rightPoint =
            new PolarPoint(bounds.width / 2, (lo.absolutePosition - OVERLAP_DEGREE) * Math.PI / 180)
                .toAbsolutePoint(bounds);
        lo.leftPoint =
            new PolarPoint(bounds.width / 2, (lo.absolutePosition + OVERLAP_DEGREE) * Math.PI / 180)
                .toAbsolutePoint(bounds);
      }
      if (hi.visible) {
        hi.absolutePosition = (int) scale.getCoercedValuePosition(hi.value, false);
        hi.relativePosition = (int) scale.getCoercedValuePosition(hi.value, true);
        hi.rightPoint =
            new PolarPoint(bounds.width / 2, (hi.absolutePosition - OVERLAP_DEGREE) * Math.PI / 180)
                .toAbsolutePoint(bounds);
        hi.leftPoint =
            new PolarPoint(bounds.width / 2, (hi.absolutePosition + OVERLAP_DEGREE) * Math.PI / 180)
                .toAbsolutePoint(bounds);
      }
      if (hihi.visible) {
        hihi.absolutePosition = (int) scale.getCoercedValuePosition(hihi.value, false);
        hihi.relativePosition = (int) scale.getCoercedValuePosition(hihi.value, true);
        hihi.rightPoint =
            new PolarPoint(
                    bounds.width / 2, (hihi.absolutePosition - OVERLAP_DEGREE) * Math.PI / 180)
                .toAbsolutePoint(bounds);
        hihi.leftPoint =
            new PolarPoint(
                    bounds.width / 2, (hihi.absolutePosition + OVERLAP_DEGREE) * Math.PI / 180)
                .toAbsolutePoint(bounds);
      }
      setDirty(false);
    }
  }