Ignore:
Timestamp:
2009-07-03T12:34:14+02:00 (16 years ago)
Author:
stoecker
Message:

adapted plugins to JOSm 1722, UtilsPlugin still has a problem

Location:
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/MapUtils.java

    r15585 r16290  
    33import java.util.Collection;
    44import org.openstreetmap.josm.Main;
    5 import org.openstreetmap.josm.data.osm.Node;
     5import org.openstreetmap.josm.actions.AutoScaleAction;
    66import org.openstreetmap.josm.data.osm.OsmPrimitive;
    7 import org.openstreetmap.josm.data.osm.Way;
    8 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    9 import org.openstreetmap.josm.gui.MapView;
    107
    118/**
     
    2118
    2219    /**
    23      * Zoom level used for zooming to a single node.
    24      */
    25     public static final double NODE_ZOOM_LEVEL = 0.00000007;
    26 
    27 
    28     /**
    2920     * Selects and zooms the JOSM viewport to given primitives.
    30      *
    31      * <p>It does so by calculating the center of given primitives and
    32      * then it zooms to it.</p>
    33      *
    34      * <p><b>WARNING and TODO:</b> The method {@code zoomTo()} currently
    35      * checks for damaged {@link Node}s, whose {@code eastNorth} is set to
    36      * null. This property is not accessed in this method and therefore
    37      * no checking is done. However the "mad GUI" problem may still arise.
    38      * Therefore please be careful.</p>
    39      *
    40      * @see BoundingXYVisitor
    41      * @see MapView
    4221     */
    4322    public static void zoomToMany(Collection<OsmPrimitive> primitives) {
    44         BoundingXYVisitor visitor = new BoundingXYVisitor();
    45         for (OsmPrimitive op : primitives) {
    46             if (op instanceof Node)
    47                 ((Node) op).visit(visitor);
    48 
    49             else if (op instanceof Way)
    50                 ((Way) op).visit(visitor);
    51         }
    52         Main.map.mapView.zoomTo(
    53                 visitor.min.interpolate(visitor.max, 0.5),
    54                 NODE_ZOOM_LEVEL);
    5523        Main.ds.setSelected(primitives);
     24        (new AutoScaleAction("selection")).actionPerformed(null);
    5625    }
    5726
    5827    /**
    5928     * Selects and zooms the JOSM viewport to given primitive.
    60      *
    61      * <p><b>TODO:</b> There is an error in JOSM, which makes the whole
    62      * GUI totally mad if we zoom to a {@link Node}, whose {@code eastNorth}
    63      * is set null. Currently zooming to such a node is ignored, but the
    64      * question is where so such damaged nodes come from?</p>
    65      *
    66      * @see BoundingXYVisitor
    67      * @see MapView
    6829     */
    6930    public static void zoomTo(OsmPrimitive primitive) {
    70         BoundingXYVisitor visitor = new BoundingXYVisitor();
    71 
    72         if (primitive instanceof Node && ((Node) primitive).eastNorth != null)
    73             Main.map.mapView.zoomTo(((Node) primitive).eastNorth, NODE_ZOOM_LEVEL);
    74 
    75         else if (primitive instanceof Way) {
    76             ((Way) primitive).visit(visitor);
    77             Main.map.mapView.zoomTo(
    78                     visitor.min.interpolate(visitor.max, 0.5),
    79                     NODE_ZOOM_LEVEL);
    80         }
    81 
    8231        Main.ds.setSelected(primitive);
     32        (new AutoScaleAction("selection")).actionPerformed(null);
    8333    }
    8434}
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/AddressElement.java

    r15585 r16290  
    9797
    9898        if (prim instanceof Node)
    99             result += " " + StringUtils.latLonToString(((Node) prim).coor);
     99            result += " " + StringUtils.latLonToString(((Node) prim).getCoor());
    100100        else if (prim instanceof Way)
    101             result += " " + StringUtils.latLonToString(((Way) prim).firstNode().coor);
     101            result += " " + StringUtils.latLonToString(((Way) prim).firstNode().getCoor());
    102102
    103103        return result;
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.java

    r15649 r16290  
    4040        LocationSelector ls = new LocationSelector();
    4141        ls.setVisible(true);
    42        
     42
    4343        if (ls.getValue() == 1)
    4444            return ls.selectedElement;
     
    5050        super(Main.parent, "Výběr umístění",
    5151                            new String[] { "OK", "Zrušit"}, true);
    52        
     52
    5353        initComponents();
    5454        setupDialog(mainPanel, new String[] { "ok.png", "cancel.png"});
     
    6868     * Hardly ever working method for autodetecting the current location.
    6969     *
    70      * @deprecated 
     70     * @deprecated
    7171     */
    7272    private void autodetectLocation() {
     
    9393
    9494        try {
    95             Bounds bounds = visitor.getBounds();
    96             LatLon max = bounds.max;
    97             LatLon min = bounds.min;
    98             center = new LatLon(
    99                     (max.getX() + min.getX()) / 2,
    100                     (max.getY() + min.getY()) / 2);
    101 
     95            center = Main.proj.eastNorth2latlon(visitor.getBounds().getCenter());
    10296        } catch (Exception e) {
    10397            System.err.println("AUTO: No bounds to determine autolocation.");
     
    128122            }
    129123
    130             double currLen = multiplicator * (node.coor.distance(center));
     124            double currLen = multiplicator * (node.getCoor().distance(center));
    131125
    132126
     
    138132
    139133        if (bestFit != null) {
    140            
     134
    141135            if (assertions)
    142136                System.out.println("AUTO: Best fit " + bestFit.getName()
    143137                                 + "\t " + bestFit.get("name"));
    144            
     138
    145139            for (Region oblast : Database.getInstance().regions) {
    146140                for (ViToCi obec : oblast.getViToCis()) {
     
    263257        ItemEvent event = new ItemEvent(this,
    264258                   ItemEvent.DESELECTED, selectedElement, ItemEvent.DESELECTED);
    265        
     259
    266260        for (ItemListener i : listeners)
    267261            i.itemStateChanged(event);
     
    271265        event = new ItemEvent(this,
    272266                       ItemEvent.SELECTED, selectedElement, ItemEvent.SELECTED);
    273        
     267
    274268        for (ItemListener i : listeners)
    275269                i.itemStateChanged(event);
     
    323317        else if (oblastComboBox.getSelectedItem() != null)
    324318            selectedElement = ((ElementWithStreets) oblastComboBox.getSelectedItem());
    325        
     319
    326320        }//GEN-LAST:event_suburbComboBoxItemStateChanged
    327321
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/proposal/ExtractAddressIntoNodeProposal.java

    r15166 r16290  
    5151        if (!isApplicable(primitive))
    5252            return;
    53        
     53
    5454        Way way = (Way) primitive;
    5555
    5656        BoundingXYVisitor visitor = new BoundingXYVisitor();
    5757        way.visit(visitor);
    58         LatLon center = new LatLon(
    59                 (visitor.getBounds().max.lat() + visitor.getBounds().min.lat())/2,
    60                 (visitor.getBounds().max.lon() + visitor.getBounds().min.lon())/2
    61             );
    62        
    63         Node addrNode = new Node(center);
     58
     59        Node addrNode = new Node(visitor.getBounds().getCenter());
    6460
    6561        for (String key : way.keySet())
     
    7571    /**
    7672     * Returns textual representation of this proposal.
    77      * 
     73     *
    7874     * Currently the string is in Czech language (see {@link CzechAddressPlugin}).
    7975     */
     
    8379    }
    8480
    85    
     81
    8682
    8783}
Note: See TracChangeset for help on using the changeset viewer.