1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.insignificant.josm.plugins.imagewaypoint;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.BorderLayout;
|
---|
7 | import java.awt.event.KeyEvent;
|
---|
8 |
|
---|
9 | import javax.swing.Action;
|
---|
10 | import javax.swing.JButton;
|
---|
11 | import javax.swing.JPanel;
|
---|
12 |
|
---|
13 | import org.insignificant.josm.plugins.imagewaypoint.actions.NextAction;
|
---|
14 | import org.insignificant.josm.plugins.imagewaypoint.actions.PreviousAction;
|
---|
15 | import org.insignificant.josm.plugins.imagewaypoint.actions.RotateLeftAction;
|
---|
16 | import org.insignificant.josm.plugins.imagewaypoint.actions.RotateRightAction;
|
---|
17 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
18 | import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
|
---|
19 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
20 |
|
---|
21 | public 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 | }
|
---|