Changeset 4336 in josm


Ignore:
Timestamp:
2011-08-25T23:58:48+02:00 (13 years ago)
Author:
stoecker
Message:

fix #6720 - slippy map download not refreshed, improve resize handling for slippy map downloader

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/bbox/SizeButton.java

    r3094 r4336  
    2626    }
    2727
    28     public void paint(Graphics g){
    29         if(isEnlarged){
     28    public void paint(Graphics g) {
     29        if(isEnlarged) {
    3030            if(shrinkImage != null)
    3131                g.drawImage(shrinkImage.getImage(),x,y, null);
    32         }else{
     32        } else {
    3333            if(enlargeImage != null)
    3434                g.drawImage(enlargeImage.getImage(),x,y, null);
     
    3636    }
    3737
    38     public void toggle(){
     38    public void toggle() {
    3939        isEnlarged = !isEnlarged;
    4040    }
    4141
    42     public boolean hit(Point point){
    43         if(x < point.x && point.x < x + enlargeImage.getIconWidth()){
    44             if(y < point.y && point.y < y + enlargeImage.getIconHeight() ){
     42    public boolean isEnlarged() {
     43        return isEnlarged;
     44    }
     45
     46    public boolean hit(Point point) {
     47        if(x < point.x && point.x < x + enlargeImage.getIconWidth()) {
     48            if(y < point.y && point.y < y + enlargeImage.getIconHeight()) {
    4549                return true;
    4650            }
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r4202 r4336  
    1010import java.awt.Point;
    1111import java.awt.Rectangle;
    12 import java.awt.Toolkit;
    1312import java.io.File;
    1413import java.io.IOException;
     
    4039import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
    4140import org.openstreetmap.josm.data.preferences.StringProperty;
    42 import org.openstreetmap.josm.gui.download.DownloadDialog;
    4341import org.openstreetmap.josm.gui.layer.TMSLayer;
    4442
     
    153151
    154152    private static final StringProperty PROP_MAPSTYLE = new StringProperty("slippy_map_chooser.mapstyle", "Mapnik");
    155 
    156     // standard dimension
    157     private Dimension iDownloadDialogDimension;
     153    public static final String RESIZE_PROP = SlippyMapBBoxChooser.class.getName() + ".resize";
    158154
    159155    private TileLoader cachedLoader;
     
    341337        Bounds oldValue = this.bbox;
    342338        this.bbox = b;
     339        repaint();
    343340        firePropertyChange(BBOX_PROP, oldValue, this.bbox);
    344         repaint();
    345     }
    346 
    347     private DownloadDialog iGui;
    348 
    349     public void setGui(final DownloadDialog gui) {
    350         iGui = gui;
    351341    }
    352342
     
    356346     */
    357347    public void resizeSlippyMap() {
    358         int w, h;
    359 
    360         // retrieve the size of the display
    361         Dimension iScreenSize = Toolkit.getDefaultToolkit().getScreenSize();
    362 
    363         // enlarge
    364         if(iDownloadDialogDimension == null) {
    365             // make the each dimension 90% of the absolute display size
    366             w = iScreenSize.width * 90 / 100;
    367             h = iScreenSize.height * 90 / 100;
    368             iDownloadDialogDimension = iGui.getSize();
    369         }
    370         // shrink
    371         else {
    372             // set the size back to the initial dimensions
    373             w = iDownloadDialogDimension.width;
    374             h = iDownloadDialogDimension.height;
    375             iDownloadDialogDimension = null;
    376         }
    377 
    378         // resize and center the DownloadDialog
    379         iGui.setBounds((iScreenSize.width - w) / 2, (iScreenSize.height - h) / 2, w, h);
    380         repaint();
     348        boolean large = iSizeButton.isEnlarged();
     349        firePropertyChange(RESIZE_PROP, !large, large);
    381350    }
    382351
     
    398367     */
    399368    public void setBoundingBox(Bounds bbox) {
    400         if (bbox == null) {
     369        if (bbox == null || (bbox.getMin().lat() == 0.0 && bbox.getMin().lon() == 0.0
     370        && bbox.getMax().lat() == 0.0 && bbox.getMax().lon() == 0.0)) {
    401371            this.bbox = null;
     372            iSelectionRectStart = null;
     373            iSelectionRectEnd = null;
     374            repaint();
    402375            return;
    403376        }
    404         // test if a bounding box has been set
    405         if (bbox.getMin().lat() == 0.0 && bbox.getMin().lon() == 0.0 && bbox.getMax().lat() == 0.0 && bbox.getMax().lon() == 0.0) {
    406             this.bbox = null;
    407         }
    408 
     377
     378        this.bbox = bbox;
    409379        int y1 = OsmMercator.LatToY(bbox.getMin().lat(), MAX_ZOOM);
    410380        int y2 = OsmMercator.LatToY(bbox.getMax().lat(), MAX_ZOOM);
     
    425395        setDisplayToFitMapMarkers();
    426396        zoomOut();
    427         this.bbox = bbox;
    428397    }
    429398}
  • trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java

    r4168 r4336  
    44
    55import static org.openstreetmap.josm.tools.I18n.tr;
     6
     7import java.awt.Dimension;
     8import java.awt.Graphics;
     9import java.awt.Toolkit;
    610
    711import java.beans.PropertyChangeEvent;
     
    2428    private DownloadDialog iGui;
    2529    private SlippyMapBBoxChooser pnlSlippyMapBBoxChooser;
     30    // standard dimension
     31    private Dimension iDownloadDialogDimension;
    2632
    2733    /**
     
    3541    public void addGui(final DownloadDialog gui) {
    3642        iGui = gui;
    37         pnlSlippyMapBBoxChooser.setGui(iGui);
    3843        iGui.addDownloadAreaSelector(pnlSlippyMapBBoxChooser, tr("Slippy map"));
    3944    }
     
    4146    public void setDownloadArea(Bounds area) {
    4247        pnlSlippyMapBBoxChooser.setBoundingBox(area);
     48        repaint();
    4349    }
    4450
     
    4854                iGui.boundingBoxChanged((Bounds)evt.getNewValue(), this);
    4955            }
     56        } else if(evt.getPropertyName().equals(SlippyMapBBoxChooser.RESIZE_PROP)) {
     57            int w, h;
     58
     59            // retrieve the size of the display
     60            Dimension iScreenSize = Toolkit.getDefaultToolkit().getScreenSize();
     61
     62            // enlarge
     63            if(iDownloadDialogDimension == null) {
     64                // make the each dimension 90% of the absolute display size
     65                w = iScreenSize.width * 90 / 100;
     66                h = iScreenSize.height * 90 / 100;
     67                iDownloadDialogDimension = iGui.getSize();
     68            }
     69            // shrink
     70            else {
     71                // set the size back to the initial dimensions
     72                w = iDownloadDialogDimension.width;
     73                h = iDownloadDialogDimension.height;
     74                iDownloadDialogDimension = null;
     75            }
     76
     77            // resize and center the DownloadDialog
     78            iGui.setBounds((iScreenSize.width - w) / 2, (iScreenSize.height - h) / 2, w, h);
     79            repaint();
    5080        }
    5181    }
Note: See TracChangeset for help on using the changeset viewer.