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.dialogs.SmpDialogAction;
|
---|
15 | import toms.seamarks.SeaMark;
|
---|
16 |
|
---|
17 | public class BuoyIsol extends Buoy {
|
---|
18 | public BuoyIsol(SmpDialogAction dia, Node node) {
|
---|
19 | super(dia);
|
---|
20 |
|
---|
21 | String str;
|
---|
22 | Map<String, String> keys;
|
---|
23 | keys = node.getKeys();
|
---|
24 | setNode(node);
|
---|
25 |
|
---|
26 | resetMask();
|
---|
27 |
|
---|
28 | dlg.cbM01StyleOfMark.removeAllItems();
|
---|
29 | dlg.cbM01StyleOfMark.addItem("Not set");
|
---|
30 | dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
|
---|
31 | dlg.cbM01StyleOfMark.addItem("Spar Buoy");
|
---|
32 | dlg.cbM01StyleOfMark.addItem("Beacon");
|
---|
33 | dlg.cbM01StyleOfMark.addItem("Tower");
|
---|
34 | dlg.cbM01StyleOfMark.addItem("Float");
|
---|
35 | dlg.cbM01StyleOfMark.setEnabled(true);
|
---|
36 |
|
---|
37 | dlg.cbM01Kennung.removeAllItems();
|
---|
38 | dlg.cbM01Kennung.addItem("Not set");
|
---|
39 | dlg.cbM01Kennung.addItem("Fl(2)");
|
---|
40 |
|
---|
41 | dlg.cM01TopMark.setSelected(true);
|
---|
42 |
|
---|
43 | setColour(SeaMark.BLACK_RED_BLACK);
|
---|
44 | setLightColour("W");
|
---|
45 | setBuoyIndex(ISOLATED_DANGER);
|
---|
46 | setTopMark(true);
|
---|
47 | setRegion(Main.pref.get("tomsplugin.IALA").equals("B"));
|
---|
48 |
|
---|
49 | if (keys.containsKey("name"))
|
---|
50 | setName(keys.get("name"));
|
---|
51 |
|
---|
52 | if (keys.containsKey("seamark:name"))
|
---|
53 | setName(keys.get("seamark:name"));
|
---|
54 |
|
---|
55 | if (keys.containsKey("seamark:buoy_isolated_danger:name"))
|
---|
56 | setName(keys.get("seamark:buoy_isolated_danger:name"));
|
---|
57 | else if (keys.containsKey("seamark:beacon_isolated_danger:name"))
|
---|
58 | setName(keys.get("seamark:beacon_isolated_danger:name"));
|
---|
59 | else if (keys.containsKey("seamark:light_float:name"))
|
---|
60 | setName(keys.get("seamark:light_float:name"));
|
---|
61 |
|
---|
62 | if (keys.containsKey("seamark:buoy_isolated_danger:shape")) {
|
---|
63 | str = keys.get("seamark:buoy_isolated_danger:shape");
|
---|
64 |
|
---|
65 | if (str.equals("pillar"))
|
---|
66 | setStyleIndex(ISOL_PILLAR);
|
---|
67 | else if (str.equals("spar"))
|
---|
68 | setStyleIndex(ISOL_SPAR);
|
---|
69 | } else if (keys.containsKey("seamark:beacon_isolated_danger:colour")) {
|
---|
70 | if (keys.containsKey("seamark:beacon_isolated_danger:shape")) {
|
---|
71 | str = keys.get("seamark:beacon_isolated_danger:shape");
|
---|
72 |
|
---|
73 | if (str.equals("tower"))
|
---|
74 | setStyleIndex(ISOL_TOWER);
|
---|
75 | else
|
---|
76 | setStyleIndex(ISOL_BEACON);
|
---|
77 | } else
|
---|
78 | setStyleIndex(ISOL_BEACON);
|
---|
79 | } else if (keys.containsKey("seamark:type")
|
---|
80 | && (keys.get("seamark:type").equals("light_float"))) {
|
---|
81 | setStyleIndex(CARD_FLOAT);
|
---|
82 | }
|
---|
83 |
|
---|
84 | if (keys.containsKey("seamark:topmark:shape")
|
---|
85 | || keys.containsKey("seamark:topmark:colour")) {
|
---|
86 | setTopMark(true);
|
---|
87 | }
|
---|
88 |
|
---|
89 | if (keys.containsKey("seamark:light:colour")) {
|
---|
90 | str = keys.get("seamark:light:colour");
|
---|
91 |
|
---|
92 | if (keys.containsKey("seamark:light:character")) {
|
---|
93 | setLightGroup(keys);
|
---|
94 | String c = keys.get("seamark:light:character");
|
---|
95 | setLightChar(c);
|
---|
96 | setLightPeriod(keys);
|
---|
97 | }
|
---|
98 |
|
---|
99 | if (str.equals("white")) {
|
---|
100 | setFired(true);
|
---|
101 | setLightColour("W");
|
---|
102 | }
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | public void paintSign() {
|
---|
107 | super.paintSign();
|
---|
108 |
|
---|
109 | dlg.sM01StatusBar.setText(getErrMsg());
|
---|
110 | dlg.lM01Icon02.setIcon(null);
|
---|
111 |
|
---|
112 | dlg.tfM01Name.setEnabled(true);
|
---|
113 | dlg.tfM01Name.setText(getName());
|
---|
114 | dlg.cM01Fired.setEnabled(true);
|
---|
115 | dlg.cM01TopMark.setEnabled(false);
|
---|
116 |
|
---|
117 | String image = "/images/Cardinal";
|
---|
118 |
|
---|
119 | switch (getStyleIndex()) {
|
---|
120 | case ISOL_PILLAR:
|
---|
121 | image += "_Pillar_Single";
|
---|
122 | break;
|
---|
123 | case ISOL_SPAR:
|
---|
124 | image += "_Spar_Single";
|
---|
125 | break;
|
---|
126 | case ISOL_BEACON:
|
---|
127 | image += "_Beacon_Single";
|
---|
128 | break;
|
---|
129 | case ISOL_TOWER:
|
---|
130 | image += "_Tower_Single";
|
---|
131 | break;
|
---|
132 | case ISOL_FLOAT:
|
---|
133 | image += "_Float_Single";
|
---|
134 | break;
|
---|
135 | default:
|
---|
136 | }
|
---|
137 |
|
---|
138 | if (!image.equals("/images/Cardinal")) {
|
---|
139 | image += ".png";
|
---|
140 | dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
|
---|
141 | if (isFired()) {
|
---|
142 | dlg.lM01Icon02.setIcon(new ImageIcon(getClass().getResource("/images/Light_White_120.png")));
|
---|
143 | if (getLightChar() != "") {
|
---|
144 | String c;
|
---|
145 |
|
---|
146 | c = getLightChar();
|
---|
147 | if (getLightGroup() != "")
|
---|
148 | c = c + "(" + getLightGroup() + ")";
|
---|
149 | dlg.cbM01Kennung.setSelectedItem(c);
|
---|
150 | }
|
---|
151 | }
|
---|
152 | } else
|
---|
153 | dlg.lM01Icon01.setIcon(null);
|
---|
154 | }
|
---|
155 |
|
---|
156 | public void saveSign() {
|
---|
157 | Node node = getNode();
|
---|
158 |
|
---|
159 | if (node == null) {
|
---|
160 | return;
|
---|
161 | }
|
---|
162 |
|
---|
163 | switch (getStyleIndex()) {
|
---|
164 | case ISOL_PILLAR:
|
---|
165 | super.saveSign("buoy_isolated_danger");
|
---|
166 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
167 | "seamark:buoy_isolated_danger:shape", "pillar"));
|
---|
168 | break;
|
---|
169 | case ISOL_SPAR:
|
---|
170 | super.saveSign("buoy_isolated_danger");
|
---|
171 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
172 | "seamark:buoy_isolated_danger:shape", "spar"));
|
---|
173 | break;
|
---|
174 | case ISOL_BEACON:
|
---|
175 | super.saveSign("beacon_isolated_danger");
|
---|
176 | break;
|
---|
177 | case ISOL_TOWER:
|
---|
178 | super.saveSign("beacon_isolated_danger");
|
---|
179 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
180 | "seamark:beacon_isolated_danger:shape", "tower"));
|
---|
181 | break;
|
---|
182 | case ISOL_FLOAT:
|
---|
183 | super.saveSign("light_float");
|
---|
184 | break;
|
---|
185 | default:
|
---|
186 | }
|
---|
187 |
|
---|
188 | switch (getStyleIndex()) {
|
---|
189 | case ISOL_PILLAR:
|
---|
190 | case ISOL_SPAR:
|
---|
191 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
192 | "seamark:buoy_isolated_danger:colour_pattern", "horizontal stripes"));
|
---|
193 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
194 | "seamark:buoy_isolated_danger:colour", "black;red;black"));
|
---|
195 | break;
|
---|
196 | case ISOL_BEACON:
|
---|
197 | case ISOL_TOWER:
|
---|
198 | Main.main.undoRedo
|
---|
199 | .add(new ChangePropertyCommand(node,
|
---|
200 | "seamark:beacon_isolated_danger:colour_pattern",
|
---|
201 | "horizontal stripes"));
|
---|
202 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
203 | "seamark:beacon_isolated_danger:colour", "black;red;black"));
|
---|
204 | break;
|
---|
205 | case ISOL_FLOAT:
|
---|
206 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
207 | "seamark:light_float:colour_pattern", "horizontal stripes"));
|
---|
208 | Main.main.undoRedo.add(new ChangePropertyCommand(node,
|
---|
209 | "seamark:light_float:colour", "black;red;black"));
|
---|
210 | break;
|
---|
211 | }
|
---|
212 |
|
---|
213 | saveTopMarkData("2 spheres", "black");
|
---|
214 |
|
---|
215 | saveLightData("white");
|
---|
216 |
|
---|
217 | }
|
---|
218 |
|
---|
219 | public void setLightColour() {
|
---|
220 | super.setLightColour("W");
|
---|
221 | }
|
---|
222 |
|
---|
223 | }
|
---|