code: public void setFactor(int factor) {
          this.factor = factor = Math.max(-127, Math.min(127, factor));
  
          if (factor > 1) {
              baseFilter.setInRed(new IntRange(factor, 255 - factor));
              baseFilter.setInGreen(new IntRange(factor, 255 - factor));
              baseFilter.setInBlue(new IntRange(factor, 255 - factor));
              baseFilter.setInGray(new IntRange(factor, 255 - factor));
  
              baseFilter.setOutRed(new IntRange(0, 255));
              baseFilter.setOutGreen(new IntRange(0, 255));
              baseFilter.setOutBlue(new IntRange(0, 255));
              baseFilter.setOutGray(new IntRange(0, 255));
          } else {
              baseFilter.setInRed(new IntRange(-factor, 255 + factor));
              baseFilter.setInGreen(new IntRange(-factor, 255 + factor));
              baseFilter.setInBlue(new IntRange(-factor, 255 + factor));
              baseFilter.setInGray(new IntRange(-factor, 255 + factor));
  
              baseFilter.setOutRed(new IntRange(0, 255));
              baseFilter.setOutGreen(new IntRange(0, 255));
              baseFilter.setOutBlue(new IntRange(0, 255));
              baseFilter.setOutGray(new IntRange(0, 255));
          }
      }
docs: Set Contrast adjusting factor, [-127, 127].
  
  @param factor Contrast factor.