Changeset 33887 in osm for applications/editors/josm/plugins/indoorhelper/src/model
- Timestamp:
- 2017-11-25T01:25:40+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/indoorhelper/src/model
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/src/model/IndoorHelperModel.java
r32637 r33887 29 29 import org.openstreetmap.josm.data.osm.Filter.FilterPreferenceEntry; 30 30 import org.openstreetmap.josm.data.osm.Tag; 31 import org.openstreetmap.josm.gui.MainApplication; 31 32 import org.openstreetmap.josm.gui.dialogs.FilterDialog; 32 33 import org.openstreetmap.josm.gui.dialogs.FilterTableModel; … … 78 79 79 80 // Get the filter dialog 80 FilterDialog filterDialog = Main .map.getToggleDialog(FilterDialog.class);81 FilterDialog filterDialog = MainApplication.getMap().getToggleDialog(FilterDialog.class); 81 82 82 83 if (filterDialog != null) { … … 123 124 124 125 // Get the filter dialog 125 FilterDialog filterDialog = Main .map.getToggleDialog(FilterDialog.class);126 FilterDialog filterDialog = MainApplication.getMap().getToggleDialog(FilterDialog.class); 126 127 127 128 if (filterDialog != null) { … … 182 183 this.workingLevel = this.getLevelNumberFromIndex(index); 183 184 184 FilterDialog filterDialog = Main .map.getToggleDialog(FilterDialog.class);185 FilterDialog filterDialog = MainApplication.getMap().getToggleDialog(FilterDialog.class); 185 186 FilterTableModel filterTableModel = filterDialog.getFilterModel(); 186 187 … … 258 259 */ 259 260 public void addTagsToOSM(IndoorObject object, List<Tag> userTags) { 260 if (!Main.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { 261 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { 261 262 262 263 List<Tag> tags = this.getObjectTags(object); … … 276 277 } 277 278 278 } else if (Main.getLayerManager().getEditDataSet().selectionEmpty()) { 279 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 279 280 280 281 JOptionPane.showMessageDialog(null, "No data selected.", "Error", JOptionPane.ERROR_MESSAGE); … … 290 291 public void addTagsToOSM(IndoorObject object) { 291 292 292 if (!Main.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { 293 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { 293 294 List<Tag> tags = this.getObjectTags(object); 294 295 tags.add(new Tag("indoor:level", Integer.toString(workingLevel))); … … 301 302 Main.main.undoRedo.add(new ChangePropertyCommand(Main.main.getInProgressSelection(), t.getKey(), t.getValue())); 302 303 } 303 } else if (Main.getLayerManager().getEditDataSet().selectionEmpty()) { 304 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 304 305 JOptionPane.showMessageDialog(null, "No data selected.", "Error", JOptionPane.ERROR_MESSAGE); 305 306 } -
applications/editors/josm/plugins/indoorhelper/src/model/PresetCounter.java
r32637 r33887 28 28 /** 29 29 * Counter for the calls of specific indoor objects, to track which items were used most frequently. 30 * 30 * 31 31 * @author egru 32 32 * 33 33 */ 34 34 public class PresetCounter { 35 35 36 36 private List<IndoorObject> rankingList; 37 37 private List<ObjectCounter> counterList; 38 38 39 39 /** 40 40 * Initiates the counterList with the available IndoorObjects. 41 41 */ 42 42 43 43 public PresetCounter() { 44 44 this.init(); 45 45 } 46 46 47 47 private void init() { 48 48 counterList = new ArrayList<>(); 49 49 50 50 counterList.add(new ObjectCounter(IndoorObject.CONCRETE_WALL, 0)); 51 51 counterList.add(new ObjectCounter(IndoorObject.DOOR, 0)); … … 60 60 counterList.add(new ObjectCounter(IndoorObject.TOILET_MALE, 0)); 61 61 } 62 62 63 63 /** 64 64 * Increments the counter of a specific IndoorObject in the list. … … 67 67 public void count(IndoorObject object) { 68 68 ListIterator<ObjectCounter> iterator = this.counterList.listIterator(); 69 69 70 70 // Go through the list and increment the corresponding objects counter value. 71 71 while (iterator.hasNext()) { 72 72 ObjectCounter counterTemp = iterator.next(); 73 73 if (counterTemp.getObject().equals(object)) { 74 counterList.get(iterator.nextIndex()-1).increment(); 74 counterList.get(iterator.nextIndex()-1).increment(); 75 75 } 76 76 } 77 77 78 78 //Sort the list. 79 79 this.sort(); 80 80 } 81 81 82 82 private void sort() { 83 83 Collections.sort(counterList); 84 84 Collections.reverse(counterList); 85 85 } 86 86 87 87 public List<IndoorObject> getRanking() { 88 rankingList = new ArrayList< IndoorObject>();89 88 rankingList = new ArrayList<>(); 89 90 90 rankingList.add(counterList.get(0).getObject()); 91 91 rankingList.add(counterList.get(1).getObject()); 92 92 rankingList.add(counterList.get(2).getObject()); 93 93 rankingList.add(counterList.get(3).getObject()); 94 94 95 95 return rankingList; 96 96 } 97 98 private class ObjectCounter implements Comparable<ObjectCounter> { 97 98 private static class ObjectCounter implements Comparable<ObjectCounter> { 99 99 private IndoorObject object; 100 100 private int count; 101 101 102 102 ObjectCounter(IndoorObject o, int c) { 103 103 this.object = o; 104 104 this.count = c; 105 105 } 106 106 107 107 public int getCount() { 108 108 return this.count; 109 109 } 110 110 111 111 public IndoorObject getObject() { 112 112 return this.object; 113 113 } 114 114 115 115 public void increment() { 116 116 this.count += 1; 117 117 } 118 118 119 119 @Override 120 120 public int compareTo(ObjectCounter o) { … … 128 128 return 1; 129 129 } 130 130 131 131 return 0; 132 132 } 133 133 134 134 } 135 135 136 136 }
Note:
See TracChangeset
for help on using the changeset viewer.