source: josm/trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java@ 6070

Last change on this file since 6070 was 6070, checked in by stoecker, 11 years ago

see #8853 remove tabs, trailing spaces, windows line ends, strange characters

  • Property svn:eol-style set to native
File size: 2.6 KB
Line 
1// This code has been adapted and copied from code that has been written by Immanuel Scholz and others for JOSM.
2// License: GPL. Copyright 2007 by Tim Haussmann
3package org.openstreetmap.josm.gui.download;
4
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.Dimension;
8import java.awt.Toolkit;
9import java.beans.PropertyChangeEvent;
10import java.beans.PropertyChangeListener;
11
12import javax.swing.JPanel;
13
14import org.openstreetmap.josm.data.Bounds;
15import org.openstreetmap.josm.gui.bbox.BBoxChooser;
16import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser;
17
18/**
19 * JComponent that displays the slippy map tiles
20 *
21 * @author Tim Haussmann
22 *
23 */
24public class SlippyMapChooser extends JPanel implements DownloadSelection, PropertyChangeListener{
25
26 private DownloadDialog iGui;
27 private SlippyMapBBoxChooser pnlSlippyMapBBoxChooser;
28 // standard dimension
29 private Dimension iDownloadDialogDimension;
30
31 /**
32 * Create the chooser component.
33 */
34 public SlippyMapChooser() {
35 pnlSlippyMapBBoxChooser = new SlippyMapBBoxChooser();
36 pnlSlippyMapBBoxChooser.addPropertyChangeListener(this);
37 }
38
39 public void addGui(final DownloadDialog gui) {
40 iGui = gui;
41 iGui.addDownloadAreaSelector(pnlSlippyMapBBoxChooser, tr("Slippy map"));
42 }
43
44 public void setDownloadArea(Bounds area) {
45 pnlSlippyMapBBoxChooser.setBoundingBox(area);
46 repaint();
47 }
48
49 public void propertyChange(PropertyChangeEvent evt) {
50 if (evt.getPropertyName().equals(BBoxChooser.BBOX_PROP)) {
51 if (iGui != null) {
52 iGui.boundingBoxChanged((Bounds)evt.getNewValue(), this);
53 }
54 } else if(evt.getPropertyName().equals(SlippyMapBBoxChooser.RESIZE_PROP)) {
55 int w, h;
56
57 // retrieve the size of the display
58 Dimension iScreenSize = Toolkit.getDefaultToolkit().getScreenSize();
59
60 // enlarge
61 if(iDownloadDialogDimension == null) {
62 // make the each dimension 90% of the absolute display size
63 w = iScreenSize.width * 90 / 100;
64 h = iScreenSize.height * 90 / 100;
65 iDownloadDialogDimension = iGui.getSize();
66 }
67 // shrink
68 else {
69 // set the size back to the initial dimensions
70 w = iDownloadDialogDimension.width;
71 h = iDownloadDialogDimension.height;
72 iDownloadDialogDimension = null;
73 }
74
75 // resize and center the DownloadDialog
76 iGui.setBounds((iScreenSize.width - w) / 2, (iScreenSize.height - h) / 2, w, h);
77 repaint();
78 }
79 }
80}
Note: See TracBrowser for help on using the repository browser.