public class FilterModel extends java.lang.Object implements SortableModel<Filter>
Modifier and Type | Field and Description |
---|---|
private boolean |
changed
true, if the filter state (normal / disabled / hidden) of any primitive has changed in the process
|
private int |
disabledAndHiddenCount
number of primitives that are disabled and hidden
|
private int |
disabledCount
number of primitives that are disabled but not hidden
|
private FilterMatcher |
filterMatcher |
private java.util.List<Filter> |
filters |
Constructor and Description |
---|
FilterModel() |
Modifier and Type | Method and Description |
---|---|
boolean |
addFilter(Filter filter)
Adds a new filter to the filter list.
|
void |
clearFilterFlags()
Clears all filtered flags from all primitives in the dataset
|
void |
clearFilters()
Removes all filters from this model.
|
void |
drawOSDText(java.awt.Graphics2D g,
OSDLabel lblOSD,
java.lang.String header,
java.lang.String footer)
Draws a text on the map display that indicates that filters are active.
|
void |
executeFilters()
Runs the filters on the current edit data set.
|
void |
executeFilters(java.util.Collection<? extends OsmPrimitive> primitives)
Runs the filter on a list of primitives that are part of the edit data set.
|
static java.util.Collection<OsmPrimitive> |
getAffectedPrimitives(java.util.Collection<? extends OsmPrimitive> primitives)
Returns the list of primitives whose filtering can be affected by change in primitive
|
int |
getDisabledAndHiddenCount()
Returns the number of primitives that are disabled and hidden.
|
int |
getDisabledCount()
Returns the number of primitives that are disabled but not hidden.
|
Filter |
getFilter(int rowIndex)
Deprecated.
Use
getValue(int) |
java.util.List<Filter> |
getFilters()
Returns the list of filters.
|
int |
getFiltersCount()
Returns the number of filters.
|
Filter |
getValue(int rowIndex)
Get object value at given index.
|
boolean |
hasFilters()
Determines if at least one filter is enabled.
|
boolean |
isChanged()
Determines if the filter state (normal / disabled / hidden) of any primitive has changed in the process.
|
void |
loadPrefs(java.lang.String prefEntry)
Initializes the model from preferences.
|
boolean |
moveDownFilter(int rowIndex)
Moves down the filter in the given row.
|
boolean |
moveFilters(int delta,
int... rowIndexes)
Moves the filters in the given rows by a number of positions.
|
boolean |
moveUpFilter(int rowIndex)
Moves up the filter in the given row
|
Filter |
removeFilter(int rowIndex)
Removes the filter that is displayed in the given row
|
void |
reverse()
Reverse the items order.
|
void |
savePrefs(java.lang.String prefEntry)
Saves the model to preferences.
|
Filter |
setFilter(int rowIndex,
Filter filter)
Deprecated.
|
Filter |
setValue(int rowIndex,
Filter filter)
Set object value at given index.
|
void |
sort()
Sort the items.
|
private void |
updateFilterMatcher() |
private static void |
updateMap() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canMove, canMoveDown, canMoveUp, doMove
private int disabledCount
private int disabledAndHiddenCount
private boolean changed
private final FilterMatcher filterMatcher
public FilterModel()
private void updateFilterMatcher()
public void loadPrefs(java.lang.String prefEntry)
prefEntry
- preference keypublic void savePrefs(java.lang.String prefEntry)
prefEntry
- preferences keypublic void executeFilters()
public void executeFilters(java.util.Collection<? extends OsmPrimitive> primitives)
primitives
- The primitivesprivate static void updateMap()
public void clearFilterFlags()
public void clearFilters()
public boolean addFilter(Filter filter)
filter
- The new filterCollection.add(E)
)public boolean moveFilters(int delta, int... rowIndexes)
delta
- negative or positive incrementrowIndexes
- The filter rowspublic boolean moveDownFilter(int rowIndex)
rowIndex
- The filter rowpublic boolean moveUpFilter(int rowIndex)
rowIndex
- The filter rowpublic Filter removeFilter(int rowIndex)
rowIndex
- The index of the filter to remove@Deprecated public Filter setFilter(int rowIndex, Filter filter)
setValue(int, org.openstreetmap.josm.data.osm.Filter)
rowIndex
- The row indexfilter
- The filter that should be placed in that rowpublic Filter setValue(int rowIndex, Filter filter)
ReorderableModel
setValue
in interface ReorderableModel<Filter>
rowIndex
- indexfilter
- new value@Deprecated public Filter getFilter(int rowIndex)
getValue(int)
rowIndex
- The row indexpublic Filter getValue(int rowIndex)
ReorderableModel
getValue
in interface ReorderableModel<Filter>
rowIndex
- indexpublic void drawOSDText(java.awt.Graphics2D g, OSDLabel lblOSD, java.lang.String header, java.lang.String footer)
g
- The graphics to draw that text on.lblOSD
- On Screen Display labelheader
- The title to display at the beginning of OSDfooter
- The message to display at the bottom of OSD. Must end by </html>
public java.util.List<Filter> getFilters()
public int getFiltersCount()
public int getDisabledCount()
public int getDisabledAndHiddenCount()
public boolean isChanged()
public boolean hasFilters()
true
if at least one filter is enabledpublic static java.util.Collection<OsmPrimitive> getAffectedPrimitives(java.util.Collection<? extends OsmPrimitive> primitives)
primitives
- list of primitives to checkpublic void sort()
SortableModel
sort
in interface SortableModel<Filter>
public void reverse()
SortableModel
reverse
in interface SortableModel<Filter>