- Timestamp:
- 2026-07-23T18:04:58+02:00 (3 days ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
src/org/openstreetmap/josm/gui/MapView.java (modified) (1 diff)
-
src/org/openstreetmap/josm/gui/autofilter/AutoFilterButton.java (modified) (3 diffs)
-
src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java (modified) (20 diffs)
-
src/org/openstreetmap/josm/gui/autofilter/AutoFilterRule.java (modified) (11 diffs)
-
src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java (modified) (2 diffs)
-
src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java (modified) (4 diffs)
-
test/unit/org/openstreetmap/josm/gui/autofilter/AutoFilterRuleTest.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapView.java
r19403 r19592 621 621 622 622 MapFrame map = MainApplication.getMap(); 623 if (AutoFilterManager.getInstance().getCurrent AutoFilter() != null) {623 if (AutoFilterManager.getInstance().getCurrentCombinedFilter() != null) { 624 624 AutoFilterManager.getInstance().drawOSDText(tempG); 625 625 } else if (MainApplication.isDisplayingMapView() && map.filterDialog != null) { -
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterButton.java
r19519 r19592 15 15 import org.openstreetmap.josm.actions.PreferencesAction; 16 16 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 17 import org.openstreetmap.josm.gui.MainApplication;18 17 import org.openstreetmap.josm.gui.preferences.display.DrawingPreference; 19 18 … … 36 35 @Override 37 36 public synchronized void actionPerformed(ActionEvent e) { 37 38 38 AutoFilterManager afm = AutoFilterManager.getInstance(); 39 if (filter.equals(afm.getCurrentAutoFilter())) { 40 afm.setCurrentAutoFilter(null);41 MainApplication.getMap().filterDialog.getFilterModel().executeFilters(true);39 40 if (afm.getCurrentAutoFilters().isEmpty()) { 41 afm.setCurrentAutoFilter(filter); 42 42 } else { 43 afm.setCurrentAutoFilter(filter); 43 if ((e.getModifiers() & ActionEvent.CTRL_MASK) != 0 44 || (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0) { 45 if (afm.getCurrentAutoFilters().contains(filter)) { 46 afm.removeCurrentAutoFilter(filter); 47 } else { 48 afm.addCurrentAutoFilter(filter); 49 } 50 } else { 51 if (afm.getCurrentAutoFilters().size() == 1 && afm.getCurrentAutoFilters().contains(filter)) { 52 afm.setCurrentAutoFilter(null); 53 } else { 54 afm.setCurrentAutoFilter(filter); 55 } 56 } 44 57 } 58 45 59 } 46 60 }); … … 55 69 if (getModel().isPressed()) { 56 70 g.setColor(PROP_COLOR.get().darker().darker()); 57 } else if (getModel().isRollover() || AutoFilterManager.getInstance().getCurrentAutoFilter () == filter) {71 } else if (getModel().isRollover() || AutoFilterManager.getInstance().getCurrentAutoFilters().contains(filter)) { 58 72 g.setColor(PROP_COLOR.get().darker()); 59 73 } else { -
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java
r19519 r19592 9 9 import java.util.Collection; 10 10 import java.util.Collections; 11 import java.util.HashMap; 11 12 import java.util.List; 12 13 import java.util.Map; 13 14 import java.util.NavigableSet; 14 15 import java.util.Objects; 15 import java.util. TreeMap;16 import java.util.OptionalInt; 16 17 import java.util.TreeSet; 17 import java.util.function.Consumer; 18 import java.util.stream.Collectors; 19 import java.util.stream.IntStream; 18 20 19 21 import org.openstreetmap.josm.actions.mapmode.MapMode; … … 64 66 65 67 /** 66 * Property to determine sif the auto filter feature is enabled.68 * Property to determine if the auto filter feature is enabled. 67 69 */ 68 70 public static final BooleanProperty PROP_AUTO_FILTER_ENABLED = new BooleanProperty("auto.filter.enabled", true); 69 71 70 72 /** 73 * Property to determine if the auto filter feature completely hides elements instead of just disabling them. 74 * Equivalent to {@link Filter#hiding} 75 */ 76 public static final BooleanProperty PROP_AUTO_FILTER_HIDING = new BooleanProperty("auto.filter.hiding", false); 77 78 79 /** 71 80 * Property to determine the current auto filter rule. 72 81 */ … … 81 90 * The buttons currently displayed in map view. 82 91 */ 83 private final Map< Integer, AutoFilterButton> buttons = newTreeMap<>();92 private final Map<OptionalInt, AutoFilterButton> buttons = new HashMap<>(); 84 93 85 94 /** … … 104 113 105 114 /** 106 * The currently selected auto filter, if any. 107 */ 108 private AutoFilter currentAutoFilter; 115 * The currently selected auto filters, if any. 116 * If more than one auto filter is active, elements will match if they match at least one of them. 117 */ 118 private final List<AutoFilter> currentAutoFilters = new ArrayList<>(); 109 119 110 120 /** … … 134 144 // Retrieve the values from current rule visible on screen 135 145 NavigableSet<Integer> values = getNumericValues(); 136 // Make sure current auto filter button remains visible even if no data is found, to allow user to disable it 137 if (currentAutoFilter != null) { 138 values.add(currentAutoFilter.getFilter().value); 139 } 140 if (!values.equals(buttons.keySet())) { 146 // Make sure current auto filter buttons remain visible even if no data is found, to allow user to disable them 147 for (var currentAutoFilter : currentAutoFilters) { 148 if (currentAutoFilter.getFilter().value != null) { 149 values.add(currentAutoFilter.getFilter().value); 150 } 151 } 152 if (!values.equals(buttons.keySet().stream() 153 .filter(it -> it.isPresent() && it.getAsInt() != Integer.MIN_VALUE) 154 .map(OptionalInt::getAsInt).collect(Collectors.toSet()))) { 141 155 removeAllButtons(); 142 156 addNewButtons(values); … … 147 161 static class CompiledFilter extends Filter implements MatchSupplier { 148 162 final AutoFilterRule rule; 149 final intvalue;150 151 CompiledFilter(AutoFilterRule rule, int value) {163 final Integer value; 164 165 CompiledFilter(AutoFilterRule rule, Integer value, boolean hiding) { 152 166 this.rule = rule; 153 167 this.value = value; 168 this.hiding = hiding; 154 169 this.enable = true; 155 170 this.inverted = true; … … 174 189 return false; 175 190 CompiledFilter other = (CompiledFilter) obj; 176 return Objects.equals(rule, other.rule) && value == other.value; 191 return Objects.equals(rule, other.rule) && Objects.equals(value, other.value); 192 } 193 } 194 195 /** The combination of multiple {@link CompiledFilter}s */ 196 static class CombinedFilter extends Filter implements MatchSupplier { 197 198 private final List<CompiledFilter> filters; 199 200 CombinedFilter(List<CompiledFilter> filters) { 201 202 if (filters == null || filters.isEmpty()) throw new IllegalArgumentException("no filters provided"); 203 204 this.filters = filters; 205 206 boolean hiding = filters.get(0).hiding; 207 String key = filters.get(0).rule.getKey(); 208 List<String> values = new ArrayList<>(); 209 210 for (CompiledFilter filter : filters) { 211 if (hiding != filter.hiding) throw new IllegalArgumentException("non-matching hiding properties"); 212 if (!Objects.equals(key, filter.rule.getKey())) throw new IllegalArgumentException("non-matching keys"); 213 values.add(filter.rule.formatValue(filter.value)); 214 } 215 216 this.hiding = hiding; 217 this.enable = true; 218 this.inverted = true; 219 this.text = key + "~" + String.join("|", values); 220 221 } 222 223 @Override 224 public SearchCompiler.Match get() { 225 return new SearchCompiler.Match() { 226 @Override 227 public boolean match(OsmPrimitive osm) { 228 return filters.stream().anyMatch(filter -> filter.get().match(osm)); 229 } 230 }; 231 } 232 233 @Override 234 public int hashCode() { 235 return 31 * super.hashCode() + Objects.hash(filters); 236 } 237 238 @Override 239 public boolean equals(Object obj) { 240 if (this == obj) 241 return true; 242 if (!super.equals(obj) || getClass() != obj.getClass()) 243 return false; 244 CombinedFilter other = (CombinedFilter) obj; 245 return Objects.equals(filters, other.filters); 177 246 } 178 247 } … … 180 249 static class Match extends SearchCompiler.Match { 181 250 final AutoFilterRule rule; 182 final intvalue;183 184 Match(AutoFilterRule rule, intvalue) {251 final Integer value; 252 253 Match(AutoFilterRule rule, Integer value) { 185 254 this.rule = rule; 186 255 this.value = value; … … 189 258 @Override 190 259 public boolean match(OsmPrimitive osm) { 191 return rule.getTagValuesForPrimitive(osm).anyMatch(v -> v == value); 260 IntStream values = rule.getTagValuesForPrimitive(osm, false); 261 if (value != null) { 262 return values.anyMatch(v -> v == value); 263 } else { 264 return values.findAny().isEmpty(); 265 } 192 266 } 193 267 … … 197 271 if (o == null || getClass() != o.getClass()) return false; 198 272 Match match = (Match) o; 199 return value ==match.value &&273 return Objects.equals(value, match.value) && 200 274 Objects.equals(rule, match.rule); 201 275 } … … 215 289 final AutoFilterButton keyButton = AutoFilterButton.forOsmKey(enabledRule.getKey()); 216 290 addButton(keyButton, Integer.MIN_VALUE, i++); 217 for (final Integer value : values.descendingSet()) { 218 CompiledFilter filter = new CompiledFilter(enabledRule, value); 291 var valueList = new ArrayList<>(values.descendingSet()); 292 if (enabledRule.getNoValueFilter()) { 293 valueList.add(null); 294 } 295 for (final Integer value : valueList) { 296 CompiledFilter filter = new CompiledFilter(enabledRule, value, PROP_AUTO_FILTER_HIDING.get()); 219 297 String label = enabledRule.formatValue(value); 220 298 AutoFilter autoFilter = new AutoFilter(label, filter.text, filter); 221 299 AutoFilterButton button = new AutoFilterButton(autoFilter); 222 if ( autoFilter.equals(currentAutoFilter)) {300 if (currentAutoFilters.contains(autoFilter)) { 223 301 button.getModel().setPressed(true); 224 302 } 303 addButton(button, value, i++); 225 304 maxWidth = Math.max(maxWidth, button.getPreferredSize().width); 226 addButton(button, value, i++);227 305 } 228 306 for (AutoFilterButton b : buttons.values()) { … … 232 310 } 233 311 234 private void addButton(AutoFilterButton button, intvalue, int i) {312 private void addButton(AutoFilterButton button, Integer value, int i) { 235 313 MapView mapView = MainApplication.getMap().mapView; 236 buttons.put(value, button); 314 buttons.put(value == null ? OptionalInt.empty() : OptionalInt.of(value), button); 237 315 mapView.add(button).setLocation(3, 60 + 22*i); 238 316 } … … 253 331 BBox bbox = MainApplication.getMap().mapView.getState().getViewArea().getLatLonBoundsBox().toBBox(); 254 332 NavigableSet<Integer> values = new TreeSet<>(); 255 Consumer<OsmPrimitive> consumer = o -> enabledRule.getTagValuesForPrimitive(o).forEach(values::add); 256 ds.searchNodes(bbox).forEach(consumer); 257 ds.searchWays(bbox).forEach(consumer); 258 ds.searchRelations(bbox).forEach(consumer); 333 for (var primitiveList : List.of(ds.searchNodes(bbox), ds.searchWays(bbox), ds.searchRelations(bbox))) { 334 // add all values that are directly mentioned 335 primitiveList.forEach(o -> enabledRule.getTagValuesForPrimitive(o, true).forEach(values::add)); 336 // only add integer values from value ranges, not fractional values 337 primitiveList.forEach(o -> enabledRule.getTagValuesForPrimitive(o, false) 338 .filter(v -> !enabledRule.formatValue(v).contains(".")) 339 .forEach(values::add)); 340 341 } 259 342 return values; 260 343 } … … 268 351 public void dataChanged(DataChangedEvent event) { 269 352 updateFiltersFull(); 353 updateButtons(); 270 354 } 271 355 … … 314 398 315 399 private synchronized void updateFiltersFull() { 316 if (currentAutoFilter != null) {400 if (!currentAutoFilters.isEmpty()) { 317 401 model.executeFilters(); 318 402 } … … 320 404 321 405 private synchronized void updateFiltersEvent(AbstractDatasetChangedEvent event, boolean affectedOnly) { 322 if (currentAutoFilter != null) {406 if (!currentAutoFilters.isEmpty()) { 323 407 Collection<? extends OsmPrimitive> prims = event.getPrimitives(); 324 408 model.executeFilters(affectedOnly ? FilterModel.getAffectedPrimitives(prims) : prims); … … 383 467 384 468 /** 385 * Returns the currently selected auto filter, if any. 386 * @return the currently selected auto filter, or null 387 */ 388 public synchronized AutoFilter getCurrentAutoFilter() { 389 return currentAutoFilter; 469 * Returns the currently selected auto filters, if any. 470 * @return the currently selected auto filters. Can be empty. 471 */ 472 public synchronized List<AutoFilter> getCurrentAutoFilters() { 473 return currentAutoFilters; 474 } 475 476 /** 477 * Returns a combination of all {@link #getCurrentAutoFilters()}, if any. 478 * @return a single combined filter, or null 479 */ 480 public Filter getCurrentCombinedFilter() { 481 if (currentAutoFilters.isEmpty()) { 482 return null; 483 } else if (currentAutoFilters.size() == 1) { 484 return currentAutoFilters.get(0).getFilter(); 485 } else { 486 return new CombinedFilter(currentAutoFilters.stream().map(AutoFilter::getFilter).collect(Collectors.toList())); 487 } 390 488 } 391 489 … … 395 493 */ 396 494 public synchronized void setCurrentAutoFilter(AutoFilter autoFilter) { 495 currentAutoFilters.clear(); 496 if (autoFilter != null) { 497 currentAutoFilters.add(autoFilter); 498 } 499 updateModelFilters(); 500 } 501 502 public synchronized void addCurrentAutoFilter(AutoFilter autoFilter) { 503 if (!currentAutoFilters.contains(autoFilter)) { 504 currentAutoFilters.add(autoFilter); 505 updateModelFilters(); 506 } 507 } 508 509 public synchronized void removeCurrentAutoFilter(AutoFilter autoFilter) { 510 if (currentAutoFilters.contains(autoFilter)) { 511 currentAutoFilters.removeIf(it -> Objects.equals(it, autoFilter)); 512 updateModelFilters(); 513 } 514 } 515 516 private synchronized void updateModelFilters() { 397 517 model.clearFilters(); 398 currentAutoFilter = autoFilter; 399 if (autoFilter != null) { 400 model.addFilter(autoFilter.getFilter()); 518 if (currentAutoFilters.isEmpty()) { 519 if (MainApplication.getMap() != null) { 520 MainApplication.getMap().filterDialog.getFilterModel().executeFilters(true); 521 } 522 } else { 523 model.addFilter(getCurrentCombinedFilter()); 401 524 model.executeFilters(); 402 if (model.isChanged()) { 403 OsmDataLayer dataLayer = MainApplication.getLayerManager().getActiveDataLayer(); 404 if (dataLayer != null) { 405 dataLayer.invalidate(); 406 } 525 // update the data layer (necessary even if model.isChanged() == false to update the OSDText) 526 OsmDataLayer dataLayer = MainApplication.getLayerManager().getActiveDataLayer(); 527 if (dataLayer != null) { 528 dataLayer.invalidate(); 407 529 } 408 530 } … … 414 536 */ 415 537 public synchronized void drawOSDText(Graphics2D g) { 538 String filterText = Objects.requireNonNull(getCurrentCombinedFilter()).text; 539 String lengthLimitedFilterText = filterText.length() > 18 ? filterText.substring(0, 18) + "…" : filterText; 416 540 model.drawOSDText(g, lblOSD, 417 tr("<h2>Filter active: {0}</h2>", currentAutoFilter.getFilter().text),541 tr("<h2>Filter active: {0}</h2>", lengthLimitedFilterText), 418 542 tr("</p><p>Click again on filter button to see all objects.</p></html>")); 419 543 } … … 438 562 resetCurrentAutoFilter(); 439 563 } 440 } else if (e.getKey().equals(PROP_AUTO_FILTER_RULE.getKey())) { 564 } else if (e.getKey().equals(PROP_AUTO_FILTER_RULE.getKey()) 565 || e.getKey().equals(PROP_AUTO_FILTER_HIDING.getKey())) { 441 566 enableAutoFilterRule(PROP_AUTO_FILTER_RULE.get()); 442 567 resetCurrentAutoFilter(); -
trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterRule.java
r19519 r19592 4 4 import java.text.DecimalFormat; 5 5 import java.util.Arrays; 6 import java.util.HashSet; 7 import java.util.List; 6 8 import java.util.Locale; 7 9 import java.util.Objects; 8 10 import java.util.Optional; 11 import java.util.Set; 9 12 import java.util.function.Function; 10 13 import java.util.function.IntFunction; … … 13 16 import java.util.regex.Pattern; 14 17 import java.util.stream.IntStream; 18 import java.util.stream.Stream; 15 19 16 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 18 22 import org.openstreetmap.josm.data.preferences.BooleanProperty; 19 23 import org.openstreetmap.josm.tools.Logging; 24 25 import static java.util.stream.Collectors.toList; 20 26 21 27 /** … … 43 49 private IntFunction<String> valueFormatter = Integer::toString; 44 50 51 private boolean noValueFilter = false; 52 53 /** The union of {@link #key} and the keys provided by {@link #setExtraKeys(List)}. */ 54 private List<String> allKeys; 55 45 56 /** 46 57 * Constructs a new {@code AutoFilterRule}. … … 51 62 this.key = key; 52 63 this.minZoomLevel = minZoomLevel; 64 this.allKeys = List.of(key); 53 65 } 54 66 … … 67 79 public int getMinZoomLevel() { 68 80 return minZoomLevel; 81 } 82 83 /** 84 * Returns true if there should be a filter button for OSM primitives which have no value for the key. 85 * @since xxx 86 */ 87 public boolean getNoValueFilter() { 88 return noValueFilter; 69 89 } 70 90 … … 73 93 * @param value the numeric value to format 74 94 * @return the formatted value 75 */ 76 public String formatValue(int value) { 77 return valueFormatter.apply(value); 95 * @since xxx 96 */ 97 public String formatValue(Integer value) { 98 return value == null ? "∅" : valueFormatter.apply(value); 78 99 } 79 100 … … 113 134 114 135 /** 136 * Adds a filter button for OSM primitives which have no value for the key. 137 */ 138 public AutoFilterRule enableNoValueFilter() { 139 this.noValueFilter = true; 140 return this; 141 } 142 143 /** 144 * Sets extra OSM keys on which the rule applies in addition to the primary key ({@link #getKey()}). 145 * This allows a filter to look at the values of more than one key at the same time. 146 * @param extraKeys the list of extra keys, may be empty 147 * @return {@code this} 148 * @throws NullPointerException if {@code extraKeys} is null 149 * @since xxx 150 */ 151 public AutoFilterRule setExtraKeys(List<String> extraKeys) { 152 Objects.requireNonNull(extraKeys); 153 this.allKeys = Stream.concat(Stream.of(key), extraKeys.stream()).collect(toList()); 154 return this; 155 } 156 157 /** 115 158 * Returns the numeric values for the given OSM primitive 116 * @param osm the primitive 159 * 160 * @param osm the primitive 161 * @param directValuesOnly whether "inner" values from ranges (such as 6 and 7 for 5-8) should be omitted 117 162 * @return a stream of numeric values 118 */ 119 public IntStream getTagValuesForPrimitive(OsmPrimitive osm) { 163 * @since xxx 164 */ 165 public IntStream getTagValuesForPrimitive(OsmPrimitive osm, boolean directValuesOnly) { 166 if (osm.isDeleted()) return IntStream.empty(); 167 if (allKeys.size() == 1) { 168 IntStream values = getTagValuesForPrimitive(osm, key, directValuesOnly); 169 if (values != null) return values; 170 } else { 171 Set<Integer> allValues = new HashSet<>(); 172 for (String k : allKeys) { 173 IntStream values = getTagValuesForPrimitive(osm, k, directValuesOnly); 174 if (values != null) { 175 values.forEach(allValues::add); 176 } 177 } 178 if (!allValues.isEmpty()) return allValues.stream().mapToInt(it -> it).sorted(); 179 } 180 return Boolean.TRUE.equals(PROP_AUTO_FILTER_DEFAULTS.get()) ? defaultValueSupplier.apply(osm) : IntStream.empty(); 181 } 182 183 private IntStream getTagValuesForPrimitive(OsmPrimitive osm, String key, boolean directValuesOnly) { 120 184 String value = osm.get(key); 121 185 if (value != null) { … … 126 190 int a = valueExtractor.applyAsInt(m.group(1)); 127 191 int b = valueExtractor.applyAsInt(m.group(2)); 128 return IntStream.rangeClosed(Math.min(a, b), Math.max(a, b)); 192 if (directValuesOnly && a != b) { 193 return IntStream.of(a, b).sorted(); 194 } else { 195 return IntStream.rangeClosed(Math.min(a, b), Math.max(a, b)); 196 } 129 197 } else { 130 198 try { … … 137 205 }); 138 206 } 139 return Boolean.TRUE.equals(PROP_AUTO_FILTER_DEFAULTS.get()) ? defaultValueSupplier.apply(osm) : IntStream.empty();207 return null; 140 208 } 141 209 … … 157 225 .setDefaultValueSupplier(AutoFilterRule::defaultLayer), 158 226 new AutoFilterRule("level", 17) 227 .setExtraKeys(List.of("repeat_on")) 228 .enableNoValueFilter() 159 229 // #17109, support values like 0.5 or 1.5 - level values are multiplied by 2 when parsing, values are divided by 2 for formatting 160 230 .setValueExtractor(s -> (int) (Double.parseDouble(s) * 2.)) -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java
r18556 r19592 99 99 */ 100 100 public void executeFilters(boolean force) { 101 if (AutoFilterManager.getInstance().getCurrent AutoFilter() == null && (force || model.hasFilters())) {101 if (AutoFilterManager.getInstance().getCurrentCombinedFilter() == null && (force || model.hasFilters())) { 102 102 model.executeFilters(); 103 103 updateMap(); … … 112 112 */ 113 113 public void executeFilters(Collection<? extends OsmPrimitive> primitives, boolean force) { 114 if (AutoFilterManager.getInstance().getCurrent AutoFilter() == null && (force || model.hasFilters())) {114 if (AutoFilterManager.getInstance().getCurrentCombinedFilter() == null && (force || model.hasFilters())) { 115 115 model.executeFilters(primitives); 116 116 updateMap(); -
trunk/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java
r18416 r19592 57 57 private final JCheckBox discardableKeys = new JCheckBox(tr("Display discardable keys")); 58 58 private final JCheckBox autoFilters = new JCheckBox(tr("Use auto filters")); 59 private final JCheckBox autoFiltersHiding = new JCheckBox(tr("Hide auto-filtered elements")); 60 59 61 private final JLabel lblRule = new JLabel(tr("Rule")); 60 62 private final JosmComboBox<AutoFilterRule> autoFilterRules = new JosmComboBox<>( … … 150 152 lblRule.setEnabled(autoFilters.isSelected()); 151 153 autoFilterRules.setEnabled(autoFilters.isSelected()); 154 autoFiltersHiding.setEnabled(autoFilters.isSelected()); 152 155 }); 153 156 autoFilterRules.setToolTipText("Rule defining which tag will provide automatic filters, below a certain zoom level"); 154 157 autoFilterRules.setSelectedItem(AutoFilterManager.getInstance().getAutoFilterRule(AutoFilterManager.PROP_AUTO_FILTER_RULE.get())); 158 autoFiltersHiding.setToolTipText( 159 tr("Completely hide elements which do not match the automatic filter instead of merely disabling them")); 160 autoFiltersHiding.setSelected(AutoFilterManager.PROP_AUTO_FILTER_HIDING.get()); 155 161 156 162 JLabel performanceLabel = new JLabel(tr("Options that affect drawing performance")); … … 184 190 panel.add(lblRule, GBC.std().insets(40, 0, 0, 0)); 185 191 panel.add(autoFilterRules, GBC.eop().fill(GBC.HORIZONTAL).insets(5, 0, 0, 0)); 192 panel.add(autoFiltersHiding, GBC.eop().insets(40, 0, 0, 0)); 186 193 187 194 ExpertToggleAction.addVisibilitySwitcher(performanceLabel); … … 214 221 Config.getPref().putBoolean("display.discardable-keys", discardableKeys.isSelected()); 215 222 AutoFilterManager.PROP_AUTO_FILTER_ENABLED.put(autoFilters.isSelected()); 223 AutoFilterManager.PROP_AUTO_FILTER_HIDING.put(autoFiltersHiding.isSelected()); 216 224 AutoFilterManager.PROP_AUTO_FILTER_RULE.put(((AutoFilterRule) autoFilterRules.getSelectedItem()).getKey()); 217 225 int vn = Config.getPref().getInt("mappaint.node.virtual-size", 8); -
trunk/test/unit/org/openstreetmap/josm/gui/autofilter/AutoFilterRuleTest.java
r19519 r19592 23 23 class AutoFilterRuleTest { 24 24 /** 25 * Unit test of {@link AutoFilterRule#getTagValuesForPrimitive}. 25 * Unit test of {@link AutoFilterRule#getTagValuesForPrimitive(OsmPrimitive, boolean)}. 26 26 */ 27 27 @Test … … 37 37 assertTagValuesForPrimitive(level, "way level=10;12-13", 20, 24, 25, 26); 38 38 assertTagValuesForPrimitive(level, "way level=0;0.5;1;1.5;2;2.5;3", 0, 1, 2, 3, 4, 5, 6); 39 assertTagValuesForPrimitive(level, "node level=0 repeat_on=1;2", 0, 2, 4); 40 assertTagValuesForPrimitive(level, "way level=4 repeat_on=4;5 layer=1", 8, 10); 39 41 assertEquals("0 0.5 1 1.5 2 2.5 3", 40 42 IntStream.of(0, 1, 2, 3, 4, 5, 6).mapToObj(level::formatValue).collect(Collectors.joining(" "))); … … 42 44 43 45 /** 44 * Unit test of {@link AutoFilterRule#getTagValuesForPrimitive} to deal with {@code %} of key {@code incline}. 46 * Unit test of {@link AutoFilterRule#getTagValuesForPrimitive(OsmPrimitive, boolean)} to deal with {@code %} of key {@code incline}. 45 47 */ 46 48 @Test … … 53 55 54 56 /** 55 * Unit test of {@link AutoFilterRule#getTagValuesForPrimitive} provides sensible defaults, see #17496. 57 * Unit test of {@link AutoFilterRule#getTagValuesForPrimitive(OsmPrimitive, boolean)} provides sensible defaults, see #17496. 56 58 */ 57 59 @Test … … 70 72 private void assertTagValuesForPrimitive(AutoFilterRule rule, String assertion, int... expected) { 71 73 final OsmPrimitive primitive = OsmUtils.createPrimitive(assertion); 72 final int[] actual = rule.getTagValuesForPrimitive(primitive).toArray(); 74 final int[] actual = rule.getTagValuesForPrimitive(primitive, false).toArray(); 73 75 assertArrayEquals(expected, actual); 74 76 }
Note:
See TracChangeset
for help on using the changeset viewer.
