Changeset 30459 in osm for applications
- Timestamp:
- 2014-05-19T18:26:32+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/build.xml
r30419 r30459 5 5 <property name="commit.message" value="[josm_utilsplugin2]: select boundary by double-click; multitagger table highlights"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="7 001"/>7 <property name="plugin.main.version" value="7146"/> 8 8 9 9 <property name="plugin.author" value="Kalle Lampila, Upliner, Zverik, akks, joshdoe and others"/> -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/UtilsPlugin2.java
r30419 r30459 2 2 package org.openstreetmap.josm.plugins.utilsplugin2; 3 3 4 import java.awt.event.MouseAdapter;5 import java.awt.event.MouseEvent;6 import java.awt.event.MouseListener;7 4 import javax.swing.JMenu; 8 5 import javax.swing.JMenuItem; 9 import javax.swing.SwingUtilities;10 6 11 7 import org.openstreetmap.josm.Main; 12 8 import org.openstreetmap.josm.actions.search.SearchCompiler; 13 import org.openstreetmap.josm.data.coor.EastNorth;14 9 import org.openstreetmap.josm.gui.MainMenu; 15 10 import org.openstreetmap.josm.gui.MapFrame; … … 132 127 SearchCompiler.addMatchFactory(new UtilsSimpleMatchFactory()); 133 128 } 134 135 MouseListener mouseListener = new MouseAdapter() { 136 @Override 137 public void mouseReleased(final MouseEvent e) { 138 if (e.getButton()==MouseEvent.BUTTON1 && 139 e.getClickCount() > 1 && Main.isDisplayingMapView() && Main.map.mapMode == Main.map.mapModeSelect && 140 (0 == (e.getModifiersEx() & (MouseEvent.ALT_DOWN_MASK + MouseEvent.CTRL_DOWN_MASK + MouseEvent.SHIFT_DOWN_MASK) ))) { 141 SwingUtilities.invokeLater(new Runnable() { 142 @Override 143 public void run() { 144 EastNorth en = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 145 SelectBoundaryAction.selectByInternalPoint(en); 146 } 147 }); 148 } 149 } 150 }; 151 129 152 130 @Override 153 131 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { … … 182 160 drawArc.setEnabled(enabled); 183 161 multiTag.setEnabled(enabled); 184 if (oldFrame!=null && oldFrame.mapView!=null) oldFrame.mapView.removeMouseListener(mouseListener);185 if (newFrame!=null && newFrame.mapView!=null && Main.pref.getBoolean(UtilsPluginPreferences.PREF_DOUBLECLICK, true))186 newFrame.mapView.addMouseListener(mouseListener);187 162 } 188 163 -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/UtilsPluginPreferences.java
r30419 r30459 14 14 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 15 15 import java.awt.event.ActionListener; 16 import javax.swing.JCheckBox;17 16 import javax.swing.JPanel; 18 17 import javax.swing.ListSelectionModel; 19 18 import javax.swing.event.TableModelListener; 20 19 import javax.swing.table.DefaultTableModel; 21 import org.openstreetmap.josm.Main;22 20 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 23 21 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; … … 32 30 JButton loadButton; 33 31 JButton saveButton; 34 JCheckBox dblClick = new JCheckBox(tr("Double click selects object by its internal point"));35 public static final String PREF_DOUBLECLICK = "utilsplugin2.doubleclick";36 32 37 33 public UtilsPluginPreferences() { … … 81 77 + " Your can manually load settings from file <b>customurl.txt</b> in JOSM folder")); 82 78 83 dblClick.setSelected(Main.pref.getBoolean(PREF_DOUBLECLICK, true));84 all.add(dblClick, GBC.std().insets(5,10,0,0));85 86 79 all.add(new JLabel(tr("Custom URL configuration")),GBC.std().insets(5,10,0,0)); 87 80 all.add(resetButton,GBC.std().insets(25,10,0,0)); … … 134 127 List<String> lst = readItemsFromTable(); 135 128 URLList.updateURLList(lst); 136 Main.pref.put(PREF_DOUBLECLICK, dblClick.isSelected()); 129 137 130 return false; 138 131 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectBoundaryAction.java
r30419 r30459 9 9 import java.awt.event.KeyEvent; 10 10 import java.util.Collection; 11 import java.util.Collections;12 11 import java.util.HashSet; 13 12 import java.util.Set; 14 import java.util.TreeMap;15 13 16 14 import javax.swing.JOptionPane; … … 18 16 19 17 import org.openstreetmap.josm.actions.JosmAction; 20 import org.openstreetmap.josm.data.coor.EastNorth; 21 import org.openstreetmap.josm.data.osm.BBox; 18 import org.openstreetmap.josm.actions.SelectByInternalPointAction; 22 19 import org.openstreetmap.josm.data.osm.Node; 23 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 24 import org.openstreetmap.josm.data.osm.Relation;25 import org.openstreetmap.josm.data.osm.RelationMember;26 21 import org.openstreetmap.josm.data.osm.Way; 27 22 import org.openstreetmap.josm.gui.Notification; 28 import org.openstreetmap.josm.tools.Geometry;29 23 30 24 import org.openstreetmap.josm.tools.Shortcut; … … 43 37 putValue("help", ht("/Action/SelectAreaBoundary")); 44 38 } 45 46 public static void selectByInternalPoint(EastNorth e) { 47 //Node n= new Node(e); 48 TreeMap<Double, OsmPrimitive> found = new TreeMap<>(); 49 for (Way w: getCurrentDataSet().getWays()) { 50 if (w.isUsable() && w.isClosed() ) { 51 //if (Geometry.nodeInsidePolygon(n, w.getNodes())) { 52 if (NodeWayUtils.isPointInsidePolygon(e, NodeWayUtils.getWayPoints(w))) { 53 found.put(Geometry.closedWayArea(w), w); 54 } 55 } 56 } 57 for (Relation r: getCurrentDataSet().getRelations()) { 58 if (r.isUsable() && r.isMultipolygon()) { 59 //if (Geometry.isNodeInsideMultiPolygon(n, r, null)) { 60 if (NodeWayUtils.isPointInsideMultipolygon(e, r)) { 61 for (RelationMember m: r.getMembers()) { 62 if (m.isWay() && m.getWay().isClosed()) { 63 found.values().remove(m.getWay()); 64 } 65 } 66 // estimate multipolygon size by its bounding box area 67 BBox bBox = r.getBBox(); 68 EastNorth en1 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getTopLeft()); 69 EastNorth en2 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getBottomRight()); 70 double s = Math.abs((en1.east()-en2.east())*(en1.north()-en2.north())); 71 if (s==0) s=1e8; 72 found.put(s, r); 73 } 74 } 75 } 76 77 if (!found.isEmpty()) { 78 getCurrentDataSet().setSelected(Collections.singletonList( 79 found.firstEntry().getValue())); 80 } 81 } 82 39 83 40 @Override 84 41 public void actionPerformed(ActionEvent e) { … … 101 58 } else { 102 59 Point p = Main.map.mapView.getMousePosition(); 103 selectByInternalPoint(Main.map.mapView.getEastNorth(p.x, p.y));60 SelectByInternalPointAction.performSelection(Main.map.mapView.getEastNorth(p.x, p.y), false, false); 104 61 return; 105 62 }
Note:
See TracChangeset
for help on using the changeset viewer.