Changeset 33887 in osm
- Timestamp:
- 2017-11-25T01:25:40+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/indoorhelper
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/build.xml
r32680 r33887 5 5 <property name="commit.message" value="Inital commit"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="1 0580"/>7 <property name="plugin.main.version" value="12856"/> 8 8 9 9 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/indoorhelper/src/controller/IndoorHelperController.java
r33632 r33887 37 37 import org.openstreetmap.josm.data.validation.OsmValidator; 38 38 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 39 import org.openstreetmap.josm.gui.MainApplication; 39 40 import org.openstreetmap.josm.gui.dialogs.FilterDialog; 40 41 import org.openstreetmap.josm.gui.dialogs.FilterTableModel; … … 77 78 78 79 addToolboxListeners(); 79 Main .map.addToggleDialog(toolboxView);80 MainApplication.getMap().addToggleDialog(toolboxView); 80 81 } 81 82 … … 142 143 143 144 // Delete the indoor filters 144 FilterDialog filterDialog = Main .map.getToggleDialog(FilterDialog.class);145 FilterDialog filterDialog = MainApplication.getMap().getToggleDialog(FilterDialog.class); 145 146 146 147 if (filterDialog != null) { … … 394 395 */ 395 396 private void setPluginPreferences(boolean enabled) { 396 Collection<Map<String, String>> validatorMaps = 397 Main.pref.getListOf Structs("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries",397 Collection<Map<String, String>> validatorMaps = 398 Main.pref.getListOfMaps("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 398 399 new ArrayList<>()); 399 Collection<Map<String, String>> styleMaps = 400 Main.pref.getListOf Structs("mappaint.style.entries", new ArrayList<>());400 Collection<Map<String, String>> styleMaps = 401 Main.pref.getListOfMaps("mappaint.style.entries", new ArrayList<>()); 401 402 402 403 if (enabled) { … … 418 419 indoorValidator.put("title", "Indoor"); 419 420 indoorValidator.put("active", "true"); 420 indoorValidator.put("url", Main.pref.get UserDataDirectory()+ sep +"validator" +421 indoorValidator.put("url", Main.pref.getDirs().getUserDataDirectory(false)+ sep +"validator" + 421 422 sep + "indoorhelper.validator.mapcss"); 422 423 423 424 validatorMapsNew.add(indoorValidator); 424 Main.pref.putListOf Structs("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries",425 Main.pref.putListOfMaps("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 425 426 validatorMapsNew); 426 427 … … 441 442 indoorMapPaint.put("title", "Indoor"); 442 443 indoorMapPaint.put("active", "true"); 443 indoorMapPaint.put("url", Main.pref.get UserDataDirectory() + sep + "styles"444 indoorMapPaint.put("url", Main.pref.getDirs().getUserDataDirectory(false) + sep + "styles" 444 445 + sep + "indoor.mapcss"); 445 446 styleMapsNew.add(indoorMapPaint); 446 Main.pref.putListOf Structs("mappaint.style.entries", styleMapsNew);447 Main.pref.putListOfMaps("mappaint.style.entries", styleMapsNew); 447 448 448 449 updateSettings(); … … 465 466 indoorValidator.put("title", "Indoor"); 466 467 indoorValidator.put("active", "false"); 467 indoorValidator.put("url", Main.pref.get UserDataDirectory()+ sep +"validator" +468 indoorValidator.put("url", Main.pref.getDirs().getUserDataDirectory(false)+ sep +"validator" + 468 469 sep + "indoorhelper.validator.mapcss"); 469 470 470 471 validatorMapsNew.add(indoorValidator); 471 Main.pref.putListOf Structs("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries",472 Main.pref.putListOfMaps("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 472 473 validatorMapsNew); 473 474 … … 489 490 indoorMapPaint.put("title", "Indoor"); 490 491 indoorMapPaint.put("active", "false"); 491 indoorMapPaint.put("url", Main.pref.get UserDataDirectory() + sep + "styles"492 indoorMapPaint.put("url", Main.pref.getDirs().getUserDataDirectory(false) + sep + "styles" 492 493 + sep + "indoor.mapcss"); 493 494 styleMapsNew.add(indoorMapPaint); 494 Main.pref.putListOf Structs("mappaint.style.entries", styleMapsNew);495 Main.pref.putListOfMaps("mappaint.style.entries", styleMapsNew); 495 496 496 497 updateSettings(); -
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 } -
applications/editors/josm/plugins/indoorhelper/src/org/openstreetmap/josm/plugins/indoorhelper/IndoorHelperPlugin.java
r32637 r33887 23 23 import java.io.InputStream; 24 24 import java.io.OutputStream; 25 25 26 import org.openstreetmap.josm.Main; 26 27 import org.openstreetmap.josm.gui.MapFrame; … … 33 34 /** 34 35 * This is the main class for the indoorhelper plug-in. 35 * 36 * 36 37 * @author egru 37 * 38 * 38 39 */ 39 40 public class IndoorHelperPlugin extends Plugin { … … 46 47 /** 47 48 * Constructor for the plug-in. 48 * 49 * 49 50 * Exports the needed files and adds them to the settings. 50 * 51 * 51 52 * @param info general information about the plug-in 52 53 */ 53 54 public IndoorHelperPlugin(PluginInformation info) throws Exception { 54 super(info); 55 super(info); 55 56 56 57 this.exportValidator("/data/indoorhelper.validator.mapcss"); … … 72 73 } 73 74 } 74 75 75 76 /** 76 77 * Exports the mapcss validator file to the preferences directory. … … 92 93 byte[] buffer = new byte[4096]; 93 94 94 String valDirPath = Main.pref.get UserDataDirectory() + sep + "validator";95 String valDirPath = Main.pref.getDirs().getUserDataDirectory(false) + sep + "validator"; 95 96 File valDir = new File(valDirPath); 96 97 valDir.mkdirs(); … … 107 108 } finally { 108 109 stream.close(); 109 } 110 } 110 111 } 111 112 … … 128 129 byte[] buffer = new byte[4096]; 129 130 130 String valDirPath = Main.pref.get UserDataDirectory() + sep + "styles";131 String valDirPath = Main.pref.getDirs().getUserDataDirectory(false) + sep + "styles"; 131 132 File valDir = new File(valDirPath); 132 133 valDir.mkdirs(); … … 143 144 } finally { 144 145 stream.close(); 145 } 146 } 146 147 } 147 148 148 149 /** 149 150 * Writes the indoor validator file in the user preferences if it isn't there … … 179 180 // indoorValidator.put("title", "Indoor"); 180 181 // indoorValidator.put("active", "true"); 181 // indoorValidator.put("url", Main.pref.getUserDataDirectory()+ sep +"validator" + 182 // indoorValidator.put("url", Main.pref.getUserDataDirectory()+ sep +"validator" + 182 183 // sep + "indoorhelper.validator.mapcss"); 183 184 // 184 185 // validatorMapsNew.add(indoorValidator); 185 186 // Main.pref.putListOfStructs 186 // ("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 187 // ("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 187 188 // validatorMapsNew); 188 189 // }
Note:
See TracChangeset
for help on using the changeset viewer.