Changeset 3851 in josm


Ignore:
Timestamp:
2011-02-03T22:19:11+01:00 (13 years ago)
Author:
bastiK
Message:

remove tabs

Location:
trunk/src/org/openstreetmap/josm/io/remotecontrol
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java

    r3850 r3851  
    3838
    3939
    40         private final JTable propertyTable;
    41         private Collection<? extends OsmPrimitive> sel;
    42         boolean[] existing;
     40    private final JTable propertyTable;
     41    private Collection<? extends OsmPrimitive> sel;
     42    boolean[] existing;
    4343
    44         public AddTagsDialog(String[][] tags) {
    45                 super(Main.parent, tr("Add tags to selected objects"), new String[] { tr("Add tags"), tr("Cancel")},
    46                                 false,
    47                                 true);
     44    public AddTagsDialog(String[][] tags) {
     45        super(Main.parent, tr("Add tags to selected objects"), new String[] { tr("Add tags"), tr("Cancel")},
     46                false,
     47                true);
    4848
    49                 DataSet.addSelectionListener(this);
     49        DataSet.addSelectionListener(this);
    5050
    5151
    52                 DefaultTableModel tm = new DefaultTableModel(new String[] {tr("Assume"), tr("Key"), tr("Value")}, tags.length) {
    53                         @Override
    54                         public Class getColumnClass(int c) {
    55                                 return getValueAt(0, c).getClass();
    56                         }
     52        DefaultTableModel tm = new DefaultTableModel(new String[] {tr("Assume"), tr("Key"), tr("Value")}, tags.length) {
     53            @Override
     54            public Class getColumnClass(int c) {
     55                return getValueAt(0, c).getClass();
     56            }
    5757
    58                 };
     58        };
    5959
    60                 sel = Main.main.getCurrentDataSet().getSelected();
    61                 existing = new boolean[tags.length];
     60        sel = Main.main.getCurrentDataSet().getSelected();
     61        existing = new boolean[tags.length];
    6262
    63                 for (int i = 0; i<tags.length; i++) {
    64                         existing[i] = false;
    65                         String key = tags[i][0];
    66                         Boolean b = Boolean.TRUE;
    67                         for (OsmPrimitive osm : sel) {
    68                                 if (osm.keySet().contains(key)) {
    69                                         b = Boolean.FALSE;
    70                                         existing[i]=true;
    71                                         break;
    72                                 }
    73                         }
    74                         tm.setValueAt(b, i, 0);
    75                         tm.setValueAt(tags[i][0], i, 1);
    76                         tm.setValueAt(tags[i][1], i, 2);
    77                 }
     63        for (int i = 0; i<tags.length; i++) {
     64            existing[i] = false;
     65            String key = tags[i][0];
     66            Boolean b = Boolean.TRUE;
     67            for (OsmPrimitive osm : sel) {
     68                if (osm.keySet().contains(key)) {
     69                    b = Boolean.FALSE;
     70                    existing[i]=true;
     71                    break;
     72                }
     73            }
     74            tm.setValueAt(b, i, 0);
     75            tm.setValueAt(tags[i][0], i, 1);
     76            tm.setValueAt(tags[i][1], i, 2);
     77        }
    7878
    79                 propertyTable = new JTable(tm) {
     79        propertyTable = new JTable(tm) {
    8080
    81                         private static final long serialVersionUID = 1L;
     81            private static final long serialVersionUID = 1L;
    8282
    83                         @Override
    84                         public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    85                                 Component c = super.prepareRenderer(renderer, row, column);
    86                                 if (existing[row]) {
    87                                         c.setFont(c.getFont().deriveFont(Font.ITALIC));
    88                                         c.setForeground(new Color(100, 100, 100));
    89                                 } else {
    90                                         c.setFont(c.getFont().deriveFont(Font.PLAIN));
    91                                         c.setForeground(new Color(0, 0, 0));
    92                                 }
    93                                 return c;
    94                         }
    95                 };
     83            @Override
     84            public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
     85                Component c = super.prepareRenderer(renderer, row, column);
     86                if (existing[row]) {
     87                    c.setFont(c.getFont().deriveFont(Font.ITALIC));
     88                    c.setForeground(new Color(100, 100, 100));
     89                } else {
     90                    c.setFont(c.getFont().deriveFont(Font.PLAIN));
     91                    c.setForeground(new Color(0, 0, 0));
     92                }
     93                return c;
     94            }
     95        };
    9696
    97                 // a checkbox has a size of 15 px
    98                 propertyTable.getColumnModel().getColumn(0).setMaxWidth(15);
    99                 // get edit results if the table looses the focus, for example if a user clicks "add tags"
    100                 propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
     97        // a checkbox has a size of 15 px
     98        propertyTable.getColumnModel().getColumn(0).setMaxWidth(15);
     99        // get edit results if the table looses the focus, for example if a user clicks "add tags"
     100        propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    101101
    102                 // set the content of this AddTagsDialog consisting of the tableHeader and the table itself.
    103                 JPanel tablePanel = new JPanel();
    104                 tablePanel.setLayout(new GridBagLayout());
    105                 tablePanel.add(propertyTable.getTableHeader(), GBC.eol().fill(GBC.HORIZONTAL));
    106                 tablePanel.add(propertyTable, GBC.eol().fill(GBC.BOTH));
    107                 setContent(tablePanel);
     102        // set the content of this AddTagsDialog consisting of the tableHeader and the table itself.
     103        JPanel tablePanel = new JPanel();
     104        tablePanel.setLayout(new GridBagLayout());
     105        tablePanel.add(propertyTable.getTableHeader(), GBC.eol().fill(GBC.HORIZONTAL));
     106        tablePanel.add(propertyTable, GBC.eol().fill(GBC.BOTH));
     107        setContent(tablePanel);
    108108
    109                 // set the default Dimensions and show the dialog
    110                 setPreferredSize(new Dimension(400,tablePanel.getPreferredSize().height+100));
    111                 showDialog();
    112         }
     109        // set the default Dimensions and show the dialog
     110        setPreferredSize(new Dimension(400,tablePanel.getPreferredSize().height+100));
     111        showDialog();
     112    }
    113113
    114         /**
    115         * This method looks for existing tags in the current selection and sets the corresponding boolean in the boolean array existing[]
    116         */
    117         private void findExistingTags() {
    118                 TableModel tm = propertyTable.getModel();
    119                 for (int i=0; i<tm.getRowCount(); i++) {
    120                         String key = (String)tm.getValueAt(i, 1);
    121                         existing[i] = false;
    122                         for (OsmPrimitive osm : sel) {
    123                                 if (osm.keySet().contains(key)) {
    124                                         existing[i] = true;
    125                                         break;
    126                                 }
    127                         }
    128                 }
    129                 propertyTable.repaint();
    130         }
     114    /**
     115    * This method looks for existing tags in the current selection and sets the corresponding boolean in the boolean array existing[]
     116    */
     117    private void findExistingTags() {
     118        TableModel tm = propertyTable.getModel();
     119        for (int i=0; i<tm.getRowCount(); i++) {
     120            String key = (String)tm.getValueAt(i, 1);
     121            existing[i] = false;
     122            for (OsmPrimitive osm : sel) {
     123                if (osm.keySet().contains(key)) {
     124                    existing[i] = true;
     125                    break;
     126                }
     127            }
     128        }
     129        propertyTable.repaint();
     130    }
    131131
    132         /**
    133         * If you click the "Add tags" button build a ChangePropertyCommand for every key that has a checked checkbox to apply the key value pair to all selected osm objects.
    134         * You get a entry for every key in the command queue.
    135         */
    136         @Override
    137         protected void buttonAction(int buttonIndex, ActionEvent evt) {
    138                 if (buttonIndex == 0) {
    139                         TableModel tm = propertyTable.getModel();
    140                         for (int i=0; i<tm.getRowCount(); i++) {
    141                                 if ((Boolean)tm.getValueAt(i, 0)) {
    142                                         Main.main.undoRedo.add(new ChangePropertyCommand(sel, (String)tm.getValueAt(i, 1), (String)tm.getValueAt(i, 2)));
    143                                 }
    144                         }
    145                 }
    146                 setVisible(false);
    147         }
     132    /**
     133    * If you click the "Add tags" button build a ChangePropertyCommand for every key that has a checked checkbox to apply the key value pair to all selected osm objects.
     134    * You get a entry for every key in the command queue.
     135    */
     136    @Override
     137    protected void buttonAction(int buttonIndex, ActionEvent evt) {
     138        if (buttonIndex == 0) {
     139            TableModel tm = propertyTable.getModel();
     140            for (int i=0; i<tm.getRowCount(); i++) {
     141                if ((Boolean)tm.getValueAt(i, 0)) {
     142                    Main.main.undoRedo.add(new ChangePropertyCommand(sel, (String)tm.getValueAt(i, 1), (String)tm.getValueAt(i, 2)));
     143                }
     144            }
     145        }
     146        setVisible(false);
     147    }
    148148
    149         @Override
    150         public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    151                 sel = newSelection;
    152                 findExistingTags();
    153         }
     149    @Override
     150    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
     151        sel = newSelection;
     152        findExistingTags();
     153    }
    154154
    155155}
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r3850 r3851  
    3131public class LoadAndZoomHandler extends RequestHandler
    3232{
    33         public static final String command = "load_and_zoom";
    34         public static final String command2 = "zoom";
    35 
    36         public static final String loadDataPermissionKey = "remotecontrol.permission.load-data";
    37         public static final boolean loadDataPermissionDefault = true;
    38         public static final String changeSelectionPermissionKey = "remotecontrol.permission.change-selection";
    39         public static final boolean changeSelectionPermissionDefault = true;
    40         public static final String changeViewportPermissionKey = "remotecontrol.permission.change-viewport";
    41         public static final boolean changeViewportPermissionDefault = true;
    42 
    43         @Override
    44         public String getPermissionMessage()
    45         {
    46                 return tr("Remote Control has been asked to load data from the API.") +
    47                 "<br>" + tr("Request details: {0}", request);
    48         }
    49 
    50         @Override
    51         protected String[] getMandatoryParams()
    52         {
    53                 return new String[] { "bottom", "top", "left", "right" };
    54         }
    55 
    56         @Override
    57         protected void handleRequest() throws RequestHandlerErrorException
    58         {
    59                 DownloadTask osmTask = new DownloadOsmTask();
    60                 double minlat = 0;
    61                 double maxlat = 0;
    62                 double minlon = 0;
    63                 double maxlon = 0;
    64                 try {
    65                         minlat = Double.parseDouble(args.get("bottom"));
    66                         maxlat = Double.parseDouble(args.get("top"));
    67                         minlon = Double.parseDouble(args.get("left"));
    68                         maxlon = Double.parseDouble(args.get("right"));
    69 
    70                         if(command.equals(myCommand))
    71                         {
    72                                 if (!Main.pref.getBoolean(loadDataPermissionKey, loadDataPermissionDefault))
    73                                 {
    74                                         System.out.println("RemoteControl: download forbidden by preferences");
    75                                 }
    76                                 else
    77                                 {
    78 
    79                                         // find out whether some data has already been downloaded
    80                                         Area present = null;
    81                                         Area toDownload = null;
    82                                         DataSet ds = Main.main.getCurrentDataSet();
    83                                         if (ds != null)
    84                                                 present = ds.getDataSourceArea();
    85                                         if (present != null && !present.isEmpty()) {
    86                                                 toDownload = new Area(new Rectangle2D.Double(minlon,minlat,maxlon-minlon,maxlat-minlat));
    87                                                 toDownload.subtract(present);
    88                                                 if (!toDownload.isEmpty())
    89                                                 {
    90                                                         // the result might not be a rectangle (L shaped etc)
    91                                                         Rectangle2D downloadBounds = toDownload.getBounds2D();
    92                                                         minlat = downloadBounds.getMinY();
    93                                                         minlon = downloadBounds.getMinX();
    94                                                         maxlat = downloadBounds.getMaxY();
    95                                                         maxlon = downloadBounds.getMaxX();
    96                                                 }
    97                                         }
    98                                         if((toDownload != null) && toDownload.isEmpty())
    99                                         {
    100                                                 System.out.println("RemoteControl: no download necessary");
    101                                         }
    102                                         else
    103                                         {
    104                                                 Future<?> future = osmTask.download(false /*no new layer*/, new Bounds(minlat,minlon,maxlat,maxlon), null /* let the task manage the progress monitor */);
    105                                                 Main.worker.submit(new PostDownloadHandler(osmTask, future));
    106                                         }
    107                                 }
    108                         }
    109                 } catch (Exception ex) {
    110                         System.out.println("RemoteControl: Error parsing load_and_zoom remote control request:");
    111                         ex.printStackTrace();
    112                         throw new RequestHandlerErrorException();
    113                 }
    114 
    115                 /**
    116                 * deselect objects if parameter addtags given
    117                 */
    118                 if (args.containsKey("addtags")) {
    119                         Main.worker.execute(new Runnable() {
    120                                 public void run() {
    121                                         DataSet ds = Main.main.getCurrentDataSet();
    122                                         if(ds == null) // e.g. download failed
    123                                                 return;
    124                                         ds.clearSelection();
    125                                 }
    126                         });
    127                 }
    128 
    129                 if (args.containsKey("select") && Main.pref.getBoolean(changeSelectionPermissionKey, changeSelectionPermissionDefault)) {
    130                         // select objects after downloading, zoom to selection.
    131                         final String selection = args.get("select");
    132                         Main.worker.execute(new Runnable() {
    133                                 public void run() {
    134                                         HashSet<Long> ways = new HashSet<Long>();
    135                                         HashSet<Long> nodes = new HashSet<Long>();
    136                                         HashSet<Long> relations = new HashSet<Long>();
    137                                         HashSet<OsmPrimitive> newSel = new HashSet<OsmPrimitive>();
    138                                         for (String item : selection.split(",")) {
    139                                                 if (item.startsWith("way")) {
    140                                                         ways.add(Long.parseLong(item.substring(3)));
    141                                                 } else if (item.startsWith("node")) {
    142                                                         nodes.add(Long.parseLong(item.substring(4)));
    143                                                 } else if (item.startsWith("relation")) {
    144                                                         relations.add(Long.parseLong(item.substring(8)));
    145                                                 } else if (item.startsWith("rel")) {
    146                                                         relations.add(Long.parseLong(item.substring(3)));
    147                                                 } else {
    148                                                         System.out.println("RemoteControl: invalid selection '"+item+"' ignored");
    149                                                 }
    150                                         }
    151                                         DataSet ds = Main.main.getCurrentDataSet();
    152                                         if(ds == null) // e.g. download failed
    153                                                 return;
    154                                         for (Way w : ds.getWays()) {
    155                                                 if (ways.contains(w.getId())) {
    156                                                         newSel.add(w);
    157                                                 }
    158                                         }
    159                                         for (Node n : ds.getNodes()) {
    160                                                 if (nodes.contains(n.getId())) {
    161                                                         newSel.add(n);
    162                                                 }
    163                                         }
    164                                         for (Relation r : ds.getRelations()) {
    165                                                 if (relations.contains(r.getId())) {
    166                                                         newSel.add(r);
    167                                                 }
    168                                         }
    169                                         ds.setSelected(newSel);
    170                                         if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault))
    171                                                 new AutoScaleAction("selection").actionPerformed(null);
    172                                 }
    173                         });
    174                 } else if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault)) {
    175                         // after downloading, zoom to downloaded area.
    176                         zoom(minlat, maxlat, minlon, maxlon);
    177                 }
    178 
    179                 /*
    180                 * parse addtags parameters
    181                 * Example URL (part):
    182                 * addtags=wikipedia:de%3DResidenzschloss Dresden|name:en%3DDresden Castle
    183                 */
    184                 if (args.containsKey("addtags")) {
    185                         Main.worker.execute(new Runnable() {
    186                                 public void run() {
    187                                         String[] tags = null;
    188                                         try {
    189                                                 tags = URLDecoder.decode(args.get("addtags"), "UTF-8").split("\\|");
    190                                         } catch (UnsupportedEncodingException e) {
     33    public static final String command = "load_and_zoom";
     34    public static final String command2 = "zoom";
     35
     36    public static final String loadDataPermissionKey = "remotecontrol.permission.load-data";
     37    public static final boolean loadDataPermissionDefault = true;
     38    public static final String changeSelectionPermissionKey = "remotecontrol.permission.change-selection";
     39    public static final boolean changeSelectionPermissionDefault = true;
     40    public static final String changeViewportPermissionKey = "remotecontrol.permission.change-viewport";
     41    public static final boolean changeViewportPermissionDefault = true;
     42
     43    @Override
     44    public String getPermissionMessage()
     45    {
     46        return tr("Remote Control has been asked to load data from the API.") +
     47        "<br>" + tr("Request details: {0}", request);
     48    }
     49
     50    @Override
     51    protected String[] getMandatoryParams()
     52    {
     53        return new String[] { "bottom", "top", "left", "right" };
     54    }
     55
     56    @Override
     57    protected void handleRequest() throws RequestHandlerErrorException
     58    {
     59        DownloadTask osmTask = new DownloadOsmTask();
     60        double minlat = 0;
     61        double maxlat = 0;
     62        double minlon = 0;
     63        double maxlon = 0;
     64        try {
     65            minlat = Double.parseDouble(args.get("bottom"));
     66            maxlat = Double.parseDouble(args.get("top"));
     67            minlon = Double.parseDouble(args.get("left"));
     68            maxlon = Double.parseDouble(args.get("right"));
     69
     70            if(command.equals(myCommand))
     71            {
     72                if (!Main.pref.getBoolean(loadDataPermissionKey, loadDataPermissionDefault))
     73                {
     74                    System.out.println("RemoteControl: download forbidden by preferences");
     75                }
     76                else
     77                {
     78
     79                    // find out whether some data has already been downloaded
     80                    Area present = null;
     81                    Area toDownload = null;
     82                    DataSet ds = Main.main.getCurrentDataSet();
     83                    if (ds != null)
     84                        present = ds.getDataSourceArea();
     85                    if (present != null && !present.isEmpty()) {
     86                        toDownload = new Area(new Rectangle2D.Double(minlon,minlat,maxlon-minlon,maxlat-minlat));
     87                        toDownload.subtract(present);
     88                        if (!toDownload.isEmpty())
     89                        {
     90                            // the result might not be a rectangle (L shaped etc)
     91                            Rectangle2D downloadBounds = toDownload.getBounds2D();
     92                            minlat = downloadBounds.getMinY();
     93                            minlon = downloadBounds.getMinX();
     94                            maxlat = downloadBounds.getMaxY();
     95                            maxlon = downloadBounds.getMaxX();
     96                        }
     97                    }
     98                    if((toDownload != null) && toDownload.isEmpty())
     99                    {
     100                        System.out.println("RemoteControl: no download necessary");
     101                    }
     102                    else
     103                    {
     104                        Future<?> future = osmTask.download(false /*no new layer*/, new Bounds(minlat,minlon,maxlat,maxlon), null /* let the task manage the progress monitor */);
     105                        Main.worker.submit(new PostDownloadHandler(osmTask, future));
     106                    }
     107                }
     108            }
     109        } catch (Exception ex) {
     110            System.out.println("RemoteControl: Error parsing load_and_zoom remote control request:");
     111            ex.printStackTrace();
     112            throw new RequestHandlerErrorException();
     113        }
     114
     115        /**
     116        * deselect objects if parameter addtags given
     117        */
     118        if (args.containsKey("addtags")) {
     119            Main.worker.execute(new Runnable() {
     120                public void run() {
     121                    DataSet ds = Main.main.getCurrentDataSet();
     122                    if(ds == null) // e.g. download failed
     123                        return;
     124                    ds.clearSelection();
     125                }
     126            });
     127        }
     128
     129        if (args.containsKey("select") && Main.pref.getBoolean(changeSelectionPermissionKey, changeSelectionPermissionDefault)) {
     130            // select objects after downloading, zoom to selection.
     131            final String selection = args.get("select");
     132            Main.worker.execute(new Runnable() {
     133                public void run() {
     134                    HashSet<Long> ways = new HashSet<Long>();
     135                    HashSet<Long> nodes = new HashSet<Long>();
     136                    HashSet<Long> relations = new HashSet<Long>();
     137                    HashSet<OsmPrimitive> newSel = new HashSet<OsmPrimitive>();
     138                    for (String item : selection.split(",")) {
     139                        if (item.startsWith("way")) {
     140                            ways.add(Long.parseLong(item.substring(3)));
     141                        } else if (item.startsWith("node")) {
     142                            nodes.add(Long.parseLong(item.substring(4)));
     143                        } else if (item.startsWith("relation")) {
     144                            relations.add(Long.parseLong(item.substring(8)));
     145                        } else if (item.startsWith("rel")) {
     146                            relations.add(Long.parseLong(item.substring(3)));
     147                        } else {
     148                            System.out.println("RemoteControl: invalid selection '"+item+"' ignored");
     149                        }
     150                    }
     151                    DataSet ds = Main.main.getCurrentDataSet();
     152                    if(ds == null) // e.g. download failed
     153                        return;
     154                    for (Way w : ds.getWays()) {
     155                        if (ways.contains(w.getId())) {
     156                            newSel.add(w);
     157                        }
     158                    }
     159                    for (Node n : ds.getNodes()) {
     160                        if (nodes.contains(n.getId())) {
     161                            newSel.add(n);
     162                        }
     163                    }
     164                    for (Relation r : ds.getRelations()) {
     165                        if (relations.contains(r.getId())) {
     166                            newSel.add(r);
     167                        }
     168                    }
     169                    ds.setSelected(newSel);
     170                    if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault))
     171                        new AutoScaleAction("selection").actionPerformed(null);
     172                }
     173            });
     174        } else if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault)) {
     175            // after downloading, zoom to downloaded area.
     176            zoom(minlat, maxlat, minlon, maxlon);
     177        }
     178
     179        /*
     180        * parse addtags parameters
     181        * Example URL (part):
     182        * addtags=wikipedia:de%3DResidenzschloss Dresden|name:en%3DDresden Castle
     183        */
     184        if (args.containsKey("addtags")) {
     185            Main.worker.execute(new Runnable() {
     186                public void run() {
     187                    String[] tags = null;
     188                    try {
     189                        tags = URLDecoder.decode(args.get("addtags"), "UTF-8").split("\\|");
     190                    } catch (UnsupportedEncodingException e) {
    191191                        new RuntimeException();
    192                                         }
    193                                         String[][] keyValue = new String[tags.length][2];
    194                                         for (int i = 0; i<tags.length; i++) {
    195                                                 keyValue[i] = tags[i].split("=");
    196 
    197                                                 keyValue[i][0] = keyValue[i][0];
    198                                                 keyValue[i][1] = keyValue[i][1];
    199                                         }
    200 
    201                                         new AddTagsDialog(keyValue);
    202                                 }
    203                         });
    204                 }
    205 
    206         }
    207 
    208         protected void zoom(double minlat, double maxlat, double minlon, double maxlon) {
    209                 final Bounds bounds = new Bounds(new LatLon(minlat, minlon),
    210                                 new LatLon(maxlat, maxlon));
    211 
    212                 // make sure this isn't called unless there *is* a MapView
    213                 //
    214                 if (Main.map != null && Main.map.mapView != null) {
    215                         Main.worker.execute(new Runnable() {
    216                                 public void run() {
    217                                         BoundingXYVisitor bbox = new BoundingXYVisitor();
    218                                         bbox.visit(bounds);
    219                                         Main.map.mapView.recalculateCenterScale(bbox);
    220                                 }
    221                         });
    222                 }
    223         }
     192                    }
     193                    String[][] keyValue = new String[tags.length][2];
     194                    for (int i = 0; i<tags.length; i++) {
     195                        keyValue[i] = tags[i].split("=");
     196
     197                        keyValue[i][0] = keyValue[i][0];
     198                        keyValue[i][1] = keyValue[i][1];
     199                    }
     200
     201                    new AddTagsDialog(keyValue);
     202                }
     203            });
     204        }
     205
     206    }
     207
     208    protected void zoom(double minlat, double maxlat, double minlon, double maxlon) {
     209        final Bounds bounds = new Bounds(new LatLon(minlat, minlon),
     210                new LatLon(maxlat, maxlon));
     211
     212        // make sure this isn't called unless there *is* a MapView
     213        //
     214        if (Main.map != null && Main.map.mapView != null) {
     215            Main.worker.execute(new Runnable() {
     216                public void run() {
     217                    BoundingXYVisitor bbox = new BoundingXYVisitor();
     218                    bbox.visit(bounds);
     219                    Main.map.mapView.recalculateCenterScale(bbox);
     220                }
     221            });
     222        }
     223    }
    224224}
Note: See TracChangeset for help on using the changeset viewer.