Changeset 10310 in osm for applications/editors/josm


Ignore:
Timestamp:
2008-08-29T15:28:56+02:00 (16 years ago)
Author:
stotz
Message:

Bugfix: Zoom level was wrong when displaying an external specified bounding box for the first time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/slippy_map_chooser/src/SlippyMapChooser.java

    r9851 r10310  
    1111import java.awt.Point;
    1212import java.awt.Toolkit;
     13import java.awt.event.ComponentEvent;
     14import java.awt.event.ComponentListener;
    1315import java.awt.geom.Point2D;
    1416import java.util.Vector;
     
    3638 *
    3739 */
    38 public class SlippyMapChooser extends JMapViewer implements DownloadSelection {
     40public class SlippyMapChooser extends JMapViewer implements DownloadSelection, ComponentListener {
    3941
    4042        private DownloadDialog iGui;
     
    5658        TileLoader cachedLoader;
    5759        TileLoader uncachedLoader;
     60        JPanel slipyyMapTabPanel;
     61        boolean firstShown = true;
    5862
    5963        /**
     
    6973                setFileCacheEnabled(SlippyMapChooserPlugin.ENABLE_FILE_CACHE);
    7074                setMaxTilesInmemory(SlippyMapChooserPlugin.MAX_TILES_IN_MEMORY);
     75                addComponentListener(this);
    7176        }
    7277
     
    8489        public void addGui(final DownloadDialog gui) {
    8590                iGui = gui;
    86                 JPanel temp = new JPanel();
    87                 temp.setLayout(new BorderLayout());
    88                 temp.add(this, BorderLayout.CENTER);
    89                 temp.add(new JLabel((tr("Zoom: Mousewheel or double click.   "
     91                slipyyMapTabPanel = new JPanel();
     92                slipyyMapTabPanel.setLayout(new BorderLayout());
     93                slipyyMapTabPanel.add(this, BorderLayout.CENTER);
     94                slipyyMapTabPanel.add(new JLabel((tr("Zoom: Mousewheel or double click.   "
    9095                                + "Move map: Hold right mousebutton and move mouse.   Select: Click."))),
    9196                                BorderLayout.SOUTH);
    92                 iGui.tabpane.add(temp, tr("Slippy map"));
    93 
    94                 new OsmMapControl(this, temp, iSizeButton, iSourceButton);
    95                 boundingBoxChanged(gui);
     97                iGui.tabpane.add(slipyyMapTabPanel, tr("Slippy map"));
     98                iGui.tabpane.addComponentListener(this);
     99                new OsmMapControl(this, slipyyMapTabPanel, iSizeButton, iSourceButton);
    96100        }
    97101
     
    250254        }
    251255
     256        public void componentHidden(ComponentEvent e) {
     257        }
     258
     259        public void componentMoved(ComponentEvent e) {
     260        }
     261
     262        public void componentShown(ComponentEvent e) {
     263        }
     264
     265        public void componentResized(ComponentEvent e) {
     266                if (!this.equals(e.getSource()) || getHeight() == 0 || getWidth() == 0)
     267                        return;
     268                firstShown = false;
     269                // The bounding box has to be set after SlippyMapChooser's size has been
     270                // finally set - otherwise the zoom level will be totally wrong (too wide)
     271                boundingBoxChanged(iGui);
     272        }
     273
    252274}
Note: See TracChangeset for help on using the changeset viewer.