Changeset 15842 in josm for trunk/src/org


Ignore:
Timestamp:
2020-02-11T20:31:02+01:00 (5 years ago)
Author:
simon04
Message:

fix #17109 - Autofilter: support 0.5 steps for level

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterRule.java

    r15839 r15842  
    22package org.openstreetmap.josm.gui.autofilter;
    33
     4import java.text.DecimalFormat;
    45import java.util.Arrays;
    56import java.util.Objects;
     
    122123                Matcher m = p.matcher(v);
    123124                if (m.matches()) {
    124                     int a = Integer.parseInt(m.group(1));
    125                     int b = Integer.parseInt(m.group(2));
     125                    int a = valueExtractor.applyAsInt(m.group(1));
     126                    int b = valueExtractor.applyAsInt(m.group(2));
    126127                    return IntStream.rangeClosed(Math.min(a, b), Math.max(a, b));
    127128                } else {
     
    144145    public static AutoFilterRule[] defaultRules() {
    145146        return new AutoFilterRule[]{
    146             new AutoFilterRule("level", 17),
     147            new AutoFilterRule("level", 17)
     148                // #17109, support values like 0.5 or 1.5 - level values are multiplied by 2 when parsing, values are divided by 2 for formatting
     149                .setValueExtractor(s -> (int) (Double.parseDouble(s) * 2.))
     150                .setValueFormatter(v -> DecimalFormat.getInstance().format(v / 2.)),
    147151            new AutoFilterRule("layer", 16)
    148152                    .setDefaultValueSupplier(AutoFilterRule::defaultLayer),
Note: See TracChangeset for help on using the changeset viewer.