source: josm/trunk/src/org/openstreetmap/josm/gui/layer/imagery/AutoZoomAction.java

Last change on this file was 11950, checked in by Don-vip, 8 years ago

extract actions from AbstractTileSourceLayer to gui.layer.imagery package

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer.imagery;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Component;
7import java.awt.event.ActionEvent;
8import java.util.List;
9
10import javax.swing.AbstractAction;
11import javax.swing.JCheckBoxMenuItem;
12
13import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
14import org.openstreetmap.josm.gui.layer.Layer;
15import org.openstreetmap.josm.gui.layer.Layer.LayerAction;
16
17/**
18 * Auto zoom.
19 * @since 11950 (extracted from {@link AbstractTileSourceLayer})
20 */
21public class AutoZoomAction extends AbstractAction implements LayerAction {
22
23 private final AbstractTileSourceLayer<?> layer;
24
25 /**
26 * Constructs a new {@code AutoZoomAction}.
27 * @param layer imagery layer
28 */
29 public AutoZoomAction(AbstractTileSourceLayer<?> layer) {
30 super(tr("Auto zoom"));
31 this.layer = layer;
32 }
33
34 @Override
35 public void actionPerformed(ActionEvent ae) {
36 TileSourceDisplaySettings settings = layer.getDisplaySettings();
37 settings.setAutoZoom(!settings.isAutoZoom());
38 }
39
40 @Override
41 public Component createMenuComponent() {
42 JCheckBoxMenuItem item = new JCheckBoxMenuItem(this);
43 item.setSelected(layer.getDisplaySettings().isAutoZoom());
44 return item;
45 }
46
47 @Override
48 public boolean supportLayers(List<Layer> layers) {
49 return AbstractTileSourceLayer.actionSupportLayers(layers);
50 }
51}
Note: See TracBrowser for help on using the repository browser.