Changeset 14387 in josm for trunk/src


Ignore:
Timestamp:
2018-10-30T22:51:22+01:00 (6 years ago)
Author:
simon04
Message:

fix #15832 - Add labels for background imagery sliders

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityAction.java

    r14248 r14387  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     5import static org.openstreetmap.josm.tools.I18n.trc;
    56
    67import java.awt.BorderLayout;
     
    1516import java.util.ArrayList;
    1617import java.util.Collection;
     18import java.util.Dictionary;
    1719import java.util.HashMap;
     20import java.util.Hashtable;
    1821import java.util.List;
    1922import java.util.function.Supplier;
     
    248251
    249252            slider.addChangeListener(e -> onStateChanged());
     253
     254            //final NumberFormat format = DecimalFormat.getInstance();
     255            //setLabels(format.format(minValue), format.format((minValue + maxValue) / 2), format.format(maxValue));
     256        }
     257
     258        protected void setLabels(String labelMinimum, String labelMiddle, String labelMaximum) {
     259            final Dictionary<Integer, JLabel> labels = new Hashtable<>();
     260            labels.put(slider.getMinimum(), new JLabel(labelMinimum));
     261            labels.put((slider.getMaximum() + slider.getMinimum()) / 2, new JLabel(labelMiddle));
     262            labels.put(slider.getMaximum(), new JLabel(labelMaximum));
     263            slider.setLabelTable(labels);
     264            slider.setPaintLabels(true);
    250265        }
    251266
     
    334349    class OpacitySlider extends AbstractFilterSlider<Layer> {
    335350        /**
    336          * Creaate a new {@link OpacitySlider}.
     351         * Create a new {@link OpacitySlider}.
    337352         */
    338353        OpacitySlider() {
    339354            super(0, 1, Layer.class);
     355            setLabels("0%", "50%", "100%");
    340356            slider.setToolTipText(tr("Adjust opacity of the layer."));
    341357        }
     
    410426        GammaFilterSlider() {
    411427            super(-1, 1, ImageryLayer.class);
     428            setLabels("0", "1", "∞");
    412429            slider.setToolTipText(tr("Adjust gamma value of the layer."));
    413430        }
     
    469486        SharpnessSlider() {
    470487            super(0, MAX_SHARPNESS_FACTOR, ImageryLayer.class);
     488            setLabels(trc("image sharpness", "blurred"), trc("image sharpness", "normal"), trc("image sharpness", "sharp"));
    471489            slider.setToolTipText(tr("Adjust sharpness/blur value of the layer."));
    472490        }
     
    506524        ColorfulnessSlider() {
    507525            super(0, MAX_COLORFUL_FACTOR, ImageryLayer.class);
     526            setLabels(trc("image colorfulness", "less"), trc("image colorfulness", "normal"), trc("image colorfulness", "more"));
    508527            slider.setToolTipText(tr("Adjust colorfulness of the layer."));
    509528        }
Note: See TracChangeset for help on using the changeset viewer.