1 | package panels;
|
---|
2 |
|
---|
3 | import java.awt.*;
|
---|
4 | import java.awt.event.*;
|
---|
5 |
|
---|
6 | import javax.swing.*;
|
---|
7 |
|
---|
8 | import java.util.*;
|
---|
9 |
|
---|
10 | import messages.Messages;
|
---|
11 | import smed.SmedAction;
|
---|
12 | import seamarks.SeaMark.*;
|
---|
13 |
|
---|
14 | public class PanelMore extends JPanel {
|
---|
15 |
|
---|
16 | private SmedAction dlg;
|
---|
17 | public JLabel infoLabel;
|
---|
18 | public JTextField infoBox;
|
---|
19 | private FocusListener flInfo = new FocusAdapter() {
|
---|
20 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
21 | dlg.panelMain.mark.setInfo(infoBox.getText());
|
---|
22 | }
|
---|
23 | };
|
---|
24 | public JLabel sourceLabel;
|
---|
25 | public JTextField sourceBox;
|
---|
26 | private FocusListener flSource = new FocusAdapter() {
|
---|
27 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
28 | dlg.panelMain.mark.setSource(sourceBox.getText());
|
---|
29 | }
|
---|
30 | };
|
---|
31 | public JLabel elevLabel;
|
---|
32 | public JTextField elevBox;
|
---|
33 | private FocusListener flElev = new FocusAdapter() {
|
---|
34 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
35 | dlg.panelMain.mark.setElevation(elevBox.getText());
|
---|
36 | }
|
---|
37 | };
|
---|
38 | public JLabel heightLabel;
|
---|
39 | public JTextField heightBox;
|
---|
40 | private FocusListener flHeight = new FocusAdapter() {
|
---|
41 | public void focusLost(java.awt.event.FocusEvent e) {
|
---|
42 | dlg.panelMain.mark.setObjectHeight(heightBox.getText());
|
---|
43 | }
|
---|
44 | };
|
---|
45 | public JLabel statusLabel;
|
---|
46 | public JComboBox<String> statusBox;
|
---|
47 | public EnumMap<Sts, Integer> statuses = new EnumMap<Sts, Integer>(Sts.class);
|
---|
48 | private ActionListener alStatus = new ActionListener() {
|
---|
49 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
50 | for (Sts sts : statuses.keySet()) {
|
---|
51 | int idx = statuses.get(sts);
|
---|
52 | if (dlg.panelMain.mark != null && (idx == statusBox.getSelectedIndex()))
|
---|
53 | dlg.panelMain.mark.setStatus(sts);
|
---|
54 | }
|
---|
55 | }
|
---|
56 | };
|
---|
57 | public JLabel constrLabel;
|
---|
58 | public JComboBox<String> constrBox;
|
---|
59 | public EnumMap<Cns, Integer> constructions = new EnumMap<Cns, Integer>(Cns.class);
|
---|
60 | private ActionListener alConstr = new ActionListener() {
|
---|
61 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
62 | for (Cns cns : constructions.keySet()) {
|
---|
63 | int idx = constructions.get(cns);
|
---|
64 | if (dlg.panelMain.mark != null && (idx == constrBox.getSelectedIndex()))
|
---|
65 | dlg.panelMain.mark.setConstr(cns);
|
---|
66 | }
|
---|
67 | }
|
---|
68 | };
|
---|
69 | public JLabel conLabel;
|
---|
70 | public JComboBox<String> conBox;
|
---|
71 | public EnumMap<Con, Integer> conspicuities = new EnumMap<Con, Integer>(Con.class);
|
---|
72 | private ActionListener alCon = new ActionListener() {
|
---|
73 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
74 | for (Con con : conspicuities.keySet()) {
|
---|
75 | int idx = conspicuities.get(con);
|
---|
76 | if (dlg.panelMain.mark != null && (idx == conBox.getSelectedIndex()))
|
---|
77 | dlg.panelMain.mark.setConsp(con);
|
---|
78 | }
|
---|
79 | }
|
---|
80 | };
|
---|
81 | public JLabel reflLabel;
|
---|
82 | public JComboBox<String> reflBox;
|
---|
83 | public EnumMap<Con, Integer> reflectivities = new EnumMap<Con, Integer>(Con.class);
|
---|
84 | private ActionListener alRefl = new ActionListener() {
|
---|
85 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
86 | for (Con con : reflectivities.keySet()) {
|
---|
87 | int idx = reflectivities.get(con);
|
---|
88 | if (dlg.panelMain.mark != null && (idx == reflBox.getSelectedIndex()))
|
---|
89 | dlg.panelMain.mark.setRefl(con);
|
---|
90 | }
|
---|
91 | }
|
---|
92 | };
|
---|
93 | public PanelPat panelPat;
|
---|
94 | private ButtonGroup regionButtons = new ButtonGroup();
|
---|
95 | public JRadioButton regionAButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionAButton.png")));
|
---|
96 | public JRadioButton regionBButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionBButton.png")));
|
---|
97 | public JRadioButton regionCButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionCButton.png")));
|
---|
98 | private ActionListener alRegion = new ActionListener() {
|
---|
99 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
100 | if (regionAButton.isSelected()) {
|
---|
101 | dlg.panelMain.mark.setRegion(Reg.A);
|
---|
102 | switch (dlg.panelMain.mark.getCategory()) {
|
---|
103 | case LAM_PORT:
|
---|
104 | dlg.panelMain.mark.setObjColour(Col.RED);
|
---|
105 | dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
|
---|
106 | break;
|
---|
107 | case LAM_PPORT:
|
---|
108 | dlg.panelMain.mark.setObjColour(Col.RED);
|
---|
109 | dlg.panelMain.mark.addObjColour(Col.GREEN);
|
---|
110 | dlg.panelMain.mark.addObjColour(Col.RED);
|
---|
111 | dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
|
---|
112 | break;
|
---|
113 | case LAM_STBD:
|
---|
114 | dlg.panelMain.mark.setObjColour(Col.GREEN);
|
---|
115 | dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
|
---|
116 | break;
|
---|
117 | case LAM_PSTBD:
|
---|
118 | dlg.panelMain.mark.setObjColour(Col.GREEN);
|
---|
119 | dlg.panelMain.mark.addObjColour(Col.RED);
|
---|
120 | dlg.panelMain.mark.addObjColour(Col.GREEN);
|
---|
121 | dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
|
---|
122 | break;
|
---|
123 | }
|
---|
124 | regionAButton.setBorderPainted(true);
|
---|
125 | } else {
|
---|
126 | regionAButton.setBorderPainted(false);
|
---|
127 | }
|
---|
128 | if (regionBButton.isSelected()) {
|
---|
129 | dlg.panelMain.mark.setRegion(Reg.B);
|
---|
130 | switch (dlg.panelMain.mark.getCategory()) {
|
---|
131 | case LAM_PORT:
|
---|
132 | dlg.panelMain.mark.setObjColour(Col.GREEN);
|
---|
133 | dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
|
---|
134 | break;
|
---|
135 | case LAM_PPORT:
|
---|
136 | dlg.panelMain.mark.setObjColour(Col.GREEN);
|
---|
137 | dlg.panelMain.mark.addObjColour(Col.RED);
|
---|
138 | dlg.panelMain.mark.addObjColour(Col.GREEN);
|
---|
139 | dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
|
---|
140 | break;
|
---|
141 | case LAM_STBD:
|
---|
142 | dlg.panelMain.mark.setObjColour(Col.RED);
|
---|
143 | dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
|
---|
144 | break;
|
---|
145 | case LAM_PSTBD:
|
---|
146 | dlg.panelMain.mark.setObjColour(Col.RED);
|
---|
147 | dlg.panelMain.mark.addObjColour(Col.GREEN);
|
---|
148 | dlg.panelMain.mark.addObjColour(Col.RED);
|
---|
149 | dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
|
---|
150 | break;
|
---|
151 | }
|
---|
152 | regionBButton.setBorderPainted(true);
|
---|
153 | } else {
|
---|
154 | regionBButton.setBorderPainted(false);
|
---|
155 | }
|
---|
156 | if (regionCButton.isSelected()) {
|
---|
157 | dlg.panelMain.mark.setRegion(Reg.C);
|
---|
158 | dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
|
---|
159 | switch (dlg.panelMain.mark.getCategory()) {
|
---|
160 | case LAM_PORT:
|
---|
161 | dlg.panelMain.mark.setObjColour(Col.RED);
|
---|
162 | dlg.panelMain.mark.addObjColour(Col.WHITE);
|
---|
163 | dlg.panelMain.mark.addObjColour(Col.RED);
|
---|
164 | dlg.panelMain.mark.addObjColour(Col.WHITE);
|
---|
165 | break;
|
---|
166 | case LAM_PPORT:
|
---|
167 | case LAM_PSTBD:
|
---|
168 | dlg.panelMain.mark.setObjColour(Col.RED);
|
---|
169 | dlg.panelMain.mark.addObjColour(Col.GREEN);
|
---|
170 | dlg.panelMain.mark.addObjColour(Col.RED);
|
---|
171 | dlg.panelMain.mark.addObjColour(Col.GREEN);
|
---|
172 | break;
|
---|
173 | case LAM_STBD:
|
---|
174 | dlg.panelMain.mark.setObjColour(Col.GREEN);
|
---|
175 | dlg.panelMain.mark.addObjColour(Col.WHITE);
|
---|
176 | dlg.panelMain.mark.addObjColour(Col.GREEN);
|
---|
177 | dlg.panelMain.mark.addObjColour(Col.WHITE);
|
---|
178 | break;
|
---|
179 | }
|
---|
180 | regionCButton.setBorderPainted(true);
|
---|
181 | } else {
|
---|
182 | regionCButton.setBorderPainted(false);
|
---|
183 | }
|
---|
184 | panelPat.syncPanel();
|
---|
185 | }
|
---|
186 | };
|
---|
187 |
|
---|
188 | public PanelMore(SmedAction dia) {
|
---|
189 | dlg = dia;
|
---|
190 | setLayout(null);
|
---|
191 | panelPat = new PanelPat(dlg, Ent.BODY);
|
---|
192 | panelPat.setBounds(new Rectangle(0, 0, 110, 160));
|
---|
193 | add(panelPat);
|
---|
194 | add(getRegionButton(regionAButton, 110, 0, 34, 30, "RegionA"));
|
---|
195 | add(getRegionButton(regionBButton, 110, 32, 34, 30, "RegionB"));
|
---|
196 | add(getRegionButton(regionCButton, 110, 64, 34, 30, "RegionC"));
|
---|
197 |
|
---|
198 | elevLabel = new JLabel(Messages.getString("Elevation"), SwingConstants.CENTER);
|
---|
199 | elevLabel.setBounds(new Rectangle(140, 0, 90, 20));
|
---|
200 | add(elevLabel);
|
---|
201 | elevBox = new JTextField();
|
---|
202 | elevBox.setBounds(new Rectangle(160, 20, 50, 20));
|
---|
203 | elevBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
204 | add(elevBox);
|
---|
205 | elevBox.addFocusListener(flElev);
|
---|
206 |
|
---|
207 | heightLabel = new JLabel(Messages.getString("Height"), SwingConstants.CENTER);
|
---|
208 | heightLabel.setBounds(new Rectangle(140, 40, 90, 20));
|
---|
209 | add(heightLabel);
|
---|
210 | heightBox = new JTextField();
|
---|
211 | heightBox.setBounds(new Rectangle(160, 60, 50, 20));
|
---|
212 | heightBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
213 | add(heightBox);
|
---|
214 | heightBox.addFocusListener(flHeight);
|
---|
215 |
|
---|
216 | sourceLabel = new JLabel(Messages.getString("Source"), SwingConstants.CENTER);
|
---|
217 | sourceLabel.setBounds(new Rectangle(110, 80, 130, 20));
|
---|
218 | add(sourceLabel);
|
---|
219 | sourceBox = new JTextField();
|
---|
220 | sourceBox.setBounds(new Rectangle(110, 100, 130, 20));
|
---|
221 | sourceBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
222 | add(sourceBox);
|
---|
223 | sourceBox.addFocusListener(flSource);
|
---|
224 |
|
---|
225 | infoLabel = new JLabel(Messages.getString("Information"), SwingConstants.CENTER);
|
---|
226 | infoLabel.setBounds(new Rectangle(110, 120, 130, 20));
|
---|
227 | add(infoLabel);
|
---|
228 | infoBox = new JTextField();
|
---|
229 | infoBox.setBounds(new Rectangle(110, 140, 130, 20));
|
---|
230 | infoBox.setHorizontalAlignment(SwingConstants.CENTER);
|
---|
231 | add(infoBox);
|
---|
232 | infoBox.addFocusListener(flInfo);
|
---|
233 |
|
---|
234 | statusLabel = new JLabel(Messages.getString("Status"), SwingConstants.CENTER);
|
---|
235 | statusLabel.setBounds(new Rectangle(250, 0, 100, 20));
|
---|
236 | add(statusLabel);
|
---|
237 | statusBox = new JComboBox<>();
|
---|
238 | statusBox.setBounds(new Rectangle(250, 20, 100, 20));
|
---|
239 | addStsItem("", Sts.UNKSTS);
|
---|
240 | addStsItem(Messages.getString("Permanent"), Sts.PERM);
|
---|
241 | addStsItem(Messages.getString("Occasional"), Sts.OCC);
|
---|
242 | addStsItem(Messages.getString("Recommended"), Sts.REC);
|
---|
243 | addStsItem(Messages.getString("NotInUse"), Sts.NIU);
|
---|
244 | addStsItem(Messages.getString("Intermittent"), Sts.INT);
|
---|
245 | addStsItem(Messages.getString("Reserved"), Sts.RESV);
|
---|
246 | addStsItem(Messages.getString("Temporary"), Sts.TEMP);
|
---|
247 | addStsItem(Messages.getString("Private"), Sts.PRIV);
|
---|
248 | addStsItem(Messages.getString("Mandatory"), Sts.MAND);
|
---|
249 | addStsItem(Messages.getString("Destroyed"), Sts.DEST);
|
---|
250 | addStsItem(Messages.getString("Extinguished"), Sts.EXT);
|
---|
251 | addStsItem(Messages.getString("Illuminated"), Sts.ILLUM);
|
---|
252 | addStsItem(Messages.getString("Historic"), Sts.HIST);
|
---|
253 | addStsItem(Messages.getString("Public"), Sts.PUB);
|
---|
254 | addStsItem(Messages.getString("Synchronized"), Sts.SYNC);
|
---|
255 | addStsItem(Messages.getString("Watched"), Sts.WATCH);
|
---|
256 | addStsItem(Messages.getString("UnWatched"), Sts.UNWAT);
|
---|
257 | addStsItem(Messages.getString("Doubtful"), Sts.DOUBT);
|
---|
258 | add(statusBox);
|
---|
259 | statusBox.addActionListener(alStatus);
|
---|
260 |
|
---|
261 | constrLabel = new JLabel(Messages.getString("Construction"), SwingConstants.CENTER);
|
---|
262 | constrLabel.setBounds(new Rectangle(250, 40, 100, 20));
|
---|
263 | add(constrLabel);
|
---|
264 | constrBox = new JComboBox<>();
|
---|
265 | constrBox.setBounds(new Rectangle(250, 60, 100, 20));
|
---|
266 | addCnsItem("", Cns.UNKCNS);
|
---|
267 | addCnsItem(Messages.getString("Masonry"), Cns.BRICK);
|
---|
268 | addCnsItem(Messages.getString("Concreted"), Cns.CONC);
|
---|
269 | addCnsItem(Messages.getString("Boulders"), Cns.BOULD);
|
---|
270 | addCnsItem(Messages.getString("HardSurfaced"), Cns.HSURF);
|
---|
271 | addCnsItem(Messages.getString("Unsurfaced"), Cns.USURF);
|
---|
272 | addCnsItem(Messages.getString("Wooden"), Cns.WOOD);
|
---|
273 | addCnsItem(Messages.getString("Metal"), Cns.METAL);
|
---|
274 | addCnsItem(Messages.getString("GRP"), Cns.GLAS);
|
---|
275 | addCnsItem(Messages.getString("Painted"), Cns.PAINT);
|
---|
276 | add(constrBox);
|
---|
277 | constrBox.addActionListener(alConstr);
|
---|
278 |
|
---|
279 | conLabel = new JLabel(Messages.getString("Conspicuity"), SwingConstants.CENTER);
|
---|
280 | conLabel.setBounds(new Rectangle(250, 80, 100, 20));
|
---|
281 | add(conLabel);
|
---|
282 | conBox = new JComboBox<>();
|
---|
283 | conBox.setBounds(new Rectangle(250, 100, 100, 20));
|
---|
284 | addConItem("", Con.UNKCON);
|
---|
285 | addConItem(Messages.getString("Conspicuous"), Con.CONSP);
|
---|
286 | addConItem(Messages.getString("NotConspicuous"), Con.NCONS);
|
---|
287 | add(conBox);
|
---|
288 | conBox.addActionListener(alCon);
|
---|
289 |
|
---|
290 | reflLabel = new JLabel(Messages.getString("Reflectivity"), SwingConstants.CENTER);
|
---|
291 | reflLabel.setBounds(new Rectangle(250, 120, 100, 20));
|
---|
292 | add(reflLabel);
|
---|
293 | reflBox = new JComboBox<>();
|
---|
294 | reflBox.setBounds(new Rectangle(250, 140, 100, 20));
|
---|
295 | addReflItem("", Con.UNKCON);
|
---|
296 | addReflItem(Messages.getString("Conspicuous"), Con.CONSP);
|
---|
297 | addReflItem(Messages.getString("NotConspicuous"), Con.NCONS);
|
---|
298 | addReflItem(Messages.getString("Reflector"), Con.REFL);
|
---|
299 | add(reflBox);
|
---|
300 | reflBox.addActionListener(alRefl);
|
---|
301 |
|
---|
302 | }
|
---|
303 |
|
---|
304 | public void syncPanel() {
|
---|
305 | panelPat.syncPanel();
|
---|
306 | regionAButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.A);
|
---|
307 | regionBButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.B);
|
---|
308 | regionCButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.C);
|
---|
309 | elevBox.setText(dlg.panelMain.mark.getElevation());
|
---|
310 | heightBox.setText(dlg.panelMain.mark.getObjectHeight());
|
---|
311 | sourceBox.setText(dlg.panelMain.mark.getSource());
|
---|
312 | infoBox.setText(dlg.panelMain.mark.getInfo());
|
---|
313 | for (Sts sts : statuses.keySet()) {
|
---|
314 | int item = statuses.get(sts);
|
---|
315 | if (dlg.panelMain.mark.getStatus() == sts)
|
---|
316 | statusBox.setSelectedIndex(item);
|
---|
317 | }
|
---|
318 | for (Cns cns : constructions.keySet()) {
|
---|
319 | int item = constructions.get(cns);
|
---|
320 | if (dlg.panelMain.mark.getConstr() == cns)
|
---|
321 | constrBox.setSelectedIndex(item);
|
---|
322 | }
|
---|
323 | for (Con con : conspicuities.keySet()) {
|
---|
324 | int item = conspicuities.get(con);
|
---|
325 | if (dlg.panelMain.mark.getConsp() == con)
|
---|
326 | conBox.setSelectedIndex(item);
|
---|
327 | }
|
---|
328 | for (Con con : reflectivities.keySet()) {
|
---|
329 | int item = reflectivities.get(con);
|
---|
330 | if (dlg.panelMain.mark.getRefl() == con)
|
---|
331 | reflBox.setSelectedIndex(item);
|
---|
332 | }
|
---|
333 | }
|
---|
334 |
|
---|
335 | private void addStsItem(String str, Sts sts) {
|
---|
336 | statuses.put(sts, statusBox.getItemCount());
|
---|
337 | statusBox.addItem(str);
|
---|
338 | }
|
---|
339 |
|
---|
340 | private void addCnsItem(String str, Cns cns) {
|
---|
341 | constructions.put(cns, constrBox.getItemCount());
|
---|
342 | constrBox.addItem(str);
|
---|
343 | }
|
---|
344 |
|
---|
345 | private void addConItem(String str, Con con) {
|
---|
346 | conspicuities.put(con, conBox.getItemCount());
|
---|
347 | conBox.addItem(str);
|
---|
348 | }
|
---|
349 |
|
---|
350 | private void addReflItem(String str, Con con) {
|
---|
351 | reflectivities.put(con, reflBox.getItemCount());
|
---|
352 | reflBox.addItem(str);
|
---|
353 | }
|
---|
354 |
|
---|
355 | private JRadioButton getRegionButton(JRadioButton button, int x, int y, int w, int h, String tip) {
|
---|
356 | button.setBounds(new Rectangle(x, y, w, h));
|
---|
357 | button.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
358 | button.setToolTipText(Messages.getString(tip));
|
---|
359 | button.addActionListener(alRegion);
|
---|
360 | regionButtons.add(button);
|
---|
361 | return button;
|
---|
362 | }
|
---|
363 | }
|
---|