1 | //License: GPL. For details, see LICENSE file.
|
---|
2 | // Copyright (c) 2009 / 2010 by Werner Koenig & Malcolm Herring
|
---|
3 |
|
---|
4 | package toms.seamarks.buoys;
|
---|
5 |
|
---|
6 | import java.util.Map;
|
---|
7 |
|
---|
8 | import javax.swing.ImageIcon;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.Main;
|
---|
11 | import org.openstreetmap.josm.command.ChangePropertyCommand;
|
---|
12 | import org.openstreetmap.josm.data.osm.Node;
|
---|
13 |
|
---|
14 | import toms.Messages;
|
---|
15 | import toms.dialogs.SmpDialogAction;
|
---|
16 | import toms.seamarks.SeaMark;
|
---|
17 |
|
---|
18 | public class BuoyIsol extends Buoy {
|
---|
19 | public BuoyIsol(SmpDialogAction dia, Node node) {
|
---|
20 | super(dia);
|
---|
21 |
|
---|
22 | String str;
|
---|
23 | Map<String, String> keys;
|
---|
24 | keys = node.getKeys();
|
---|
25 | setNode(node);
|
---|
26 |
|
---|
27 | resetMask();
|
---|
28 | dlg.cbM01TypeOfMark.setSelectedIndex(ISOLATED_DANGER);
|
---|
29 |
|
---|
30 | dlg.cbM01StyleOfMark.removeAllItems();
|
---|
31 | dlg.cbM01StyleOfMark.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$
|
---|
32 | dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$
|
---|
33 | dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$
|
---|
34 | dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$
|
---|
35 | dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.06")); //$NON-NLS-1$
|
---|
36 | dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$
|
---|
37 | dlg.cbM01StyleOfMark.setVisible(true);
|
---|
38 | dlg.lM01StyleOfMark.setVisible(true);
|
---|
39 |
|
---|
40 | setBuoyIndex(ISOLATED_DANGER);
|
---|
41 | setColour(SeaMark.BLACK_RED_BLACK);
|
---|
42 | setLightColour("W"); //$NON-NLS-1$
|
---|
43 | setTopMark(true);
|
---|
44 | setRegion(Main.pref.get("tomsplugin.IALA").equals("B")); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
45 |
|
---|
46 | if (keys.containsKey("name")) //$NON-NLS-1$
|
---|
47 | setName(keys.get("name")); //$NON-NLS-1$
|
---|
48 |
|
---|
49 | if (keys.containsKey("seamark:name")) //$NON-NLS-1$
|
---|
50 | setName(keys.get("seamark:name")); //$NON-NLS-1$
|
---|
51 |
|
---|
52 | if (keys.containsKey("seamark:buoy_isolated_danger:name")) //$NON-NLS-1$
|
---|
53 | setName(keys.get("seamark:buoy_isolated_danger:name")); //$NON-NLS-1$
|
---|
54 | else if (keys.containsKey("seamark:beacon_isolated_danger:name")) //$NON-NLS-1$
|
---|
55 | setName(keys.get("seamark:beacon_isolated_danger:name")); //$NON-NLS-1$
|
---|
56 | else if (keys.containsKey("seamark:light_float:name")) //$NON-NLS-1$
|
---|
57 | setName(keys.get("seamark:light_float:name")); //$NON-NLS-1$
|
---|
58 |
|
---|
59 | if (keys.containsKey("seamark:buoy_isolated_danger:shape")) { //$NON-NLS-1$
|
---|
60 | str = keys.get("seamark:buoy_isolated_danger:shape"); //$NON-NLS-1$
|
---|
61 |
|
---|
62 | if (str.equals("pillar")) //$NON-NLS-1$
|
---|
63 | setStyleIndex(ISOL_PILLAR);
|
---|
64 | else if (str.equals("spar")) //$NON-NLS-1$
|
---|
65 | setStyleIndex(ISOL_SPAR);
|
---|
66 | } else if (keys.containsKey("seamark:beacon_isolated_danger:shape")) { //$NON-NLS-1$
|
---|
67 | str = keys.get("seamark:beacon_isolated_danger:shape"); //$NON-NLS-1$
|
---|
68 |
|
---|
69 | if (str.equals("tower")) //$NON-NLS-1$
|
---|
70 | setStyleIndex(ISOL_TOWER);
|
---|
71 | else
|
---|
72 | setStyleIndex(ISOL_BEACON);
|
---|
73 | } else if (keys.containsKey("seamark:type") //$NON-NLS-1$
|
---|
74 | && (keys.get("seamark:type").equals("light_float"))) { //$NON-NLS-1$ //$NON-NLS-2$
|
---|
75 | setStyleIndex(ISOL_FLOAT);
|
---|
76 | }
|
---|
77 |
|
---|
78 | if (getStyleIndex() >= dlg.cbM01StyleOfMark.getItemCount())
|
---|
79 | setStyleIndex(0);
|
---|
80 | dlg.cbM01StyleOfMark.setSelectedIndex(getStyleIndex());
|
---|
81 |
|
---|
82 | if (keys.containsKey("seamark:topmark:shape") //$NON-NLS-1$
|
---|
83 | || keys.containsKey("seamark:topmark:colour")) { //$NON-NLS-1$
|
---|
84 | setTopMark(true);
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 | refreshLights();
|
---|
89 | parseLights(keys);
|
---|
90 | parseFogRadar(keys);
|
---|
91 |
|
---|
92 | dlg.cbM01StyleOfMark.setSelectedIndex(getStyleIndex());
|
---|
93 | dlg.tfM01Name.setText(getName());
|
---|
94 | dlg.cM01TopMark.setSelected(hasTopMark());
|
---|
95 | }
|
---|
96 |
|
---|
97 | public void refreshLights() {
|
---|
98 | dlg.cbM01Kennung.removeAllItems();
|
---|
99 | dlg.cbM01Kennung.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$
|
---|
100 | dlg.cbM01Kennung.addItem("Fl(2)"); //$NON-NLS-1$
|
---|
101 | dlg.cbM01Kennung.setSelectedIndex(0);
|
---|
102 | }
|
---|
103 |
|
---|
104 | public boolean isValid() {
|
---|
105 | return (getBuoyIndex() > 0) && (getStyleIndex() > 0);
|
---|
106 | }
|
---|
107 |
|
---|
108 | public void setLightColour() {
|
---|
109 | super.setLightColour("W"); //$NON-NLS-1$
|
---|
110 | }
|
---|
111 |
|
---|
112 | public void paintSign() {
|
---|
113 | if (dlg.paintlock)
|
---|
114 | return;
|
---|
115 |
|
---|
116 | super.paintSign();
|
---|
117 |
|
---|
118 | dlg.sM01StatusBar.setText(getErrMsg());
|
---|
119 |
|
---|
120 | if (isValid()) {
|
---|
121 | dlg.tfM01Name.setEnabled(true);
|
---|
122 | dlg.tfM01Name.setText(getName());
|
---|
123 | dlg.cM01TopMark.setVisible(true);
|
---|
124 | dlg.cM01Radar.setVisible(true);
|
---|
125 | dlg.cM01Racon.setVisible(true);
|
---|
126 | dlg.cM01Fog.setVisible(true);
|
---|
127 | dlg.cM01Fired.setVisible(true);
|
---|
128 | if (!isSectored()) {
|
---|
129 | dlg.cbM01Colour.setVisible(false);
|
---|
130 | dlg.lM01Colour.setVisible(false);
|
---|
131 | }
|
---|
132 | dlg.rbM01Fired1.setVisible(false);
|
---|
133 | dlg.rbM01FiredN.setVisible(false);
|
---|
134 | dlg.lM01Height.setVisible(false);
|
---|
135 | dlg.tfM01Height.setVisible(false);
|
---|
136 | dlg.lM01Range.setVisible(false);
|
---|
137 | dlg.tfM01Range.setVisible(false);
|
---|
138 |
|
---|
139 | if (isFired()) {
|
---|
140 | switch (getStyleIndex()) {
|
---|
141 | case ISOL_BEACON:
|
---|
142 | case ISOL_TOWER:
|
---|
143 | dlg.lM01Height.setVisible(true);
|
---|
144 | dlg.tfM01Height.setVisible(true);
|
---|
145 | dlg.lM01Range.setVisible(true);
|
---|
146 | dlg.tfM01Range.setVisible(true);
|
---|
147 | break;
|
---|
148 | default:
|
---|
149 | }
|
---|
150 | }
|
---|
151 |
|
---|
152 | String image = "/images/Cardinal"; //$NON-NLS-1$
|
---|
153 |
|
---|
154 | switch (getStyleIndex()) {
|
---|
155 | case ISOL_PILLAR:
|
---|
156 | image += "_Pillar_Single"; //$NON-NLS-1$
|
---|
157 | break;
|
---|
158 | case ISOL_SPAR:
|
---|
159 | image += "_Spar_Single"; //$NON-NLS-1$
|
---|
160 | break;
|
---|
161 | case ISOL_BEACON:
|
---|
162 | image += "_Beacon_Single"; //$NON-NLS-1$
|
---|
163 | break;
|
---|
164 | case ISOL_TOWER:
|
---|
165 | image += "_Tower_Single"; //$NON-NLS-1$
|
---|
166 | break;
|
---|
167 | case ISOL_FLOAT:
|
---|
168 | image += "_Float_Single"; //$NON-NLS-1$
|
---|
169 | break;
|
---|
170 | default:
|
---|
171 | }
|
---|
172 |
|
---|
173 | if (!image.equals("/images/Cardinal")) { //$NON-NLS-1$
|
---|
174 | image += ".png"; //$NON-NLS-1$
|
---|
175 | dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource(image)));
|
---|
176 | } else
|
---|
177 | dlg.lM01Icon.setIcon(null);
|
---|
178 | } else {
|
---|
179 | dlg.tfM01Name.setEnabled(false);
|
---|
180 | dlg.tfM01Name.setText(""); //$NON-NLS-1$
|
---|
181 | dlg.cM01TopMark.setVisible(false);
|
---|
182 | dlg.cM01Radar.setVisible(false);
|
---|
183 | dlg.cM01Racon.setVisible(false);
|
---|
184 | dlg.cM01Fog.setVisible(false);
|
---|
185 | dlg.cM01Fired.setVisible(false);
|
---|
186 | }
|
---|
187 | }
|
---|
188 |
|
---|
189 | public void saveSign() {
|
---|
190 | Node node = getNode();
|
---|
191 |
|
---|
192 | if (node == null) {
|
---|
193 | return;
|
---|
194 | }
|
---|
195 |
|
---|
196 | switch (getStyleIndex()) {
|
---|
197 | case ISOL_PILLAR:
|
---|
198 | super.saveSign("buoy_isolated_danger"); //$NON-NLS-1$
|
---|
199 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
200 | "seamark:buoy_isolated_danger:shape", "pillar")); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
201 | break;
|
---|
202 | case ISOL_SPAR:
|
---|
203 | super.saveSign("buoy_isolated_danger"); //$NON-NLS-1$
|
---|
204 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
205 | "seamark:buoy_isolated_danger:shape", "spar")); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
206 | break;
|
---|
207 | case ISOL_BEACON:
|
---|
208 | super.saveSign("beacon_isolated_danger"); //$NON-NLS-1$
|
---|
209 | break;
|
---|
210 | case ISOL_TOWER:
|
---|
211 | super.saveSign("beacon_isolated_danger"); //$NON-NLS-1$
|
---|
212 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
213 | "seamark:beacon_isolated_danger:shape", "tower")); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
214 | break;
|
---|
215 | case ISOL_FLOAT:
|
---|
216 | super.saveSign("light_float"); //$NON-NLS-1$
|
---|
217 | break;
|
---|
218 | default:
|
---|
219 | }
|
---|
220 |
|
---|
221 | switch (getStyleIndex()) {
|
---|
222 | case ISOL_PILLAR:
|
---|
223 | case ISOL_SPAR:
|
---|
224 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
225 | "seamark:buoy_isolated_danger:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
226 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
227 | "seamark:buoy_isolated_danger:colour", "black;red;black")); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
228 | break;
|
---|
229 | case ISOL_BEACON:
|
---|
230 | case ISOL_TOWER:
|
---|
231 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
232 | "seamark:beacon_isolated_danger:colour_pattern", //$NON-NLS-1$
|
---|
233 | "horizontal stripes")); //$NON-NLS-1$
|
---|
234 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
235 | "seamark:beacon_isolated_danger:colour", "black;red;black")); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
236 | break;
|
---|
237 | case ISOL_FLOAT:
|
---|
238 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
239 | "seamark:light_float:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
240 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
241 | "seamark:light_float:colour", "black;red;black")); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
242 | break;
|
---|
243 | }
|
---|
244 |
|
---|
245 | saveTopMarkData("2 spheres", "black"); //$NON-NLS-1$ //$NON-NLS-2$
|
---|
246 | saveLightData(); //$NON-NLS-1$
|
---|
247 | saveRadarFogData();
|
---|
248 | }
|
---|
249 | }
|
---|