Changeset 30459 in osm for applications


Ignore:
Timestamp:
2014-05-19T18:26:32+02:00 (11 years ago)
Author:
simon04
Message:

JOSM/utilsplugin2 - see #josm10037 - Double-click selection mode has been integrated in JOSM core

Location:
applications/editors/josm/plugins/utilsplugin2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/build.xml

    r30419 r30459  
    55    <property name="commit.message" value="[josm_utilsplugin2]: select boundary by double-click; multitagger table highlights"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="7001"/>
     7    <property name="plugin.main.version" value="7146"/>
    88
    99    <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  
    22package org.openstreetmap.josm.plugins.utilsplugin2;
    33
    4 import java.awt.event.MouseAdapter;
    5 import java.awt.event.MouseEvent;
    6 import java.awt.event.MouseListener;
    74import javax.swing.JMenu;
    85import javax.swing.JMenuItem;
    9 import javax.swing.SwingUtilities;
    106
    117import org.openstreetmap.josm.Main;
    128import org.openstreetmap.josm.actions.search.SearchCompiler;
    13 import org.openstreetmap.josm.data.coor.EastNorth;
    149import org.openstreetmap.josm.gui.MainMenu;
    1510import org.openstreetmap.josm.gui.MapFrame;
     
    132127        SearchCompiler.addMatchFactory(new UtilsSimpleMatchFactory());
    133128    }
    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
    152130    @Override
    153131    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
     
    182160        drawArc.setEnabled(enabled);
    183161        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);
    187162    }
    188163   
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/UtilsPluginPreferences.java

    r30419 r30459  
    1414import org.openstreetmap.josm.gui.widgets.HtmlPanel;
    1515import java.awt.event.ActionListener;
    16 import javax.swing.JCheckBox;
    1716import javax.swing.JPanel;
    1817import javax.swing.ListSelectionModel;
    1918import javax.swing.event.TableModelListener;
    2019import javax.swing.table.DefaultTableModel;
    21 import org.openstreetmap.josm.Main;
    2220import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2321import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     
    3230    JButton loadButton;
    3331    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";
    3632
    3733    public UtilsPluginPreferences() {
     
    8177                + " Your can manually load settings from file <b>customurl.txt</b> in JOSM folder"));
    8278
    83         dblClick.setSelected(Main.pref.getBoolean(PREF_DOUBLECLICK, true));
    84         all.add(dblClick, GBC.std().insets(5,10,0,0));
    85        
    8679        all.add(new JLabel(tr("Custom URL configuration")),GBC.std().insets(5,10,0,0));
    8780        all.add(resetButton,GBC.std().insets(25,10,0,0));
     
    134127        List<String> lst = readItemsFromTable();
    135128        URLList.updateURLList(lst);
    136         Main.pref.put(PREF_DOUBLECLICK, dblClick.isSelected());
     129
    137130        return false;
    138131    }
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectBoundaryAction.java

    r30419 r30459  
    99import java.awt.event.KeyEvent;
    1010import java.util.Collection;
    11 import java.util.Collections;
    1211import java.util.HashSet;
    1312import java.util.Set;
    14 import java.util.TreeMap;
    1513
    1614import javax.swing.JOptionPane;
     
    1816
    1917import org.openstreetmap.josm.actions.JosmAction;
    20 import org.openstreetmap.josm.data.coor.EastNorth;
    21 import org.openstreetmap.josm.data.osm.BBox;
     18import org.openstreetmap.josm.actions.SelectByInternalPointAction;
    2219import org.openstreetmap.josm.data.osm.Node;
    2320import org.openstreetmap.josm.data.osm.OsmPrimitive;
    24 import org.openstreetmap.josm.data.osm.Relation;
    25 import org.openstreetmap.josm.data.osm.RelationMember;
    2621import org.openstreetmap.josm.data.osm.Way;
    2722import org.openstreetmap.josm.gui.Notification;
    28 import org.openstreetmap.josm.tools.Geometry;
    2923
    3024import org.openstreetmap.josm.tools.Shortcut;
     
    4337        putValue("help", ht("/Action/SelectAreaBoundary"));
    4438    }
    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
    8340    @Override
    8441    public void actionPerformed(ActionEvent e) {
     
    10158            } else {
    10259                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);
    10461                return;
    10562            }
Note: See TracChangeset for help on using the changeset viewer.