|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.data.osm.FilterMatcher
public class FilterMatcher
Class that encapsulates the filter logic, i.e. applies a list of
filters to a primitive.
Uses SearchCompiler.Match#match
to see if the filter expression matches,
cares for "inverted-flag" of the filters and combines the results of all active
filters.
There are two major use cases:
(1) Hide features that you don't like to edit but get in the way, e.g.
landuse
or power lines. It is expected, that the inverted flag
if false for these kind of filters.
(2) Highlight certain features, that are currently interesting and hide everything
else. This can be thought of as an improved search (Ctrl-F), where you can
continue editing and don't loose the current selection. It is expected that
the inverted flag of the filter is true in this case.
In addition to the formal application of filter rules, some magic is applied
to (hopefully) match the expectations of the user:
(1) non-inverted: When hiding a way, all its untagged nodes are hidden as well.
This avoids a "cloud of nodes", that normally isn't useful without the
corresponding way.
(2) inverted: When displaying a way, we show all its nodes, although the
individual nodes do not match the filter expression. The reason is, that a
way without its nodes cannot be edited properly.
Multipolygons and (untagged) member ways are handled in a similar way.
Nested Class Summary | |
---|---|
private static class |
FilterMatcher.FilterInfo
|
static class |
FilterMatcher.FilterType
Describes quality of the filtering. |
Field Summary | |
---|---|
private java.util.List<FilterMatcher.FilterInfo> |
disabledFilters
|
private java.util.List<FilterMatcher.FilterInfo> |
hiddenFilters
|
Constructor Summary | |
---|---|
FilterMatcher()
|
Method Summary | |
---|---|
private boolean |
allParentMultipolygonsFiltered(OsmPrimitive primitive,
boolean hidden)
|
private boolean |
allParentWaysFiltered(OsmPrimitive primitive,
boolean hidden)
Check if all parent ways are filtered. |
FilterMatcher.FilterType |
isDisabled(OsmPrimitive primitive)
Check if primitive is disabled. |
private boolean |
isFiltered(OsmPrimitive primitive,
boolean hidden)
Check if primitive is filtered. |
private boolean |
isFilterExplicit(OsmPrimitive primitive,
boolean hidden)
Check if primitive is hidden explicitly. |
FilterMatcher.FilterType |
isHidden(OsmPrimitive primitive)
Check if primitive is hidden. |
private boolean |
oneParentMultipolygonNotFiltered(OsmPrimitive primitive,
boolean hidden)
|
private boolean |
oneParentWayNotFiltered(OsmPrimitive primitive,
boolean hidden)
|
private FilterMatcher.FilterType |
test(java.util.List<FilterMatcher.FilterInfo> filters,
OsmPrimitive primitive,
boolean hidden)
|
void |
update(java.util.Collection<Filter> filters)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final java.util.List<FilterMatcher.FilterInfo> hiddenFilters
private final java.util.List<FilterMatcher.FilterInfo> disabledFilters
Constructor Detail |
---|
public FilterMatcher()
Method Detail |
---|
public void update(java.util.Collection<Filter> filters) throws SearchCompiler.ParseError
SearchCompiler.ParseError
private boolean isFiltered(OsmPrimitive primitive, boolean hidden)
primitive
- the primitive to checkhidden
- the minimum level required for the primitive to count as filtered
private boolean isFilterExplicit(OsmPrimitive primitive, boolean hidden)
primitive
- the primitive to checkhidden
- the level where the check is performed
private boolean allParentWaysFiltered(OsmPrimitive primitive, boolean hidden)
primitive
- the primitive to checkhidden
- parameter that indicates the minimum level of filtering:
true when objects need to be hidden to count as filtered and
false when it suffices to be disabled to count as filtered
hidden
and
(c) at least one of the parent ways is explicitly filteredprivate boolean oneParentWayNotFiltered(OsmPrimitive primitive, boolean hidden)
private boolean allParentMultipolygonsFiltered(OsmPrimitive primitive, boolean hidden)
private boolean oneParentMultipolygonNotFiltered(OsmPrimitive primitive, boolean hidden)
private FilterMatcher.FilterType test(java.util.List<FilterMatcher.FilterInfo> filters, OsmPrimitive primitive, boolean hidden)
public FilterMatcher.FilterType isHidden(OsmPrimitive primitive)
primitive
- the primitive
public FilterMatcher.FilterType isDisabled(OsmPrimitive primitive)
primitive
- the primitive
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |