Ticket #14408: plugins-conflation-fix-and-improvement.diff
| File plugins-conflation-fix-and-improvement.diff, 56.2 KB (added by , 9 years ago) |
|---|
-
josm/plugins/conflation/.checkstyle
1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false"> 4 <local-check-config name="JOSM" location="/JOSM/tools/checkstyle/josm_checks.xml" type="project" description=""> 5 <additional-data name="protect-config-file" value="false"/> 6 </local-check-config> 7 <fileset name="all" enabled="true" check-config-name="JOSM" local="true"> 8 <file-match-pattern match-pattern="." include-pattern="true"/> 9 </fileset> 10 <filter name="DerivedFiles" enabled="true"/> 11 <filter name="FilesFromPackage" enabled="true"> 12 <filter-data value="src/com"/> 13 </filter> 14 </fileset-config> -
josm/plugins/conflation/.project
15 15 <arguments> 16 16 </arguments> 17 17 </buildCommand> 18 <buildCommand> 19 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 20 <arguments> 21 </arguments> 22 </buildCommand> 18 23 </buildSpec> 19 24 <natures> 20 25 <nature>org.eclipse.jdt.core.javanature</nature> 26 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 21 27 </natures> 22 28 </projectDescription> -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflateMatchCommand.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 import java.util.ArrayList; 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 7 import java.util.Arrays; 5 8 import java.util.Collection; 6 import java.util. Collections;9 import java.util.HashSet; 7 10 import java.util.List; 11 import java.util.stream.Collectors; 12 8 13 import javax.swing.Icon; 14 9 15 import org.openstreetmap.josm.command.AddPrimitivesCommand; 10 16 import org.openstreetmap.josm.command.Command; 11 17 import org.openstreetmap.josm.command.PseudoCommand; 12 18 import org.openstreetmap.josm.data.osm.DataSet; 13 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 20 import org.openstreetmap.josm.data.osm.PrimitiveData; 21 import org.openstreetmap.josm.plugins.utilsplugin2.replacegeometry.ReplaceGeometryException; 15 22 import org.openstreetmap.josm.plugins.utilsplugin2.replacegeometry.ReplaceGeometryUtils; 16 import static org.openstreetmap.josm.tools.I18n.tr;17 23 import org.openstreetmap.josm.tools.ImageProvider; 18 24 import org.openstreetmap.josm.tools.UserCancelException; 19 25 26 20 27 /** 21 28 * Command to conflate one object with another. 22 29 */ 23 30 public class ConflateMatchCommand extends Command { 31 32 private final DataSet sourceDataSet; 33 private final DataSet targetDataSet; 24 34 private final SimpleMatch match; 25 35 private final SimpleMatchList matches; 26 private final Command replaceCommand;36 private Command replaceCommand = null; 27 37 private AddPrimitivesCommand addPrimitivesCommand = null; 28 38 29 39 public ConflateMatchCommand(SimpleMatch match, … … 31 41 super(settings.getSubjectLayer()); 32 42 this.match = match; 33 43 this.matches = matches; 34 35 DataSet sourceDataSet = settings.getReferenceDataSet(); 36 DataSet targetDataSet = settings.getSubjectDataSet(); 37 // copy objects from reference dataset 38 if (targetDataSet != sourceDataSet) { 39 // TODO: use MergeCommand instead? 40 List<PrimitiveData> newObjects = ConflationUtils.copyObjects(sourceDataSet, match.getReferenceObject()); 41 42 // FIXME: bad form to execute command in constructor, how to fix? 43 addPrimitivesCommand = new AddPrimitivesCommand(newObjects, newObjects, settings.getSubjectLayer()); 44 if (!addPrimitivesCommand.executeCommand()) 45 throw new AssertionError(); 46 } 47 48 // need to copy from other layer before this? 49 replaceCommand = ReplaceGeometryUtils.buildReplaceCommand( 50 match.getSubjectObject(), 51 targetDataSet.getPrimitiveById(match.getReferenceObject().getPrimitiveId())); 52 53 if (addPrimitivesCommand != null) 54 addPrimitivesCommand.undoCommand(); 55 if (replaceCommand == null) { 56 throw new UserCancelException(); 57 } 44 this.sourceDataSet = settings.getReferenceDataSet(); 45 this.targetDataSet = settings.getSubjectDataSet(); 58 46 } 59 47 60 48 @Override 61 49 public boolean executeCommand() { 62 if (addPrimitivesCommand != null) { 63 if (!addPrimitivesCommand.executeCommand()) 64 return false; 50 boolean ok = true; 51 try { 52 if (targetDataSet != sourceDataSet) { 53 if (addPrimitivesCommand == null) { 54 List<PrimitiveData> newObjects = ConflationUtils.copyObjects(sourceDataSet, match.getReferenceObject(), targetDataSet); 55 addPrimitivesCommand = new AddPrimitivesCommand(newObjects, newObjects, getLayer()); 56 } 57 if (!addPrimitivesCommand.executeCommand()) { 58 ok = false; 59 addPrimitivesCommand = null; 60 } 61 } 62 if (ok) { 63 if (replaceCommand == null) { 64 replaceCommand = ReplaceGeometryUtils.buildReplaceCommand( 65 match.getSubjectObject(), 66 targetDataSet.getPrimitiveById(match.getReferenceObject().getPrimitiveId())); 67 if (replaceCommand == null) { 68 // Throwing an exception is the only way I found to be sure 69 // the command is not added to the undo list. 70 throw new ReplaceGeometryException(tr("Canceled")); 71 } 72 } 73 if (replaceCommand.executeCommand()) { 74 matches.remove(match); 75 } else { 76 ok = false; 77 } 78 } 79 } catch (RuntimeException e) { 80 ok = false; 81 throw e; 82 } finally { 83 if (!ok) { 84 replaceCommand = null; 85 if (addPrimitivesCommand != null) { 86 addPrimitivesCommand.undoCommand(); 87 addPrimitivesCommand = null; 88 } 89 } 65 90 } 66 if (!replaceCommand.executeCommand()) 67 return false; 68 matches.remove(match); 69 70 return true; 91 return ok; 71 92 } 72 93 73 94 @Override 74 95 public void undoCommand() { 75 replaceCommand.undoCommand(); 76 if (addPrimitivesCommand != null) 96 if (replaceCommand != null) { 97 replaceCommand.undoCommand(); 98 matches.add(match); 99 } 100 if (addPrimitivesCommand != null) { 77 101 addPrimitivesCommand.undoCommand(); 78 matches.add(match);102 } 79 103 } 80 104 81 105 @Override 82 106 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) { 83 107 throw new UnsupportedOperationException("Not supported yet."); … … 88 112 //TODO: make more descriptive 89 113 return tr("Conflate object pair"); 90 114 } 91 115 92 116 @Override 93 117 public Icon getDescriptionIcon() { 94 118 return ImageProvider.get("dialogs", "conflation"); 95 119 } 96 120 97 121 @Override 98 122 public Collection<? extends OsmPrimitive> getParticipatingPrimitives() { 99 return Collections.singleton(match.getSubjectObject()); 123 Collection<OsmPrimitive> prims = new HashSet<>(); 124 if (addPrimitivesCommand != null) 125 prims.addAll(addPrimitivesCommand.getParticipatingPrimitives()); 126 if (replaceCommand != null) 127 prims.addAll(replaceCommand.getParticipatingPrimitives()); 128 return prims; 100 129 } 101 130 102 131 @Override 103 132 public Collection<PseudoCommand> getChildren() { 104 if (replaceCommand == null) 105 return null; 106 107 Collection<PseudoCommand> children = new ArrayList<>(); 108 if (addPrimitivesCommand != null) 109 children.add(addPrimitivesCommand); 110 children.addAll(replaceCommand.getChildren()); 111 return children; 133 return Arrays.asList(addPrimitivesCommand, replaceCommand).stream() 134 .filter(c -> c != null) 135 .collect(Collectors.toList()); 112 136 } 113 137 } -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflateUnmatchedObjectCommand.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import java.util.ArrayList; … … 29 30 this.unmatchedObjects = unmatchedObjects; 30 31 this.listModel = listModel; 31 32 32 List<PrimitiveData> newObjects = ConflationUtils.copyObjects(sourceDataLayer.data, unmatchedObjects );33 List<PrimitiveData> newObjects = ConflationUtils.copyObjects(sourceDataLayer.data, unmatchedObjects, targetDataLayer.data); 33 34 34 35 addPrimitivesCommand = new AddPrimitivesCommand(newObjects, newObjects, targetDataLayer); 35 36 } … … 69 70 return unmatchedObjects; 70 71 } 71 72 72 73 73 @Override 74 74 public Collection<PseudoCommand> getChildren() { 75 75 Collection<PseudoCommand> children = new ArrayList<>(); -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import static org.openstreetmap.josm.tools.I18n.tr; … … 31 32 */ 32 33 public class ConflationLayer extends Layer { 33 34 protected SimpleMatchList matches; 34 35 35 36 public ConflationLayer(SimpleMatchList matches) { 36 37 super(tr("Conflation")); 37 38 this.matches = matches; 38 39 } 39 40 40 41 public ConflationLayer() { 41 42 this(null); 42 43 } … … 88 89 g2.draw(path); 89 90 } 90 91 } 91 92 93 92 } 94 93 95 96 94 @Override 97 95 public Icon getIcon() { 98 96 // TODO: change icon … … 121 119 OsmPrimitive reference = match.getReferenceObject(); 122 120 OsmPrimitive subject = match.getSubjectObject(); 123 121 if (reference != null && reference instanceof Node) 124 v.visit((Node) reference);122 v.visit((Node) reference); 125 123 if (subject != null && subject instanceof Node) 126 v.visit((Node) subject);124 v.visit((Node) subject); 127 125 } 128 126 } 129 127 … … 142 140 SeparatorLayerAction.INSTANCE, 143 141 new LayerListPopup.InfoAction(this)}; 144 142 } 145 143 146 144 public void setMatches(SimpleMatchList matches) { 147 145 this.matches = matches; 148 146 // TODO: does repaint automatically occur? -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationPlugin.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 import java.awt.GraphicsEnvironment;5 6 5 import org.openstreetmap.josm.gui.MapFrame; 7 6 import org.openstreetmap.josm.plugins.Plugin; 8 7 import org.openstreetmap.josm.plugins.PluginInformation; 9 8 10 9 public class ConflationPlugin extends Plugin { 11 10 12 private ConflationToggleDialog dialog = null;13 14 11 /** 15 12 * constructor 16 13 */ … … 21 18 // add dialog the first time the mapframe is loaded 22 19 @Override 23 20 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 24 if (oldFrame == null && newFrame != null && !GraphicsEnvironment.isHeadless()) { 25 if (dialog == null) { 26 dialog = new ConflationToggleDialog(this); 27 } 28 newFrame.addToggleDialog(dialog); 21 if (oldFrame == null && newFrame != null) { 22 newFrame.addToggleDialog(new ConflationToggleDialog(this)); 29 23 } 30 24 } 31 25 } -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationToggleDialog.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import static org.openstreetmap.josm.tools.I18n.marktr; … … 18 19 import java.util.Arrays; 19 20 import java.util.Collection; 20 21 import java.util.HashSet; 21 import java.util.LinkedList;22 22 import java.util.List; 23 23 import java.util.Map; 24 24 import java.util.Set; … … 48 48 import org.openstreetmap.josm.actions.JosmAction; 49 49 import org.openstreetmap.josm.command.Command; 50 50 import org.openstreetmap.josm.data.SelectionChangedListener; 51 import org.openstreetmap.josm.data.osm.DataSet; 51 52 import org.openstreetmap.josm.data.osm.OsmPrimitive; 52 53 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 53 54 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; … … 62 63 import org.openstreetmap.josm.gui.SideButton; 63 64 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 64 65 import org.openstreetmap.josm.gui.layer.Layer; 66 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 67 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 68 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 69 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 65 70 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 66 71 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 67 72 import org.openstreetmap.josm.plugins.jts.JTSConverter; … … 81 86 import com.vividsolutions.jump.task.TaskMonitor; 82 87 83 88 public class ConflationToggleDialog extends ToggleDialog 84 implements SelectionChangedListener, DataSetListener, SimpleMatchListListener {89 implements SelectionChangedListener, DataSetListener, SimpleMatchListListener, LayerChangeListener { 85 90 86 public final staticString TITLE_PREFIX = tr("Conflation");87 public final staticString PREF_PREFIX = "conflation";91 public static final String TITLE_PREFIX = tr("Conflation"); 92 public static final String PREF_PREFIX = "conflation"; 88 93 JTabbedPane tabbedPane; 89 94 JTable matchTable; 90 95 JList<OsmPrimitive> referenceOnlyList; … … 116 121 public void windowClosed(WindowEvent e) { 117 122 // "Generate matches" was clicked 118 123 if (settingsDialog.getValue() == 1) { 124 clear(true, true, false); 119 125 settings = settingsDialog.getSettings(); 120 126 performMatching(); 121 127 } … … 139 145 140 146 matchTable.setRowSelectionAllowed(true); 141 147 matchTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 148 matchTable.setAutoCreateRowSorter(true); 142 149 143 150 referenceOnlyListModel = new UnmatchedObjectListModel(); 144 151 referenceOnlyList = new JList<>(referenceOnlyListModel); … … 326 333 } 327 334 328 335 @Override 336 public void showNotify() { 337 super.showNotify(); 338 DataSet.addSelectionListener(this); 339 Main.getLayerManager().addLayerChangeListener(this); 340 } 341 342 @Override 343 public void hideNotify() { 344 super.hideNotify(); 345 DataSet.removeSelectionListener(this); 346 Main.getLayerManager().removeLayerChangeListener(this); 347 clear(true, true, true); 348 settingsDialog.clear(true, true); 349 } 350 351 private void clear(boolean shouldClearReference, boolean shouldClearSubject, boolean shouldRemoveConflationLayer) { 352 if (shouldRemoveConflationLayer && (conflationLayer != null)) { 353 if (Main.getLayerManager().containsLayer(conflationLayer)) { 354 Main.getLayerManager().removeLayer(conflationLayer); 355 } 356 conflationLayer = null; 357 } 358 if (settings != null) { 359 if (shouldClearReference) { 360 DataSet dataSet = settings.getReferenceDataSet(); 361 if (dataSet != null) { 362 dataSet.removeDataSetListener(this); 363 settings.setReferenceDataSet(null); 364 } 365 settings.setReferenceLayer(null); 366 settings.setReferenceSelection(null); 367 } 368 if (shouldClearSubject) { 369 DataSet dataSet = settings.getSubjectDataSet(); 370 if (dataSet != null) { 371 dataSet.removeDataSetListener(this); 372 settings.setSubjectDataSet(null); 373 } 374 settings.setSubjectLayer(null); 375 settings.setSubjectSelection(null); 376 } 377 } 378 referenceOnlyListModel.clear(); 379 subjectOnlyListModel.clear(); 380 setMatches(new SimpleMatchList()); 381 } 382 383 private void setMatches(SimpleMatchList matchList) { 384 matches.clear(); 385 matches.removeAllConflationListChangedListener(); 386 matches = matchList; 387 matchTableModel.setMatches(matches); 388 matches.addConflationListChangedListener(conflateAction); 389 matches.addConflationListChangedListener(removeAction); 390 matches.addConflationListChangedListener(this); 391 if (conflationLayer != null) { 392 conflationLayer.setMatches(matches); 393 } 394 } 395 396 @Override 329 397 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 330 // TODO 398 if (newSelection.size() > 0) { 399 referenceOnlyList.getSelectionModel().clearSelection(); 400 subjectOnlyList.getSelectionModel().clearSelection(); 401 matchTable.getSelectionModel().clearSelection(); 402 boolean ensureVisible = true; 403 for (OsmPrimitive item: newSelection) { 404 addObjectToSelection(item, ensureVisible); 405 ensureVisible = false; 406 } 407 } 408 } 409 410 private boolean addObjectToSelection(OsmPrimitive object, boolean ensureVisible) { 411 int index = referenceOnlyListModel.indexOf(object); 412 if (index >= 0) { 413 referenceOnlyList.getSelectionModel().addSelectionInterval(index, index); 414 if (ensureVisible) { 415 tabbedPane.setSelectedIndex(1); 416 referenceOnlyList.ensureIndexIsVisible(index); 417 } 418 return true; 419 } 420 index = subjectOnlyListModel.indexOf(object); 421 if (index >= 0) { 422 subjectOnlyList.getSelectionModel().addSelectionInterval(index, index); 423 if (ensureVisible) { 424 tabbedPane.setSelectedIndex(2); 425 subjectOnlyList.ensureIndexIsVisible(index); 426 } 427 return true; 428 } 429 index = 0; 430 for (SimpleMatch c : matches) { 431 if ((c.getSubjectObject() == object) || (c.getReferenceObject() == object)) { 432 break; 433 } 434 index++; 435 } 436 if (index < matches.size()) { 437 index = matchTable.convertRowIndexToView(index); 438 matchTable.getSelectionModel().addSelectionInterval(index, index); 439 if (ensureVisible) { 440 tabbedPane.setSelectedIndex(0); 441 matchTable.scrollRectToVisible(new Rectangle(matchTable.getCellRect(index, 0, true))); 442 } 443 return true; 444 } 445 return false; 331 446 } 332 447 333 448 private Collection<SimpleMatch> getSelectedFromTable() { 334 449 ListSelectionModel lsm = matchTable.getSelectionModel(); 335 450 Collection<SimpleMatch> selMatches = new HashSet<>(); 336 451 for (int i = lsm.getMinSelectionIndex(); i <= lsm.getMaxSelectionIndex(); i++) { 337 if (lsm.isSelectedIndex(i) && i < matches.size()) { 338 selMatches.add(matches.get(i)); 452 if (lsm.isSelectedIndex(i) && (i < matches.size())) { 453 int modelIndex = matchTable.convertRowIndexToModel(i); 454 if (modelIndex < matches.size()) { 455 selMatches.add(matches.get(modelIndex)); 456 } 339 457 } 340 458 } 341 459 return selMatches; … … 352 470 //TODO: do something! 353 471 } 354 472 } 473 355 474 protected static class ConflatePopupMenu extends JPopupMenu { 356 475 357 static public void launch(Component parent) {476 public static void launch(Component parent) { 358 477 JPopupMenu menu = new ConflatePopupMenu(); 359 478 Rectangle r = parent.getBounds(); 360 479 menu.show(parent, r.x, r.y + r.height); … … 380 499 381 500 private final String columnName; 382 501 383 publicColorTableCellRenderer(String column) {502 ColorTableCellRenderer(String column) { 384 503 this.columnName = column; 385 504 setOpaque(true); 386 505 } … … 409 528 } 410 529 } 411 530 412 static public class LayerListCellRenderer extends DefaultListCellRenderer {531 public static class LayerListCellRenderer extends DefaultListCellRenderer { 413 532 414 533 @Override 415 534 public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, … … 429 548 */ 430 549 class RemoveMatchCommand extends Command { 431 550 private final Collection<SimpleMatch> toRemove; 432 publicRemoveMatchCommand(Collection<SimpleMatch> toRemove) {551 RemoveMatchCommand(Collection<SimpleMatch> toRemove) { 433 552 this.toRemove = toRemove; 434 553 } 435 554 … … 462 581 private final UnmatchedObjectListModel model; 463 582 private final Collection<OsmPrimitive> objects; 464 583 465 publicRemoveUnmatchedObjectCommand(UnmatchedObjectListModel model,584 RemoveUnmatchedObjectCommand(UnmatchedObjectListModel model, 466 585 Collection<OsmPrimitive> objects) { 467 586 this.model = model; 468 587 this.objects = objects; … … 500 619 501 620 class RemoveAction extends JosmAction implements SimpleMatchListListener, ChangeListener, ListSelectionListener { 502 621 503 publicRemoveAction() {622 RemoveAction() { 504 623 super(tr("Remove"), "dialogs/delete", tr("Remove selected matches"), 505 624 null, false); 506 625 } 626 507 627 @Override 508 628 public void actionPerformed(ActionEvent e) { 509 629 Component selComponent = getSelectedTabComponent(); … … 540 660 } 541 661 542 662 } 663 543 664 @Override 544 665 public void simpleMatchListChanged(SimpleMatchList list) { 545 666 } … … 562 683 563 684 class ConflateAction extends JosmAction implements SimpleMatchListListener, ChangeListener, ListSelectionListener { 564 685 565 publicConflateAction() {686 ConflateAction() { 566 687 // TODO: make sure shortcuts make sense 567 688 super(tr("Conflate"), "dialogs/conflation", tr("Conflate selected objects"), 568 689 Shortcut.registerShortcut("conflation:replace", tr("Conflation: {0}", tr("Replace")), … … 571 692 572 693 @Override 573 694 public void actionPerformed(ActionEvent e) { 574 if (getSelectedTabComponent().equals(matchTable)) 575 conflateMatchActionPerformed(); 576 else if (getSelectedTabComponent().equals(referenceOnlyList)) 577 conflateUnmatchedObjectActionPerformed(); 695 try { 696 DataSet.removeSelectionListener(ConflationToggleDialog.this); 697 if (getSelectedTabComponent().equals(matchTable)) 698 conflateMatchActionPerformed(); 699 else if (getSelectedTabComponent().equals(referenceOnlyList)) 700 conflateUnmatchedObjectActionPerformed(); 701 } finally { 702 DataSet.addSelectionListener(ConflationToggleDialog.this); 703 } 578 704 } 579 705 580 706 private void conflateUnmatchedObjectActionPerformed() { … … 587 713 588 714 private void conflateMatchActionPerformed() { 589 715 SimpleMatch nextSelection = matches.findNextSelection(); 590 List<Command> cmds = new LinkedList<>();716 //List<Command> cmds = new LinkedList<>(); 591 717 try { 592 718 // iterate over selected matches in reverse order since they will be removed as we go 593 719 List<SimpleMatch> selMatches = new ArrayList<>(matches.getSelected()); 594 720 for (SimpleMatch c : selMatches) { 595 596 721 ConflateMatchCommand conflateCommand; 597 722 try { 598 723 conflateCommand = new ConflateMatchCommand(c, matches, settings); 599 724 } catch (UserCancelException ex) { 600 725 break; 601 726 } 602 cmds.add(conflateCommand);603 604 727 // FIXME: how to chain commands which change relations? (see below) 728 //cmds.add(conflateCommand); 605 729 Main.main.undoRedo.add(conflateCommand); 606 730 } 607 731 } catch (ReplaceGeometryException ex) { … … 659 783 * the list (either matches or single primitives). 660 784 * 661 785 */ 662 class ZoomToListSelectionAction extends JosmAction implements ListSelectionListener {663 publicZoomToListSelectionAction() {786 class ZoomToListSelectionAction extends JosmAction implements ListSelectionListener { 787 ZoomToListSelectionAction() { 664 788 super(tr("Zoom to selected primitive(s)"), "dialogs/autoscale/selection", tr("Zoom to selected primitive(s)"), 665 789 null, false); 666 790 } … … 692 816 * the list (either matches or single primitives). 693 817 * 694 818 */ 695 class SelectListSelectionAction extends JosmAction implements ListSelectionListener {696 publicSelectListSelectionAction() {819 class SelectListSelectionAction extends JosmAction implements ListSelectionListener { 820 SelectListSelectionAction() { 697 821 super(tr("Select selected primitive(s)"), "dialogs/select", tr("Select the primitives currently selected in the list"), 698 822 null, false); 699 823 } … … 730 854 //FIXME: this doesn't seem to be working 731 855 int row = matchTable.rowAtPoint(evt.getPoint()); 732 856 matchTable.getSelectionModel().addSelectionInterval(row, row); 733 } 734 else if (c == subjectOnlyList || c == referenceOnlyList) { 735 int idx = ((JList<?>)c).locationToIndex(evt.getPoint()); 857 } else if (c == subjectOnlyList || c == referenceOnlyList) { 858 int idx = ((JList<?>) c).locationToIndex(evt.getPoint()); 736 859 if (idx < 0) 737 860 return; 738 ((JList<?>) c).setSelectedIndex(idx);861 ((JList<?>) c).setSelectedIndex(idx); 739 862 } 740 863 } 741 864 … … 747 870 * The popup menu for the selection list 748 871 */ 749 872 class SelectionPopup extends JPopupMenu { 750 publicSelectionPopup() {873 SelectionPopup() { 751 874 matchTable.getSelectionModel().addListSelectionListener(zoomToListSelectionAction); 752 875 subjectOnlyList.addListSelectionListener(zoomToListSelectionAction); 753 876 referenceOnlyList.addListSelectionListener(zoomToListSelectionAction); … … 767 890 768 891 @Override 769 892 public void primitivesRemoved(PrimitivesRemovedEvent event) { 770 List<? extends OsmPrimitive> prims = event.getPrimitives(); 771 for (OsmPrimitive p : prims) { 772 // TODO: use hashmap 773 for (SimpleMatch c : matches) { 774 if (c.getReferenceObject().equals(p) || c.getSubjectObject().equals(p)) { 775 matches.remove(c); 776 break; 893 if (settings != null) { 894 DataSet dataSet = event.getDataset(); 895 if (dataSet == settings.getReferenceDataSet()) { 896 for (OsmPrimitive p : event.getPrimitives()) { 897 // TODO: use hashmap 898 for (SimpleMatch c : matches) { 899 if (c.getReferenceObject().equals(p)) { 900 matches.remove(c); 901 break; 902 } 903 } 904 referenceOnlyListModel.removeElement(p); 905 } 906 } else if (dataSet == settings.getSubjectDataSet()) { 907 for (OsmPrimitive p : event.getPrimitives()) { 908 // TODO: use hashmap 909 for (SimpleMatch c : matches) { 910 if (c.getSubjectObject().equals(p)) { 911 matches.remove(c); 912 break; 913 } 914 } 915 subjectOnlyListModel.removeElement(p); 777 916 } 778 917 } 779 780 referenceOnlyListModel.removeElement(p);781 subjectOnlyListModel.removeElement(p);782 918 } 783 919 } 784 920 … … 808 944 809 945 /** 810 946 * Create FeatureSchema using union of all keys from all selected primitives 811 * @param prims812 * @return813 947 */ 814 948 private FeatureSchema createSchema(Collection<OsmPrimitive> prims) { 815 949 Set<String> keys = new HashSet<>(); … … 878 1012 FeatureCollection refColl = new FeatureDataset(allFeatures.getFeatureSchema()); 879 1013 FeatureCollection subColl = new FeatureDataset(allFeatures.getFeatureSchema()); 880 1014 for (Feature f : allFeatures.getFeatures()) { 881 OsmFeature osmFeature = (OsmFeature) f;1015 OsmFeature osmFeature = (OsmFeature) f; 882 1016 if (settings.getReferenceSelection().contains(osmFeature.getPrimitive())) 883 1017 refColl.add(osmFeature); 884 1018 if (settings.getSubjectSelection().contains(osmFeature.getPrimitive())) … … 909 1043 SimpleMatchList list = new SimpleMatchList(); 910 1044 for (Map.Entry<Feature, Matches> entry: map.entrySet()) { 911 1045 OsmFeature target = (OsmFeature) entry.getKey(); 912 OsmFeature subject = (OsmFeature) entry.getValue().getTopMatch();1046 OsmFeature subject = (OsmFeature) entry.getValue().getTopMatch(); 913 1047 if (target != null && subject != null) 914 1048 list.add(new SimpleMatch(target.getPrimitive(), subject.getPrimitive(), 915 1049 entry.getValue().getTopScore())); … … 921 1055 } 922 1056 923 1057 private void performMatching() { 924 matches = generateMatches(settings);1058 setMatches(generateMatches(settings)); 925 1059 926 1060 // populate unmatched objects 927 1061 List<OsmPrimitive> referenceOnly = new ArrayList<>(settings.getReferenceSelection()); … … 938 1072 939 1073 updateTabTitles(); 940 1074 941 matchTableModel.setMatches(matches);942 matches.addConflationListChangedListener(matchTableModel);943 matches.addConflationListChangedListener(conflateAction);944 matches.addConflationListChangedListener(removeAction);945 matches.addConflationListChangedListener(this);946 1075 settings.getSubjectDataSet().addDataSetListener(this); 947 1076 settings.getReferenceDataSet().addDataSetListener(this); 948 1077 // add conflation layer 949 1078 try { 950 1079 if (conflationLayer == null) { 951 1080 conflationLayer = new ConflationLayer(matches); 1081 } 1082 if (!Main.getLayerManager().containsLayer(conflationLayer)) { 952 1083 Main.getLayerManager().addLayer(conflationLayer); 953 1084 } 954 1085 } catch (Exception ex) { … … 974 1105 updateTabTitles(); 975 1106 } 976 1107 } 1108 1109 @Override 1110 public void layerAdded(LayerAddEvent e) { 1111 // Nothing to do 1112 } 1113 1114 @Override 1115 public void layerRemoving(LayerRemoveEvent e) { 1116 Layer removedLayer = e.getRemovedLayer(); 1117 if (settings != null) { 1118 boolean shouldclearReferenceSettings = removedLayer == settings.getReferenceLayer(); 1119 boolean shouldclearSubjectSettings = removedLayer == settings.getSubjectLayer(); 1120 if (shouldclearReferenceSettings || shouldclearSubjectSettings) { 1121 clear(shouldclearReferenceSettings, shouldclearSubjectSettings, true); 1122 } 1123 } 1124 this.settingsDialog.layerRemoving(e); 1125 } 1126 1127 @Override 1128 public void layerOrderChanged(LayerOrderChangeEvent e) { 1129 // Nothing to do 1130 } 977 1131 } -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationUtils.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import java.util.ArrayList; 5 6 import java.util.Collection; 6 7 import java.util.Collections; 7 8 import java.util.List; 9 import java.util.stream.Collectors; 10 8 11 import org.openstreetmap.josm.Main; 9 12 import org.openstreetmap.josm.data.coor.EastNorth; 10 13 import org.openstreetmap.josm.data.coor.LatLon; … … 15 18 16 19 public final class ConflationUtils { 17 20 21 private ConflationUtils() {} 22 18 23 public static EastNorth getCenter(OsmPrimitive prim) { 19 24 LatLon center = prim.getBBox().getTopLeft().getCenter(prim.getBBox().getBottomRight()); 20 25 return Main.map.mapView.getProjection().latlon2eastNorth(center); 21 26 } 22 27 23 public static List<PrimitiveData> copyObjects(DataSet sourceDataSet, OsmPrimitive primitive ) {24 return copyObjects(sourceDataSet, Collections.singleton(primitive) );28 public static List<PrimitiveData> copyObjects(DataSet sourceDataSet, OsmPrimitive primitive, DataSet destDataSet) { 29 return copyObjects(sourceDataSet, Collections.singleton(primitive), destDataSet); 25 30 } 26 31 27 public static List<PrimitiveData> copyObjects(DataSet sourceDataSet, Collection<OsmPrimitive> primitives ) {32 public static List<PrimitiveData> copyObjects(DataSet sourceDataSet, Collection<OsmPrimitive> primitives, DataSet destDataSet) { 28 33 29 34 Collection<OsmPrimitive> origSelection = sourceDataSet.getSelected(); 30 35 sourceDataSet.setSelected(primitives); … … 34 39 //restore selection 35 40 sourceDataSet.setSelected(origSelection); 36 41 37 List<PrimitiveData> newObjects = new ArrayList<>(); 38 for (OsmPrimitive p : newDataSet.allPrimitives()) { 39 newObjects.add(p.save()); 40 } 41 return newObjects; 42 return newDataSet.allPrimitives().stream() 43 .filter(p -> destDataSet.getPrimitiveById(p.getPrimitiveId()) == null) 44 .map(p -> p.save()) 45 .collect(Collectors.toCollection(ArrayList::new)); 42 46 } 43 47 } -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/MatchFinderPanel.java
1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.conflation; 2 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 26 27 import com.vividsolutions.jcs.conflate.polygonmatch.IdenticalFeatureFilter; 27 28 import com.vividsolutions.jcs.conflate.polygonmatch.OneToOneFCMatchFinder; 28 29 29 30 30 public class MatchFinderPanel extends JPanel { 31 31 private final JComboBox<String> matchFinderComboBox; 32 32 private final CentroidDistanceComponent centroidDistanceComponent; … … 35 35 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 36 36 setBorder(new CompoundBorder( 37 37 BorderFactory.createTitledBorder(tr("Match finder settings")), 38 BorderFactory.createEmptyBorder(5, 5,5,5)));38 BorderFactory.createEmptyBorder(5, 5, 5, 5))); 39 39 40 40 String[] matchFinderStrings = {"DisambiguatingFCMatchFinder", "OneToOneFCMatchFinder" }; 41 41 matchFinderComboBox = new JComboBox<>(matchFinderStrings); … … 72 72 abstract class DistanceComponent extends AbstractScoreComponent { 73 73 SpinnerNumberModel threshDistanceSpinnerModel; 74 74 75 publicDistanceComponent(String title) {75 DistanceComponent(String title) { 76 76 setBorder(new CompoundBorder( 77 77 BorderFactory.createTitledBorder(tr(title)), 78 BorderFactory.createEmptyBorder(5, 5,5,5)));78 BorderFactory.createEmptyBorder(5, 5, 5, 5))); 79 79 80 80 JPanel panel = new JPanel(); 81 81 panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS)); … … 99 99 } 100 100 101 101 class CentroidDistanceComponent extends DistanceComponent { 102 publicCentroidDistanceComponent() {102 CentroidDistanceComponent() { 103 103 super(tr("Centroid distance")); 104 104 } 105 105 … … 112 112 } 113 113 114 114 class HausdorffDistanceComponent extends DistanceComponent { 115 publicHausdorffDistanceComponent() {115 HausdorffDistanceComponent() { 116 116 super(tr("Hausdorff distance")); 117 117 } 118 118 -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/OsmFeature.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import com.vividsolutions.jump.feature.AbstractBasicFeature; … … 16 17 /** 17 18 * Create a copy of the OSM geometry 18 19 * TODO: update from underlying primitive 19 * @param prim20 20 */ 21 21 public OsmFeature(OsmPrimitive prim, JTSConverter jtsConverter) { 22 22 super(new FeatureSchema()); -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SettingsDialog.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import static org.openstreetmap.josm.tools.I18n.tr; … … 26 27 import org.openstreetmap.josm.data.osm.Relation; 27 28 import org.openstreetmap.josm.data.osm.Way; 28 29 import org.openstreetmap.josm.gui.ExtendedDialog; 30 import org.openstreetmap.josm.gui.layer.Layer; 29 31 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 32 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 30 33 import org.openstreetmap.josm.tools.ImageProvider; 31 34 32 35 /** … … 92 95 93 96 referencePanel.setBorder(new CompoundBorder( 94 97 BorderFactory.createTitledBorder(tr("Reference")), 95 BorderFactory.createEmptyBorder(5, 5,5,5)));98 BorderFactory.createEmptyBorder(5, 5, 5, 5))); 96 99 referencePanel.setAlignmentX(LEFT_ALIGNMENT); 97 100 referencePanel.setLayout(new BoxLayout(referencePanel, 98 101 BoxLayout.PAGE_AXIS)); … … 129 132 130 133 subjectPanel.setBorder(new CompoundBorder( 131 134 BorderFactory.createTitledBorder(tr("Subject")), 132 BorderFactory.createEmptyBorder(5, 5,5,5)));135 BorderFactory.createEmptyBorder(5, 5, 5, 5))); 133 136 subjectPanel.setAlignmentX(LEFT_ALIGNMENT); 134 137 subjectPanel.setLayout(new BoxLayout(subjectPanel, BoxLayout.PAGE_AXIS)); 135 138 … … 172 175 173 176 /** 174 177 * Matches are actually generated in windowClosed event in ConflationToggleDialog 175 *176 * @param buttonIndex177 * @param evt178 178 */ 179 179 @Override 180 180 protected void buttonAction(int buttonIndex, ActionEvent evt) { 181 181 // "Generate matches" as clicked 182 182 if (buttonIndex == 0) { 183 183 if (referenceSelection.isEmpty() || subjectSelection.isEmpty()) { 184 JOptionPane.showMessageDialog(Main.parent, tr("Selections must be made for both reference and subject."), tr("Incomplete selections"), JOptionPane.ERROR_MESSAGE); 184 JOptionPane.showMessageDialog(Main.parent, 185 tr("Selections must be made for both reference and subject."), tr("Incomplete selections"), 186 JOptionPane.ERROR_MESSAGE); 185 187 return; 186 188 } 187 189 } … … 220 222 221 223 class RestoreSubjectAction extends JosmAction { 222 224 223 publicRestoreSubjectAction() {225 RestoreSubjectAction() { 224 226 super(tr("Restore"), null, tr("Restore subject selection"), null, false); 225 227 } 226 228 … … 236 238 237 239 class RestoreReferenceAction extends JosmAction { 238 240 239 publicRestoreReferenceAction() {241 RestoreReferenceAction() { 240 242 super(tr("Restore"), null, tr("Restore reference selection"), null, false); 241 243 } 242 244 … … 252 254 253 255 class FreezeSubjectAction extends JosmAction { 254 256 255 publicFreezeSubjectAction() {257 FreezeSubjectAction() { 256 258 super(tr("Freeze"), null, tr("Freeze subject selection"), null, false); 257 259 } 258 260 … … 267 269 // subjectDataSet.addDataSetListener(tableModel); FIXME: 268 270 subjectLayer = Main.getLayerManager().getEditLayer(); 269 271 if (subjectDataSet == null || subjectLayer == null) { 270 JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."), tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE); 272 JOptionPane.showMessageDialog(Main.parent, 273 tr("No valid OSM data layer present."), tr("Error freezing selection"), 274 JOptionPane.ERROR_MESSAGE); 271 275 return; 272 276 } 273 277 subjectSelection.clear(); 274 278 subjectSelection.addAll(subjectDataSet.getSelected()); 275 279 if (subjectSelection.isEmpty()) { 276 JOptionPane.showMessageDialog(Main.parent, tr("Nothing is selected, please try again."), tr("Empty selection"), JOptionPane.ERROR_MESSAGE); 280 JOptionPane.showMessageDialog(Main.parent, 281 tr("Nothing is selected, please try again."), tr("Empty selection"), 282 JOptionPane.ERROR_MESSAGE); 277 283 return; 278 284 } 279 285 update(); … … 282 288 283 289 class FreezeReferenceAction extends JosmAction { 284 290 285 publicFreezeReferenceAction() {291 FreezeReferenceAction() { 286 292 super(tr("Freeze"), null, tr("Freeze reference selection"), null, false); 287 293 } 288 294 … … 297 303 // referenceDataSet.addDataSetListener(this); FIXME: 298 304 referenceLayer = Main.getLayerManager().getEditLayer(); 299 305 if (referenceDataSet == null || referenceLayer == null) { 300 JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."), tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE); 306 JOptionPane.showMessageDialog(Main.parent, 307 tr("No valid OSM data layer present."), tr("Error freezing selection"), 308 JOptionPane.ERROR_MESSAGE); 301 309 return; 302 310 } 303 311 referenceSelection.clear(); 304 312 referenceSelection.addAll(referenceDataSet.getSelected()); 305 313 if (referenceSelection.isEmpty()) { 306 JOptionPane.showMessageDialog(Main.parent, tr("Nothing is selected, please try again."), tr("Empty selection"), JOptionPane.ERROR_MESSAGE); 314 JOptionPane.showMessageDialog(Main.parent, 315 tr("Nothing is selected, please try again."), tr("Empty selection"), 316 JOptionPane.ERROR_MESSAGE); 307 317 return; 308 318 } 309 319 update(); … … 331 341 subjectLayerLabel.setText(subjectLayer.getName()); 332 342 subjectSelectionLabel.setText(tr("{0}: {1} / {2}: {3} / {4}: {5}", 333 343 "Relations", numRelations, "Ways", numWays, "Nodes", numNodes)); 344 } else { 345 subjectLayerLabel.setText("(none)"); 346 subjectSelectionLabel.setText(tr("{0}: 0 / {1}: 0 / {2}: 0", 347 "Relations", "Ways", "Nodes")); 334 348 } 335 349 numNodes = 0; 336 350 numWays = 0; … … 348 362 referenceLayerLabel.setText(referenceLayer.getName()); 349 363 referenceSelectionLabel.setText(tr("{0}: {1} / {2}: {3} / {4}: {5}", 350 364 "Relations", numRelations, "Ways", numWays, "Nodes", numNodes)); 365 } else { 366 referenceLayerLabel.setText("(none)"); 367 referenceSelectionLabel.setText(tr("{0}: 0 / {1}: 0 / {2}: 0", 368 "Relations", "Ways", "Nodes")); 351 369 } 352 370 353 371 //FIXME: properly update match finder settings 354 372 } 373 374 /** 375 * To be called when a layer is removed. 376 * Clear any reference to the removed layer. 377 * @param e the layer remove event. 378 */ 379 public void layerRemoving(LayerRemoveEvent e) { 380 Layer removedLayer = e.getRemovedLayer(); 381 this.clear(removedLayer == referenceLayer, removedLayer == subjectLayer); 382 } 383 384 /** 385 * Clear some settings. 386 * @param shouldClearReference if "Reference" settings should be cleared. 387 * @param shouldClearSubject if "Subject" settings should be cleared. 388 */ 389 public void clear(boolean shouldClearReference, boolean shouldClearSubject) { 390 if (shouldClearReference || shouldClearSubject) { 391 if (shouldClearReference) { 392 referenceLayer = null; 393 referenceDataSet = null; 394 referenceSelection.clear(); 395 } 396 if (shouldClearSubject) { 397 subjectLayer = null; 398 subjectDataSet = null; 399 subjectSelection.clear(); 400 } 401 update(); 402 } 403 } 404 355 405 } -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SimpleMatch.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 42 43 public Object getDistance() { 43 44 return distance; 44 45 } 45 } 46 Pas de fin de ligne à la fin du fichier 46 } -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SimpleMatchList.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 import java.util.*; 5 import java.util.ArrayList; 6 import java.util.Collection; 7 import java.util.Collections; 8 import java.util.Iterator; 9 import java.util.LinkedList; 10 import java.util.List; 5 11 import java.util.concurrent.CopyOnWriteArrayList; 6 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 7 13 … … 148 154 public void addConflationListChangedListener(SimpleMatchListListener listener) { 149 155 listeners.addIfAbsent(listener); 150 156 } 157 158 public void removeConflationListChangedListener(SimpleMatchListListener listener) { 159 listeners.remove(listener); 160 } 161 162 public void removeAllConflationListChangedListener() { 163 listeners.clear(); 164 } 151 165 152 public void fireListChanged() {166 public void fireListChanged() { 153 167 for (SimpleMatchListListener l : listeners) { 154 168 l.simpleMatchListChanged(this); 155 169 } 156 170 } 157 171 158 public void fireSelectionChanged() {172 public void fireSelectionChanged() { 159 173 for (SimpleMatchListListener l : listeners) { 160 174 l.simpleMatchSelectionChanged(selected); 161 175 } … … 167 181 168 182 /** 169 183 * Set which {@see SimpleMatch} is currently selected. Set to null to clear selection. 170 * @param match171 184 */ 172 185 public void setSelected(SimpleMatch match) { 173 186 if (match != null) … … 184 197 selected.addAll(matches); 185 198 fireSelectionChanged(); 186 199 } 187 } 188 Pas de fin de ligne à la fin du fichier 200 } -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SimpleMatchListListener.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import java.util.Collection; … … 10 11 * 11 12 * @param list The new list. 12 13 */ 13 publicvoid simpleMatchListChanged(SimpleMatchList list);14 void simpleMatchListChanged(SimpleMatchList list); 14 15 15 16 /** 16 17 * Informs the listener that the conflation list selection has changed. 17 18 * 18 19 * @param selected The newly selected conflation match. 19 20 */ 20 public void simpleMatchSelectionChanged(Collection<SimpleMatch> selected); 21 } 22 Pas de fin de ligne à la fin du fichier 21 void simpleMatchSelectionChanged(Collection<SimpleMatch> selected); 22 } -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SimpleMatchSettings.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import com.vividsolutions.jcs.conflate.polygonmatch.FCMatchFinder; -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SimpleMatchesTableModel.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import java.util.Collection; … … 16 17 17 18 private SimpleMatchList matches = null; 18 19 // TODO: make columns dynamic 19 private final staticString[] columnNames = {tr("Reference"), tr("Subject"), "Distance (m)", "Score", "Tags"};20 private static final String[] columnNames = {tr("Reference"), tr("Subject"), "Distance (m)", "Score", "Tags"}; 20 21 21 22 @Override 22 23 public int getColumnCount() { … … 70 71 71 72 @Override 72 73 public Class<?> getColumnClass(int c) { 73 return getValueAt(0, c).getClass(); 74 Object value = getValueAt(0, c); 75 if (value != null) { 76 return value.getClass(); 77 } else { 78 return Object.class; 79 } 74 80 } 75 81 76 82 /** … … 84 90 * @param matches the matches to set 85 91 */ 86 92 public void setMatches(SimpleMatchList matches) { 87 this.matches = matches; 88 fireTableDataChanged(); 93 if (matches != this.matches) { 94 if (this.matches != null) { 95 this.matches.removeConflationListChangedListener(this); 96 } 97 this.matches = matches; 98 if (matches != null) { 99 matches.addConflationListChangedListener(this); 100 } 101 fireTableDataChanged(); 102 } 89 103 } 90 104 91 105 @Override -
josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/UnmatchedObjectListModel.java
1 // License: GPL. See LICENSE file for details. Copyright 2012 by Josh Doe and others. 1 // License: GPL. For details, see LICENSE file. 2 // Copyright 2012 by Josh Doe and others. 2 3 package org.openstreetmap.josm.plugins.conflation; 3 4 4 5 import java.util.Collection;
