Changeset 16162 in osm for applications/editors


Ignore:
Timestamp:
2009-06-26T22:11:40+02:00 (15 years ago)
Author:
jttt
Message:

Use getter for Node.coor and Node.eastNorth

Location:
applications/editors/josm/plugins
Files:
4 added
7 edited

Legend:

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

    r15858 r16162  
    2626                <attribute name="Plugin-Description" value="Make terraced houses out of single blocks."/>
    2727                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/Terracer"/>
    28                 <attribute name="Plugin-Mainversion" value="1598"/>
     28                <attribute name="Plugin-Mainversion" value="1638"/>
    2929                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    3030            </manifest>
  • applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java

    r14048 r16162  
    11/**
    22 * Terracer: A JOSM Plugin for terraced houses.
    3  * 
     3 *
    44 * Copyright 2009 CloudMade Ltd.
    5  * 
     5 *
    66 * Released under the GPLv2, see LICENSE file for details.
    77 */
     
    1111import static org.openstreetmap.josm.tools.I18n.trn;
    1212
    13 import java.awt.BorderLayout;
    1413import java.awt.Choice;
    1514import java.awt.Component;
     
    2019import java.awt.event.KeyEvent;
    2120import java.util.ArrayList;
    22 import java.util.Arrays;
    2321import java.util.Collection;
    2422import java.util.Collections;
    25 import java.util.HashMap;
    2623import java.util.LinkedList;
    27 import java.util.List;
    28 import java.util.Map;
    29 import java.util.TreeMap;
    3024import java.util.TreeSet;
    3125
    32 import javax.swing.JComponent;
    3326import javax.swing.JFormattedTextField;
    3427import javax.swing.JLabel;
     
    3629import javax.swing.JPanel;
    3730import javax.swing.JSpinner;
    38 import javax.swing.JTextField;
    3931import javax.swing.SpinnerNumberModel;
    40 import javax.swing.SpringLayout;
    4132import javax.swing.event.ChangeEvent;
    4233import javax.swing.event.ChangeListener;
     
    5344import org.openstreetmap.josm.data.osm.RelationMember;
    5445import org.openstreetmap.josm.data.osm.Way;
    55 import org.openstreetmap.josm.gui.tagging.TaggingPreset.Item;
    5646import org.openstreetmap.josm.tools.AutoCompleteComboBox;
    5747import org.openstreetmap.josm.tools.GBC;
     
    6252 * Terraces a quadrilateral, closed way into a series of quadrilateral,
    6353 * closed ways.
    64  * 
     54 *
    6555 * At present it only works on quadrilaterals, but there is no reason
    66  * why it couldn't be extended to work with other shapes too. The 
    67  * algorithm employed is naive, but it works in the simple case. 
    68  * 
     56 * why it couldn't be extended to work with other shapes too. The
     57 * algorithm employed is naive, but it works in the simple case.
     58 *
    6959 * @author zere
    7060 */
     
    7666
    7767        public TerracerAction() {
    78                 super(tr("Terrace a building"), 
    79                                 "terrace", 
     68                super(tr("Terrace a building"),
     69                                "terrace",
    8070                                tr("Creates individual buildings from a long building."),
    81                                 Shortcut.registerShortcut("tools:Terracer", 
     71                                Shortcut.registerShortcut("tools:Terracer",
    8272                                                tr("Tool: {0}", tr("Terrace a building")),
    83                                                 KeyEvent.VK_T, Shortcut.GROUP_EDIT, 
     73                                                KeyEvent.VK_T, Shortcut.GROUP_EDIT,
    8474                                                Shortcut.SHIFT_DEFAULT),
    8575                                                true);
     
    112102                                        optionPane.createDialog(Main.parent, title).setVisible(true);
    113103                                        Object answerObj = optionPane.getValue();
    114                                         if (answerObj != null && 
     104                                        if (answerObj != null &&
    115105                                                        answerObj != JOptionPane.UNINITIALIZED_VALUE &&
    116                                                         (answerObj instanceof Integer && 
     106                                                        (answerObj instanceof Integer &&
    117107                                                                        (Integer)answerObj == JOptionPane.OK_OPTION)) {
    118108
    119109                                                // call out to the method which does the actual
    120110                                                // terracing.
    121                                                 terraceBuilding(way, 
    122                                                                 dialog.numberFrom(), 
     111                                                terraceBuilding(way,
     112                                                                dialog.numberFrom(),
    123113                                                                dialog.numberTo(),
    124114                                                                dialog.stepSize(),
     
    137127
    138128                if (badSelect) {
    139                         JOptionPane.showMessageDialog(Main.parent, 
     129                        JOptionPane.showMessageDialog(Main.parent,
    140130                                        tr("Select a single, closed way of at least four nodes."));
    141131                }
     
    144134        /**
    145135         * Terraces a single, closed, quadrilateral way.
    146          * 
     136         *
    147137         * Any node must be adjacent to both a short and long edge, we naively
    148138         * choose the longest edge and its opposite and interpolate along them
    149139         * linearly to produce new nodes. Those nodes are then assembled into
    150140         * closed, quadrilateral ways and left in the selection.
    151          * 
     141         *
    152142         * @param w The closed, quadrilateral way to terrace.
    153143         */
     
    167157                Collection<Way> ways = new LinkedList<Way>();
    168158
    169                 // create intermediate nodes by interpolating. 
     159                // create intermediate nodes by interpolating.
    170160                for (int i = 0; i <= nb; ++i) {
    171                         new_nodes[0][i] = interpolateAlong(interp.a, frontLength * (double)(i) / (double)(nb));
    172                         new_nodes[1][i] = interpolateAlong(interp.b, backLength * (double)(i) / (double)(nb));
     161                        new_nodes[0][i] = interpolateAlong(interp.a, frontLength * (i) / (nb));
     162                        new_nodes[1][i] = interpolateAlong(interp.b, backLength * (i) / (nb));
    173163                        commands.add(new AddCommand(new_nodes[0][i]));
    174164                        commands.add(new AddCommand(new_nodes[1][i]));
     
    214204         * Creates a node at a certain distance along a way, as calculated by the
    215205         * great circle distance.
    216          * 
    217          * Note that this really isn't an efficient way to do this and leads to 
     206         *
     207         * Note that this really isn't an efficient way to do this and leads to
    218208         * O(N^2) running time for the main algorithm, but its simple and easy
    219209         * to understand, and probably won't matter for reasonable-sized ways.
    220          * 
     210         *
    221211         * @param w The way to interpolate.
    222212         * @param l The length at which to place the node.
     
    226216                Node n = null;
    227217                for (Pair<Node,Node> p : w.getNodePairs(false)) {
    228                         final double seg_length = p.a.coor.greatCircleDistance(p.b.coor);
     218                        final double seg_length = p.a.getCoor().greatCircleDistance(p.b.getCoor());
    229219                        if (l <= seg_length) {
    230220                                n = interpolateNode(p.a, p.b, l / seg_length);
     
    245235         * Calculates the great circle length of a way by summing the great circle
    246236         * distance of each pair of nodes.
    247          * 
     237         *
    248238         * @param w The way to calculate length of.
    249239         * @return The length of the way.
     
    252242                double length = 0.0;
    253243                for (Pair<Node,Node> p : w.getNodePairs(false)) {
    254                         length += p.a.coor.greatCircleDistance(p.b.coor);
     244                        length += p.a.getCoor().greatCircleDistance(p.b.getCoor());
    255245                }
    256246                return length;
     
    258248
    259249        /**
    260          * Given a way, try and find a definite front and back by looking at the 
     250         * Given a way, try and find a definite front and back by looking at the
    261251         * segments to find the "sides". Sides are assumed to be single segments
    262252         * which cannot be contiguous.
    263          * 
     253         *
    264254         * @param w The way to analyse.
    265255         * @return A pair of ways (front, back) pointing in the same directions.
     
    327317                Node a = w.nodes.get(i);
    328318                Node b = w.nodes.get((i+1) % (w.nodes.size() - 1));
    329                 return a.coor.greatCircleDistance(b.coor);
     319                return a.getCoor().greatCircleDistance(b.getCoor());
    330320        }
    331321
     
    334324         * into order and return the array of indexes such that, for a returned array
    335325         * x, a[x[i]] is sorted for ascending index i.
    336          * 
     326         *
    337327         * This isn't efficient at all, but should be fine for the small arrays we're
    338328         * expecting. If this gets slow - replace it with some more efficient algorithm.
    339          * 
     329         *
    340330         * @param a The array to sort.
    341          * @return An array of indexes, the same size as the input, such that a[x[i]] 
     331         * @return An array of indexes, the same size as the input, such that a[x[i]]
    342332         * is in sorted order.
    343333         */
     
    370360
    371361        /**
    372          * Calculate "sideness" metric for each segment in a way. 
     362         * Calculate "sideness" metric for each segment in a way.
    373363         */
    374364        private double[] calculateSideness(Way w) {
     
    385375                }
    386376                sideness[length-1] = calculateSideness(
    387                                 w.nodes.get(length - 2), w.nodes.get(length - 1), 
     377                                w.nodes.get(length - 2), w.nodes.get(length - 1),
    388378                                w.nodes.get(length), w.nodes.get(1));
    389379
     
    397387         */
    398388        private double calculateSideness(Node a, Node b, Node c, Node d) {
    399                 final double ndx = b.coor.getX() - a.coor.getX();
    400                 final double pdx = d.coor.getX() - c.coor.getX();
    401                 final double ndy = b.coor.getY() - a.coor.getY();
    402                 final double pdy = d.coor.getY() - c.coor.getY();
    403 
    404                 return (ndx * pdx + ndy * pdy) / 
     389                final double ndx = b.getCoor().getX() - a.getCoor().getX();
     390                final double pdx = d.getCoor().getX() - c.getCoor().getX();
     391                final double ndy = b.getCoor().getY() - a.getCoor().getY();
     392                final double pdy = d.getCoor().getY() - c.getCoor().getY();
     393
     394                return (ndx * pdx + ndy * pdy) /
    405395                Math.sqrt((ndx * ndx + ndy * ndy) * (pdx * pdx + pdy * pdy));
    406396        }
     
    426416                        chi = new JSpinner(hi);
    427417
    428                         lo.addChangeListener(new ChangeListener() { 
     418                        lo.addChangeListener(new ChangeListener() {
    429419                                public void stateChanged(ChangeEvent e) {
    430420                                        hi.setMinimum((Integer)lo.getNumber());
    431421                                }
    432422                        });
    433                         hi.addChangeListener(new ChangeListener() { 
     423                        hi.addChangeListener(new ChangeListener() {
    434424                                public void stateChanged(ChangeEvent e) {
    435425                                        lo.setMaximum((Integer)hi.getNumber());
     
    521511
    522512        /**
    523          * Generates a list of all visible names of highways in order to do 
     513         * Generates a list of all visible names of highways in order to do
    524514         * autocompletion on the road name.
    525515         */
     
    539529         * Creates a new node at the interpolated position between the argument
    540530         * nodes. Interpolates linearly in Lat/Lon coordinates.
    541          * 
     531         *
    542532         * @param a First node, at which f=0.
    543533         * @param b Last node, at which f=1.
     
    551541
    552542        /**
    553          * Calculates the interpolated position between the argument nodes. Interpolates 
     543         * Calculates the interpolated position between the argument nodes. Interpolates
    554544         * linearly in Lat/Lon coordinates.
    555          * 
     545         *
    556546         * @param a First node, at which f=0.
    557547         * @param b Last node, at which f=1.
     
    563553                // screen coordinates rather than lat/lon, but it doesn't seem to
    564554                // make a great deal of difference at the scale of most terraces.
    565                 return new LatLon(a.coor.lat() * (1.0 - f) + b.coor.lat() * f,
    566                                 a.coor.lon() * (1.0 - f) + b.coor.lon() * f);
     555                return new LatLon(a.getCoor().lat() * (1.0 - f) + b.getCoor().lat() * f,
     556                                a.getCoor().lon() * (1.0 - f) + b.getCoor().lon() * f);
    567557        }
    568558}
  • applications/editors/josm/plugins/utilsplugin/build.xml

    r15127 r16162  
    2525                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
    2626                <attribute name="Plugin-Description" value="Several utilities that make your life easier: e.g. simplify way, join areas, jump to position."/>
    27                 <attribute name="Plugin-Mainversion" value="1598"/>
     27                <attribute name="Plugin-Mainversion" value="1638"/>
    2828                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    2929            </manifest>
  • applications/editors/josm/plugins/utilsplugin/src/UtilsPlugin/JoinAreasAction.java

    r15960 r16162  
    33import static org.openstreetmap.josm.tools.I18n.marktr;
    44import static org.openstreetmap.josm.tools.I18n.tr;
    5 import static org.openstreetmap.josm.tools.I18n.trn;
    6 
     5
     6import java.awt.GridBagLayout;
     7import java.awt.Polygon;
    78import java.awt.event.ActionEvent;
    89import java.awt.event.KeyEvent;
    910import java.awt.geom.Line2D;
    10 import java.awt.geom.Point2D;
    11 import java.awt.GridBagLayout;
    12 import java.awt.Point;
    13 import java.awt.Polygon;
    14 
    1511import java.util.ArrayList;
    16 import java.util.Arrays;
    1712import java.util.Collection;
    1813import java.util.Collections;
    19 import java.util.Comparator;
    2014import java.util.HashMap;
    2115import java.util.LinkedList;
    2216import java.util.List;
    2317import java.util.Map;
    24 import java.util.Map.Entry;
    2518import java.util.Set;
    2619import java.util.TreeMap;
    2720import java.util.TreeSet;
     21import java.util.Map.Entry;
    2822
    2923import javax.swing.Box;
     
    3327import javax.swing.JPanel;
    3428
     29import org.openstreetmap.josm.Main;
    3530import org.openstreetmap.josm.actions.CombineWayAction;
    3631import org.openstreetmap.josm.actions.JosmAction;
    3732import org.openstreetmap.josm.actions.ReverseWayAction;
    3833import org.openstreetmap.josm.actions.SplitWayAction;
    39 
    4034import org.openstreetmap.josm.command.AddCommand;
    4135import org.openstreetmap.josm.command.ChangeCommand;
     
    4337import org.openstreetmap.josm.command.DeleteCommand;
    4438import org.openstreetmap.josm.command.SequenceCommand;
    45 
    4639import org.openstreetmap.josm.data.Bounds;
     40import org.openstreetmap.josm.data.UndoRedoHandler;
    4741import org.openstreetmap.josm.data.coor.EastNorth;
    4842import org.openstreetmap.josm.data.coor.LatLon;
     
    5448import org.openstreetmap.josm.data.osm.RelationMember;
    5549import org.openstreetmap.josm.data.osm.TigerUtils;
    56 import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor;
    5750import org.openstreetmap.josm.data.osm.Way;
    58 import org.openstreetmap.josm.data.osm.WaySegment;
    59 import org.openstreetmap.josm.data.projection.Epsg4326;
    60 import org.openstreetmap.josm.data.projection.Lambert;
    61 import org.openstreetmap.josm.data.projection.Mercator;
    62 import org.openstreetmap.josm.data.UndoRedoHandler;
    63 
    6451import org.openstreetmap.josm.gui.ExtendedDialog;
    6552import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    66 import org.openstreetmap.josm.Main;
    6753import org.openstreetmap.josm.tools.GBC;
    68 import org.openstreetmap.josm.tools.Pair;
    6954import org.openstreetmap.josm.tools.Shortcut;
    7055
     
    8368            this.pos = pos;
    8469            this.n = n;
    85             this.dis = n.coor.greatCircleDistance(dis);
     70            this.dis = n.getCoor().greatCircleDistance(dis);
    8671        }
    8772
     
    160145                boolean isInsideOneBoundingBox = false;
    161146                for (Bounds b : bounds) {
    162                     if (b.contains(node.coor)) {
     147                    if (b.contains(node.getCoor())) {
    163148                        isInsideOneBoundingBox = true;
    164149                        break;
     
    362347                }
    363348                LatLon intersection = getLineLineIntersection(
    364                         a.nodes.get(i)  .eastNorth.east(), a.nodes.get(i)  .eastNorth.north(),
    365                         a.nodes.get(i+1).eastNorth.east(), a.nodes.get(i+1).eastNorth.north(),
    366                         b.nodes.get(j)  .eastNorth.east(), b.nodes.get(j)  .eastNorth.north(),
    367                         b.nodes.get(j+1).eastNorth.east(), b.nodes.get(j+1).eastNorth.north());
     349                        a.nodes.get(i)  .getEastNorth().east(), a.nodes.get(i)  .getEastNorth().north(),
     350                        a.nodes.get(i+1).getEastNorth().east(), a.nodes.get(i+1).getEastNorth().north(),
     351                        b.nodes.get(j)  .getEastNorth().east(), b.nodes.get(j)  .getEastNorth().north(),
     352                        b.nodes.get(j+1).getEastNorth().east(), b.nodes.get(j+1).getEastNorth().north());
    368353                if(intersection == null) continue;
    369354
     
    373358                nodes.add(n);
    374359                // The distance is needed to sort and add the nodes in direction of the way
    375                 nodesA.add(new NodeToSegs(i,  n, a.nodes.get(i).coor));
     360                nodesA.add(new NodeToSegs(i,  n, a.nodes.get(i).getCoor()));
    376361                if(same)
    377                     nodesA.add(new NodeToSegs(j,  n, a.nodes.get(j).coor));
     362                    nodesA.add(new NodeToSegs(j,  n, a.nodes.get(j).getCoor()));
    378363                else
    379                     nodesB.add(new NodeToSegs(j,  n, b.nodes.get(j).coor));
     364                    nodesB.add(new NodeToSegs(j,  n, b.nodes.get(j).getCoor()));
    380365            }
    381366        }
     
    423408    private void addNodesToWay(Way a, ArrayList<NodeToSegs> nodes) {
    424409        Way ax=new Way(a);
    425         List<NodeToSegs> newnodes = new ArrayList<NodeToSegs>();
    426410        Collections.sort(nodes);
    427411
     
    539523        for(Way w: multigonWays) {
    540524            Polygon poly = new Polygon();
    541             for(Node n: ((Way)w).nodes) poly.addPoint(latlonToXY(n.coor.lat()), latlonToXY(n.coor.lon()));
     525            for(Node n: (w).nodes) poly.addPoint(latlonToXY(n.getCoor().lat()), latlonToXY(n.getCoor().lon()));
    542526
    543527            for(Node n: multigonNodes) {
    544                 if(!((Way)w).nodes.contains(n) && poly.contains(latlonToXY(n.coor.lat()), latlonToXY(n.coor.lon()))) {
     528                if(!(w).nodes.contains(n) && poly.contains(latlonToXY(n.getCoor().lat()), latlonToXY(n.getCoor().lon()))) {
    545529                    getWaysByNode(innerWays, multigonWays, n);
    546530                }
     
    564548    private void getWaysByNode(Collection<Way> innerWays, Collection<Way> w, Node n) {
    565549        for(Way way : w) {
    566             if(!((Way)way).nodes.contains(n)) continue;
     550            if(!(way).nodes.contains(n)) continue;
    567551            if(!innerWays.contains(way)) innerWays.add(way); // Will need this later for multigons
    568552        }
  • applications/editors/josm/plugins/utilsplugin/src/UtilsPlugin/JumpToAction.java

    r13575 r16162  
    44
    55import java.awt.BorderLayout;
    6 import java.awt.Component;
     6import java.awt.GridBagLayout;
    77import java.awt.event.ActionEvent;
    8 import java.awt.event.InputEvent;
    98import java.awt.event.KeyEvent;
     9import java.awt.event.MouseEvent;
    1010import java.awt.event.MouseListener;
    11 import java.awt.event.MouseEvent;
    12 import java.awt.GridBagLayout;
    13 import java.awt.GridLayout;
    14 import java.awt.Toolkit;
    1511
    16 import javax.swing.Box;
    17 import javax.swing.event.DocumentListener;
    18 import javax.swing.event.DocumentEvent;
    19 import javax.swing.JComponent;
    20 import javax.swing.JDialog;
    2112import javax.swing.JLabel;
    2213import javax.swing.JOptionPane;
    2314import javax.swing.JPanel;
    2415import javax.swing.JTextField;
    25 import javax.swing.KeyStroke;
     16import javax.swing.event.DocumentEvent;
     17import javax.swing.event.DocumentListener;
    2618
    2719import org.openstreetmap.josm.Main;
    2820import org.openstreetmap.josm.actions.JosmAction;
    2921import org.openstreetmap.josm.data.Bounds;
    30 import org.openstreetmap.josm.data.coor.EastNorth;
    3122import org.openstreetmap.josm.data.coor.LatLon;
    32 import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    33 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     23import org.openstreetmap.josm.gui.NavigatableComponent;
    3424import org.openstreetmap.josm.tools.GBC;
    3525import org.openstreetmap.josm.tools.OsmUrlToBounds;
     
    4131        KeyEvent.VK_G, Shortcut.GROUP_HOTKEY), true);
    4232    }
    43    
     33
    4434    private JTextField url = new JTextField();
    4535    private JTextField lat = new JTextField();
    4636    private JTextField lon = new JTextField();
    4737    private JTextField zm = new JTextField();
    48    
     38
    4939    private double zoomFactor = 0;
    5040    public void showJumpToDialog() {
     
    5242        lat.setText(java.lang.Double.toString(curPos.lat()));
    5343        lon.setText(java.lang.Double.toString(curPos.lon()));
    54        
     44
    5545        LatLon ll1 = Main.map.mapView.getLatLon(0,0);
    5646        LatLon ll2 = Main.map.mapView.getLatLon(100,0);
    5747        double dist = ll1.greatCircleDistance(ll2);
    5848        zoomFactor = Main.map.mapView.getScale()/dist;
    59        
     49
    6050        zm.setText(java.lang.Long.toString(Math.round(dist*100)/100));
    6151        updateUrl(true);
    62        
     52
    6353        JPanel panel = new JPanel(new BorderLayout());
    6454        panel.add(new JLabel("<html>"
     
    6959                              + "</html>"),
    7060                  BorderLayout.NORTH);
    71        
    72         class osmURLListener implements DocumentListener { 
    73             public void changedUpdate(DocumentEvent e) { parseURL(); } 
    74             public void insertUpdate(DocumentEvent e) { parseURL(); } 
    75             public void removeUpdate(DocumentEvent e) { parseURL(); } 
     61
     62        class osmURLListener implements DocumentListener {
     63            public void changedUpdate(DocumentEvent e) { parseURL(); }
     64            public void insertUpdate(DocumentEvent e) { parseURL(); }
     65            public void removeUpdate(DocumentEvent e) { parseURL(); }
    7666        }
    77        
    78         class osmLonLatListener implements DocumentListener { 
    79             public void changedUpdate(DocumentEvent e) { updateUrl(false); } 
    80             public void insertUpdate(DocumentEvent e) { updateUrl(false); } 
    81             public void removeUpdate(DocumentEvent e) { updateUrl(false); } 
    82         } 
    83        
     67
     68        class osmLonLatListener implements DocumentListener {
     69            public void changedUpdate(DocumentEvent e) { updateUrl(false); }
     70            public void insertUpdate(DocumentEvent e) { updateUrl(false); }
     71            public void removeUpdate(DocumentEvent e) { updateUrl(false); }
     72        }
     73
    8474        osmLonLatListener x=new osmLonLatListener();
    85         lat.getDocument().addDocumentListener(x); 
    86         lon.getDocument().addDocumentListener(x); 
    87         zm.getDocument().addDocumentListener(x); 
    88         url.getDocument().addDocumentListener(new osmURLListener()); 
    89        
     75        lat.getDocument().addDocumentListener(x);
     76        lon.getDocument().addDocumentListener(x);
     77        zm.getDocument().addDocumentListener(x);
     78        url.getDocument().addDocumentListener(new osmURLListener());
     79
    9080        JPanel p = new JPanel(new GridBagLayout());
    9181        panel.add(p, BorderLayout.NORTH);
    92        
     82
    9383        p.add(new JLabel(tr("Latitude")), GBC.eol());
    9484        p.add(lat, GBC.eol().fill(GBC.HORIZONTAL));
    95        
     85
    9686        p.add(new JLabel(tr("Longitude")), GBC.eol());
    9787        p.add(lon, GBC.eol().fill(GBC.HORIZONTAL));
    98        
     88
    9989        p.add(new JLabel(tr("Zoom (in metres)")), GBC.eol());
    10090        p.add(zm, GBC.eol().fill(GBC.HORIZONTAL));
    101        
     91
    10292        p.add(new JLabel(tr("URL")), GBC.eol());
    10393        p.add(url, GBC.eol().fill(GBC.HORIZONTAL));
    104        
     94
    10595        Object[] buttons = { tr("Jump there"), tr("Cancel") };
    10696        LatLon ll = null;
     
    116106                            buttons,
    117107                            buttons[0]);
    118            
     108
    119109            if (option != JOptionPane.OK_OPTION) return;
    120110            try {
     
    125115            }
    126116        }
    127        
     117
    128118        Main.map.mapView.zoomTo(Main.proj.latlon2eastNorth(ll), zoomFactor * zoomLvl);
    129119    }
    130    
     120
    131121    private void parseURL() {
    132122        if(!url.hasFocus()) return;
     
    135125            lat.setText(Double.toString((b.min.lat() + b.max.lat())/2));
    136126            lon.setText(Double.toString((b.min.lon() + b.max.lon())/2));
    137            
     127
    138128            int zoomLvl = 16;
    139             String[] args = url.getText().substring(url.getText().indexOf('?')+1).split("&"); 
    140             for (String arg : args) { 
    141                 int eq = arg.indexOf('='); 
    142                 if (eq == -1 || !arg.substring(0, eq).equalsIgnoreCase("zoom")) continue; 
    143                
     129            String[] args = url.getText().substring(url.getText().indexOf('?')+1).split("&");
     130            for (String arg : args) {
     131                int eq = arg.indexOf('=');
     132                if (eq == -1 || !arg.substring(0, eq).equalsIgnoreCase("zoom")) continue;
     133
    144134                zoomLvl = Integer.parseInt(arg.substring(eq + 1));
    145135                break;
    146136            }
    147            
     137
    148138            // 10000000 = 10 000 * 1000 = World * (km -> m)
    149139            zm.setText(Double.toString(Math.round(10000000 * Math.pow(2, (-1) * zoomLvl))));
    150140        }
    151141    }
    152    
     142
    153143    private void updateUrl(boolean force) {
    154144        if(!lat.hasFocus() && !lon.hasFocus() && !zm.hasFocus() && !force) return;
     
    170160        showJumpToDialog();
    171161    }
    172    
     162
    173163    /**
    174      * Converts a given scale into OSM-Style zoom factors 
     164     * Converts a given scale into OSM-Style zoom factors
    175165     * @param double scale
    176      */   
     166     */
    177167    public int getZoom(double scale) {
    178168        double sizex = scale * Main.map.mapView.getWidth();
    179169        double sizey = scale * Main.map.mapView.getHeight();
    180170        for (int zoom = 0; zoom <= 32; zoom++, sizex *= 2, sizey *= 2)
    181             if (sizex > Main.map.mapView.world.east() || sizey > Main.map.mapView.world.north())
     171            if (sizex > NavigatableComponent.world.east() || sizey > NavigatableComponent.world.north())
    182172                return zoom;
    183173        return 32;
    184174    }
    185  
     175
    186176    public void mousePressed(MouseEvent e) {}
    187177
  • applications/editors/josm/plugins/utilsplugin/src/UtilsPlugin/SimplifyWayAction.java

    r14121 r16162  
    5555                        boolean isInsideOneBoundingBox = false;
    5656                        for (Bounds b : bounds) {
    57                             if (b.contains(node.coor)) {
     57                            if (b.contains(node.getCoor())) {
    5858                                isInsideOneBoundingBox = true;
    5959                                break;
     
    161161            Node n = wnew.nodes.get(i);
    162162            double xte = Math.abs(EARTH_RAD
    163                     * xtd(fromN.coor.lat() * Math.PI / 180, fromN.coor.lon() * Math.PI / 180, toN.coor.lat() * Math.PI
    164                             / 180, toN.coor.lon() * Math.PI / 180, n.coor.lat() * Math.PI / 180, n.coor.lon() * Math.PI
     163                    * xtd(fromN.getCoor().lat() * Math.PI / 180, fromN.getCoor().lon() * Math.PI / 180, toN.getCoor().lat() * Math.PI
     164                            / 180, toN.getCoor().lon() * Math.PI / 180, n.getCoor().lat() * Math.PI / 180, n.getCoor().lon() * Math.PI
    165165                            / 180));
    166166            if (xte > xtemax) {
  • applications/editors/josm/plugins/utilsplugin/src/UtilsPlugin/UtilsPlugin.java

    r14120 r16162  
    11package UtilsPlugin;
    22
    3 import static org.openstreetmap.josm.tools.I18n.tr;
    4 
    5 
    6 import java.awt.event.ActionEvent;
    7 import javax.swing.AbstractAction;
    83import javax.swing.JMenuItem;
    9 import javax.swing.JOptionPane;
    10 import javax.swing.JPanel;
    11 import javax.swing.BoxLayout;
    124
    135import org.openstreetmap.josm.Main;
     6import org.openstreetmap.josm.gui.MainMenu;
     7import org.openstreetmap.josm.gui.MapFrame;
    148import org.openstreetmap.josm.plugins.Plugin;
    15 import org.openstreetmap.josm.gui.MapFrame;
    16 import org.openstreetmap.josm.gui.MainMenu;
    17 import org.openstreetmap.josm.gui.IconToggleButton;
    18 import org.openstreetmap.josm.actions.JosmAction;
    199
    2010public class UtilsPlugin extends Plugin {
Note: See TracChangeset for help on using the changeset viewer.