- Timestamp:
- 2016-04-16T23:59:37+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityAction.java
r10144 r10148 40 40 public final class LayerVisibilityAction extends AbstractAction implements IEnabledStateUpdating, LayerAction { 41 41 protected static final int SLIDER_STEPS = 100; 42 private static final double MAX_GAMMA_FACTOR = 2;43 42 private static final double MAX_SHARPNESS_FACTOR = 2; 44 43 private static final double MAX_COLORFUL_FACTOR = 2; … … 316 315 */ 317 316 GammaFilterSlider() { 318 super( 0, MAX_GAMMA_FACTOR, ImageryLayer.class);317 super(-1, 1, ImageryLayer.class); 319 318 setToolTipText(tr("Adjust gamma value of the layer.")); 320 319 } … … 323 322 protected void updateSliderWhileEnabled(Collection<? extends Layer> usedLayers, boolean allHidden) { 324 323 double gamma = ((ImageryLayer) usedLayers.iterator().next()).getGamma(); 325 setRealValue( gamma);324 setRealValue(mapGammaToInterval(gamma)); 326 325 } 327 326 328 327 @Override 329 328 protected void applyValueToLayer(ImageryLayer layer) { 330 layer.setGamma( getRealValue());329 layer.setGamma(mapIntervalToGamma(getRealValue())); 331 330 } 332 331 … … 339 338 public String getLabel() { 340 339 return tr("Gamma"); 340 } 341 342 /** 343 * Maps a number x from the range (-1,1) to a gamma value. 344 * Gamma value is in the range (0, infinity). 345 * Gamma values of 3 and 1/3 have opposite effects, so the mapping 346 * should be symmetric in that sense. 347 * @param x the slider value in the range (-1,1) 348 * @return the gamma value 349 */ 350 private double mapIntervalToGamma(double x) { 351 // properties of the mapping: 352 // g(-1) = 0 353 // g(0) = 1 354 // g(1) = infinity 355 // g(-x) = 1 / g(x) 356 return (1 + x) / (1 - x); 357 } 358 359 private double mapGammaToInterval(double gamma) { 360 return (gamma - 1) / (gamma + 1); 341 361 } 342 362 }
Note:
See TracChangeset
for help on using the changeset viewer.