1 | package oseam.panels;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
4 |
|
---|
5 | import java.awt.*;
|
---|
6 | import java.awt.event.*;
|
---|
7 |
|
---|
8 | import javax.swing.*;
|
---|
9 |
|
---|
10 | import java.util.*;
|
---|
11 |
|
---|
12 | import oseam.Messages;
|
---|
13 | import oseam.dialogs.OSeaMAction;
|
---|
14 | import oseam.seamarks.SeaMark.* ;
|
---|
15 |
|
---|
16 | public class PanelMore extends JPanel {
|
---|
17 |
|
---|
18 | private OSeaMAction dlg;
|
---|
19 | public JLabel infoLabel;
|
---|
20 | public JTextField infoBox;
|
---|
21 | private ActionListener alInfo = new ActionListener() {
|
---|
22 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
23 | if (dlg.mark == null)
|
---|
24 | return;
|
---|
25 | }
|
---|
26 | };
|
---|
27 | public JLabel sourceLabel;
|
---|
28 | public JTextField sourceBox;
|
---|
29 | private ActionListener alSource = new ActionListener() {
|
---|
30 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
31 | if (dlg.mark == null)
|
---|
32 | return;
|
---|
33 | }
|
---|
34 | };
|
---|
35 | public JLabel elevLabel;
|
---|
36 | public JTextField elevBox;
|
---|
37 | private ActionListener alElev = new ActionListener() {
|
---|
38 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
39 | if (dlg.mark == null)
|
---|
40 | return;
|
---|
41 | }
|
---|
42 | };
|
---|
43 | public JLabel heightLabel;
|
---|
44 | public JTextField heightBox;
|
---|
45 | private ActionListener alHeight = new ActionListener() {
|
---|
46 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
47 | if (dlg.mark == null)
|
---|
48 | return;
|
---|
49 | }
|
---|
50 | };
|
---|
51 | public JLabel statusLabel;
|
---|
52 | public JComboBox statusBox;
|
---|
53 | public EnumMap<Sts, Integer> statuses = new EnumMap<Sts, Integer>(Sts.class);
|
---|
54 | private ActionListener alStatus = new ActionListener() {
|
---|
55 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
56 | for (Sts sts : statuses.keySet()) {
|
---|
57 | int idx = statuses.get(sts);
|
---|
58 | if (dlg.mark != null && (idx == statusBox.getSelectedIndex()))
|
---|
59 | dlg.mark.setStatus(sts);
|
---|
60 | }
|
---|
61 | }
|
---|
62 | };
|
---|
63 | public JLabel constrLabel;
|
---|
64 | public JComboBox constrBox;
|
---|
65 | private ActionListener alConstr = new ActionListener() {
|
---|
66 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
67 | if (dlg.mark == null)
|
---|
68 | return;
|
---|
69 | }
|
---|
70 | };
|
---|
71 | public JLabel visLabel;
|
---|
72 | public JComboBox visBox;
|
---|
73 | private ActionListener alVis = new ActionListener() {
|
---|
74 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
75 | if (dlg.mark == null)
|
---|
76 | return;
|
---|
77 | }
|
---|
78 | };
|
---|
79 | public JLabel conspLabel;
|
---|
80 | public JComboBox conspBox;
|
---|
81 | private ActionListener alConsp = new ActionListener() {
|
---|
82 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
83 | if (dlg.mark == null)
|
---|
84 | return;
|
---|
85 | }
|
---|
86 | };
|
---|
87 | public PanelPat panelPat;
|
---|
88 | private ButtonGroup regionButtons = new ButtonGroup();
|
---|
89 | public JRadioButton regionAButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionAButton.png")));
|
---|
90 | public JRadioButton regionBButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionBButton.png")));
|
---|
91 | public JRadioButton regionCButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionCButton.png")));
|
---|
92 | private ActionListener alRegion = new ActionListener() {
|
---|
93 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
94 | if (regionAButton.isSelected()) {
|
---|
95 | dlg.mark.setRegion(Reg.A);
|
---|
96 | switch (dlg.mark.getCategory()) {
|
---|
97 | case LAM_PORT:
|
---|
98 | dlg.mark.setColour(Ent.BODY, Col.RED);
|
---|
99 | dlg.mark.setPattern(Ent.BODY, Pat.NONE);
|
---|
100 | break;
|
---|
101 | case LAM_PPORT:
|
---|
102 | dlg.mark.setColour(Ent.BODY, Col.RED);
|
---|
103 | dlg.mark.addColour(Ent.BODY, Col.GREEN);
|
---|
104 | dlg.mark.addColour(Ent.BODY, Col.RED);
|
---|
105 | dlg.mark.setPattern(Ent.BODY, Pat.HORIZ);
|
---|
106 | break;
|
---|
107 | case LAM_STBD:
|
---|
108 | dlg.mark.setColour(Ent.BODY, Col.GREEN);
|
---|
109 | dlg.mark.setPattern(Ent.BODY, Pat.NONE);
|
---|
110 | break;
|
---|
111 | case LAM_PSTBD:
|
---|
112 | dlg.mark.setColour(Ent.BODY, Col.GREEN);
|
---|
113 | dlg.mark.addColour(Ent.BODY, Col.RED);
|
---|
114 | dlg.mark.addColour(Ent.BODY, Col.GREEN);
|
---|
115 | dlg.mark.setPattern(Ent.BODY, Pat.HORIZ);
|
---|
116 | break;
|
---|
117 | }
|
---|
118 | regionAButton.setBorderPainted(true);
|
---|
119 | } else {
|
---|
120 | regionAButton.setBorderPainted(false);
|
---|
121 | }
|
---|
122 | if (regionBButton.isSelected()) {
|
---|
123 | dlg.mark.setRegion(Reg.B);
|
---|
124 | switch (dlg.mark.getCategory()) {
|
---|
125 | case LAM_PORT:
|
---|
126 | dlg.mark.setColour(Ent.BODY, Col.GREEN);
|
---|
127 | dlg.mark.setPattern(Ent.BODY, Pat.NONE);
|
---|
128 | break;
|
---|
129 | case LAM_PPORT:
|
---|
130 | dlg.mark.setColour(Ent.BODY, Col.GREEN);
|
---|
131 | dlg.mark.addColour(Ent.BODY, Col.RED);
|
---|
132 | dlg.mark.addColour(Ent.BODY, Col.GREEN);
|
---|
133 | dlg.mark.setPattern(Ent.BODY, Pat.HORIZ);
|
---|
134 | break;
|
---|
135 | case LAM_STBD:
|
---|
136 | dlg.mark.setColour(Ent.BODY, Col.RED);
|
---|
137 | dlg.mark.setPattern(Ent.BODY, Pat.NONE);
|
---|
138 | break;
|
---|
139 | case LAM_PSTBD:
|
---|
140 | dlg.mark.setColour(Ent.BODY, Col.RED);
|
---|
141 | dlg.mark.addColour(Ent.BODY, Col.GREEN);
|
---|
142 | dlg.mark.addColour(Ent.BODY, Col.RED);
|
---|
143 | dlg.mark.setPattern(Ent.BODY, Pat.HORIZ);
|
---|
144 | break;
|
---|
145 | }
|
---|
146 | regionBButton.setBorderPainted(true);
|
---|
147 | } else {
|
---|
148 | regionBButton.setBorderPainted(false);
|
---|
149 | }
|
---|
150 | if (regionCButton.isSelected()) {
|
---|
151 | dlg.mark.setRegion(Reg.C);
|
---|
152 | dlg.mark.setPattern(Ent.BODY, Pat.HORIZ);
|
---|
153 | switch (dlg.mark.getCategory()) {
|
---|
154 | case LAM_PORT:
|
---|
155 | dlg.mark.setColour(Ent.BODY, Col.RED);
|
---|
156 | dlg.mark.addColour(Ent.BODY, Col.WHITE);
|
---|
157 | dlg.mark.addColour(Ent.BODY, Col.RED);
|
---|
158 | dlg.mark.addColour(Ent.BODY, Col.WHITE);
|
---|
159 | break;
|
---|
160 | case LAM_PPORT:
|
---|
161 | case LAM_PSTBD:
|
---|
162 | dlg.mark.setColour(Ent.BODY, Col.RED);
|
---|
163 | dlg.mark.addColour(Ent.BODY, Col.GREEN);
|
---|
164 | dlg.mark.addColour(Ent.BODY, Col.RED);
|
---|
165 | dlg.mark.addColour(Ent.BODY, Col.GREEN);
|
---|
166 | break;
|
---|
167 | case LAM_STBD:
|
---|
168 | dlg.mark.setColour(Ent.BODY, Col.GREEN);
|
---|
169 | dlg.mark.addColour(Ent.BODY, Col.WHITE);
|
---|
170 | dlg.mark.addColour(Ent.BODY, Col.GREEN);
|
---|
171 | dlg.mark.addColour(Ent.BODY, Col.WHITE);
|
---|
172 | break;
|
---|
173 | }
|
---|
174 | regionCButton.setBorderPainted(true);
|
---|
175 | } else {
|
---|
176 | regionCButton.setBorderPainted(false);
|
---|
177 | }
|
---|
178 | dlg.mark.paintSign();
|
---|
179 | }
|
---|
180 | };
|
---|
181 |
|
---|
182 | public PanelMore(OSeaMAction dia) {
|
---|
183 | dlg = dia;
|
---|
184 | this.setLayout(null);
|
---|
185 | panelPat = new PanelPat(dlg);
|
---|
186 | panelPat.setBounds(new Rectangle(0, 0, 110, 160));
|
---|
187 | this.add(panelPat, null);
|
---|
188 | this.add(getRegionButton(regionAButton, 110, 0, 34, 30, "RegionA"), null);
|
---|
189 | this.add(getRegionButton(regionBButton, 110, 32, 34, 30, "RegionB"), null);
|
---|
190 | this.add(getRegionButton(regionCButton, 110, 64, 34, 30, "RegionC"), null);
|
---|
191 |
|
---|
192 | elevLabel = new JLabel(Messages.getString("Elevation"), SwingConstants.CENTER);
|
---|
193 | elevLabel.setBounds(new Rectangle(140, 0, 90, 20));
|
---|
194 | this.add(elevLabel, null);
|
---|
195 | elevBox = new JTextField();
|
---|
196 | elevBox.setBounds(new Rectangle(160, 20, 50, 20));
|
---|
197 | this.add(elevBox, null);
|
---|
198 | elevBox.addActionListener(alElev);
|
---|
199 |
|
---|
200 | heightLabel = new JLabel(Messages.getString("Height"), SwingConstants.CENTER);
|
---|
201 | heightLabel.setBounds(new Rectangle(140, 40, 90, 20));
|
---|
202 | this.add(heightLabel, null);
|
---|
203 | heightBox = new JTextField();
|
---|
204 | heightBox.setBounds(new Rectangle(160, 60, 50, 20));
|
---|
205 | this.add(heightBox, null);
|
---|
206 | heightBox.addActionListener(alHeight);
|
---|
207 |
|
---|
208 | sourceLabel = new JLabel(Messages.getString("Source"), SwingConstants.CENTER);
|
---|
209 | sourceLabel.setBounds(new Rectangle(110, 80, 130, 20));
|
---|
210 | this.add(sourceLabel, null);
|
---|
211 | sourceBox = new JTextField();
|
---|
212 | sourceBox.setBounds(new Rectangle(110, 100, 130, 20));
|
---|
213 | this.add(sourceBox, null);
|
---|
214 | sourceBox.addActionListener(alSource);
|
---|
215 |
|
---|
216 | infoLabel = new JLabel(Messages.getString("Information"), SwingConstants.CENTER);
|
---|
217 | infoLabel.setBounds(new Rectangle(110, 120, 130, 20));
|
---|
218 | this.add(infoLabel, null);
|
---|
219 | infoBox = new JTextField();
|
---|
220 | infoBox.setBounds(new Rectangle(110, 140, 130, 20));
|
---|
221 | this.add(infoBox, null);
|
---|
222 | infoBox.addActionListener(alInfo);
|
---|
223 |
|
---|
224 | statusLabel = new JLabel(Messages.getString("Status"), SwingConstants.CENTER);
|
---|
225 | statusLabel.setBounds(new Rectangle(250, 0, 100, 20));
|
---|
226 | this.add(statusLabel, null);
|
---|
227 | statusBox = new JComboBox();
|
---|
228 | statusBox.setBounds(new Rectangle(250, 20, 100, 20));
|
---|
229 | addStsItem(Messages.getString("NotSet"), Sts.UNKNOWN);
|
---|
230 | this.add(statusBox, null);
|
---|
231 | statusBox.addActionListener(alStatus);
|
---|
232 |
|
---|
233 | constrLabel = new JLabel(Messages.getString("Construction"), SwingConstants.CENTER);
|
---|
234 | constrLabel.setBounds(new Rectangle(250, 40, 100, 20));
|
---|
235 | this.add(constrLabel, null);
|
---|
236 | constrBox = new JComboBox();
|
---|
237 | constrBox.setBounds(new Rectangle(250, 60, 100, 20));
|
---|
238 | this.add(constrBox, null);
|
---|
239 | constrBox.addActionListener(alConstr);
|
---|
240 |
|
---|
241 | conspLabel = new JLabel(Messages.getString("Reflectivity"), SwingConstants.CENTER);
|
---|
242 | conspLabel.setBounds(new Rectangle(250, 80, 100, 20));
|
---|
243 | this.add(conspLabel, null);
|
---|
244 | conspBox = new JComboBox();
|
---|
245 | conspBox.setBounds(new Rectangle(250, 100, 100, 20));
|
---|
246 | this.add(conspBox, null);
|
---|
247 | conspBox.addActionListener(alConsp);
|
---|
248 |
|
---|
249 | visLabel = new JLabel(Messages.getString("Visibility"), SwingConstants.CENTER);
|
---|
250 | visLabel.setBounds(new Rectangle(250, 120, 100, 20));
|
---|
251 | this.add(visLabel, null);
|
---|
252 | visBox = new JComboBox();
|
---|
253 | visBox.setBounds(new Rectangle(250, 140, 100, 20));
|
---|
254 | this.add(visBox, null);
|
---|
255 | visBox.addActionListener(alVis);
|
---|
256 |
|
---|
257 | }
|
---|
258 |
|
---|
259 | public void clearSelections() {
|
---|
260 | panelPat.clearSelections();
|
---|
261 | }
|
---|
262 |
|
---|
263 | private void addStsItem(String str, Sts sts) {
|
---|
264 | statuses.put(sts, statusBox.getItemCount());
|
---|
265 | statusBox.addItem(str);
|
---|
266 | }
|
---|
267 |
|
---|
268 | private JRadioButton getRegionButton(JRadioButton button, int x, int y, int w, int h, String tip) {
|
---|
269 | button.setBounds(new Rectangle(x, y, w, h));
|
---|
270 | button.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
271 | button.setToolTipText(Messages.getString(tip));
|
---|
272 | button.addActionListener(alRegion);
|
---|
273 | regionButtons.add(button);
|
---|
274 | return button;
|
---|
275 | }
|
---|
276 |
|
---|
277 | }
|
---|