source: josm/trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ShowThumbnailAction.java@ 8041

Last change on this file since 8041 was 7954, checked in by stoecker, 9 years ago

see #10854 - fix typos

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. See LICENSE file for details.
2package org.openstreetmap.josm.gui.layer.geoimage;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Component;
7import java.awt.event.ActionEvent;
8import java.util.List;
9import javax.swing.AbstractAction;
10import javax.swing.JCheckBoxMenuItem;
11
12import org.openstreetmap.josm.Main;
13import org.openstreetmap.josm.gui.layer.Layer;
14import org.openstreetmap.josm.gui.layer.Layer.LayerAction;
15import org.openstreetmap.josm.tools.ImageProvider;
16
17/**
18 * Toggle the image display between thumbnails and symbols.
19 * @since 7935
20 */
21public class ShowThumbnailAction extends AbstractAction implements LayerAction {
22
23 private final GeoImageLayer layer;
24
25 /**
26 * Constructs a new {@code ToggleGeoImageThumbAction} action.
27 * @param layer image layer
28 */
29 public ShowThumbnailAction(GeoImageLayer layer) {
30 super(tr("Show thumbnails"), ImageProvider.get("dialogs/geoimage/togglegit"));
31 putValue(SHORT_DESCRIPTION, tr("Show image thumbnails instead of icons."));
32 this.layer = layer;
33 }
34
35 /**
36 * This is called after the menu entry was selected.
37 * @param arg0 action event
38 */
39 @Override
40 public void actionPerformed(ActionEvent arg0) {
41 layer.setUseThumbs(!layer.isUseThumbs());
42 Main.map.mapView.repaint();
43 }
44
45 /**
46 * Check if there is any suitable image to be toggled.
47 * @param layer image layer
48 * @return {@code true} if there are images to be toggled,
49 * {@code false} otherwise
50 */
51 private static boolean enabled(GeoImageLayer layer) {
52 return !layer.data.isEmpty();
53 }
54
55 /** Create actual menu entry and define if it is enabled or not. */
56 @Override
57 public Component createMenuComponent() {
58 JCheckBoxMenuItem toggleItem = new JCheckBoxMenuItem(this);
59 toggleItem.setEnabled(enabled(layer));
60 toggleItem.setState(layer.isUseThumbs());
61 return toggleItem;
62 }
63
64 /** Check if the current layer is supported. */
65 @Override
66 public boolean supportLayers(List<Layer> layers) {
67 return layers.size() == 1 && layers.get(0) instanceof GeoImageLayer;
68 }
69}
Note: See TracBrowser for help on using the repository browser.