public void setScalingFactor(String scaleString) {
    if (scaleString.toLowerCase().startsWith("a"))
      scalingFactor = SCALE_AUTO;
    else if (scaleString.toLowerCase().startsWith("f"))
      scalingFactor = SCALE_FIXEDRATIO;
    else {
      scaleString = scaleString.replaceAll("[^\\d]", "");
      int sf = -1;
      try {
        sf = Integer.parseInt(scaleString);
      } catch(NumberFormatException e) {};
      if (sf >= 1 && sf <= 1000) {
        scalingFactor = sf;
      }
    }
  }