source: osm/applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointDialog.java

Last change on this file was 33561, checked in by donvip, 7 years ago

fix warnings

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.insignificant.josm.plugins.imagewaypoint;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.BorderLayout;
7import java.awt.event.KeyEvent;
8
9import javax.swing.Action;
10import javax.swing.JButton;
11import javax.swing.JPanel;
12
13import org.insignificant.josm.plugins.imagewaypoint.actions.NextAction;
14import org.insignificant.josm.plugins.imagewaypoint.actions.PreviousAction;
15import org.insignificant.josm.plugins.imagewaypoint.actions.RotateLeftAction;
16import org.insignificant.josm.plugins.imagewaypoint.actions.RotateRightAction;
17import org.openstreetmap.josm.gui.MainApplication;
18import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
19import org.openstreetmap.josm.tools.Shortcut;
20
21public final class ImageWayPointDialog extends ToggleDialog {
22 final ImageComponent imageDisplay;
23 private final Action previousAction;
24 private final Action nextAction;
25 private final Action rotateLeftAction;
26 private final Action rotateRightAction;
27
28 private final IImageChangeListener listener;
29
30 public ImageWayPointDialog() {
31 super(tr("WayPoint Image"), "imagewaypoint", tr("Display non-geotagged photos"),
32 Shortcut.registerShortcut("subwindow:imagewaypoint", tr("Toggle: {0}", tr("WayPoint Image")),
33 KeyEvent.VK_Y, Shortcut.ALT_SHIFT), 200);
34
35 this.previousAction = new PreviousAction();
36 this.nextAction = new NextAction();
37 this.rotateLeftAction = new RotateLeftAction();
38 this.rotateRightAction = new RotateRightAction();
39
40 final JButton previousButton = new JButton(this.previousAction);
41 final JButton nextButton = new JButton(this.nextAction);
42 final JButton rotateLeftButton = new JButton(this.rotateLeftAction);
43 final JButton rotateRightButton = new JButton(this.rotateRightAction);
44
45 // default layout, FlowLayout, is fine
46 final JPanel buttonPanel = new JPanel();
47 buttonPanel.add(previousButton);
48 buttonPanel.add(nextButton);
49 buttonPanel.add(rotateLeftButton);
50 buttonPanel.add(rotateRightButton);
51
52 final JPanel mainPanel = new JPanel();
53 mainPanel.setLayout(new BorderLayout());
54
55 this.imageDisplay = new ImageComponent();
56 mainPanel.add(buttonPanel, BorderLayout.SOUTH);
57 mainPanel.add(this.imageDisplay, BorderLayout.CENTER);
58
59 this.listener = new ImageChangeListener(this);
60 ImageEntries.getInstance().addListener(this.listener);
61
62 this.updateGUI();
63 add(mainPanel);
64 }
65
66 void updateGUI() {
67 this.previousAction.setEnabled(ImageEntries.getInstance().hasPrevious());
68 this.nextAction.setEnabled(ImageEntries.getInstance().hasNext());
69 this.rotateLeftAction.setEnabled(null != ImageEntries.getInstance().getCurrentImageEntry());
70 this.rotateRightAction.setEnabled(null != ImageEntries.getInstance().getCurrentImageEntry());
71
72 if (null != MainApplication.getMap()) {
73 MainApplication.getMap().repaint();
74 }
75 }
76}
Note: See TracBrowser for help on using the repository browser.