Changeset 3356 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-06-29T17:19:26+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
r3355 r3356 26 26 import org.openstreetmap.josm.actions.search.SearchAction; 27 27 import org.openstreetmap.josm.data.osm.Filter; 28 import org.openstreetmap.josm.data.osm.Filters;29 28 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 30 29 import org.openstreetmap.josm.data.osm.event.DataSetListener; … … 43 42 44 43 private JTable userTable; 45 private Filter s filters = new Filters();44 private FilterTableModel filterModel = new FilterTableModel(); 46 45 private SideButton addButton; 47 46 private SideButton editButton; … … 61 60 public void showNotify() { 62 61 DatasetEventManager.getInstance().addDatasetListener(listenerAdapter, FireMode.IN_EDT_CONSOLIDATED); 63 filter s.executeFilters();62 filterModel.executeFilters(); 64 63 } 65 64 … … 67 66 public void hideNotify() { 68 67 DatasetEventManager.getInstance().removeDatasetListener(listenerAdapter); 69 filter s.clearFilterFlags();68 filterModel.clearFilterFlags(); 70 69 Main.map.mapView.repaint(); 71 70 } … … 79 78 Filter filter = (Filter)SearchAction.showSearchDialog(new Filter()); 80 79 if(filter != null){ 81 filter s.addFilter(filter);80 filterModel.addFilter(filter); 82 81 } 83 82 } … … 90 89 int index = userTable.getSelectionModel().getMinSelectionIndex(); 91 90 if(index < 0) return; 92 Filter f = filter s.getFilter(index);91 Filter f = filterModel.getFilter(index); 93 92 Filter filter = (Filter)SearchAction.showSearchDialog(f); 94 93 if(filter != null){ 95 filter s.setFilter(index, filter);94 filterModel.setFilter(index, filter); 96 95 } 97 96 } … … 104 103 int index = userTable.getSelectionModel().getMinSelectionIndex(); 105 104 if(index < 0) return; 106 filter s.removeFilter(index);105 filterModel.removeFilter(index); 107 106 } 108 107 }); … … 114 113 int index = userTable.getSelectionModel().getMinSelectionIndex(); 115 114 if(index < 0) return; 116 filter s.moveUpFilter(index);115 filterModel.moveUpFilter(index); 117 116 userTable.getSelectionModel().setSelectionInterval(index-1, index-1); 118 117 } … … 125 124 int index = userTable.getSelectionModel().getMinSelectionIndex(); 126 125 if(index < 0) return; 127 filter s.moveDownFilter(index);126 filterModel.moveDownFilter(index); 128 127 userTable.getSelectionModel().setSelectionInterval(index+1, index+1); 129 128 } … … 144 143 JPanel pnl = new JPanel(); 145 144 pnl.setLayout(new BorderLayout()); 146 userTable = new JTable(filter s){145 userTable = new JTable(filterModel){ 147 146 @Override 148 147 protected JTableHeader createDefaultTableHeader() { … … 183 182 184 183 public void processDatasetEvent(AbstractDatasetChangedEvent event) { 185 filter s.executeFilters();184 filterModel.executeFilters(); 186 185 } 187 186 … … 189 188 @Override 190 189 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 191 Filter s model = (Filters)table.getModel();190 FilterTableModel model = (FilterTableModel)table.getModel(); 192 191 Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 193 192 cell.setEnabled(model.isCellEnabled(row, column)); … … 198 197 static class BooleanRenderer extends JCheckBox implements TableCellRenderer { 199 198 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 200 Filter s model = (Filters)table.getModel();199 FilterTableModel model = (FilterTableModel)table.getModel(); 201 200 setSelected((Boolean)value); 202 201 setEnabled(model.isCellEnabled(row, column)); … … 209 208 SwingUtilities.invokeLater(new Runnable() { 210 209 public void run() { 211 setTitle(tr("Filter Hidden:{0} Disabled:{1}", filter s.disabledAndHiddenCount, filters.disabledCount));210 setTitle(tr("Filter Hidden:{0} Disabled:{1}", filterModel.disabledAndHiddenCount, filterModel.disabledCount)); 212 211 } 213 212 }); … … 215 214 216 215 public void drawOSDText(Graphics2D g) { 217 filter s.drawOSDText(g);216 filterModel.drawOSDText(g); 218 217 } 219 218 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java
r3355 r3356 1 package org.openstreetmap.josm. data.osm;1 package org.openstreetmap.josm.gui.dialogs; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 21 21 import org.openstreetmap.josm.Main; 22 22 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 23 import org.openstreetmap.josm.data.osm.DataSet; 24 import org.openstreetmap.josm.data.osm.Filter; 25 import org.openstreetmap.josm.data.osm.FilterMatcher; 26 import org.openstreetmap.josm.data.osm.FilterWorker; 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 28 24 29 /** … … 26 31 * @author Petr_Dlouhý 27 32 */ 28 public class Filter sextends AbstractTableModel {33 public class FilterTableModel extends AbstractTableModel { 29 34 30 35 // number of primitives that are disabled but not hidden … … 33 38 public int disabledAndHiddenCount; 34 39 35 public Filter s() {40 public FilterTableModel() { 36 41 loadPrefs(); 37 42 } … … 54 59 55 60 56 /** 57 * Apply the filters to the primitives of the data set. 58 * 59 * There are certain rules to ensure that a way is not displayed "naked" 60 * without its nodes (1) and on the other hand to avoid hiding a way but 61 * leaving its nodes visible as a cloud of points (2). 62 * 63 * In normal (non-inverted) mode only problem (2) is relevant. 64 * Untagged child nodes of filtered ways that are not used by other 65 * unfiltered ways are filtered as well. 66 * 67 * If a filter applies explicitly to a node, (2) is ignored and it 68 * is filtered in any case. 69 * 70 * In inverted mode usually only problem (1) is relevant. 71 * If the inverted filter applies explicitly to a node, this no longer 72 * means it is filtered in any case: 73 * E.g. the filter [searchtext="highway=footway", inverted=true] displays 74 * the footways only. But that does not mean, the nodes of the footway 75 * (which do not have the highway tag) should be filtered as well. 76 * 77 * So first the Filter is applied for ways and relations. Then to nodes 78 * (but hides them only if they are not used by any unfiltered way). 79 */ 61 80 62 public void executeFilters() { 81 63 DataSet ds = Main.main.getCurrentDataSet(); … … 85 67 final Collection<OsmPrimitive> all = ds.allNonDeletedCompletePrimitives(); 86 68 87 for (OsmPrimitive primitive: all) { 88 if (filterMatcher.isHidden(primitive)) { 89 primitive.setDisabledState(true); 90 } else if (filterMatcher.isDisabled(primitive)) { 91 primitive.setDisabledState(false); 92 } else { 93 primitive.unsetDisabledState(); 94 } 95 } 96 97 for (OsmPrimitive primitive: all) { 98 if (primitive instanceof Way && primitive.isDisabled()) { 99 Way w = (Way)primitive; 100 for (Node n: w.getNodes()) { 101 102 if (n.isTagged()) { 103 continue; 104 } 105 106 boolean disabled = w.isDisabled(); 107 boolean hidden = w.isDisabledAndHidden(); 108 for (OsmPrimitive ref: n.getReferrers()) { 109 if (ref instanceof Way) { 110 disabled = disabled && ref.isDisabled(); 111 hidden = hidden && ref.isDisabledAndHidden(); 112 } 113 } 114 115 if (disabled) { 116 n.setDisabledState(hidden); 117 } 118 } 119 } 120 } 69 FilterWorker.executeFilters(all, filterMatcher); 121 70 122 71 disabledCount = 0; … … 147 96 DataSet ds = Main.main.getCurrentDataSet(); 148 97 if (ds != null) { 149 for (OsmPrimitive osm : ds.allPrimitives()) { 150 osm.unsetDisabledState(); 151 } 98 FilterWorker.clearFilterFlags(ds.allPrimitives()); 152 99 } 153 100 disabledCount = 0;
Note:
See TracChangeset
for help on using the changeset viewer.