Changeset 33974 in osm for applications/editors/josm/plugins/indoorhelper
- Timestamp:
- 2018-01-04T11:05:03+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/indoorhelper
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/.classpath
r32364 r33974 7 7 <classpathentry combineaccessrules="false" kind="src" path="/JOSM-piclayer"/> 8 8 <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> 9 <classpathentry kind="lib" path="/afs/tu-chemnitz.de/home/urz/r/rebsc/projects/josm/dist/PicLayer.jar"/> 10 <classpathentry kind="lib" path="/afs/tu-chemnitz.de/home/urz/r/rebsc/projects/josm/core/dist/josm-custom.jar" sourcepath="/JOSM/src"/> 9 11 <classpathentry kind="output" path="bin"/> 10 12 </classpath> -
applications/editors/josm/plugins/indoorhelper/README
r32122 r33974 23 23 24 24 Erik Gruschka 25 Rebecca Schmidt 25 26 26 27 -
applications/editors/josm/plugins/indoorhelper/build.xml
r33887 r33974 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 2856"/>7 <property name="plugin.main.version" value="13265"/> 8 8 9 9 <!-- Configure these properties (replace "..." accordingly). … … 11 11 --> 12 12 <property name="plugin.author" value="Erik Gruschka"/> 13 <property name="plugin.author" value="Rebecca Schmidt"/> 13 14 <property name="plugin.class" value="org.openstreetmap.josm.plugins.indoorhelper.IndoorHelperPlugin"/> 14 15 <property name="plugin.description" value="Gives assistance for the mapping process of indoor OSM building data. Includes a validator and a mappaint style for indoor-data."/> -
applications/editors/josm/plugins/indoorhelper/data/indoorhelper.validator.mapcss
r32122 r33974 2 2 3 3 /* rule which checks if every way and every POI has a level-tag */ 4 way[! indoor:level], node:unconnected[!indoor:level]{4 way[!level], node:unconnected[!level]{ 5 5 throwWarning: tr("This object has no level tag."); 6 fixAdd: "indoor:level=*";6 fixAdd: tr("level=*"); 7 7 suggestAlternative: "Delete the object or use the plug-in to add a POI tag!"; 8 8 } 9 9 10 10 /* rules for wrong assigned ways or nodes */ 11 node:unconnected[ indoor:area], node:unconnected[indoor:highway]{11 node:unconnected[area], node:unconnected[highway]{ 12 12 throwWarning: tr("You assigned properties to a node which should only be assigned to ways!"); 13 fixRemove: " indoor:area";14 fixRemove: " indoor:highway";13 fixRemove: "area"; 14 fixRemove: "highway"; 15 15 } 16 16 17 way[ indoor:door], way[indoor:entrance]{17 way[door], way[entrance]{ 18 18 throwWarning: tr("You assigned properties to a way which should only be assigned to nodes!"); 19 fixRemove: " indoor:door";20 fixRemove: " indoor:entrance";19 fixRemove: "door"; 20 fixRemove: "entrance"; 21 21 } 22 23 24 25 26 27 28 29 -
applications/editors/josm/plugins/indoorhelper/src/controller/IndoorHelperController.java
r33887 r33974 19 19 package controller; 20 20 21 import static org.openstreetmap.josm.tools.I18n.tr; 22 21 23 import java.awt.event.ActionEvent; 22 24 import java.awt.event.ActionListener; 23 25 import java.awt.event.ItemEvent; 24 26 import java.awt.event.ItemListener; 27 import java.awt.event.KeyEvent; 28 import java.awt.event.WindowEvent; 29 import java.awt.event.WindowListener; 25 30 import java.util.ArrayList; 26 31 import java.util.Collection; … … 29 34 import java.util.List; 30 35 import java.util.Map; 31 36 import java.util.Optional; 37 38 import javax.swing.AbstractAction; 32 39 import javax.swing.JOptionPane; 33 40 34 41 import org.openstreetmap.josm.Main; 35 42 import org.openstreetmap.josm.actions.ValidateAction; 43 import org.openstreetmap.josm.actions.mapmode.DrawAction; 44 import org.openstreetmap.josm.actions.mapmode.SelectAction; 45 import org.openstreetmap.josm.data.osm.OsmPrimitive; 36 46 import org.openstreetmap.josm.data.osm.Tag; 37 47 import org.openstreetmap.josm.data.validation.OsmValidator; 38 48 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 39 49 import org.openstreetmap.josm.gui.MainApplication; 40 import org.openstreetmap.josm.gui. dialogs.FilterDialog;41 import org.openstreetmap.josm.gui. dialogs.FilterTableModel;50 import org.openstreetmap.josm.gui.MapFrame; 51 import org.openstreetmap.josm.gui.help.HelpBrowser; 42 52 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 53 import org.openstreetmap.josm.spi.preferences.MapListSetting; 54 import org.openstreetmap.josm.spi.preferences.Setting; 55 import org.openstreetmap.josm.tools.Shortcut; 43 56 44 57 import model.IndoorHelperModel; 45 58 import model.TagCatalog.IndoorObject; 46 import views.FittingView;47 59 import views.LevelSelectorView; 48 60 import views.ToolBoxView; 49 61 50 62 /** 51 * 52 * Class for the Controller which provides the communication between 53 * the IndoorHelperModel and the different views. 54 * 55 * @author egru 56 * 57 */ 63 * 64 * Class for the Controller which provides the communication between 65 * the IndoorHelperModel and the different views. 66 * 67 * @author egru 68 * @author rebsc 69 * 70 */ 58 71 public class IndoorHelperController { 59 72 60 private IndoorHelperModel model; 61 private ToolBoxView toolboxView; 62 private FittingView fittingView; 63 private LevelSelectorView selectorView; 64 private String sep = System.getProperty("file.separator"); 65 66 67 private int lastLevelIndex; 68 69 /** 70 * Constructor for the {@link IndoorHelperController} which initiates model and views. 71 * 72 */ 73 public IndoorHelperController() { 74 this.model = new IndoorHelperModel(); 75 this.toolboxView = new ToolBoxView(); 76 77 this.lastLevelIndex = 0; 78 79 addToolboxListeners(); 80 MainApplication.getMap().addToggleDialog(toolboxView); 81 } 73 private IndoorHelperModel model; 74 private ToolBoxView toolboxView; 75 private String sep; 76 private String levelValue, levelNum; 77 private MapFrame map; 78 private DrawAction drawAction; 79 private SelectAction selectAction; 80 private SpaceAction SpaceAction; 81 private transient Shortcut SpaceShortcut; 82 private EnterAction EnterAction; 83 private transient Shortcut EnterShortcut; 84 private boolean OuterHelp,InnerHelp,LevelHelp; 85 private Collection<OsmPrimitive> innerRelation; 86 private LevelSelectorView selectorView; 87 88 /** 89 * Constructor for the {@link IndoorHelperController} which initiates model and views. 90 * 91 */ 92 public IndoorHelperController() { 93 94 this.model = new IndoorHelperModel(); 95 this.toolboxView = new ToolBoxView(); 96 97 this.sep = System.getProperty("file.separator"); 98 setPluginPreferences(true); 99 100 // Multipolygon actions 101 this.drawAction = new DrawAction(); 102 this.map = MainApplication.getMap(); 103 this.selectAction = new SelectAction(map); 104 105 // Ui elements 106 toolboxView.setAllUiElementsEnabled(true); 107 toolboxView.setROUiElementsEnabled(false); 108 109 addToolboxListeners(); 110 MainApplication.getMap().addToggleDialog(toolboxView); 111 112 // Shortcuts 113 SpaceShortcut = Shortcut.registerShortcut("mapmode:space", 114 tr(""), KeyEvent.VK_SPACE, Shortcut.DIRECT); 115 this.SpaceAction = new SpaceAction(); 116 MainApplication.registerActionShortcut(SpaceAction,SpaceShortcut); 117 118 EnterShortcut = Shortcut.registerShortcut("mapmode:ALT", 119 tr(""), KeyEvent.VK_ENTER, Shortcut.DIRECT); 120 this.EnterAction = new EnterAction(); 121 MainApplication.registerActionShortcut(EnterAction,EnterShortcut); 122 123 // Helper 124 OuterHelp = false; 125 InnerHelp = false; 126 LevelHelp = false; 127 innerRelation = null; 128 levelValue = new String(); 129 levelNum = new String(); 130 131 } 132 82 133 83 134 /** … … 87 138 88 139 if (this.toolboxView != null) { 89 this.toolboxView.setPowerButtonListener(new ToolPowerButtonListener());90 140 this.toolboxView.setApplyButtonListener(new ToolApplyButtonListener()); 91 this.toolboxView.setLevelItemListener(new ToolLevelItemListener()); 141 this.toolboxView.setLevelCheckBoxListener(new ToolLevelCheckBoxListener()); 142 this.toolboxView.setHelpButtonListener(new ToolHelpButtonListener()); 143 this.toolboxView.setAddLevelButtonListener(new ToolAddLevelButtonListener()); 92 144 this.toolboxView.setObjectItemListener(new ToolObjectItemListener()); 145 this.toolboxView.setOuterButtonListener(new ToolOuterButtonListener()); 146 this.toolboxView.setInnerButtonListener(new ToolInnerButtonListener()); 147 this.toolboxView.setMultiCheckBoxListener(new ToolMultiCheckBoxListener()); 93 148 this.toolboxView.setPreset1Listener(new Preset1Listener()); 94 149 this.toolboxView.setPreset2Listener(new Preset2Listener()); … … 103 158 private void addLevelSelectorListeners() { 104 159 if (this.selectorView != null) { 105 this.selectorView.setOkButtonListener(new LevelOkButtonListener()); 106 this.selectorView.setCancelButtonListener(new LevelCancelButtonListener()); 160 this.selectorView.setOkButtonListener(new ToolLevelOkButtonListener()); 161 this.selectorView.setCancelButtonListener(new ToolLevelCancelButtonListener()); 162 this.selectorView.setSelectorWindowListener(new ToolSelectorWindowSListener()); 107 163 } 164 108 165 } 109 166 110 /** 111 * Adds the button-listeners to the {@link FittingView}. 112 */ 113 private void addFittingListeners() { 114 if (this.fittingView != null) { 115 this.fittingView.setOkButtonListener(new FittingOkButtonListener()); 116 } 167 /************************************************* 168 * TOOLBOX LISTENER 169 * 170 */ 171 172 /** 173 * The listener which provides the handling of the apply button. 174 * Gets the texts which were written by the user and writes them to the OSM-data. 175 * After that it checks the tagged data with the built-in validator file. 176 * 177 * @author egru 178 * @author rebsc 179 */ 180 class ToolApplyButtonListener implements ActionListener { 181 182 @Override 183 public void actionPerformed(ActionEvent e) { 184 185 IndoorObject indoorObject = toolboxView.getSelectedObject(); 186 187 // collecting all tags 188 List<Tag> tags = new ArrayList<>(); 189 if (toolboxView.getLevelCheckBoxStatus() == false && !levelValue.equals("")) { 190 tags.add(new Tag(tr("level"),levelValue)); 191 } 192 if (!toolboxView.getLevelNameText().isEmpty() && !toolboxView.getLevelCheckBoxStatus()) { 193 tags.add(new Tag(tr("level_name"),toolboxView.getLevelNameText())); 194 } 195 if (!toolboxView.getNameText().isEmpty()) { 196 tags.add(new Tag(tr("name"), toolboxView.getNameText())); 197 } 198 if (!toolboxView.getRefText().isEmpty()) { 199 tags.add(new Tag(tr("ref"), toolboxView.getRefText())); 200 } 201 if (!toolboxView.getRepeatOnText().isEmpty()){ 202 tags.add(new Tag(tr("repeat_on"),toolboxView.getRepeatOnText())); 203 } 204 if (!toolboxView.getLevelNameText().isEmpty() && !toolboxView.getLevelCheckBoxStatus()) { 205 tags.add(new Tag(tr("level_name"),toolboxView.getLevelNameText())); 206 } 207 208 // Tagging to OSM Data 209 model.addTagsToOSM(indoorObject, tags); 210 211 // Reset ui elements 212 toolboxView.resetUiElements(); 213 214 //Do the validation process 215 ValidateAction validateAction = new ValidateAction(); 216 validateAction.doValidate(true); 217 218 refreshPresets(); 219 220 } 221 } 222 223 /** 224 * The listener which is called when a new item in the object list is selected. 225 * 226 * @author egru 227 * @author rebsc 228 * 229 */ 230 class ToolObjectItemListener implements ItemListener { 231 232 @Override 233 public void itemStateChanged(ItemEvent e) { 234 if (toolboxView.getSelectedObject().equals(IndoorObject.ROOM)) { 235 toolboxView.setNRUiElementsEnabled(true); 236 toolboxView.setROUiElementsEnabled(false); 237 } 238 else if (toolboxView.getSelectedObject().equals(IndoorObject.STEPS) || 239 toolboxView.getSelectedObject().equals(IndoorObject.ELEVATOR)) { 240 toolboxView.setROUiElementsEnabled(true); 241 toolboxView.setNRUiElementsEnabled(true); 242 } 243 else { 244 toolboxView.setROUiElementsEnabled(false); 245 } 246 } 247 } 248 249 /** 250 * The listener which is called when the LevelCheckBox is selected. 251 * 252 * @author rebsc 253 */ 254 class ToolLevelCheckBoxListener implements ItemListener{ 255 @Override 256 public void itemStateChanged(ItemEvent e) { 257 if(e.getStateChange() == ItemEvent.SELECTED) { 258 toolboxView.setLVLUiElementsEnabled(false); 259 } 260 else { 261 toolboxView.setLVLUiElementsEnabled(true); 262 } 263 } 264 } 265 266 /** 267 * The listener which is called when the helpbutton got pushed. 268 * 269 * @author rebsc 270 */ 271 static class ToolHelpButtonListener implements ActionListener{ 272 273 @Override 274 public void actionPerformed(ActionEvent e) { 275 String topic = tr("ToolB"); 276 HelpBrowser.setUrlForHelpTopic(Optional.ofNullable(topic).orElse(tr("/"))); 277 } 278 } 279 280 /** 281 * The listener which is called when the addlevelbutton got pushed. 282 * 283 * @author rebsc 284 */ 285 class ToolAddLevelButtonListener implements ActionListener{ 286 287 @Override 288 public void actionPerformed(ActionEvent e) { 289 290 if(selectorView == null) { 291 selectorView = new LevelSelectorView(); 292 addLevelSelectorListeners(); 293 294 //Show LevelSelectorView 295 selectorView.setVisible(true); 296 } else { 297 //Put focus back on LevelSelectorView 298 selectorView.toFront(); 299 } 300 301 } 302 } 303 304 /** 305 * The listener which is called when the MultiCheckBox is selected. 306 * 307 * @author rebsc 308 */ 309 class ToolMultiCheckBoxListener implements ItemListener{ 310 @Override 311 public void itemStateChanged(ItemEvent e) { 312 if(e.getStateChange() == ItemEvent.SELECTED) { 313 toolboxView.setMultiUiElementsEnabled(false); 314 } 315 else { 316 toolboxView.setMultiUiElementsEnabled(true); 317 } 318 } 319 } 320 321 /** 322 * The listener which is called when the OUTER Button got pushed. 323 * 324 * @author rebsc 325 */ 326 class ToolOuterButtonListener implements ActionListener{ 327 328 @Override 329 public void actionPerformed(ActionEvent e) { 330 // Select drawing action 331 map.selectMapMode(drawAction); 332 333 // For space shortcut to add the relation after spacebar got pushed {@link SpaceAction} 334 OuterHelp = true; 335 InnerHelp = false; 336 } 337 } 338 339 /** 340 * The listener which is called when the INNER Button got pushed. 341 * 342 * @author rebsc 343 */ 344 class ToolInnerButtonListener implements ActionListener { 345 @Override 346 public void actionPerformed(ActionEvent e) { 347 // Select drawing action 348 map.selectMapMode(drawAction); 349 350 // For space shortcut to edit the relation after enter got pushed {@link SpaceAction}{@link EnterAction} 351 InnerHelp = true; 352 OuterHelp = false; 353 354 } 355 } 356 357 /** 358 * Listener for preset button 1. 359 * @author egru 360 * 361 */ 362 class Preset1Listener implements ActionListener { 363 364 @Override 365 public void actionPerformed(ActionEvent e) { 366 model.addTagsToOSM(toolboxView.getPreset1()); 367 } 368 } 369 370 /** 371 * Listener for preset button 2. 372 * @author egru 373 * 374 */ 375 class Preset2Listener implements ActionListener { 376 377 @Override 378 public void actionPerformed(ActionEvent e) { 379 model.addTagsToOSM(toolboxView.getPreset2()); 380 } 381 } 382 383 /** 384 * Listener for preset button 3. 385 * @author egru 386 * 387 */ 388 class Preset3Listener implements ActionListener { 389 390 @Override 391 public void actionPerformed(ActionEvent e) { 392 model.addTagsToOSM(toolboxView.getPreset3()); 393 } 394 } 395 396 /** 397 * Listener for preset button 4. 398 * @author egru 399 * 400 */ 401 class Preset4Listener implements ActionListener { 402 403 @Override 404 public void actionPerformed(ActionEvent e) { 405 model.addTagsToOSM(toolboxView.getPreset4()); 406 } 407 } 408 409 /** 410 * Updates the preset button from the current ranking. 411 */ 412 private void refreshPresets() { 413 toolboxView.setPresetButtons(model.getPresetRanking()); 414 } 415 416 /************************************************* 417 * LEVEL SELCTOR VIEW LISTENER 418 * 419 */ 420 /** 421 * Specific listener for the applyButton 422 * @author rebsc 423 * 424 */ 425 class ToolLevelOkButtonListener implements ActionListener { 426 427 @Override 428 public void actionPerformed(ActionEvent e) { 429 LevelHelp = true; 430 431 //Get insert level number out of SelectorView 432 if(!selectorView.getLevelNumber().equals("")) { 433 levelNum = selectorView.getLevelNumber(); 434 435 //Unset visibility 436 selectorView.dispose(); 437 //Select draw-action 438 map.selectMapMode(drawAction); 439 440 }else { 441 JOptionPane.showMessageDialog(null, tr("Please insert a value."), tr("Error"), JOptionPane.ERROR_MESSAGE); 442 } 443 444 selectorView = null; 445 } 446 } 447 448 /** 449 * Specific listener for the cancelButton 450 * @author rebsc 451 * 452 */ 453 class ToolLevelCancelButtonListener implements ActionListener { 454 455 @Override 456 public void actionPerformed(ActionEvent e) { 457 selectorView.dispose(); 458 selectorView = null; 459 } 460 } 461 462 /** 463 * General listener for LevelSelectorView window 464 * @author rebsc 465 * 466 */ 467 class ToolSelectorWindowSListener implements WindowListener{ 468 469 @Override 470 public void windowClosed(WindowEvent e) { 471 selectorView = null; 472 } 473 474 @Override 475 public void windowClosing(WindowEvent e) { 476 selectorView = null; 477 } 478 479 @Override 480 public void windowActivated(WindowEvent arg0) { 481 // TODO Auto-generated method stub 482 483 } 484 485 @Override 486 public void windowDeactivated(WindowEvent arg0) { 487 // TODO Auto-generated method stub 488 489 } 490 491 @Override 492 public void windowDeiconified(WindowEvent arg0) { 493 // TODO Auto-generated method stub 494 495 } 496 497 @Override 498 public void windowIconified(WindowEvent arg0) { 499 // TODO Auto-generated method stub 500 501 } 502 503 @Override 504 public void windowOpened(WindowEvent arg0) { 505 // TODO Auto-generated method stub 506 507 } 508 } 509 510 511 /************************************************* 512 * SHORTCUT METHODS 513 * 514 */ 515 /** 516 * Shortcut for Spacebar 517 * @author rebsc 518 */ 519 private class SpaceAction extends AbstractAction { 520 521 private static final long serialVersionUID = 1L; 522 523 @Override 524 public void actionPerformed(ActionEvent e) { 525 if(OuterHelp) { 526 527 //Create new relation and add the currently drawn object to it 528 model.addRelation("outer"); 529 map.selectMapMode(selectAction); 530 OuterHelp = false; 531 532 //Clear currently selection 533 MainApplication.getLayerManager().getEditDataSet().clearSelection(); 534 } 535 else if(InnerHelp) { 536 537 //Save new drawn relation for adding 538 innerRelation = MainApplication.getLayerManager().getEditDataSet().getAllSelected(); 539 map.selectMapMode(selectAction); 540 541 //Clear currently selection 542 MainApplication.getLayerManager().getEditDataSet().clearSelection(); 543 } 544 else if(LevelHelp) { 545 546 List<Tag> tags = new ArrayList<>(); 547 tags.add(new Tag(tr("level"),levelNum)); 548 549 //Add level tag 550 model.addTagsToOSM(tags); 551 552 //Change action 553 map.selectMapMode(selectAction); 554 LevelHelp = false; 555 } 556 } 557 } 558 559 /** 560 * Shortcut for Enter 561 * @author rebsc 562 */ 563 private class EnterAction extends AbstractAction { 564 565 private static final long serialVersionUID = 1L; 566 567 @Override 568 public void actionPerformed(ActionEvent e) { 569 570 if(InnerHelp && !OuterHelp) { 571 572 // Edit the new drawn relation member to selected relation 573 model.editRelation("inner", innerRelation); 574 InnerHelp = false; 575 576 }else if((InnerHelp && OuterHelp) || (OuterHelp && !InnerHelp)){ 577 JOptionPane.showMessageDialog(null, tr("Please press spacebar first to add \"outer\" object to relation."), tr("Relation-Error"), JOptionPane.ERROR_MESSAGE); 578 resetHelper(); 579 } 580 } 581 } 582 583 /************************************************* 584 * FILTER METHODS 585 * 586 */ 587 /** 588 * Function which unset the disabled state of currently hidden and/or disabled objects which have a 589 * specific tag (key). Just unsets the disabled state if object has a tag-value which is part of the 590 * current working level. 591 * Specific example: key: repeat_on ; value: 1-4; 592 * If current selected workinglevel is "3" all objects with the leveltag "level=3" are hidden but the 593 * objects with the key "repeat_on" and the value which includes "3" or is (minValue+1) - maxValue (4-...), 594 * because repeat_on tag starts on the current workinglevel+1. 595 * @param key sepcific key to unset hidden objects which contains it 596 * @author rebsc 597 */ 598 public void unsetSpecificKeyFilter(String key) { 599 600 Collection<OsmPrimitive> p = Main.main.getEditDataSet().allPrimitives(); 601 Map<String, String> tags = new HashMap<>(); 602 Integer level = Integer.parseInt(levelValue); 603 Integer firstVal, secVal; 604 605 //Find all primitives with the specific tag and check if value is part of the current 606 //workinglevel. After that unset the disabled status. 607 for(OsmPrimitive osm: p) { 608 if((osm.isDisabledAndHidden() || osm.isDisabled()) && osm.hasKey(key)) { 609 610 tags = osm.getInterestingTags(); 611 612 for(Map.Entry<String, String> e: tags.entrySet()) { 613 if(e.getKey().equals(key)) { 614 String val = e.getValue(); 615 616 //Extract values 617 if(val.indexOf("-") == 0) { 618 firstVal = (Integer.parseInt(val.split("-",2)[1].split("-",2)[0]))*-1; 619 secVal = Integer.parseInt(val.split("-",2)[1].split("-",2)[1]); 620 }else { 621 firstVal = Integer.parseInt(val.split("-")[0]); 622 secVal = Integer.parseInt(val.split("-")[1]); 623 } 624 625 //Compare values to current working level 626 if(level >= ((firstVal)-1) && level <= secVal) { 627 osm.unsetDisabledState(); 628 }else { 629 osm.setDisabledState(true); 630 } 631 } 632 633 } 634 635 } 636 } 637 638 } 639 640 /** 641 * Function which updates the current working level tag 642 * 643 * @param indoorLevel: current working level 644 */ 645 public void setIndoorLevel(String indoorLevel) { 646 this.toolboxView.setLevelLabel(indoorLevel); 647 } 648 649 /** 650 * Function which gets the current working level tag 651 * 652 * @param indoorLevel: current working level 653 */ 654 public void getIndoorLevel(String indoorLevel) { 655 levelValue = indoorLevel; 656 117 657 } 118 658 119 //******************************************************************** 120 //********************* TOOLBOX LISTENERS ************************ 121 //******************************************************************** 122 123 /** 124 * The listener which handles the power button. 125 * 126 * @author egru 127 * 128 */ 129 class ToolPowerButtonListener implements ActionListener { 130 131 @Override 132 public void actionPerformed(ActionEvent e) { 133 if (toolboxView.getPowerButtonState()) { 134 selectorView = new LevelSelectorView(); 135 addLevelSelectorListeners(); 136 selectorView.setVisible(true); 137 setPluginPreferences(true); 138 } else if (!toolboxView.getPowerButtonState()) { 139 model = new IndoorHelperModel(); 140 selectorView.dispose(); 141 toolboxView.reset(); 142 setPluginPreferences(false); 143 144 // Delete the indoor filters 145 FilterDialog filterDialog = MainApplication.getMap().getToggleDialog(FilterDialog.class); 146 147 if (filterDialog != null) { 148 FilterTableModel filterTableModel = filterDialog.getFilterModel(); 149 150 for (int i = filterTableModel.getRowCount()-1; i > -1; i--) { 151 if (filterTableModel.getFilter(i).text.startsWith("\"indoor:level\"=\"")) { 152 filterTableModel.removeFilter(i); 153 } 154 } 155 } 156 } 157 } 158 } 159 160 /** 161 * The listener which provides the handling of the apply button. 162 * Gets the texts which were written by the user and writes them to the OSM-data. 163 * After that it checks the tagged data with the built-in validator file. 164 * 165 * @author egru 166 */ 167 class ToolApplyButtonListener implements ActionListener { 168 169 @Override 170 public void actionPerformed(ActionEvent e) { 171 IndoorObject indoorObject = toolboxView.getSelectedObject(); 172 if (toolboxView.getNameText().isEmpty() && toolboxView.getRefText().isEmpty() && toolboxView.getLevelName().isEmpty()) { 173 model.addTagsToOSM(indoorObject); 174 } else { 175 List<Tag> tags = new ArrayList<>(); 176 if (!toolboxView.getLevelName().isEmpty()) { 177 model.getLevelList().get(toolboxView.getSelectedLevelIndex()).setNameTag(toolboxView.getLevelName()); 178 } 179 if (!toolboxView.getNameText().isEmpty()) { 180 tags.add(new Tag("name", toolboxView.getNameText())); 181 } 182 if (!toolboxView.getRefText().isEmpty()) { 183 tags.add(new Tag("ref", toolboxView.getRefText())); 184 } 185 model.addTagsToOSM(indoorObject, tags); 186 } 187 //Do the validation process 188 ValidateAction validateAction = new ValidateAction(); 189 validateAction.doValidate(true); 190 191 refreshPresets(); 192 } 193 } 194 195 /** 196 * <pre>The listener which is called when a new item in the level list is selected. 197 *It also sets the name-tag for a level, if the user has done an input in the textbox. 198 * </pre> 199 * @author egru 200 * 201 */ 202 class ToolLevelItemListener implements ItemListener { 203 204 @Override 205 public void itemStateChanged(ItemEvent e) { 206 if (!toolboxView.levelListIsEmpty()) { 207 208 if (!toolboxView.getLevelName().isEmpty()) { 209 model.getLevelList().get(lastLevelIndex).setNameTag(toolboxView.getLevelName()); 210 } 211 212 if (!model.getLevelList().get(toolboxView.getSelectedLevelIndex()).hasEmptyName()) { 213 toolboxView.setLevelName(model.getLevelList().get(toolboxView.getSelectedLevelIndex()).getName()); 214 } else { 215 toolboxView.setLevelName(""); 216 } 217 model.setWorkingLevel(toolboxView.getSelectedLevelIndex()); 218 219 lastLevelIndex = toolboxView.getSelectedLevelIndex(); 220 } 221 } 222 } 223 224 225 226 /** 227 * The listener which is called when a new item in the object list is selected. 228 * 229 * @author egru 230 * 231 */ 232 class ToolObjectItemListener implements ItemListener { 233 234 @Override 235 public void itemStateChanged(ItemEvent e) { 236 if (toolboxView.getSelectedObject().equals(IndoorObject.ROOM)) { 237 toolboxView.setTagUiElementsEnabled(true); 238 } else { 239 toolboxView.setTagUiElementsEnabled(false); 240 } 241 } 242 } 243 244 /** 245 * Listener for preset button 1. 246 * @author egru 247 * 248 */ 249 class Preset1Listener implements ActionListener { 250 251 @Override 252 public void actionPerformed(ActionEvent e) { 253 model.addTagsToOSM(toolboxView.getPreset1()); 254 255 } 256 } 257 258 /** 259 * Listener for preset button 2. 260 * @author egru 261 * 262 */ 263 class Preset2Listener implements ActionListener { 264 265 @Override 266 public void actionPerformed(ActionEvent e) { 267 model.addTagsToOSM(toolboxView.getPreset2()); 268 269 } 270 271 } 272 273 /** 274 * Listener for preset button 3. 275 * @author egru 276 * 277 */ 278 class Preset3Listener implements ActionListener { 279 280 @Override 281 public void actionPerformed(ActionEvent e) { 282 model.addTagsToOSM(toolboxView.getPreset3()); 283 284 } 285 286 } 287 288 /** 289 * Listener for preset button 4. 290 * @author egru 291 * 292 */ 293 class Preset4Listener implements ActionListener { 294 295 @Override 296 public void actionPerformed(ActionEvent e) { 297 model.addTagsToOSM(toolboxView.getPreset4()); 298 299 } 300 301 } 302 303 /** 304 * Updates the preset button from the current ranking. 305 */ 306 private void refreshPresets() { 307 toolboxView.setPresetButtons(model.getPresetRanking()); 308 } 309 310 311 //******************* 312 // SELECTOR LISTENERS 313 //******************* 314 315 /** 316 * <pre> 317 * The listener which handles the click on the OK-button of the {@link LevelSelectorView}. 318 * It sends the data of the view to the model and displays an error message, 319 * if the level-list couldn't be created. 320 * </pre> 321 * @author egru 322 * 323 */ 324 class LevelOkButtonListener implements ActionListener { 325 326 @Override 327 public void actionPerformed(ActionEvent e) { 328 boolean levelSuccess = model.setBuildingLevels(selectorView.getMin(), selectorView.getMax()); 329 330 if (levelSuccess) { 331 toolboxView.setLevelList(model.getLevelList()); //set the levels to the ComboBox and 332 model.setWorkingLevel(toolboxView.getSelectedLevelIndex()); //sets the working level in the model 333 334 selectorView.dispose(); 335 336 fittingView = new FittingView(); 337 addFittingListeners(); 338 fittingView.setVisible(true); 339 } else { 340 341 JOptionPane.showMessageDialog(null, "Lowest Level has to be lower than the highest level", 342 "Error", JOptionPane.ERROR_MESSAGE); 343 } 344 } 345 } 346 347 /** 348 * Closes the level selection view if the user hits the cancel button. 349 * 350 * @author egru 351 * 352 */ 353 class LevelCancelButtonListener implements ActionListener { 354 355 @Override 356 public void actionPerformed(ActionEvent e) { 357 selectorView.dispose(); 358 toolboxView.setPowerButtonDisabled(); 359 setPluginPreferences(false); 360 } 361 362 } 363 364 365 366 //******************* 367 // FITTING LISTENERS 368 //******************* 369 /** 370 * Closes the {@link FittingView} if the OK-Button is clicked. 371 * Enables the UI elements of the toolbox 372 * 373 * @author egru 374 * 375 */ 376 class FittingOkButtonListener implements ActionListener { 377 378 @Override 379 public void actionPerformed(ActionEvent e) { 380 fittingView.dispose(); 381 toolboxView.setAllUiElementsEnabled(true); 382 toolboxView.setTagUiElementsEnabled(false); 383 } 384 385 } 386 387 /* 388 HELPER METHODS 389 */ 390 391 /** 392 * Enables or disables the preferences for the mapcss-style and the validator. 393 * 394 * @param enabled Activates or disables the settings. 395 */ 396 private void setPluginPreferences(boolean enabled) { 397 Collection<Map<String, String>> validatorMaps = 398 Main.pref.getListOfMaps("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 399 new ArrayList<>()); 400 Collection<Map<String, String>> styleMaps = 401 Main.pref.getListOfMaps("mappaint.style.entries", new ArrayList<>()); 402 403 if (enabled) { 404 //set the validator active 405 406 List<Map<String, String>> validatorMapsNew = new ArrayList<>(); 407 if (!validatorMaps.isEmpty()) { 408 validatorMapsNew.addAll(validatorMaps); 409 } 410 411 for (Map<String, String> map : validatorMapsNew) { 412 if (map.containsValue("Indoor")) { 413 validatorMapsNew.remove(map); 414 break; 415 } 416 } 417 418 Map<String, String> indoorValidator = new HashMap<>(); 419 indoorValidator.put("title", "Indoor"); 420 indoorValidator.put("active", "true"); 421 indoorValidator.put("url", Main.pref.getDirs().getUserDataDirectory(false)+ sep +"validator" + 422 sep + "indoorhelper.validator.mapcss"); 423 424 validatorMapsNew.add(indoorValidator); 425 Main.pref.putListOfMaps("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 426 validatorMapsNew); 427 428 //set mappaint active 429 430 List<Map<String, String>> styleMapsNew = new ArrayList<>(); 431 if (!styleMaps.isEmpty()) { 432 styleMapsNew.addAll(styleMaps); 433 } 434 435 for (Map<String, String> map : styleMapsNew) { 436 if (map.containsValue("Indoor")) { 437 styleMapsNew.remove(map); 438 break; 439 } 440 } 441 Map<String, String> indoorMapPaint = new HashMap<>(); 442 indoorMapPaint.put("title", "Indoor"); 443 indoorMapPaint.put("active", "true"); 444 indoorMapPaint.put("url", Main.pref.getDirs().getUserDataDirectory(false) + sep + "styles" 445 + sep + "indoor.mapcss"); 446 styleMapsNew.add(indoorMapPaint); 447 Main.pref.putListOfMaps("mappaint.style.entries", styleMapsNew); 448 449 updateSettings(); 450 } else { 451 //set the validator inactive 452 453 454 List<Map<String, String>> validatorMapsNew = new ArrayList<>(); 455 if (!validatorMaps.isEmpty()) { 456 validatorMapsNew.addAll(validatorMaps); 457 } 458 459 for (Map<String, String> map : validatorMapsNew) { 460 if (map.containsValue("Indoor")) { 461 validatorMapsNew.remove(map); 462 break; 463 } 464 } 465 Map<String, String> indoorValidator = new HashMap<>(); 466 indoorValidator.put("title", "Indoor"); 467 indoorValidator.put("active", "false"); 468 indoorValidator.put("url", Main.pref.getDirs().getUserDataDirectory(false)+ sep +"validator" + 469 sep + "indoorhelper.validator.mapcss"); 470 471 validatorMapsNew.add(indoorValidator); 472 Main.pref.putListOfMaps("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 473 validatorMapsNew); 474 475 476 //set mappaint inactive 477 478 479 List<Map<String, String>> styleMapsNew = new ArrayList<>(); 480 if (!styleMaps.isEmpty()) { 481 styleMapsNew.addAll(styleMaps); 482 } 483 for (Map<String, String> map : styleMapsNew) { 484 if (map.containsValue("Indoor")) { 485 styleMapsNew.remove(map); 486 break; 487 } 488 } 489 Map<String, String> indoorMapPaint = new HashMap<>(); 490 indoorMapPaint.put("title", "Indoor"); 491 indoorMapPaint.put("active", "false"); 492 indoorMapPaint.put("url", Main.pref.getDirs().getUserDataDirectory(false) + sep + "styles" 493 + sep + "indoor.mapcss"); 494 styleMapsNew.add(indoorMapPaint); 495 Main.pref.putListOfMaps("mappaint.style.entries", styleMapsNew); 496 497 updateSettings(); 498 } 499 } 659 660 /************************************************* 661 * HELPER METHODS 662 * 663 */ 664 665 /** 666 * Function which resets the helper for relation adding 667 */ 668 private void resetHelper() { 669 InnerHelp = false; 670 OuterHelp = false; 671 } 500 672 501 673 /** … … 511 683 MapPaintStyles.readFromPreferences(); 512 684 } 685 686 /** 687 * Enables or disables the preferences for the mapcss-style and the validator. 688 * 689 * @param enabled Activates or disables the settings. 690 */ 691 @SuppressWarnings("deprecation") 692 private void setPluginPreferences(boolean enabled) { 693 Map<String, Setting<?>> settings = Main.pref.getAllSettings(); 694 695 MapListSetting validatorMapListSetting = (MapListSetting) settings. 696 get("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries"); 697 List<Map<String, String>> validatorMaps = new ArrayList<>(); 698 if (validatorMapListSetting != null) { 699 validatorMaps = validatorMapListSetting.getValue(); 700 } 701 702 MapListSetting styleMapListSetting = (MapListSetting) settings. 703 get("mappaint.style.entries"); 704 List<Map<String, String>> styleMaps = new ArrayList<>(); 705 if (styleMapListSetting != null) { 706 styleMaps = styleMapListSetting.getValue(); 707 } 708 709 if (enabled) { 710 //set the validator active 711 712 List<Map<String, String>> validatorMapsNew = new ArrayList<>(); 713 if (!validatorMaps.isEmpty()) { 714 validatorMapsNew.addAll(validatorMaps); 715 } 716 717 for (Map<String, String> map : validatorMapsNew) { 718 if (map.containsValue(tr("Indoor"))) { 719 validatorMapsNew.remove(map); 720 break; 721 } 722 } 723 724 Map<String, String> indoorValidator = new HashMap<>(); 725 indoorValidator.put("title", "Indoor"); 726 indoorValidator.put("active", "true"); 727 indoorValidator.put("url", Main.pref.getUserDataDirectory()+ sep +"validator" + 728 sep + "indoorhelper.validator.mapcss"); 729 730 validatorMapsNew.add(indoorValidator); 731 Main.pref.putListOfMaps("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 732 validatorMapsNew); 733 734 //set mappaint active 735 736 List<Map<String, String>> styleMapsNew = new ArrayList<>(); 737 if (!styleMaps.isEmpty()) { 738 styleMapsNew.addAll(styleMaps); 739 } 740 741 for (Map<String, String> map : styleMapsNew) { 742 if (map.containsValue(tr("Indoor"))) { 743 styleMapsNew.remove(map); 744 break; 745 } 746 } 747 Map<String, String> indoorMapPaint = new HashMap<>(); 748 indoorMapPaint.put("title", tr("Indoor")); 749 indoorMapPaint.put("active", "true"); 750 indoorMapPaint.put("url", Main.pref.getUserDataDirectory() + sep + "styles" 751 + sep + "sit.mapcss"); 752 styleMapsNew.add(indoorMapPaint); 753 Main.pref.putListOfMaps("mappaint.style.entries", styleMapsNew); 754 755 updateSettings(); 756 } else { 757 //set the validator inactive 758 759 760 List<Map<String, String>> validatorMapsNew = new ArrayList<>(); 761 if (!validatorMaps.isEmpty()) { 762 validatorMapsNew.addAll(validatorMaps); 763 } 764 765 for (Map<String, String> map : validatorMapsNew) { 766 if (map.containsValue(tr("Indoor"))) { 767 validatorMapsNew.remove(map); 768 break; 769 } 770 } 771 Map<String, String> indoorValidator = new HashMap<>(); 772 indoorValidator.put("title", tr("Indoor")); 773 indoorValidator.put("active", "false"); 774 indoorValidator.put("url", Main.pref.getUserDataDirectory()+ sep +"validator" + 775 sep + "indoorhelper.validator.mapcss"); 776 777 validatorMapsNew.add(indoorValidator); 778 Main.pref.putListOfMaps("validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries", 779 validatorMapsNew); 780 781 782 //set mappaint inactive 783 784 785 List<Map<String, String>> styleMapsNew = new ArrayList<>(); 786 if (!styleMaps.isEmpty()) { 787 styleMapsNew.addAll(styleMaps); 788 } 789 for (Map<String, String> map : styleMapsNew) { 790 if (map.containsValue(tr("Indoor"))) { 791 styleMapsNew.remove(map); 792 break; 793 } 794 } 795 Map<String, String> indoorMapPaint = new HashMap<>(); 796 indoorMapPaint.put("title", tr("Indoor")); 797 indoorMapPaint.put("active", "false"); 798 indoorMapPaint.put("url", Main.pref.getUserDataDirectory() + sep + "styles" 799 + sep + "sit.mapcss"); 800 styleMapsNew.add(indoorMapPaint); 801 Main.pref.putListOfMaps("mappaint.style.entries", styleMapsNew); 802 803 updateSettings(); 804 } 805 } 806 807 808 809 810 811 /** 812 * 813 * 814 * 815 * 816 * 817 * 818 * 819 * 820 * 821 */ 513 822 } 514 515 -
applications/editors/josm/plugins/indoorhelper/src/model/IndoorHelperModel.java
r33887 r33974 19 19 package model; 20 20 21 import java.util.ArrayList; 21 import static org.openstreetmap.josm.tools.I18n.tr; 22 23 import java.util.Collection; 22 24 import java.util.List; 23 25 … … 25 27 26 28 import org.openstreetmap.josm.Main; 29 import org.openstreetmap.josm.command.AddCommand; 27 30 import org.openstreetmap.josm.command.ChangePropertyCommand; 28 import org.openstreetmap.josm.data.osm.Filter; 29 import org.openstreetmap.josm.data.osm.Filter.FilterPreferenceEntry; 31 import org.openstreetmap.josm.data.osm.DataSet; 32 import org.openstreetmap.josm.data.osm.OsmPrimitive; 33 import org.openstreetmap.josm.data.osm.Relation; 34 import org.openstreetmap.josm.data.osm.RelationMember; 30 35 import org.openstreetmap.josm.data.osm.Tag; 31 36 import org.openstreetmap.josm.gui.MainApplication; 32 import org.openstreetmap.josm.gui.dialogs.FilterDialog;33 import org.openstreetmap.josm.gui.dialogs.FilterTableModel;34 37 35 38 import model.TagCatalog.IndoorObject; … … 40 43 * 41 44 * @author egru 45 * @author rebsc 42 46 */ 43 public class IndoorHelperModel { 44 45 private java.util.List<IndoorLevel> levelList; 46 private int workingLevel; 47 private int workingIndex; 47 public class IndoorHelperModel{ 48 48 49 private TagCatalog tags; 49 50 private PresetCounter counter; 50 51 51 52 /** 52 * Constructor for the {@link IndoorHelperModel} which sets the current53 * workingLevel to 0 and creates the{@linkTagCatalog}.53 * Constructor for the {@link IndoorHelperModel} which creates the {@link TagCatalog} 54 * and {@link PresetCounter}. 54 55 */ 55 56 public IndoorHelperModel() { 56 this.workingLevel = 0;57 this.levelList = new ArrayList<>();58 57 this.tags = new TagCatalog(); 59 58 this.counter = new PresetCounter(); … … 61 60 62 61 /** 63 * Method to create a list of levels for the current building.64 * It also creates the filters which are needed to execute the indoor mapping.65 * minLevel should be lower than maxLevel or the same.66 *67 * @param minLevel the lowest level of the building68 * @param maxLevel the highest level of the building69 * @return boolean which indicates if the creation of the levelList was successful70 */71 public boolean setBuildingLevels(int minLevel, int maxLevel) {72 73 if (minLevel < maxLevel) {74 75 for (int i = minLevel; i <= maxLevel; i++) {76 77 IndoorLevel level = new IndoorLevel(i);78 levelList.add(level);79 80 // Get the filter dialog81 FilterDialog filterDialog = MainApplication.getMap().getToggleDialog(FilterDialog.class);82 83 if (filterDialog != null) {84 // Create a new filter85 //Filter filter = new Filter("\"indoor:level\"=\""+i+"\"", SearchMode.add, false, false, false);86 FilterPreferenceEntry entry = new FilterPreferenceEntry();87 entry.case_sensitive = false;88 entry.enable = false;89 entry.hiding = false;90 entry.inverted = false;91 entry.mapCSS_search = false;92 entry.mode = "add";93 entry.text = "\"indoor:level\"=\""+i+"\"";94 Filter filter = new Filter(entry);95 96 FilterTableModel filterTableModel = filterDialog.getFilterModel();97 98 boolean exists = false;99 100 // Search if the filter exists already.101 for (Filter listFilter : filterTableModel.getFilters()) {102 if (listFilter.equals(filter)) {103 exists = true;104 }105 }106 107 // Only add the filter if it is not already in the filter dialog.108 if (exists == false) {109 filterTableModel.addFilter(filter);110 }111 112 } else {113 //Show error message if filter dialog is null.114 JOptionPane.showMessageDialog(null, "Filter Dialog is null.", "Error", JOptionPane.ERROR_MESSAGE);115 }116 }117 118 return true;119 120 } else if (minLevel == maxLevel) {121 122 IndoorLevel level = new IndoorLevel(minLevel);123 levelList.add(level);124 125 // Get the filter dialog126 FilterDialog filterDialog = MainApplication.getMap().getToggleDialog(FilterDialog.class);127 128 if (filterDialog != null) {129 // Create a new filter130 //Filter filter = new Filter("\"indoor:level\"=\""+minLevel+"\"", SearchMode.add, false, false, false);131 132 FilterPreferenceEntry entry = new FilterPreferenceEntry();133 entry.case_sensitive = false;134 entry.enable = false;135 entry.hiding = false;136 entry.inverted = false;137 entry.mapCSS_search = false;138 entry.mode = "add";139 entry.text = "\"indoor:level\"=\""+minLevel+"\"";140 Filter filter = new Filter(entry);141 142 FilterTableModel filterTableModel = filterDialog.getFilterModel();143 144 boolean exists = false;145 146 // Search if the filter exists already.147 for (Filter listFilter : filterTableModel.getFilters()) {148 if (listFilter.equals(filter)) {149 exists = true;150 }151 }152 153 // Only add the filter if it is not already in the filter dialog.154 if (exists == false) {155 filterTableModel.addFilter(filter);156 }157 } else {158 JOptionPane.showMessageDialog(null, "Filter Dialog is null.", "Error", JOptionPane.ERROR_MESSAGE);159 }160 161 return true;162 }163 164 return false;165 }166 167 /**168 * Getter for the levelList of the model.169 *170 * @return the levelList, or null if no levelList was created yet171 */172 public java.util.List<IndoorLevel> getLevelList() {173 return this.levelList;174 }175 176 /**177 * Function to set the level the user wants to work on (with the level index) and activates the corresponding filter.178 *179 * @param index the index of the level the user wants to work on180 */181 public void setWorkingLevel(int index) {182 this.workingIndex = index;183 this.workingLevel = this.getLevelNumberFromIndex(index);184 185 FilterDialog filterDialog = MainApplication.getMap().getToggleDialog(FilterDialog.class);186 FilterTableModel filterTableModel = filterDialog.getFilterModel();187 188 189 for (Filter filter : filterTableModel.getFilters()) {190 // disable the filter for the current level191 if (filter.text.equals("\"indoor:level\"=\""+workingLevel+"\"")) {192 filterTableModel.setValueAt(false, filterTableModel.getFilters().indexOf(filter), FilterTableModel.COL_ENABLED);193 filterTableModel.setValueAt(false, filterTableModel.getFilters().indexOf(filter), FilterTableModel.COL_HIDING);194 } else if (filter.text.startsWith("\"indoor:level\"=\"")) {195 filterTableModel.setValueAt(true, filterTableModel.getFilters().indexOf(filter), FilterTableModel.COL_ENABLED);196 filterTableModel.setValueAt(true, filterTableModel.getFilters().indexOf(filter), FilterTableModel.COL_HIDING);197 }198 }199 }200 201 /**202 * Function to get the current working level of the plug-in203 *204 * @return {@link Integer} which represents the current working level205 */206 public int getWorkingLevel() {207 return this.workingLevel;208 }209 210 /**211 * Method to get the index of the current working level of the plug-in.212 *213 * @return {@link Integer} which represents the index214 */215 public int getWorkingIndex() {216 return this.workingIndex;217 }218 219 /**220 * Returns the level number which is corresponding to a specific index.221 *222 * @param index index of the level223 * @return a level number as an {@link Integer}224 */225 public int getLevelNumberFromIndex(int index) {226 return levelList.get(index).getLevelNumber();227 }228 229 /**230 * Function to set the nameTag of a specific level.231 *232 * @param levelNumber number of the level233 * @param levelName tag which the user wants to set234 * @return boolean which indicates if the level was found in the levelList235 */236 public void setLevelName(int levelIndex, String levelName) {237 if ((levelName.length() > 0) && (levelName != null)) {238 levelList.get(levelIndex).setNameTag(levelName);239 }240 }241 242 /**243 62 * Function to get a tag-set out of the {@link TagCatalog}. 244 * 63 * ClipboardUtils.copy(Main.getLayerManager().getEditDataSet(),Main.getLayerManager().getEditDataSet().getKey()); 245 64 * @param object the {@link IndoorObject} from which you want to get the tag-set 246 65 * @return a {@link List} of {@link Tag}s … … 250 69 } 251 70 252 253 /** 254 * Method which adds the selected tag-set to the currently selected OSM data. 255 * It also adds the level tag corresponding to the current working level. 71 /** 72 * Method which adds the selected tag-set to the currently selected OSM data. If OSM data is a relation add tag-set 73 * directly to the relation otherwise add it to nodes and/or ways. 256 74 * 257 75 * @param object the object which defines the tag-set you want to add 258 76 * @param userTags the tags which are given by the user input 259 */ 260 public void addTagsToOSM(IndoorObject object, List<Tag> userTags) { 77 * @author rebsc 78 */ 79 public void addTagsToOSM(IndoorObject object, List<Tag> userTags) { 261 80 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { 262 81 82 DataSet ds = Main.main.getEditDataSet(); 263 83 List<Tag> tags = this.getObjectTags(object); 84 Collection<Relation> relations = ds.getRelations(); 85 Relation relationToAdd = null; 86 264 87 tags.addAll(userTags); 265 tags.add(new Tag("indoor:level", Integer.toString(workingLevel))); 266 267 if (!this.getLevelList().get(workingIndex).hasEmptyName()) { 268 tags.add(this.getLevelList().get(workingIndex).getNameTag()); 88 89 // Increment the counter for the presets 90 this.counter.count(object); 91 92 // Put value on {@link relationToAdd} if selected object is a relation. 93 relationToAdd = getRelationFromDataSet(ds,relations); 94 95 if(relationToAdd != null) { 96 //Add tags to relation 97 for (Tag t : tags) { 98 Main.main.undoRedo.add(new ChangePropertyCommand(relationToAdd, t.getKey(), t.getValue())); 99 } 100 }else{ 101 //Add tags to ways or nodes 102 for (Tag t : tags) { 103 Main.main.undoRedo.add(new ChangePropertyCommand(Main.main.getInProgressSelection(), t.getKey(), t.getValue())); 104 } 269 105 } 270 271 // Increment the counter for the presets 106 //If the selected dataset is empty 107 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 108 109 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 110 } 111 } 112 113 /** 114 * Method which adds a object {@link IndoorObject} to the currently selected OSM data (to nodes and/or ways). 115 * 116 * @param object the object which defines the tag-set you want to add 117 */ 118 public void addTagsToOSM(IndoorObject object) { 119 120 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { 121 List<Tag> tags = this.getObjectTags(object); 122 123 //Increment the counter for the presets 272 124 this.counter.count(object); 273 125 … … 276 128 Main.main.undoRedo.add(new ChangePropertyCommand(Main.main.getInProgressSelection(), t.getKey(), t.getValue())); 277 129 } 278 130 //If the selected dataset ist empty 279 131 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 280 281 JOptionPane.showMessageDialog(null, "No data selected.", "Error", JOptionPane.ERROR_MESSAGE); 282 } 283 } 284 285 /** 286 * Method which adds the selected tag-set to the currently selected OSM data. 287 * It also adds the level tag corresponding to the current working level. 288 * 289 * @param object the object which defines the tag-set you want to add 290 */ 291 public void addTagsToOSM(IndoorObject object) { 132 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 133 } 134 } 135 136 /** 137 * Method which adds a list of tag-sets to the currently selected OSM data. Tags directly to ways and/or nodes. 138 * 139 * @param userTags the tags which are given by the user input 140 * @author rebsc 141 */ 142 public void addTagsToOSM(List<Tag> userTags) { 292 143 293 144 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { 294 List<Tag> tags = this.getObjectTags(object);295 tags.add(new Tag("indoor:level", Integer.toString(workingLevel)));296 297 // Increment the counter for the presets298 this.counter.count(object);299 145 300 146 //Add the tags to the current selection 301 for (Tag t : tags) {147 for (Tag t : userTags) { 302 148 Main.main.undoRedo.add(new ChangePropertyCommand(Main.main.getInProgressSelection(), t.getKey(), t.getValue())); 303 149 } 304 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 305 JOptionPane.showMessageDialog(null, "No data selected.", "Error", JOptionPane.ERROR_MESSAGE); 306 } 307 } 308 309 /** 150 } 151 else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 152 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 153 } 154 } 155 156 /** 157 * Method which adds the relation to OSM data. Also adds the selected tag-set to relation object. 158 * 159 * @param String the Multipolygon Role as String 160 * @author rebsc 161 */ 162 public void addRelation(String role){ 163 Relation newRelation = new Relation(); 164 RelationMember newMember; 165 DataSet ds = Main.main.getEditDataSet(); 166 167 // Create new relation and add a new member with specific role 168 if(!MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 169 for (OsmPrimitive osm : ds.getSelected()) { 170 newMember = new RelationMember(role == null ? "" : role, osm); 171 newRelation.addMember(newMember); 172 } 173 } 174 // Add relation to OSM data 175 MainApplication.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newRelation)); 176 } 177 178 /** 179 * Method which edits the selected object to the currently selected OSM data (relations). 180 * 181 * @param role The Multipolygon Role as String 182 * @param relation 183 * @author rebsc 184 */ 185 public void editRelation(String role, Collection<OsmPrimitive> innerRelation){ 186 187 RelationMember newMember; 188 DataSet ds = Main.main.getEditDataSet(); 189 Collection<Relation> relations = ds.getRelations(); 190 Relation relation = getRelationFromDataSet(ds,relations); 191 192 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty() && 193 !innerRelation.isEmpty() && getRole(ds,relations).equals("outer")) { 194 195 //Add new relation member to selected relation 196 for (OsmPrimitive osm : innerRelation) { 197 newMember = new RelationMember(role == null ? "" : role, osm); 198 relation.addMember(newMember); 199 }; 200 201 //Check if dataset is not empty or if {@link innerRelation} has no value 202 }else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty() || innerRelation.isEmpty()) { 203 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 204 205 //If selected object is not a relation member or not a relation member with role "outer" 206 }else if(!getRole(ds,relations).equals("outer")) { 207 JOptionPane.showMessageDialog(null, tr("No relation or no relation member with role \"outer\" selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 208 } 209 210 } 211 212 /** 310 213 * Returns the current ranking of the preset counter, which includes the 4 most used items. 311 214 * … … 315 218 return counter.getRanking(); 316 219 } 220 221 222 223 /************************************************* 224 * HELPER METHODS 225 * 226 */ 227 228 /** 229 * Function which returns the the relation (if any) of the currently selected object. 230 * If not returns null. 231 * @param ds actual working dataset 232 * @param relations collection of relations in the dataset 233 * @return relation of currently selected dataset 234 * @author rebsc 235 */ 236 private Relation getRelationFromDataSet(DataSet ds, Collection<Relation> relations) { 237 for(Relation r: relations) { 238 for(RelationMember rm: r.getMembers()) { 239 for(OsmPrimitive osm: ds.getSelected()) { 240 if(rm.refersTo(osm)) { 241 return r; 242 } 243 } 244 } 245 } 246 return null; 247 } 248 249 /** 250 * Function which returns the relation role (if any) of the currently selected object. 251 * If object is not a relation returns empty string. 252 * @param ds active dataset 253 * @param relations collection of relations in the dataset 254 * @return role of currently selected relation member if any 255 * @author rebsc 256 */ 257 private String getRole(DataSet ds, Collection<Relation> relations) { 258 259 if(isRelationMember(ds,relations)) { 260 for(Relation r: relations) { 261 for(RelationMember rm: r.getMembers()) { 262 for(OsmPrimitive osm: ds.getSelected()) { 263 if(rm.refersTo(osm)) { 264 return rm.getRole(); 265 } 266 } 267 } 268 } 269 } 270 return ""; 271 } 272 273 /** 274 * Function which returns true if the currently selected object is a relation 275 * @param ds active dataset 276 * @return true if selected object is a relation 277 * @author rebsc 278 */ 279 private boolean isRelationMember(DataSet ds, Collection<Relation> relations) { 280 for(Relation r: relations) { 281 for(RelationMember rm: r.getMembers()) { 282 for(OsmPrimitive osm: ds.getSelected()) { 283 if(rm.refersTo(osm)) { 284 return true; 285 } 286 } 287 } 288 } 289 return false; 290 } 291 292 293 /** 294 * 295 * 296 * 297 * 298 * 299 * 300 * 301 * 302 * 303 */ 317 304 } -
applications/editors/josm/plugins/indoorhelper/src/model/PresetCounter.java
r33887 r33974 30 30 * 31 31 * @author egru 32 * 32 * @author rebsc 33 33 */ 34 34 public class PresetCounter { … … 49 49 50 50 counterList.add(new ObjectCounter(IndoorObject.CONCRETE_WALL, 0)); 51 counterList.add(new ObjectCounter(IndoorObject.DOOR, 0)); 51 counterList.add(new ObjectCounter(IndoorObject.DOOR_PRIVATE, 0)); 52 counterList.add(new ObjectCounter(IndoorObject.DOOR_PUBLIC, 0)); 52 53 counterList.add(new ObjectCounter(IndoorObject.ELEVATOR, 0)); 53 54 counterList.add(new ObjectCounter(IndoorObject.ENTRANCE, 0)); 55 counterList.add(new ObjectCounter(IndoorObject.ENTRANCE_EXIT_ONLY, 0)); 56 counterList.add(new ObjectCounter(IndoorObject.ACCESS_PRIVATE, 0)); 57 counterList.add(new ObjectCounter(IndoorObject.ACCESS_PUBLIC, 0)); 54 58 counterList.add(new ObjectCounter(IndoorObject.GLASS_WALL, 0)); 55 59 counterList.add(new ObjectCounter(IndoorObject.ROOM, 0)); 56 counterList.add(new ObjectCounter(IndoorObject.SHELL, 0));57 counterList.add(new ObjectCounter(IndoorObject.STAIRWAYS, 0));58 60 counterList.add(new ObjectCounter(IndoorObject.STEPS, 0)); 61 counterList.add(new ObjectCounter(IndoorObject.CORRIDOR, 0)); 59 62 counterList.add(new ObjectCounter(IndoorObject.TOILET_FEMALE, 0)); 60 63 counterList.add(new ObjectCounter(IndoorObject.TOILET_MALE, 0)); 64 counterList.add(new ObjectCounter(IndoorObject.ZONE, 0)); 65 counterList.add(new ObjectCounter(IndoorObject.BENCH, 0)); 61 66 } 62 67 … … 134 139 } 135 140 141 142 143 /** 144 * 145 * 146 * 147 * 148 * 149 * 150 * 151 * 152 * 153 */ 136 154 } -
applications/editors/josm/plugins/indoorhelper/src/model/TagCatalog.java
r32637 r33974 19 19 package model; 20 20 21 /** 22 * Class to provide the indoor tagging catalog. 23 * 24 * @author egru 25 * @author rebsc 26 * 27 */ 28 29 /** 30 * Class to provide the indoor tagging catalog. 31 * 32 * @author egru 33 * @author rebsc 34 * 35 */ 36 import static org.openstreetmap.josm.tools.I18n.tr; 37 21 38 import java.util.ArrayList; 22 39 import java.util.List; … … 24 41 import org.openstreetmap.josm.data.osm.Tag; 25 42 26 /** 27 * Class to provide the indoor tagging catalog. 28 * 29 * @author egru 30 * 31 */ 43 public final class TagCatalog { 32 44 33 public final class TagCatalog {34 35 45 /** 36 * Function to get a specific tag-set out of the {@link TagCatalog}. 37 * 46 * Function to get a specific tag-set out of the {@link TagCatalog}. 47 * 38 48 * @param o the object for which you want the tag-set 39 49 * @return a list of tags for the specified object 40 */ 50 */ 41 51 public List<Tag> getTags(IndoorObject o) { 42 43 List<Tag> tagList = new ArrayList< Tag>();44 52 53 List<Tag> tagList = new ArrayList<>(); 54 45 55 switch(o) { 46 56 case CONCRETE_WALL: 47 tagList.add(new Tag("indoor :area", "wall"));48 tagList.add(new Tag( "indoor:wall:material","concrete"));57 tagList.add(new Tag(tr("indoor"), tr("wall"))); 58 tagList.add(new Tag(tr("material"), tr("concrete"))); 49 59 return tagList; 50 case DOOR: 51 tagList.add(new Tag("indoor:door", "yes")); 60 case DOOR_PRIVATE: 61 tagList.add(new Tag(tr("door"), tr("yes"))); 62 tagList.add(new Tag ("access","private")); 63 return tagList; 64 case DOOR_PUBLIC: 65 tagList.add(new Tag(tr("door"), tr("yes"))); 66 tagList.add(new Tag (tr("access"),tr("public"))); 52 67 return tagList; 53 68 case ELEVATOR: 54 tagList.add(new Tag( "indoor:area","elevator"));69 tagList.add(new Tag(tr("highway"), tr("elevator"))); 55 70 return tagList; 56 71 case ENTRANCE: 57 tagList.add(new Tag( "indoor:entrance", "yes"));72 tagList.add(new Tag(tr("entrance"), tr("yes"))); 58 73 return tagList; 74 case ENTRANCE_EXIT_ONLY: 75 tagList.add(new Tag(tr("entrance"), tr("exit"))); 76 return tagList; 77 case ACCESS_PRIVATE: 78 tagList.add(new Tag(tr("access"),tr("private"))); 79 return tagList; 80 case ACCESS_PUBLIC: 81 tagList.add(new Tag(tr("access"),tr("public"))); 82 return tagList; 59 83 case TOILET_FEMALE: 60 tagList.add(new Tag("indoor :area", "room"));61 tagList.add(new Tag("amenity" ,"toilets"));62 tagList.add(new Tag("female" , "yes"));84 tagList.add(new Tag(tr("indoor"), tr("room"))); 85 tagList.add(new Tag(tr("amenity"), tr("toilets"))); 86 tagList.add(new Tag(tr("female"), tr("yes"))); 63 87 return tagList; 64 88 case GLASS_WALL: 65 tagList.add(new Tag("indoor :area", "wall"));66 tagList.add(new Tag( "indoor:wall:material","glass"));89 tagList.add(new Tag(tr("indoor"), tr("wall"))); 90 tagList.add(new Tag(tr("material"), tr("glass"))); 67 91 return tagList; 68 92 case TOILET_MALE: 69 tagList.add(new Tag("indoor :area", "room"));70 tagList.add(new Tag("amenity" ,"toilets"));71 tagList.add(new Tag( "male", "yes"));93 tagList.add(new Tag(tr("indoor"), tr("room"))); 94 tagList.add(new Tag(tr("amenity"), tr("toilets"))); 95 tagList.add(new Tag(tr("male"), tr("yes"))); 72 96 return tagList; 73 97 case ROOM: 74 tagList.add(new Tag("indoor:area", "room")); 75 return tagList; 76 case SHELL: 77 tagList.add(new Tag("indoor:area", "shell")); 78 return tagList; 79 case STAIRWAYS: 80 tagList.add(new Tag("indoor:area", "stairways")); 98 tagList.add(new Tag(tr("indoor"), tr("room"))); 81 99 return tagList; 82 100 case STEPS: 83 tagList.add(new Tag( "indoor:highway","steps"));101 tagList.add(new Tag(tr("highway"), tr("steps"))); 84 102 return tagList; 103 case CORRIDOR: 104 tagList.add(new Tag(tr("indoor"), tr("corridor"))); 105 return tagList; 106 case BENCH: 107 tagList.add(new Tag(tr("amenity"),tr("bench"))); 108 return tagList; 109 case ZONE: 110 tagList.add(new Tag(tr("area"),tr("zone"))); 111 return tagList; 112 case NONE: 113 return tagList; 85 114 default: 86 115 tagList = null; … … 88 117 } 89 118 } 90 119 91 120 /** 92 121 * {@link Enum} class for an easier access of elements in the {@link TagCatalog} 93 * 122 * 94 123 * @author egru 124 * @author rebsc 95 125 * 96 126 */ 97 127 public enum IndoorObject { 98 SHELL, CONCRETE_WALL, GLASS_WALL, ROOM, TOILET_MALE, TOILET_FEMALE, ELEVATOR, STAIRWAYS, STEPS, DOOR, ENTRANCE; 128 CONCRETE_WALL, GLASS_WALL, ROOM, TOILET_MALE, TOILET_FEMALE, ELEVATOR, DOOR_PRIVATE, DOOR_PUBLIC, ENTRANCE, 129 ENTRANCE_EXIT_ONLY,ACCESS_PRIVATE,ACCESS_PUBLIC,STEPS,CORRIDOR,BENCH,ZONE,NONE; 99 130 } 100 131 132 133 /** 134 * 135 * 136 * 137 * 138 * 139 * 140 * 141 * 142 * 143 */ 101 144 } -
applications/editors/josm/plugins/indoorhelper/src/org/openstreetmap/josm/plugins/indoorhelper/IndoorHelperPlugin.java
r33887 r33974 25 25 26 26 import org.openstreetmap.josm.Main; 27 import org.openstreetmap.josm.gui.MainApplication; 27 28 import org.openstreetmap.josm.gui.MapFrame; 29 import org.openstreetmap.josm.gui.autofilter.AutoFilter; 30 import org.openstreetmap.josm.gui.autofilter.AutoFilterManager; 31 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 32 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 33 import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationEvent; 34 import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationListener; 35 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 28 36 import org.openstreetmap.josm.plugins.Plugin; 29 37 import org.openstreetmap.josm.plugins.PluginInformation; … … 36 44 * 37 45 * @author egru 46 * @author rebsc 38 47 * 39 48 */ 40 public class IndoorHelperPlugin extends Plugin { 41 42 43 49 public class IndoorHelperPlugin extends Plugin implements PaintableInvalidationListener, ActiveLayerChangeListener { 50 51 52 @SuppressWarnings("unused") 44 53 private IndoorHelperController controller; 45 54 String sep = System.getProperty("file.separator"); … … 54 63 public IndoorHelperPlugin(PluginInformation info) throws Exception { 55 64 super(info); 56 65 MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(this); 57 66 this.exportValidator("/data/indoorhelper.validator.mapcss"); 58 this.exportStyleFile(" indoor.mapcss");67 this.exportStyleFile("sit.mapcss"); 59 68 this.exportStyleFile("entrance_door_icon.png"); 60 69 this.exportStyleFile("entrance_icon.png"); 61 // this.setIndoorValidator(); 62 } 70 this.exportStyleFile("elevator_icon.png"); 71 72 //this.setIndoorValidator(); 73 } 74 63 75 64 76 /** … … 74 86 } 75 87 88 76 89 /** 77 90 * Exports the mapcss validator file to the preferences directory. 78 91 */ 79 private void exportValidator(String resourceName) throws Exception { 92 @SuppressWarnings("deprecation") 93 private void exportValidator(String resourceName) throws Exception { 80 94 InputStream stream = null; 81 95 OutputStream resStreamOut = null; 82 83 96 84 97 try { … … 93 106 byte[] buffer = new byte[4096]; 94 107 95 String valDirPath = Main.pref.get Dirs().getUserDataDirectory(false) + sep + "validator";108 String valDirPath = Main.pref.getUserDataDirectory() + sep + "validator"; 96 109 File valDir = new File(valDirPath); 97 110 valDir.mkdirs(); … … 129 142 byte[] buffer = new byte[4096]; 130 143 131 String valDirPath = Main.pref.getDirs().getUserDataDirectory(false) + sep + "styles"; 144 @SuppressWarnings("deprecation") 145 String valDirPath = Main.pref.getUserDataDirectory() + sep + "styles"; 132 146 File valDir = new File(valDirPath); 133 147 valDir.mkdirs(); … … 146 160 } 147 161 } 162 163 @Override 164 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 165 OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 166 if (editLayer != null) { 167 editLayer.addInvalidationListener(this); 168 } 169 } 170 171 @Override 172 public void paintableInvalidated(PaintableInvalidationEvent event){ 173 AutoFilter currentAutoFilter = AutoFilterManager.getInstance().getCurrentAutoFilter(); 174 String currentFilterValue = new String(); 175 176 if(currentAutoFilter != null) { 177 currentFilterValue = currentAutoFilter.getFilter().text.split("=")[1]; 178 179 this.controller.setIndoorLevel(currentFilterValue); 180 this.controller.getIndoorLevel(currentFilterValue); 181 this.controller.unsetSpecificKeyFilter("repeat_on"); 182 183 }else{ 184 currentFilterValue = ""; 185 this.controller.setIndoorLevel(currentFilterValue); 186 this.controller.getIndoorLevel(currentFilterValue); 187 }; 188 189 } 148 190 149 191 /** … … 189 231 // } 190 232 // } 233 234 /** 235 * 236 * 237 * 238 * 239 * 240 * 241 * 242 * 243 * 244 */ 191 245 } -
applications/editors/josm/plugins/indoorhelper/src/views/LevelSelectorView.java
r32637 r33974 1 /*2 * Indoorhelper is a JOSM plug-in to support users when creating their own indoor maps.3 * Copyright (C) 2016 Erik Gruschka4 *5 * This program is free software: you can redistribute it and/or modify6 * it under the terms of the GNU General Public License as published by7 * the Free Software Foundation, either version 3 of the License, or8 * (at your option) any later version.9 *10 * This program is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU General Public License16 * along with this program. If not, see <http://www.gnu.org/licenses/>.17 */18 19 1 package views; 20 2 … … 22 4 23 5 import java.awt.BorderLayout; 24 import java.awt.Container;25 6 import java.awt.GridBagConstraints; 26 7 import java.awt.GridBagLayout; 27 8 import java.awt.Insets; 28 9 import java.awt.event.ActionListener; 10 import java.awt.event.FocusEvent; 11 import java.awt.event.FocusListener; 12 import java.awt.event.WindowListener; 29 13 30 14 import javax.swing.JButton; … … 32 16 import javax.swing.JLabel; 33 17 import javax.swing.JPanel; 34 import javax.swing.JSpinner;35 import javax.swing.JSpinner.DefaultEditor;36 18 import javax.swing.border.EmptyBorder; 37 19 20 import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField; 21 38 22 /** 39 * Class for the pop-up window which provides an level selector to get a user input. 40 * In this window the user declares the lowest and the highest level of the building he wants to map. 23 * This is the level selector toolbox of the indoorhelper plug-in. 41 24 * 42 * @author egru25 * @author rebsc 43 26 * 44 27 */ 45 46 @SuppressWarnings("serial")47 28 public class LevelSelectorView extends JFrame { 48 29 49 private JPanel dialogPane; 30 private static final long serialVersionUID = 1L; 31 private JPanel dialogPane; 50 32 private JPanel contentPanel; 51 private JLabel minLabel; 52 private JSpinner minSpinner; 53 private JLabel maxLabel; 54 private JSpinner maxSpinner; 33 private JPanel infoBar; 55 34 private JPanel buttonBar; 56 35 private JButton okButton; 57 36 private JButton cancelButton; 37 private JLabel label1; 38 private JLabel label2; 39 private DisableShortcutsOnFocusGainedTextField field; 58 40 59 41 public LevelSelectorView() { … … 64 46 dialogPane = new JPanel(); 65 47 contentPanel = new JPanel(); 66 minLabel = new JLabel(); 67 minSpinner = new JSpinner(); 68 maxLabel = new JLabel(); 69 maxSpinner = new JSpinner(); 48 infoBar = new JPanel(); 70 49 buttonBar = new JPanel(); 71 50 okButton = new JButton(); 72 51 cancelButton = new JButton(); 52 label1 = new JLabel(); 53 label2 = new JLabel(); 54 field = new DisableShortcutsOnFocusGainedTextField(); 73 55 74 56 //======== this ======== 75 setTitle(tr(" Level Selection"));76 Container contentPane = getContentPane(); 57 setTitle(tr("Add a new level")); 58 java.awt.Container contentPane = getContentPane(); 77 59 contentPane.setLayout(new BorderLayout()); 78 60 … … 82 64 dialogPane.setLayout(new BorderLayout()); 83 65 66 67 //======== infoBar ======== 68 { 69 70 //---- Label1 ---- 71 label1.setText(tr("<html> Please insert the new level number you want to add.<br> " 72 + " <i>Info</i>: <br> If the OK button got pressed you will switch to the drawing action.<br>" 73 + "To finish the new object please press the spacebar. The new level<br>will be tagged automatically. </html>")); 74 infoBar.add(label1); 75 } 76 dialogPane.add(infoBar,BorderLayout.NORTH); 77 78 84 79 //======== contentPanel ======== 85 80 { 86 81 contentPanel.setLayout(new GridBagLayout()); 87 82 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0}; 88 83 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0}; … … 90 85 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 91 86 92 //---- minLabel ----93 minLabel.setText(tr("Lowest Level"));94 contentPanel.add(maxLabel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,95 GridBagConstraints.CENTER, GridBagConstraints.BOTH,96 new Insets(0, 0, 5, 5), 0, 0));97 JSpinner.DefaultEditor minEditor = (DefaultEditor) maxSpinner.getEditor();98 minEditor.getTextField().setColumns(2);99 maxSpinner.setToolTipText(tr("The lowest level of your building."));100 contentPanel.add(maxSpinner, new GridBagConstraints(2, 0, 2, 1, 0.0, 0.0,101 GridBagConstraints.CENTER, GridBagConstraints.BOTH,102 new Insets(0, 0, 5, 0), 0, 0));103 87 104 //---- maxLabel ---- 105 maxLabel.setText(tr("Highest Level")); 106 contentPanel.add(minLabel, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, 107 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 108 new Insets(0, 0, 5, 5), 0, 0)); 109 JSpinner.DefaultEditor maxEditor = (DefaultEditor) minSpinner.getEditor(); 110 maxEditor.getTextField().setColumns(2); 111 minSpinner.setToolTipText(tr("The highest level of your building.")); 112 contentPanel.add(minSpinner, new GridBagConstraints(2, 2, 2, 1, 0.0, 0.0, 113 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 114 new Insets(0, 0, 5, 0), 0, 0)); 88 //---- Label2 ---- 89 label2.setText(tr("level number:")); 90 contentPanel.add(label2,new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, 91 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 92 new Insets(5, 5, 5, 30), 0, 0)); 93 94 //---- Field ---- 95 field.setToolTipText(tr("Example: '2' or '3'")); 96 field.addFocusListener(new FocusListener() { 97 98 @Override 99 public void focusLost(FocusEvent e) {} 100 101 @Override 102 public void focusGained(FocusEvent e) { 103 field.selectAll(); 104 } 105 }); 106 contentPanel.add(field, new GridBagConstraints(3, 0, 2, 1, 0.0, 0.0, 107 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 108 new Insets(5, 0, 5, 200), 0, 0)); 109 115 110 } 116 111 dialogPane.add(contentPanel, BorderLayout.CENTER); … … 126 121 okButton.setText(tr("OK")); 127 122 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 128 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 129 new Insets(0, 0, 0, 5), 0, 0)); 123 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 124 new Insets(0, 0, 0, 5), 0, 0)); 130 125 131 //---- cancelButton ----132 126 //---- Button ---- 127 cancelButton.setText(tr("Cancel")); 133 128 buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 134 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 135 new Insets(0, 0, 0, 0), 0, 0)); 136 } 137 dialogPane.add(contentPanel, BorderLayout.CENTER); 138 139 //======== buttonBar ======== 140 { 141 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 142 buttonBar.setLayout(new GridBagLayout()); 143 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80}; 144 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0}; 145 146 //---- okButton ---- 147 okButton.setText(tr("OK")); 148 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 149 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 150 new Insets(0, 0, 0, 5), 0, 0)); 151 152 //---- cancelButton ---- 153 cancelButton.setText(tr("Cancel")); 154 buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 155 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 156 new Insets(0, 0, 0, 0), 0, 0)); 129 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 130 new Insets(0, 0, 0, 0), 0, 0)); 157 131 } 158 132 dialogPane.add(buttonBar, BorderLayout.SOUTH); … … 164 138 } 165 139 140 /************************************************* 141 * GETTER 142 * 143 */ 166 144 /** 145 * Getter for the level number field. 146 * 147 * @return the {@link String} 148 */ 149 public String getLevelNumber() { 150 return this.field.getText(); 151 } 152 153 /************************************************* 154 * SELECTOR VIEW LISTENER 155 * 156 */ 157 158 /** 167 159 * Set the listener for the OK button. 168 160 * … … 173 165 } 174 166 175 176 * Set the listener for the cancel button.167 /** 168 * Set the listener for the Cancel button. 177 169 * 178 170 * @param l the listener to set … … 183 175 184 176 /** 185 * Getter forthe lowest level.177 * Set the listener for window {@Link LevelSelectorView} 186 178 * 187 * @ return Integer which represents the lowest level of the building.179 * @param l the listener to set 188 180 */ 189 public int getMin() {190 return (int) this.minSpinner.getValue();181 public void setSelectorWindowListener(WindowListener l) { 182 this.addWindowListener(l); 191 183 } 192 184 193 /** 194 * Getter for the highest level. 195 * 196 * @return Integer which represents the highest level of the building. 197 */ 198 public int getMax() { 199 return (int) this.maxSpinner.getValue(); 200 } 185 /** 186 * 187 * 188 * 189 * 190 * 191 * 192 * 193 * 194 */ 201 195 } -
applications/editors/josm/plugins/indoorhelper/src/views/PresetButton.java
r32637 r33974 45 45 this.indoorObject = object; 46 46 this.setText(indoorObject.toString()); 47 this.setToolTipText(indoorObject.toString()); 47 this.setToolTipText("Fast Tag: "+indoorObject.toString()); 48 48 } 49 49 50 51 /** 52 * 53 * 54 * 55 * 56 * 57 * 58 * 59 * 60 */ 50 61 } -
applications/editors/josm/plugins/indoorhelper/src/views/ToolBoxView.java
r32637 r33974 22 22 23 23 import java.awt.BorderLayout; 24 import java.awt.Color; 24 25 import java.awt.GridBagConstraints; 25 26 import java.awt.GridBagLayout; … … 31 32 import java.awt.event.ItemListener; 32 33 import java.util.List; 33 import java.util.ListIterator;34 34 35 35 import javax.swing.JButton; 36 import javax.swing.JCheckBox; 36 37 import javax.swing.JLabel; 37 38 import javax.swing.JPanel; 38 39 import javax.swing.JSeparator; 39 import javax.swing.JToggleButton;40 40 import javax.swing.border.EmptyBorder; 41 41 … … 44 44 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 45 45 46 import model.IndoorLevel;47 46 import model.TagCatalog; 48 47 import model.TagCatalog.IndoorObject; 49 48 50 49 /** 51 * 52 * This is the main toolbox of the indoorhelper plug-in. 53 * 54 * @author egru 55 * 56 */ 50 * 51 * This is the main toolbox of the indoorhelper plug-in. 52 * 53 * @author egru 54 * @author rebsc 55 * 56 */ 57 57 @SuppressWarnings("serial") 58 58 public class ToolBoxView extends ToggleDialog { 59 private JPanel dialogPane; 60 private JPanel contentPanel; 61 private JToggleButton powerButton; 62 private JLabel levelLabel; 63 private JosmComboBox<String> levelBox; 64 private JLabel levelTagLabel; 65 private DisableShortcutsOnFocusGainedTextField levelTagField; 66 private JLabel objectLabel; 67 private JosmComboBox<TagCatalog.IndoorObject> objectBox; 68 private JLabel nameLabel; 69 private DisableShortcutsOnFocusGainedTextField nameField; 70 private JLabel refLabel; 71 private DisableShortcutsOnFocusGainedTextField refField; 72 private JPanel buttonBar; 73 private JButton applyButton; 74 private JSeparator separator1; 75 private JSeparator separator2; 76 private PresetButton preset1; 77 private PresetButton preset2; 78 private PresetButton preset3; 79 private PresetButton preset4; 80 81 public ToolBoxView() { 82 super(tr("Indoor Mapping Helper"), "indoorhelper", 83 tr("Toolbox for indoor mapping assistance"), null, 300, true); 84 85 initComponents(); 86 } 87 88 /** 89 * Creates the layout of the plug-in. 90 */ 91 private void initComponents() { 92 dialogPane = new JPanel(); 93 contentPanel = new JPanel(); 94 powerButton = new JToggleButton(); 95 levelLabel = new JLabel(); 96 levelBox = new JosmComboBox<String>(); 97 levelTagLabel = new JLabel(); 98 levelTagField = new DisableShortcutsOnFocusGainedTextField(); 99 objectLabel = new JLabel(); 100 objectBox = new JosmComboBox<>(TagCatalog.IndoorObject.values()); 101 nameLabel = new JLabel(); 102 nameField = new DisableShortcutsOnFocusGainedTextField(); 103 refLabel = new JLabel(); 104 refField = new DisableShortcutsOnFocusGainedTextField(); 105 buttonBar = new JPanel(); 106 applyButton = new JButton(); 107 separator1 = new JSeparator(); 108 separator2 = new JSeparator(); 109 preset1 = new PresetButton(IndoorObject.ROOM); 110 preset2 = new PresetButton(IndoorObject.SHELL); 111 preset3 = new PresetButton(IndoorObject.CONCRETE_WALL); 112 preset4 = new PresetButton(IndoorObject.GLASS_WALL); 113 114 //======== this ======== 115 //Container contentPane = this.get; 116 //contentPane.setLayout(new BorderLayout()); 117 118 //======== dialogPane ======== 119 { 120 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); 121 dialogPane.setLayout(new BorderLayout()); 122 123 //======== contentPanel ======== 124 { 125 contentPanel.setLayout(new GridBagLayout()); 126 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] { 127 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 128 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0}; 129 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] { 130 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 131 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 132 133 //---- powerButton ---- 134 powerButton.setText(tr("POWER")); 135 powerButton.setToolTipText(tr("Activates the plug-in")); 136 contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0, 137 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 138 new Insets(0, 0, 5, 5), 0, 0)); 139 contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0, 140 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 141 new Insets(0, 0, 5, 5), 0, 0)); 142 143 //---- levelLabel ---- 144 levelLabel.setText(tr("Working Level")); 145 contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, 146 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 147 new Insets(0, 0, 5, 5), 0, 0)); 148 149 //---- levelBox ---- 150 levelBox.setEnabled(false); 151 levelBox.setEditable(false); 152 levelBox.setToolTipText(tr("Selects the working level.")); 153 contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0, 154 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 155 new Insets(0, 0, 5, 5), 0, 0)); 156 157 //---- levelTagLabel ---- 158 levelTagLabel.setText(tr("Level Name")); 159 contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, 160 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 161 new Insets(0, 0, 5, 5), 0, 0)); 162 163 //---- levelTagField ---- 164 levelTagField.setEnabled(false); 165 levelTagField.setColumns(6); 166 levelTagField.setToolTipText(tr("Optional name-tag for a level.")); 167 contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0, 168 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 169 new Insets(0, 0, 5, 5), 0, 0)); 170 contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0, 171 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 172 new Insets(0, 0, 5, 5), 0, 0)); 173 174 //---- objectLabel ---- 175 objectLabel.setText(tr("Object")); 176 contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, 177 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 178 new Insets(0, 0, 5, 5), 0, 0)); 179 180 //---- objectBox ---- 181 objectBox.setEnabled(false); 182 objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL); 183 objectBox.setToolTipText(tr("The object preset you want to tag.")); 184 contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0, 185 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 186 new Insets(0, 0, 5, 5), 0, 0)); 187 188 //---- nameLabel ---- 189 nameLabel.setText(tr("Name")); 190 contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, 191 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 192 new Insets(0, 0, 5, 5), 0, 0)); 193 194 //---- nameField ---- 195 nameField.setEnabled(false); 196 nameField.addFocusListener(new FocusListener() { 197 198 @Override 199 public void focusLost(FocusEvent e) {} 200 201 @Override 202 public void focusGained(FocusEvent e) { 203 nameField.selectAll(); 204 } 205 }); 206 nameField.setToolTipText(tr("Sets the name tag when the room-object is selected.")); 207 contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0, 208 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 209 new Insets(0, 0, 5, 5), 0, 0)); 210 211 //---- refLabel ---- 212 refLabel.setText(tr("Reference")); 213 contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0, 214 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 215 new Insets(0, 0, 0, 5), 0, 0)); 216 217 //---- refField ---- 218 refField.setEnabled(false); 219 refField.addFocusListener(new FocusListener() { 220 221 @Override 222 public void focusLost(FocusEvent e) {} 223 224 @Override 225 public void focusGained(FocusEvent e) { 226 refField.selectAll(); 227 } 228 }); 229 refField.setToolTipText(tr("Sets the ref tag when the room-object is selected.")); 230 contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0, 231 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 232 new Insets(0, 0, 0, 5), 0, 0)); 233 234 //---- preset1 ---- 235 preset1.setEnabled(false); 236 contentPanel.add(preset1, new GridBagConstraints(16, 2, 1, 1, 0.0, 0.0, 237 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 238 new Insets(0, 0, 5, 5), 0, 0)); 239 contentPanel.add(separator2, new GridBagConstraints(1, 3, 13, 1, 0.0, 0.0, 240 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 241 new Insets(0, 0, 5, 5), 0, 0)); 242 243 //---- preset2 ---- 244 preset2.setEnabled(false); 245 contentPanel.add(preset2, new GridBagConstraints(16, 3, 1, 1, 0.0, 0.0, 246 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 247 new Insets(0, 0, 5, 5), 0, 0)); 248 249 //---- preset3 ---- 250 preset3.setEnabled(false); 251 contentPanel.add(preset3, new GridBagConstraints(16, 4, 1, 1, 0.0, 0.0, 252 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 253 new Insets(0, 0, 5, 5), 0, 0)); 254 255 //---- preset4 ---- 256 preset4.setEnabled(false); 257 contentPanel.add(preset4, new GridBagConstraints(16, 5, 1, 1, 0.0, 0.0, 258 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 259 new Insets(0, 0, 5, 5), 0, 0)); 260 } 261 dialogPane.add(contentPanel, BorderLayout.CENTER); 262 263 //======== buttonBar ======== 264 { 265 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 266 buttonBar.setLayout(new GridBagLayout()); 267 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 268 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 269 270 //---- applyButton ---- 271 applyButton.setText(tr("Apply Tags")); 272 applyButton.setEnabled(false); 273 buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, 274 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 275 new Insets(0, 0, 0, 0), 0, 0)); 276 } 277 dialogPane.add(buttonBar, BorderLayout.SOUTH); 278 } 279 //contentPane.add(dialogPane, BorderLayout.CENTER); 280 281 282 this.createLayout(dialogPane, false, null); 283 } 284 285 /** 286 * Returns the state of the power button. 287 * 288 * @return boolean which is true when the button is selected 289 */ 290 public boolean getPowerButtonState() { 291 return this.powerButton.isSelected(); 292 } 293 294 /** 295 * Enables or disables the interactive UI elements of the toolbox. 296 * 297 * @param enabled set this true for enabled elements 298 */ 299 public void setAllUiElementsEnabled(boolean enabled) { 300 this.applyButton.setEnabled(enabled); 301 this.levelBox.setEnabled(enabled); 302 this.objectBox.setEnabled(enabled); 303 this.nameField.setEnabled(enabled); 304 this.refField.setEnabled(enabled); 305 this.levelTagField.setEnabled(enabled); 306 this.preset1.setEnabled(enabled); 307 this.preset2.setEnabled(enabled); 308 this.preset3.setEnabled(enabled); 309 this.preset4.setEnabled(enabled); 310 311 312 if (enabled == false) { 313 resetUiElements(); 314 this.levelTagField.setText(""); 315 } 316 } 317 318 /** 319 * Enables or disables the interactive text box elements name and ref. 320 * 321 * @param enabled set this true for enabled elements 322 */ 323 public void setTagUiElementsEnabled(boolean enabled) { 324 this.nameField.setEnabled(enabled); 325 this.refField.setEnabled(enabled); 326 327 if (enabled == false) resetUiElements(); 328 } 329 330 /** 331 * Disables the power-button of the plug-in. 332 */ 333 public void setPowerButtonDisabled() { 334 this.powerButton.setSelected(false); 335 } 336 337 /** 338 * Getter for the selected {@link IndoorObject} in the objectBox. 339 * 340 * @return the selected indoor object in the object ComboBox. 341 */ 342 public IndoorObject getSelectedObject() { 343 return (IndoorObject) this.objectBox.getSelectedItem(); 344 } 345 346 347 /** 348 * Sets the level list for the level selection comboBox. 349 * 350 * @param levelList the list of levels which you want to set 351 */ 352 public void setLevelList(List<IndoorLevel> levelList) { 353 this.levelBox.removeAllItems(); 354 355 ListIterator<IndoorLevel> listIterator = levelList.listIterator(); 356 357 while (listIterator.hasNext()) { 358 IndoorLevel level = listIterator.next(); 359 if (level.hasEmptyName()) { 360 this.levelBox.addItem(Integer.toString(level.getLevelNumber())); 361 } else { 362 this.levelBox.addItem(level.getName()); 363 } 364 } 365 } 366 367 /** 368 * Getter for the selected working level. 369 * 370 * @return the index of the selected item in the level-box 371 */ 372 public int getSelectedLevelIndex() { 373 return this.levelBox.getSelectedIndex(); 374 } 375 376 /** 377 * Checks if the level list is empty. 378 * 379 * @return boolean which is true if the level-list is empty 380 */ 381 public boolean levelListIsEmpty() { 382 if (this.levelBox.getItemCount() == 0) { 383 return true; 384 } else { 385 return false; 386 } 387 } 388 389 /** 390 * Getter for the level-name-field. 391 * 392 * @return the {@link String} of the levelTagField 393 */ 394 public String getLevelName() { 395 return this.levelTagField.getText(); 396 } 397 398 /** 399 * Setter for the level name field. 400 * 401 * @param name the String for the levelTagField 402 */ 403 public void setLevelName(String name) { 404 this.levelTagField.setText(name); 405 } 406 407 /** 408 * Getter for the name {@link TextField}. 409 * 410 * @return {@link String} of the name text field 411 */ 412 public String getNameText() { 413 return this.nameField.getText(); 414 } 415 416 /** 417 * Getter for the ref {@link TextField}. 418 * 419 * @return {@link String} of the ref text field 420 */ 421 public String getRefText() { 422 return this.refField.getText(); 423 } 424 425 /** 426 * Resets the view by making the UI elements disabled and deleting the level list. 427 */ 428 public void reset() { 429 this.setAllUiElementsEnabled(false); 430 this.levelBox.removeAllItems(); 431 } 432 433 /** 434 * Clears the text boxes and sets an empty {@link String}. 435 */ 436 public void resetUiElements() { 437 this.nameField.setText(""); 438 this.refField.setText(""); 439 } 440 441 /* 442 * ******************************** 443 * SETTERS FOR THE BUTTON LISTENERS 444 * ******************************** 445 */ 446 447 /** 448 * Set the listener for the power button. 449 * 450 * @param l the listener to set 451 */ 452 public void setPowerButtonListener(ActionListener l) { 453 this.powerButton.addActionListener(l); 454 } 455 456 /** 457 * Set the listener for the apply button. 458 * 459 * @param l the listener to set 460 */ 461 public void setApplyButtonListener(ActionListener l) { 462 this.applyButton.addActionListener(l); 463 } 464 465 /** 466 * Set the listener which is called when a new item in the level list is selected. 467 * 468 * @param l the listener to set 469 */ 470 public void setLevelItemListener(ItemListener l) { 471 this.levelBox.addItemListener(l); 472 } 473 474 475 /** 476 * Set the listener which is called when a new item in the object list is selected. 477 * 478 * @param l the listener to set 479 */ 480 public void setObjectItemListener(ItemListener l) { 481 this.objectBox.addItemListener(l); 482 } 483 484 // Preset Button Functions 485 486 public void setPresetButtons(List<IndoorObject> objects) { 487 this.preset1.setIndoorObject(objects.get(0)); 488 this.preset2.setIndoorObject(objects.get(1)); 489 this.preset3.setIndoorObject(objects.get(2)); 490 this.preset4.setIndoorObject(objects.get(3)); 491 } 492 493 public void setPreset1Listener(ActionListener l) { 494 this.preset1.addActionListener(l); 495 } 496 497 public void setPreset2Listener(ActionListener l) { 498 this.preset2.addActionListener(l); 499 } 500 501 public void setPreset3Listener(ActionListener l) { 502 this.preset3.addActionListener(l); 503 } 504 505 public void setPreset4Listener(ActionListener l) { 506 this.preset4.addActionListener(l); 507 } 508 509 public IndoorObject getPreset1() { 510 return preset1.getIndoorObject(); 511 } 512 513 public IndoorObject getPreset2() { 514 return preset2.getIndoorObject(); 515 } 516 517 public IndoorObject getPreset3() { 518 return preset3.getIndoorObject(); 519 } 520 521 public IndoorObject getPreset4() { 522 return preset4.getIndoorObject(); 523 } 59 private JPanel dialogPanel; 60 private JPanel contentPanel; 61 private JLabel levelLabel; 62 private JCheckBox levelCheckBox; 63 private JLabel levelNameLabel; 64 private DisableShortcutsOnFocusGainedTextField levelNameField; 65 private JLabel repeatOnLabel; 66 private DisableShortcutsOnFocusGainedTextField repeatOnField; 67 private JLabel objectLabel; 68 private JosmComboBox<TagCatalog.IndoorObject> objectBox; 69 private JLabel nameLabel; 70 private DisableShortcutsOnFocusGainedTextField nameField; 71 private JLabel refLabel; 72 private DisableShortcutsOnFocusGainedTextField refField; 73 private JLabel multiLabel; 74 private JButton multiOuterButton; 75 private JButton multiInnerButton; 76 private JCheckBox multiCheckBox; 77 private JPanel buttonBar; 78 private JButton applyButton; 79 private JSeparator separator1; 80 private JSeparator separator2; 81 private PresetButton preset1; 82 private PresetButton preset2; 83 private PresetButton preset3; 84 private PresetButton preset4; 85 private JButton addLevelButton; 86 private JButton helpButton; 87 88 89 public ToolBoxView() { 90 super(tr("Indoor Mapping Helper"), "indoorhelper", 91 tr("Toolbox for indoor mapping assistance"), null, 300, true); 92 93 initComponents(); 94 } 95 96 /************************************************* 97 * CREATES THE LAYOUT OF THE PLUG-IN. 98 * 99 */ 100 private void initComponents() { 101 dialogPanel = new JPanel(); 102 contentPanel = new JPanel(); 103 levelLabel = new JLabel(); 104 levelCheckBox = new JCheckBox(); 105 levelNameLabel = new JLabel(); 106 levelNameField = new DisableShortcutsOnFocusGainedTextField(); 107 repeatOnLabel = new JLabel(); 108 repeatOnField = new DisableShortcutsOnFocusGainedTextField(); 109 objectLabel = new JLabel(); 110 objectBox = new JosmComboBox<>(TagCatalog.IndoorObject.values()); 111 nameLabel = new JLabel(); 112 nameField = new DisableShortcutsOnFocusGainedTextField(); 113 refLabel = new JLabel(); 114 refField = new DisableShortcutsOnFocusGainedTextField(); 115 multiLabel = new JLabel(); 116 multiOuterButton = new JButton(); 117 multiInnerButton = new JButton(); 118 multiCheckBox = new JCheckBox(); 119 buttonBar = new JPanel(); 120 applyButton = new JButton(); 121 separator1 = new JSeparator(); 122 separator2 = new JSeparator(); 123 preset1 = new PresetButton(IndoorObject.ROOM); 124 preset2 = new PresetButton(IndoorObject.STEPS); 125 preset3 = new PresetButton(IndoorObject.CONCRETE_WALL); 126 preset4 = new PresetButton(IndoorObject.GLASS_WALL); 127 addLevelButton = new JButton(); 128 helpButton = new JButton(); 129 130 //======== this ======== 131 //Container contentPane = this.get; 132 //contentPane.setLayout(new BorderLayout()); 133 134 //======== dialogPane ======== 135 { 136 dialogPanel.setBorder(new EmptyBorder(12, 12, 12, 12)); 137 dialogPanel.setLayout(new BorderLayout()); 138 139 //======== contentPanel ======== 140 { 141 contentPanel.setLayout(new GridBagLayout()); 142 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] { 143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 144 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0}; 145 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] { 146 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 147 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 148 149 150 //---- addLevelButton ---- 151 addLevelButton.setText(tr("Insert level")); 152 addLevelButton.setToolTipText(tr("Add a new level to layer.")); 153 addLevelButton.setEnabled(false); 154 contentPanel.add(addLevelButton, new GridBagConstraints(12, 1, 3, 1, 0.0, 1.0, 155 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 156 new Insets(0, 0, 5, 30), 0, 0)); 157 158 //---- helpButton ---- 159 helpButton.setText(tr("<html><b>?</strong></b>")); 160 helpButton.setToolTipText(tr("Show Help-Browser.")); 161 helpButton.setBackground(Color.LIGHT_GRAY); 162 helpButton.setEnabled(false); 163 contentPanel.add(helpButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, 164 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 165 new Insets(0, 0, 5, 0), 0, 0)); 166 167 //---- levelNameLabel ---- 168 levelNameLabel.setText(tr("Level name")); 169 contentPanel.add(levelNameLabel, new GridBagConstraints(0, 1, 3, 1, 0.0, 1.0, 170 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 171 new Insets(0, 0, 5, 5), 0, 0)); 172 173 //---- levelNameField ---- 174 levelNameField.setEnabled(false); 175 levelNameField.setToolTipText(tr("Sets optional name tag for a level.")); 176 contentPanel.add(levelNameField, new GridBagConstraints(3, 1, 3, 1, 0.0, 1.0, 177 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 178 new Insets(0, 0, 5, 30), 0, 0)); 179 180 //---- levelLabel ---- 181 levelLabel.setText(tr("Working level: NONE")); 182 levelLabel.setToolTipText(tr("Shows the current working level.")); 183 contentPanel.add(levelLabel, new GridBagConstraints(6, 1, 3, 1, 0.0, 1.0, 184 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 185 new Insets(0, 0, 5, 5), 0, 0)); 186 187 //---- levelCheckBox ---- 188 levelCheckBox.setToolTipText(tr("Deactivate automatic level tagging.")); 189 contentPanel.add(levelCheckBox, new GridBagConstraints(9, 1, 1, 1, 0.0, 1.0, 190 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 191 new Insets(0, 0, 5, 5), 0, 0)); 192 contentPanel.add(separator1, new GridBagConstraints(0, 2, 0, 1, 0.0, 0.0, 193 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 194 new Insets(0, 0, 5, 5), 0, 0)); 195 196 //---- objectLabel ---- 197 objectLabel.setText(tr("Object")); 198 contentPanel.add(objectLabel, new GridBagConstraints(0, 3, 3, 1, 0.0, 1.0, 199 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 200 new Insets(0, 0, 5, 5), 0, 0)); 201 202 //---- objectBox ---- 203 objectBox.setEnabled(false); 204 objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL); 205 objectBox.setToolTipText(tr("The object preset you want to tag.")); 206 contentPanel.add(objectBox, new GridBagConstraints(3, 3, 3, 1, 0.0, 1.0, 207 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 208 new Insets(0, 0, 5, 30), 0, 0)); 209 210 //---- nameLabel ---- 211 nameLabel.setText(tr("Name")); 212 contentPanel.add(nameLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 1.0, 213 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 214 new Insets(0, 0, 5, 5), 0, 0)); 215 216 //---- nameField ---- 217 nameField.setEnabled(false); 218 nameField.addFocusListener(new FocusListener() { 219 220 @Override 221 public void focusLost(FocusEvent e) {} 222 223 @Override 224 public void focusGained(FocusEvent e) { 225 nameField.selectAll(); 226 } 227 }); 228 nameField.setToolTipText(tr("Sets the name tag.")); 229 contentPanel.add(nameField, new GridBagConstraints(3, 4, 3, 1, 0.0, 1.0, 230 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 231 new Insets(0, 0, 5, 30), 0, 0)); 232 233 //---- refLabel ---- 234 refLabel.setText(tr("Reference")); 235 contentPanel.add(refLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 1.0, 236 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 237 new Insets(0, 0, 5, 5), 0, 0)); 238 239 //---- refField ---- 240 refField.setEnabled(false); 241 refField.addFocusListener(new FocusListener() { 242 243 @Override 244 public void focusLost(FocusEvent e) {} 245 246 @Override 247 public void focusGained(FocusEvent e) { 248 refField.selectAll(); 249 } 250 }); 251 refField.setToolTipText(tr("Sets the referance tag.")); 252 contentPanel.add(refField, new GridBagConstraints(3, 5, 3, 1, 0.0, 1.0, 253 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 254 new Insets(0, 0, 5, 30), 0, 0)); 255 256 //---- repeatOnLabel ---- 257 repeatOnLabel.setText(tr("Repeat on")); 258 contentPanel.add(repeatOnLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 1.0, 259 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 260 new Insets(0, 0, 5, 5), 0, 0)); 261 262 //---- repeatOnField ---- 263 repeatOnField.setEnabled(false); 264 repeatOnField.addFocusListener(new FocusListener() { 265 266 @Override 267 public void focusLost(FocusEvent e) {} 268 269 @Override 270 public void focusGained(FocusEvent e) { 271 repeatOnField.selectAll(); 272 } 273 }); 274 repeatOnField.setToolTipText(tr("Sets the repeat on tag when highway objects are selected. Please tag like this: -3-4 or -2--3 or 5-6 .")); 275 contentPanel.add(repeatOnField, new GridBagConstraints(3, 6, 3, 1, 0.0, 1.0, 276 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 277 new Insets(0, 0, 5, 30), 0, 0)); 278 contentPanel.add(separator2, new GridBagConstraints(0, 7, 0, 1, 0.0, 1.0, 279 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 280 new Insets(0, 0, 5, 5), 0, 0)); 281 282 //---- preset1 ---- 283 preset1.setEnabled(false); 284 contentPanel.add(preset1, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0, 285 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 286 new Insets(0, 0, 5, 5), 0, 0)); 287 //---- preset2 ---- 288 preset2.setEnabled(false); 289 contentPanel.add(preset2, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, 290 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 291 new Insets(0, 0, 5, 5), 0, 0)); 292 293 //---- preset3 ---- 294 preset3.setEnabled(false); 295 contentPanel.add(preset3, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, 296 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 297 new Insets(0, 0, 5, 5), 0, 0)); 298 299 //---- preset4 ---- 300 preset4.setEnabled(false); 301 contentPanel.add(preset4, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0, 302 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 303 new Insets(0, 0, 5, 5), 0, 0)); 304 305 //---- multiLabel ---- 306 multiLabel.setText(tr("Multipolygon")); 307 contentPanel.add(multiLabel, new GridBagConstraints(0, 8, 3, 1, 0.0, 1.0, 308 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 309 new Insets(0, 0, 5, 5), 0, 0)); 310 311 //---- multiOuterButton ---- 312 multiOuterButton.setText(tr("OUTER")); 313 multiOuterButton.setToolTipText(tr("Creation-Tool for multipolygon with role: outer. To finish press the spacebar.")); 314 multiOuterButton.setEnabled(false); 315 contentPanel.add(multiOuterButton, new GridBagConstraints(3, 8, 3, 1, 0.0, 1.0, 316 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 317 new Insets(0, 0, 5, 30), 0, 0)); 318 319 //---- multiInnerButton ---- 320 multiInnerButton.setText(tr("INNER")); 321 multiInnerButton.setToolTipText(tr("Creation-Tool for multipolygons with role: inner. To finish press spacebar. To add to relation select \"outer\" and press enter.")); 322 multiInnerButton.setEnabled(false); 323 contentPanel.add(multiInnerButton, new GridBagConstraints(6, 8, 1, 1, 0.0, 0.0, 324 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 325 new Insets(0, 0, 5, 5), 0, 0)); 326 327 //---- multiCheckBox ---- 328 multiCheckBox.setToolTipText(tr("Deactivate multipolygon function.")); 329 contentPanel.add(multiCheckBox, new GridBagConstraints(9, 8, 1, 1, 0.0, 1.0, 330 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 331 new Insets(0, 0, 5, 5), 0, 0)); 332 } 333 dialogPanel.add(contentPanel, BorderLayout.CENTER); 334 335 //======== buttonBar ======== 336 { 337 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 338 buttonBar.setLayout(new GridBagLayout()); 339 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 340 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 341 342 //---- applyButton ---- 343 applyButton.setText(tr("Apply")); 344 applyButton.setToolTipText(tr("Add selected tags and/or relations to obeject.")); 345 applyButton.setEnabled(false); 346 buttonBar.add(applyButton, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, 347 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 348 new Insets(0, 0, 0, 0), 0, 0)); 349 } 350 dialogPanel.add(buttonBar, BorderLayout.SOUTH); 351 } 352 this.createLayout(dialogPanel, true, null); 353 354 } 355 356 /************************************************* 357 * ENABLES OR DISABLES UI ELEMENTS 358 * 359 */ 360 /** 361 * Enables or disables the interactive UI elements of the toolbox. 362 * 363 * @param enabled set this true for enabled elements 364 */ 365 public void setAllUiElementsEnabled(boolean enabled) { 366 this.applyButton.setEnabled(enabled); 367 this.levelCheckBox.setEnabled(enabled); 368 this.helpButton.setEnabled(enabled); 369 this.objectBox.setEnabled(enabled); 370 this.levelNameField.setEnabled(enabled); 371 this.nameField.setEnabled(enabled); 372 this.refField.setEnabled(enabled); 373 this.levelNameField.setEnabled(enabled); 374 this.repeatOnField.setEnabled(enabled); 375 this.multiOuterButton.setEnabled(enabled); 376 this.multiInnerButton.setEnabled(enabled); 377 this.multiCheckBox.setEnabled(enabled); 378 this.helpButton.setEnabled(enabled); 379 this.addLevelButton.setEnabled(enabled); 380 this.preset1.setEnabled(enabled); 381 this.preset2.setEnabled(enabled); 382 this.preset3.setEnabled(enabled); 383 this.preset4.setEnabled(enabled); 384 385 if (enabled == false) { 386 resetUiElements(); 387 } 388 } 389 390 /** 391 * Enables or disables the interactive text box elements {@link #name} and {@link #ref}. 392 * 393 * @param enabled set this true for enabled elements 394 */ 395 public void setNRUiElementsEnabled(boolean enabled) { 396 this.nameField.setEnabled(enabled); 397 this.refField.setEnabled(enabled); 398 399 } 400 401 /** 402 * Enables or disables the interactive text box element {@link #repeatOn}. 403 * @param enabled set this true for enabled elements 404 */ 405 public void setROUiElementsEnabled(boolean enabled){ 406 this.repeatOnField.setEnabled(enabled); 407 408 } 409 410 /** 411 * Enables or disables the interactive text box element {@link #levelName}. 412 * @param enabled set this true for enabled elements 413 */ 414 public void setLVLUiElementsEnabled(boolean enabled) { 415 this.levelNameField.setEnabled(enabled); 416 this.addLevelButton.setEnabled(enabled); 417 418 } 419 420 /** 421 * Enables or disables the interactive ComboBoxes {@link #multiRoleBox} and {@link #multiEditBox }. 422 * @param enabled set this true for enabled elements 423 */ 424 public void setMultiUiElementsEnabled(boolean enabled) { 425 this.multiOuterButton.setEnabled(enabled); 426 this.multiInnerButton.setEnabled(enabled); 427 428 if (enabled == false) resetUiElements(); 429 } 430 431 /** 432 * Resets the view by making the UI elements disabled and deleting the level list. 433 */ 434 public void reset() { 435 this.setAllUiElementsEnabled(false); 436 } 437 438 439 /************************************************* 440 * GETTER and SETTER FOR THE INTERACTIVE UI BOXES 441 * 442 */ 443 /** 444 * Getter for the selected {@link IndoorObject} in the objectBox. 445 * 446 * @return the selected indoor object in the object ComboBox. 447 */ 448 public IndoorObject getSelectedObject() { 449 return (IndoorObject) this.objectBox.getSelectedItem(); 450 } 451 452 /** 453 * Getter for the level name field. 454 * 455 * @return the {@link String} of the {@link #levelNameField} 456 */ 457 public String getLevelNameText() { 458 return this.levelNameField.getText(); 459 } 460 461 /** 462 * Setter for the level name field. 463 * 464 * @param name the String for the {@link #levelNameField} 465 */ 466 public void setLevelNameText(String name) { 467 this.levelNameField.setText(name); 468 } 469 470 /** 471 * Getter for the name tag {@link TextField}. 472 * 473 * @return {@link String} of the name text field 474 */ 475 public String getNameText() { 476 return this.nameField.getText(); 477 } 478 479 /** 480 * Setter for the current level value tag 481 * 482 * @param current level value as String 483 * @author rebsc 484 */ 485 public void setLevelLabel(String levelTag) { 486 if (getLevelCheckBoxStatus() == false) { 487 if(!levelTag.equals("")) { 488 this.levelLabel.setText((tr("Working level: {0}",levelTag))); 489 } 490 else { 491 this.levelLabel.setText((tr("Working level: NONE"))); 492 } 493 } 494 else { 495 this.levelLabel.setText((tr("Working level: NONE"))); 496 } 497 } 498 499 /** 500 * Getter for the CheckBox Status 501 * 502 * @return boolean which tells if box is selected or not. 503 */ 504 public boolean getLevelCheckBoxStatus() { 505 return this.levelCheckBox.isSelected(); 506 } 507 508 /** 509 * Getter for the ref {@link TextField}. 510 * 511 * @return {@link String} of the ref text field 512 */ 513 public String getRefText() { 514 return this.refField.getText(); 515 } 516 517 /** 518 * Getter for the repeat on {@link TextField}. 519 * @return {@link String} of the repeat on text field 520 */ 521 public String getRepeatOnText() { 522 return this.repeatOnField.getText(); 523 } 524 525 526 /************************************************* 527 * RESETER FOR THE INTERACTIVE UI BOXES 528 * 529 */ 530 531 /** 532 * Clears the text boxes and sets an empty {@link String}. 533 */ 534 public void resetUiElements() { 535 this.nameField.setText(tr("")); 536 this.levelNameField.setText(tr("")); 537 this.refField.setText(tr("")); 538 this.repeatOnField.setText(tr("")); 539 this.levelNameField.setText(tr("")); 540 } 541 542 543 /************************************************* 544 * SETTERS FOR THE BUTTON LISTENER 545 * 546 */ 547 548 /** 549 * Set the listener for the apply button. 550 * 551 * @param l the listener to set 552 */ 553 public void setApplyButtonListener(ActionListener l) { 554 this.applyButton.addActionListener(l); 555 } 556 557 /** 558 * Set the listener for CheckBox. 559 * @param l the listener to set 560 */ 561 public void setLevelCheckBoxListener(ItemListener l) { 562 this.levelCheckBox.addItemListener(l); 563 } 564 565 /** 566 * Set the listener for helpButton. 567 * @param l the listener to set 568 */ 569 public void setHelpButtonListener(ActionListener l) { 570 this.helpButton.addActionListener(l); 571 } 572 573 /** 574 * Set the listener for addLevelButton. 575 * @param l the listener to set 576 */ 577 public void setAddLevelButtonListener(ActionListener l) { 578 this.addLevelButton.addActionListener(l); 579 } 580 581 582 /** 583 * Set the listener for object box. 584 * 585 * @param l the listener to set 586 */ 587 public void setObjectItemListener(ItemListener l) { 588 this.objectBox.addItemListener(l); 589 } 590 591 /** 592 * Set the listener for the OUTTER button. 593 * 594 * @param l the listener to set 595 */ 596 public void setOuterButtonListener(ActionListener l) { 597 this.multiOuterButton.addActionListener(l); 598 } 599 600 /** 601 * Set the listener for the INNER button. 602 * 603 * @param l the listener to set 604 */ 605 public void setInnerButtonListener(ActionListener l) { 606 this.multiInnerButton.addActionListener(l); 607 } 608 609 /** 610 * Set the listener for the multi checkbox. 611 * 612 * @param l the listener to set 613 */ 614 public void setMultiCheckBoxListener(ItemListener l) { 615 this.multiCheckBox.addItemListener(l); 616 } 617 618 /************************************************* 619 * PRESET BUTTON FUNCTION 620 * 621 */ 622 public void setPresetButtons(List<IndoorObject> objects) { 623 this.preset1.setIndoorObject(objects.get(0)); 624 this.preset2.setIndoorObject(objects.get(1)); 625 this.preset3.setIndoorObject(objects.get(2)); 626 this.preset4.setIndoorObject(objects.get(3)); 627 } 628 629 public void setPreset1Listener(ActionListener l) { 630 this.preset1.addActionListener(l); 631 } 632 633 public void setPreset2Listener(ActionListener l) { 634 this.preset2.addActionListener(l); 635 } 636 637 public void setPreset3Listener(ActionListener l) { 638 this.preset3.addActionListener(l); 639 } 640 641 public void setPreset4Listener(ActionListener l) { 642 this.preset4.addActionListener(l); 643 } 644 645 public IndoorObject getPreset1() { 646 return preset1.getIndoorObject(); 647 } 648 649 public IndoorObject getPreset2() { 650 return preset2.getIndoorObject(); 651 } 652 653 public IndoorObject getPreset3() { 654 return preset3.getIndoorObject(); 655 } 656 657 public IndoorObject getPreset4() { 658 return preset4.getIndoorObject(); 659 } 660 661 662 /** 663 * 664 * 665 * 666 * 667 * 668 * 669 * 670 * 671 * 672 */ 524 673 }
Note:
See TracChangeset
for help on using the changeset viewer.