Changeset 27742 in osm for applications/editors/josm/plugins/conflation/src
- Timestamp:
- 2012-02-10T04:42:04+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java
r26023 r27742 12 12 import java.awt.Point; 13 13 import java.awt.geom.GeneralPath; 14 import java.util.Iterator; 15 import java.util.List; 16 import java.util.Map; 14 17 import org.openstreetmap.josm.actions.RenameLayerAction; 15 18 16 19 17 20 import org.openstreetmap.josm.data.Bounds; 18 import org.openstreetmap.josm.data.conflict.Conflict;19 import org.openstreetmap.josm.data.conflict.ConflictCollection;20 21 import org.openstreetmap.josm.data.osm.DataSet; 21 22 import org.openstreetmap.josm.data.osm.Node; … … 27 28 import org.openstreetmap.josm.gui.layer.Layer; 28 29 import org.openstreetmap.josm.gui.layer.Layer.SeparatorLayerAction; 29 import org.openstreetmap.josm. gui.layer.OsmDataLayer;30 import org.openstreetmap.josm.plugins.conflation.ConflationOptionsPanel.ConflationCandidate; 30 31 import org.openstreetmap.josm.tools.ImageProvider; 31 32 … … 35 36 * @author Josh Doe <josh@joshdoe.com> 36 37 */ 37 public class ConflationLayer extends OsmDataLayer implements LayerChangeListener { 38 // TODO: this really shouldn't be OsmDataLayer, but easy to use conflict dialog 39 40 ConflictCollection conflicts; 41 42 public ConflationLayer(DataSet ds, ConflictCollection conflicts) { 43 super(ds, tr("Conflation symbols"), null); 38 public class ConflationLayer extends Layer implements LayerChangeListener { 39 protected List<ConflationCandidate> candidates; 40 protected ConflationCandidate selectedCandidate = null; 41 42 public ConflationLayer(DataSet ds, List<ConflationCandidate> candidates) { 43 super(tr("Conflation")); 44 44 MapView.addLayerChangeListener(this); 45 this.c onflicts = conflicts;45 this.candidates = candidates; 46 46 } 47 47 … … 54 54 Graphics2D g2 = g; 55 55 BasicStroke line = new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); 56 g2.setColor(Color.blue);57 56 g2.setStroke(line); 58 59 GeneralPath path = new GeneralPath();60 57 61 58 final double PHI = Math.toRadians(20); 62 59 final double cosPHI = Math.cos(PHI); 63 60 final double sinPHI = Math.sin(PHI); 64 65 for (Conflict c : conflicts) { 66 OsmPrimitive p = c.getMy(); 67 OsmPrimitive q = c.getTheir(); 68 if (p != null && q != null) { 61 for (Iterator<ConflationCandidate> it = this.candidates.iterator(); it.hasNext();) { 62 ConflationCandidate candidate = it.next(); 63 if (candidate.equals(selectedCandidate)) { 64 g2.setColor(Color.blue); 65 } else { 66 g2.setColor(Color.cyan); 67 } 68 OsmPrimitive src = candidate.getSource(); 69 OsmPrimitive tgt = candidate.getTarget(); 70 if (src != null && tgt != null) { 71 GeneralPath path = new GeneralPath(); 69 72 // we have a pair, so draw line between them, FIXME: not good to use getCenter() from here, move to utils? 70 Point p1 = mv.getPoint(ConflationOptionsPanel.getCenter( p));71 Point p2 = mv.getPoint(ConflationOptionsPanel.getCenter( q));73 Point p1 = mv.getPoint(ConflationOptionsPanel.getCenter(src)); 74 Point p2 = mv.getPoint(ConflationOptionsPanel.getCenter(tgt)); 72 75 path.moveTo(p1.x, p1.y); 73 76 path.lineTo(p2.x, p2.y); … … 88 91 } 89 92 } 93 g2.draw(path); 90 94 } 91 // TODO: handle other than just Node->Node cases92 // TODO: draw color coded circle around unmatched nodes93 95 } 94 96 95 g2.draw(path);97 96 98 } 97 99 … … 120 122 @Override 121 123 public void visitBoundingBox(BoundingXYVisitor v) { 122 //TODO: handle Way/Relation types123 for (Conflict c : conflicts) {124 OsmPrimitive my = c.getMy();125 OsmPrimitive t heir = c.getTheir();126 if ( my!= null &&myinstanceof Node)127 v.visit((Node) my);128 if (t heir!= null && theirinstanceof Node)129 v.visit((Node)t heir);124 for (Iterator<ConflationCandidate> it = this.candidates.iterator(); it.hasNext();) { 125 ConflationCandidate candidate = it.next(); 126 OsmPrimitive src = candidate.getSource(); 127 OsmPrimitive tgt = candidate.getTarget(); 128 if (src != null && src instanceof Node) 129 v.visit((Node)src); 130 if (tgt != null && tgt instanceof Node) 131 v.visit((Node)tgt); 130 132 } 131 133 } … … 164 166 * @return the set of conflicts currently managed in this layer 165 167 */ 166 public ConflictCollection getConflicts() { 167 return conflicts; 168 public List<ConflationCandidate> getCandidates() { 169 return this.candidates; 170 } 171 172 public void setSelectedCandidate(ConflationCandidate c) { 173 selectedCandidate = c; 168 174 } 169 175 } -
applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.form
r26023 r27742 1 <?xml version="1. 1" encoding="UTF-8" ?>1 <?xml version="1.0" encoding="UTF-8" ?> 2 2 3 3 <Form version="1.6" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> … … 69 69 <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> 70 70 <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> 71 <TitledBorder title=" My Set"/>71 <TitledBorder title="Target Selection"/> 72 72 </Border> 73 73 </Property> … … 144 144 </Properties> 145 145 <Events> 146 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="freeze MySetButtonActionPerformed"/>146 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="freezeTargetSelectionActionPerformed"/> 147 147 </Events> 148 148 </Component> … … 201 201 <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> 202 202 <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> 203 <TitledBorder title=" Their Set"/>203 <TitledBorder title="Source Selection"/> 204 204 </Border> 205 205 </Property> … … 276 276 </Properties> 277 277 <Events> 278 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="freeze TheirSelectionButtonActionPerformed"/>278 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="freezeSourceSelectionActionPerformed"/> 279 279 </Events> 280 280 </Component> … … 360 360 <DimensionLayout dim="0"> 361 361 <Group type="103" groupAlignment="0" attributes="0"> 362 <Group type="102" alignment="1" attributes="0"> 363 <EmptySpace pref="578" max="32767" attributes="0"/> 364 <Component id="criteriaTabConflateButton" min="-2" max="-2" attributes="0"/> 365 <EmptySpace max="-2" attributes="0"/> 366 </Group> 367 <Group type="102" alignment="0" attributes="0"> 368 <EmptySpace max="-2" attributes="0"/> 369 <Component id="jPanel2" min="-2" max="-2" attributes="0"/> 370 <EmptySpace pref="292" max="32767" attributes="0"/> 362 <Group type="102" attributes="0"> 363 <EmptySpace max="-2" attributes="0"/> 364 <Group type="103" groupAlignment="0" attributes="0"> 365 <Group type="102" alignment="1" attributes="0"> 366 <EmptySpace min="0" pref="568" max="32767" attributes="0"/> 367 <Component id="criteriaTabConflateButton" min="-2" max="-2" attributes="0"/> 368 </Group> 369 <Group type="102" alignment="0" attributes="0"> 370 <Component id="jPanel2" min="-2" max="-2" attributes="0"/> 371 <EmptySpace min="0" pref="282" max="32767" attributes="0"/> 372 </Group> 373 </Group> 374 <EmptySpace max="-2" attributes="0"/> 371 375 </Group> 372 376 </Group> … … 491 495 <Component id="jLabel8" min="-2" max="-2" attributes="0"/> 492 496 <EmptySpace type="unrelated" max="-2" attributes="0"/> 493 <Component id=" useMyTagsButton" min="-2" max="-2" attributes="0"/>497 <Component id="replaceGeometryButton" min="-2" max="-2" attributes="0"/> 494 498 <EmptySpace type="unrelated" max="-2" attributes="0"/> 495 499 <Component id="useTheirTagsButton" min="-2" max="-2" attributes="0"/> 496 500 <EmptySpace type="unrelated" max="-2" attributes="0"/> 497 501 <Component id="jButton1" min="-2" max="-2" attributes="0"/> 498 <EmptySpace pref=" 300" max="32767" attributes="0"/>502 <EmptySpace pref="252" max="32767" attributes="0"/> 499 503 </Group> 500 504 </Group> … … 506 510 <Group type="103" groupAlignment="3" attributes="0"> 507 511 <Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/> 508 <Component id=" useMyTagsButton" alignment="3" min="-2" max="-2" attributes="0"/>512 <Component id="replaceGeometryButton" alignment="3" min="-2" max="-2" attributes="0"/> 509 513 <Component id="useTheirTagsButton" alignment="3" min="-2" max="-2" attributes="0"/> 510 514 <Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/> … … 516 520 </Layout> 517 521 <SubComponents> 518 <Component class="javax.swing.JButton" name=" useMyTagsButton">519 <Properties> 520 <Property name="text" type="java.lang.String" value=" My Tags"/>522 <Component class="javax.swing.JButton" name="replaceGeometryButton"> 523 <Properties> 524 <Property name="text" type="java.lang.String" value="Replace Geometry"/> 521 525 </Properties> 522 526 <Events> 523 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler=" useMyTagsButtonActionPerformed"/>527 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="replaceGeometryButtonActionPerformed"/> 524 528 </Events> 525 529 </Component> … … 541 545 </Component> 542 546 </SubComponents> 543 </Container>544 <Container class="javax.swing.JPanel" name="tagMergerPlaceholderPanel">545 <Properties>546 <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">547 <Dimension value="[661, 250]"/>548 </Property>549 </Properties>550 551 <Layout>552 <DimensionLayout dim="0">553 <Group type="103" groupAlignment="0" attributes="0">554 <EmptySpace min="0" pref="661" max="32767" attributes="0"/>555 </Group>556 </DimensionLayout>557 <DimensionLayout dim="1">558 <Group type="103" groupAlignment="0" attributes="0">559 <EmptySpace min="0" pref="150" max="32767" attributes="0"/>560 </Group>561 </DimensionLayout>562 </Layout>563 547 </Container> 564 548 <Component class="javax.swing.JButton" name="resolveButton"> -
applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.java
r26023 r27742 10 10 11 11 import java.awt.Component; 12 import java.util.ArrayList; 13 import java.util.HashSet; 14 15 import java.util.List; 16 import java.util.Set; 12 import java.util.*; 17 13 import javax.swing.DefaultListCellRenderer; 18 14 import javax.swing.Icon; … … 30 26 import org.openstreetmap.josm.Main; 31 27 import org.openstreetmap.josm.command.Command; 32 import org.openstreetmap.josm.data.conflict.Conflict;33 28 import org.openstreetmap.josm.data.conflict.ConflictCollection; 34 29 import org.openstreetmap.josm.data.conflict.IConflictListener; … … 39 34 import org.openstreetmap.josm.data.osm.TagCollection; 40 35 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 41 import org.openstreetmap.josm.gui.conflict.pair.ConflictResolver;42 36 import org.openstreetmap.josm.gui.layer.Layer; 43 37 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 38 39 import org.openstreetmap.josm.plugins.conflation.ConflationUtils.*; 44 40 45 41 /** … … 50 46 ConflationOptionsDialog dlg = null; 51 47 ConflationLayer conflationLayer = null; 52 DataSet myDataSet = null;53 DataSet theirDataSet = null;54 ArrayList<OsmPrimitive> mySelection = null;48 DataSet targetDataSet = null; 49 DataSet sourceDataSet = null; 50 ArrayList<OsmPrimitive> targetSelection = null; 55 51 ArrayList<OsmPrimitive> theirSelection = null; 56 OsmDataLayer myLayer = null;52 OsmDataLayer targetLayer = null; 57 53 OsmDataLayer theirLayer = null; 58 ConflictCollection conflicts = null;59 ConflictResolver conflictResolver;60 OsmPrimitive[][] pairs;61 int[][] assignment;62 54 MatchTableModel tableModel; 55 List<ConflationCandidate> candidates = null; 63 56 64 57 /** Creates new form ConflationPanel */ … … 66 59 initComponents(); 67 60 68 // add selection handler, to c hange ConflictResolver contents and center/zoom view61 // add selection handler, to center/zoom view 69 62 resultsTable.getSelectionModel().addListSelectionListener( 70 63 new MatchListSelectionHandler()); … … 76 69 resultsTable.getColumnModel().getColumn(4).setCellRenderer(cr); 77 70 78 // replace dummy panel with conflictResolver79 conflictResolver = new ConflictResolver();80 for (int i = 0; i < resultsPanel.getComponentCount(); i++) {81 if (resultsPanel.getComponent(i) == tagMergerPlaceholderPanel) {82 resultsPanel.add(conflictResolver, i);83 resultsPanel.remove(tagMergerPlaceholderPanel);84 break;85 }86 }87 resultsPanel.validate();88 89 71 this.dlg = dlg; 90 91 conflicts = new ConflictCollection();92 72 93 73 // set layer names to comboboxes … … 144 124 resultsTable = new javax.swing.JTable(); 145 125 jPanel1 = new javax.swing.JPanel(); 146 useMyTagsButton = new javax.swing.JButton();126 replaceGeometryButton = new javax.swing.JButton(); 147 127 jLabel8 = new javax.swing.JLabel(); 148 128 useTheirTagsButton = new javax.swing.JButton(); 149 129 jButton1 = new javax.swing.JButton(); 150 tagMergerPlaceholderPanel = new javax.swing.JPanel();151 130 resolveButton = new javax.swing.JButton(); 152 131 153 132 setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS)); 154 133 155 refSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(" My Set"));134 refSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Target Selection")); 156 135 157 136 freezeMySetButton.setText("Freeze Selection"); 158 137 freezeMySetButton.addActionListener(new java.awt.event.ActionListener() { 159 138 public void actionPerformed(java.awt.event.ActionEvent evt) { 160 freeze MySetButtonActionPerformed(evt);139 freezeTargetSelectionActionPerformed(evt); 161 140 } 162 141 }); … … 194 173 .addGroup(refSetPanelLayout.createSequentialGroup() 195 174 .addComponent(freezeMySetButton) 196 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 3 87, Short.MAX_VALUE)175 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 392, Short.MAX_VALUE) 197 176 .addComponent(restoreMySetButton)) 198 177 .addGroup(refSetPanelLayout.createSequentialGroup() … … 236 215 ); 237 216 238 nonRefSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(" Their Set"));217 nonRefSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Source Selection")); 239 218 240 219 freezeTheirSelectionButton.setText("Freeze Selection"); 241 220 freezeTheirSelectionButton.addActionListener(new java.awt.event.ActionListener() { 242 221 public void actionPerformed(java.awt.event.ActionEvent evt) { 243 freeze TheirSelectionButtonActionPerformed(evt);222 freezeSourceSelectionActionPerformed(evt); 244 223 } 245 224 }); … … 277 256 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, nonRefSetPanelLayout.createSequentialGroup() 278 257 .addComponent(freezeTheirSelectionButton) 279 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 3 87, Short.MAX_VALUE)258 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 392, Short.MAX_VALUE) 280 259 .addComponent(restoreTheirSetButton)) 281 260 .addGroup(nonRefSetPanelLayout.createSequentialGroup() … … 403 382 criteriaTabPanelLayout.setHorizontalGroup( 404 383 criteriaTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 405 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, criteriaTabPanelLayout.createSequentialGroup() 406 .addContainerGap(578, Short.MAX_VALUE) 407 .addComponent(criteriaTabConflateButton) 384 .addGroup(criteriaTabPanelLayout.createSequentialGroup() 385 .addContainerGap() 386 .addGroup(criteriaTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 387 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, criteriaTabPanelLayout.createSequentialGroup() 388 .addGap(0, 568, Short.MAX_VALUE) 389 .addComponent(criteriaTabConflateButton)) 390 .addGroup(criteriaTabPanelLayout.createSequentialGroup() 391 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 392 .addGap(0, 282, Short.MAX_VALUE))) 408 393 .addContainerGap()) 409 .addGroup(criteriaTabPanelLayout.createSequentialGroup()410 .addContainerGap()411 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)412 .addContainerGap(292, Short.MAX_VALUE))413 394 ); 414 395 criteriaTabPanelLayout.setVerticalGroup( … … 444 425 jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); 445 426 446 useMyTagsButton.setText("My Tags");447 useMyTagsButton.addActionListener(new java.awt.event.ActionListener() {448 public void actionPerformed(java.awt.event.ActionEvent evt) { 449 useMyTagsButtonActionPerformed(evt);427 replaceGeometryButton.setText("Replace Geometry"); 428 replaceGeometryButton.addActionListener(new java.awt.event.ActionListener() { 429 public void actionPerformed(java.awt.event.ActionEvent evt) { 430 replaceGeometryButtonActionPerformed(evt); 450 431 } 451 432 }); … … 466 447 .addComponent(jLabel8) 467 448 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 468 .addComponent( useMyTagsButton)449 .addComponent(replaceGeometryButton) 469 450 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 470 451 .addComponent(useTheirTagsButton) 471 452 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 472 453 .addComponent(jButton1) 473 .addContainerGap( 300, Short.MAX_VALUE))454 .addContainerGap(252, Short.MAX_VALUE)) 474 455 ); 475 456 jPanel1Layout.setVerticalGroup( … … 479 460 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 480 461 .addComponent(jLabel8) 481 .addComponent( useMyTagsButton)462 .addComponent(replaceGeometryButton) 482 463 .addComponent(useTheirTagsButton) 483 464 .addComponent(jButton1)) … … 486 467 487 468 resultsPanel.add(jPanel1); 488 489 tagMergerPlaceholderPanel.setPreferredSize(new java.awt.Dimension(661, 250));490 491 javax.swing.GroupLayout tagMergerPlaceholderPanelLayout = new javax.swing.GroupLayout(tagMergerPlaceholderPanel);492 tagMergerPlaceholderPanel.setLayout(tagMergerPlaceholderPanelLayout);493 tagMergerPlaceholderPanelLayout.setHorizontalGroup(494 tagMergerPlaceholderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)495 .addGap(0, 661, Short.MAX_VALUE)496 );497 tagMergerPlaceholderPanelLayout.setVerticalGroup(498 tagMergerPlaceholderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)499 .addGap(0, 150, Short.MAX_VALUE)500 );501 502 resultsPanel.add(tagMergerPlaceholderPanel);503 469 504 470 resolveButton.setText("Resolve"); … … 523 489 524 490 // some initialization 525 int n = mySelection.size();491 int n = targetSelection.size(); 526 492 int m = theirSelection.size(); 527 493 int maxLen = Math.max(n, m); … … 531 497 for (int i = 0; i < n; i++) { 532 498 for (int j = 0; j < m; j++) { 533 cost[i][j] = calcCost( mySelection.get(i), theirSelection.get(j));499 cost[i][j] = calcCost(targetSelection.get(i), theirSelection.get(j)); 534 500 } 535 501 } 536 502 537 503 // perform assignment using Hungarian algorithm 538 assignment = new int[maxLen][2]; 539 assignment = HungarianAlgorithm.hgAlgorithm(cost, "min"); 540 541 // create array of primitives based on indices from assignment 542 pairs = new OsmPrimitive[maxLen][2]; 504 int[][] assignment = HungarianAlgorithm.hgAlgorithm(cost, "min"); 505 OsmPrimitive target, source; 506 candidates = new LinkedList<ConflationCandidate>(); 543 507 for (int i = 0; i < maxLen; i++) { 544 508 if (assignment[i][0] < n) 545 pairs[i][0] = mySelection.get(assignment[i][0]);509 target = targetSelection.get(assignment[i][0]); 546 510 else 547 pairs[i][0]= null;511 target = null; 548 512 if (assignment[i][1] < m) 549 pairs[i][1]= theirSelection.get(assignment[i][1]);513 source = theirSelection.get(assignment[i][1]); 550 514 else 551 pairs[i][1]= null;552 553 if ( pairs[i][0]!= null &&pairs[i][1]!= null) {515 source = null; 516 517 if (target != null && source != null) { 554 518 // TODO: do something! 555 c onflicts.add(pairs[i][0], pairs[i][1]);519 candidates.add(new ConflationCandidate(source, target)); 556 520 } 557 521 } … … 559 523 // add conflation layer 560 524 try { 561 conflationLayer = new ConflationLayer( myLayer.data, conflicts);525 conflationLayer = new ConflationLayer(targetLayer.data, candidates); 562 526 Main.main.addLayer(conflationLayer); 563 527 } catch (Exception ex) { … … 568 532 resultsTable.setModel(tableModel); 569 533 570 conflictResolver.populate(conflicts.get(0));571 534 // print list of matched pairsalong with distance 572 535 // upon selection of one pair, highlight them and draw arrow … … 579 542 580 543 private void restoreMySetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restoreMySetButtonActionPerformed 581 if ( myLayer != null &&myDataSet != null &&mySelection != null && !mySelection.isEmpty()) {582 Main.map.mapView.setActiveLayer( myLayer);583 myLayer.setVisible(true);584 myDataSet.setSelected(mySelection);544 if (targetLayer != null && targetDataSet != null && targetSelection != null && !targetSelection.isEmpty()) { 545 Main.map.mapView.setActiveLayer(targetLayer); 546 targetLayer.setVisible(true); 547 targetDataSet.setSelected(targetSelection); 585 548 } 586 549 }//GEN-LAST:event_restoreMySetButtonActionPerformed 587 550 588 551 private void restoreTheirSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restoreTheirSetButtonActionPerformed 589 if (theirLayer != null && theirDataSet != null && theirSelection != null && !theirSelection.isEmpty()) {552 if (theirLayer != null && sourceDataSet != null && theirSelection != null && !theirSelection.isEmpty()) { 590 553 Main.map.mapView.setActiveLayer(theirLayer); 591 554 theirLayer.setVisible(true); 592 theirDataSet.setSelected(theirSelection);555 sourceDataSet.setSelected(theirSelection); 593 556 } 594 557 }//GEN-LAST:event_restoreTheirSetButtonActionPerformed 595 558 596 private void freeze MySetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_freezeMySetButtonActionPerformed597 myDataSet = Main.main.getCurrentDataSet();598 myLayer = Main.main.getEditLayer();599 if ( myDataSet == null ||myLayer == null) {559 private void freezeTargetSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_freezeTargetSelectionActionPerformed 560 targetDataSet = Main.main.getCurrentDataSet(); 561 targetLayer = Main.main.getEditLayer(); 562 if (targetDataSet == null || targetLayer == null) { 600 563 JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."), 601 564 tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE); 602 565 return; 603 566 } 604 mySelection = new ArrayList<OsmPrimitive>(myDataSet.getSelected());605 if ( mySelection.isEmpty()) {567 targetSelection = new ArrayList<OsmPrimitive>(targetDataSet.getSelected()); 568 if (targetSelection.isEmpty()) { 606 569 JOptionPane.showMessageDialog(Main.parent, tr("Nothing is selected, please try again."), 607 570 tr("Empty selection"), JOptionPane.ERROR_MESSAGE); … … 612 575 int numWays = 0; 613 576 int numRelations = 0; 614 for (OsmPrimitive p: mySelection) {577 for (OsmPrimitive p: targetSelection) { 615 578 switch(p.getType()) { 616 579 case NODE: numNodes++; break; … … 620 583 } 621 584 622 myLayerLabel.setText( myLayer.getName());585 myLayerLabel.setText(targetLayer.getName()); 623 586 myNodeCountLabel.setText(Integer.toString(numNodes)); 624 587 myWayCountLabel.setText(Integer.toString(numWays)); 625 588 myRelationCountLabel.setText(Integer.toString(numRelations)); 626 }//GEN-LAST:event_freeze MySetButtonActionPerformed627 628 private void freeze TheirSelectionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_freezeTheirSelectionButtonActionPerformed629 theirDataSet = Main.main.getCurrentDataSet();589 }//GEN-LAST:event_freezeTargetSelectionActionPerformed 590 591 private void freezeSourceSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_freezeSourceSelectionActionPerformed 592 sourceDataSet = Main.main.getCurrentDataSet(); 630 593 theirLayer = Main.main.getEditLayer(); 631 if ( theirDataSet == null || theirLayer == null) {594 if (sourceDataSet == null || theirLayer == null) { 632 595 JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."), 633 596 tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE); 634 597 return; 635 598 } 636 theirSelection = new ArrayList<OsmPrimitive>( theirDataSet.getSelected());599 theirSelection = new ArrayList<OsmPrimitive>(sourceDataSet.getSelected()); 637 600 if (theirSelection.isEmpty()) { 638 601 JOptionPane.showMessageDialog(Main.parent, tr("Nothing is selected, please try again."), … … 644 607 int numWays = 0; 645 608 int numRelations = 0; 646 for (OsmPrimitive p: mySelection) {609 for (OsmPrimitive p: theirSelection) { 647 610 switch(p.getType()) { 648 611 case NODE: numNodes++; break; … … 656 619 theirWayCountLabel.setText(Integer.toString(numWays)); 657 620 theirRelationCountLabel.setText(Integer.toString(numRelations)); 658 }//GEN-LAST:event_freezeTheirSelectionButtonActionPerformed 659 660 private void useMyTagsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useMyTagsButtonActionPerformed 661 int[] rows = resultsTable.getSelectedRows(); 662 }//GEN-LAST:event_useMyTagsButtonActionPerformed 621 }//GEN-LAST:event_freezeSourceSelectionActionPerformed 663 622 664 623 private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed … … 667 626 668 627 private void resolveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resolveButtonActionPerformed 669 if (!conflictResolver.isResolvedCompletely()) { 670 JOptionPane.showMessageDialog(Main.parent, tr("Unresolved differences remain, please fix remaining differences."), 671 tr("Conflict not resolved completely"), JOptionPane.ERROR_MESSAGE); 672 return; 673 } 674 Command cmd = conflictResolver.buildResolveCommand(); 675 Main.main.undoRedo.add(cmd); 628 // FIXME: perform replace geometry 629 //Main.main.undoRedo.add(cmd); 676 630 }//GEN-LAST:event_resolveButtonActionPerformed 631 632 private void replaceGeometryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_replaceGeometryButtonActionPerformed 633 634 }//GEN-LAST:event_replaceGeometryButtonActionPerformed 677 635 678 636 static public class LayerListCellRenderer extends DefaultListCellRenderer { … … 725 683 726 684 public int getRowCount() { 727 return c onflicts.size();685 return candidates.size(); 728 686 } 729 687 … … 735 693 public Object getValueAt(int row, int col) { 736 694 if (col == 0) 737 return c onflicts.get(row).getMy();695 return candidates.get(row).getSource(); 738 696 if (col == 1) 739 return c onflicts.get(row).getTheir();697 return candidates.get(row).getTarget(); 740 698 if (col == 4) { 741 699 HashSet<OsmPrimitive> set = new HashSet<OsmPrimitive>(); 742 set.add(c onflicts.get(row).getMy());743 set.add(c onflicts.get(row).getTheir());700 set.add(candidates.get(row).getSource()); 701 set.add(candidates.get(row).getTarget()); 744 702 TagCollection tags = TagCollection.unionOfAllPrimitives(set); 745 703 Set<String> keys = tags.getKeysWithMultipleValues(); … … 804 762 // only one item selected, show tags and zoom/center map 805 763 if (!lsm.isSelectionEmpty() && firstIndex == lastIndex) { 806 Conflict<?> c = conflicts.get(firstIndex); 807 conflictResolver.populate(c); 764 ConflationCandidate c = candidates.get(firstIndex); 765 766 conflationLayer.setSelectedCandidate(c); 767 768 targetDataSet.setSelected(Arrays.asList(c.getTarget(), c.getSource())); 808 769 809 770 ArrayList<OsmPrimitive> sel = new ArrayList<OsmPrimitive>(); 810 sel.add(c.get My());811 sel.add(c.getT heir());771 sel.add(c.getSource()); 772 sel.add(c.getTarget()); 812 773 813 774 BoundingXYVisitor box = new BoundingXYVisitor(); … … 835 796 System.err.println("1 conflict has been resolved."); 836 797 refreshView(); 798 } 799 800 public class ConflationCandidate { 801 protected OsmPrimitive source; 802 protected OsmPrimitive target; 803 804 public ConflationCandidate(OsmPrimitive source, OsmPrimitive target) { 805 if (source == null || target == null) { 806 throw new IllegalArgumentException("Invalid source or target"); 807 } 808 this.source = source; 809 this.target = target; 810 } 811 812 public OsmPrimitive getSource() { 813 return source; 814 } 815 816 public OsmPrimitive getTarget() { 817 return target; 818 } 837 819 } 838 820 … … 865 847 private javax.swing.JPanel objectTabPanel; 866 848 private javax.swing.JPanel refSetPanel; 849 private javax.swing.JButton replaceGeometryButton; 867 850 private javax.swing.JButton resolveButton; 868 851 private javax.swing.JButton restoreMySetButton; … … 871 854 private javax.swing.JTabbedPane resultsTabPanel; 872 855 private javax.swing.JTable resultsTable; 873 private javax.swing.JPanel tagMergerPlaceholderPanel;874 856 private javax.swing.JLabel theirLayerLabel; 875 857 private javax.swing.JLabel theirNodeCountLabel; 876 858 private javax.swing.JLabel theirRelationCountLabel; 877 859 private javax.swing.JLabel theirWayCountLabel; 878 private javax.swing.JButton useMyTagsButton;879 860 private javax.swing.JButton useTheirTagsButton; 880 861 // End of variables declaration//GEN-END:variables
Note:
See TracChangeset
for help on using the changeset viewer.