source: osm/applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/dialogs/OSeaMAction.java@ 24630

Last change on this file since 24630 was 24630, checked in by malcolmh, 14 years ago

test image

File size: 9.3 KB
Line 
1package oseam.dialogs;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5import oseam.panels.*;
6
7import java.awt.Color;
8import java.awt.Dimension;
9import java.awt.Font;
10import java.awt.Rectangle;
11import java.awt.event.ActionEvent;
12import java.awt.event.ActionListener;
13import java.awt.event.ComponentListener;
14import java.awt.event.FocusAdapter;
15import java.awt.event.FocusEvent;
16import java.awt.event.ItemEvent;
17import java.awt.event.ItemListener;
18import java.beans.PropertyChangeListener;
19import java.util.Collection;
20import java.util.Iterator;
21import java.util.Map;
22
23import javax.swing.BorderFactory;
24import javax.swing.ButtonGroup;
25import javax.swing.ImageIcon;
26import javax.swing.JButton;
27import javax.swing.JCheckBox;
28import javax.swing.JComboBox;
29import javax.swing.JLabel;
30import javax.swing.JMenuItem;
31import javax.swing.JPanel;
32import javax.swing.JRadioButton;
33import javax.swing.JTextField;
34
35import org.openstreetmap.josm.Main;
36import org.openstreetmap.josm.command.ChangePropertyCommand;
37import org.openstreetmap.josm.command.Command;
38import org.openstreetmap.josm.data.SelectionChangedListener;
39import org.openstreetmap.josm.data.osm.DataSet;
40import org.openstreetmap.josm.data.osm.Node;
41import org.openstreetmap.josm.data.osm.OsmPrimitive;
42import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
43import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
44
45import oseam.Messages;
46import oseam.OSeaM;
47
48public class OSeaMAction {
49
50 private JPanel oseamPanel = null;
51
52 private JLabel shapeIcon = null;
53 private JLabel lightIcon = null;
54 private JLabel topIcon = null;
55 private JLabel reflIcon = null;
56 private JLabel radarIcon = null;
57 private JLabel fogIcon = null;
58 private JLabel nameLabel = null;
59 private JTextField nameBox = null;
60 private JButton saveButton = null;
61 private ButtonGroup typeButtons = null;
62 private JRadioButton chanButton = null;
63 private JRadioButton hazButton = null;
64 private JRadioButton specButton = null;
65 private JRadioButton lightsButton = null;
66 private ButtonGroup miscButtons = null;
67 private JRadioButton topButton = null;
68 private JRadioButton fogButton = null;
69 private JRadioButton radarButton = null;
70 private JRadioButton litButton = null;
71 private PanelChan panelChan = null;
72 private PanelHaz panelHaz = null;
73 private PanelSpec panelSpec = null;
74
75 public OSeaMAction() {
76
77 String str = Main.pref.get("mappaint.style.sources");
78 if (!str.contains("dev.openseamap.org")) {
79 if (!str.isEmpty())
80 str += new String(new char[] { 0x1e });
81 Main.pref.put("mappaint.style.sources", str
82 + "http://dev.openseamap.org/josm/seamark_styles.xml");
83 }
84 str = Main.pref.get("color.background");
85 if (str.equals("#000000") || str.isEmpty())
86 Main.pref.put("color.background", "#606060");
87
88 panelChan= new PanelChan();
89 panelChan.setBounds(new Rectangle(105, 0, 295, 160));
90 panelChan.setVisible(false);
91 panelHaz= new PanelHaz();
92 panelHaz.setBounds(new Rectangle(105, 0, 295, 160));
93 panelHaz.setVisible(false);
94 panelSpec= new PanelSpec();
95 panelSpec.setBounds(new Rectangle(105, 0, 295, 160));
96 panelSpec.setVisible(false);
97 }
98
99 public JPanel getOSeaMPanel() {
100 if (oseamPanel == null) {
101 oseamPanel = new JPanel();
102 oseamPanel.setLayout(null);
103 oseamPanel.setSize(new Dimension(400, 360));
104
105 shapeIcon = new JLabel(new ImageIcon(getClass().getResource("/images/Cardinal_Pillar_South.png")));
106 shapeIcon.setBounds(new Rectangle(265, 165, 130, 185));
107 oseamPanel.add(shapeIcon, null);
108 lightIcon = new JLabel(new ImageIcon(getClass().getResource("/images/Light_White_120.png")));
109 lightIcon.setBounds(new Rectangle(265, 165, 125, 185));
110 oseamPanel.add(lightIcon, null);
111 topIcon = new JLabel();
112 topIcon.setBounds(new Rectangle(265, 165, 125, 185));
113 oseamPanel.add(topIcon, null);
114 reflIcon = new JLabel(new ImageIcon(getClass().getResource("/images/Radar_Reflector_355.png")));
115 reflIcon.setBounds(new Rectangle(265, 165, 125, 185));
116 oseamPanel.add(reflIcon, null);
117 radarIcon = new JLabel(new ImageIcon(getClass().getResource("/images/Radar_Station.png")));
118 radarIcon.setBounds(new Rectangle(265, 165, 130, 185));
119 oseamPanel.add(radarIcon, null);
120 fogIcon = new JLabel(new ImageIcon(getClass().getResource("/images/Fog_Signal.png")));
121 fogIcon.setBounds(new Rectangle(265, 165, 125, 185));
122 oseamPanel.add(fogIcon, null);
123
124 oseamPanel.add(getChanButton(), null);
125 oseamPanel.add(getHazButton(), null);
126 oseamPanel.add(getSpecButton(), null);
127 oseamPanel.add(getLightsButton(), null);
128 oseamPanel.add(panelChan, null);
129 oseamPanel.add(panelHaz, null);
130 oseamPanel.add(panelSpec, null);
131 typeButtons = new ButtonGroup();
132 typeButtons.add(chanButton);
133 typeButtons.add(hazButton);
134 typeButtons.add(specButton);
135 typeButtons.add(lightsButton);
136 ActionListener alType = new ActionListener() {
137 public void actionPerformed(java.awt.event.ActionEvent e) {
138 if (chanButton.isSelected()) {
139 chanButton.setEnabled(false);
140 panelChan.setVisible(true);
141 } else {
142 chanButton.setEnabled(true);
143 panelChan.setVisible(false);
144 }
145 if (hazButton.isSelected()) {
146 hazButton.setEnabled(false);
147 panelHaz.setVisible(true);
148 } else {
149 hazButton.setEnabled(true);
150 panelHaz.setVisible(false);
151 }
152 if (specButton.isSelected()) {
153 specButton.setEnabled(false);
154 panelSpec.setVisible(true);
155 } else {
156 specButton.setEnabled(true);
157 panelSpec.setVisible(false);
158 }
159 lightsButton.setEnabled(!lightsButton.isSelected());
160 }
161 };
162 chanButton.addActionListener(alType);
163 hazButton.addActionListener(alType);
164 specButton.addActionListener(alType);
165 lightsButton.addActionListener(alType);
166
167 oseamPanel.add(getTopButton(), null);
168 oseamPanel.add(getFogButton(), null);
169 oseamPanel.add(getRadarButton(), null);
170 oseamPanel.add(getLitButton(), null);
171 miscButtons = new ButtonGroup();
172 miscButtons.add(topButton);
173 miscButtons.add(fogButton);
174 miscButtons.add(radarButton);
175 miscButtons.add(litButton);
176 ActionListener alMisc = new ActionListener() {
177 public void actionPerformed(java.awt.event.ActionEvent e) {
178 topButton.setEnabled(!topButton.isSelected());
179 fogButton.setEnabled(!fogButton.isSelected());
180 radarButton.setEnabled(!radarButton.isSelected());
181 litButton.setEnabled(!litButton.isSelected());
182 }
183 };
184 topButton.addActionListener(alMisc);
185 fogButton.addActionListener(alMisc);
186 radarButton.addActionListener(alMisc);
187 litButton.addActionListener(alMisc);
188
189 nameLabel = new JLabel();
190 nameLabel.setBounds(new Rectangle(5, 327, 60, 20));
191 nameLabel.setText(tr("Name:"));
192 oseamPanel.add(nameLabel, null);
193 nameBox = new JTextField();
194 nameBox.setBounds(new Rectangle(60, 325, 200, 25));
195 oseamPanel.add(nameBox, null);
196 saveButton = new JButton();
197 saveButton.setBounds(new Rectangle(285, 325, 100, 25));
198 saveButton.setText(tr("Save"));
199 oseamPanel.add(saveButton, null);
200 }
201 return oseamPanel;
202 }
203
204 private JRadioButton getChanButton() {
205 if (chanButton == null) {
206 chanButton = new JRadioButton(new ImageIcon(getClass().getResource(
207 Messages.getString("ChanButton"))));
208 chanButton.setBounds(new Rectangle(0, 0, 105, 40));
209 chanButton.setToolTipText(Messages.getString("ChanTip"));
210 }
211 return chanButton;
212 }
213
214 private JRadioButton getHazButton() {
215 if (hazButton == null) {
216 hazButton = new JRadioButton(new ImageIcon(getClass().getResource(
217 Messages.getString("HazButton"))));
218 hazButton.setBounds(new Rectangle(0, 40, 105, 40));
219 hazButton.setToolTipText(Messages.getString("HazTip"));
220 }
221 return hazButton;
222 }
223
224 private JRadioButton getSpecButton() {
225 if (specButton == null) {
226 specButton = new JRadioButton(new ImageIcon(getClass().getResource(
227 Messages.getString("SpecButton"))));
228 specButton.setBounds(new Rectangle(0, 80, 105, 40));
229 specButton.setToolTipText(Messages.getString("SpecTip"));
230 }
231 return specButton;
232 }
233
234 private JRadioButton getLightsButton() {
235 if (lightsButton == null) {
236 lightsButton = new JRadioButton(new ImageIcon(getClass().getResource(
237 Messages.getString("LightsButton"))));
238 lightsButton.setBounds(new Rectangle(0, 120, 105, 40));
239 lightsButton.setToolTipText(Messages.getString("LightsTip"));
240 }
241 return lightsButton;
242 }
243
244 private JRadioButton getTopButton() {
245 if (topButton == null) {
246 topButton = new JRadioButton(new ImageIcon(getClass().getResource(
247 "/images/TopButton.png")));
248 topButton.setBounds(new Rectangle(0, 165, 40, 40));
249 topButton.setToolTipText(tr("Topmarks"));
250 }
251 return topButton;
252 }
253
254 private JRadioButton getFogButton() {
255 if (fogButton == null) {
256 fogButton = new JRadioButton(new ImageIcon(getClass().getResource(
257 "/images/FogButton.png")));
258 fogButton.setBounds(new Rectangle(0, 200, 40, 40));
259 fogButton.setToolTipText(tr("Fog signals"));
260 }
261 return fogButton;
262 }
263
264 private JRadioButton getRadarButton() {
265 if (radarButton == null) {
266 radarButton = new JRadioButton(new ImageIcon(getClass().getResource(
267 "/images/RadarButton.png")));
268 radarButton.setBounds(new Rectangle(0, 235, 40, 40));
269 radarButton.setToolTipText(tr("Radar"));
270 }
271 return radarButton;
272 }
273
274 private JRadioButton getLitButton() {
275 if (litButton == null) {
276 litButton = new JRadioButton(new ImageIcon(getClass().getResource(
277 "/images/LitButton.png")));
278 litButton.setBounds(new Rectangle(0, 270, 40, 40));
279 litButton.setToolTipText(tr("Lights"));
280 }
281 return litButton;
282 }
283
284}
Note: See TracBrowser for help on using the repository browser.