1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.download;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.beans.PropertyChangeEvent;
|
---|
7 | import java.beans.PropertyChangeListener;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.data.Bounds;
|
---|
10 | import org.openstreetmap.josm.gui.bbox.BBoxChooser;
|
---|
11 | import org.openstreetmap.josm.gui.bbox.TileSelectionBBoxChooser;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Tile selector.
|
---|
15 | *
|
---|
16 | * Provides a tile coordinate input field.
|
---|
17 | *
|
---|
18 | * @author Frederik Ramm
|
---|
19 | *
|
---|
20 | */
|
---|
21 | public class TileSelection implements DownloadSelection, PropertyChangeListener {
|
---|
22 | private TileSelectionBBoxChooser chooser;
|
---|
23 | private DownloadDialog parent;
|
---|
24 |
|
---|
25 | protected final void build() {
|
---|
26 | chooser = new TileSelectionBBoxChooser();
|
---|
27 | chooser.addPropertyChangeListener(this);
|
---|
28 | }
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Constructs a new {@code TileSelection}.
|
---|
32 | */
|
---|
33 | public TileSelection() {
|
---|
34 | build();
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | public void addGui(final DownloadDialog gui) {
|
---|
39 | if (gui != null)
|
---|
40 | gui.addDownloadAreaSelector(chooser, tr("Tile Numbers"));
|
---|
41 | parent = gui;
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public void setDownloadArea(Bounds area) {
|
---|
46 | chooser.setBoundingBox(area);
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public void propertyChange(PropertyChangeEvent evt) {
|
---|
51 | if (evt.getPropertyName().equals(BBoxChooser.BBOX_PROP)) {
|
---|
52 | Bounds bbox = (Bounds) evt.getNewValue();
|
---|
53 | parent.boundingBoxChanged(bbox, this);
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|