Ignore:
Timestamp:
27.10.2009 01:21:32 (3 years ago)
Author:
Gubaer
Message:

Cleanup in download logic (less global, more encapsulation)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java

    r2093 r2327  
    3030import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 
    3131import org.openstreetmap.josm.Main; 
     32import org.openstreetmap.josm.data.Bounds; 
     33import org.openstreetmap.josm.data.coor.LatLon; 
    3234 
    3335/** 
     
    120122        String labelText = tr("<b>Zoom:</b> Mousewheel, double click or Ctrl + Up/Down " 
    121123                + "<b>Move map:</b> Hold right mousebutton and move mouse or use cursor keys. <b>Select:</b> Hold left mousebutton and draw a frame."); 
    122         slipyyMapTabPanel.add(new JLabel("<html>" + labelText + "</html>"), BorderLayout.SOUTH); 
    123         iGui.tabpane.add(slipyyMapTabPanel, tr("Slippy map")); 
     124        slipyyMapTabPanel.add(new JLabel("<html>" + labelText + "</html>"), BorderLayout.SOUTH);         
     125        iGui.addDownloadAreaSelector(slipyyMapTabPanel, tr("Slippy map")); 
    124126        new OsmMapControl(this, slipyyMapTabPanel, iSizeButton, iSourceButton); 
    125127    } 
     
    165167 
    166168    public void boundingBoxChanged(DownloadDialog gui) { 
    167  
     169        Bounds b = gui.getSelectedDownloadArea(); 
     170        if (b == null) 
     171            return; 
     172         
    168173        // test if a bounding box has been set set 
    169         if (gui.minlat == 0.0 && gui.minlon == 0.0 && gui.maxlat == 0.0 && gui.maxlon == 0.0) 
     174        if (b.getMin().lat() == 0.0 && b.getMin().lon() == 0.0 && b.getMax().lat() == 0.0 && b.getMax().lon() == 0.0) 
    170175            return; 
    171176 
    172         int y1 = OsmMercator.LatToY(gui.minlat, MAX_ZOOM); 
    173         int y2 = OsmMercator.LatToY(gui.maxlat, MAX_ZOOM); 
    174         int x1 = OsmMercator.LonToX(gui.minlon, MAX_ZOOM); 
    175         int x2 = OsmMercator.LonToX(gui.maxlon, MAX_ZOOM); 
     177        int y1 = OsmMercator.LatToY(b.getMin().lat(), MAX_ZOOM); 
     178        int y2 = OsmMercator.LatToY(b.getMax().lat(), MAX_ZOOM); 
     179        int x1 = OsmMercator.LonToX(b.getMin().lon(), MAX_ZOOM); 
     180        int x2 = OsmMercator.LonToX(b.getMax().lon(), MAX_ZOOM); 
    176181 
    177182        iSelectionRectStart = new Point(Math.min(x1, x2), Math.min(y1, y2)); 
     
    179184 
    180185        // calc the screen coordinates for the new selection rectangle 
    181         MapMarkerDot xmin_ymin = new MapMarkerDot(gui.minlat, gui.minlon); 
    182         MapMarkerDot xmax_ymax = new MapMarkerDot(gui.maxlat, gui.maxlon); 
     186        MapMarkerDot xmin_ymin = new MapMarkerDot(b.getMin()); 
     187        MapMarkerDot xmax_ymax = new MapMarkerDot(b.getMax()); 
    183188 
    184189        Vector<MapMarker> marker = new Vector<MapMarker>(2); 
     
    218223        Coordinate l1 = getPosition(p_max); 
    219224        Coordinate l2 = getPosition(p_min); 
    220         iGui.minlon = Math.min(l2.getLon(), l1.getLon()); 
    221         iGui.minlat = Math.min(l1.getLat(), l2.getLat()); 
    222         iGui.maxlon = Math.max(l2.getLon(), l1.getLon()); 
    223         iGui.maxlat = Math.max(l1.getLat(), l2.getLat()); 
    224  
    225         iGui.boundingBoxChanged(this); 
     225        Bounds b = new Bounds( 
     226                new LatLon( 
     227                        Math.min(l2.getLat(), l1.getLat()),  
     228                        Math.min(l1.getLon(), l2.getLon()) 
     229                        ), 
     230                new LatLon( 
     231                        Math.max(l2.getLat(), l1.getLat()),  
     232                        Math.max(l1.getLon(), l2.getLon())) 
     233                ); 
     234        iGui.boundingBoxChanged(b, this); 
    226235        repaint(); 
    227236    } 
Note: See TracChangeset for help on using the changeset viewer.