Changeset 27959 in osm for applications/editors/josm/plugins
- Timestamp:
- 2012-03-01T06:08:16+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/conflation
- Files:
-
- 8 added
- 4 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/conflation/build.xml
r27852 r27959 106 106 <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.conflation.ConflationPlugin"/> 107 107 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/> 108 <attribute name="Plugin-Description" value=" Tool for conflating (merging) data"/>108 <attribute name="Plugin-Description" value="(Warning: Experimental!) Tool for conflating (merging) data"/> 109 109 <attribute name="Plugin-Icon" value="images/conflation.png"/> 110 110 <attribute name="Plugin-Requires" value="utilsplugin2"/> -
applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java
r27751 r27959 4 4 import java.awt.BasicStroke; 5 5 import java.awt.Color; 6 import javax.swing.Action;7 import javax.swing.Icon;8 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;9 import static org.openstreetmap.josm.tools.I18n.tr;10 11 6 import java.awt.Graphics2D; 12 7 import java.awt.Point; 13 8 import java.awt.geom.GeneralPath; 14 9 import java.util.Iterator; 15 import java .util.List;16 import java .util.Map;10 import javax.swing.Action; 11 import javax.swing.Icon; 17 12 import org.openstreetmap.josm.actions.RenameLayerAction; 18 19 20 13 import org.openstreetmap.josm.data.Bounds; 21 14 import org.openstreetmap.josm.data.osm.DataSet; 22 15 import org.openstreetmap.josm.data.osm.Node; 23 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 24 18 import org.openstreetmap.josm.gui.MapView; 25 19 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; … … 28 22 import org.openstreetmap.josm.gui.layer.Layer; 29 23 import org.openstreetmap.josm.gui.layer.Layer.SeparatorLayerAction; 30 import org.openstreetmap.josm.plugins.conflation.ConflationOptionsPanel.ConflationCandidate;24 import static org.openstreetmap.josm.tools.I18n.tr; 31 25 import org.openstreetmap.josm.tools.ImageProvider; 32 26 … … 37 31 */ 38 32 public class ConflationLayer extends Layer implements LayerChangeListener { 39 protected List<ConflationCandidate>candidates;33 protected ConflationCandidateList candidates; 40 34 protected ConflationCandidate selectedCandidate = null; 41 35 42 public ConflationLayer(DataSet ds, List<ConflationCandidate>candidates) {36 public ConflationLayer(DataSet ds, ConflationCandidateList candidates) { 43 37 super(tr("Conflation")); 44 38 MapView.addLayerChangeListener(this); … … 66 60 g2.setColor(Color.cyan); 67 61 } 68 OsmPrimitive src = candidate.getSource ();69 OsmPrimitive tgt = candidate.getTarget ();62 OsmPrimitive src = candidate.getSourcePrimitive(); 63 OsmPrimitive tgt = candidate.getTargetPrimitive(); 70 64 if (src != null && tgt != null) { 71 65 GeneralPath path = new GeneralPath(); 72 66 // we have a pair, so draw line between them, FIXME: not good to use getCenter() from here, move to utils? 73 Point p1 = mv.getPoint(Conflation OptionsPanel.getCenter(src));74 Point p2 = mv.getPoint(Conflation OptionsPanel.getCenter(tgt));67 Point p1 = mv.getPoint(ConflationUtils.getCenter(src)); 68 Point p2 = mv.getPoint(ConflationUtils.getCenter(tgt)); 75 69 path.moveTo(p1.x, p1.y); 76 70 path.lineTo(p2.x, p2.y); … … 124 118 for (Iterator<ConflationCandidate> it = this.candidates.iterator(); it.hasNext();) { 125 119 ConflationCandidate candidate = it.next(); 126 OsmPrimitive src = candidate.getSource ();127 OsmPrimitive tgt = candidate.getTarget ();120 OsmPrimitive src = candidate.getSourcePrimitive(); 121 OsmPrimitive tgt = candidate.getTargetPrimitive(); 128 122 if (src != null && src instanceof Node) 129 123 v.visit((Node)src); … … 166 160 * @return the set of conflicts currently managed in this layer 167 161 */ 168 public List<ConflationCandidate>getCandidates() {162 public ConflationCandidateList getCandidates() { 169 163 return this.candidates; 170 164 } -
applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationPlugin.java
r27755 r27959 2 2 package org.openstreetmap.josm.plugins.conflation; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;5 import static org.openstreetmap.josm.tools.I18n.marktr;6 import static org.openstreetmap.josm.tools.I18n.tr;7 8 4 import java.awt.event.KeyEvent; 9 import java.io.IOException; 10 import java.util.logging.FileHandler; 11 import java.util.logging.Logger; 12 import javax.swing.JMenu; 13 import javax.swing.JOptionPane; 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.gui.MainMenu; 5 import org.openstreetmap.josm.gui.MapFrame; 16 6 import org.openstreetmap.josm.plugins.Plugin; 17 7 import org.openstreetmap.josm.plugins.PluginInformation; 8 import org.openstreetmap.josm.tools.Shortcut; 18 9 10 import static org.openstreetmap.josm.tools.I18n.tr; 19 11 20 12 public class ConflationPlugin extends Plugin { 21 13 22 ConflationAction action = null; 23 Logger logger; 14 private ConflationToggleDialog dialog = null; 24 15 25 16 /** … … 28 19 public ConflationPlugin(PluginInformation info) { 29 20 super(info); 21 } 30 22 31 try { 32 logger = Logger.getLogger(ConflationPlugin.class.getName()); 33 FileHandler fh = new FileHandler("C:/temp/log.txt"); 34 logger.addHandler(fh); 35 } 36 catch (IOException e) { 37 JOptionPane.showMessageDialog(Main.parent, "Failed to create log file", 38 "Failed to create logger", JOptionPane.ERROR_MESSAGE); 39 } 40 41 try { 42 JMenu conflationMenu = Main.main.menu.addMenu(marktr("Conflation"), KeyEvent.VK_R, 43 Main.main.menu.defaultMenuPos, ht("/Plugin/Conflation")); 44 MainMenu.add(conflationMenu, new ConflationAction()); 45 46 47 } catch (Exception e) { 48 JOptionPane.showMessageDialog(Main.parent, e.toString(), 49 "Error adding conflation menu item", JOptionPane.ERROR_MESSAGE); 23 // add dialog the first time the mapframe is loaded 24 @Override 25 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 26 if (oldFrame == null && newFrame != null) { 27 if (dialog == null) { 28 Shortcut shortcut = Shortcut.registerShortcut("Conflation", tr("Toggle: {0}", tr("Open Conflation")), 29 KeyEvent.VK_0, Shortcut.ALT_SHIFT); 30 String name = "Conflation"; 31 String tooltip = "Activates the conflation plugin"; 32 dialog = new ConflationToggleDialog(tr(name), "conflation.png", tr(tooltip), 33 shortcut, 150, this); 34 } 35 newFrame.addToggleDialog(dialog); 50 36 } 51 37 }
Note:
See TracChangeset
for help on using the changeset viewer.