Changeset 11055 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/layer
- Timestamp:
- 2016-09-27T00:28:57+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityAction.java
r10763 r11055 7 7 import java.awt.GridBagLayout; 8 8 import java.awt.event.ActionEvent; 9 import java.awt.event.MouseWheelEvent; 9 10 import java.util.ArrayList; 10 11 import java.util.Collection; … … 40 41 public final class LayerVisibilityAction extends AbstractAction implements IEnabledStateUpdating, LayerAction { 41 42 private static final int SLIDER_STEPS = 100; 43 /** 44 * Steps the value is changed by a mouse wheel change (one full click) 45 */ 46 private static final int SLIDER_WHEEL_INCREMENT = 5; 42 47 private static final double MAX_SHARPNESS_FACTOR = 2; 43 48 private static final double MAX_COLORFUL_FACTOR = 2; … … 172 177 173 178 addChangeListener(e -> onStateChanged()); 179 addMouseWheelListener(this::mouseWheelMoved); 174 180 } 175 181 … … 186 192 } 187 193 194 protected void mouseWheelMoved(MouseWheelEvent e) { 195 double rotation = e.getPreciseWheelRotation(); 196 double destinationValue = getValue() + rotation * SLIDER_WHEEL_INCREMENT; 197 if (rotation < 0) { 198 destinationValue = Math.floor(destinationValue); 199 } else { 200 destinationValue = Math.ceil(destinationValue); 201 } 202 setValue(Utils.clamp((int) destinationValue, getMinimum(), getMaximum())); 203 e.consume(); 204 } 205 188 206 protected void applyValueToLayer(T layer) { 189 207 } … … 204 222 protected int convertFromRealValue(double value) { 205 223 int i = (int) ((value - minValue) / (maxValue - minValue) * SLIDER_STEPS + .5); 206 if (i < getMinimum()) { 207 return getMinimum(); 208 } else if (i > getMaximum()) { 209 return getMaximum(); 210 } else { 211 return i; 212 } 224 return Utils.clamp(i, getMinimum(), getMaximum()); 213 225 } 214 226
Note:
See TracChangeset
for help on using the changeset viewer.