Changeset 12955 in josm for trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
- Timestamp:
- 2017-10-09T00:17:55+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
r12931 r12955 22 22 import java.util.concurrent.CopyOnWriteArrayList; 23 23 24 import javax.swing.ButtonModel; 25 import javax.swing.JToggleButton; 24 26 import javax.swing.JOptionPane; 25 27 import javax.swing.SpringLayout; 28 import javax.swing.event.ChangeListener; 29 import javax.swing.event.ChangeEvent; 26 30 27 31 import org.openstreetmap.gui.jmapviewer.Coordinate; … … 44 48 import org.openstreetmap.josm.data.imagery.TileLoaderFactory; 45 49 import org.openstreetmap.josm.data.osm.BBox; 50 import org.openstreetmap.josm.data.preferences.BooleanProperty; 46 51 import org.openstreetmap.josm.data.preferences.StringProperty; 47 52 import org.openstreetmap.josm.gui.MainApplication; … … 56 61 * This panel displays a map and lets the user chose a {@link BBox}. 57 62 */ 58 public class SlippyMapBBoxChooser extends JMapViewer implements BBoxChooser, MainLayerManager.ActiveLayerChangeListener {63 public class SlippyMapBBoxChooser extends JMapViewer implements BBoxChooser, ChangeListener, MainLayerManager.ActiveLayerChangeListener { 59 64 60 65 /** … … 121 126 122 127 private static final StringProperty PROP_MAPSTYLE = new StringProperty("slippy_map_chooser.mapstyle", "Mapnik"); 128 private static final BooleanProperty PROP_SHOWDLAREA = new BooleanProperty("slippy_map_chooser.show_downloaded_area", true); 123 129 /** 124 130 * The property name used for the resize button. … … 131 137 132 138 private final SizeButton iSizeButton; 139 private final ButtonModel showDownloadAreaButtonModel; 133 140 private final SourceButton iSourceButton; 134 141 private transient Bounds bbox; … … 173 180 List<TileSource> tileSources = getAllTileSources(); 174 181 175 iSourceButton = new SourceButton(this, tileSources); 182 this.showDownloadAreaButtonModel = new JToggleButton.ToggleButtonModel(); 183 this.showDownloadAreaButtonModel.setSelected(PROP_SHOWDLAREA.get()); 184 this.showDownloadAreaButtonModel.addChangeListener(this); 185 iSourceButton = new SourceButton(this, tileSources, this.showDownloadAreaButtonModel); 176 186 add(iSourceButton); 177 springLayout.putConstraint(SpringLayout.EAST, iSourceButton, 0, SpringLayout.EAST, this);178 springLayout.putConstraint(SpringLayout.NORTH, iSourceButton, 30, SpringLayout.NORTH, this);187 springLayout.putConstraint(SpringLayout.EAST, iSourceButton, -2, SpringLayout.EAST, this); 188 springLayout.putConstraint(SpringLayout.NORTH, iSourceButton, 2, SpringLayout.NORTH, this); 179 189 180 190 iSizeButton = new SizeButton(this); … … 231 241 // enough to make sharing code impractical) 232 242 final OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 233 if (editLayer != null && Config.getPref().getBoolean("draw.data.downloaded_area", true) && !editLayer.data.getDataSources().isEmpty()) {243 if (editLayer != null && this.showDownloadAreaButtonModel.isSelected() && !editLayer.data.getDataSources().isEmpty()) { 234 244 // initialize area with current viewport 235 245 Rectangle b = this.getBounds(); … … 271 281 @Override 272 282 public void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e) { 283 this.repaint(); 284 } 285 286 @Override 287 public void stateChanged(ChangeEvent e) { 288 // fired for the stateChanged event of this.showDownloadAreaButtonModel 289 PROP_SHOWDLAREA.put(this.showDownloadAreaButtonModel.isSelected()); 273 290 this.repaint(); 274 291 } … … 342 359 this.setTileSource(tileSource); 343 360 PROP_MAPSTYLE.put(tileSource.getName()); // TODO Is name really unique? 361 if (this.iSourceButton.getCurrentSource() != tileSource) { // prevent infinite recursion 362 this.iSourceButton.setCurrentMap(tileSource); 363 } 344 364 } 345 365
Note:
See TracChangeset
for help on using the changeset viewer.