Changeset 34005 in osm for applications/editors/josm/plugins/indoorhelper/src
- Timestamp:
- 2018-01-13T18:19:22+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/indoorhelper/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/src/controller/IndoorHelperController.java
r33997 r34005 83 83 private EnterAction EnterAction; 84 84 private transient Shortcut EnterShortcut; 85 private boolean OuterHelp,InnerHelp,LevelHelp; 85 private boolean OuterHelp, InnerHelp, LevelHelp; 86 86 private Collection<OsmPrimitive> innerRelation; 87 87 private LevelSelectorView selectorView; … … 93 93 public IndoorHelperController() { 94 94 95 95 this.model = new IndoorHelperModel(); 96 96 this.toolboxView = new ToolBoxView(); 97 97 … … 115 115 "", KeyEvent.VK_SPACE, Shortcut.DIRECT); 116 116 this.SpaceAction = new SpaceAction(); 117 MainApplication.registerActionShortcut(SpaceAction,SpaceShortcut); 117 MainApplication.registerActionShortcut(SpaceAction, SpaceShortcut); 118 118 119 119 EnterShortcut = Shortcut.registerShortcut("mapmode:ALT", 120 120 "", KeyEvent.VK_ENTER, Shortcut.DIRECT); 121 121 this.EnterAction = new EnterAction(); 122 MainApplication.registerActionShortcut(EnterAction,EnterShortcut); 122 MainApplication.registerActionShortcut(EnterAction, EnterShortcut); 123 123 124 124 // Helper … … 126 126 InnerHelp = false; 127 127 LevelHelp = false; 128 129 130 128 innerRelation = null; 129 levelValue = new String(); 130 levelNum = new String(); 131 131 132 132 } … … 166 166 } 167 167 168 /*************************************************169 * TOOLBOX LISTENER170 *171 */172 173 168 /** 174 169 * The listener which provides the handling of the apply button. … … 186 181 IndoorObject indoorObject = toolboxView.getSelectedObject(); 187 182 188 183 // collecting all tags 189 184 List<Tag> tags = new ArrayList<>(); 190 185 if (toolboxView.getLevelCheckBoxStatus() == false && !levelValue.equals("")) { 191 186 tags.add(new Tag("level", levelValue)); 192 187 } 193 194 195 188 if (!toolboxView.getLevelNameText().isEmpty() && !toolboxView.getLevelCheckBoxStatus()) { 189 tags.add(new Tag("level_name", toolboxView.getLevelNameText())); 190 } 196 191 if (!toolboxView.getNameText().isEmpty()) { 197 192 tags.add(new Tag("name", toolboxView.getNameText())); … … 200 195 tags.add(new Tag("ref", toolboxView.getRefText())); 201 196 } 202 if (!toolboxView.getRepeatOnText().isEmpty()){ 203 204 205 206 207 197 if (!toolboxView.getRepeatOnText().isEmpty()) { 198 tags.add(new Tag("repeat_on", toolboxView.getRepeatOnText())); 199 } 200 if (!toolboxView.getLevelNameText().isEmpty() && !toolboxView.getLevelCheckBoxStatus()) { 201 tags.add(new Tag("level_name", toolboxView.getLevelNameText())); 202 } 208 203 209 204 // Tagging to OSM Data … … 236 231 toolboxView.setNRUiElementsEnabled(true); 237 232 toolboxView.setROUiElementsEnabled(false); 238 } 239 else if (toolboxView.getSelectedObject().equals(IndoorObject.STEPS) || 240 toolboxView.getSelectedObject().equals(IndoorObject.ELEVATOR)) { 241 toolboxView.setROUiElementsEnabled(true); 242 toolboxView.setNRUiElementsEnabled(true); 243 } 244 else { 233 } else if (toolboxView.getSelectedObject().equals(IndoorObject.STEPS) || 234 toolboxView.getSelectedObject().equals(IndoorObject.ELEVATOR)) { 235 toolboxView.setROUiElementsEnabled(true); 236 toolboxView.setNRUiElementsEnabled(true); 237 } else { 245 238 toolboxView.setROUiElementsEnabled(false); 246 239 } … … 253 246 * @author rebsc 254 247 */ 255 class ToolLevelCheckBoxListener implements ItemListener{ 248 class ToolLevelCheckBoxListener implements ItemListener { 256 249 @Override 257 250 public void itemStateChanged(ItemEvent e) { 258 if(e.getStateChange() == ItemEvent.SELECTED) { 259 toolboxView.setLVLUiElementsEnabled(false); 260 } 261 else { 262 toolboxView.setLVLUiElementsEnabled(true); 263 } 251 if (e.getStateChange() == ItemEvent.SELECTED) { 252 toolboxView.setLVLUiElementsEnabled(false); 253 } else { 254 toolboxView.setLVLUiElementsEnabled(true); 255 } 264 256 } 265 257 } … … 270 262 * @author rebsc 271 263 */ 272 static class ToolHelpButtonListener implements ActionListener{ 273 274 275 276 277 278 279 264 static class ToolHelpButtonListener implements ActionListener { 265 266 @Override 267 public void actionPerformed(ActionEvent e) { 268 String topic = "indoorHelper"; 269 //Open HelpBrowser for short description about the plugin 270 HelpBrowser.setUrlForHelpTopic(Optional.ofNullable(topic).orElse("/")); 271 } 280 272 } 281 273 … … 285 277 * @author rebsc 286 278 */ 287 class ToolAddLevelButtonListener implements ActionListener{ 288 289 290 291 292 if(selectorView == null) {293 294 295 296 297 298 299 300 301 302 303 279 class ToolAddLevelButtonListener implements ActionListener { 280 281 @Override 282 public void actionPerformed(ActionEvent e) { 283 284 if (selectorView == null) { 285 selectorView = new LevelSelectorView(); 286 addLevelSelectorListeners(); 287 288 //Show LevelSelectorView 289 selectorView.setVisible(true); 290 } else { 291 //Put focus back on LevelSelectorView 292 selectorView.toFront(); 293 } 294 295 } 304 296 } 305 297 … … 309 301 * @author rebsc 310 302 */ 311 class ToolMultiCheckBoxListener implements ItemListener{ 303 class ToolMultiCheckBoxListener implements ItemListener { 312 304 @Override 313 305 public void itemStateChanged(ItemEvent e) { 314 if(e.getStateChange() == ItemEvent.SELECTED) { 315 toolboxView.setMultiUiElementsEnabled(false); 316 } 317 else { 318 toolboxView.setMultiUiElementsEnabled(true); 319 } 306 if (e.getStateChange() == ItemEvent.SELECTED) { 307 toolboxView.setMultiUiElementsEnabled(false); 308 } else { 309 toolboxView.setMultiUiElementsEnabled(true); 310 } 320 311 } 321 312 } … … 326 317 * @author rebsc 327 318 */ 328 class ToolOuterButtonListener implements ActionListener{ 329 330 331 332 333 334 335 336 337 338 319 class ToolOuterButtonListener implements ActionListener { 320 321 @Override 322 public void actionPerformed(ActionEvent e) { 323 // Select drawing action 324 map.selectMapMode(drawAction); 325 326 // For space shortcut to add the relation after spacebar got pushed {@link SpaceAction} 327 OuterHelp = true; 328 InnerHelp = false; 329 } 339 330 } 340 331 … … 345 336 */ 346 337 class ToolInnerButtonListener implements ActionListener { 347 348 349 350 351 352 353 354 355 356 338 @Override 339 public void actionPerformed(ActionEvent e) { 340 // Select drawing action 341 map.selectMapMode(drawAction); 342 343 // For space shortcut to edit the relation after enter got pushed {@link SpaceAction}{@link EnterAction} 344 InnerHelp = true; 345 OuterHelp = false; 346 347 } 357 348 } 358 349 … … 416 407 } 417 408 418 /*************************************************419 * LEVEL SELCTOR VIEW LISTENER420 *421 */422 409 /** 423 410 * Specific listener for the applyButton … … 429 416 @Override 430 417 public void actionPerformed(ActionEvent e) { 431 432 433 //Get insert level number out of SelectorView434 if(!selectorView.getLevelNumber().equals("")) {435 436 437 438 439 440 441 442 }else {443 444 445 446 418 LevelHelp = true; 419 420 // Get insert level number out of SelectorView 421 if (!selectorView.getLevelNumber().equals("")) { 422 levelNum = selectorView.getLevelNumber(); 423 424 //Unset visibility 425 selectorView.dispose(); 426 //Select draw-action 427 map.selectMapMode(drawAction); 428 429 } else { 430 JOptionPane.showMessageDialog(null, tr("Please insert a value."), tr("Error"), JOptionPane.ERROR_MESSAGE); 431 } 432 433 selectorView = null; 447 434 } 448 435 } … … 467 454 * 468 455 */ 469 class ToolSelectorWindowSListener implements WindowListener{ 470 471 @Override 472 public void windowClosed(WindowEvent e) { 473 selectorView = null; 474 } 475 476 @Override 477 public void windowClosing(WindowEvent e) { 478 selectorView = null; 479 } 480 481 @Override 482 public void windowActivated(WindowEvent arg0) { 483 // TODO Auto-generated method stub 484 485 } 486 487 @Override 488 public void windowDeactivated(WindowEvent arg0) { 489 // TODO Auto-generated method stub 490 491 } 492 493 @Override 494 public void windowDeiconified(WindowEvent arg0) { 495 // TODO Auto-generated method stub 496 497 } 498 499 @Override 500 public void windowIconified(WindowEvent arg0) { 501 // TODO Auto-generated method stub 502 503 } 504 505 @Override 506 public void windowOpened(WindowEvent arg0) { 507 // TODO Auto-generated method stub 508 509 } 510 } 511 512 513 /************************************************* 514 * SHORTCUT METHODS 515 * 516 */ 456 class ToolSelectorWindowSListener implements WindowListener { 457 458 @Override 459 public void windowClosed(WindowEvent e) { 460 selectorView = null; 461 } 462 463 @Override 464 public void windowClosing(WindowEvent e) { 465 selectorView = null; 466 } 467 468 @Override 469 public void windowActivated(WindowEvent arg0) { 470 // TODO Auto-generated method stub 471 472 } 473 474 @Override 475 public void windowDeactivated(WindowEvent arg0) { 476 // TODO Auto-generated method stub 477 478 } 479 480 @Override 481 public void windowDeiconified(WindowEvent arg0) { 482 // TODO Auto-generated method stub 483 484 } 485 486 @Override 487 public void windowIconified(WindowEvent arg0) { 488 // TODO Auto-generated method stub 489 490 } 491 492 @Override 493 public void windowOpened(WindowEvent arg0) { 494 // TODO Auto-generated method stub 495 496 } 497 } 498 517 499 /** 518 500 * Shortcut for Spacebar … … 521 503 private class SpaceAction extends AbstractAction { 522 504 523 private static final long serialVersionUID = 1L; 524 525 @Override 526 public void actionPerformed(ActionEvent e) { 527 if(OuterHelp) { 528 529 //Create new relation and add the currently drawn object to it 530 model.addRelation("outer"); 531 map.selectMapMode(selectAction); 532 OuterHelp = false; 533 534 //Clear currently selection 535 MainApplication.getLayerManager().getEditDataSet().clearSelection(); 536 } 537 else if(InnerHelp) { 538 539 //Save new drawn relation for adding 540 innerRelation = MainApplication.getLayerManager().getEditDataSet().getAllSelected(); 541 map.selectMapMode(selectAction); 542 543 //Clear currently selection 544 MainApplication.getLayerManager().getEditDataSet().clearSelection(); 545 } 546 else if(LevelHelp) { 505 private static final long serialVersionUID = 1L; 506 507 @Override 508 public void actionPerformed(ActionEvent e) { 509 if (OuterHelp) { 510 511 //Create new relation and add the currently drawn object to it 512 model.addRelation("outer"); 513 map.selectMapMode(selectAction); 514 OuterHelp = false; 515 516 //Clear currently selection 517 MainApplication.getLayerManager().getEditDataSet().clearSelection(); 518 } else if (InnerHelp) { 519 520 //Save new drawn relation for adding 521 innerRelation = MainApplication.getLayerManager().getEditDataSet().getAllSelected(); 522 map.selectMapMode(selectAction); 523 524 //Clear currently selection 525 MainApplication.getLayerManager().getEditDataSet().clearSelection(); 526 } else if (LevelHelp) { 547 527 548 528 List<Tag> tags = new ArrayList<>(); 549 550 551 552 553 554 555 556 529 tags.add(new Tag("level", levelNum)); 530 531 //Add level tag 532 model.addTagsToOSM(tags); 533 534 //Change action 535 map.selectMapMode(selectAction); 536 LevelHelp = false; 557 537 } 558 538 } … … 565 545 private class EnterAction extends AbstractAction { 566 546 567 private static final long serialVersionUID = 1L; 568 569 @Override 570 public void actionPerformed(ActionEvent e) { 571 572 if(InnerHelp && !OuterHelp) { 573 574 // Edit the new drawn relation member to selected relation 575 model.editRelation("inner", innerRelation); 576 InnerHelp = false; 577 578 }else if((InnerHelp && OuterHelp) || (OuterHelp && !InnerHelp)){ 579 JOptionPane.showMessageDialog(null, tr("Please press spacebar first to add \"outer\" object to relation."), tr("Relation-Error"), JOptionPane.ERROR_MESSAGE); 580 resetHelper(); 581 } 582 } 583 } 584 585 /************************************************* 586 * FILTER METHODS 587 * 588 */ 547 private static final long serialVersionUID = 1L; 548 549 @Override 550 public void actionPerformed(ActionEvent e) { 551 if (InnerHelp && !OuterHelp) { 552 // Edit the new drawn relation member to selected relation 553 model.editRelation("inner", innerRelation); 554 InnerHelp = false; 555 } else if ((InnerHelp && OuterHelp) || (OuterHelp && !InnerHelp)) { 556 JOptionPane.showMessageDialog(null, 557 tr("Please press spacebar first to add \"outer\" object to relation."), tr("Relation-Error"), JOptionPane.ERROR_MESSAGE); 558 resetHelper(); 559 } 560 } 561 } 562 589 563 /** 590 564 * Function which unset the disabled state of currently hidden and/or disabled objects which have a … … 592 566 * current working level. 593 567 * Specific example: key: repeat_on ; value: 1-4; 594 * If current selected workinglevel is "3" all objects with the leveltag "level=3" are hidden but the 595 * objects with the key "repeat_on" and the value which includes "3" or is (minValue+1) - maxValue (4-...), 596 * because repeat_on tag starts on the current workinglevel+1. 568 * If current selected workinglevel is "3" all objects with the leveltag "level=3" are hidden but the 569 * objects with the key "repeat_on" and the value which includes "3" or is (minValue+1) - maxValue (4-...), 570 * because repeat_on tag starts on the current workinglevel+1. 571 * @author rebsc 597 572 * @param key sepcific key to unset hidden objects which contains it 598 * @author rebsc599 573 */ 600 574 public void unsetSpecificKeyFilter(String key) { 601 575 602 Collection<OsmPrimitive> p = Main.main.getEditDataSet().allPrimitives(); 603 Map<String, String> tags = new HashMap<>(); 604 Integer level = Integer.parseInt(levelValue); 605 Integer firstVal, secVal; 606 607 //Find all primitives with the specific tag and check if value is part of the current 608 //workinglevel. After that unset the disabled status. 609 for(OsmPrimitive osm: p) { 610 if((osm.isDisabledAndHidden() || osm.isDisabled()) && osm.hasKey(key)) { 611 612 tags = osm.getInterestingTags(); 613 614 for(Map.Entry<String, String> e: tags.entrySet()) { 615 if(e.getKey().equals(key)) { 616 String val = e.getValue(); 617 618 //Extract values 619 if(val.indexOf("-") == 0) { 620 firstVal = (Integer.parseInt(val.split("-",2)[1].split("-",2)[0]))*-1; 621 secVal = Integer.parseInt(val.split("-",2)[1].split("-",2)[1]); 622 }else { 623 firstVal = Integer.parseInt(val.split("-")[0]); 624 secVal = Integer.parseInt(val.split("-")[1]); 625 } 626 627 //Compare values to current working level 628 if(level >= ((firstVal)-1) && level <= secVal) { 629 osm.unsetDisabledState(); 630 }else { 631 osm.setDisabledState(true); 632 } 633 } 634 635 } 636 637 } 638 } 639 640 } 641 642 /** 643 * Function which updates the current working level tag 644 * 645 * @param indoorLevel: current working level 646 */ 647 public void setIndoorLevel(String indoorLevel) { 648 this.toolboxView.setLevelLabel(indoorLevel); 649 } 650 651 /** 652 * Function which gets the current working level tag 653 * 654 * @param indoorLevel: current working level 655 */ 576 Collection<OsmPrimitive> p = Main.main.getEditDataSet().allPrimitives(); 577 Map<String, String> tags = new HashMap<>(); 578 Integer level = Integer.parseInt(levelValue); 579 Integer firstVal, secVal; 580 581 //Find all primitives with the specific tag and check if value is part of the current 582 //workinglevel. After that unset the disabled status. 583 for (OsmPrimitive osm: p) { 584 if ((osm.isDisabledAndHidden() || osm.isDisabled()) && osm.hasKey(key)) { 585 586 tags = osm.getInterestingTags(); 587 588 for (Map.Entry<String, String> e: tags.entrySet()) { 589 if (e.getKey().equals(key)) { 590 String val = e.getValue(); 591 592 //Extract values 593 if (val.indexOf("-") == 0) { 594 firstVal = (Integer.parseInt(val.split("-", 2)[1].split("-", 2)[0]))*-1; 595 secVal = Integer.parseInt(val.split("-", 2)[1].split("-", 2)[1]); 596 } else { 597 firstVal = Integer.parseInt(val.split("-")[0]); 598 secVal = Integer.parseInt(val.split("-")[1]); 599 } 600 601 //Compare values to current working level 602 if (level >= ((firstVal)-1) && level <= secVal) { 603 osm.unsetDisabledState(); 604 } else { 605 osm.setDisabledState(true); 606 } 607 } 608 } 609 } 610 } 611 } 612 613 /** 614 * Function which updates the current working level tag 615 * 616 * @param indoorLevel current working level 617 */ 618 public void setIndoorLevel(String indoorLevel) { 619 this.toolboxView.setLevelLabel(indoorLevel); 620 } 621 622 /** 623 * Function which gets the current working level tag 624 * 625 * @param indoorLevel current working level 626 */ 656 627 public void getIndoorLevel(String indoorLevel) { 657 levelValue = indoorLevel; 658 659 } 660 661 662 /************************************************* 663 * HELPER METHODS 664 * 665 */ 666 667 /** 668 * Function which resets the helper for relation adding 669 */ 670 private void resetHelper() { 671 InnerHelp = false; 672 OuterHelp = false; 673 } 628 levelValue = indoorLevel; 629 } 630 631 /** 632 * Function which resets the helper for relation adding 633 */ 634 private void resetHelper() { 635 InnerHelp = false; 636 OuterHelp = false; 637 } 674 638 675 639 /** … … 686 650 } 687 651 688 /** 689 * Enables or disables the preferences for the mapcss-style and the validator. 690 * 691 * @param enabled Activates or disables the settings. 692 */ 693 @SuppressWarnings("deprecation") 694 private void setPluginPreferences(boolean enabled) { 652 /** 653 * Enables or disables the preferences for the mapcss-style and the validator. 654 * 655 * @param enabled Activates or disables the settings. 656 */ 657 private void setPluginPreferences(boolean enabled) { 695 658 Map<String, Setting<?>> settings = Main.pref.getAllSettings(); 696 659 … … 727 690 indoorValidator.put("title", "Indoor"); 728 691 indoorValidator.put("active", "true"); 729 indoorValidator.put("url", Main.pref.getUserDataDirectory()+ sep +"validator" + 692 indoorValidator.put("url", Main.pref.getDirs().getUserDataDirectory(true)+ sep +"validator" + 730 693 sep + "indoorhelper.validator.mapcss"); 731 694 … … 750 713 indoorMapPaint.put("title", tr("Indoor")); 751 714 indoorMapPaint.put("active", "true"); 752 indoorMapPaint.put("url", Main.pref.getUserDataDirectory() + sep + "styles" 715 indoorMapPaint.put("url", Main.pref.getDirs().getUserDataDirectory(true) + sep + "styles" 753 716 + sep + "sit.mapcss"); 754 717 styleMapsNew.add(indoorMapPaint); … … 774 737 indoorValidator.put("title", tr("Indoor")); 775 738 indoorValidator.put("active", "false"); 776 indoorValidator.put("url", Main.pref.getUserDataDirectory()+ sep +"validator" + 739 indoorValidator.put("url", Main.pref.getDirs().getUserDataDirectory(true)+ sep +"validator" + 777 740 sep + "indoorhelper.validator.mapcss"); 778 741 … … 798 761 indoorMapPaint.put("title", tr("Indoor")); 799 762 indoorMapPaint.put("active", "false"); 800 indoorMapPaint.put("url", Main.pref.getUserDataDirectory() + sep + "styles" 763 indoorMapPaint.put("url", Main.pref.getDirs().getUserDataDirectory(true) + sep + "styles" 801 764 + sep + "sit.mapcss"); 802 765 styleMapsNew.add(indoorMapPaint); … … 806 769 } 807 770 } 808 809 810 811 812 813 /**814 *815 *816 *817 *818 *819 *820 *821 *822 *823 */824 771 } -
applications/editors/josm/plugins/indoorhelper/src/model/IndoorHelperModel.java
r33997 r34005 46 46 * @author rebsc 47 47 */ 48 public class IndoorHelperModel{ 48 public class IndoorHelperModel { 49 49 50 50 private TagCatalog tags; … … 74 74 * directly to the relation otherwise add it to nodes and/or ways. 75 75 * 76 * @author rebsc 76 77 * @param object the object which defines the tag-set you want to add 77 78 * @param userTags the tags which are given by the user input 78 * @author rebsc 79 */ 80 public void addTagsToOSM(IndoorObject object, List<Tag> userTags) { 79 */ 80 public void addTagsToOSM(IndoorObject object, List<Tag> userTags) { 81 81 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { 82 82 83 83 DataSet ds = Main.main.getEditDataSet(); 84 84 List<Tag> tags = this.getObjectTags(object); 85 85 Collection<Relation> relations = ds.getRelations(); … … 92 92 93 93 // Put value on {@link relationToAdd} if selected object is a relation. 94 relationToAdd = getRelationFromDataSet(ds,relations); 95 96 if(relationToAdd != null) { 97 98 99 100 101 } else{102 103 104 105 94 relationToAdd = getRelationFromDataSet(ds, relations); 95 96 if (relationToAdd != null) { 97 //Add tags to relation 98 for (Tag t : tags) { 99 Main.main.undoRedo.add(new ChangePropertyCommand(relationToAdd, t.getKey(), t.getValue())); 100 } 101 } else { 102 //Add tags to ways or nodes 103 for (Tag t : tags) { 104 Main.main.undoRedo.add(new ChangePropertyCommand(Main.main.getInProgressSelection(), t.getKey(), t.getValue())); 105 } 106 106 } 107 107 //If the selected dataset is empty 108 108 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 109 109 110 110 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 111 111 } 112 112 } … … 117 117 * @param object the object which defines the tag-set you want to add 118 118 */ 119 119 public void addTagsToOSM(IndoorObject object) { 120 120 121 121 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { … … 138 138 * Method which adds a list of tag-sets to the currently selected OSM data. Tags directly to ways and/or nodes. 139 139 * 140 * @author rebsc 140 141 * @param userTags the tags which are given by the user input 141 * @author rebsc 142 */ 143 public void addTagsToOSM(List<Tag> userTags) { 142 */ 143 public void addTagsToOSM(List<Tag> userTags) { 144 144 145 145 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { … … 149 149 Main.main.undoRedo.add(new ChangePropertyCommand(Main.main.getInProgressSelection(), t.getKey(), t.getValue())); 150 150 } 151 } 152 else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 151 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 153 152 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 154 153 } … … 158 157 * Method which adds the relation to OSM data. Also adds the selected tag-set to relation object. 159 158 * 159 * @author rebsc 160 160 * @param String the Multipolygon Role as String 161 * @author rebsc 162 */ 163 public void addRelation(String role){ 164 Relation newRelation = new Relation(); 165 RelationMember newMember; 166 DataSet ds = Main.main.getEditDataSet(); 161 */ 162 public void addRelation(String role) { 163 Relation newRelation = new Relation(); 164 RelationMember newMember; 165 DataSet ds = Main.main.getEditDataSet(); 167 166 168 167 // Create new relation and add a new member with specific role 169 if(!MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) {170 168 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 169 for (OsmPrimitive osm : ds.getSelected()) { 171 170 newMember = new RelationMember(role == null ? "" : role, osm); 172 171 newRelation.addMember(newMember); 173 172 } 174 175 173 } 174 // Add relation to OSM data 176 175 MainApplication.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newRelation)); 177 176 } … … 180 179 * Method which edits the selected object to the currently selected OSM data (relations). 181 180 * 181 * @author rebsc 182 182 * @param role The Multipolygon Role as String 183 * @param relation 184 * @author rebsc 185 */ 186 public void editRelation(String role, Collection<OsmPrimitive> innerRelation){ 187 188 RelationMember newMember; 189 DataSet ds = Main.main.getEditDataSet(); 190 Collection<Relation> relations = ds.getRelations(); 191 Relation relation = getRelationFromDataSet(ds,relations); 183 */ 184 public void editRelation(String role, Collection<OsmPrimitive> innerRelation) { 185 186 RelationMember newMember; 187 DataSet ds = Main.main.getEditDataSet(); 188 Collection<Relation> relations = ds.getRelations(); 189 Relation relation = getRelationFromDataSet(ds, relations); 192 190 193 191 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty() && 194 195 196 192 !innerRelation.isEmpty() && getRole(ds, relations).equals("outer")) { 193 194 //Add new relation member to selected relation 197 195 for (OsmPrimitive osm : innerRelation) { 198 196 newMember = new RelationMember(role == null ? "" : role, osm); … … 201 199 202 200 //Check if dataset is not empty or if {@link innerRelation} has no value 203 }else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty() || innerRelation.isEmpty()) { 201 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty() || innerRelation.isEmpty()) { 204 202 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 205 203 206 204 //If selected object is not a relation member or not a relation member with role "outer" 207 } else if(!getRole(ds,relations).equals("outer")) {208 tr("No relation or no relation member with role \"outer\" selected."), tr("Error"), JOptionPane.ERROR_MESSAGE);209 }210 211 } 212 213 /** 205 } else if (!getRole(ds, relations).equals("outer")) { 206 JOptionPane.showMessageDialog(null, 207 tr("No relation or no relation member with role \"outer\" selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 208 } 209 } 210 211 /** 214 212 * Returns the current ranking of the preset counter, which includes the 4 most used items. 215 213 * … … 220 218 } 221 219 222 223 224 /*************************************************225 * HELPER METHODS226 *227 */228 229 220 /** 230 221 * Function which returns the the relation (if any) of the currently selected object. 231 222 * If not returns null. 223 * @author rebsc 232 224 * @param ds actual working dataset 233 225 * @param relations collection of relations in the dataset 234 226 * @return relation of currently selected dataset 235 * @author rebsc236 227 */ 237 228 private Relation getRelationFromDataSet(DataSet ds, Collection<Relation> relations) { 238 for(Relation r: relations) {239 for(RelationMember rm: r.getMembers()) {240 for(OsmPrimitive osm: ds.getSelected()) {241 if(rm.refersTo(osm)) {242 243 244 245 246 247 229 for (Relation r: relations) { 230 for (RelationMember rm: r.getMembers()) { 231 for (OsmPrimitive osm: ds.getSelected()) { 232 if (rm.refersTo(osm)) { 233 return r; 234 } 235 } 236 } 237 } 238 return null; 248 239 } 249 240 … … 251 242 * Function which returns the relation role (if any) of the currently selected object. 252 243 * If object is not a relation returns empty string. 244 * @author rebsc 253 245 * @param ds active dataset 254 246 * @param relations collection of relations in the dataset 255 247 * @return role of currently selected relation member if any 256 * @author rebsc257 248 */ 258 249 private String getRole(DataSet ds, Collection<Relation> relations) { 259 250 260 if(isRelationMember(ds,relations)) {261 for(Relation r: relations) {262 for(RelationMember rm: r.getMembers()) {263 for(OsmPrimitive osm: ds.getSelected()) {264 if(rm.refersTo(osm)) {265 266 267 268 269 270 271 251 if (isRelationMember(ds, relations)) { 252 for (Relation r: relations) { 253 for (RelationMember rm: r.getMembers()) { 254 for (OsmPrimitive osm: ds.getSelected()) { 255 if (rm.refersTo(osm)) { 256 return rm.getRole(); 257 } 258 } 259 } 260 } 261 } 262 return ""; 272 263 } 273 264 274 265 /** 275 266 * Function which returns true if the currently selected object is a relation 267 * @author rebsc 276 268 * @param ds active dataset 277 269 * @return true if selected object is a relation 278 * @author rebsc279 270 */ 280 271 private boolean isRelationMember(DataSet ds, Collection<Relation> relations) { 281 for(Relation r: relations) { 282 for(RelationMember rm: r.getMembers()) { 283 for(OsmPrimitive osm: ds.getSelected()) { 284 if(rm.refersTo(osm)) { 285 return true; 286 } 287 } 288 } 289 } 290 return false; 291 } 292 293 294 /** 295 * 296 * 297 * 298 * 299 * 300 * 301 * 302 * 303 * 304 */ 272 for (Relation r: relations) { 273 for (RelationMember rm: r.getMembers()) { 274 for (OsmPrimitive osm: ds.getSelected()) { 275 if (rm.refersTo(osm)) { 276 return true; 277 } 278 } 279 } 280 } 281 return false; 282 } 305 283 } -
applications/editors/josm/plugins/indoorhelper/src/model/PresetCounter.java
r33997 r34005 137 137 return 0; 138 138 } 139 140 139 } 141 142 143 144 /**145 *146 *147 *148 *149 *150 *151 *152 *153 *154 */155 140 } -
applications/editors/josm/plugins/indoorhelper/src/model/TagCatalog.java
r33997 r34005 19 19 20 20 package model; 21 22 /**23 * Class to provide the indoor tagging catalog.24 *25 * @author egru26 * @author rebsc27 *28 */29 import static org.openstreetmap.josm.tools.I18n.tr;30 21 31 22 import java.util.ArrayList; … … 53 44 case DOOR_PRIVATE: 54 45 tagList.add(new Tag("door", "yes")); 55 tagList.add(new Tag 46 tagList.add(new Tag("access", "private")); 56 47 return tagList; 57 48 case DOOR_PUBLIC: 58 49 tagList.add(new Tag("door", "yes")); 59 tagList.add(new Tag 50 tagList.add(new Tag("access", "public")); 60 51 return tagList; 61 52 case ELEVATOR: … … 69 60 return tagList; 70 61 case ACCESS_PRIVATE: 71 72 62 tagList.add(new Tag("access", "private")); 63 return tagList; 73 64 case ACCESS_PUBLIC: 74 75 65 tagList.add(new Tag("access", "public")); 66 return tagList; 76 67 case TOILET_FEMALE: 77 68 tagList.add(new Tag("indoor", "room")); … … 95 86 return tagList; 96 87 case CORRIDOR: 97 98 88 tagList.add(new Tag("indoor", "corridor")); 89 return tagList; 99 90 case BENCH: 100 101 91 tagList.add(new Tag("amenity", "bench")); 92 return tagList; 102 93 case ZONE: 103 104 94 tagList.add(new Tag("area", "zone")); 95 return tagList; 105 96 case NONE: 106 97 return tagList; 107 98 default: 108 99 tagList = null; … … 116 107 * @author egru 117 108 * @author rebsc 118 *119 109 */ 120 110 public enum IndoorObject { 121 111 CONCRETE_WALL, GLASS_WALL, ROOM, TOILET_MALE, TOILET_FEMALE, ELEVATOR, DOOR_PRIVATE, DOOR_PUBLIC, ENTRANCE, 122 ENTRANCE_EXIT_ONLY,ACCESS_PRIVATE,ACCESS_PUBLIC, STEPS,CORRIDOR,BENCH,ZONE,NONE;112 ENTRANCE_EXIT_ONLY, ACCESS_PRIVATE, ACCESS_PUBLIC, STEPS, CORRIDOR, BENCH, ZONE, NONE; 123 113 } 124 125 126 /**127 *128 *129 *130 *131 *132 *133 *134 *135 *136 */137 114 } -
applications/editors/josm/plugins/indoorhelper/src/org/openstreetmap/josm/plugins/indoorhelper/IndoorHelperPlugin.java
r33997 r34005 40 40 import controller.IndoorHelperController; 41 41 42 43 42 /** 44 43 * This is the main class for the indoorhelper plug-in. … … 50 49 public class IndoorHelperPlugin extends Plugin implements PaintableInvalidationListener, ActiveLayerChangeListener { 51 50 52 53 @SuppressWarnings("unused") 51 @SuppressWarnings("unused") 54 52 private IndoorHelperController controller; 55 53 String sep = System.getProperty("file.separator"); … … 91 89 * Exports the mapcss validator file to the preferences directory. 92 90 */ 93 @SuppressWarnings("deprecation") 94 private void exportValidator(String resourceName) throws Exception { 91 private void exportValidator(String resourceName) throws Exception { 95 92 InputStream stream = null; 96 93 OutputStream resStreamOut = null; … … 107 104 byte[] buffer = new byte[4096]; 108 105 109 String valDirPath = Main.pref.getUserDataDirectory() + sep + "validator"; 106 String valDirPath = Main.pref.getDirs().getUserDataDirectory(true) + sep + "validator"; 110 107 File valDir = new File(valDirPath); 111 108 valDir.mkdirs(); … … 129 126 */ 130 127 private void exportStyleFile(String resourceName) throws Exception { 131 InputStream stream = null; 132 OutputStream resStreamOut = null; 133 134 try { 135 stream = IndoorHelperPlugin.class.getResourceAsStream("/data/" + resourceName); 128 try (InputStream stream = IndoorHelperPlugin.class.getResourceAsStream("/data/" + resourceName)) { 136 129 if (stream == null) { 137 130 System.out.println("MapPaint: stream is null"); … … 143 136 byte[] buffer = new byte[4096]; 144 137 145 @SuppressWarnings("deprecation") 146 String valDirPath = Main.pref.getUserDataDirectory() + sep + "styles"; 138 String valDirPath = Main.pref.getDirs().getUserDataDirectory(true) + sep + "styles"; 147 139 File valDir = new File(valDirPath); 148 140 valDir.mkdirs(); 149 141 outPath = valDir.getAbsolutePath() +sep+ resourceName; 150 System.out.println("MapPaint"+outPath); 151 152 resStreamOut = new FileOutputStream(outPath); 153 while ((readBytes = stream.read(buffer)) > 0) { 154 resStreamOut.write(buffer, 0, readBytes); 155 } 156 resStreamOut.close(); 142 143 try (OutputStream resStreamOut = new FileOutputStream(outPath)) { 144 while ((readBytes = stream.read(buffer)) > 0) { 145 resStreamOut.write(buffer, 0, readBytes); 146 } 147 } 157 148 } catch (Exception ex) { 158 149 throw ex; 159 } finally { 160 stream.close(); 161 } 162 } 163 164 @Override 165 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 166 OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 150 } 151 } 152 153 @Override 154 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 155 OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 167 156 if (editLayer != null) { 168 157 editLayer.addInvalidationListener(this); 169 158 } 170 } 171 172 @Override 173 public void paintableInvalidated(PaintableInvalidationEvent event){ 174 AutoFilter currentAutoFilter = AutoFilterManager.getInstance().getCurrentAutoFilter(); 175 String currentFilterValue = new String(); 176 177 if(currentAutoFilter != null) { 178 currentFilterValue = currentAutoFilter.getFilter().text.split("=")[1]; 179 180 this.controller.setIndoorLevel(currentFilterValue); 181 this.controller.getIndoorLevel(currentFilterValue); 182 this.controller.unsetSpecificKeyFilter("repeat_on"); 183 184 }else{ 185 currentFilterValue = ""; 186 this.controller.setIndoorLevel(currentFilterValue); 187 this.controller.getIndoorLevel(currentFilterValue); 188 }; 189 190 } 159 } 160 161 @Override 162 public void paintableInvalidated(PaintableInvalidationEvent event) { 163 AutoFilter currentAutoFilter = AutoFilterManager.getInstance().getCurrentAutoFilter(); 164 String currentFilterValue = new String(); 165 166 if (currentAutoFilter != null) { 167 currentFilterValue = currentAutoFilter.getFilter().text.split("=")[1]; 168 169 this.controller.setIndoorLevel(currentFilterValue); 170 this.controller.getIndoorLevel(currentFilterValue); 171 this.controller.unsetSpecificKeyFilter("repeat_on"); 172 173 } else { 174 currentFilterValue = ""; 175 this.controller.setIndoorLevel(currentFilterValue); 176 this.controller.getIndoorLevel(currentFilterValue); 177 } 178 } 191 179 192 180 /** … … 232 220 // } 233 221 // } 234 235 /**236 *237 *238 *239 *240 *241 *242 *243 *244 *245 */246 222 } -
applications/editors/josm/plugins/indoorhelper/src/views/DialogPanel.java
r32637 r34005 68 68 powerButton = new JToggleButton(); 69 69 levelLabel = new JLabel(); 70 levelBox = new JosmComboBox< String>();70 levelBox = new JosmComboBox<>(); 71 71 levelTagLabel = new JLabel(); 72 72 levelTagField = new DisableShortcutsOnFocusGainedTextField(); … … 88 88 89 89 //======== dialogPane ======== 90 { 91 this.setBorder(new EmptyBorder(12, 12, 12, 12)); 92 this.setLayout(new BorderLayout()); 93 94 //======== contentPanel ======== 95 { 96 contentPanel.setLayout(new GridBagLayout()); 97 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] { 98 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}; 99 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0}; 100 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] { 101 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}; 102 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 103 104 //---- powerButton ---- 105 powerButton.setText(tr("POWER")); 106 powerButton.setToolTipText(tr("Activates the plug-in")); 107 contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0, 108 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 109 new Insets(0, 0, 5, 5), 0, 0)); 110 contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0, 111 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 112 new Insets(0, 0, 5, 5), 0, 0)); 113 114 //---- levelLabel ---- 115 levelLabel.setText(tr("Working Level")); 116 contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, 117 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 118 new Insets(0, 0, 5, 5), 0, 0)); 119 120 //---- levelBox ---- 121 levelBox.setEnabled(false); 122 levelBox.setEditable(false); 123 levelBox.setToolTipText(tr("Selects the working level.")); 124 contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0, 125 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 126 new Insets(0, 0, 5, 5), 0, 0)); 127 128 //---- levelTagLabel ---- 129 levelTagLabel.setText(tr("Level Name")); 130 contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, 131 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 132 new Insets(0, 0, 5, 5), 0, 0)); 133 134 //---- levelTagField ---- 135 levelTagField.setEnabled(false); 136 levelTagField.setColumns(6); 137 levelTagField.setToolTipText(tr("Optional name-tag for a level.")); 138 contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0, 139 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 140 new Insets(0, 0, 5, 5), 0, 0)); 141 contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0, 142 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 143 new Insets(0, 0, 5, 5), 0, 0)); 144 145 //---- objectLabel ---- 146 objectLabel.setText(tr("Object")); 147 contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, 148 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 149 new Insets(0, 0, 5, 5), 0, 0)); 150 151 //---- objectBox ---- 152 objectBox.setEnabled(false); 153 objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL); 154 objectBox.setToolTipText(tr("The object preset you want to tag.")); 155 contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0, 156 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 157 new Insets(0, 0, 5, 5), 0, 0)); 158 159 //---- nameLabel ---- 160 nameLabel.setText(tr("Name")); 161 contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, 162 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 163 new Insets(0, 0, 5, 5), 0, 0)); 164 165 //---- nameField ---- 166 nameField.setEnabled(false); 167 nameField.addFocusListener(new FocusListener() { 168 169 @Override 170 public void focusLost(FocusEvent e) {} 171 172 @Override 173 public void focusGained(FocusEvent e) { 174 nameField.selectAll(); 175 } 176 }); 177 nameField.setToolTipText(tr("Sets the name tag when the room-object is selected.")); 178 contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0, 179 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 180 new Insets(0, 0, 5, 5), 0, 0)); 181 182 //---- refLabel ---- 183 refLabel.setText(tr("Reference")); 184 contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0, 185 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 186 new Insets(0, 0, 0, 5), 0, 0)); 187 188 //---- refField ---- 189 refField.setEnabled(false); 190 refField.addFocusListener(new FocusListener() { 191 192 @Override 193 public void focusLost(FocusEvent e) {} 194 195 @Override 196 public void focusGained(FocusEvent e) { 197 refField.selectAll(); 198 } 199 }); 200 refField.setToolTipText(tr("Sets the ref tag when the room-object is selected.")); 201 contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0, 202 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 203 new Insets(0, 0, 0, 5), 0, 0)); 90 91 this.setBorder(new EmptyBorder(12, 12, 12, 12)); 92 this.setLayout(new BorderLayout()); 93 94 //======== contentPanel ======== 95 96 contentPanel.setLayout(new GridBagLayout()); 97 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] { 98 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}; 99 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0}; 100 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] { 101 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, 102 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}; 103 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 104 105 //---- powerButton ---- 106 powerButton.setText(tr("POWER")); 107 powerButton.setToolTipText(tr("Activates the plug-in")); 108 contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0, 109 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 110 new Insets(0, 0, 5, 5), 0, 0)); 111 contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0, 112 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 113 new Insets(0, 0, 5, 5), 0, 0)); 114 115 //---- levelLabel ---- 116 levelLabel.setText(tr("Working Level")); 117 contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0, 118 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 119 new Insets(0, 0, 5, 5), 0, 0)); 120 121 //---- levelBox ---- 122 levelBox.setEnabled(false); 123 levelBox.setEditable(false); 124 levelBox.setToolTipText(tr("Selects the working level.")); 125 contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0, 126 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 127 new Insets(0, 0, 5, 5), 0, 0)); 128 129 //---- levelTagLabel ---- 130 levelTagLabel.setText(tr("Level Name")); 131 contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, 132 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 133 new Insets(0, 0, 5, 5), 0, 0)); 134 135 //---- levelTagField ---- 136 levelTagField.setEnabled(false); 137 levelTagField.setColumns(6); 138 levelTagField.setToolTipText(tr("Optional name-tag for a level.")); 139 contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0, 140 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 141 new Insets(0, 0, 5, 5), 0, 0)); 142 contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0, 143 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 144 new Insets(0, 0, 5, 5), 0, 0)); 145 146 //---- objectLabel ---- 147 objectLabel.setText(tr("Object")); 148 contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, 149 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 150 new Insets(0, 0, 5, 5), 0, 0)); 151 152 //---- objectBox ---- 153 objectBox.setEnabled(false); 154 objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL); 155 objectBox.setToolTipText(tr("The object preset you want to tag.")); 156 contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0, 157 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 158 new Insets(0, 0, 5, 5), 0, 0)); 159 160 //---- nameLabel ---- 161 nameLabel.setText(tr("Name")); 162 contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, 163 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 164 new Insets(0, 0, 5, 5), 0, 0)); 165 166 //---- nameField ---- 167 nameField.setEnabled(false); 168 nameField.addFocusListener(new FocusListener() { 169 170 @Override 171 public void focusLost(FocusEvent e) {} 172 173 @Override 174 public void focusGained(FocusEvent e) { 175 nameField.selectAll(); 204 176 } 205 this.add(contentPanel, BorderLayout.CENTER); 206 207 //======== buttonBar ======== 208 { 209 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 210 buttonBar.setLayout(new GridBagLayout()); 211 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 212 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 213 214 //---- applyButton ---- 215 applyButton.setText(tr("Apply Tags")); 216 applyButton.setEnabled(false); 217 buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, 218 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 219 new Insets(0, 0, 0, 0), 0, 0)); 177 }); 178 nameField.setToolTipText(tr("Sets the name tag when the room-object is selected.")); 179 contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0, 180 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 181 new Insets(0, 0, 5, 5), 0, 0)); 182 183 //---- refLabel ---- 184 refLabel.setText(tr("Reference")); 185 contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0, 186 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 187 new Insets(0, 0, 0, 5), 0, 0)); 188 189 //---- refField ---- 190 refField.setEnabled(false); 191 refField.addFocusListener(new FocusListener() { 192 193 @Override 194 public void focusLost(FocusEvent e) {} 195 196 @Override 197 public void focusGained(FocusEvent e) { 198 refField.selectAll(); 220 199 } 221 this.add(buttonBar, BorderLayout.SOUTH); 222 } 200 }); 201 refField.setToolTipText(tr("Sets the ref tag when the room-object is selected.")); 202 contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0, 203 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 204 new Insets(0, 0, 0, 5), 0, 0)); 205 206 this.add(contentPanel, BorderLayout.CENTER); 207 208 //======== buttonBar ======== 209 210 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 211 buttonBar.setLayout(new GridBagLayout()); 212 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 213 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 214 215 //---- applyButton ---- 216 applyButton.setText(tr("Apply Tags")); 217 applyButton.setEnabled(false); 218 buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, 219 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 220 new Insets(0, 0, 0, 0), 0, 0)); 221 222 this.add(buttonBar, BorderLayout.SOUTH); 223 223 } 224 225 224 } -
applications/editors/josm/plugins/indoorhelper/src/views/FittingView.java
r32637 r34005 68 68 69 69 //======== dialogPane ======== 70 {71 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));72 dialogPane.setLayout(new BorderLayout());73 70 74 //======== contentPanel ======== 75 { 76 contentPanel.setLayout(new FlowLayout()); 71 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); 72 dialogPane.setLayout(new BorderLayout()); 77 73 78 //---- label1 ---- 79 label1.setText(tr("<html>Please mind to start fitting your building-plans now.<br>" + 80 "To do so, use the PicLayer plug-in, which you can install<br>" + 81 "using the JOSM plug-in management.</html>")); 82 contentPanel.add(label1); 83 } 84 dialogPane.add(contentPanel, BorderLayout.CENTER); 74 //======== contentPanel ======== 85 75 86 //======== buttonBar ======== 87 { 88 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 89 buttonBar.setLayout(new GridBagLayout()); 90 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 91 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 76 contentPanel.setLayout(new FlowLayout()); 92 77 93 //---- okButton ---- 94 okButton.setText(tr("OK")); 95 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 96 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 97 new Insets(0, 0, 0, 0), 0, 0)); 98 } 99 dialogPane.add(buttonBar, BorderLayout.SOUTH); 100 } 78 //---- label1 ---- 79 label1.setText(tr("<html>Please mind to start fitting your building-plans now.<br>" + 80 "To do so, use the PicLayer plug-in, which you can install<br>" + 81 "using the JOSM plug-in management.</html>")); 82 contentPanel.add(label1); 83 84 dialogPane.add(contentPanel, BorderLayout.CENTER); 85 86 //======== buttonBar ======== 87 88 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 89 buttonBar.setLayout(new GridBagLayout()); 90 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 91 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 92 93 //---- okButton ---- 94 okButton.setText(tr("OK")); 95 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 96 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 97 new Insets(0, 0, 0, 0), 0, 0)); 98 99 dialogPane.add(buttonBar, BorderLayout.SOUTH); 100 101 101 contentPane.add(dialogPane, BorderLayout.CENTER); 102 102 pack(); -
applications/editors/josm/plugins/indoorhelper/src/views/LevelSelectorView.java
r33997 r34005 46 46 public class LevelSelectorView extends JFrame { 47 47 48 49 48 private static final long serialVersionUID = 1L; 49 private JPanel dialogPane; 50 50 private JPanel contentPanel; 51 51 private JPanel infoBar; … … 78 78 79 79 //======== dialogPane ======== 80 {81 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));82 dialogPane.setLayout(new BorderLayout());83 80 81 dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); 82 dialogPane.setLayout(new BorderLayout()); 84 83 85 //======== infoBar ======== 86 { 84 //======== infoBar ======== 87 85 88 //---- Label1 ---- 89 label1.setText(tr("<html> Please insert the new level number you want to add.<br> " 90 + " <i>Info</i>: <br> If the OK button got pressed you will switch to the drawing action.<br>" 91 + "To finish the new object please press the spacebar. The new level<br>will be tagged automatically. </html>")); 92 infoBar.add(label1); 93 } 94 dialogPane.add(infoBar,BorderLayout.NORTH); 86 //---- Label1 ---- 87 label1.setText(tr("<html> Please insert the new level number you want to add.<br> " 88 + " <i>Info</i>: <br> If the OK button got pressed you will switch to the drawing action.<br>" 89 + "To finish the new object please press the spacebar. The new level<br>will be tagged automatically. </html>")); 90 infoBar.add(label1); 91 dialogPane.add(infoBar, BorderLayout.NORTH); 95 92 93 //======== contentPanel ======== 96 94 97 //======== contentPanel ======== 98 { 99 contentPanel.setLayout(new GridBagLayout()); 100 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0}; 101 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0}; 102 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4}; 103 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 95 contentPanel.setLayout(new GridBagLayout()); 96 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0}; 97 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0}; 98 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4}; 99 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 104 100 101 //---- Label2 ---- 102 label2.setText(tr("level number:")); 103 contentPanel.add(label2, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, 104 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 105 new Insets(5, 5, 5, 30), 0, 0)); 105 106 106 //---- Label2 ---- 107 label2.setText(tr("level number:")); 108 contentPanel.add(label2,new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, 109 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 110 new Insets(5, 5, 5, 30), 0, 0)); 107 //---- Field ---- 108 field.setToolTipText(tr("Example: '2' or '3'")); 109 field.addFocusListener(new FocusListener() { 111 110 112 //---- Field ---- 113 field.setToolTipText(tr("Example: '2' or '3'")); 114 field.addFocusListener(new FocusListener() { 111 @Override 112 public void focusLost(FocusEvent e) {} 115 113 116 @Override 117 public void focusLost(FocusEvent e) {} 114 @Override 115 public void focusGained(FocusEvent e) { 116 field.selectAll(); 117 } 118 }); 119 contentPanel.add(field, new GridBagConstraints(3, 0, 2, 1, 0.0, 0.0, 120 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 121 new Insets(5, 0, 5, 200), 0, 0)); 118 122 119 @Override 120 public void focusGained(FocusEvent e) { 121 field.selectAll(); 122 } 123 }); 124 contentPanel.add(field, new GridBagConstraints(3, 0, 2, 1, 0.0, 0.0, 125 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 126 new Insets(5, 0, 5, 200), 0, 0)); 123 dialogPane.add(contentPanel, BorderLayout.CENTER); 127 124 128 } 129 dialogPane.add(contentPanel, BorderLayout.CENTER); 125 //======== buttonBar ======== 130 126 131 //======== buttonBar ======== 132 { 133 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 134 buttonBar.setLayout(new GridBagLayout()); 135 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80}; 136 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0}; 127 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 128 buttonBar.setLayout(new GridBagLayout()); 129 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80}; 130 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0}; 137 131 138 139 140 141 142 132 //---- okButton ---- 133 okButton.setText(tr("OK")); 134 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, 135 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 136 new Insets(0, 0, 0, 5), 0, 0)); 143 137 144 145 146 147 148 149 } 150 151 } 138 //---- Button ---- 139 cancelButton.setText(tr("Cancel")); 140 buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 141 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 142 new Insets(0, 0, 0, 0), 0, 0)); 143 144 dialogPane.add(buttonBar, BorderLayout.SOUTH); 145 152 146 contentPane.add(dialogPane, BorderLayout.CENTER); 153 147 pack(); 154 148 setLocationRelativeTo(getOwner()); 155 156 149 } 157 150 158 /*************************************************159 * GETTER160 *161 */162 151 /** 163 152 * Getter for the level number field. … … 169 158 } 170 159 171 /************************************************* 172 * SELECTOR VIEW LISTENER 173 * 174 */ 175 176 /** 160 /** 177 161 * Set the listener for the OK button. 178 162 * … … 183 167 } 184 168 185 169 /** 186 170 * Set the listener for the Cancel button. 187 171 * … … 198 182 */ 199 183 public void setSelectorWindowListener(WindowListener l) { 200 184 this.addWindowListener(l); 201 185 } 202 203 /**204 *205 *206 *207 *208 *209 *210 *211 *212 */213 186 } -
applications/editors/josm/plugins/indoorhelper/src/views/PresetButton.java
r33997 r34005 29 29 * 30 30 */ 31 32 31 @SuppressWarnings("serial") 33 32 class PresetButton extends JButton { … … 48 47 this.setToolTipText("Fast Tag: "+indoorObject.toString()); 49 48 } 50 51 52 /**53 *54 *55 *56 *57 *58 *59 *60 *61 */62 49 } -
applications/editors/josm/plugins/indoorhelper/src/views/ToolBoxView.java
r33997 r34005 57 57 @SuppressWarnings("serial") 58 58 public class ToolBoxView extends ToggleDialog { 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 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; 88 87 89 88 public ToolBoxView() { … … 94 93 } 95 94 96 /*************************************************97 * CREATES THE LAYOUT OF THE PLUG-IN.98 *99 */100 95 private void initComponents() { 101 96 dialogPanel = new JPanel(); … … 133 128 134 129 //======== 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)); 130 131 dialogPanel.setBorder(new EmptyBorder(12, 12, 12, 12)); 132 dialogPanel.setLayout(new BorderLayout()); 133 134 //======== contentPanel ======== 135 136 contentPanel.setLayout(new GridBagLayout()); 137 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] { 138 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}; 139 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0}; 140 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] { 141 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, 142 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}; 143 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4}; 144 145 //---- addLevelButton ---- 146 addLevelButton.setText(tr("Insert level")); 147 addLevelButton.setToolTipText(tr("Add a new level to layer.")); 148 addLevelButton.setEnabled(false); 149 contentPanel.add(addLevelButton, new GridBagConstraints(12, 1, 3, 1, 0.0, 1.0, 150 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 151 new Insets(0, 0, 5, 30), 0, 0)); 152 153 //---- helpButton ---- 154 helpButton.setText(tr("<html><b>?</strong></b>")); 155 helpButton.setToolTipText(tr("Show Help-Browser.")); 156 helpButton.setBackground(Color.LIGHT_GRAY); 157 helpButton.setEnabled(false); 158 contentPanel.add(helpButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, 159 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 160 new Insets(0, 0, 5, 0), 0, 0)); 161 162 //---- levelNameLabel ---- 163 levelNameLabel.setText(tr("Level name")); 164 contentPanel.add(levelNameLabel, new GridBagConstraints(0, 1, 3, 1, 0.0, 1.0, 165 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 166 new Insets(0, 0, 5, 5), 0, 0)); 167 168 //---- levelNameField ---- 169 levelNameField.setEnabled(false); 170 levelNameField.setToolTipText(tr("Sets optional name tag for a level.")); 171 contentPanel.add(levelNameField, new GridBagConstraints(3, 1, 3, 1, 0.0, 1.0, 172 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 173 new Insets(0, 0, 5, 30), 0, 0)); 174 175 //---- levelLabel ---- 176 levelLabel.setText(tr("Working level: NONE")); 177 levelLabel.setToolTipText(tr("Shows the current working level.")); 178 contentPanel.add(levelLabel, new GridBagConstraints(6, 1, 3, 1, 0.0, 1.0, 179 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 180 new Insets(0, 0, 5, 5), 0, 0)); 181 182 //---- levelCheckBox ---- 183 levelCheckBox.setToolTipText(tr("Deactivate automatic level tagging.")); 184 contentPanel.add(levelCheckBox, new GridBagConstraints(9, 1, 1, 1, 0.0, 1.0, 185 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 186 new Insets(0, 0, 5, 5), 0, 0)); 187 contentPanel.add(separator1, new GridBagConstraints(0, 2, 0, 1, 0.0, 0.0, 188 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 189 new Insets(0, 0, 5, 5), 0, 0)); 190 191 //---- objectLabel ---- 192 objectLabel.setText(tr("Object")); 193 contentPanel.add(objectLabel, new GridBagConstraints(0, 3, 3, 1, 0.0, 1.0, 194 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 195 new Insets(0, 0, 5, 5), 0, 0)); 196 197 //---- objectBox ---- 198 objectBox.setEnabled(false); 199 objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL); 200 objectBox.setToolTipText(tr("The object preset you want to tag.")); 201 contentPanel.add(objectBox, new GridBagConstraints(3, 3, 3, 1, 0.0, 1.0, 202 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 203 new Insets(0, 0, 5, 30), 0, 0)); 204 205 //---- nameLabel ---- 206 nameLabel.setText(tr("Name")); 207 contentPanel.add(nameLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 1.0, 208 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 209 new Insets(0, 0, 5, 5), 0, 0)); 210 211 //---- nameField ---- 212 nameField.setEnabled(false); 213 nameField.addFocusListener(new FocusListener() { 214 215 @Override 216 public void focusLost(FocusEvent e) {} 217 218 @Override 219 public void focusGained(FocusEvent e) { 220 nameField.selectAll(); 332 221 } 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)); 222 }); 223 nameField.setToolTipText(tr("Sets the name tag.")); 224 contentPanel.add(nameField, new GridBagConstraints(3, 4, 3, 1, 0.0, 1.0, 225 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 226 new Insets(0, 0, 5, 30), 0, 0)); 227 228 //---- refLabel ---- 229 refLabel.setText(tr("Reference")); 230 contentPanel.add(refLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 1.0, 231 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 232 new Insets(0, 0, 5, 5), 0, 0)); 233 234 //---- refField ---- 235 refField.setEnabled(false); 236 refField.addFocusListener(new FocusListener() { 237 238 @Override 239 public void focusLost(FocusEvent e) {} 240 241 @Override 242 public void focusGained(FocusEvent e) { 243 refField.selectAll(); 349 244 } 350 dialogPanel.add(buttonBar, BorderLayout.SOUTH); 351 } 245 }); 246 refField.setToolTipText(tr("Sets the referance tag.")); 247 contentPanel.add(refField, new GridBagConstraints(3, 5, 3, 1, 0.0, 1.0, 248 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 249 new Insets(0, 0, 5, 30), 0, 0)); 250 251 //---- repeatOnLabel ---- 252 repeatOnLabel.setText(tr("Repeat on")); 253 contentPanel.add(repeatOnLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 1.0, 254 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 255 new Insets(0, 0, 5, 5), 0, 0)); 256 257 //---- repeatOnField ---- 258 repeatOnField.setEnabled(false); 259 repeatOnField.addFocusListener(new FocusListener() { 260 261 @Override 262 public void focusLost(FocusEvent e) {} 263 264 @Override 265 public void focusGained(FocusEvent e) { 266 repeatOnField.selectAll(); 267 } 268 }); 269 repeatOnField.setToolTipText( 270 tr("Sets the repeat on tag when highway objects are selected. Please tag like this: -3-4 or -2--3 or 5-6 .")); 271 contentPanel.add(repeatOnField, new GridBagConstraints(3, 6, 3, 1, 0.0, 1.0, 272 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 273 new Insets(0, 0, 5, 30), 0, 0)); 274 contentPanel.add(separator2, new GridBagConstraints(0, 7, 0, 1, 0.0, 1.0, 275 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 276 new Insets(0, 0, 5, 5), 0, 0)); 277 278 //---- preset1 ---- 279 preset1.setEnabled(false); 280 contentPanel.add(preset1, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0, 281 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 282 new Insets(0, 0, 5, 5), 0, 0)); 283 //---- preset2 ---- 284 preset2.setEnabled(false); 285 contentPanel.add(preset2, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, 286 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 287 new Insets(0, 0, 5, 5), 0, 0)); 288 289 //---- preset3 ---- 290 preset3.setEnabled(false); 291 contentPanel.add(preset3, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, 292 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 293 new Insets(0, 0, 5, 5), 0, 0)); 294 295 //---- preset4 ---- 296 preset4.setEnabled(false); 297 contentPanel.add(preset4, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0, 298 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 299 new Insets(0, 0, 5, 5), 0, 0)); 300 301 //---- multiLabel ---- 302 multiLabel.setText(tr("Multipolygon")); 303 contentPanel.add(multiLabel, new GridBagConstraints(0, 8, 3, 1, 0.0, 1.0, 304 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 305 new Insets(0, 0, 5, 5), 0, 0)); 306 307 //---- multiOuterButton ---- 308 multiOuterButton.setText(tr("OUTER")); 309 multiOuterButton.setToolTipText(tr("Creation-Tool for multipolygon with role: outer. To finish press the spacebar.")); 310 multiOuterButton.setEnabled(false); 311 contentPanel.add(multiOuterButton, new GridBagConstraints(3, 8, 3, 1, 0.0, 1.0, 312 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 313 new Insets(0, 0, 5, 30), 0, 0)); 314 315 //---- multiInnerButton ---- 316 multiInnerButton.setText(tr("INNER")); 317 multiInnerButton.setToolTipText( 318 tr("Creation-Tool for multipolygons with role: inner. To finish press spacebar. To add to relation select \"outer\" and press enter.")); 319 multiInnerButton.setEnabled(false); 320 contentPanel.add(multiInnerButton, new GridBagConstraints(6, 8, 1, 1, 0.0, 0.0, 321 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 322 new Insets(0, 0, 5, 5), 0, 0)); 323 324 //---- multiCheckBox ---- 325 multiCheckBox.setToolTipText(tr("Deactivate multipolygon function.")); 326 contentPanel.add(multiCheckBox, new GridBagConstraints(9, 8, 1, 1, 0.0, 1.0, 327 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 328 new Insets(0, 0, 5, 5), 0, 0)); 329 330 dialogPanel.add(contentPanel, BorderLayout.CENTER); 331 332 //======== buttonBar ======== 333 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); 334 buttonBar.setLayout(new GridBagLayout()); 335 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80}; 336 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0}; 337 338 //---- applyButton ---- 339 applyButton.setText(tr("Apply")); 340 applyButton.setToolTipText(tr("Add selected tags and/or relations to obeject.")); 341 applyButton.setEnabled(false); 342 buttonBar.add(applyButton, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, 343 GridBagConstraints.CENTER, GridBagConstraints.BOTH, 344 new Insets(0, 0, 0, 0), 0, 0)); 345 346 dialogPanel.add(buttonBar, BorderLayout.SOUTH); 347 352 348 this.createLayout(dialogPanel, true, null); 353 354 } 355 356 /************************************************* 357 * ENABLES OR DISABLES UI ELEMENTS 358 * 359 */ 349 } 350 360 351 /** 361 352 * Enables or disables the interactive UI elements of the toolbox. … … 364 355 */ 365 356 public void setAllUiElementsEnabled(boolean enabled) { 366 367 368 357 this.applyButton.setEnabled(enabled); 358 this.levelCheckBox.setEnabled(enabled); 359 this.helpButton.setEnabled(enabled); 369 360 this.objectBox.setEnabled(enabled); 370 361 this.levelNameField.setEnabled(enabled); … … 402 393 * Enables or disables the interactive text box element {@link #repeatOn}. 403 394 * @param enabled set this true for enabled elements 404 */ 405 public void setROUiElementsEnabled(boolean enabled){ 406 this.repeatOnField.setEnabled(enabled); 407 395 */ 396 public void setROUiElementsEnabled(boolean enabled) { 397 this.repeatOnField.setEnabled(enabled); 408 398 } 409 399 … … 411 401 * Enables or disables the interactive text box element {@link #levelName}. 412 402 * @param enabled set this true for enabled elements 413 403 */ 414 404 public void setLVLUiElementsEnabled(boolean enabled) { 415 416 405 this.levelNameField.setEnabled(enabled); 406 this.addLevelButton.setEnabled(enabled); 417 407 418 408 } … … 421 411 * Enables or disables the interactive ComboBoxes {@link #multiRoleBox} and {@link #multiEditBox }. 422 412 * @param enabled set this true for enabled elements 423 413 */ 424 414 public void setMultiUiElementsEnabled(boolean enabled) { 425 426 427 428 415 this.multiOuterButton.setEnabled(enabled); 416 this.multiInnerButton.setEnabled(enabled); 417 418 if (enabled == false) resetUiElements(); 429 419 } 430 420 … … 436 426 } 437 427 438 439 /*************************************************440 * GETTER and SETTER FOR THE INTERACTIVE UI BOXES441 *442 */443 428 /** 444 429 * Getter for the selected {@link IndoorObject} in the objectBox. … … 480 465 * Setter for the current level value tag 481 466 * 467 * @author rebsc 482 468 * @param current level value as String 483 * @author rebsc484 469 */ 485 470 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 } 471 if (getLevelCheckBoxStatus() == false) { 472 if (!levelTag.equals("")) { 473 this.levelLabel.setText((tr("Working level: {0}", levelTag))); 474 } else { 475 this.levelLabel.setText((tr("Working level: NONE"))); 476 } 477 } else { 478 this.levelLabel.setText((tr("Working level: NONE"))); 479 } 497 480 } 498 481 … … 503 486 */ 504 487 public boolean getLevelCheckBoxStatus() { 505 488 return this.levelCheckBox.isSelected(); 506 489 } 507 490 … … 522 505 return this.repeatOnField.getText(); 523 506 } 524 525 526 /*************************************************527 * RESETER FOR THE INTERACTIVE UI BOXES528 *529 */530 507 531 508 /** … … 540 517 } 541 518 542 543 /*************************************************544 * SETTERS FOR THE BUTTON LISTENER545 *546 */547 548 519 /** 549 520 * Set the listener for the apply button. … … 560 531 */ 561 532 public void setLevelCheckBoxListener(ItemListener l) { 562 533 this.levelCheckBox.addItemListener(l); 563 534 } 564 535 … … 568 539 */ 569 540 public void setHelpButtonListener(ActionListener l) { 570 541 this.helpButton.addActionListener(l); 571 542 } 572 543 … … 576 547 */ 577 548 public void setAddLevelButtonListener(ActionListener l) { 578 549 this.addLevelButton.addActionListener(l); 579 550 } 580 551 … … 616 587 } 617 588 618 /*************************************************619 * PRESET BUTTON FUNCTION620 *621 */622 589 public void setPresetButtons(List<IndoorObject> objects) { 623 590 this.preset1.setIndoorObject(objects.get(0)); … … 658 625 return preset4.getIndoorObject(); 659 626 } 660 661 662 /**663 *664 *665 *666 *667 *668 *669 *670 *671 *672 */673 627 }
Note:
See TracChangeset
for help on using the changeset viewer.