Changeset 32767 in osm for applications/editors
- Timestamp:
- 2016-08-04T02:27:43+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/smed
- Files:
-
- 1 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed/src/messages/Messages.java
r30294 r32767 5 5 6 6 public class Messages { 7 7 private static final String BUNDLE_NAME = "resources/msg.messages"; 8 8 9 9 private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); 10 10 11 12 11 private Messages() { 12 } 13 13 14 15 16 17 18 19 20 14 public static String getString(String key) { 15 try { 16 return RESOURCE_BUNDLE.getString(key); 17 } catch (MissingResourceException e) { 18 return '!' + key + '!'; 19 } 20 } 21 21 } -
applications/editors/josm/plugins/smed/src/panels/PanelChan.java
r30738 r32767 1 1 package panels; 2 2 3 import javax.swing.*; 4 5 import java.awt.*; 6 import java.awt.event.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 7 import javax.swing.BorderFactory; 8 import javax.swing.ButtonGroup; 9 import javax.swing.ImageIcon; 10 import javax.swing.JPanel; 11 import javax.swing.JRadioButton; 12 import javax.swing.JToggleButton; 7 13 8 14 import messages.Messages; 15 import seamarks.SeaMark; 16 import seamarks.SeaMark.Att; 17 import seamarks.SeaMark.Cat; 18 import seamarks.SeaMark.Col; 19 import seamarks.SeaMark.Grp; 20 import seamarks.SeaMark.Pat; 21 import seamarks.SeaMark.Shp; 22 import seamarks.SeaMark.Top; 9 23 import smed.SmedAction; 10 import seamarks.SeaMark;11 import seamarks.SeaMark.*;12 24 13 25 public class PanelChan extends JPanel { 14 26 15 private SmedAction dlg; 16 public PanelPort panelPort = null; 17 public PanelStbd panelStbd = null; 18 public PanelSaw panelSaw = null; 19 public ButtonGroup catButtons = new ButtonGroup(); 20 public JRadioButton portButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PortButton.png"))); 21 public JRadioButton stbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StbdButton.png"))); 22 public JRadioButton prefStbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PrefStbdButton.png"))); 23 public JRadioButton prefPortButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PrefPortButton.png"))); 24 public JRadioButton safeWaterButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SafeWaterButton.png"))); 25 private ActionListener alCat = new ActionListener() { 26 public void actionPerformed(java.awt.event.ActionEvent e) { 27 panelPort.setVisible(false); 28 panelStbd.setVisible(false); 29 panelSaw.setVisible(false); 30 SmedAction.panelMain.moreButton.setVisible(false); 31 SmedAction.panelMain.saveButton.setEnabled(false); 32 topmarkButton.setVisible(false); 33 lightButton.setVisible(false); 34 Shp shp = SmedAction.panelMain.mark.getShape(); 35 if (portButton.isSelected()) { 36 SmedAction.panelMain.mark.setCategory(Cat.LAM_PORT); 37 if (panelPort.shapes.containsKey(shp)) { 38 panelPort.shapes.get(shp).setSelected(true); 39 } else { 40 panelPort.shapeButtons.clearSelection(); 41 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 42 } 43 panelPort.alShape.actionPerformed(null); 44 panelPort.setVisible(true); 45 portButton.setBorderPainted(true); 46 } else { 47 portButton.setBorderPainted(false); 48 } 49 if (stbdButton.isSelected()) { 50 SmedAction.panelMain.mark.setCategory(Cat.LAM_STBD); 51 if (panelStbd.shapes.containsKey(shp)) { 52 panelStbd.shapes.get(shp).setSelected(true); 53 } else { 54 panelStbd.shapeButtons.clearSelection(); 55 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 56 } 57 panelStbd.alShape.actionPerformed(null); 58 panelStbd.setVisible(true); 59 stbdButton.setBorderPainted(true); 60 } else { 61 stbdButton.setBorderPainted(false); 62 } 63 if (prefStbdButton.isSelected()) { 64 SmedAction.panelMain.mark.setCategory(Cat.LAM_PSTBD); 65 if (panelPort.shapes.containsKey(shp)) { 66 panelPort.shapes.get(shp).setSelected(true); 67 } else { 68 panelPort.shapeButtons.clearSelection(); 69 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 70 } 71 panelPort.alShape.actionPerformed(null); 72 panelPort.setVisible(true); 73 prefStbdButton.setBorderPainted(true); 74 } else { 75 prefStbdButton.setBorderPainted(false); 76 } 77 if (prefPortButton.isSelected()) { 78 SmedAction.panelMain.mark.setCategory(Cat.LAM_PPORT); 79 if (panelStbd.shapes.containsKey(shp)) { 80 panelStbd.shapes.get(shp).setSelected(true); 81 } else { 82 panelStbd.shapeButtons.clearSelection(); 83 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 84 } 85 panelStbd.alShape.actionPerformed(null); 86 panelStbd.setVisible(true); 87 prefPortButton.setBorderPainted(true); 88 } else { 89 prefPortButton.setBorderPainted(false); 90 } 91 if (safeWaterButton.isSelected()) { 92 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 93 panelSaw.setVisible(true); 94 if (panelSaw.shapes.containsKey(shp)) { 95 panelSaw.shapes.get(shp).setSelected(true); 96 } else { 97 panelSaw.shapeButtons.clearSelection(); 98 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 99 } 100 panelSaw.alShape.actionPerformed(null); 101 panelSaw.setVisible(true); 102 safeWaterButton.setBorderPainted(true); 103 } else { 104 safeWaterButton.setBorderPainted(false); 105 } 106 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 107 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 108 SmedAction.panelMain.panelMore.syncPanel(); 109 } 110 }; 111 public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/ChanTopButton.png"))); 112 private ActionListener alTop = new ActionListener() { 113 public void actionPerformed(java.awt.event.ActionEvent e) { 114 if (topmarkButton.isSelected()) { 115 if (SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.SAW) { 116 SmedAction.panelMain.mark.setTopmark(Top.SPHERE); 117 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 118 SmedAction.panelMain.mark.setTopColour(Col.RED); 119 } else { 120 switch (dlg.panelMain.mark.getCategory()) { 121 case LAM_PORT: 122 case LAM_PSTBD: 123 dlg.panelMain.mark.setTopmark(Top.CYL); 124 switch (dlg.panelMain.mark.getRegion()) { 125 case A: 126 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 127 dlg.panelMain.mark.setTopColour(Col.RED); 128 break; 129 case B: 130 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 131 dlg.panelMain.mark.setTopColour(Col.GREEN); 132 break; 133 case C: 134 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PORT) { 135 dlg.panelMain.mark.setTopPattern(Pat.HSTRP); 136 dlg.panelMain.mark.setTopColour(Col.RED); 137 dlg.panelMain.mark.addTopColour(Col.WHITE); 138 } else { 139 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 140 dlg.panelMain.mark.setTopColour(Col.RED); 141 } 142 break; 143 } 144 break; 145 case LAM_STBD: 146 case LAM_PPORT: 147 dlg.panelMain.mark.setTopmark(Top.CONE); 148 switch (dlg.panelMain.mark.getRegion()) { 149 case A: 150 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 151 dlg.panelMain.mark.setTopColour(Col.GREEN); 152 break; 153 case B: 154 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 155 dlg.panelMain.mark.setTopColour(Col.RED); 156 break; 157 case C: 158 if (dlg.panelMain.mark.getCategory() == Cat.LAM_STBD) { 159 dlg.panelMain.mark.setTopPattern(Pat.HSTRP); 160 dlg.panelMain.mark.setTopColour(Col.GREEN); 161 dlg.panelMain.mark.addTopColour(Col.WHITE); 162 } else { 163 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 164 dlg.panelMain.mark.setTopColour(Col.GREEN); 165 } 166 break; 167 } 168 break; 169 } 170 } 171 topmarkButton.setBorderPainted(true); 172 } else { 173 dlg.panelMain.mark.setTopmark(Top.NOTOP); 174 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 175 dlg.panelMain.mark.setTopColour(Col.UNKCOL); 176 topmarkButton.setBorderPainted(false); 177 } 178 dlg.panelMain.panelTop.syncPanel(); 179 } 180 }; 181 public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png"))); 182 private ActionListener alLit = new ActionListener() { 183 public void actionPerformed(java.awt.event.ActionEvent e) { 184 if (lightButton.isSelected()) { 185 if (SeaMark.GrpMAP.get(dlg.panelMain.mark.getObject()) == Grp.SAW) { 186 dlg.panelMain.mark.setLightAtt(Att.CHR, 0, "LFl"); 187 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE); 188 } else { 189 dlg.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl"); 190 switch (dlg.panelMain.mark.getCategory()) { 191 case LAM_PORT: 192 case LAM_PPORT: 193 switch (dlg.panelMain.mark.getRegion()) { 194 case A: 195 case C: 196 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.RED); 197 break; 198 case B: 199 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.GREEN); 200 break; 201 } 202 break; 203 case LAM_STBD: 204 case LAM_PSTBD: 205 switch (dlg.panelMain.mark.getRegion()) { 206 case A: 207 case C: 208 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.GREEN); 209 break; 210 case B: 211 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.RED); 212 break; 213 } 214 break; 215 } 216 } 217 lightButton.setBorderPainted(true); 218 } else { 219 dlg.panelMain.mark.clrLight(); 220 lightButton.setBorderPainted(false); 221 } 222 dlg.panelMain.panelLit.syncPanel(); 223 } 224 }; 225 226 public PanelChan(SmedAction dia) { 227 dlg = dia; 228 setLayout(null); 229 panelPort = new PanelPort(dlg); 230 panelPort.setBounds(new Rectangle(55, 0, 70, 160)); 231 panelPort.setVisible(false); 232 panelStbd = new PanelStbd(dlg); 233 panelStbd.setBounds(new Rectangle(55, 0, 70, 160)); 234 panelStbd.setVisible(false); 235 panelSaw = new PanelSaw(dlg); 236 panelSaw.setBounds(new Rectangle(55, 0, 70, 160)); 237 panelSaw.setVisible(false); 238 add(panelPort); 239 add(panelStbd); 240 add(panelSaw); 241 add(getCatButton(portButton, 0, 0, 52, 32, "Port")); 242 add(getCatButton(stbdButton, 0, 32, 52, 32, "Stbd")); 243 add(getCatButton(prefStbdButton, 0, 64, 52, 32, "PrefStbd")); 244 add(getCatButton(prefPortButton, 0, 96, 52, 32, "PrefPort")); 245 add(getCatButton(safeWaterButton, 0, 128, 52, 32, "SafeWater")); 246 247 topmarkButton.setBounds(new Rectangle(130, 0, 34, 32)); 248 topmarkButton.setToolTipText(Messages.getString("Topmark")); 249 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); 250 topmarkButton.addActionListener(alTop); 251 topmarkButton.setVisible(false); 252 add(topmarkButton); 253 lightButton.setBounds(new Rectangle(130, 32, 34, 32)); 254 lightButton.setToolTipText(Messages.getString("Light")); 255 lightButton.setBorder(BorderFactory.createLoweredBevelBorder()); 256 lightButton.addActionListener(alLit); 257 lightButton.setVisible(false); 258 add(lightButton); 259 } 260 261 public void syncPanel() { 262 panelPort.setVisible(false); 263 panelStbd.setVisible(false); 264 panelSaw.setVisible(false); 265 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PORT) { 266 panelPort.setVisible(true); 267 portButton.setBorderPainted(true); 268 } else { 269 portButton.setBorderPainted(false); 270 } 271 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PPORT) { 272 panelStbd.setVisible(true); 273 prefPortButton.setBorderPainted(true); 274 } else { 275 prefPortButton.setBorderPainted(false); 276 } 277 if (dlg.panelMain.mark.getCategory() == Cat.LAM_STBD) { 278 panelStbd.setVisible(true); 279 stbdButton.setBorderPainted(true); 280 } else { 281 stbdButton.setBorderPainted(false); 282 } 283 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PSTBD) { 284 panelPort.setVisible(true); 285 prefStbdButton.setBorderPainted(true); 286 } else { 287 prefStbdButton.setBorderPainted(false); 288 } 289 if (SeaMark.GrpMAP.get(dlg.panelMain.mark.getObject()) == Grp.SAW) { 290 panelSaw.setVisible(true); 291 safeWaterButton.setBorderPainted(true); 292 } else { 293 safeWaterButton.setBorderPainted(false); 294 } 295 topmarkButton.setBorderPainted(dlg.panelMain.mark.getTopmark() != Top.NOTOP); 296 topmarkButton.setSelected(dlg.panelMain.mark.getTopmark() != Top.NOTOP); 297 topmarkButton.setVisible(dlg.panelMain.mark.testValid()); 298 Boolean lit = (dlg.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)dlg.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty(); 299 lightButton.setBorderPainted(lit); 300 lightButton.setSelected(lit); 301 lightButton.setVisible(dlg.panelMain.mark.testValid()); 302 panelPort.syncPanel(); 303 panelStbd.syncPanel(); 304 panelSaw.syncPanel(); 305 dlg.panelMain.mark.testValid(); 306 } 307 308 private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) { 309 button.setBounds(new Rectangle(x, y, w, h)); 310 button.setBorder(BorderFactory.createLoweredBevelBorder()); 311 button.setToolTipText(Messages.getString(tip)); 312 button.addActionListener(alCat); 313 catButtons.add(button); 314 return button; 315 } 27 private SmedAction dlg; 28 public PanelPort panelPort = null; 29 public PanelStbd panelStbd = null; 30 public PanelSaw panelSaw = null; 31 public ButtonGroup catButtons = new ButtonGroup(); 32 public JRadioButton portButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PortButton.png"))); 33 public JRadioButton stbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StbdButton.png"))); 34 public JRadioButton prefStbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PrefStbdButton.png"))); 35 public JRadioButton prefPortButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PrefPortButton.png"))); 36 public JRadioButton safeWaterButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SafeWaterButton.png"))); 37 private ActionListener alCat = new ActionListener() { 38 @Override 39 public void actionPerformed(ActionEvent e) { 40 panelPort.setVisible(false); 41 panelStbd.setVisible(false); 42 panelSaw.setVisible(false); 43 SmedAction.panelMain.moreButton.setVisible(false); 44 SmedAction.panelMain.saveButton.setEnabled(false); 45 topmarkButton.setVisible(false); 46 lightButton.setVisible(false); 47 Shp shp = SmedAction.panelMain.mark.getShape(); 48 if (portButton.isSelected()) { 49 SmedAction.panelMain.mark.setCategory(Cat.LAM_PORT); 50 if (panelPort.shapes.containsKey(shp)) { 51 panelPort.shapes.get(shp).setSelected(true); 52 } else { 53 panelPort.shapeButtons.clearSelection(); 54 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 55 } 56 panelPort.alShape.actionPerformed(null); 57 panelPort.setVisible(true); 58 portButton.setBorderPainted(true); 59 } else { 60 portButton.setBorderPainted(false); 61 } 62 if (stbdButton.isSelected()) { 63 SmedAction.panelMain.mark.setCategory(Cat.LAM_STBD); 64 if (panelStbd.shapes.containsKey(shp)) { 65 panelStbd.shapes.get(shp).setSelected(true); 66 } else { 67 panelStbd.shapeButtons.clearSelection(); 68 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 69 } 70 panelStbd.alShape.actionPerformed(null); 71 panelStbd.setVisible(true); 72 stbdButton.setBorderPainted(true); 73 } else { 74 stbdButton.setBorderPainted(false); 75 } 76 if (prefStbdButton.isSelected()) { 77 SmedAction.panelMain.mark.setCategory(Cat.LAM_PSTBD); 78 if (panelPort.shapes.containsKey(shp)) { 79 panelPort.shapes.get(shp).setSelected(true); 80 } else { 81 panelPort.shapeButtons.clearSelection(); 82 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 83 } 84 panelPort.alShape.actionPerformed(null); 85 panelPort.setVisible(true); 86 prefStbdButton.setBorderPainted(true); 87 } else { 88 prefStbdButton.setBorderPainted(false); 89 } 90 if (prefPortButton.isSelected()) { 91 SmedAction.panelMain.mark.setCategory(Cat.LAM_PPORT); 92 if (panelStbd.shapes.containsKey(shp)) { 93 panelStbd.shapes.get(shp).setSelected(true); 94 } else { 95 panelStbd.shapeButtons.clearSelection(); 96 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 97 } 98 panelStbd.alShape.actionPerformed(null); 99 panelStbd.setVisible(true); 100 prefPortButton.setBorderPainted(true); 101 } else { 102 prefPortButton.setBorderPainted(false); 103 } 104 if (safeWaterButton.isSelected()) { 105 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 106 panelSaw.setVisible(true); 107 if (panelSaw.shapes.containsKey(shp)) { 108 panelSaw.shapes.get(shp).setSelected(true); 109 } else { 110 panelSaw.shapeButtons.clearSelection(); 111 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 112 } 113 panelSaw.alShape.actionPerformed(null); 114 panelSaw.setVisible(true); 115 safeWaterButton.setBorderPainted(true); 116 } else { 117 safeWaterButton.setBorderPainted(false); 118 } 119 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 120 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 121 SmedAction.panelMain.panelMore.syncPanel(); 122 } 123 }; 124 public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/ChanTopButton.png"))); 125 private ActionListener alTop = new ActionListener() { 126 @Override 127 public void actionPerformed(ActionEvent e) { 128 if (topmarkButton.isSelected()) { 129 if (SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.SAW) { 130 SmedAction.panelMain.mark.setTopmark(Top.SPHERE); 131 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 132 SmedAction.panelMain.mark.setTopColour(Col.RED); 133 } else { 134 switch (dlg.panelMain.mark.getCategory()) { 135 case LAM_PORT: 136 case LAM_PSTBD: 137 dlg.panelMain.mark.setTopmark(Top.CYL); 138 switch (dlg.panelMain.mark.getRegion()) { 139 case A: 140 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 141 dlg.panelMain.mark.setTopColour(Col.RED); 142 break; 143 case B: 144 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 145 dlg.panelMain.mark.setTopColour(Col.GREEN); 146 break; 147 case C: 148 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PORT) { 149 dlg.panelMain.mark.setTopPattern(Pat.HSTRP); 150 dlg.panelMain.mark.setTopColour(Col.RED); 151 dlg.panelMain.mark.addTopColour(Col.WHITE); 152 } else { 153 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 154 dlg.panelMain.mark.setTopColour(Col.RED); 155 } 156 break; 157 } 158 break; 159 case LAM_STBD: 160 case LAM_PPORT: 161 dlg.panelMain.mark.setTopmark(Top.CONE); 162 switch (dlg.panelMain.mark.getRegion()) { 163 case A: 164 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 165 dlg.panelMain.mark.setTopColour(Col.GREEN); 166 break; 167 case B: 168 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 169 dlg.panelMain.mark.setTopColour(Col.RED); 170 break; 171 case C: 172 if (dlg.panelMain.mark.getCategory() == Cat.LAM_STBD) { 173 dlg.panelMain.mark.setTopPattern(Pat.HSTRP); 174 dlg.panelMain.mark.setTopColour(Col.GREEN); 175 dlg.panelMain.mark.addTopColour(Col.WHITE); 176 } else { 177 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 178 dlg.panelMain.mark.setTopColour(Col.GREEN); 179 } 180 break; 181 } 182 break; 183 } 184 } 185 topmarkButton.setBorderPainted(true); 186 } else { 187 dlg.panelMain.mark.setTopmark(Top.NOTOP); 188 dlg.panelMain.mark.setTopPattern(Pat.NOPAT); 189 dlg.panelMain.mark.setTopColour(Col.UNKCOL); 190 topmarkButton.setBorderPainted(false); 191 } 192 dlg.panelMain.panelTop.syncPanel(); 193 } 194 }; 195 public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png"))); 196 private ActionListener alLit = new ActionListener() { 197 @Override 198 public void actionPerformed(ActionEvent e) { 199 if (lightButton.isSelected()) { 200 if (SeaMark.GrpMAP.get(dlg.panelMain.mark.getObject()) == Grp.SAW) { 201 dlg.panelMain.mark.setLightAtt(Att.CHR, 0, "LFl"); 202 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE); 203 } else { 204 dlg.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl"); 205 switch (dlg.panelMain.mark.getCategory()) { 206 case LAM_PORT: 207 case LAM_PPORT: 208 switch (dlg.panelMain.mark.getRegion()) { 209 case A: 210 case C: 211 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.RED); 212 break; 213 case B: 214 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.GREEN); 215 break; 216 } 217 break; 218 case LAM_STBD: 219 case LAM_PSTBD: 220 switch (dlg.panelMain.mark.getRegion()) { 221 case A: 222 case C: 223 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.GREEN); 224 break; 225 case B: 226 dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.RED); 227 break; 228 } 229 break; 230 } 231 } 232 lightButton.setBorderPainted(true); 233 } else { 234 dlg.panelMain.mark.clrLight(); 235 lightButton.setBorderPainted(false); 236 } 237 dlg.panelMain.panelLit.syncPanel(); 238 } 239 }; 240 241 public PanelChan(SmedAction dia) { 242 dlg = dia; 243 setLayout(null); 244 panelPort = new PanelPort(dlg); 245 panelPort.setBounds(new Rectangle(55, 0, 70, 160)); 246 panelPort.setVisible(false); 247 panelStbd = new PanelStbd(dlg); 248 panelStbd.setBounds(new Rectangle(55, 0, 70, 160)); 249 panelStbd.setVisible(false); 250 panelSaw = new PanelSaw(dlg); 251 panelSaw.setBounds(new Rectangle(55, 0, 70, 160)); 252 panelSaw.setVisible(false); 253 add(panelPort); 254 add(panelStbd); 255 add(panelSaw); 256 add(getCatButton(portButton, 0, 0, 52, 32, "Port")); 257 add(getCatButton(stbdButton, 0, 32, 52, 32, "Stbd")); 258 add(getCatButton(prefStbdButton, 0, 64, 52, 32, "PrefStbd")); 259 add(getCatButton(prefPortButton, 0, 96, 52, 32, "PrefPort")); 260 add(getCatButton(safeWaterButton, 0, 128, 52, 32, "SafeWater")); 261 262 topmarkButton.setBounds(new Rectangle(130, 0, 34, 32)); 263 topmarkButton.setToolTipText(Messages.getString("Topmark")); 264 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); 265 topmarkButton.addActionListener(alTop); 266 topmarkButton.setVisible(false); 267 add(topmarkButton); 268 lightButton.setBounds(new Rectangle(130, 32, 34, 32)); 269 lightButton.setToolTipText(Messages.getString("Light")); 270 lightButton.setBorder(BorderFactory.createLoweredBevelBorder()); 271 lightButton.addActionListener(alLit); 272 lightButton.setVisible(false); 273 add(lightButton); 274 } 275 276 public void syncPanel() { 277 panelPort.setVisible(false); 278 panelStbd.setVisible(false); 279 panelSaw.setVisible(false); 280 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PORT) { 281 panelPort.setVisible(true); 282 portButton.setBorderPainted(true); 283 } else { 284 portButton.setBorderPainted(false); 285 } 286 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PPORT) { 287 panelStbd.setVisible(true); 288 prefPortButton.setBorderPainted(true); 289 } else { 290 prefPortButton.setBorderPainted(false); 291 } 292 if (dlg.panelMain.mark.getCategory() == Cat.LAM_STBD) { 293 panelStbd.setVisible(true); 294 stbdButton.setBorderPainted(true); 295 } else { 296 stbdButton.setBorderPainted(false); 297 } 298 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PSTBD) { 299 panelPort.setVisible(true); 300 prefStbdButton.setBorderPainted(true); 301 } else { 302 prefStbdButton.setBorderPainted(false); 303 } 304 if (SeaMark.GrpMAP.get(dlg.panelMain.mark.getObject()) == Grp.SAW) { 305 panelSaw.setVisible(true); 306 safeWaterButton.setBorderPainted(true); 307 } else { 308 safeWaterButton.setBorderPainted(false); 309 } 310 topmarkButton.setBorderPainted(dlg.panelMain.mark.getTopmark() != Top.NOTOP); 311 topmarkButton.setSelected(dlg.panelMain.mark.getTopmark() != Top.NOTOP); 312 topmarkButton.setVisible(dlg.panelMain.mark.testValid()); 313 Boolean lit = (dlg.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)dlg.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty(); 314 lightButton.setBorderPainted(lit); 315 lightButton.setSelected(lit); 316 lightButton.setVisible(dlg.panelMain.mark.testValid()); 317 panelPort.syncPanel(); 318 panelStbd.syncPanel(); 319 panelSaw.syncPanel(); 320 dlg.panelMain.mark.testValid(); 321 } 322 323 private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) { 324 button.setBounds(new Rectangle(x, y, w, h)); 325 button.setBorder(BorderFactory.createLoweredBevelBorder()); 326 button.setToolTipText(Messages.getString(tip)); 327 button.addActionListener(alCat); 328 catButtons.add(button); 329 return button; 330 } 316 331 317 332 } -
applications/editors/josm/plugins/smed/src/panels/PanelChr.java
r30738 r32767 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.*; 6 import java.awt.event.*; 5 import java.awt.Rectangle; 6 import java.awt.event.ActionEvent; 7 import java.awt.event.ActionListener; 8 import java.awt.event.FocusEvent; 9 import java.awt.event.FocusListener; 10 import java.util.EnumMap; 11 import java.util.EnumSet; 7 12 8 import javax.swing.*; 9 10 import java.util.*; 13 import javax.swing.BorderFactory; 14 import javax.swing.ImageIcon; 15 import javax.swing.JLabel; 16 import javax.swing.JPanel; 17 import javax.swing.JTextField; 18 import javax.swing.JToggleButton; 19 import javax.swing.SwingConstants; 11 20 12 21 import messages.Messages; 22 import seamarks.SeaMark; 23 import seamarks.SeaMark.Att; 24 import seamarks.SeaMark.Chr; 25 import seamarks.SeaMark.Col; 13 26 import smed.SmedAction; 14 import seamarks.SeaMark;15 import seamarks.SeaMark.*;16 27 17 28 public class PanelChr extends JPanel { 18 29 19 private SmedAction dlg; 20 public JLabel col1Label = new JLabel(); 21 public JLabel col2Label = new JLabel(); 22 public JLabel charLabel = new JLabel(); 23 public JTextField charBox = new JTextField(); 24 public JToggleButton noneButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/NoCharButton.png"))); 25 public JToggleButton fixedButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/FixedButton.png"))); 26 public JToggleButton flashButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/FlashButton.png"))); 27 public JToggleButton longFlashButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/LongFlashButton.png"))); 28 public JToggleButton quickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/QuickButton.png"))); 29 public JToggleButton veryQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/VeryQuickButton.png"))); 30 public JToggleButton ultraQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/UltraQuickButton.png"))); 31 public JToggleButton interruptedQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedQuickButton.png"))); 32 public JToggleButton interruptedVeryQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedVeryQuickButton.png"))); 33 public JToggleButton interruptedUltraQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedUltraQuickButton.png"))); 34 public JToggleButton isophasedButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/IsophasedButton.png"))); 35 public JToggleButton occultingButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/OccultingButton.png"))); 36 public JToggleButton morseButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/MorseButton.png"))); 37 public JToggleButton alternatingButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/AlternatingButton.png"))); 38 private EnumMap<Chr, JToggleButton> buttons = new EnumMap<>(Chr.class); 39 private ActionListener alCharButton = new ActionListener() { 40 public void actionPerformed(java.awt.event.ActionEvent e) { 41 JToggleButton source = (JToggleButton) e.getSource(); 42 EnumSet<Chr> combo = EnumSet.noneOf(Chr.class); 43 for (Chr chr : buttons.keySet()) { 44 JToggleButton button = buttons.get(chr); 45 if (button.isSelected()) { 46 combo.add(chr); 47 button.setBorderPainted(true); 48 } else { 49 combo.remove(chr); 50 button.setBorderPainted(false); 51 } 52 } 53 if (SeaMark.ChrMAP.containsKey(combo)) { 54 charBox.setText(SeaMark.ChrMAP.get(combo)); 55 } else { 56 for (Chr chr : buttons.keySet()) { 57 JToggleButton button = buttons.get(chr); 58 if (button == source) { 59 charBox.setText(SeaMark.ChrMAP.get(EnumSet.of(chr))); 60 button.setSelected(true); 61 button.setBorderPainted(true); 62 } else { 63 button.setSelected(false); 64 button.setBorderPainted(false); 65 } 66 } 67 } 68 String str = charBox.getText(); 69 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, str); 70 if (!str.contains("Al")) { 71 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0))); 72 SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKCOL); 73 } else { 74 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0))); 75 } 76 } 77 }; 78 private FocusListener flCharBox = new FocusListener() { 79 public void focusGained(java.awt.event.FocusEvent e) {} 80 public void focusLost(java.awt.event.FocusEvent e) { 81 String str = charBox.getText(); 82 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, str); 83 EnumSet<Chr> set = EnumSet.noneOf(Chr.class); 84 for (EnumSet<Chr> map : SeaMark.ChrMAP.keySet()) { 85 if (str.equals(SeaMark.ChrMAP.get(map))) { 86 set = map; 87 break; 88 } 89 } 90 for (Chr chr : buttons.keySet()) { 91 JToggleButton button = buttons.get(chr); 92 if (set.contains(chr)) { 93 button.setSelected(true); 94 button.setBorderPainted(true); 95 } else { 96 button.setSelected(false); 97 button.setBorderPainted(false); 98 } 99 } 100 if (!str.contains("Al")) { 101 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0))); 102 SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKCOL); 103 } else { 104 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0))); 105 } 106 } 107 }; 30 private SmedAction dlg; 31 public JLabel col1Label = new JLabel(); 32 public JLabel col2Label = new JLabel(); 33 public JLabel charLabel = new JLabel(); 34 public JTextField charBox = new JTextField(); 35 public JToggleButton noneButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/NoCharButton.png"))); 36 public JToggleButton fixedButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/FixedButton.png"))); 37 public JToggleButton flashButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/FlashButton.png"))); 38 public JToggleButton longFlashButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/LongFlashButton.png"))); 39 public JToggleButton quickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/QuickButton.png"))); 40 public JToggleButton veryQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/VeryQuickButton.png"))); 41 public JToggleButton ultraQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/UltraQuickButton.png"))); 42 public JToggleButton interruptedQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedQuickButton.png"))); 43 public JToggleButton interruptedVeryQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedVeryQuickButton.png"))); 44 public JToggleButton interruptedUltraQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedUltraQuickButton.png"))); 45 public JToggleButton isophasedButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/IsophasedButton.png"))); 46 public JToggleButton occultingButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/OccultingButton.png"))); 47 public JToggleButton morseButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/MorseButton.png"))); 48 public JToggleButton alternatingButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/AlternatingButton.png"))); 49 private EnumMap<Chr, JToggleButton> buttons = new EnumMap<>(Chr.class); 50 private ActionListener alCharButton = new ActionListener() { 51 @Override 52 public void actionPerformed(ActionEvent e) { 53 JToggleButton source = (JToggleButton) e.getSource(); 54 EnumSet<Chr> combo = EnumSet.noneOf(Chr.class); 55 for (Chr chr : buttons.keySet()) { 56 JToggleButton button = buttons.get(chr); 57 if (button.isSelected()) { 58 combo.add(chr); 59 button.setBorderPainted(true); 60 } else { 61 combo.remove(chr); 62 button.setBorderPainted(false); 63 } 64 } 65 if (SeaMark.ChrMAP.containsKey(combo)) { 66 charBox.setText(SeaMark.ChrMAP.get(combo)); 67 } else { 68 for (Chr chr : buttons.keySet()) { 69 JToggleButton button = buttons.get(chr); 70 if (button == source) { 71 charBox.setText(SeaMark.ChrMAP.get(EnumSet.of(chr))); 72 button.setSelected(true); 73 button.setBorderPainted(true); 74 } else { 75 button.setSelected(false); 76 button.setBorderPainted(false); 77 } 78 } 79 } 80 String str = charBox.getText(); 81 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, str); 82 if (!str.contains("Al")) { 83 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0))); 84 SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKCOL); 85 } else { 86 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0))); 87 } 88 } 89 }; 90 private FocusListener flCharBox = new FocusListener() { 91 @Override 92 public void focusGained(FocusEvent e) {} 93 @Override 94 public void focusLost(FocusEvent e) { 95 String str = charBox.getText(); 96 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, str); 97 EnumSet<Chr> set = EnumSet.noneOf(Chr.class); 98 for (EnumSet<Chr> map : SeaMark.ChrMAP.keySet()) { 99 if (str.equals(SeaMark.ChrMAP.get(map))) { 100 set = map; 101 break; 102 } 103 } 104 for (Chr chr : buttons.keySet()) { 105 JToggleButton button = buttons.get(chr); 106 if (set.contains(chr)) { 107 button.setSelected(true); 108 button.setBorderPainted(true); 109 } else { 110 button.setSelected(false); 111 button.setBorderPainted(false); 112 } 113 } 114 if (!str.contains("Al")) { 115 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0))); 116 SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKCOL); 117 } else { 118 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0))); 119 } 120 } 121 }; 108 122 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 123 public PanelChr(SmedAction dia) { 124 dlg = dia; 125 setLayout(null); 126 add(getChrButton(noneButton, 0, 0, 44, 16, Messages.getString("NoChar"), Chr.UNKCHR)); 127 add(getChrButton(fixedButton, 0, 16, 44, 16, Messages.getString("FChar"), Chr.FIXED)); 128 add(getChrButton(flashButton, 0, 32, 44, 16, Messages.getString("FlChar"), Chr.FLASH)); 129 add(getChrButton(longFlashButton, 0, 48, 44, 16, Messages.getString("LFlChar"), Chr.LFLASH)); 130 add(getChrButton(quickButton, 0, 64, 44, 16, Messages.getString("QChar"), Chr.QUICK)); 131 add(getChrButton(veryQuickButton, 0, 80, 44, 16, Messages.getString("VQChar"), Chr.VQUICK)); 132 add(getChrButton(ultraQuickButton, 0, 96, 44, 16, Messages.getString("UQChar"), Chr.UQUICK)); 133 add(getChrButton(alternatingButton, 44, 0, 44, 16, Messages.getString("AlChar"), Chr.ALTERNATING)); 134 add(getChrButton(isophasedButton, 44, 16, 44, 16, Messages.getString("IsoChar"), Chr.ISOPHASED)); 135 add(getChrButton(occultingButton, 44, 32, 44, 16, Messages.getString("OcChar"), Chr.OCCULTING)); 136 add(getChrButton(morseButton, 44, 48, 44, 16, Messages.getString("MoChar"), Chr.MORSE)); 137 add(getChrButton(interruptedQuickButton, 44, 64, 44, 16, Messages.getString("IQChar"), Chr.IQUICK)); 138 add(getChrButton(interruptedVeryQuickButton, 44, 80, 44, 16, Messages.getString("IVQChar"), Chr.IVQUICK)); 139 add(getChrButton(interruptedUltraQuickButton, 44, 96, 44, 16, Messages.getString("IUQChar"), Chr.IUQUICK)); 140 charLabel.setBounds(new Rectangle(0, 113, 88, 20)); 141 charLabel.setHorizontalAlignment(SwingConstants.CENTER); 142 charLabel.setText(Messages.getString("Character")); 143 add(charLabel); 144 col1Label.setBounds(new Rectangle(10, 135, 10, 20)); 145 col1Label.setOpaque(true); 146 add(col1Label); 147 col2Label.setBounds(new Rectangle(70, 135, 10, 20)); 148 col2Label.setOpaque(true); 149 add(col2Label); 150 charBox.setBounds(new Rectangle(20, 135, 50, 20)); 151 charBox.setHorizontalAlignment(SwingConstants.CENTER); 152 add(charBox); 153 charBox.addFocusListener(flCharBox); 154 } 141 155 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 156 public void syncPanel() { 157 String str = (String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0); 158 charBox.setText(str); 159 EnumSet<Chr> set = EnumSet.noneOf(Chr.class); 160 for (EnumSet<Chr> map : SeaMark.ChrMAP.keySet()) { 161 if (dlg.node != null && str.equals(SeaMark.ChrMAP.get(map))) { 162 set = map; 163 break; 164 } 165 } 166 if (!str.contains("Al")) { 167 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0))); 168 } else { 169 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0))); 170 } 171 col1Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0))); 172 for (Chr chr : buttons.keySet()) { 173 JToggleButton button = buttons.get(chr); 174 if (set.contains(chr)) { 175 button.setSelected(true); 176 button.setBorderPainted(true); 177 } else { 178 button.setSelected(false); 179 button.setBorderPainted(false); 180 } 181 } 182 } 169 183 170 171 172 173 174 175 176 177 178 184 private JToggleButton getChrButton(JToggleButton button, int x, int y, int w, int h, String tip, Chr chr) { 185 button.setBounds(new Rectangle(x, y, w, h)); 186 button.setBorder(BorderFactory.createLoweredBevelBorder()); 187 button.setBorderPainted(false); 188 button.setToolTipText(tr(tip)); 189 button.addActionListener(alCharButton); 190 buttons.put(chr, button); 191 return button; 192 } 179 193 180 194 } -
applications/editors/josm/plugins/smed/src/panels/PanelCol.java
r30738 r32767 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.*; 6 import java.awt.event.*; 7 import javax.swing.*; 8 9 import java.util.*; 5 import java.awt.Color; 6 import java.awt.Rectangle; 7 import java.awt.event.ActionEvent; 8 import java.awt.event.ActionListener; 9 import java.util.ArrayList; 10 import java.util.EnumMap; 11 12 import javax.swing.BorderFactory; 13 import javax.swing.ButtonGroup; 14 import javax.swing.ImageIcon; 15 import javax.swing.JPanel; 16 import javax.swing.JRadioButton; 10 17 11 18 import messages.Messages; 19 import seamarks.SeaMark; 20 import seamarks.SeaMark.Att; 21 import seamarks.SeaMark.Col; 22 import seamarks.SeaMark.Ent; 12 23 import smed.SmedAction; 13 import seamarks.SeaMark;14 import seamarks.SeaMark.*;15 24 16 25 public class PanelCol extends JPanel { 17 26 18 private SmedAction dlg; 19 private Ent ent; 20 private ButtonGroup colourButtons = new ButtonGroup(); 21 public JRadioButton delButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DelButton.png"))); 22 public JRadioButton addButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/AddButton.png"))); 23 public JRadioButton whiteButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WhiteButton.png"))); 24 public JRadioButton redButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RedButton.png"))); 25 public JRadioButton greenButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/GreenButton.png"))); 26 public JRadioButton yellowButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/YellowButton.png"))); 27 public JRadioButton orangeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OrangeButton.png"))); 28 public JRadioButton amberButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/AmberButton.png"))); 29 public JRadioButton blueButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BlueButton.png"))); 30 public JRadioButton violetButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/VioletButton.png"))); 31 public JRadioButton blackButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BlackButton.png"))); 32 public JRadioButton greyButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/GreyButton.png"))); 33 public JRadioButton brownButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BrownButton.png"))); 34 public JRadioButton magentaButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/MagentaButton.png"))); 35 public JRadioButton pinkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PinkButton.png"))); 36 public EnumMap<Col, JRadioButton> colours = new EnumMap<>(Col.class); 37 private ActionListener alColour = new ActionListener() { 38 public void actionPerformed(java.awt.event.ActionEvent e) { 39 for (Col col : colours.keySet()) { 40 JRadioButton button = colours.get(col); 41 if (button.isSelected()) { 42 if (ent == Ent.LIGHT) { 43 if (((String) SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).contains("Al")) { 44 if (((button == delButton) && (SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0) == Col.UNKCOL)) 45 || (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) == Col.UNKCOL)) { 46 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, col); 47 SmedAction.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col)); 48 } else { 49 SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, col); 50 SmedAction.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col)); 51 } 52 } else { 53 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, col); 54 SmedAction.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col)); 55 SmedAction.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col)); 56 } 57 button.setBorderPainted(true); 58 } else { 59 if (button == delButton) { 60 SmedAction.panelMain.mark.subColour(ent, stackIdx); 61 } else if (button == addButton) { 62 if (stackCol.size() != 0) 63 stackIdx++; 64 if (stackCol.size() == 0) 65 SmedAction.panelMain.mark.setColour(ent, col); 66 else 67 switch (SmedAction.panelMain.mark.getPattern(ent)) { 68 case NOPAT: 69 break; 70 case BORDER: 71 case CROSS: 72 if (stackCol.size() < 2) 73 SmedAction.panelMain.mark.addColour(ent, stackIdx, col); 74 break; 75 case SQUARED: 76 if (stackCol.size() < 4) 77 SmedAction.panelMain.mark.addColour(ent, stackIdx, col); 78 break; 79 default: 80 SmedAction.panelMain.mark.addColour(ent, stackIdx, col); 81 break; 82 } 83 } else { 84 SmedAction.panelMain.mark.setColour(ent, stackIdx, col); 85 } 86 syncPanel(); 87 } 88 } else { 89 button.setBorderPainted(false); 90 } 91 } 92 } 93 }; 94 private JPanel stack; 95 private ButtonGroup stackColours = new ButtonGroup(); 96 private ArrayList<JRadioButton> stackCol = new ArrayList<>(); 97 private int stackIdx = 0; 98 private ActionListener alStack = new ActionListener() { 99 public void actionPerformed(java.awt.event.ActionEvent e) { 100 for (int i = 0; stackCol.size() > i; i++) { 101 JRadioButton button = stackCol.get(i); 102 if (button.isSelected()) { 103 stackIdx = i; 104 button.setBorderPainted(true); 105 } else { 106 button.setBorderPainted(false); 107 } 108 } 109 } 110 }; 111 112 public PanelCol(SmedAction dia, Ent entity) { 113 dlg = dia; 114 ent = entity; 115 setLayout(null); 116 add(getColButton(delButton, 0, 0, 34, 16, Messages.getString("RemColour"), Col.UNKCOL)); 117 add(getColButton(whiteButton, 0, 16, 34, 16, Messages.getString("White"), Col.WHITE)); 118 add(getColButton(redButton, 0, 32, 34, 16, Messages.getString("Red"), Col.RED)); 119 add(getColButton(orangeButton, 0, 48, 34, 16, Messages.getString("Orange"), Col.ORANGE)); 120 add(getColButton(amberButton, 0, 64, 34, 16, Messages.getString("Amber"), Col.AMBER)); 121 add(getColButton(yellowButton, 0, 80, 34, 16, Messages.getString("Yellow"), Col.YELLOW)); 122 add(getColButton(greenButton, 0, 96, 34, 16, Messages.getString("Green"), Col.GREEN)); 123 add(getColButton(blueButton, 0, 112, 34, 16, Messages.getString("Blue"), Col.BLUE)); 124 add(getColButton(violetButton, 0, 128, 34, 16, Messages.getString("Violet"), Col.VIOLET)); 125 if (ent != Ent.LIGHT) { 126 add(getColButton(addButton, 0, 144, 34, 16, Messages.getString("AddColour"), Col.BLANK)); 127 add(getColButton(blackButton, 37, 0, 34, 16, Messages.getString("Black"), Col.BLACK)); 128 add(getColButton(greyButton, 37, 16, 34, 16, Messages.getString("Grey"), Col.GREY)); 129 add(getColButton(brownButton, 37, 32, 34, 16, Messages.getString("Brown"), Col.BROWN)); 130 add(getColButton(magentaButton, 37, 48, 34, 16, Messages.getString("Magenta"), Col.MAGENTA)); 131 add(getColButton(pinkButton, 37, 64, 34, 16, Messages.getString("Pink"), Col.PINK)); 132 133 stack = new JPanel(); 134 stack.setBorder(BorderFactory.createLineBorder(Color.black, 2)); 135 stack.setBounds(38, 87, 34, 64); 136 stack.setLayout(null); 137 add(stack); 138 } 139 } 140 141 public void trimStack(int max) { 142 while (stackCol.size() > max) { 143 stackCol.get(stackCol.size() - 1).setSelected(true); 144 delButton.doClick(); 145 } 146 } 147 148 public void syncPanel() { 149 if (ent == Ent.LIGHT) { 150 for (Col col : colours.keySet()) { 151 JRadioButton button = colours.get(col); 152 if (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) == col) { 153 button.setBorderPainted(true); 154 } else 155 button.setBorderPainted(false); 156 } 157 } else { 158 int idx; 159 for (idx = 0; SmedAction.panelMain.mark.getColour(ent, idx) != Col.UNKCOL; idx++) { 160 if (stackCol.size() <= idx) { 161 stackCol.add(idx, new JRadioButton(new ImageIcon(getClass().getResource("/images/ColourButton.png")))); 162 JRadioButton btnI = stackCol.get(idx); 163 btnI.setBorder(BorderFactory.createLoweredBevelBorder()); 164 stack.add(btnI); 165 stackColours.add(btnI); 166 btnI.addActionListener(alStack); 167 } 168 } 169 while (idx < stackCol.size()) { 170 JRadioButton btnI = stackCol.get(idx); 171 btnI.removeActionListener(alStack); 172 stackColours.remove(btnI); 173 stack.remove(btnI); 174 stackCol.remove(idx); 175 } 176 if (stackIdx >= stackCol.size()) 177 stackIdx = stackCol.size() - 1; 178 if (stackIdx < 0) 179 stackIdx = 0; 180 if (stackCol.size() == 0) { 181 stack.repaint(); 182 } else { 183 int height = 60 / stackCol.size(); 184 for (idx = 0; stackCol.size() > idx; idx++) { 185 JRadioButton btnI = stackCol.get(idx); 186 btnI.setBounds(2, (2 + (idx * height)), 30, height); 187 btnI.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getColour(ent, idx))); 188 if (stackIdx == idx) { 189 btnI.setBorderPainted(true); 190 } else { 191 btnI.setBorderPainted(false); 192 } 193 } 194 } 195 } 196 } 197 198 private JRadioButton getColButton(JRadioButton button, int x, int y, int w, int h, String tip, Col col) { 199 button.setBounds(new Rectangle(x, y, w, h)); 200 button.setBorder(BorderFactory.createLoweredBevelBorder()); 201 button.setToolTipText(tr(tip)); 202 button.addActionListener(alColour); 203 colourButtons.add(button); 204 colours.put(col, button); 205 return button; 206 } 27 private SmedAction dlg; 28 private Ent ent; 29 private ButtonGroup colourButtons = new ButtonGroup(); 30 public JRadioButton delButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DelButton.png"))); 31 public JRadioButton addButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/AddButton.png"))); 32 public JRadioButton whiteButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WhiteButton.png"))); 33 public JRadioButton redButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RedButton.png"))); 34 public JRadioButton greenButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/GreenButton.png"))); 35 public JRadioButton yellowButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/YellowButton.png"))); 36 public JRadioButton orangeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OrangeButton.png"))); 37 public JRadioButton amberButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/AmberButton.png"))); 38 public JRadioButton blueButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BlueButton.png"))); 39 public JRadioButton violetButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/VioletButton.png"))); 40 public JRadioButton blackButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BlackButton.png"))); 41 public JRadioButton greyButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/GreyButton.png"))); 42 public JRadioButton brownButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BrownButton.png"))); 43 public JRadioButton magentaButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/MagentaButton.png"))); 44 public JRadioButton pinkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PinkButton.png"))); 45 public EnumMap<Col, JRadioButton> colours = new EnumMap<>(Col.class); 46 private ActionListener alColour = new ActionListener() { 47 @Override 48 public void actionPerformed(ActionEvent e) { 49 for (Col col : colours.keySet()) { 50 JRadioButton button = colours.get(col); 51 if (button.isSelected()) { 52 if (ent == Ent.LIGHT) { 53 if (((String) SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).contains("Al")) { 54 if (((button == delButton) && (SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0) == Col.UNKCOL)) 55 || (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) == Col.UNKCOL)) { 56 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, col); 57 SmedAction.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col)); 58 } else { 59 SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, col); 60 SmedAction.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col)); 61 } 62 } else { 63 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, col); 64 SmedAction.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col)); 65 SmedAction.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col)); 66 } 67 button.setBorderPainted(true); 68 } else { 69 if (button == delButton) { 70 SmedAction.panelMain.mark.subColour(ent, stackIdx); 71 } else if (button == addButton) { 72 if (stackCol.size() != 0) { 73 stackIdx++; 74 } 75 if (stackCol.size() == 0) { 76 SmedAction.panelMain.mark.setColour(ent, col); 77 } else { 78 switch (SmedAction.panelMain.mark.getPattern(ent)) { 79 case NOPAT: 80 break; 81 case BORDER: 82 case CROSS: 83 if (stackCol.size() < 2) { 84 SmedAction.panelMain.mark.addColour(ent, stackIdx, col); 85 } 86 break; 87 case SQUARED: 88 if (stackCol.size() < 4) { 89 SmedAction.panelMain.mark.addColour(ent, stackIdx, col); 90 } 91 break; 92 default: 93 SmedAction.panelMain.mark.addColour(ent, stackIdx, col); 94 break; 95 } 96 } 97 } else { 98 SmedAction.panelMain.mark.setColour(ent, stackIdx, col); 99 } 100 syncPanel(); 101 } 102 } else { 103 button.setBorderPainted(false); 104 } 105 } 106 } 107 }; 108 private JPanel stack; 109 private ButtonGroup stackColours = new ButtonGroup(); 110 private ArrayList<JRadioButton> stackCol = new ArrayList<>(); 111 private int stackIdx = 0; 112 private ActionListener alStack = new ActionListener() { 113 @Override 114 public void actionPerformed(ActionEvent e) { 115 for (int i = 0; stackCol.size() > i; i++) { 116 JRadioButton button = stackCol.get(i); 117 if (button.isSelected()) { 118 stackIdx = i; 119 button.setBorderPainted(true); 120 } else { 121 button.setBorderPainted(false); 122 } 123 } 124 } 125 }; 126 127 public PanelCol(SmedAction dia, Ent entity) { 128 dlg = dia; 129 ent = entity; 130 setLayout(null); 131 add(getColButton(delButton, 0, 0, 34, 16, Messages.getString("RemColour"), Col.UNKCOL)); 132 add(getColButton(whiteButton, 0, 16, 34, 16, Messages.getString("White"), Col.WHITE)); 133 add(getColButton(redButton, 0, 32, 34, 16, Messages.getString("Red"), Col.RED)); 134 add(getColButton(orangeButton, 0, 48, 34, 16, Messages.getString("Orange"), Col.ORANGE)); 135 add(getColButton(amberButton, 0, 64, 34, 16, Messages.getString("Amber"), Col.AMBER)); 136 add(getColButton(yellowButton, 0, 80, 34, 16, Messages.getString("Yellow"), Col.YELLOW)); 137 add(getColButton(greenButton, 0, 96, 34, 16, Messages.getString("Green"), Col.GREEN)); 138 add(getColButton(blueButton, 0, 112, 34, 16, Messages.getString("Blue"), Col.BLUE)); 139 add(getColButton(violetButton, 0, 128, 34, 16, Messages.getString("Violet"), Col.VIOLET)); 140 if (ent != Ent.LIGHT) { 141 add(getColButton(addButton, 0, 144, 34, 16, Messages.getString("AddColour"), Col.BLANK)); 142 add(getColButton(blackButton, 37, 0, 34, 16, Messages.getString("Black"), Col.BLACK)); 143 add(getColButton(greyButton, 37, 16, 34, 16, Messages.getString("Grey"), Col.GREY)); 144 add(getColButton(brownButton, 37, 32, 34, 16, Messages.getString("Brown"), Col.BROWN)); 145 add(getColButton(magentaButton, 37, 48, 34, 16, Messages.getString("Magenta"), Col.MAGENTA)); 146 add(getColButton(pinkButton, 37, 64, 34, 16, Messages.getString("Pink"), Col.PINK)); 147 148 stack = new JPanel(); 149 stack.setBorder(BorderFactory.createLineBorder(Color.black, 2)); 150 stack.setBounds(38, 87, 34, 64); 151 stack.setLayout(null); 152 add(stack); 153 } 154 } 155 156 public void trimStack(int max) { 157 while (stackCol.size() > max) { 158 stackCol.get(stackCol.size() - 1).setSelected(true); 159 delButton.doClick(); 160 } 161 } 162 163 public void syncPanel() { 164 if (ent == Ent.LIGHT) { 165 for (Col col : colours.keySet()) { 166 JRadioButton button = colours.get(col); 167 if (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) == col) { 168 button.setBorderPainted(true); 169 } else { 170 button.setBorderPainted(false); 171 } 172 } 173 } else { 174 int idx; 175 for (idx = 0; SmedAction.panelMain.mark.getColour(ent, idx) != Col.UNKCOL; idx++) { 176 if (stackCol.size() <= idx) { 177 stackCol.add(idx, new JRadioButton(new ImageIcon(getClass().getResource("/images/ColourButton.png")))); 178 JRadioButton btnI = stackCol.get(idx); 179 btnI.setBorder(BorderFactory.createLoweredBevelBorder()); 180 stack.add(btnI); 181 stackColours.add(btnI); 182 btnI.addActionListener(alStack); 183 } 184 } 185 while (idx < stackCol.size()) { 186 JRadioButton btnI = stackCol.get(idx); 187 btnI.removeActionListener(alStack); 188 stackColours.remove(btnI); 189 stack.remove(btnI); 190 stackCol.remove(idx); 191 } 192 if (stackIdx >= stackCol.size()) { 193 stackIdx = stackCol.size() - 1; 194 } 195 if (stackIdx < 0) { 196 stackIdx = 0; 197 } 198 if (stackCol.size() == 0) { 199 stack.repaint(); 200 } else { 201 int height = 60 / stackCol.size(); 202 for (idx = 0; stackCol.size() > idx; idx++) { 203 JRadioButton btnI = stackCol.get(idx); 204 btnI.setBounds(2, (2 + (idx * height)), 30, height); 205 btnI.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getColour(ent, idx))); 206 if (stackIdx == idx) { 207 btnI.setBorderPainted(true); 208 } else { 209 btnI.setBorderPainted(false); 210 } 211 } 212 } 213 } 214 } 215 216 private JRadioButton getColButton(JRadioButton button, int x, int y, int w, int h, String tip, Col col) { 217 button.setBounds(new Rectangle(x, y, w, h)); 218 button.setBorder(BorderFactory.createLoweredBevelBorder()); 219 button.setToolTipText(tr(tip)); 220 button.addActionListener(alColour); 221 colourButtons.add(button); 222 colours.put(col, button); 223 return button; 224 } 207 225 208 226 } -
applications/editors/josm/plugins/smed/src/panels/PanelFog.java
r30738 r32767 1 1 package panels; 2 2 3 import javax.swing.*; 4 5 import java.awt.*; 6 import java.awt.event.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.awt.event.FocusAdapter; 7 import java.awt.event.FocusEvent; 8 import java.awt.event.FocusListener; 7 9 import java.util.EnumMap; 8 10 11 import javax.swing.BorderFactory; 12 import javax.swing.ButtonGroup; 13 import javax.swing.ImageIcon; 14 import javax.swing.JLabel; 15 import javax.swing.JPanel; 16 import javax.swing.JRadioButton; 17 import javax.swing.JTextField; 18 import javax.swing.SwingConstants; 19 9 20 import messages.Messages; 21 import seamarks.SeaMark.Fog; 10 22 import smed.SmedAction; 11 import seamarks.SeaMark.*;12 23 13 24 public class PanelFog extends JPanel { 14 25 15 private SmedAction dlg; 16 private ButtonGroup fogButtons = new ButtonGroup(); 17 public JRadioButton noFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png"))); 18 public JRadioButton yesFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogYesButton.png"))); 19 public JRadioButton hornButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogHornButton.png"))); 20 public JRadioButton sirenButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogSirenButton.png"))); 21 public JRadioButton diaButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogDiaButton.png"))); 22 public JRadioButton bellButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogBellButton.png"))); 23 public JRadioButton whisButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogWhisButton.png"))); 24 public JRadioButton gongButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogGongButton.png"))); 25 public JRadioButton explosButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogExplosButton.png"))); 26 private EnumMap<Fog, JRadioButton> fogs = new EnumMap<>(Fog.class); 27 private ActionListener alFog = new ActionListener() { 28 public void actionPerformed(java.awt.event.ActionEvent e) { 29 for (Fog fog : fogs.keySet()) { 30 JRadioButton button = fogs.get(fog); 31 if (button.isSelected()) { 32 SmedAction.panelMain.mark.setFogSound(fog); 33 button.setBorderPainted(true); 34 } else 35 button.setBorderPainted(false); 36 } 37 } 38 }; 39 public JLabel groupLabel; 40 public JTextField groupBox; 41 private FocusListener flGroup = new FocusAdapter() { 42 public void focusLost(java.awt.event.FocusEvent e) { 43 SmedAction.panelMain.mark.setFogGroup(groupBox.getText()); 44 } 45 }; 46 public JLabel periodLabel; 47 public JTextField periodBox; 48 private FocusListener flPeriod = new FocusAdapter() { 49 public void focusLost(java.awt.event.FocusEvent e) { 50 SmedAction.panelMain.mark.setFogPeriod(periodBox.getText()); 51 } 52 }; 53 public JLabel seqLabel; 54 public JTextField seqBox; 55 private FocusListener flSeq = new FocusAdapter() { 56 public void focusLost(java.awt.event.FocusEvent e) { 57 SmedAction.panelMain.mark.setFogSequence(seqBox.getText()); 58 } 59 }; 60 public JLabel rangeLabel; 61 public JTextField rangeBox; 62 private FocusListener flRange = new FocusAdapter() { 63 public void focusLost(java.awt.event.FocusEvent e) { 64 SmedAction.panelMain.mark.setFogRange(rangeBox.getText()); 65 } 66 }; 26 private SmedAction dlg; 27 private ButtonGroup fogButtons = new ButtonGroup(); 28 public JRadioButton noFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png"))); 29 public JRadioButton yesFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogYesButton.png"))); 30 public JRadioButton hornButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogHornButton.png"))); 31 public JRadioButton sirenButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogSirenButton.png"))); 32 public JRadioButton diaButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogDiaButton.png"))); 33 public JRadioButton bellButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogBellButton.png"))); 34 public JRadioButton whisButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogWhisButton.png"))); 35 public JRadioButton gongButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogGongButton.png"))); 36 public JRadioButton explosButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogExplosButton.png"))); 37 private EnumMap<Fog, JRadioButton> fogs = new EnumMap<>(Fog.class); 38 private ActionListener alFog = new ActionListener() { 39 @Override 40 public void actionPerformed(ActionEvent e) { 41 for (Fog fog : fogs.keySet()) { 42 JRadioButton button = fogs.get(fog); 43 if (button.isSelected()) { 44 SmedAction.panelMain.mark.setFogSound(fog); 45 button.setBorderPainted(true); 46 } else { 47 button.setBorderPainted(false); 48 } 49 } 50 } 51 }; 52 public JLabel groupLabel; 53 public JTextField groupBox; 54 private FocusListener flGroup = new FocusAdapter() { 55 @Override 56 public void focusLost(FocusEvent e) { 57 SmedAction.panelMain.mark.setFogGroup(groupBox.getText()); 58 } 59 }; 60 public JLabel periodLabel; 61 public JTextField periodBox; 62 private FocusListener flPeriod = new FocusAdapter() { 63 @Override 64 public void focusLost(FocusEvent e) { 65 SmedAction.panelMain.mark.setFogPeriod(periodBox.getText()); 66 } 67 }; 68 public JLabel seqLabel; 69 public JTextField seqBox; 70 private FocusListener flSeq = new FocusAdapter() { 71 @Override 72 public void focusLost(FocusEvent e) { 73 SmedAction.panelMain.mark.setFogSequence(seqBox.getText()); 74 } 75 }; 76 public JLabel rangeLabel; 77 public JTextField rangeBox; 78 private FocusListener flRange = new FocusAdapter() { 79 @Override 80 public void focusLost(FocusEvent e) { 81 SmedAction.panelMain.mark.setFogRange(rangeBox.getText()); 82 } 83 }; 67 84 68 69 70 71 72 73 74 75 76 77 78 79 85 public PanelFog(SmedAction dia) { 86 dlg = dia; 87 setLayout(null); 88 add(getFogButton(noFogButton, 0, 2, 27, 27, "NoFog", Fog.NOFOG)); 89 add(getFogButton(yesFogButton, 0, 32, 27, 27, "FogSignal", Fog.FOGSIG)); 90 add(getFogButton(hornButton, 0, 62, 27, 27, "Horn", Fog.HORN)); 91 add(getFogButton(sirenButton, 0, 92, 27, 27, "Siren", Fog.SIREN)); 92 add(getFogButton(gongButton, 0, 122, 27, 27, "Gong", Fog.GONG)); 93 add(getFogButton(diaButton, 30, 2, 27, 27, "Diaphone", Fog.DIA)); 94 add(getFogButton(bellButton, 30, 32, 27, 27, "Bell", Fog.BELL)); 95 add(getFogButton(whisButton, 30, 62, 27, 27, "Whistle", Fog.WHIS)); 96 add(getFogButton(explosButton, 30, 92, 27, 27, "Explosion", Fog.EXPLOS)); 80 97 81 82 83 84 85 86 87 88 98 groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER); 99 groupLabel.setBounds(new Rectangle(75, 0, 100, 20)); 100 add(groupLabel); 101 groupBox = new JTextField(); 102 groupBox.setBounds(new Rectangle(100, 20, 50, 20)); 103 groupBox.setHorizontalAlignment(SwingConstants.CENTER); 104 add(groupBox); 105 groupBox.addFocusListener(flGroup); 89 106 90 91 92 93 94 95 96 97 107 periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER); 108 periodLabel.setBounds(new Rectangle(75, 40, 100, 20)); 109 add(periodLabel); 110 periodBox = new JTextField(); 111 periodBox.setBounds(new Rectangle(100, 60, 50, 20)); 112 periodBox.setHorizontalAlignment(SwingConstants.CENTER); 113 add(periodBox); 114 periodBox.addFocusListener(flPeriod); 98 115 99 100 101 102 103 104 105 106 116 seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER); 117 seqLabel.setBounds(new Rectangle(75, 80, 100, 20)); 118 add(seqLabel); 119 seqBox = new JTextField(); 120 seqBox.setBounds(new Rectangle(100, 100, 50, 20)); 121 seqBox.setHorizontalAlignment(SwingConstants.CENTER); 122 add(seqBox); 123 seqBox.addFocusListener(flSeq); 107 124 108 109 110 111 112 113 114 115 125 rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER); 126 rangeLabel.setBounds(new Rectangle(75, 120, 100, 20)); 127 add(rangeLabel); 128 rangeBox = new JTextField(); 129 rangeBox.setBounds(new Rectangle(100, 140, 50, 20)); 130 rangeBox.setHorizontalAlignment(SwingConstants.CENTER); 131 add(rangeBox); 132 rangeBox.addFocusListener(flRange); 116 133 117 134 } 118 135 119 120 121 122 123 124 125 126 127 128 136 public void syncPanel() { 137 for (Fog fog : fogs.keySet()) { 138 JRadioButton button = fogs.get(fog); 139 button.setBorderPainted(SmedAction.panelMain.mark.getFogSound() == fog); 140 } 141 groupBox.setText(SmedAction.panelMain.mark.getFogGroup()); 142 seqBox.setText(SmedAction.panelMain.mark.getFogSequence()); 143 periodBox.setText(SmedAction.panelMain.mark.getFogPeriod()); 144 rangeBox.setText(SmedAction.panelMain.mark.getFogRange()); 145 } 129 146 130 131 132 133 134 135 136 137 138 147 private JRadioButton getFogButton(JRadioButton button, int x, int y, int w, int h, String tip, Fog fog) { 148 button.setBounds(new Rectangle(x, y, w, h)); 149 button.setBorder(BorderFactory.createLoweredBevelBorder()); 150 button.setToolTipText(Messages.getString(tip)); 151 button.addActionListener(alFog); 152 fogButtons.add(button); 153 fogs.put(fog, button); 154 return button; 155 } 139 156 140 157 } -
applications/editors/josm/plugins/smed/src/panels/PanelHaz.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.event.*; 4 import java.awt.*; 5 6 import javax.swing.*; 7 8 import java.util.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.util.EnumMap; 7 8 import javax.swing.BorderFactory; 9 import javax.swing.ButtonGroup; 10 import javax.swing.ImageIcon; 11 import javax.swing.JPanel; 12 import javax.swing.JRadioButton; 13 import javax.swing.JToggleButton; 9 14 10 15 import messages.Messages; 16 import seamarks.SeaMark; 17 import seamarks.SeaMark.Att; 18 import seamarks.SeaMark.Cat; 19 import seamarks.SeaMark.Col; 20 import seamarks.SeaMark.Grp; 21 import seamarks.SeaMark.Obj; 22 import seamarks.SeaMark.Pat; 23 import seamarks.SeaMark.Shp; 24 import seamarks.SeaMark.Top; 11 25 import smed.SmedAction; 12 import seamarks.SeaMark;13 import seamarks.SeaMark.*;14 26 15 27 public class PanelHaz extends JPanel { 16 28 17 private SmedAction dlg; 18 public ButtonGroup catButtons = new ButtonGroup(); 19 public JRadioButton northButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardNButton.png"))); 20 public JRadioButton southButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardSButton.png"))); 21 public JRadioButton eastButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardEButton.png"))); 22 public JRadioButton westButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardWButton.png"))); 23 public JRadioButton isolButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/IsolButton.png"))); 24 private ActionListener alCat = new ActionListener() { 25 public void actionPerformed(java.awt.event.ActionEvent e) { 26 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 27 if (northButton.isSelected()) { 28 SmedAction.panelMain.mark.setCategory(Cat.CAM_NORTH); 29 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 30 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 31 northButton.setBorderPainted(true); 32 } else { 33 northButton.setBorderPainted(false); 34 } 35 if (southButton.isSelected()) { 36 SmedAction.panelMain.mark.setCategory(Cat.CAM_SOUTH); 37 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 38 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 39 southButton.setBorderPainted(true); 40 } else { 41 southButton.setBorderPainted(false); 42 } 43 if (eastButton.isSelected()) { 44 SmedAction.panelMain.mark.setCategory(Cat.CAM_EAST); 45 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 46 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 47 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 48 eastButton.setBorderPainted(true); 49 } else { 50 eastButton.setBorderPainted(false); 51 } 52 if (westButton.isSelected()) { 53 SmedAction.panelMain.mark.setCategory(Cat.CAM_WEST); 54 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 55 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 56 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 57 westButton.setBorderPainted(true); 58 } else { 59 westButton.setBorderPainted(false); 60 } 61 if (isolButton.isSelected()) { 62 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 63 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 64 SmedAction.panelMain.mark.addObjColour(Col.RED); 65 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 66 isolButton.setBorderPainted(true); 67 } else { 68 isolButton.setBorderPainted(false); 69 } 70 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 71 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 72 SmedAction.panelMain.panelMore.syncPanel(); 73 } 74 }; 75 private ButtonGroup shapeButtons = new ButtonGroup(); 76 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 77 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 78 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 79 public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png"))); 80 public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png"))); 81 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 82 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 83 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 84 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 85 public EnumMap<Shp, Obj> carObjects = new EnumMap<>(Shp.class); 86 public EnumMap<Shp, Obj> isdObjects = new EnumMap<>(Shp.class); 87 private ActionListener alShape = new ActionListener() { 88 public void actionPerformed(java.awt.event.ActionEvent e) { 89 for (Shp shp : shapes.keySet()) { 90 JRadioButton button = shapes.get(shp); 91 if (button.isSelected()) { 92 SmedAction.panelMain.mark.setShape(shp); 93 if (isolButton.isSelected()) 94 SmedAction.panelMain.mark.setObject(isdObjects.get(shp)); 95 else 96 SmedAction.panelMain.mark.setObject(carObjects.get(shp)); 97 button.setBorderPainted(true); 98 } else 99 button.setBorderPainted(false); 100 } 101 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 102 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 103 } 104 }; 105 public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/HazTopButton.png"))); 106 private ActionListener alTop = new ActionListener() { 107 public void actionPerformed(java.awt.event.ActionEvent e) { 108 if (topmarkButton.isSelected()) { 109 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 110 SmedAction.panelMain.mark.setTopColour(Col.BLACK); 111 switch (SmedAction.panelMain.mark.getCategory()) { 112 case CAM_NORTH: 113 SmedAction.panelMain.mark.setTopmark(Top.NORTH); 114 break; 115 case CAM_SOUTH: 116 SmedAction.panelMain.mark.setTopmark(Top.SOUTH); 117 break; 118 case CAM_EAST: 119 SmedAction.panelMain.mark.setTopmark(Top.EAST); 120 break; 121 case CAM_WEST: 122 SmedAction.panelMain.mark.setTopmark(Top.WEST); 123 break; 124 default: 125 SmedAction.panelMain.mark.setTopmark(Top.SPHERES2); 126 break; 127 } 128 topmarkButton.setBorderPainted(true); 129 } else { 130 SmedAction.panelMain.mark.setTopmark(Top.NOTOP); 131 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 132 SmedAction.panelMain.mark.setTopColour(Col.UNKCOL); 133 topmarkButton.setBorderPainted(false); 134 } 135 SmedAction.panelMain.panelTop.syncPanel(); 136 } 137 }; 138 public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png"))); 139 private ActionListener alLit = new ActionListener() { 140 public void actionPerformed(java.awt.event.ActionEvent e) { 141 if (lightButton.isSelected()) { 142 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE); 143 switch (SmedAction.panelMain.mark.getCategory()) { 144 case CAM_NORTH: 145 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 146 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, ""); 147 break; 148 case CAM_SOUTH: 149 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q+LFl"); 150 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "6"); 151 break; 152 case CAM_EAST: 153 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 154 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "3"); 155 break; 156 case CAM_WEST: 157 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 158 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "9"); 159 break; 160 default: 161 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl"); 162 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "2"); 163 break; 164 } 165 lightButton.setBorderPainted(true); 166 } else { 167 SmedAction.panelMain.mark.clrLight(); 168 lightButton.setBorderPainted(false); 169 } 170 SmedAction.panelMain.panelLit.syncPanel(); 171 } 172 }; 173 174 public PanelHaz(SmedAction dia) { 175 dlg = dia; 176 setLayout(null); 177 add(getCatButton(northButton, 0, 0, 52, 32, "North")); 178 add(getCatButton(southButton, 0, 32, 52, 32, "South")); 179 add(getCatButton(eastButton, 0, 64, 52, 32, "East")); 180 add(getCatButton(westButton, 0, 96, 52, 32, "West")); 181 add(getCatButton(isolButton, 0, 128, 52, 32, "Isol")); 182 183 add(getShapeButton(pillarButton, 55, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYCAR, Obj.BOYISD)); 184 add(getShapeButton(sparButton, 55, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYCAR, Obj.BOYISD)); 185 add(getShapeButton(canButton, 55, 64, 34, 32, "Can", Shp.CAN, Obj.BOYCAR, Obj.BOYISD)); 186 add(getShapeButton(coneButton, 55, 96, 34, 32, "Cone", Shp.CONI, Obj.BOYCAR, Obj.BOYISD)); 187 add(getShapeButton(sphereButton, 55, 128, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYCAR, Obj.BOYISD)); 188 add(getShapeButton(floatButton, 90, 0, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT, Obj.LITFLT)); 189 add(getShapeButton(beaconButton, 90, 32, 34, 32, "Beacon", Shp.BEACON, Obj.BCNCAR, Obj.BCNISD)); 190 add(getShapeButton(towerButton, 90, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNCAR, Obj.BCNISD)); 191 192 topmarkButton.setBounds(new Rectangle(130, 0, 34, 32)); 193 topmarkButton.setToolTipText(Messages.getString("Topmark")); 194 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); 195 topmarkButton.addActionListener(alTop); 196 topmarkButton.setVisible(false); 197 add(topmarkButton); 198 lightButton.setBounds(new Rectangle(130, 32, 34, 32)); 199 lightButton.setToolTipText(Messages.getString("Light")); 200 lightButton.setBorder(BorderFactory.createLoweredBevelBorder()); 201 lightButton.addActionListener(alLit); 202 lightButton.setVisible(false); 203 add(lightButton); 204 } 205 206 public void syncPanel() { 207 northButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_NORTH); 208 southButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_SOUTH); 209 eastButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_EAST); 210 westButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_WEST); 211 isolButton.setBorderPainted(SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.ISD); 212 for (Shp shp : shapes.keySet()) { 213 JRadioButton button = shapes.get(shp); 214 button.setBorderPainted(SmedAction.panelMain.mark.getShape() == shp); 215 } 216 topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 217 topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 218 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 219 Boolean lit = (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty(); 220 lightButton.setBorderPainted(lit); 221 lightButton.setSelected(lit); 222 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 223 } 224 225 private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) { 226 button.setBounds(new Rectangle(x, y, w, h)); 227 button.setBorder(BorderFactory.createLoweredBevelBorder()); 228 button.setToolTipText(Messages.getString(tip)); 229 button.addActionListener(alCat); 230 catButtons.add(button); 231 return button; 232 } 233 234 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj car, Obj isd) { 235 button.setBounds(new Rectangle(x, y, w, h)); 236 button.setBorder(BorderFactory.createLoweredBevelBorder()); 237 button.setToolTipText(Messages.getString(tip)); 238 button.addActionListener(alShape); 239 shapeButtons.add(button); 240 shapes.put(shp, button); 241 carObjects.put(shp, car); 242 isdObjects.put(shp, isd); 243 return button; 244 } 29 private SmedAction dlg; 30 public ButtonGroup catButtons = new ButtonGroup(); 31 public JRadioButton northButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardNButton.png"))); 32 public JRadioButton southButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardSButton.png"))); 33 public JRadioButton eastButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardEButton.png"))); 34 public JRadioButton westButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardWButton.png"))); 35 public JRadioButton isolButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/IsolButton.png"))); 36 private ActionListener alCat = new ActionListener() { 37 @Override 38 public void actionPerformed(ActionEvent e) { 39 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 40 if (northButton.isSelected()) { 41 SmedAction.panelMain.mark.setCategory(Cat.CAM_NORTH); 42 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 43 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 44 northButton.setBorderPainted(true); 45 } else { 46 northButton.setBorderPainted(false); 47 } 48 if (southButton.isSelected()) { 49 SmedAction.panelMain.mark.setCategory(Cat.CAM_SOUTH); 50 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 51 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 52 southButton.setBorderPainted(true); 53 } else { 54 southButton.setBorderPainted(false); 55 } 56 if (eastButton.isSelected()) { 57 SmedAction.panelMain.mark.setCategory(Cat.CAM_EAST); 58 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 59 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 60 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 61 eastButton.setBorderPainted(true); 62 } else { 63 eastButton.setBorderPainted(false); 64 } 65 if (westButton.isSelected()) { 66 SmedAction.panelMain.mark.setCategory(Cat.CAM_WEST); 67 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 68 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 69 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 70 westButton.setBorderPainted(true); 71 } else { 72 westButton.setBorderPainted(false); 73 } 74 if (isolButton.isSelected()) { 75 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 76 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 77 SmedAction.panelMain.mark.addObjColour(Col.RED); 78 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 79 isolButton.setBorderPainted(true); 80 } else { 81 isolButton.setBorderPainted(false); 82 } 83 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 84 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 85 SmedAction.panelMain.panelMore.syncPanel(); 86 } 87 }; 88 private ButtonGroup shapeButtons = new ButtonGroup(); 89 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 90 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 91 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 92 public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png"))); 93 public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png"))); 94 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 95 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 96 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 97 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 98 public EnumMap<Shp, Obj> carObjects = new EnumMap<>(Shp.class); 99 public EnumMap<Shp, Obj> isdObjects = new EnumMap<>(Shp.class); 100 private ActionListener alShape = new ActionListener() { 101 @Override 102 public void actionPerformed(ActionEvent e) { 103 for (Shp shp : shapes.keySet()) { 104 JRadioButton button = shapes.get(shp); 105 if (button.isSelected()) { 106 SmedAction.panelMain.mark.setShape(shp); 107 if (isolButton.isSelected()) { 108 SmedAction.panelMain.mark.setObject(isdObjects.get(shp)); 109 } else { 110 SmedAction.panelMain.mark.setObject(carObjects.get(shp)); 111 } 112 button.setBorderPainted(true); 113 } else { 114 button.setBorderPainted(false); 115 } 116 } 117 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 118 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 119 } 120 }; 121 public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/HazTopButton.png"))); 122 private ActionListener alTop = new ActionListener() { 123 @Override 124 public void actionPerformed(ActionEvent e) { 125 if (topmarkButton.isSelected()) { 126 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 127 SmedAction.panelMain.mark.setTopColour(Col.BLACK); 128 switch (SmedAction.panelMain.mark.getCategory()) { 129 case CAM_NORTH: 130 SmedAction.panelMain.mark.setTopmark(Top.NORTH); 131 break; 132 case CAM_SOUTH: 133 SmedAction.panelMain.mark.setTopmark(Top.SOUTH); 134 break; 135 case CAM_EAST: 136 SmedAction.panelMain.mark.setTopmark(Top.EAST); 137 break; 138 case CAM_WEST: 139 SmedAction.panelMain.mark.setTopmark(Top.WEST); 140 break; 141 default: 142 SmedAction.panelMain.mark.setTopmark(Top.SPHERES2); 143 break; 144 } 145 topmarkButton.setBorderPainted(true); 146 } else { 147 SmedAction.panelMain.mark.setTopmark(Top.NOTOP); 148 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 149 SmedAction.panelMain.mark.setTopColour(Col.UNKCOL); 150 topmarkButton.setBorderPainted(false); 151 } 152 SmedAction.panelMain.panelTop.syncPanel(); 153 } 154 }; 155 public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png"))); 156 private ActionListener alLit = new ActionListener() { 157 @Override 158 public void actionPerformed(ActionEvent e) { 159 if (lightButton.isSelected()) { 160 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE); 161 switch (SmedAction.panelMain.mark.getCategory()) { 162 case CAM_NORTH: 163 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 164 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, ""); 165 break; 166 case CAM_SOUTH: 167 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q+LFl"); 168 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "6"); 169 break; 170 case CAM_EAST: 171 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 172 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "3"); 173 break; 174 case CAM_WEST: 175 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 176 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "9"); 177 break; 178 default: 179 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl"); 180 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "2"); 181 break; 182 } 183 lightButton.setBorderPainted(true); 184 } else { 185 SmedAction.panelMain.mark.clrLight(); 186 lightButton.setBorderPainted(false); 187 } 188 SmedAction.panelMain.panelLit.syncPanel(); 189 } 190 }; 191 192 public PanelHaz(SmedAction dia) { 193 dlg = dia; 194 setLayout(null); 195 add(getCatButton(northButton, 0, 0, 52, 32, "North")); 196 add(getCatButton(southButton, 0, 32, 52, 32, "South")); 197 add(getCatButton(eastButton, 0, 64, 52, 32, "East")); 198 add(getCatButton(westButton, 0, 96, 52, 32, "West")); 199 add(getCatButton(isolButton, 0, 128, 52, 32, "Isol")); 200 201 add(getShapeButton(pillarButton, 55, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYCAR, Obj.BOYISD)); 202 add(getShapeButton(sparButton, 55, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYCAR, Obj.BOYISD)); 203 add(getShapeButton(canButton, 55, 64, 34, 32, "Can", Shp.CAN, Obj.BOYCAR, Obj.BOYISD)); 204 add(getShapeButton(coneButton, 55, 96, 34, 32, "Cone", Shp.CONI, Obj.BOYCAR, Obj.BOYISD)); 205 add(getShapeButton(sphereButton, 55, 128, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYCAR, Obj.BOYISD)); 206 add(getShapeButton(floatButton, 90, 0, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT, Obj.LITFLT)); 207 add(getShapeButton(beaconButton, 90, 32, 34, 32, "Beacon", Shp.BEACON, Obj.BCNCAR, Obj.BCNISD)); 208 add(getShapeButton(towerButton, 90, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNCAR, Obj.BCNISD)); 209 210 topmarkButton.setBounds(new Rectangle(130, 0, 34, 32)); 211 topmarkButton.setToolTipText(Messages.getString("Topmark")); 212 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); 213 topmarkButton.addActionListener(alTop); 214 topmarkButton.setVisible(false); 215 add(topmarkButton); 216 lightButton.setBounds(new Rectangle(130, 32, 34, 32)); 217 lightButton.setToolTipText(Messages.getString("Light")); 218 lightButton.setBorder(BorderFactory.createLoweredBevelBorder()); 219 lightButton.addActionListener(alLit); 220 lightButton.setVisible(false); 221 add(lightButton); 222 } 223 224 public void syncPanel() { 225 northButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_NORTH); 226 southButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_SOUTH); 227 eastButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_EAST); 228 westButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_WEST); 229 isolButton.setBorderPainted(SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.ISD); 230 for (Shp shp : shapes.keySet()) { 231 JRadioButton button = shapes.get(shp); 232 button.setBorderPainted(SmedAction.panelMain.mark.getShape() == shp); 233 } 234 topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 235 topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 236 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 237 Boolean lit = (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty(); 238 lightButton.setBorderPainted(lit); 239 lightButton.setSelected(lit); 240 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 241 } 242 243 private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) { 244 button.setBounds(new Rectangle(x, y, w, h)); 245 button.setBorder(BorderFactory.createLoweredBevelBorder()); 246 button.setToolTipText(Messages.getString(tip)); 247 button.addActionListener(alCat); 248 catButtons.add(button); 249 return button; 250 } 251 252 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj car, Obj isd) { 253 button.setBounds(new Rectangle(x, y, w, h)); 254 button.setBorder(BorderFactory.createLoweredBevelBorder()); 255 button.setToolTipText(Messages.getString(tip)); 256 button.addActionListener(alShape); 257 shapeButtons.add(button); 258 shapes.put(shp, button); 259 carObjects.put(shp, car); 260 isdObjects.put(shp, isd); 261 return button; 262 } 245 263 246 264 } -
applications/editors/josm/plugins/smed/src/panels/PanelLights.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.event.*; 4 import java.awt.*; 5 6 import javax.swing.*; 7 8 import java.util.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.awt.event.FocusAdapter; 7 import java.awt.event.FocusEvent; 8 import java.awt.event.FocusListener; 9 import java.util.EnumMap; 10 11 import javax.swing.BorderFactory; 12 import javax.swing.ButtonGroup; 13 import javax.swing.ImageIcon; 14 import javax.swing.JComboBox; 15 import javax.swing.JLabel; 16 import javax.swing.JPanel; 17 import javax.swing.JRadioButton; 18 import javax.swing.JTextField; 19 import javax.swing.SwingConstants; 9 20 10 21 import messages.Messages; 22 import seamarks.SeaMark.Cat; 23 import seamarks.SeaMark.Fnc; 24 import seamarks.SeaMark.Obj; 25 import seamarks.SeaMark.Shp; 11 26 import smed.SmedAction; 12 import seamarks.SeaMark.*;13 27 14 28 public class PanelLights extends JPanel { 15 29 16 private SmedAction dlg; 17 18 public JLabel categoryLabel; 19 20 public JComboBox<String> landCatBox; 21 public EnumMap<Cat, Integer> landCats = new EnumMap<>(Cat.class); 22 private ActionListener alLandCatBox = new ActionListener() { 23 public void actionPerformed(java.awt.event.ActionEvent e) { 24 for (Cat cat : landCats.keySet()) { 25 int idx = landCats.get(cat); 26 if (dlg.node != null && (idx == landCatBox.getSelectedIndex())) { 27 SmedAction.panelMain.mark.setCategory(cat); 28 SmedAction.panelMain.mark.testValid(); 29 } 30 } 31 } 32 }; 33 public JComboBox<String> trafficCatBox; 34 public EnumMap<Cat, Integer> trafficCats = new EnumMap<>(Cat.class); 35 private ActionListener alTrafficCatBox = new ActionListener() { 36 public void actionPerformed(java.awt.event.ActionEvent e) { 37 for (Cat cat : trafficCats.keySet()) { 38 int idx = trafficCats.get(cat); 39 if (dlg.node != null && (idx == trafficCatBox.getSelectedIndex())) { 40 SmedAction.panelMain.mark.setCategory(cat); 41 SmedAction.panelMain.mark.testValid(); 42 } 43 } 44 } 45 }; 46 public JComboBox<String> warningCatBox; 47 public EnumMap<Cat, Integer> warningCats = new EnumMap<>(Cat.class); 48 private ActionListener alWarningCatBox = new ActionListener() { 49 public void actionPerformed(java.awt.event.ActionEvent e) { 50 for (Cat cat : warningCats.keySet()) { 51 int idx = warningCats.get(cat); 52 if (dlg.node != null && (idx == warningCatBox.getSelectedIndex())) { 53 SmedAction.panelMain.mark.setCategory(cat); 54 SmedAction.panelMain.mark.testValid(); 55 } 56 } 57 } 58 }; 59 public JComboBox<String> platformCatBox; 60 public EnumMap<Cat, Integer> platformCats = new EnumMap<>(Cat.class); 61 private ActionListener alPlatformCatBox = new ActionListener() { 62 public void actionPerformed(java.awt.event.ActionEvent e) { 63 for (Cat cat : platformCats.keySet()) { 64 int idx = platformCats.get(cat); 65 if (dlg.node != null && (idx == platformCatBox.getSelectedIndex())) { 66 SmedAction.panelMain.mark.setCategory(cat); 67 SmedAction.panelMain.mark.testValid(); 68 } 69 } 70 } 71 }; 72 public JComboBox<String> pilotCatBox; 73 public EnumMap<Cat, Integer> pilotCats = new EnumMap<>(Cat.class); 74 private ActionListener alPilotCatBox = new ActionListener() { 75 public void actionPerformed(java.awt.event.ActionEvent e) { 76 for (Cat cat : pilotCats.keySet()) { 77 int idx = pilotCats.get(cat); 78 if (dlg.node != null && (idx == pilotCatBox.getSelectedIndex())) { 79 SmedAction.panelMain.mark.setCategory(cat); 80 SmedAction.panelMain.mark.testValid(); 81 } 82 } 83 } 84 }; 85 public JComboBox<String> rescueCatBox; 86 public EnumMap<Cat, Integer> rescueCats = new EnumMap<>(Cat.class); 87 private ActionListener alRescueCatBox = new ActionListener() { 88 public void actionPerformed(java.awt.event.ActionEvent e) { 89 for (Cat cat : rescueCats.keySet()) { 90 int idx = rescueCats.get(cat); 91 if (dlg.node != null && (idx == rescueCatBox.getSelectedIndex())) { 92 SmedAction.panelMain.mark.setCategory(cat); 93 SmedAction.panelMain.mark.testValid(); 94 } 95 } 96 } 97 }; 98 public JComboBox<String> radioCatBox; 99 public EnumMap<Cat, Integer> radioCats = new EnumMap<>(Cat.class); 100 private ActionListener alRadioCatBox = new ActionListener() { 101 public void actionPerformed(java.awt.event.ActionEvent e) { 102 for (Cat cat : radioCats.keySet()) { 103 int idx = radioCats.get(cat); 104 if (dlg.node != null && (idx == radioCatBox.getSelectedIndex())) { 105 SmedAction.panelMain.mark.setCategory(cat); 106 SmedAction.panelMain.mark.testValid(); 107 } 108 } 109 } 110 }; 111 public JComboBox<String> radarCatBox; 112 public EnumMap<Cat, Integer> radarCats = new EnumMap<>(Cat.class); 113 private ActionListener alRadarCatBox = new ActionListener() { 114 public void actionPerformed(java.awt.event.ActionEvent e) { 115 for (Cat cat : radarCats.keySet()) { 116 int idx = radarCats.get(cat); 117 if (dlg.node != null && (idx == radarCatBox.getSelectedIndex())) { 118 SmedAction.panelMain.mark.setCategory(cat); 119 SmedAction.panelMain.mark.testValid(); 120 } 121 } 122 } 123 }; 124 public JLabel functionLabel; 125 public JComboBox<String> functionBox; 126 public EnumMap<Fnc, Integer> functions = new EnumMap<>(Fnc.class); 127 private ActionListener alfunctionBox = new ActionListener() { 128 public void actionPerformed(java.awt.event.ActionEvent e) { 129 for (Fnc fnc : functions.keySet()) { 130 int idx = functions.get(fnc); 131 if (dlg.node != null && (idx == functionBox.getSelectedIndex())) { 132 SmedAction.panelMain.mark.setFunc(fnc); 133 SmedAction.panelMain.mark.testValid(); 134 } 135 } 136 } 137 }; 138 private ButtonGroup objButtons = new ButtonGroup(); 139 public JRadioButton houseButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LighthouseButton.png"))); 140 public JRadioButton majorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightMajorButton.png"))); 141 public JRadioButton minorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightMinorButton.png"))); 142 public JRadioButton vesselButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightVesselButton.png"))); 143 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightFloatButton.png"))); 144 public JRadioButton landButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LandmarkButton.png"))); 145 public JRadioButton trafficButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TrafficButton.png"))); 146 public JRadioButton warningButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WarningButton.png"))); 147 public JRadioButton platformButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PlatformButton.png"))); 148 public JRadioButton coastguardButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CoastguardButton.png"))); 149 public JRadioButton pilotButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PilotButton.png"))); 150 public JRadioButton rescueButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RescueButton.png"))); 151 public JRadioButton radioButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadioStationButton.png"))); 152 public JRadioButton radarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarStationButton.png"))); 153 public EnumMap<Obj, JRadioButton> objects = new EnumMap<>(Obj.class); 154 private ActionListener alObj = new ActionListener() { 155 public void actionPerformed(java.awt.event.ActionEvent e) { 156 for (Obj obj : objects.keySet()) { 157 JRadioButton button = objects.get(obj); 158 if (button.isSelected()) { 159 SmedAction.panelMain.mark.setObject(obj); 160 button.setBorderPainted(true); 161 } else 162 button.setBorderPainted(false); 163 } 164 if (SmedAction.panelMain.mark.getObject() == Obj.LITVES) 165 SmedAction.panelMain.mark.setShape(Shp.SUPER); 166 else if (SmedAction.panelMain.mark.getObject() == Obj.LITFLT) 167 SmedAction.panelMain.mark.setShape(Shp.FLOAT); 168 else SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 169 functionLabel.setVisible(false); 170 categoryLabel.setVisible(false); 171 functionLabel.setVisible(false); 172 functionBox.setVisible(false); 173 landCatBox.setVisible(false); 174 trafficCatBox.setVisible(false); 175 warningCatBox.setVisible(false); 176 platformCatBox.setVisible(false); 177 pilotCatBox.setVisible(false); 178 rescueCatBox.setVisible(false); 179 radioCatBox.setVisible(false); 180 radarCatBox.setVisible(false); 181 chLabel.setVisible(false); 182 chBox.setVisible(false); 183 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 184 if (landButton.isSelected()) { 185 functionLabel.setVisible(true); 186 categoryLabel.setVisible(true); 187 functionBox.setVisible(true); 188 landCatBox.setVisible(true); 189 alLandCatBox.actionPerformed(null); 190 } else if (trafficButton.isSelected()) { 191 categoryLabel.setVisible(true); 192 trafficCatBox.setVisible(true); 193 chLabel.setVisible(true); 194 chBox.setVisible(true); 195 alTrafficCatBox.actionPerformed(null); 196 } else if (warningButton.isSelected()) { 197 categoryLabel.setVisible(true); 198 warningCatBox.setVisible(true); 199 chLabel.setVisible(true); 200 chBox.setVisible(true); 201 alWarningCatBox.actionPerformed(null); 202 } else if (platformButton.isSelected()) { 203 categoryLabel.setVisible(true); 204 platformCatBox.setVisible(true); 205 alPlatformCatBox.actionPerformed(null); 206 } else if (pilotButton.isSelected()) { 207 categoryLabel.setVisible(true); 208 pilotCatBox.setVisible(true); 209 chLabel.setVisible(true); 210 chBox.setVisible(true); 211 alPilotCatBox.actionPerformed(null); 212 } else if (rescueButton.isSelected()) { 213 categoryLabel.setVisible(true); 214 rescueCatBox.setVisible(true); 215 alRescueCatBox.actionPerformed(null); 216 } else if (radioButton.isSelected()) { 217 categoryLabel.setVisible(true); 218 radioCatBox.setVisible(true); 219 chLabel.setVisible(true); 220 chBox.setVisible(true); 221 alRadioCatBox.actionPerformed(null); 222 } else if (radarButton.isSelected()) { 223 categoryLabel.setVisible(true); 224 radarCatBox.setVisible(true); 225 chLabel.setVisible(true); 226 chBox.setVisible(true); 227 alRadarCatBox.actionPerformed(null); 228 } 229 SmedAction.panelMain.mark.testValid(); 230 } 231 }; 232 public JLabel chLabel; 233 public JTextField chBox; 234 private FocusListener flCh = new FocusAdapter() { 235 public void focusLost(java.awt.event.FocusEvent e) { 236 SmedAction.panelMain.mark.setChannel(chBox.getText()); 237 } 238 }; 239 240 public PanelLights(SmedAction dia) { 241 dlg = dia; 242 setLayout(null); 243 add(getObjButton(houseButton, 0, 0, 34, 32, "Lighthouse", Obj.LITHSE)); 244 add(getObjButton(majorButton, 34, 0, 34, 32, "MajorLight", Obj.LITMAJ)); 245 add(getObjButton(minorButton, 68, 0, 34, 32, "MinorLight", Obj.LITMIN)); 246 add(getObjButton(landButton, 102, 0, 34, 32, "Landmark", Obj.LNDMRK)); 247 add(getObjButton(platformButton, 136, 0, 34, 32, "Platform", Obj.OFSPLF)); 248 add(getObjButton(vesselButton, 0, 32, 34, 32, "LightVessel", Obj.LITVES)); 249 add(getObjButton(floatButton, 34, 32, 34, 32, "LightFloat", Obj.LITFLT)); 250 add(getObjButton(trafficButton, 68, 32, 34, 32, "SSTraffic", Obj.SISTAT)); 251 add(getObjButton(warningButton, 102, 32, 34, 32, "SSWarning", Obj.SISTAW)); 252 add(getObjButton(coastguardButton, 0, 64, 34, 32, "CoastguardStation", Obj.CGUSTA)); 253 add(getObjButton(pilotButton, 34, 64, 34, 32, "PilotBoarding", Obj.PILBOP)); 254 add(getObjButton(rescueButton, 68, 64, 34, 32, "RescueStation", Obj.RSCSTA)); 255 add(getObjButton(radioButton, 102, 64, 34, 32, "RadioStation", Obj.RDOSTA)); 256 add(getObjButton(radarButton, 136, 64, 34, 32, "RadarStation", Obj.RADSTA)); 257 258 functionLabel = new JLabel(Messages.getString("Function"), SwingConstants.CENTER); 259 functionLabel.setBounds(new Rectangle(5, 94, 160, 18)); 260 add(functionLabel); 261 functionLabel.setVisible(false); 262 263 functionBox = new JComboBox<>(); 264 functionBox.setBounds(new Rectangle(5, 110, 160, 18)); 265 add(functionBox); 266 functionBox.addActionListener(alfunctionBox); 267 addLFItem("", Fnc.UNKFNC); 268 addLFItem(Messages.getString("Church"), Fnc.CHCH); 269 addLFItem(Messages.getString("Chapel"), Fnc.CHPL); 270 addLFItem(Messages.getString("Temple"), Fnc.TMPL); 271 addLFItem(Messages.getString("Pagoda"), Fnc.PGDA); 272 addLFItem(Messages.getString("ShintoShrine"), Fnc.SHSH); 273 addLFItem(Messages.getString("BuddhistTemple"), Fnc.BTMP); 274 addLFItem(Messages.getString("Mosque"), Fnc.MOSQ); 275 addLFItem(Messages.getString("Marabout"), Fnc.MRBT); 276 functionBox.setVisible(false); 277 278 categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER); 279 categoryLabel.setBounds(new Rectangle(5, 125, 160, 18)); 280 add(categoryLabel); 281 categoryLabel.setVisible(false); 282 283 landCatBox = new JComboBox<>(); 284 landCatBox.setBounds(new Rectangle(5, 142, 160, 18)); 285 add(landCatBox); 286 landCatBox.addActionListener(alLandCatBox); 287 addLCItem("", Cat.NOCAT); 288 addLCItem(Messages.getString("Tower"), Cat.LMK_TOWR); 289 addLCItem(Messages.getString("WaterTower"), Cat.LMK_WTRT); 290 addLCItem(Messages.getString("Chimney"), Cat.LMK_CHMY); 291 addLCItem(Messages.getString("Mast"), Cat.LMK_MAST); 292 addLCItem(Messages.getString("Column"), Cat.LMK_CLMN); 293 addLCItem(Messages.getString("DishAerial"), Cat.LMK_DSHA); 294 addLCItem(Messages.getString("Flagstaff"), Cat.LMK_FLGS); 295 addLCItem(Messages.getString("FlareStack"), Cat.LMK_FLRS); 296 addLCItem(Messages.getString("Monument"), Cat.LMK_MNMT); 297 addLCItem(Messages.getString("WindMotor"), Cat.LMK_WNDM); 298 addLCItem(Messages.getString("WindSock"), Cat.LMK_WNDS); 299 addLCItem(Messages.getString("Obelisk"), Cat.LMK_OBLK); 300 addLCItem(Messages.getString("Statue"), Cat.LMK_STAT); 301 addLCItem(Messages.getString("Cross"), Cat.LMK_CROS); 302 addLCItem(Messages.getString("Dome"), Cat.LMK_DOME); 303 addLCItem(Messages.getString("RadarScanner"), Cat.LMK_SCNR); 304 addLCItem(Messages.getString("Windmill"), Cat.LMK_WNDL); 305 addLCItem(Messages.getString("Spire"), Cat.LMK_SPIR); 306 addLCItem(Messages.getString("Minaret"), Cat.LMK_MNRT); 307 addLCItem(Messages.getString("Cairn"), Cat.LMK_CARN); 308 landCatBox.setVisible(false); 309 310 trafficCatBox = new JComboBox<>(); 311 trafficCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 312 add(trafficCatBox); 313 trafficCatBox.addActionListener(alTrafficCatBox); 314 addTCItem("", Cat.NOCAT); 315 addTCItem(Messages.getString("Traffic"), Cat.SIS_TRFC); 316 addTCItem(Messages.getString("PortControl"), Cat.SIS_PTCL); 317 addTCItem(Messages.getString("PortEntry"), Cat.SIS_PTED); 318 addTCItem(Messages.getString("IPT"), Cat.SIS_IPT); 319 addTCItem(Messages.getString("Berthing"), Cat.SIS_BRTH); 320 addTCItem(Messages.getString("Dock"), Cat.SIS_DOCK); 321 addTCItem(Messages.getString("Lock"), Cat.SIS_LOCK); 322 addTCItem(Messages.getString("Barrage"), Cat.SIS_FBAR); 323 addTCItem(Messages.getString("Bridge"), Cat.SIS_BRDG); 324 addTCItem(Messages.getString("Dredging"), Cat.SIS_DRDG); 325 trafficCatBox.setVisible(false); 326 327 warningCatBox = new JComboBox<>(); 328 warningCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 329 add(warningCatBox); 330 warningCatBox.addActionListener(alWarningCatBox); 331 addWCItem("", Cat.NOCAT); 332 addWCItem(Messages.getString("Danger"), Cat.SIS_DNGR); 333 addWCItem(Messages.getString("Storm"), Cat.SIS_STRM); 334 addWCItem(Messages.getString("Weather"), Cat.SIS_WTHR); 335 addWCItem(Messages.getString("Obstruction"), Cat.SIS_OBST); 336 addWCItem(Messages.getString("Cable"), Cat.SIS_CABL); 337 addWCItem(Messages.getString("Distress"), Cat.SIS_DSTR); 338 addWCItem(Messages.getString("Time"), Cat.SIS_TIME); 339 addWCItem(Messages.getString("Tide"), Cat.SIS_TIDE); 340 addWCItem(Messages.getString("TidalStream"), Cat.SIS_TSTM); 341 addWCItem(Messages.getString("TideGauge"), Cat.SIS_TGAG); 342 addWCItem(Messages.getString("TideScale"), Cat.SIS_TSCL); 343 addWCItem(Messages.getString("Diving"), Cat.SIS_DIVE); 344 addWCItem(Messages.getString("Ice"), Cat.SIS_ICE); 345 addWCItem(Messages.getString("LevelGauge"), Cat.SIS_LGAG); 346 addWCItem(Messages.getString("Military"), Cat.SIS_MILY); 347 warningCatBox.setVisible(false); 348 349 platformCatBox = new JComboBox<>(); 350 platformCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 351 add(platformCatBox); 352 platformCatBox.addActionListener(alPlatformCatBox); 353 addPLItem("", Cat.NOCAT); 354 addPLItem(Messages.getString("Oil"), Cat.OFP_OIL); 355 addPLItem(Messages.getString("Production"), Cat.OFP_PRD); 356 addPLItem(Messages.getString("Observation"), Cat.OFP_OBS); 357 addPLItem(Messages.getString("ALP"), Cat.OFP_ALP); 358 addPLItem(Messages.getString("SALM"), Cat.OFP_SALM); 359 addPLItem(Messages.getString("MooringTower"), Cat.OFP_MOR); 360 addPLItem(Messages.getString("ArtificialIsland"), Cat.OFP_ISL); 361 addPLItem(Messages.getString("FPSO"), Cat.OFP_FPSO); 362 addPLItem(Messages.getString("Accommodation"), Cat.OFP_ACC); 363 addPLItem(Messages.getString("NCCB"), Cat.OFP_NCCB); 364 platformCatBox.setVisible(false); 365 366 pilotCatBox = new JComboBox<>(); 367 pilotCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 368 add(pilotCatBox); 369 pilotCatBox.addActionListener(alPilotCatBox); 370 addPTItem("", Cat.NOCAT); 371 addPTItem(Messages.getString("CruisingVessel"), Cat.PIL_VESS); 372 addPTItem(Messages.getString("Helicopter"), Cat.PIL_HELI); 373 addPTItem(Messages.getString("FromShore"), Cat.PIL_SHORE); 374 pilotCatBox.setVisible(false); 375 376 rescueCatBox = new JComboBox<>(); 377 rescueCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 378 add(rescueCatBox); 379 rescueCatBox.addActionListener(alRescueCatBox); 380 addRSItem("", Cat.NOCAT); 381 addRSItem(Messages.getString("Lifeboat"), Cat.RSC_LFB); 382 addRSItem(Messages.getString("Rocket"), Cat.RSC_RKT); 383 addRSItem(Messages.getString("ShipwreckedRefuge"), Cat.RSC_RSW); 384 addRSItem(Messages.getString("IntertidalRefuge"), Cat.RSC_RIT); 385 addRSItem(Messages.getString("MooredLifeboat"), Cat.RSC_MLB); 386 addRSItem(Messages.getString("Radio"), Cat.RSC_RAD); 387 addRSItem(Messages.getString("FirstAid"), Cat.RSC_FAE); 388 addRSItem(Messages.getString("Seaplane"), Cat.RSC_SPL); 389 addRSItem(Messages.getString("Aircraft"), Cat.RSC_AIR); 390 addRSItem(Messages.getString("Tug"), Cat.RSC_TUG); 391 rescueCatBox.setVisible(false); 392 393 radioCatBox = new JComboBox<>(); 394 radioCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 395 add(radioCatBox); 396 radioCatBox.addActionListener(alRadioCatBox); 397 addROItem("", Cat.NOCAT); 398 addROItem(Messages.getString("CircularBeacon"), Cat.ROS_OMNI); 399 addROItem(Messages.getString("DirectionalBeacon"), Cat.ROS_DIRL); 400 addROItem(Messages.getString("RotatingBeacon"), Cat.ROS_ROTP); 401 addROItem(Messages.getString("ConsolBeacon"), Cat.ROS_CNSL); 402 addROItem(Messages.getString("DirectionFinding"), Cat.ROS_RDF); 403 addROItem(Messages.getString("QTGService"), Cat.ROS_QTG); 404 addROItem(Messages.getString("AeronaticalBeacon"), Cat.ROS_AERO); 405 addROItem(Messages.getString("Decca"), Cat.ROS_DECA); 406 addROItem(Messages.getString("LoranC"), Cat.ROS_LORN); 407 addROItem(Messages.getString("DGPS"), Cat.ROS_DGPS); 408 addROItem(Messages.getString("Toran"), Cat.ROS_TORN); 409 addROItem(Messages.getString("Omega"), Cat.ROS_OMGA); 410 addROItem(Messages.getString("Syledis"), Cat.ROS_SYLD); 411 addROItem(Messages.getString("Chiaka"), Cat.ROS_CHKA); 412 addROItem(Messages.getString("PublicCommunication"), Cat.ROS_PCOM); 413 addROItem(Messages.getString("CommercialBroadcast"), Cat.ROS_COMB); 414 addROItem(Messages.getString("Facsimile"), Cat.ROS_FACS); 415 addROItem(Messages.getString("TimeSignal"), Cat.ROS_TIME); 416 addROItem(Messages.getString("AIS"), Cat.ROS_PAIS); 417 addROItem(Messages.getString("S-AIS"), Cat.ROS_SAIS); 418 addROItem(Messages.getString("V-AIS"), Cat.ROS_VAIS); 419 addROItem(Messages.getString("V-AISNC"), Cat.ROS_VANC); 420 addROItem(Messages.getString("V-AISSC"), Cat.ROS_VASC); 421 addROItem(Messages.getString("V-AISEC"), Cat.ROS_VAEC); 422 addROItem(Messages.getString("V-AISWC"), Cat.ROS_VAWC); 423 addROItem(Messages.getString("V-AISPL"), Cat.ROS_VAPL); 424 addROItem(Messages.getString("V-AISSL"), Cat.ROS_VASL); 425 addROItem(Messages.getString("V-AISID"), Cat.ROS_VAID); 426 addROItem(Messages.getString("V-AISSW"), Cat.ROS_VASW); 427 addROItem(Messages.getString("V-AISSP"), Cat.ROS_VASP); 428 addROItem(Messages.getString("V-AISWK"), Cat.ROS_VAWK); 429 radioCatBox.setVisible(false); 430 431 radarCatBox = new JComboBox<>(); 432 radarCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 433 add(radarCatBox); 434 radarCatBox.addActionListener(alRadarCatBox); 435 addRAItem("", Cat.NOCAT); 436 addRAItem(Messages.getString("Surveillance"), Cat.RAS_SRV); 437 addRAItem(Messages.getString("CoastRadar"), Cat.RAS_CST); 438 radarCatBox.setVisible(false); 439 440 chLabel = new JLabel("Ch:", SwingConstants.CENTER); 441 chLabel.setBounds(new Rectangle(140, 32, 30, 15)); 442 add(chLabel); 443 chBox = new JTextField(); 444 chBox.setBounds(new Rectangle(140, 45, 30, 20)); 445 chBox.setHorizontalAlignment(SwingConstants.CENTER); 446 add(chBox); 447 chBox.addFocusListener(flCh); 448 } 449 450 public void syncPanel() { 451 functionLabel.setVisible(false); 452 functionBox.setVisible(false); 453 categoryLabel.setVisible(false); 454 landCatBox.setVisible(false); 455 trafficCatBox.setVisible(false); 456 warningCatBox.setVisible(false); 457 platformCatBox.setVisible(false); 458 pilotCatBox.setVisible(false); 459 rescueCatBox.setVisible(false); 460 radioCatBox.setVisible(false); 461 radarCatBox.setVisible(false); 462 chLabel.setVisible(false); 463 chBox.setVisible(false); 464 chBox.setText(SmedAction.panelMain.mark.getChannel()); 465 if ((SmedAction.panelMain.mark.getObject() == Obj.LNDMRK) && ((SmedAction.panelMain.mark.getCategory() != Cat.NOCAT) || (SmedAction.panelMain.mark.getFunc() != Fnc.UNKFNC))) { 466 functionLabel.setVisible(true); 467 categoryLabel.setVisible(true); 468 functionBox.setVisible(true); 469 landCatBox.setVisible(true); 470 for (Fnc fnc : functions.keySet()) { 471 int item = functions.get(fnc); 472 if (SmedAction.panelMain.mark.getFunc() == fnc) 473 functionBox.setSelectedIndex(item); 474 } 475 for (Cat cat : landCats.keySet()) { 476 int item = landCats.get(cat); 477 if (SmedAction.panelMain.mark.getCategory() == cat) 478 landCatBox.setSelectedIndex(item); 479 } 480 } else if (SmedAction.panelMain.mark.getObject() == Obj.SISTAT) { 481 categoryLabel.setVisible(true); 482 trafficCatBox.setVisible(true); 483 for (Cat cat : trafficCats.keySet()) { 484 int item = trafficCats.get(cat); 485 if (SmedAction.panelMain.mark.getCategory() == cat) 486 trafficCatBox.setSelectedIndex(item); 487 } 488 chLabel.setVisible(true); 489 chBox.setVisible(true); 490 } else if (SmedAction.panelMain.mark.getObject() == Obj.SISTAW) { 491 categoryLabel.setVisible(true); 492 warningCatBox.setVisible(true); 493 for (Cat cat : warningCats.keySet()) { 494 int item = warningCats.get(cat); 495 if (SmedAction.panelMain.mark.getCategory() == cat) 496 warningCatBox.setSelectedIndex(item); 497 } 498 chLabel.setVisible(true); 499 chBox.setVisible(true); 500 } else if (SmedAction.panelMain.mark.getObject() == Obj.OFSPLF) { 501 categoryLabel.setVisible(true); 502 platformCatBox.setVisible(true); 503 for (Cat cat : platformCats.keySet()) { 504 int item = platformCats.get(cat); 505 if (SmedAction.panelMain.mark.getCategory() == cat) 506 platformCatBox.setSelectedIndex(item); 507 } 508 } else if (SmedAction.panelMain.mark.getObject() == Obj.PILBOP) { 509 categoryLabel.setVisible(true); 510 pilotCatBox.setVisible(true); 511 for (Cat cat : pilotCats.keySet()) { 512 int item = pilotCats.get(cat); 513 if (SmedAction.panelMain.mark.getCategory() == cat) 514 pilotCatBox.setSelectedIndex(item); 515 } 516 chLabel.setVisible(true); 517 chBox.setVisible(true); 518 } else if (SmedAction.panelMain.mark.getObject() == Obj.RSCSTA) { 519 categoryLabel.setVisible(true); 520 rescueCatBox.setVisible(true); 521 for (Cat cat : rescueCats.keySet()) { 522 int item = rescueCats.get(cat); 523 if (SmedAction.panelMain.mark.getCategory() == cat) 524 rescueCatBox.setSelectedIndex(item); 525 } 526 } else if (SmedAction.panelMain.mark.getObject() == Obj.RDOSTA) { 527 categoryLabel.setVisible(true); 528 radioCatBox.setVisible(true); 529 for (Cat cat : radioCats.keySet()) { 530 int item = radioCats.get(cat); 531 if (SmedAction.panelMain.mark.getCategory() == cat) 532 radioCatBox.setSelectedIndex(item); 533 } 534 chLabel.setVisible(true); 535 chBox.setVisible(true); 536 } else if (SmedAction.panelMain.mark.getObject() == Obj.RADSTA) { 537 categoryLabel.setVisible(true); 538 radarCatBox.setVisible(true); 539 for (Cat cat : radarCats.keySet()) { 540 int item = radarCats.get(cat); 541 if (SmedAction.panelMain.mark.getCategory() == cat) 542 radarCatBox.setSelectedIndex(item); 543 } 544 chLabel.setVisible(true); 545 chBox.setVisible(true); 546 } 547 for (Obj obj : objects.keySet()) { 548 JRadioButton button = objects.get(obj); 549 button.setBorderPainted(SmedAction.panelMain.mark.getObject() == obj); 550 } 551 SmedAction.panelMain.mark.testValid(); 552 } 553 554 private void addLCItem(String str, Cat cat) { 555 landCats.put(cat, landCatBox.getItemCount()); 556 landCatBox.addItem(str); 557 } 558 559 private void addTCItem(String str, Cat cat) { 560 trafficCats.put(cat, trafficCatBox.getItemCount()); 561 trafficCatBox.addItem(str); 562 } 563 564 private void addWCItem(String str, Cat cat) { 565 warningCats.put(cat, warningCatBox.getItemCount()); 566 warningCatBox.addItem(str); 567 } 568 569 private void addPLItem(String str, Cat cat) { 570 platformCats.put(cat, platformCatBox.getItemCount()); 571 platformCatBox.addItem(str); 572 } 573 574 private void addPTItem(String str, Cat cat) { 575 pilotCats.put(cat, pilotCatBox.getItemCount()); 576 pilotCatBox.addItem(str); 577 } 578 579 private void addRSItem(String str, Cat cat) { 580 rescueCats.put(cat, rescueCatBox.getItemCount()); 581 rescueCatBox.addItem(str); 582 } 583 584 private void addROItem(String str, Cat cat) { 585 radioCats.put(cat, radioCatBox.getItemCount()); 586 radioCatBox.addItem(str); 587 } 588 589 private void addRAItem(String str, Cat cat) { 590 radarCats.put(cat, radarCatBox.getItemCount()); 591 radarCatBox.addItem(str); 592 } 593 594 private void addLFItem(String str, Fnc fnc) { 595 functions.put(fnc, functionBox.getItemCount()); 596 functionBox.addItem(str); 597 } 598 599 private JRadioButton getObjButton(JRadioButton button, int x, int y, int w, int h, String tip, Obj obj) { 600 button.setBounds(new Rectangle(x, y, w, h)); 601 button.setBorder(BorderFactory.createLoweredBevelBorder()); 602 button.setToolTipText(Messages.getString(tip)); 603 button.addActionListener(alObj); 604 objButtons.add(button); 605 objects.put(obj, button); 606 return button; 607 } 30 private SmedAction dlg; 31 32 public JLabel categoryLabel; 33 34 public JComboBox<String> landCatBox; 35 public EnumMap<Cat, Integer> landCats = new EnumMap<>(Cat.class); 36 private ActionListener alLandCatBox = new ActionListener() { 37 @Override 38 public void actionPerformed(ActionEvent e) { 39 for (Cat cat : landCats.keySet()) { 40 int idx = landCats.get(cat); 41 if (dlg.node != null && (idx == landCatBox.getSelectedIndex())) { 42 SmedAction.panelMain.mark.setCategory(cat); 43 SmedAction.panelMain.mark.testValid(); 44 } 45 } 46 } 47 }; 48 public JComboBox<String> trafficCatBox; 49 public EnumMap<Cat, Integer> trafficCats = new EnumMap<>(Cat.class); 50 private ActionListener alTrafficCatBox = new ActionListener() { 51 @Override 52 public void actionPerformed(ActionEvent e) { 53 for (Cat cat : trafficCats.keySet()) { 54 int idx = trafficCats.get(cat); 55 if (dlg.node != null && (idx == trafficCatBox.getSelectedIndex())) { 56 SmedAction.panelMain.mark.setCategory(cat); 57 SmedAction.panelMain.mark.testValid(); 58 } 59 } 60 } 61 }; 62 public JComboBox<String> warningCatBox; 63 public EnumMap<Cat, Integer> warningCats = new EnumMap<>(Cat.class); 64 private ActionListener alWarningCatBox = new ActionListener() { 65 @Override 66 public void actionPerformed(ActionEvent e) { 67 for (Cat cat : warningCats.keySet()) { 68 int idx = warningCats.get(cat); 69 if (dlg.node != null && (idx == warningCatBox.getSelectedIndex())) { 70 SmedAction.panelMain.mark.setCategory(cat); 71 SmedAction.panelMain.mark.testValid(); 72 } 73 } 74 } 75 }; 76 public JComboBox<String> platformCatBox; 77 public EnumMap<Cat, Integer> platformCats = new EnumMap<>(Cat.class); 78 private ActionListener alPlatformCatBox = new ActionListener() { 79 @Override 80 public void actionPerformed(ActionEvent e) { 81 for (Cat cat : platformCats.keySet()) { 82 int idx = platformCats.get(cat); 83 if (dlg.node != null && (idx == platformCatBox.getSelectedIndex())) { 84 SmedAction.panelMain.mark.setCategory(cat); 85 SmedAction.panelMain.mark.testValid(); 86 } 87 } 88 } 89 }; 90 public JComboBox<String> pilotCatBox; 91 public EnumMap<Cat, Integer> pilotCats = new EnumMap<>(Cat.class); 92 private ActionListener alPilotCatBox = new ActionListener() { 93 @Override 94 public void actionPerformed(ActionEvent e) { 95 for (Cat cat : pilotCats.keySet()) { 96 int idx = pilotCats.get(cat); 97 if (dlg.node != null && (idx == pilotCatBox.getSelectedIndex())) { 98 SmedAction.panelMain.mark.setCategory(cat); 99 SmedAction.panelMain.mark.testValid(); 100 } 101 } 102 } 103 }; 104 public JComboBox<String> rescueCatBox; 105 public EnumMap<Cat, Integer> rescueCats = new EnumMap<>(Cat.class); 106 private ActionListener alRescueCatBox = new ActionListener() { 107 @Override 108 public void actionPerformed(ActionEvent e) { 109 for (Cat cat : rescueCats.keySet()) { 110 int idx = rescueCats.get(cat); 111 if (dlg.node != null && (idx == rescueCatBox.getSelectedIndex())) { 112 SmedAction.panelMain.mark.setCategory(cat); 113 SmedAction.panelMain.mark.testValid(); 114 } 115 } 116 } 117 }; 118 public JComboBox<String> radioCatBox; 119 public EnumMap<Cat, Integer> radioCats = new EnumMap<>(Cat.class); 120 private ActionListener alRadioCatBox = new ActionListener() { 121 @Override 122 public void actionPerformed(ActionEvent e) { 123 for (Cat cat : radioCats.keySet()) { 124 int idx = radioCats.get(cat); 125 if (dlg.node != null && (idx == radioCatBox.getSelectedIndex())) { 126 SmedAction.panelMain.mark.setCategory(cat); 127 SmedAction.panelMain.mark.testValid(); 128 } 129 } 130 } 131 }; 132 public JComboBox<String> radarCatBox; 133 public EnumMap<Cat, Integer> radarCats = new EnumMap<>(Cat.class); 134 private ActionListener alRadarCatBox = new ActionListener() { 135 @Override 136 public void actionPerformed(ActionEvent e) { 137 for (Cat cat : radarCats.keySet()) { 138 int idx = radarCats.get(cat); 139 if (dlg.node != null && (idx == radarCatBox.getSelectedIndex())) { 140 SmedAction.panelMain.mark.setCategory(cat); 141 SmedAction.panelMain.mark.testValid(); 142 } 143 } 144 } 145 }; 146 public JLabel functionLabel; 147 public JComboBox<String> functionBox; 148 public EnumMap<Fnc, Integer> functions = new EnumMap<>(Fnc.class); 149 private ActionListener alfunctionBox = new ActionListener() { 150 @Override 151 public void actionPerformed(ActionEvent e) { 152 for (Fnc fnc : functions.keySet()) { 153 int idx = functions.get(fnc); 154 if (dlg.node != null && (idx == functionBox.getSelectedIndex())) { 155 SmedAction.panelMain.mark.setFunc(fnc); 156 SmedAction.panelMain.mark.testValid(); 157 } 158 } 159 } 160 }; 161 private ButtonGroup objButtons = new ButtonGroup(); 162 public JRadioButton houseButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LighthouseButton.png"))); 163 public JRadioButton majorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightMajorButton.png"))); 164 public JRadioButton minorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightMinorButton.png"))); 165 public JRadioButton vesselButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightVesselButton.png"))); 166 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightFloatButton.png"))); 167 public JRadioButton landButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LandmarkButton.png"))); 168 public JRadioButton trafficButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TrafficButton.png"))); 169 public JRadioButton warningButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WarningButton.png"))); 170 public JRadioButton platformButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PlatformButton.png"))); 171 public JRadioButton coastguardButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CoastguardButton.png"))); 172 public JRadioButton pilotButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PilotButton.png"))); 173 public JRadioButton rescueButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RescueButton.png"))); 174 public JRadioButton radioButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadioStationButton.png"))); 175 public JRadioButton radarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarStationButton.png"))); 176 public EnumMap<Obj, JRadioButton> objects = new EnumMap<>(Obj.class); 177 private ActionListener alObj = new ActionListener() { 178 @Override 179 public void actionPerformed(ActionEvent e) { 180 for (Obj obj : objects.keySet()) { 181 JRadioButton button = objects.get(obj); 182 if (button.isSelected()) { 183 SmedAction.panelMain.mark.setObject(obj); 184 button.setBorderPainted(true); 185 } else { 186 button.setBorderPainted(false); 187 } 188 } 189 if (SmedAction.panelMain.mark.getObject() == Obj.LITVES) { 190 SmedAction.panelMain.mark.setShape(Shp.SUPER); 191 } else if (SmedAction.panelMain.mark.getObject() == Obj.LITFLT) { 192 SmedAction.panelMain.mark.setShape(Shp.FLOAT); 193 } else { 194 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 195 } 196 functionLabel.setVisible(false); 197 categoryLabel.setVisible(false); 198 functionLabel.setVisible(false); 199 functionBox.setVisible(false); 200 landCatBox.setVisible(false); 201 trafficCatBox.setVisible(false); 202 warningCatBox.setVisible(false); 203 platformCatBox.setVisible(false); 204 pilotCatBox.setVisible(false); 205 rescueCatBox.setVisible(false); 206 radioCatBox.setVisible(false); 207 radarCatBox.setVisible(false); 208 chLabel.setVisible(false); 209 chBox.setVisible(false); 210 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 211 if (landButton.isSelected()) { 212 functionLabel.setVisible(true); 213 categoryLabel.setVisible(true); 214 functionBox.setVisible(true); 215 landCatBox.setVisible(true); 216 alLandCatBox.actionPerformed(null); 217 } else if (trafficButton.isSelected()) { 218 categoryLabel.setVisible(true); 219 trafficCatBox.setVisible(true); 220 chLabel.setVisible(true); 221 chBox.setVisible(true); 222 alTrafficCatBox.actionPerformed(null); 223 } else if (warningButton.isSelected()) { 224 categoryLabel.setVisible(true); 225 warningCatBox.setVisible(true); 226 chLabel.setVisible(true); 227 chBox.setVisible(true); 228 alWarningCatBox.actionPerformed(null); 229 } else if (platformButton.isSelected()) { 230 categoryLabel.setVisible(true); 231 platformCatBox.setVisible(true); 232 alPlatformCatBox.actionPerformed(null); 233 } else if (pilotButton.isSelected()) { 234 categoryLabel.setVisible(true); 235 pilotCatBox.setVisible(true); 236 chLabel.setVisible(true); 237 chBox.setVisible(true); 238 alPilotCatBox.actionPerformed(null); 239 } else if (rescueButton.isSelected()) { 240 categoryLabel.setVisible(true); 241 rescueCatBox.setVisible(true); 242 alRescueCatBox.actionPerformed(null); 243 } else if (radioButton.isSelected()) { 244 categoryLabel.setVisible(true); 245 radioCatBox.setVisible(true); 246 chLabel.setVisible(true); 247 chBox.setVisible(true); 248 alRadioCatBox.actionPerformed(null); 249 } else if (radarButton.isSelected()) { 250 categoryLabel.setVisible(true); 251 radarCatBox.setVisible(true); 252 chLabel.setVisible(true); 253 chBox.setVisible(true); 254 alRadarCatBox.actionPerformed(null); 255 } 256 SmedAction.panelMain.mark.testValid(); 257 } 258 }; 259 public JLabel chLabel; 260 public JTextField chBox; 261 private FocusListener flCh = new FocusAdapter() { 262 @Override 263 public void focusLost(FocusEvent e) { 264 SmedAction.panelMain.mark.setChannel(chBox.getText()); 265 } 266 }; 267 268 public PanelLights(SmedAction dia) { 269 dlg = dia; 270 setLayout(null); 271 add(getObjButton(houseButton, 0, 0, 34, 32, "Lighthouse", Obj.LITHSE)); 272 add(getObjButton(majorButton, 34, 0, 34, 32, "MajorLight", Obj.LITMAJ)); 273 add(getObjButton(minorButton, 68, 0, 34, 32, "MinorLight", Obj.LITMIN)); 274 add(getObjButton(landButton, 102, 0, 34, 32, "Landmark", Obj.LNDMRK)); 275 add(getObjButton(platformButton, 136, 0, 34, 32, "Platform", Obj.OFSPLF)); 276 add(getObjButton(vesselButton, 0, 32, 34, 32, "LightVessel", Obj.LITVES)); 277 add(getObjButton(floatButton, 34, 32, 34, 32, "LightFloat", Obj.LITFLT)); 278 add(getObjButton(trafficButton, 68, 32, 34, 32, "SSTraffic", Obj.SISTAT)); 279 add(getObjButton(warningButton, 102, 32, 34, 32, "SSWarning", Obj.SISTAW)); 280 add(getObjButton(coastguardButton, 0, 64, 34, 32, "CoastguardStation", Obj.CGUSTA)); 281 add(getObjButton(pilotButton, 34, 64, 34, 32, "PilotBoarding", Obj.PILBOP)); 282 add(getObjButton(rescueButton, 68, 64, 34, 32, "RescueStation", Obj.RSCSTA)); 283 add(getObjButton(radioButton, 102, 64, 34, 32, "RadioStation", Obj.RDOSTA)); 284 add(getObjButton(radarButton, 136, 64, 34, 32, "RadarStation", Obj.RADSTA)); 285 286 functionLabel = new JLabel(Messages.getString("Function"), SwingConstants.CENTER); 287 functionLabel.setBounds(new Rectangle(5, 94, 160, 18)); 288 add(functionLabel); 289 functionLabel.setVisible(false); 290 291 functionBox = new JComboBox<>(); 292 functionBox.setBounds(new Rectangle(5, 110, 160, 18)); 293 add(functionBox); 294 functionBox.addActionListener(alfunctionBox); 295 addLFItem("", Fnc.UNKFNC); 296 addLFItem(Messages.getString("Church"), Fnc.CHCH); 297 addLFItem(Messages.getString("Chapel"), Fnc.CHPL); 298 addLFItem(Messages.getString("Temple"), Fnc.TMPL); 299 addLFItem(Messages.getString("Pagoda"), Fnc.PGDA); 300 addLFItem(Messages.getString("ShintoShrine"), Fnc.SHSH); 301 addLFItem(Messages.getString("BuddhistTemple"), Fnc.BTMP); 302 addLFItem(Messages.getString("Mosque"), Fnc.MOSQ); 303 addLFItem(Messages.getString("Marabout"), Fnc.MRBT); 304 functionBox.setVisible(false); 305 306 categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER); 307 categoryLabel.setBounds(new Rectangle(5, 125, 160, 18)); 308 add(categoryLabel); 309 categoryLabel.setVisible(false); 310 311 landCatBox = new JComboBox<>(); 312 landCatBox.setBounds(new Rectangle(5, 142, 160, 18)); 313 add(landCatBox); 314 landCatBox.addActionListener(alLandCatBox); 315 addLCItem("", Cat.NOCAT); 316 addLCItem(Messages.getString("Tower"), Cat.LMK_TOWR); 317 addLCItem(Messages.getString("WaterTower"), Cat.LMK_WTRT); 318 addLCItem(Messages.getString("Chimney"), Cat.LMK_CHMY); 319 addLCItem(Messages.getString("Mast"), Cat.LMK_MAST); 320 addLCItem(Messages.getString("Column"), Cat.LMK_CLMN); 321 addLCItem(Messages.getString("DishAerial"), Cat.LMK_DSHA); 322 addLCItem(Messages.getString("Flagstaff"), Cat.LMK_FLGS); 323 addLCItem(Messages.getString("FlareStack"), Cat.LMK_FLRS); 324 addLCItem(Messages.getString("Monument"), Cat.LMK_MNMT); 325 addLCItem(Messages.getString("WindMotor"), Cat.LMK_WNDM); 326 addLCItem(Messages.getString("WindSock"), Cat.LMK_WNDS); 327 addLCItem(Messages.getString("Obelisk"), Cat.LMK_OBLK); 328 addLCItem(Messages.getString("Statue"), Cat.LMK_STAT); 329 addLCItem(Messages.getString("Cross"), Cat.LMK_CROS); 330 addLCItem(Messages.getString("Dome"), Cat.LMK_DOME); 331 addLCItem(Messages.getString("RadarScanner"), Cat.LMK_SCNR); 332 addLCItem(Messages.getString("Windmill"), Cat.LMK_WNDL); 333 addLCItem(Messages.getString("Spire"), Cat.LMK_SPIR); 334 addLCItem(Messages.getString("Minaret"), Cat.LMK_MNRT); 335 addLCItem(Messages.getString("Cairn"), Cat.LMK_CARN); 336 landCatBox.setVisible(false); 337 338 trafficCatBox = new JComboBox<>(); 339 trafficCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 340 add(trafficCatBox); 341 trafficCatBox.addActionListener(alTrafficCatBox); 342 addTCItem("", Cat.NOCAT); 343 addTCItem(Messages.getString("Traffic"), Cat.SIS_TRFC); 344 addTCItem(Messages.getString("PortControl"), Cat.SIS_PTCL); 345 addTCItem(Messages.getString("PortEntry"), Cat.SIS_PTED); 346 addTCItem(Messages.getString("IPT"), Cat.SIS_IPT); 347 addTCItem(Messages.getString("Berthing"), Cat.SIS_BRTH); 348 addTCItem(Messages.getString("Dock"), Cat.SIS_DOCK); 349 addTCItem(Messages.getString("Lock"), Cat.SIS_LOCK); 350 addTCItem(Messages.getString("Barrage"), Cat.SIS_FBAR); 351 addTCItem(Messages.getString("Bridge"), Cat.SIS_BRDG); 352 addTCItem(Messages.getString("Dredging"), Cat.SIS_DRDG); 353 trafficCatBox.setVisible(false); 354 355 warningCatBox = new JComboBox<>(); 356 warningCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 357 add(warningCatBox); 358 warningCatBox.addActionListener(alWarningCatBox); 359 addWCItem("", Cat.NOCAT); 360 addWCItem(Messages.getString("Danger"), Cat.SIS_DNGR); 361 addWCItem(Messages.getString("Storm"), Cat.SIS_STRM); 362 addWCItem(Messages.getString("Weather"), Cat.SIS_WTHR); 363 addWCItem(Messages.getString("Obstruction"), Cat.SIS_OBST); 364 addWCItem(Messages.getString("Cable"), Cat.SIS_CABL); 365 addWCItem(Messages.getString("Distress"), Cat.SIS_DSTR); 366 addWCItem(Messages.getString("Time"), Cat.SIS_TIME); 367 addWCItem(Messages.getString("Tide"), Cat.SIS_TIDE); 368 addWCItem(Messages.getString("TidalStream"), Cat.SIS_TSTM); 369 addWCItem(Messages.getString("TideGauge"), Cat.SIS_TGAG); 370 addWCItem(Messages.getString("TideScale"), Cat.SIS_TSCL); 371 addWCItem(Messages.getString("Diving"), Cat.SIS_DIVE); 372 addWCItem(Messages.getString("Ice"), Cat.SIS_ICE); 373 addWCItem(Messages.getString("LevelGauge"), Cat.SIS_LGAG); 374 addWCItem(Messages.getString("Military"), Cat.SIS_MILY); 375 warningCatBox.setVisible(false); 376 377 platformCatBox = new JComboBox<>(); 378 platformCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 379 add(platformCatBox); 380 platformCatBox.addActionListener(alPlatformCatBox); 381 addPLItem("", Cat.NOCAT); 382 addPLItem(Messages.getString("Oil"), Cat.OFP_OIL); 383 addPLItem(Messages.getString("Production"), Cat.OFP_PRD); 384 addPLItem(Messages.getString("Observation"), Cat.OFP_OBS); 385 addPLItem(Messages.getString("ALP"), Cat.OFP_ALP); 386 addPLItem(Messages.getString("SALM"), Cat.OFP_SALM); 387 addPLItem(Messages.getString("MooringTower"), Cat.OFP_MOR); 388 addPLItem(Messages.getString("ArtificialIsland"), Cat.OFP_ISL); 389 addPLItem(Messages.getString("FPSO"), Cat.OFP_FPSO); 390 addPLItem(Messages.getString("Accommodation"), Cat.OFP_ACC); 391 addPLItem(Messages.getString("NCCB"), Cat.OFP_NCCB); 392 platformCatBox.setVisible(false); 393 394 pilotCatBox = new JComboBox<>(); 395 pilotCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 396 add(pilotCatBox); 397 pilotCatBox.addActionListener(alPilotCatBox); 398 addPTItem("", Cat.NOCAT); 399 addPTItem(Messages.getString("CruisingVessel"), Cat.PIL_VESS); 400 addPTItem(Messages.getString("Helicopter"), Cat.PIL_HELI); 401 addPTItem(Messages.getString("FromShore"), Cat.PIL_SHORE); 402 pilotCatBox.setVisible(false); 403 404 rescueCatBox = new JComboBox<>(); 405 rescueCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 406 add(rescueCatBox); 407 rescueCatBox.addActionListener(alRescueCatBox); 408 addRSItem("", Cat.NOCAT); 409 addRSItem(Messages.getString("Lifeboat"), Cat.RSC_LFB); 410 addRSItem(Messages.getString("Rocket"), Cat.RSC_RKT); 411 addRSItem(Messages.getString("ShipwreckedRefuge"), Cat.RSC_RSW); 412 addRSItem(Messages.getString("IntertidalRefuge"), Cat.RSC_RIT); 413 addRSItem(Messages.getString("MooredLifeboat"), Cat.RSC_MLB); 414 addRSItem(Messages.getString("Radio"), Cat.RSC_RAD); 415 addRSItem(Messages.getString("FirstAid"), Cat.RSC_FAE); 416 addRSItem(Messages.getString("Seaplane"), Cat.RSC_SPL); 417 addRSItem(Messages.getString("Aircraft"), Cat.RSC_AIR); 418 addRSItem(Messages.getString("Tug"), Cat.RSC_TUG); 419 rescueCatBox.setVisible(false); 420 421 radioCatBox = new JComboBox<>(); 422 radioCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 423 add(radioCatBox); 424 radioCatBox.addActionListener(alRadioCatBox); 425 addROItem("", Cat.NOCAT); 426 addROItem(Messages.getString("CircularBeacon"), Cat.ROS_OMNI); 427 addROItem(Messages.getString("DirectionalBeacon"), Cat.ROS_DIRL); 428 addROItem(Messages.getString("RotatingBeacon"), Cat.ROS_ROTP); 429 addROItem(Messages.getString("ConsolBeacon"), Cat.ROS_CNSL); 430 addROItem(Messages.getString("DirectionFinding"), Cat.ROS_RDF); 431 addROItem(Messages.getString("QTGService"), Cat.ROS_QTG); 432 addROItem(Messages.getString("AeronaticalBeacon"), Cat.ROS_AERO); 433 addROItem(Messages.getString("Decca"), Cat.ROS_DECA); 434 addROItem(Messages.getString("LoranC"), Cat.ROS_LORN); 435 addROItem(Messages.getString("DGPS"), Cat.ROS_DGPS); 436 addROItem(Messages.getString("Toran"), Cat.ROS_TORN); 437 addROItem(Messages.getString("Omega"), Cat.ROS_OMGA); 438 addROItem(Messages.getString("Syledis"), Cat.ROS_SYLD); 439 addROItem(Messages.getString("Chiaka"), Cat.ROS_CHKA); 440 addROItem(Messages.getString("PublicCommunication"), Cat.ROS_PCOM); 441 addROItem(Messages.getString("CommercialBroadcast"), Cat.ROS_COMB); 442 addROItem(Messages.getString("Facsimile"), Cat.ROS_FACS); 443 addROItem(Messages.getString("TimeSignal"), Cat.ROS_TIME); 444 addROItem(Messages.getString("AIS"), Cat.ROS_PAIS); 445 addROItem(Messages.getString("S-AIS"), Cat.ROS_SAIS); 446 addROItem(Messages.getString("V-AIS"), Cat.ROS_VAIS); 447 addROItem(Messages.getString("V-AISNC"), Cat.ROS_VANC); 448 addROItem(Messages.getString("V-AISSC"), Cat.ROS_VASC); 449 addROItem(Messages.getString("V-AISEC"), Cat.ROS_VAEC); 450 addROItem(Messages.getString("V-AISWC"), Cat.ROS_VAWC); 451 addROItem(Messages.getString("V-AISPL"), Cat.ROS_VAPL); 452 addROItem(Messages.getString("V-AISSL"), Cat.ROS_VASL); 453 addROItem(Messages.getString("V-AISID"), Cat.ROS_VAID); 454 addROItem(Messages.getString("V-AISSW"), Cat.ROS_VASW); 455 addROItem(Messages.getString("V-AISSP"), Cat.ROS_VASP); 456 addROItem(Messages.getString("V-AISWK"), Cat.ROS_VAWK); 457 radioCatBox.setVisible(false); 458 459 radarCatBox = new JComboBox<>(); 460 radarCatBox.setBounds(new Rectangle(5, 140, 160, 20)); 461 add(radarCatBox); 462 radarCatBox.addActionListener(alRadarCatBox); 463 addRAItem("", Cat.NOCAT); 464 addRAItem(Messages.getString("Surveillance"), Cat.RAS_SRV); 465 addRAItem(Messages.getString("CoastRadar"), Cat.RAS_CST); 466 radarCatBox.setVisible(false); 467 468 chLabel = new JLabel("Ch:", SwingConstants.CENTER); 469 chLabel.setBounds(new Rectangle(140, 32, 30, 15)); 470 add(chLabel); 471 chBox = new JTextField(); 472 chBox.setBounds(new Rectangle(140, 45, 30, 20)); 473 chBox.setHorizontalAlignment(SwingConstants.CENTER); 474 add(chBox); 475 chBox.addFocusListener(flCh); 476 } 477 478 public void syncPanel() { 479 functionLabel.setVisible(false); 480 functionBox.setVisible(false); 481 categoryLabel.setVisible(false); 482 landCatBox.setVisible(false); 483 trafficCatBox.setVisible(false); 484 warningCatBox.setVisible(false); 485 platformCatBox.setVisible(false); 486 pilotCatBox.setVisible(false); 487 rescueCatBox.setVisible(false); 488 radioCatBox.setVisible(false); 489 radarCatBox.setVisible(false); 490 chLabel.setVisible(false); 491 chBox.setVisible(false); 492 chBox.setText(SmedAction.panelMain.mark.getChannel()); 493 if ((SmedAction.panelMain.mark.getObject() == Obj.LNDMRK) && ((SmedAction.panelMain.mark.getCategory() != Cat.NOCAT) || (SmedAction.panelMain.mark.getFunc() != Fnc.UNKFNC))) { 494 functionLabel.setVisible(true); 495 categoryLabel.setVisible(true); 496 functionBox.setVisible(true); 497 landCatBox.setVisible(true); 498 for (Fnc fnc : functions.keySet()) { 499 int item = functions.get(fnc); 500 if (SmedAction.panelMain.mark.getFunc() == fnc) { 501 functionBox.setSelectedIndex(item); 502 } 503 } 504 for (Cat cat : landCats.keySet()) { 505 int item = landCats.get(cat); 506 if (SmedAction.panelMain.mark.getCategory() == cat) { 507 landCatBox.setSelectedIndex(item); 508 } 509 } 510 } else if (SmedAction.panelMain.mark.getObject() == Obj.SISTAT) { 511 categoryLabel.setVisible(true); 512 trafficCatBox.setVisible(true); 513 for (Cat cat : trafficCats.keySet()) { 514 int item = trafficCats.get(cat); 515 if (SmedAction.panelMain.mark.getCategory() == cat) { 516 trafficCatBox.setSelectedIndex(item); 517 } 518 } 519 chLabel.setVisible(true); 520 chBox.setVisible(true); 521 } else if (SmedAction.panelMain.mark.getObject() == Obj.SISTAW) { 522 categoryLabel.setVisible(true); 523 warningCatBox.setVisible(true); 524 for (Cat cat : warningCats.keySet()) { 525 int item = warningCats.get(cat); 526 if (SmedAction.panelMain.mark.getCategory() == cat) { 527 warningCatBox.setSelectedIndex(item); 528 } 529 } 530 chLabel.setVisible(true); 531 chBox.setVisible(true); 532 } else if (SmedAction.panelMain.mark.getObject() == Obj.OFSPLF) { 533 categoryLabel.setVisible(true); 534 platformCatBox.setVisible(true); 535 for (Cat cat : platformCats.keySet()) { 536 int item = platformCats.get(cat); 537 if (SmedAction.panelMain.mark.getCategory() == cat) { 538 platformCatBox.setSelectedIndex(item); 539 } 540 } 541 } else if (SmedAction.panelMain.mark.getObject() == Obj.PILBOP) { 542 categoryLabel.setVisible(true); 543 pilotCatBox.setVisible(true); 544 for (Cat cat : pilotCats.keySet()) { 545 int item = pilotCats.get(cat); 546 if (SmedAction.panelMain.mark.getCategory() == cat) { 547 pilotCatBox.setSelectedIndex(item); 548 } 549 } 550 chLabel.setVisible(true); 551 chBox.setVisible(true); 552 } else if (SmedAction.panelMain.mark.getObject() == Obj.RSCSTA) { 553 categoryLabel.setVisible(true); 554 rescueCatBox.setVisible(true); 555 for (Cat cat : rescueCats.keySet()) { 556 int item = rescueCats.get(cat); 557 if (SmedAction.panelMain.mark.getCategory() == cat) { 558 rescueCatBox.setSelectedIndex(item); 559 } 560 } 561 } else if (SmedAction.panelMain.mark.getObject() == Obj.RDOSTA) { 562 categoryLabel.setVisible(true); 563 radioCatBox.setVisible(true); 564 for (Cat cat : radioCats.keySet()) { 565 int item = radioCats.get(cat); 566 if (SmedAction.panelMain.mark.getCategory() == cat) { 567 radioCatBox.setSelectedIndex(item); 568 } 569 } 570 chLabel.setVisible(true); 571 chBox.setVisible(true); 572 } else if (SmedAction.panelMain.mark.getObject() == Obj.RADSTA) { 573 categoryLabel.setVisible(true); 574 radarCatBox.setVisible(true); 575 for (Cat cat : radarCats.keySet()) { 576 int item = radarCats.get(cat); 577 if (SmedAction.panelMain.mark.getCategory() == cat) { 578 radarCatBox.setSelectedIndex(item); 579 } 580 } 581 chLabel.setVisible(true); 582 chBox.setVisible(true); 583 } 584 for (Obj obj : objects.keySet()) { 585 JRadioButton button = objects.get(obj); 586 button.setBorderPainted(SmedAction.panelMain.mark.getObject() == obj); 587 } 588 SmedAction.panelMain.mark.testValid(); 589 } 590 591 private void addLCItem(String str, Cat cat) { 592 landCats.put(cat, landCatBox.getItemCount()); 593 landCatBox.addItem(str); 594 } 595 596 private void addTCItem(String str, Cat cat) { 597 trafficCats.put(cat, trafficCatBox.getItemCount()); 598 trafficCatBox.addItem(str); 599 } 600 601 private void addWCItem(String str, Cat cat) { 602 warningCats.put(cat, warningCatBox.getItemCount()); 603 warningCatBox.addItem(str); 604 } 605 606 private void addPLItem(String str, Cat cat) { 607 platformCats.put(cat, platformCatBox.getItemCount()); 608 platformCatBox.addItem(str); 609 } 610 611 private void addPTItem(String str, Cat cat) { 612 pilotCats.put(cat, pilotCatBox.getItemCount()); 613 pilotCatBox.addItem(str); 614 } 615 616 private void addRSItem(String str, Cat cat) { 617 rescueCats.put(cat, rescueCatBox.getItemCount()); 618 rescueCatBox.addItem(str); 619 } 620 621 private void addROItem(String str, Cat cat) { 622 radioCats.put(cat, radioCatBox.getItemCount()); 623 radioCatBox.addItem(str); 624 } 625 626 private void addRAItem(String str, Cat cat) { 627 radarCats.put(cat, radarCatBox.getItemCount()); 628 radarCatBox.addItem(str); 629 } 630 631 private void addLFItem(String str, Fnc fnc) { 632 functions.put(fnc, functionBox.getItemCount()); 633 functionBox.addItem(str); 634 } 635 636 private JRadioButton getObjButton(JRadioButton button, int x, int y, int w, int h, String tip, Obj obj) { 637 button.setBounds(new Rectangle(x, y, w, h)); 638 button.setBorder(BorderFactory.createLoweredBevelBorder()); 639 button.setToolTipText(Messages.getString(tip)); 640 button.addActionListener(alObj); 641 objButtons.add(button); 642 objects.put(obj, button); 643 return button; 644 } 608 645 609 646 } -
applications/editors/josm/plugins/smed/src/panels/PanelLit.java
r30738 r32767 1 1 package panels; 2 2 3 import javax.swing.*; 4 5 import java.awt.*; 6 import java.awt.event.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.awt.event.FocusAdapter; 7 import java.awt.event.FocusEvent; 8 import java.awt.event.FocusListener; 7 9 import java.util.EnumMap; 8 10 11 import javax.swing.BorderFactory; 12 import javax.swing.ButtonGroup; 13 import javax.swing.ImageIcon; 14 import javax.swing.JComboBox; 15 import javax.swing.JLabel; 16 import javax.swing.JPanel; 17 import javax.swing.JRadioButton; 18 import javax.swing.JTextField; 19 import javax.swing.SwingConstants; 20 9 21 import messages.Messages; 22 import seamarks.SeaMark.Att; 23 import seamarks.SeaMark.Ent; 24 import seamarks.SeaMark.Exh; 25 import seamarks.SeaMark.Lit; 26 import seamarks.SeaMark.Vis; 10 27 import smed.SmedAction; 11 import seamarks.SeaMark.*;12 28 13 29 public class PanelLit extends JPanel { 14 30 15 private SmedAction dlg; 16 public PanelSectors panelSector; 17 public PanelCol panelCol; 18 public PanelChr panelChr; 19 public JLabel groupLabel; 20 public JTextField groupBox; 21 private FocusListener flGroup = new FocusAdapter() { 22 public void focusLost(java.awt.event.FocusEvent e) { 23 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, groupBox.getText()); 24 } 25 }; 26 public JLabel periodLabel; 27 public JTextField periodBox; 28 private FocusListener flPeriod = new FocusAdapter() { 29 public void focusLost(java.awt.event.FocusEvent e) { 30 SmedAction.panelMain.mark.setLightAtt(Att.PER, 0, periodBox.getText()); 31 } 32 }; 33 public JLabel sequenceLabel; 34 public JTextField sequenceBox; 35 private FocusListener flSequence = new FocusAdapter() { 36 public void focusLost(java.awt.event.FocusEvent e) { 37 SmedAction.panelMain.mark.setLightAtt(Att.SEQ, 0, sequenceBox.getText()); 38 } 39 }; 40 public JLabel visibilityLabel; 41 public JComboBox<String> visibilityBox; 42 public EnumMap<Vis, Integer> visibilities = new EnumMap<>(Vis.class); 43 private ActionListener alVisibility = new ActionListener() { 44 public void actionPerformed(java.awt.event.ActionEvent e) { 45 for (Vis vis : visibilities.keySet()) { 46 int idx = visibilities.get(vis); 47 if (idx == visibilityBox.getSelectedIndex()) 48 SmedAction.panelMain.mark.setLightAtt(Att.VIS, 0, vis); 49 } 50 } 51 }; 52 public JLabel heightLabel; 53 public JTextField heightBox; 54 private FocusListener flHeight = new FocusAdapter() { 55 public void focusLost(java.awt.event.FocusEvent e) { 56 SmedAction.panelMain.mark.setLightAtt(Att.HGT, 0, heightBox.getText()); 57 } 58 }; 59 public JLabel rangeLabel; 60 public JTextField rangeBox; 61 private FocusListener flRange = new FocusAdapter() { 62 public void focusLost(java.awt.event.FocusEvent e) { 63 SmedAction.panelMain.mark.setLightAtt(Att.RNG, 0, rangeBox.getText()); 64 } 65 }; 66 public JLabel orientationLabel; 67 public JTextField orientationBox; 68 private FocusListener flOrientation = new FocusAdapter() { 69 public void focusLost(java.awt.event.FocusEvent e) { 70 SmedAction.panelMain.mark.setLightAtt(Att.ORT, 0, orientationBox.getText()); 71 } 72 }; 73 public JLabel multipleLabel; 74 public JTextField multipleBox; 75 private FocusListener flMultiple = new FocusAdapter() { 76 public void focusLost(java.awt.event.FocusEvent e) { 77 SmedAction.panelMain.mark.setLightAtt(Att.MLT, 0, multipleBox.getText()); 78 } 79 }; 80 public JLabel categoryLabel; 81 public JComboBox<String> categoryBox; 82 public EnumMap<Lit, Integer> categories = new EnumMap<>(Lit.class); 83 private ActionListener alCategory = new ActionListener() { 84 public void actionPerformed(java.awt.event.ActionEvent e) { 85 for (Lit lit : categories.keySet()) { 86 int idx = categories.get(lit); 87 if (idx == categoryBox.getSelectedIndex()) 88 SmedAction.panelMain.mark.setLightAtt(Att.LIT, 0, lit); 89 } 90 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.DIR) { 91 SmedAction.panelMain.mark.setLightAtt(Att.MLT, 0, ""); 92 multipleBox.setText(""); 93 orientationLabel.setVisible(true); 94 orientationBox.setVisible(true); 95 multipleLabel.setVisible(false); 96 multipleBox.setVisible(false); 97 } else if ((SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.VERT) || (SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.HORIZ)) { 98 SmedAction.panelMain.mark.setLightAtt(Att.ORT, 0, ""); 99 orientationBox.setText(""); 100 orientationLabel.setVisible(false); 101 orientationBox.setVisible(false); 102 multipleLabel.setVisible(true); 103 multipleBox.setVisible(true); 104 } else { 105 SmedAction.panelMain.mark.setLightAtt(Att.MLT, 0, ""); 106 multipleBox.setText(""); 107 SmedAction.panelMain.mark.setLightAtt(Att.ORT, 0, ""); 108 orientationBox.setText(""); 109 orientationLabel.setVisible(false); 110 orientationBox.setVisible(false); 111 multipleLabel.setVisible(false); 112 multipleBox.setVisible(false); 113 } 114 } 115 }; 116 public JLabel exhibitionLabel; 117 public JComboBox<String> exhibitionBox; 118 public EnumMap<Exh, Integer> exhibitions = new EnumMap<>(Exh.class); 119 private ActionListener alExhibition = new ActionListener() { 120 public void actionPerformed(java.awt.event.ActionEvent e) { 121 for (Exh exh : exhibitions.keySet()) { 122 int idx = exhibitions.get(exh); 123 if (idx == exhibitionBox.getSelectedIndex()) 124 SmedAction.panelMain.mark.setLightAtt(Att.EXH, 0, exh); 125 } 126 } 127 }; 128 private ButtonGroup typeButtons; 129 public JRadioButton singleButton; 130 public JRadioButton sectorButton; 131 private ActionListener alType = new ActionListener() { 132 public void actionPerformed(java.awt.event.ActionEvent e) { 133 singleButton.setBorderPainted(singleButton.isSelected()); 134 sectorButton.setBorderPainted(sectorButton.isSelected()); 135 if (sectorButton.isSelected()) { 136 panelSector.setVisible(true); 137 } else { 138 panelSector.setVisible(false); 139 while (SmedAction.panelMain.mark.getSectorCount() > 1) 140 SmedAction.panelMain.mark.delLight(1); 141 } 142 } 143 }; 144 145 public PanelLit(SmedAction dia) { 146 dlg = dia; 147 setLayout(null); 148 panelCol = new PanelCol(dlg, Ent.LIGHT); 149 panelCol.setBounds(new Rectangle(0, 0, 34, 160)); 150 panelChr = new PanelChr(dlg); 151 panelChr.setBounds(new Rectangle(34, 0, 88, 160)); 152 add(panelChr); 153 add(panelCol); 154 panelSector = new PanelSectors(dlg); 155 panelSector.setVisible(false); 156 157 typeButtons = new ButtonGroup(); 158 singleButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SingleButton.png"))); 159 add(getTypeButton(singleButton, 280, 125, 34, 30, "Single")); 160 sectorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SectorButton.png"))); 161 add(getTypeButton(sectorButton, 315, 125, 34, 30, "Sectored")); 162 163 groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER); 164 groupLabel.setBounds(new Rectangle(123, 0, 65, 20)); 165 add(groupLabel); 166 groupBox = new JTextField(); 167 groupBox.setBounds(new Rectangle(135, 20, 40, 20)); 168 groupBox.setHorizontalAlignment(SwingConstants.CENTER); 169 add(groupBox); 170 groupBox.addFocusListener(flGroup); 171 172 periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER); 173 periodLabel.setBounds(new Rectangle(123, 40, 65, 20)); 174 add(periodLabel); 175 periodBox = new JTextField(); 176 periodBox.setBounds(new Rectangle(135, 60, 40, 20)); 177 periodBox.setHorizontalAlignment(SwingConstants.CENTER); 178 add(periodBox); 179 periodBox.addFocusListener(flPeriod); 180 181 heightLabel = new JLabel(Messages.getString("Height"), SwingConstants.CENTER); 182 heightLabel.setBounds(new Rectangle(123, 80, 65, 20)); 183 add(heightLabel); 184 heightBox = new JTextField(); 185 heightBox.setBounds(new Rectangle(135, 100, 40, 20)); 186 heightBox.setHorizontalAlignment(SwingConstants.CENTER); 187 add(heightBox); 188 heightBox.addFocusListener(flHeight); 189 190 rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER); 191 rangeLabel.setBounds(new Rectangle(123, 120, 65, 20)); 192 add(rangeLabel); 193 rangeBox = new JTextField(); 194 rangeBox.setBounds(new Rectangle(135, 140, 40, 20)); 195 rangeBox.setHorizontalAlignment(SwingConstants.CENTER); 196 add(rangeBox); 197 rangeBox.addFocusListener(flRange); 198 199 sequenceLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER); 200 sequenceLabel.setBounds(new Rectangle(188, 120, 80, 20)); 201 add(sequenceLabel); 202 sequenceBox = new JTextField(); 203 sequenceBox.setBounds(new Rectangle(183, 140, 90, 20)); 204 sequenceBox.setHorizontalAlignment(SwingConstants.CENTER); 205 add(sequenceBox); 206 sequenceBox.addFocusListener(flSequence); 207 208 categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER); 209 categoryLabel.setBounds(new Rectangle(185, 0, 165, 20)); 210 add(categoryLabel); 211 categoryBox = new JComboBox<>(); 212 categoryBox.setBounds(new Rectangle(185, 20, 165, 20)); 213 add(categoryBox); 214 addCatItem("", Lit.UNKLIT); 215 addCatItem(Messages.getString("VertDisp"), Lit.VERT); 216 addCatItem(Messages.getString("HorizDisp"), Lit.HORIZ); 217 addCatItem(Messages.getString("Directional"), Lit.DIR); 218 addCatItem(Messages.getString("Upper"), Lit.UPPER); 219 addCatItem(Messages.getString("Lower"), Lit.LOWER); 220 addCatItem(Messages.getString("Rear"), Lit.REAR); 221 addCatItem(Messages.getString("Front"), Lit.FRONT); 222 addCatItem(Messages.getString("Aero"), Lit.AERO); 223 addCatItem(Messages.getString("AirObstruction"), Lit.AIROBS); 224 addCatItem(Messages.getString("FogDetector"), Lit.FOGDET); 225 addCatItem(Messages.getString("Floodlight"), Lit.FLOOD); 226 addCatItem(Messages.getString("Striplight"), Lit.STRIP); 227 addCatItem(Messages.getString("Subsidiary"), Lit.SUBS); 228 addCatItem(Messages.getString("Spotlight"), Lit.SPOT); 229 addCatItem(Messages.getString("MoireEffect"), Lit.MOIRE); 230 addCatItem(Messages.getString("Emergency"), Lit.EMERG); 231 addCatItem(Messages.getString("Bearing"), Lit.BEAR); 232 categoryBox.addActionListener(alCategory); 233 234 visibilityLabel = new JLabel(Messages.getString("Visibility"), SwingConstants.CENTER); 235 visibilityLabel.setBounds(new Rectangle(185, 40, 165, 20)); 236 add(visibilityLabel); 237 visibilityBox = new JComboBox<>(); 238 visibilityBox.setBounds(new Rectangle(185, 60, 165, 20)); 239 add(visibilityBox); 240 addVisibItem("", Vis.UNKVIS); 241 addVisibItem(Messages.getString("Intensified"), Vis.INTEN); 242 addVisibItem(Messages.getString("Unintensified"), Vis.UNINTEN); 243 addVisibItem(Messages.getString("PartiallyObscured"), Vis.PARTOBS); 244 visibilityBox.addActionListener(alVisibility); 245 246 exhibitionLabel = new JLabel(Messages.getString("Exhibition"), SwingConstants.CENTER); 247 exhibitionLabel.setBounds(new Rectangle(280, 80, 70, 20)); 248 add(exhibitionLabel); 249 exhibitionBox = new JComboBox<>(); 250 exhibitionBox.setBounds(new Rectangle(280, 100, 70, 20)); 251 add(exhibitionBox); 252 addExhibItem("", Exh.UNKEXH); 253 addExhibItem(Messages.getString("24h"), Exh.H24); 254 addExhibItem(Messages.getString("Day"), Exh.DAY); 255 addExhibItem(Messages.getString("Night"), Exh.NIGHT); 256 addExhibItem(Messages.getString("Fog"), Exh.FOG); 257 exhibitionBox.addActionListener(alExhibition); 258 259 orientationLabel = new JLabel(Messages.getString("Orientation"), SwingConstants.CENTER); 260 orientationLabel.setBounds(new Rectangle(188, 80, 80, 20)); 261 orientationLabel.setVisible(false); 262 add(orientationLabel); 263 orientationBox = new JTextField(); 264 orientationBox.setBounds(new Rectangle(208, 100, 40, 20)); 265 orientationBox.setHorizontalAlignment(SwingConstants.CENTER); 266 orientationBox.setVisible(false); 267 add(orientationBox); 268 orientationBox.addFocusListener(flOrientation); 269 270 multipleLabel = new JLabel(Messages.getString("Multiplicity"), SwingConstants.CENTER); 271 multipleLabel.setBounds(new Rectangle(188, 80, 80, 20)); 272 multipleLabel.setVisible(false); 273 add(multipleLabel); 274 multipleBox = new JTextField(); 275 multipleBox.setBounds(new Rectangle(208, 100, 40, 20)); 276 multipleBox.setHorizontalAlignment(SwingConstants.CENTER); 277 multipleBox.setVisible(false); 278 add(multipleBox); 279 multipleBox.addFocusListener(flMultiple); 280 } 281 282 public void syncPanel() { 283 orientationLabel.setVisible(false); 284 orientationBox.setVisible(false); 285 multipleLabel.setVisible(false); 286 multipleBox.setVisible(false); 287 groupBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.GRP, 0)); 288 periodBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.PER, 0)); 289 sequenceBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.SEQ, 0)); 290 heightBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.HGT, 0)); 291 rangeBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.RNG, 0)); 292 orientationBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.ORT, 0)); 293 orientationBox.setVisible(SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.DIR); 294 multipleBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.MLT, 0)); 295 multipleBox.setVisible((SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.VERT) || (SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.HORIZ)); 296 for (Vis vis : visibilities.keySet()) { 297 int item = visibilities.get(vis); 298 if (SmedAction.panelMain.mark.getLightAtt(Att.VIS, 0) == vis) 299 visibilityBox.setSelectedIndex(item); 300 } 301 for (Lit lit : categories.keySet()) { 302 int item = categories.get(lit); 303 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == lit) 304 categoryBox.setSelectedIndex(item); 305 } 306 for (Exh exh : exhibitions.keySet()) { 307 int item = exhibitions.get(exh); 308 if (SmedAction.panelMain.mark.getLightAtt(Att.EXH, 0) == exh) 309 exhibitionBox.setSelectedIndex(item); 310 } 311 if (SmedAction.panelMain.mark.isSectored()) { 312 singleButton.setBorderPainted(false); 313 sectorButton.setBorderPainted(true); 314 if (isVisible()) panelSector.setVisible(true); 315 } else { 316 singleButton.setBorderPainted(true); 317 sectorButton.setBorderPainted(false); 318 panelSector.setVisible(false); 319 while (SmedAction.panelMain.mark.getSectorCount() > 1) 320 SmedAction.panelMain.mark.delLight(SmedAction.panelMain.mark.getSectorCount() - 1); 321 } 322 panelCol.syncPanel(); 323 panelChr.syncPanel(); 324 panelSector.syncPanel(); 325 } 326 327 private void addCatItem(String str, Lit lit) { 328 categories.put(lit, categoryBox.getItemCount()); 329 categoryBox.addItem(str); 330 } 331 332 private void addVisibItem(String str, Vis vis) { 333 visibilities.put(vis, visibilityBox.getItemCount()); 334 visibilityBox.addItem(str); 335 } 336 337 private void addExhibItem(String str, Exh exh) { 338 exhibitions.put(exh, exhibitionBox.getItemCount()); 339 exhibitionBox.addItem(str); 340 } 341 342 private JRadioButton getTypeButton(JRadioButton button, int x, int y, int w, int h, String tip) { 343 button.setBounds(new Rectangle(x, y, w, h)); 344 button.setBorder(BorderFactory.createLoweredBevelBorder()); 345 button.setToolTipText(Messages.getString(tip)); 346 button.addActionListener(alType); 347 typeButtons.add(button); 348 return button; 349 } 31 private SmedAction dlg; 32 public PanelSectors panelSector; 33 public PanelCol panelCol; 34 public PanelChr panelChr; 35 public JLabel groupLabel; 36 public JTextField groupBox; 37 private FocusListener flGroup = new FocusAdapter() { 38 @Override 39 public void focusLost(FocusEvent e) { 40 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, groupBox.getText()); 41 } 42 }; 43 public JLabel periodLabel; 44 public JTextField periodBox; 45 private FocusListener flPeriod = new FocusAdapter() { 46 @Override 47 public void focusLost(FocusEvent e) { 48 SmedAction.panelMain.mark.setLightAtt(Att.PER, 0, periodBox.getText()); 49 } 50 }; 51 public JLabel sequenceLabel; 52 public JTextField sequenceBox; 53 private FocusListener flSequence = new FocusAdapter() { 54 @Override 55 public void focusLost(FocusEvent e) { 56 SmedAction.panelMain.mark.setLightAtt(Att.SEQ, 0, sequenceBox.getText()); 57 } 58 }; 59 public JLabel visibilityLabel; 60 public JComboBox<String> visibilityBox; 61 public EnumMap<Vis, Integer> visibilities = new EnumMap<>(Vis.class); 62 private ActionListener alVisibility = new ActionListener() { 63 @Override 64 public void actionPerformed(ActionEvent e) { 65 for (Vis vis : visibilities.keySet()) { 66 int idx = visibilities.get(vis); 67 if (idx == visibilityBox.getSelectedIndex()) { 68 SmedAction.panelMain.mark.setLightAtt(Att.VIS, 0, vis); 69 } 70 } 71 } 72 }; 73 public JLabel heightLabel; 74 public JTextField heightBox; 75 private FocusListener flHeight = new FocusAdapter() { 76 @Override 77 public void focusLost(FocusEvent e) { 78 SmedAction.panelMain.mark.setLightAtt(Att.HGT, 0, heightBox.getText()); 79 } 80 }; 81 public JLabel rangeLabel; 82 public JTextField rangeBox; 83 private FocusListener flRange = new FocusAdapter() { 84 @Override 85 public void focusLost(FocusEvent e) { 86 SmedAction.panelMain.mark.setLightAtt(Att.RNG, 0, rangeBox.getText()); 87 } 88 }; 89 public JLabel orientationLabel; 90 public JTextField orientationBox; 91 private FocusListener flOrientation = new FocusAdapter() { 92 @Override 93 public void focusLost(FocusEvent e) { 94 SmedAction.panelMain.mark.setLightAtt(Att.ORT, 0, orientationBox.getText()); 95 } 96 }; 97 public JLabel multipleLabel; 98 public JTextField multipleBox; 99 private FocusListener flMultiple = new FocusAdapter() { 100 @Override 101 public void focusLost(FocusEvent e) { 102 SmedAction.panelMain.mark.setLightAtt(Att.MLT, 0, multipleBox.getText()); 103 } 104 }; 105 public JLabel categoryLabel; 106 public JComboBox<String> categoryBox; 107 public EnumMap<Lit, Integer> categories = new EnumMap<>(Lit.class); 108 private ActionListener alCategory = new ActionListener() { 109 @Override 110 public void actionPerformed(ActionEvent e) { 111 for (Lit lit : categories.keySet()) { 112 int idx = categories.get(lit); 113 if (idx == categoryBox.getSelectedIndex()) { 114 SmedAction.panelMain.mark.setLightAtt(Att.LIT, 0, lit); 115 } 116 } 117 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.DIR) { 118 SmedAction.panelMain.mark.setLightAtt(Att.MLT, 0, ""); 119 multipleBox.setText(""); 120 orientationLabel.setVisible(true); 121 orientationBox.setVisible(true); 122 multipleLabel.setVisible(false); 123 multipleBox.setVisible(false); 124 } else if ((SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.VERT) || (SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.HORIZ)) { 125 SmedAction.panelMain.mark.setLightAtt(Att.ORT, 0, ""); 126 orientationBox.setText(""); 127 orientationLabel.setVisible(false); 128 orientationBox.setVisible(false); 129 multipleLabel.setVisible(true); 130 multipleBox.setVisible(true); 131 } else { 132 SmedAction.panelMain.mark.setLightAtt(Att.MLT, 0, ""); 133 multipleBox.setText(""); 134 SmedAction.panelMain.mark.setLightAtt(Att.ORT, 0, ""); 135 orientationBox.setText(""); 136 orientationLabel.setVisible(false); 137 orientationBox.setVisible(false); 138 multipleLabel.setVisible(false); 139 multipleBox.setVisible(false); 140 } 141 } 142 }; 143 public JLabel exhibitionLabel; 144 public JComboBox<String> exhibitionBox; 145 public EnumMap<Exh, Integer> exhibitions = new EnumMap<>(Exh.class); 146 private ActionListener alExhibition = new ActionListener() { 147 @Override 148 public void actionPerformed(ActionEvent e) { 149 for (Exh exh : exhibitions.keySet()) { 150 int idx = exhibitions.get(exh); 151 if (idx == exhibitionBox.getSelectedIndex()) { 152 SmedAction.panelMain.mark.setLightAtt(Att.EXH, 0, exh); 153 } 154 } 155 } 156 }; 157 private ButtonGroup typeButtons; 158 public JRadioButton singleButton; 159 public JRadioButton sectorButton; 160 private ActionListener alType = new ActionListener() { 161 @Override 162 public void actionPerformed(ActionEvent e) { 163 singleButton.setBorderPainted(singleButton.isSelected()); 164 sectorButton.setBorderPainted(sectorButton.isSelected()); 165 if (sectorButton.isSelected()) { 166 panelSector.setVisible(true); 167 } else { 168 panelSector.setVisible(false); 169 while (SmedAction.panelMain.mark.getSectorCount() > 1) { 170 SmedAction.panelMain.mark.delLight(1); 171 } 172 } 173 } 174 }; 175 176 public PanelLit(SmedAction dia) { 177 dlg = dia; 178 setLayout(null); 179 panelCol = new PanelCol(dlg, Ent.LIGHT); 180 panelCol.setBounds(new Rectangle(0, 0, 34, 160)); 181 panelChr = new PanelChr(dlg); 182 panelChr.setBounds(new Rectangle(34, 0, 88, 160)); 183 add(panelChr); 184 add(panelCol); 185 panelSector = new PanelSectors(dlg); 186 panelSector.setVisible(false); 187 188 typeButtons = new ButtonGroup(); 189 singleButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SingleButton.png"))); 190 add(getTypeButton(singleButton, 280, 125, 34, 30, "Single")); 191 sectorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SectorButton.png"))); 192 add(getTypeButton(sectorButton, 315, 125, 34, 30, "Sectored")); 193 194 groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER); 195 groupLabel.setBounds(new Rectangle(123, 0, 65, 20)); 196 add(groupLabel); 197 groupBox = new JTextField(); 198 groupBox.setBounds(new Rectangle(135, 20, 40, 20)); 199 groupBox.setHorizontalAlignment(SwingConstants.CENTER); 200 add(groupBox); 201 groupBox.addFocusListener(flGroup); 202 203 periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER); 204 periodLabel.setBounds(new Rectangle(123, 40, 65, 20)); 205 add(periodLabel); 206 periodBox = new JTextField(); 207 periodBox.setBounds(new Rectangle(135, 60, 40, 20)); 208 periodBox.setHorizontalAlignment(SwingConstants.CENTER); 209 add(periodBox); 210 periodBox.addFocusListener(flPeriod); 211 212 heightLabel = new JLabel(Messages.getString("Height"), SwingConstants.CENTER); 213 heightLabel.setBounds(new Rectangle(123, 80, 65, 20)); 214 add(heightLabel); 215 heightBox = new JTextField(); 216 heightBox.setBounds(new Rectangle(135, 100, 40, 20)); 217 heightBox.setHorizontalAlignment(SwingConstants.CENTER); 218 add(heightBox); 219 heightBox.addFocusListener(flHeight); 220 221 rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER); 222 rangeLabel.setBounds(new Rectangle(123, 120, 65, 20)); 223 add(rangeLabel); 224 rangeBox = new JTextField(); 225 rangeBox.setBounds(new Rectangle(135, 140, 40, 20)); 226 rangeBox.setHorizontalAlignment(SwingConstants.CENTER); 227 add(rangeBox); 228 rangeBox.addFocusListener(flRange); 229 230 sequenceLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER); 231 sequenceLabel.setBounds(new Rectangle(188, 120, 80, 20)); 232 add(sequenceLabel); 233 sequenceBox = new JTextField(); 234 sequenceBox.setBounds(new Rectangle(183, 140, 90, 20)); 235 sequenceBox.setHorizontalAlignment(SwingConstants.CENTER); 236 add(sequenceBox); 237 sequenceBox.addFocusListener(flSequence); 238 239 categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER); 240 categoryLabel.setBounds(new Rectangle(185, 0, 165, 20)); 241 add(categoryLabel); 242 categoryBox = new JComboBox<>(); 243 categoryBox.setBounds(new Rectangle(185, 20, 165, 20)); 244 add(categoryBox); 245 addCatItem("", Lit.UNKLIT); 246 addCatItem(Messages.getString("VertDisp"), Lit.VERT); 247 addCatItem(Messages.getString("HorizDisp"), Lit.HORIZ); 248 addCatItem(Messages.getString("Directional"), Lit.DIR); 249 addCatItem(Messages.getString("Upper"), Lit.UPPER); 250 addCatItem(Messages.getString("Lower"), Lit.LOWER); 251 addCatItem(Messages.getString("Rear"), Lit.REAR); 252 addCatItem(Messages.getString("Front"), Lit.FRONT); 253 addCatItem(Messages.getString("Aero"), Lit.AERO); 254 addCatItem(Messages.getString("AirObstruction"), Lit.AIROBS); 255 addCatItem(Messages.getString("FogDetector"), Lit.FOGDET); 256 addCatItem(Messages.getString("Floodlight"), Lit.FLOOD); 257 addCatItem(Messages.getString("Striplight"), Lit.STRIP); 258 addCatItem(Messages.getString("Subsidiary"), Lit.SUBS); 259 addCatItem(Messages.getString("Spotlight"), Lit.SPOT); 260 addCatItem(Messages.getString("MoireEffect"), Lit.MOIRE); 261 addCatItem(Messages.getString("Emergency"), Lit.EMERG); 262 addCatItem(Messages.getString("Bearing"), Lit.BEAR); 263 categoryBox.addActionListener(alCategory); 264 265 visibilityLabel = new JLabel(Messages.getString("Visibility"), SwingConstants.CENTER); 266 visibilityLabel.setBounds(new Rectangle(185, 40, 165, 20)); 267 add(visibilityLabel); 268 visibilityBox = new JComboBox<>(); 269 visibilityBox.setBounds(new Rectangle(185, 60, 165, 20)); 270 add(visibilityBox); 271 addVisibItem("", Vis.UNKVIS); 272 addVisibItem(Messages.getString("Intensified"), Vis.INTEN); 273 addVisibItem(Messages.getString("Unintensified"), Vis.UNINTEN); 274 addVisibItem(Messages.getString("PartiallyObscured"), Vis.PARTOBS); 275 visibilityBox.addActionListener(alVisibility); 276 277 exhibitionLabel = new JLabel(Messages.getString("Exhibition"), SwingConstants.CENTER); 278 exhibitionLabel.setBounds(new Rectangle(280, 80, 70, 20)); 279 add(exhibitionLabel); 280 exhibitionBox = new JComboBox<>(); 281 exhibitionBox.setBounds(new Rectangle(280, 100, 70, 20)); 282 add(exhibitionBox); 283 addExhibItem("", Exh.UNKEXH); 284 addExhibItem(Messages.getString("24h"), Exh.H24); 285 addExhibItem(Messages.getString("Day"), Exh.DAY); 286 addExhibItem(Messages.getString("Night"), Exh.NIGHT); 287 addExhibItem(Messages.getString("Fog"), Exh.FOG); 288 exhibitionBox.addActionListener(alExhibition); 289 290 orientationLabel = new JLabel(Messages.getString("Orientation"), SwingConstants.CENTER); 291 orientationLabel.setBounds(new Rectangle(188, 80, 80, 20)); 292 orientationLabel.setVisible(false); 293 add(orientationLabel); 294 orientationBox = new JTextField(); 295 orientationBox.setBounds(new Rectangle(208, 100, 40, 20)); 296 orientationBox.setHorizontalAlignment(SwingConstants.CENTER); 297 orientationBox.setVisible(false); 298 add(orientationBox); 299 orientationBox.addFocusListener(flOrientation); 300 301 multipleLabel = new JLabel(Messages.getString("Multiplicity"), SwingConstants.CENTER); 302 multipleLabel.setBounds(new Rectangle(188, 80, 80, 20)); 303 multipleLabel.setVisible(false); 304 add(multipleLabel); 305 multipleBox = new JTextField(); 306 multipleBox.setBounds(new Rectangle(208, 100, 40, 20)); 307 multipleBox.setHorizontalAlignment(SwingConstants.CENTER); 308 multipleBox.setVisible(false); 309 add(multipleBox); 310 multipleBox.addFocusListener(flMultiple); 311 } 312 313 public void syncPanel() { 314 orientationLabel.setVisible(false); 315 orientationBox.setVisible(false); 316 multipleLabel.setVisible(false); 317 multipleBox.setVisible(false); 318 groupBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.GRP, 0)); 319 periodBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.PER, 0)); 320 sequenceBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.SEQ, 0)); 321 heightBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.HGT, 0)); 322 rangeBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.RNG, 0)); 323 orientationBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.ORT, 0)); 324 orientationBox.setVisible(SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.DIR); 325 multipleBox.setText((String)SmedAction.panelMain.mark.getLightAtt(Att.MLT, 0)); 326 multipleBox.setVisible((SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.VERT) || (SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == Lit.HORIZ)); 327 for (Vis vis : visibilities.keySet()) { 328 int item = visibilities.get(vis); 329 if (SmedAction.panelMain.mark.getLightAtt(Att.VIS, 0) == vis) { 330 visibilityBox.setSelectedIndex(item); 331 } 332 } 333 for (Lit lit : categories.keySet()) { 334 int item = categories.get(lit); 335 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, 0) == lit) { 336 categoryBox.setSelectedIndex(item); 337 } 338 } 339 for (Exh exh : exhibitions.keySet()) { 340 int item = exhibitions.get(exh); 341 if (SmedAction.panelMain.mark.getLightAtt(Att.EXH, 0) == exh) { 342 exhibitionBox.setSelectedIndex(item); 343 } 344 } 345 if (SmedAction.panelMain.mark.isSectored()) { 346 singleButton.setBorderPainted(false); 347 sectorButton.setBorderPainted(true); 348 if (isVisible()) { 349 panelSector.setVisible(true); 350 } 351 } else { 352 singleButton.setBorderPainted(true); 353 sectorButton.setBorderPainted(false); 354 panelSector.setVisible(false); 355 while (SmedAction.panelMain.mark.getSectorCount() > 1) { 356 SmedAction.panelMain.mark.delLight(SmedAction.panelMain.mark.getSectorCount() - 1); 357 } 358 } 359 panelCol.syncPanel(); 360 panelChr.syncPanel(); 361 panelSector.syncPanel(); 362 } 363 364 private void addCatItem(String str, Lit lit) { 365 categories.put(lit, categoryBox.getItemCount()); 366 categoryBox.addItem(str); 367 } 368 369 private void addVisibItem(String str, Vis vis) { 370 visibilities.put(vis, visibilityBox.getItemCount()); 371 visibilityBox.addItem(str); 372 } 373 374 private void addExhibItem(String str, Exh exh) { 375 exhibitions.put(exh, exhibitionBox.getItemCount()); 376 exhibitionBox.addItem(str); 377 } 378 379 private JRadioButton getTypeButton(JRadioButton button, int x, int y, int w, int h, String tip) { 380 button.setBounds(new Rectangle(x, y, w, h)); 381 button.setBorder(BorderFactory.createLoweredBevelBorder()); 382 button.setToolTipText(Messages.getString(tip)); 383 button.addActionListener(alType); 384 typeButtons.add(button); 385 return button; 386 } 350 387 351 388 } -
applications/editors/josm/plugins/smed/src/panels/PanelMain.java
r30295 r32767 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.*; 6 import java.awt.event.*; 7 import javax.swing.*; 5 import java.awt.Color; 6 import java.awt.Insets; 7 import java.awt.Rectangle; 8 import java.awt.event.ActionEvent; 9 import java.awt.event.ActionListener; 10 import java.awt.event.FocusEvent; 11 import java.awt.event.FocusListener; 12 13 import javax.swing.BorderFactory; 14 import javax.swing.ButtonGroup; 15 import javax.swing.ImageIcon; 16 import javax.swing.JButton; 17 import javax.swing.JLabel; 18 import javax.swing.JPanel; 19 import javax.swing.JRadioButton; 20 import javax.swing.JTextField; 21 import javax.swing.SwingConstants; 8 22 9 23 import messages.Messages; 24 import seamarks.SeaMark; 10 25 import smed.SmedAction; 11 import seamarks.SeaMark;12 26 13 27 public class PanelMain extends JPanel { 14 28 15 private SmedAction dlg; 16 public SeaMark mark = null; 17 public PanelChan panelChan = null; 18 public PanelHaz panelHaz = null; 19 public PanelSpec panelSpec = null; 20 public PanelLights panelLights = null; 21 public PanelMore panelMore = null; 22 public PanelTop panelTop = null; 23 public PanelFog panelFog = null; 24 public PanelRadar panelRadar = null; 25 public PanelLit panelLit = null; 26 public JLabel nameLabel = null; 27 public JTextField nameBox = null; 28 public static JTextField messageBar = null; 29 private FocusListener flName = new FocusListener() { 30 public void focusLost(java.awt.event.FocusEvent e) { 31 mark.setName(nameBox.getText()); 32 } 33 public void focusGained(java.awt.event.FocusEvent e) { 34 } 35 }; 36 public JButton saveButton = null; 37 private ActionListener alSave = new ActionListener() { 38 public void actionPerformed(java.awt.event.ActionEvent e) { 39 mark.saveSign(dlg.node); 40 } 41 }; 42 public JButton moreButton = null; 43 private ActionListener alMore = new ActionListener() { 44 public void actionPerformed(java.awt.event.ActionEvent e) { 45 if (panelMore.isVisible()) { 46 moreButton.setText(">>"); 47 panelMore.setVisible(false); 48 topButton.setEnabled(true); 49 radButton.setEnabled(true); 50 fogButton.setEnabled(true); 51 litButton.setEnabled(true); 52 } else { 53 panelMore.setVisible(true); 54 moreButton.setText("<<"); 55 miscButtons.clearSelection(); 56 panelTop.setVisible(false); 57 topButton.setBorderPainted(false); 58 topButton.setEnabled(false); 59 panelRadar.setVisible(false); 60 radButton.setBorderPainted(false); 61 radButton.setEnabled(false); 62 panelFog.setVisible(false); 63 fogButton.setBorderPainted(false); 64 fogButton.setEnabled(false); 65 panelLit.setVisible(false); 66 litButton.setBorderPainted(false); 67 litButton.setEnabled(false); 68 } 69 } 70 }; 71 public ButtonGroup typeButtons = null; 72 public JRadioButton chanButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ChanButton.png"))); 73 public JRadioButton hazButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/HazButton.png"))); 74 public JRadioButton specButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SpecButton.png"))); 75 public JRadioButton lightsButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightsButton.png"))); 76 private ActionListener alType = new ActionListener() { 77 public void actionPerformed(java.awt.event.ActionEvent e) { 78 if (chanButton.isSelected()) { 79 chanButton.setBorderPainted(true); 80 panelChan.syncPanel(); 81 panelChan.setVisible(true); 82 } else { 83 chanButton.setBorderPainted(false); 84 panelChan.setVisible(false); 85 } 86 if (hazButton.isSelected()) { 87 hazButton.setBorderPainted(true); 88 panelHaz.syncPanel(); 89 panelHaz.setVisible(true); 90 } else { 91 hazButton.setBorderPainted(false); 92 panelHaz.setVisible(false); 93 } 94 if (specButton.isSelected()) { 95 specButton.setBorderPainted(true); 96 panelSpec.syncPanel(); 97 panelSpec.setVisible(true); 98 } else { 99 specButton.setBorderPainted(false); 100 panelSpec.setVisible(false); 101 } 102 if (lightsButton.isSelected()) { 103 lightsButton.setBorderPainted(true); 104 panelLights.syncPanel(); 105 panelLights.setVisible(true); 106 } else { 107 lightsButton.setBorderPainted(false); 108 panelLights.setVisible(false); 109 } 110 } 111 }; 112 private ButtonGroup miscButtons = null; 113 public JRadioButton topButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TopButton.png"))); 114 public JRadioButton fogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogButton.png"))); 115 public JRadioButton radButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarButton.png"))); 116 public JRadioButton litButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LitButton.png"))); 117 private ActionListener alMisc = new ActionListener() { 118 public void actionPerformed(java.awt.event.ActionEvent e) { 119 if (topButton.isSelected()) { 120 moreButton.setText(">>"); 121 panelMore.setVisible(false); 122 topButton.setBorderPainted(true); 123 panelTop.setVisible(true); 124 panelTop.syncPanel(); 125 } else { 126 topButton.setBorderPainted(false); 127 panelTop.setVisible(false); 128 } 129 if (fogButton.isSelected()) { 130 moreButton.setText(">>"); 131 panelMore.setVisible(false); 132 fogButton.setBorderPainted(true); 133 panelFog.setVisible(true); 134 panelFog.syncPanel(); 135 } else { 136 fogButton.setBorderPainted(false); 137 panelFog.setVisible(false); 138 } 139 if (radButton.isSelected()) { 140 moreButton.setText(">>"); 141 panelMore.setVisible(false); 142 radButton.setBorderPainted(true); 143 panelRadar.setVisible(true); 144 panelRadar.syncPanel(); 145 } else { 146 radButton.setBorderPainted(false); 147 panelRadar.setVisible(false); 148 } 149 if (litButton.isSelected()) { 150 moreButton.setText(">>"); 151 panelMore.setVisible(false); 152 litButton.setBorderPainted(true); 153 panelLit.setVisible(true); 154 panelLit.syncPanel(); 155 } else { 156 litButton.setBorderPainted(false); 157 panelLit.setVisible(false); 158 } 159 } 160 }; 161 162 public PanelMain(SmedAction dia) { 163 164 dlg = dia; 165 setLayout(null); 166 mark = new SeaMark(dlg); 167 mark.setBounds(new Rectangle(235, 0, 165, 160)); 168 add(mark); 169 panelChan = new PanelChan(dlg); 170 panelChan.setBounds(new Rectangle(65, 0, 170, 160)); 171 panelChan.setVisible(false); 172 add(panelChan); 173 panelHaz = new PanelHaz(dlg); 174 panelHaz.setBounds(new Rectangle(65, 0, 170, 160)); 175 panelHaz.setVisible(false); 176 add(panelHaz); 177 panelSpec = new PanelSpec(dlg); 178 panelSpec.setBounds(new Rectangle(65, 0, 170, 160)); 179 panelSpec.setVisible(false); 180 add(panelSpec); 181 panelLights = new PanelLights(dlg); 182 panelLights.setBounds(new Rectangle(65, 0, 170, 160)); 183 panelLights.setVisible(false); 184 add(panelLights); 185 panelMore = new PanelMore(dlg); 186 panelMore.setBounds(new Rectangle(40, 165, 360, 160)); 187 panelMore.setVisible(false); 188 add(panelMore); 189 panelTop = new PanelTop(dlg); 190 panelTop.setBounds(new Rectangle(40, 165, 360, 160)); 191 panelTop.setVisible(false); 192 add(panelTop); 193 panelFog = new PanelFog(dlg); 194 panelFog.setBounds(new Rectangle(40, 165, 360, 160)); 195 panelFog.setVisible(false); 196 add(panelFog); 197 panelRadar = new PanelRadar(dlg); 198 panelRadar.setBounds(new Rectangle(40, 165, 360, 160)); 199 panelRadar.setVisible(false); 200 add(panelRadar); 201 panelLit = new PanelLit(dlg); 202 panelLit.setBounds(new Rectangle(40, 165, 360, 160)); 203 panelLit.setVisible(false); 204 add(panelLit); 205 206 add(getButton(chanButton, 0, 0, 62, 40, "Chan"), null); 207 add(getButton(hazButton, 0, 40, 62, 40, "Haz"), null); 208 add(getButton(specButton, 0, 80, 62, 40, "Spec"), null); 209 add(getButton(lightsButton, 0, 120, 62, 40, "Lights"), null); 210 typeButtons = new ButtonGroup(); 211 typeButtons.add(chanButton); 212 typeButtons.add(hazButton); 213 typeButtons.add(specButton); 214 typeButtons.add(lightsButton); 215 chanButton.addActionListener(alType); 216 hazButton.addActionListener(alType); 217 specButton.addActionListener(alType); 218 lightsButton.addActionListener(alType); 219 220 add(getButton(topButton, 0, 185, 34, 32, "Topmarks")); 221 add(getButton(fogButton, 0, 220, 34, 32, "FogSignals")); 222 add(getButton(radButton, 0, 255, 34, 32, "Radar")); 223 add(getButton(litButton, 0, 290, 34, 32, "Lit")); 224 miscButtons = new ButtonGroup(); 225 miscButtons.add(topButton); 226 miscButtons.add(fogButton); 227 miscButtons.add(radButton); 228 miscButtons.add(litButton); 229 topButton.addActionListener(alMisc); 230 fogButton.addActionListener(alMisc); 231 radButton.addActionListener(alMisc); 232 litButton.addActionListener(alMisc); 233 234 nameLabel = new JLabel(); 235 nameLabel.setBounds(new Rectangle(5, 329, 60, 20)); 236 nameLabel.setText(tr("Name:")); 237 add(nameLabel); 238 nameBox = new JTextField(); 239 nameBox.setBounds(new Rectangle(60, 330, 200, 20)); 240 nameBox.setHorizontalAlignment(SwingConstants.CENTER); 241 add(nameBox); 242 nameBox.addFocusListener(flName); 243 244 saveButton = new JButton(); 245 saveButton.setBounds(new Rectangle(285, 330, 100, 20)); 246 saveButton.setText(tr("Save")); 247 add(saveButton); 248 saveButton.addActionListener(alSave); 249 250 moreButton = new JButton(); 251 moreButton.setBounds(new Rectangle(0, 165, 34, 15)); 252 moreButton.setMargin(new Insets(0, 0, 0, 0)); 253 moreButton.setText(">>"); 254 add(moreButton); 255 moreButton.addActionListener(alMore); 256 257 messageBar = new JTextField(); 258 messageBar.setBounds(10, 355, 380, 20); 259 messageBar.setEditable(false); 260 messageBar.setBackground(Color.WHITE); 261 add(messageBar); 262 } 263 264 public void syncPanel() { 265 typeButtons.clearSelection(); 266 chanButton.setBorderPainted(false); 267 chanButton.setEnabled(false); 268 hazButton.setBorderPainted(false); 269 hazButton.setEnabled(false); 270 specButton.setBorderPainted(false); 271 specButton.setEnabled(false); 272 lightsButton.setBorderPainted(false); 273 lightsButton.setEnabled(false); 274 miscButtons.clearSelection(); 275 topButton.setEnabled(false); 276 topButton.setBorderPainted(false); 277 fogButton.setEnabled(false); 278 fogButton.setBorderPainted(false); 279 radButton.setEnabled(false); 280 radButton.setBorderPainted(false); 281 litButton.setEnabled(false); 282 litButton.setBorderPainted(false); 283 saveButton.setEnabled(false); 284 moreButton.setVisible(false); 285 moreButton.setText(">>"); 286 moreButton.setSelected(false); 287 panelChan.setVisible(false); 288 panelHaz.setVisible(false); 289 panelSpec.setVisible(false); 290 panelLights.setVisible(false); 291 panelMore.setVisible(false); 292 panelTop.setVisible(false); 293 panelFog.setVisible(false); 294 panelRadar.setVisible(false); 295 panelLit.setVisible(false); 296 nameBox.setEnabled(false); 297 if (mark != null) { 298 nameBox.setEnabled(true); 299 chanButton.setEnabled(true); 300 hazButton.setEnabled(true); 301 specButton.setEnabled(true); 302 lightsButton.setEnabled(true); 303 nameBox.setText(mark.getName()); 304 switch (SeaMark.GrpMAP.get(mark.getObject())) { 305 case LAT: 306 case SAW: 307 chanButton.setBorderPainted(true); 308 panelChan.setVisible(true); 309 panelChan.syncPanel(); 310 break; 311 case CAR: 312 case ISD: 313 hazButton.setBorderPainted(true); 314 panelHaz.setVisible(true); 315 panelHaz.syncPanel(); 316 break; 317 case SPP: 318 specButton.setBorderPainted(true); 319 panelSpec.setVisible(true); 320 panelSpec.syncPanel(); 321 break; 322 case LGT: 323 case STN: 324 case PLF: 325 lightsButton.setBorderPainted(true); 326 panelLights.setVisible(true); 327 panelLights.syncPanel(); 328 break; 329 } 330 panelMore.syncPanel(); 331 panelTop.syncPanel(); 332 panelFog.syncPanel(); 333 panelRadar.syncPanel(); 334 panelLit.syncPanel(); 335 } 336 } 337 338 private JRadioButton getButton(JRadioButton button, int x, int y, int w, int h, String tip) { 339 button.setBounds(new Rectangle(x, y, w, h)); 340 button.setBorder(BorderFactory.createLoweredBevelBorder()); 341 button.setToolTipText(Messages.getString(tip)); 342 return button; 343 } 29 private SmedAction dlg; 30 public SeaMark mark = null; 31 public PanelChan panelChan = null; 32 public PanelHaz panelHaz = null; 33 public PanelSpec panelSpec = null; 34 public PanelLights panelLights = null; 35 public PanelMore panelMore = null; 36 public PanelTop panelTop = null; 37 public PanelFog panelFog = null; 38 public PanelRadar panelRadar = null; 39 public PanelLit panelLit = null; 40 public JLabel nameLabel = null; 41 public JTextField nameBox = null; 42 public static JTextField messageBar = null; 43 private FocusListener flName = new FocusListener() { 44 @Override 45 public void focusLost(FocusEvent e) { 46 mark.setName(nameBox.getText()); 47 } 48 @Override 49 public void focusGained(FocusEvent e) { 50 } 51 }; 52 public JButton saveButton = null; 53 private ActionListener alSave = new ActionListener() { 54 @Override 55 public void actionPerformed(ActionEvent e) { 56 mark.saveSign(dlg.node); 57 } 58 }; 59 public JButton moreButton = null; 60 private ActionListener alMore = new ActionListener() { 61 @Override 62 public void actionPerformed(ActionEvent e) { 63 if (panelMore.isVisible()) { 64 moreButton.setText(">>"); 65 panelMore.setVisible(false); 66 topButton.setEnabled(true); 67 radButton.setEnabled(true); 68 fogButton.setEnabled(true); 69 litButton.setEnabled(true); 70 } else { 71 panelMore.setVisible(true); 72 moreButton.setText("<<"); 73 miscButtons.clearSelection(); 74 panelTop.setVisible(false); 75 topButton.setBorderPainted(false); 76 topButton.setEnabled(false); 77 panelRadar.setVisible(false); 78 radButton.setBorderPainted(false); 79 radButton.setEnabled(false); 80 panelFog.setVisible(false); 81 fogButton.setBorderPainted(false); 82 fogButton.setEnabled(false); 83 panelLit.setVisible(false); 84 litButton.setBorderPainted(false); 85 litButton.setEnabled(false); 86 } 87 } 88 }; 89 public ButtonGroup typeButtons = null; 90 public JRadioButton chanButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ChanButton.png"))); 91 public JRadioButton hazButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/HazButton.png"))); 92 public JRadioButton specButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SpecButton.png"))); 93 public JRadioButton lightsButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightsButton.png"))); 94 private ActionListener alType = new ActionListener() { 95 @Override 96 public void actionPerformed(ActionEvent e) { 97 if (chanButton.isSelected()) { 98 chanButton.setBorderPainted(true); 99 panelChan.syncPanel(); 100 panelChan.setVisible(true); 101 } else { 102 chanButton.setBorderPainted(false); 103 panelChan.setVisible(false); 104 } 105 if (hazButton.isSelected()) { 106 hazButton.setBorderPainted(true); 107 panelHaz.syncPanel(); 108 panelHaz.setVisible(true); 109 } else { 110 hazButton.setBorderPainted(false); 111 panelHaz.setVisible(false); 112 } 113 if (specButton.isSelected()) { 114 specButton.setBorderPainted(true); 115 panelSpec.syncPanel(); 116 panelSpec.setVisible(true); 117 } else { 118 specButton.setBorderPainted(false); 119 panelSpec.setVisible(false); 120 } 121 if (lightsButton.isSelected()) { 122 lightsButton.setBorderPainted(true); 123 panelLights.syncPanel(); 124 panelLights.setVisible(true); 125 } else { 126 lightsButton.setBorderPainted(false); 127 panelLights.setVisible(false); 128 } 129 } 130 }; 131 private ButtonGroup miscButtons = null; 132 public JRadioButton topButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TopButton.png"))); 133 public JRadioButton fogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogButton.png"))); 134 public JRadioButton radButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarButton.png"))); 135 public JRadioButton litButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LitButton.png"))); 136 private ActionListener alMisc = new ActionListener() { 137 @Override 138 public void actionPerformed(ActionEvent e) { 139 if (topButton.isSelected()) { 140 moreButton.setText(">>"); 141 panelMore.setVisible(false); 142 topButton.setBorderPainted(true); 143 panelTop.setVisible(true); 144 panelTop.syncPanel(); 145 } else { 146 topButton.setBorderPainted(false); 147 panelTop.setVisible(false); 148 } 149 if (fogButton.isSelected()) { 150 moreButton.setText(">>"); 151 panelMore.setVisible(false); 152 fogButton.setBorderPainted(true); 153 panelFog.setVisible(true); 154 panelFog.syncPanel(); 155 } else { 156 fogButton.setBorderPainted(false); 157 panelFog.setVisible(false); 158 } 159 if (radButton.isSelected()) { 160 moreButton.setText(">>"); 161 panelMore.setVisible(false); 162 radButton.setBorderPainted(true); 163 panelRadar.setVisible(true); 164 panelRadar.syncPanel(); 165 } else { 166 radButton.setBorderPainted(false); 167 panelRadar.setVisible(false); 168 } 169 if (litButton.isSelected()) { 170 moreButton.setText(">>"); 171 panelMore.setVisible(false); 172 litButton.setBorderPainted(true); 173 panelLit.setVisible(true); 174 panelLit.syncPanel(); 175 } else { 176 litButton.setBorderPainted(false); 177 panelLit.setVisible(false); 178 } 179 } 180 }; 181 182 public PanelMain(SmedAction dia) { 183 184 dlg = dia; 185 setLayout(null); 186 mark = new SeaMark(dlg); 187 mark.setBounds(new Rectangle(235, 0, 165, 160)); 188 add(mark); 189 panelChan = new PanelChan(dlg); 190 panelChan.setBounds(new Rectangle(65, 0, 170, 160)); 191 panelChan.setVisible(false); 192 add(panelChan); 193 panelHaz = new PanelHaz(dlg); 194 panelHaz.setBounds(new Rectangle(65, 0, 170, 160)); 195 panelHaz.setVisible(false); 196 add(panelHaz); 197 panelSpec = new PanelSpec(dlg); 198 panelSpec.setBounds(new Rectangle(65, 0, 170, 160)); 199 panelSpec.setVisible(false); 200 add(panelSpec); 201 panelLights = new PanelLights(dlg); 202 panelLights.setBounds(new Rectangle(65, 0, 170, 160)); 203 panelLights.setVisible(false); 204 add(panelLights); 205 panelMore = new PanelMore(dlg); 206 panelMore.setBounds(new Rectangle(40, 165, 360, 160)); 207 panelMore.setVisible(false); 208 add(panelMore); 209 panelTop = new PanelTop(dlg); 210 panelTop.setBounds(new Rectangle(40, 165, 360, 160)); 211 panelTop.setVisible(false); 212 add(panelTop); 213 panelFog = new PanelFog(dlg); 214 panelFog.setBounds(new Rectangle(40, 165, 360, 160)); 215 panelFog.setVisible(false); 216 add(panelFog); 217 panelRadar = new PanelRadar(dlg); 218 panelRadar.setBounds(new Rectangle(40, 165, 360, 160)); 219 panelRadar.setVisible(false); 220 add(panelRadar); 221 panelLit = new PanelLit(dlg); 222 panelLit.setBounds(new Rectangle(40, 165, 360, 160)); 223 panelLit.setVisible(false); 224 add(panelLit); 225 226 add(getButton(chanButton, 0, 0, 62, 40, "Chan"), null); 227 add(getButton(hazButton, 0, 40, 62, 40, "Haz"), null); 228 add(getButton(specButton, 0, 80, 62, 40, "Spec"), null); 229 add(getButton(lightsButton, 0, 120, 62, 40, "Lights"), null); 230 typeButtons = new ButtonGroup(); 231 typeButtons.add(chanButton); 232 typeButtons.add(hazButton); 233 typeButtons.add(specButton); 234 typeButtons.add(lightsButton); 235 chanButton.addActionListener(alType); 236 hazButton.addActionListener(alType); 237 specButton.addActionListener(alType); 238 lightsButton.addActionListener(alType); 239 240 add(getButton(topButton, 0, 185, 34, 32, "Topmarks")); 241 add(getButton(fogButton, 0, 220, 34, 32, "FogSignals")); 242 add(getButton(radButton, 0, 255, 34, 32, "Radar")); 243 add(getButton(litButton, 0, 290, 34, 32, "Lit")); 244 miscButtons = new ButtonGroup(); 245 miscButtons.add(topButton); 246 miscButtons.add(fogButton); 247 miscButtons.add(radButton); 248 miscButtons.add(litButton); 249 topButton.addActionListener(alMisc); 250 fogButton.addActionListener(alMisc); 251 radButton.addActionListener(alMisc); 252 litButton.addActionListener(alMisc); 253 254 nameLabel = new JLabel(); 255 nameLabel.setBounds(new Rectangle(5, 329, 60, 20)); 256 nameLabel.setText(tr("Name:")); 257 add(nameLabel); 258 nameBox = new JTextField(); 259 nameBox.setBounds(new Rectangle(60, 330, 200, 20)); 260 nameBox.setHorizontalAlignment(SwingConstants.CENTER); 261 add(nameBox); 262 nameBox.addFocusListener(flName); 263 264 saveButton = new JButton(); 265 saveButton.setBounds(new Rectangle(285, 330, 100, 20)); 266 saveButton.setText(tr("Save")); 267 add(saveButton); 268 saveButton.addActionListener(alSave); 269 270 moreButton = new JButton(); 271 moreButton.setBounds(new Rectangle(0, 165, 34, 15)); 272 moreButton.setMargin(new Insets(0, 0, 0, 0)); 273 moreButton.setText(">>"); 274 add(moreButton); 275 moreButton.addActionListener(alMore); 276 277 messageBar = new JTextField(); 278 messageBar.setBounds(10, 355, 380, 20); 279 messageBar.setEditable(false); 280 messageBar.setBackground(Color.WHITE); 281 add(messageBar); 282 } 283 284 public void syncPanel() { 285 typeButtons.clearSelection(); 286 chanButton.setBorderPainted(false); 287 chanButton.setEnabled(false); 288 hazButton.setBorderPainted(false); 289 hazButton.setEnabled(false); 290 specButton.setBorderPainted(false); 291 specButton.setEnabled(false); 292 lightsButton.setBorderPainted(false); 293 lightsButton.setEnabled(false); 294 miscButtons.clearSelection(); 295 topButton.setEnabled(false); 296 topButton.setBorderPainted(false); 297 fogButton.setEnabled(false); 298 fogButton.setBorderPainted(false); 299 radButton.setEnabled(false); 300 radButton.setBorderPainted(false); 301 litButton.setEnabled(false); 302 litButton.setBorderPainted(false); 303 saveButton.setEnabled(false); 304 moreButton.setVisible(false); 305 moreButton.setText(">>"); 306 moreButton.setSelected(false); 307 panelChan.setVisible(false); 308 panelHaz.setVisible(false); 309 panelSpec.setVisible(false); 310 panelLights.setVisible(false); 311 panelMore.setVisible(false); 312 panelTop.setVisible(false); 313 panelFog.setVisible(false); 314 panelRadar.setVisible(false); 315 panelLit.setVisible(false); 316 nameBox.setEnabled(false); 317 if (mark != null) { 318 nameBox.setEnabled(true); 319 chanButton.setEnabled(true); 320 hazButton.setEnabled(true); 321 specButton.setEnabled(true); 322 lightsButton.setEnabled(true); 323 nameBox.setText(mark.getName()); 324 switch (SeaMark.GrpMAP.get(mark.getObject())) { 325 case LAT: 326 case SAW: 327 chanButton.setBorderPainted(true); 328 panelChan.setVisible(true); 329 panelChan.syncPanel(); 330 break; 331 case CAR: 332 case ISD: 333 hazButton.setBorderPainted(true); 334 panelHaz.setVisible(true); 335 panelHaz.syncPanel(); 336 break; 337 case SPP: 338 specButton.setBorderPainted(true); 339 panelSpec.setVisible(true); 340 panelSpec.syncPanel(); 341 break; 342 case LGT: 343 case STN: 344 case PLF: 345 lightsButton.setBorderPainted(true); 346 panelLights.setVisible(true); 347 panelLights.syncPanel(); 348 break; 349 } 350 panelMore.syncPanel(); 351 panelTop.syncPanel(); 352 panelFog.syncPanel(); 353 panelRadar.syncPanel(); 354 panelLit.syncPanel(); 355 } 356 } 357 358 private JRadioButton getButton(JRadioButton button, int x, int y, int w, int h, String tip) { 359 button.setBounds(new Rectangle(x, y, w, h)); 360 button.setBorder(BorderFactory.createLoweredBevelBorder()); 361 button.setToolTipText(Messages.getString(tip)); 362 return button; 363 } 344 364 345 365 } -
applications/editors/josm/plugins/smed/src/panels/PanelMore.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 5 6 import javax.swing.*; 7 8 import java.util.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.awt.event.FocusAdapter; 7 import java.awt.event.FocusEvent; 8 import java.awt.event.FocusListener; 9 import java.util.EnumMap; 10 11 import javax.swing.BorderFactory; 12 import javax.swing.ButtonGroup; 13 import javax.swing.ImageIcon; 14 import javax.swing.JComboBox; 15 import javax.swing.JLabel; 16 import javax.swing.JPanel; 17 import javax.swing.JRadioButton; 18 import javax.swing.JTextField; 19 import javax.swing.SwingConstants; 9 20 10 21 import messages.Messages; 22 import seamarks.SeaMark.Cns; 23 import seamarks.SeaMark.Col; 24 import seamarks.SeaMark.Con; 25 import seamarks.SeaMark.Ent; 26 import seamarks.SeaMark.Pat; 27 import seamarks.SeaMark.Reg; 28 import seamarks.SeaMark.Sts; 11 29 import smed.SmedAction; 12 import seamarks.SeaMark.*;13 30 14 31 public class PanelMore extends JPanel { 15 32 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 SmedAction.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 SmedAction.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 SmedAction.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 SmedAction.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.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 (SmedAction.panelMain.mark != null && (idx == statusBox.getSelectedIndex())) 53 SmedAction.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.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 (SmedAction.panelMain.mark != null && (idx == constrBox.getSelectedIndex())) 65 SmedAction.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.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 (SmedAction.panelMain.mark != null && (idx == conBox.getSelectedIndex())) 77 SmedAction.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.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 (SmedAction.panelMain.mark != null && (idx == reflBox.getSelectedIndex())) 89 SmedAction.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 SmedAction.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 } 33 private SmedAction dlg; 34 public JLabel infoLabel; 35 public JTextField infoBox; 36 private FocusListener flInfo = new FocusAdapter() { 37 @Override 38 public void focusLost(FocusEvent e) { 39 SmedAction.panelMain.mark.setInfo(infoBox.getText()); 40 } 41 }; 42 public JLabel sourceLabel; 43 public JTextField sourceBox; 44 private FocusListener flSource = new FocusAdapter() { 45 @Override 46 public void focusLost(FocusEvent e) { 47 SmedAction.panelMain.mark.setSource(sourceBox.getText()); 48 } 49 }; 50 public JLabel elevLabel; 51 public JTextField elevBox; 52 private FocusListener flElev = new FocusAdapter() { 53 @Override 54 public void focusLost(FocusEvent e) { 55 SmedAction.panelMain.mark.setElevation(elevBox.getText()); 56 } 57 }; 58 public JLabel heightLabel; 59 public JTextField heightBox; 60 private FocusListener flHeight = new FocusAdapter() { 61 @Override 62 public void focusLost(FocusEvent e) { 63 SmedAction.panelMain.mark.setObjectHeight(heightBox.getText()); 64 } 65 }; 66 public JLabel statusLabel; 67 public JComboBox<String> statusBox; 68 public EnumMap<Sts, Integer> statuses = new EnumMap<>(Sts.class); 69 private ActionListener alStatus = new ActionListener() { 70 @Override 71 public void actionPerformed(ActionEvent e) { 72 for (Sts sts : statuses.keySet()) { 73 int idx = statuses.get(sts); 74 if (SmedAction.panelMain.mark != null && (idx == statusBox.getSelectedIndex())) { 75 SmedAction.panelMain.mark.setStatus(sts); 76 } 77 } 78 } 79 }; 80 public JLabel constrLabel; 81 public JComboBox<String> constrBox; 82 public EnumMap<Cns, Integer> constructions = new EnumMap<>(Cns.class); 83 private ActionListener alConstr = new ActionListener() { 84 @Override 85 public void actionPerformed(ActionEvent e) { 86 for (Cns cns : constructions.keySet()) { 87 int idx = constructions.get(cns); 88 if (SmedAction.panelMain.mark != null && (idx == constrBox.getSelectedIndex())) { 89 SmedAction.panelMain.mark.setConstr(cns); 90 } 91 } 92 } 93 }; 94 public JLabel conLabel; 95 public JComboBox<String> conBox; 96 public EnumMap<Con, Integer> conspicuities = new EnumMap<>(Con.class); 97 private ActionListener alCon = new ActionListener() { 98 @Override 99 public void actionPerformed(ActionEvent e) { 100 for (Con con : conspicuities.keySet()) { 101 int idx = conspicuities.get(con); 102 if (SmedAction.panelMain.mark != null && (idx == conBox.getSelectedIndex())) { 103 SmedAction.panelMain.mark.setConsp(con); 104 } 105 } 106 } 107 }; 108 public JLabel reflLabel; 109 public JComboBox<String> reflBox; 110 public EnumMap<Con, Integer> reflectivities = new EnumMap<>(Con.class); 111 private ActionListener alRefl = new ActionListener() { 112 @Override 113 public void actionPerformed(ActionEvent e) { 114 for (Con con : reflectivities.keySet()) { 115 int idx = reflectivities.get(con); 116 if (SmedAction.panelMain.mark != null && (idx == reflBox.getSelectedIndex())) { 117 SmedAction.panelMain.mark.setRefl(con); 118 } 119 } 120 } 121 }; 122 public PanelPat panelPat; 123 private ButtonGroup regionButtons = new ButtonGroup(); 124 public JRadioButton regionAButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionAButton.png"))); 125 public JRadioButton regionBButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionBButton.png"))); 126 public JRadioButton regionCButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionCButton.png"))); 127 private ActionListener alRegion = new ActionListener() { 128 @Override 129 public void actionPerformed(ActionEvent e) { 130 if (regionAButton.isSelected()) { 131 SmedAction.panelMain.mark.setRegion(Reg.A); 132 switch (dlg.panelMain.mark.getCategory()) { 133 case LAM_PORT: 134 dlg.panelMain.mark.setObjColour(Col.RED); 135 dlg.panelMain.mark.setObjPattern(Pat.NOPAT); 136 break; 137 case LAM_PPORT: 138 dlg.panelMain.mark.setObjColour(Col.RED); 139 dlg.panelMain.mark.addObjColour(Col.GREEN); 140 dlg.panelMain.mark.addObjColour(Col.RED); 141 dlg.panelMain.mark.setObjPattern(Pat.HSTRP); 142 break; 143 case LAM_STBD: 144 dlg.panelMain.mark.setObjColour(Col.GREEN); 145 dlg.panelMain.mark.setObjPattern(Pat.NOPAT); 146 break; 147 case LAM_PSTBD: 148 dlg.panelMain.mark.setObjColour(Col.GREEN); 149 dlg.panelMain.mark.addObjColour(Col.RED); 150 dlg.panelMain.mark.addObjColour(Col.GREEN); 151 dlg.panelMain.mark.setObjPattern(Pat.HSTRP); 152 break; 153 } 154 regionAButton.setBorderPainted(true); 155 } else { 156 regionAButton.setBorderPainted(false); 157 } 158 if (regionBButton.isSelected()) { 159 dlg.panelMain.mark.setRegion(Reg.B); 160 switch (dlg.panelMain.mark.getCategory()) { 161 case LAM_PORT: 162 dlg.panelMain.mark.setObjColour(Col.GREEN); 163 dlg.panelMain.mark.setObjPattern(Pat.NOPAT); 164 break; 165 case LAM_PPORT: 166 dlg.panelMain.mark.setObjColour(Col.GREEN); 167 dlg.panelMain.mark.addObjColour(Col.RED); 168 dlg.panelMain.mark.addObjColour(Col.GREEN); 169 dlg.panelMain.mark.setObjPattern(Pat.HSTRP); 170 break; 171 case LAM_STBD: 172 dlg.panelMain.mark.setObjColour(Col.RED); 173 dlg.panelMain.mark.setObjPattern(Pat.NOPAT); 174 break; 175 case LAM_PSTBD: 176 dlg.panelMain.mark.setObjColour(Col.RED); 177 dlg.panelMain.mark.addObjColour(Col.GREEN); 178 dlg.panelMain.mark.addObjColour(Col.RED); 179 dlg.panelMain.mark.setObjPattern(Pat.HSTRP); 180 break; 181 } 182 regionBButton.setBorderPainted(true); 183 } else { 184 regionBButton.setBorderPainted(false); 185 } 186 if (regionCButton.isSelected()) { 187 dlg.panelMain.mark.setRegion(Reg.C); 188 dlg.panelMain.mark.setObjPattern(Pat.HSTRP); 189 switch (dlg.panelMain.mark.getCategory()) { 190 case LAM_PORT: 191 dlg.panelMain.mark.setObjColour(Col.RED); 192 dlg.panelMain.mark.addObjColour(Col.WHITE); 193 dlg.panelMain.mark.addObjColour(Col.RED); 194 dlg.panelMain.mark.addObjColour(Col.WHITE); 195 break; 196 case LAM_PPORT: 197 case LAM_PSTBD: 198 dlg.panelMain.mark.setObjColour(Col.RED); 199 dlg.panelMain.mark.addObjColour(Col.GREEN); 200 dlg.panelMain.mark.addObjColour(Col.RED); 201 dlg.panelMain.mark.addObjColour(Col.GREEN); 202 break; 203 case LAM_STBD: 204 dlg.panelMain.mark.setObjColour(Col.GREEN); 205 dlg.panelMain.mark.addObjColour(Col.WHITE); 206 dlg.panelMain.mark.addObjColour(Col.GREEN); 207 dlg.panelMain.mark.addObjColour(Col.WHITE); 208 break; 209 } 210 regionCButton.setBorderPainted(true); 211 } else { 212 regionCButton.setBorderPainted(false); 213 } 214 panelPat.syncPanel(); 215 } 216 }; 217 218 public PanelMore(SmedAction dia) { 219 dlg = dia; 220 setLayout(null); 221 panelPat = new PanelPat(dlg, Ent.BODY); 222 panelPat.setBounds(new Rectangle(0, 0, 110, 160)); 223 add(panelPat); 224 add(getRegionButton(regionAButton, 110, 0, 34, 30, "RegionA")); 225 add(getRegionButton(regionBButton, 110, 32, 34, 30, "RegionB")); 226 add(getRegionButton(regionCButton, 110, 64, 34, 30, "RegionC")); 227 228 elevLabel = new JLabel(Messages.getString("Elevation"), SwingConstants.CENTER); 229 elevLabel.setBounds(new Rectangle(140, 0, 90, 20)); 230 add(elevLabel); 231 elevBox = new JTextField(); 232 elevBox.setBounds(new Rectangle(160, 20, 50, 20)); 233 elevBox.setHorizontalAlignment(SwingConstants.CENTER); 234 add(elevBox); 235 elevBox.addFocusListener(flElev); 236 237 heightLabel = new JLabel(Messages.getString("Height"), SwingConstants.CENTER); 238 heightLabel.setBounds(new Rectangle(140, 40, 90, 20)); 239 add(heightLabel); 240 heightBox = new JTextField(); 241 heightBox.setBounds(new Rectangle(160, 60, 50, 20)); 242 heightBox.setHorizontalAlignment(SwingConstants.CENTER); 243 add(heightBox); 244 heightBox.addFocusListener(flHeight); 245 246 sourceLabel = new JLabel(Messages.getString("Source"), SwingConstants.CENTER); 247 sourceLabel.setBounds(new Rectangle(110, 80, 130, 20)); 248 add(sourceLabel); 249 sourceBox = new JTextField(); 250 sourceBox.setBounds(new Rectangle(110, 100, 130, 20)); 251 sourceBox.setHorizontalAlignment(SwingConstants.CENTER); 252 add(sourceBox); 253 sourceBox.addFocusListener(flSource); 254 255 infoLabel = new JLabel(Messages.getString("Information"), SwingConstants.CENTER); 256 infoLabel.setBounds(new Rectangle(110, 120, 130, 20)); 257 add(infoLabel); 258 infoBox = new JTextField(); 259 infoBox.setBounds(new Rectangle(110, 140, 130, 20)); 260 infoBox.setHorizontalAlignment(SwingConstants.CENTER); 261 add(infoBox); 262 infoBox.addFocusListener(flInfo); 263 264 statusLabel = new JLabel(Messages.getString("Status"), SwingConstants.CENTER); 265 statusLabel.setBounds(new Rectangle(250, 0, 100, 20)); 266 add(statusLabel); 267 statusBox = new JComboBox<>(); 268 statusBox.setBounds(new Rectangle(250, 20, 100, 20)); 269 addStsItem("", Sts.UNKSTS); 270 addStsItem(Messages.getString("Permanent"), Sts.PERM); 271 addStsItem(Messages.getString("Occasional"), Sts.OCC); 272 addStsItem(Messages.getString("Recommended"), Sts.REC); 273 addStsItem(Messages.getString("NotInUse"), Sts.NIU); 274 addStsItem(Messages.getString("Intermittent"), Sts.INT); 275 addStsItem(Messages.getString("Reserved"), Sts.RESV); 276 addStsItem(Messages.getString("Temporary"), Sts.TEMP); 277 addStsItem(Messages.getString("Private"), Sts.PRIV); 278 addStsItem(Messages.getString("Mandatory"), Sts.MAND); 279 addStsItem(Messages.getString("Destroyed"), Sts.DEST); 280 addStsItem(Messages.getString("Extinguished"), Sts.EXT); 281 addStsItem(Messages.getString("Illuminated"), Sts.ILLUM); 282 addStsItem(Messages.getString("Historic"), Sts.HIST); 283 addStsItem(Messages.getString("Public"), Sts.PUB); 284 addStsItem(Messages.getString("Synchronized"), Sts.SYNC); 285 addStsItem(Messages.getString("Watched"), Sts.WATCH); 286 addStsItem(Messages.getString("UnWatched"), Sts.UNWAT); 287 addStsItem(Messages.getString("Doubtful"), Sts.DOUBT); 288 add(statusBox); 289 statusBox.addActionListener(alStatus); 290 291 constrLabel = new JLabel(Messages.getString("Construction"), SwingConstants.CENTER); 292 constrLabel.setBounds(new Rectangle(250, 40, 100, 20)); 293 add(constrLabel); 294 constrBox = new JComboBox<>(); 295 constrBox.setBounds(new Rectangle(250, 60, 100, 20)); 296 addCnsItem("", Cns.UNKCNS); 297 addCnsItem(Messages.getString("Masonry"), Cns.BRICK); 298 addCnsItem(Messages.getString("Concreted"), Cns.CONC); 299 addCnsItem(Messages.getString("Boulders"), Cns.BOULD); 300 addCnsItem(Messages.getString("HardSurfaced"), Cns.HSURF); 301 addCnsItem(Messages.getString("Unsurfaced"), Cns.USURF); 302 addCnsItem(Messages.getString("Wooden"), Cns.WOOD); 303 addCnsItem(Messages.getString("Metal"), Cns.METAL); 304 addCnsItem(Messages.getString("GRP"), Cns.GLAS); 305 addCnsItem(Messages.getString("Painted"), Cns.PAINT); 306 add(constrBox); 307 constrBox.addActionListener(alConstr); 308 309 conLabel = new JLabel(Messages.getString("Conspicuity"), SwingConstants.CENTER); 310 conLabel.setBounds(new Rectangle(250, 80, 100, 20)); 311 add(conLabel); 312 conBox = new JComboBox<>(); 313 conBox.setBounds(new Rectangle(250, 100, 100, 20)); 314 addConItem("", Con.UNKCON); 315 addConItem(Messages.getString("Conspicuous"), Con.CONSP); 316 addConItem(Messages.getString("NotConspicuous"), Con.NCONS); 317 add(conBox); 318 conBox.addActionListener(alCon); 319 320 reflLabel = new JLabel(Messages.getString("Reflectivity"), SwingConstants.CENTER); 321 reflLabel.setBounds(new Rectangle(250, 120, 100, 20)); 322 add(reflLabel); 323 reflBox = new JComboBox<>(); 324 reflBox.setBounds(new Rectangle(250, 140, 100, 20)); 325 addReflItem("", Con.UNKCON); 326 addReflItem(Messages.getString("Conspicuous"), Con.CONSP); 327 addReflItem(Messages.getString("NotConspicuous"), Con.NCONS); 328 addReflItem(Messages.getString("Reflector"), Con.REFL); 329 add(reflBox); 330 reflBox.addActionListener(alRefl); 331 332 } 333 334 public void syncPanel() { 335 panelPat.syncPanel(); 336 regionAButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.A); 337 regionBButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.B); 338 regionCButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.C); 339 elevBox.setText(dlg.panelMain.mark.getElevation()); 340 heightBox.setText(dlg.panelMain.mark.getObjectHeight()); 341 sourceBox.setText(dlg.panelMain.mark.getSource()); 342 infoBox.setText(dlg.panelMain.mark.getInfo()); 343 for (Sts sts : statuses.keySet()) { 344 int item = statuses.get(sts); 345 if (dlg.panelMain.mark.getStatus() == sts) { 346 statusBox.setSelectedIndex(item); 347 } 348 } 349 for (Cns cns : constructions.keySet()) { 350 int item = constructions.get(cns); 351 if (dlg.panelMain.mark.getConstr() == cns) { 352 constrBox.setSelectedIndex(item); 353 } 354 } 355 for (Con con : conspicuities.keySet()) { 356 int item = conspicuities.get(con); 357 if (dlg.panelMain.mark.getConsp() == con) { 358 conBox.setSelectedIndex(item); 359 } 360 } 361 for (Con con : reflectivities.keySet()) { 362 int item = reflectivities.get(con); 363 if (dlg.panelMain.mark.getRefl() == con) { 364 reflBox.setSelectedIndex(item); 365 } 366 } 367 } 368 369 private void addStsItem(String str, Sts sts) { 370 statuses.put(sts, statusBox.getItemCount()); 371 statusBox.addItem(str); 372 } 373 374 private void addCnsItem(String str, Cns cns) { 375 constructions.put(cns, constrBox.getItemCount()); 376 constrBox.addItem(str); 377 } 378 379 private void addConItem(String str, Con con) { 380 conspicuities.put(con, conBox.getItemCount()); 381 conBox.addItem(str); 382 } 383 384 private void addReflItem(String str, Con con) { 385 reflectivities.put(con, reflBox.getItemCount()); 386 reflBox.addItem(str); 387 } 388 389 private JRadioButton getRegionButton(JRadioButton button, int x, int y, int w, int h, String tip) { 390 button.setBounds(new Rectangle(x, y, w, h)); 391 button.setBorder(BorderFactory.createLoweredBevelBorder()); 392 button.setToolTipText(Messages.getString(tip)); 393 button.addActionListener(alRegion); 394 regionButtons.add(button); 395 return button; 396 } 363 397 } -
applications/editors/josm/plugins/smed/src/panels/PanelPat.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.util.EnumMap; 5 7 6 import javax.swing.*; 7 8 import java.util.*; 8 import javax.swing.BorderFactory; 9 import javax.swing.ButtonGroup; 10 import javax.swing.ImageIcon; 11 import javax.swing.JPanel; 12 import javax.swing.JRadioButton; 9 13 10 14 import messages.Messages; 15 import seamarks.SeaMark.Ent; 16 import seamarks.SeaMark.Pat; 11 17 import smed.SmedAction; 12 import seamarks.SeaMark.*;13 18 14 19 public class PanelPat extends JPanel { 15 20 16 17 18 21 private SmedAction dlg; 22 private Ent ent; 23 public PanelCol panelCol; 19 24 20 private ButtonGroup patButtons = new ButtonGroup(); 21 public JRadioButton noneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NoneButton.png"))); 22 public JRadioButton horizButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/HorizontalButton.png"))); 23 public JRadioButton vertButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/VerticalButton.png"))); 24 public JRadioButton diagButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiagonalButton.png"))); 25 public JRadioButton squareButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquaredButton.png"))); 26 public JRadioButton borderButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BorderButton.png"))); 27 public EnumMap<Pat, JRadioButton> patterns = new EnumMap<>(Pat.class); 28 private ActionListener alPat = new ActionListener() { 29 public void actionPerformed(java.awt.event.ActionEvent e) { 30 for (Pat pat : patterns.keySet()) { 31 JRadioButton button = patterns.get(pat); 32 if (button.isSelected()) { 33 SmedAction.panelMain.mark.setPattern(ent, pat); 34 button.setBorderPainted(true); 35 } else 36 button.setBorderPainted(false); 37 } 38 switch (SmedAction.panelMain.mark.getPattern(ent)) { 39 case NOPAT: 40 panelCol.trimStack(1); 41 break; 42 case HSTRP: 43 case VSTRP: 44 case DIAG: 45 break; 46 case SQUARED: 47 panelCol.trimStack(4); 48 break; 49 case BORDER: 50 case CROSS: 51 panelCol.trimStack(2); 52 break; 53 } 54 } 55 }; 25 private ButtonGroup patButtons = new ButtonGroup(); 26 public JRadioButton noneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NoneButton.png"))); 27 public JRadioButton horizButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/HorizontalButton.png"))); 28 public JRadioButton vertButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/VerticalButton.png"))); 29 public JRadioButton diagButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiagonalButton.png"))); 30 public JRadioButton squareButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquaredButton.png"))); 31 public JRadioButton borderButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BorderButton.png"))); 32 public EnumMap<Pat, JRadioButton> patterns = new EnumMap<>(Pat.class); 33 private ActionListener alPat = new ActionListener() { 34 @Override 35 public void actionPerformed(ActionEvent e) { 36 for (Pat pat : patterns.keySet()) { 37 JRadioButton button = patterns.get(pat); 38 if (button.isSelected()) { 39 SmedAction.panelMain.mark.setPattern(ent, pat); 40 button.setBorderPainted(true); 41 } else { 42 button.setBorderPainted(false); 43 } 44 } 45 switch (SmedAction.panelMain.mark.getPattern(ent)) { 46 case NOPAT: 47 panelCol.trimStack(1); 48 break; 49 case HSTRP: 50 case VSTRP: 51 case DIAG: 52 break; 53 case SQUARED: 54 panelCol.trimStack(4); 55 break; 56 case BORDER: 57 case CROSS: 58 panelCol.trimStack(2); 59 break; 60 } 61 } 62 }; 56 63 57 58 59 60 61 62 63 64 65 66 67 68 69 64 public PanelPat(SmedAction dia, Ent entity) { 65 dlg = dia; 66 ent = entity; 67 setLayout(null); 68 panelCol = new PanelCol(dlg, ent); 69 panelCol.setBounds(new Rectangle(0, 0, 72, 160)); 70 add(panelCol); 71 add(getPatButton(noneButton, 76, 0, 27, 27, "NoPat", Pat.NOPAT)); 72 add(getPatButton(horizButton, 76, 26, 27, 27, "HorizPat", Pat.HSTRP)); 73 add(getPatButton(vertButton, 76, 52, 27, 27, "VertPat", Pat.VSTRP)); 74 add(getPatButton(diagButton, 76, 78, 27, 27, "DiagPat", Pat.DIAG)); 75 add(getPatButton(squareButton, 76, 104, 27, 27, "SquarePat", Pat.SQUARED)); 76 add(getPatButton(borderButton, 76, 130, 27, 27, "BorderPat", Pat.BORDER)); 70 77 71 78 } 72 79 73 public void syncPanel() { 74 for (Pat pat : patterns.keySet()) { 75 JRadioButton button = patterns.get(pat); 76 if (SmedAction.panelMain.mark.getPattern(ent) == pat) { 77 button.setBorderPainted(true); 78 } else 79 button.setBorderPainted(false); 80 } 81 panelCol.syncPanel(); 82 } 80 public void syncPanel() { 81 for (Pat pat : patterns.keySet()) { 82 JRadioButton button = patterns.get(pat); 83 if (SmedAction.panelMain.mark.getPattern(ent) == pat) { 84 button.setBorderPainted(true); 85 } else { 86 button.setBorderPainted(false); 87 } 88 } 89 panelCol.syncPanel(); 90 } 83 91 84 85 86 87 88 89 90 91 92 92 private JRadioButton getPatButton(JRadioButton button, int x, int y, int w, int h, String tip, Pat pat) { 93 button.setBounds(new Rectangle(x, y, w, h)); 94 button.setBorder(BorderFactory.createLoweredBevelBorder()); 95 button.setToolTipText(Messages.getString(tip)); 96 button.addActionListener(alPat); 97 patButtons.add(button); 98 patterns.put(pat, button); 99 return button; 100 } 93 101 94 102 } -
applications/editors/josm/plugins/smed/src/panels/PanelPort.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.util.EnumMap; 6 7 7 import java.util.*; 8 import javax.swing.BorderFactory; 9 import javax.swing.ButtonGroup; 10 import javax.swing.ImageIcon; 11 import javax.swing.JPanel; 12 import javax.swing.JRadioButton; 8 13 9 14 import messages.Messages; 15 import seamarks.SeaMark.Cat; 16 import seamarks.SeaMark.Col; 17 import seamarks.SeaMark.Obj; 18 import seamarks.SeaMark.Pat; 19 import seamarks.SeaMark.Shp; 10 20 import smed.SmedAction; 11 import seamarks.SeaMark.*;12 21 13 22 public class PanelPort extends JPanel { 14 23 15 private SmedAction dlg; 16 public ButtonGroup shapeButtons = new ButtonGroup(); 17 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 18 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 19 public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png"))); 20 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 21 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 22 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 23 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 24 public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchPButton.png"))); 25 public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png"))); 26 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 27 public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class); 28 public ActionListener alShape = new ActionListener() { 29 public void actionPerformed(java.awt.event.ActionEvent e) { 30 for (Shp shp : shapes.keySet()) { 31 JRadioButton button = shapes.get(shp); 32 if (button.isSelected()) { 33 SmedAction.panelMain.mark.setShape(shp); 34 SmedAction.panelMain.mark.setObject(objects.get(shp)); 35 button.setBorderPainted(true); 36 } else 37 button.setBorderPainted(false); 38 } 39 if (SmedAction.panelMain.mark.testValid()) { 40 SmedAction.panelMain.panelChan.topmarkButton.setVisible(true); 41 SmedAction.panelMain.panelChan.lightButton.setVisible(true); 42 if (SmedAction.panelMain.mark.getCategory() == Cat.LAM_PORT) { 43 switch (SmedAction.panelMain.mark.getRegion()) { 44 case A: 45 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 46 SmedAction.panelMain.mark.setObjColour(Col.RED); 47 break; 48 case B: 49 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 50 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 51 break; 52 case C: 53 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 54 SmedAction.panelMain.mark.setObjColour(Col.RED); 55 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 56 SmedAction.panelMain.mark.addObjColour(Col.RED); 57 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 58 break; 59 } 60 } else { 61 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 62 switch (SmedAction.panelMain.mark.getRegion()) { 63 case A: 64 SmedAction.panelMain.mark.setObjColour(Col.RED); 65 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 66 SmedAction.panelMain.mark.addObjColour(Col.RED); 67 break; 68 case B: 69 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 70 SmedAction.panelMain.mark.addObjColour(Col.RED); 71 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 72 break; 73 case C: 74 SmedAction.panelMain.mark.setObjColour(Col.RED); 75 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 76 SmedAction.panelMain.mark.addObjColour(Col.RED); 77 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 78 break; 79 } 80 } 81 SmedAction.panelMain.panelMore.syncPanel(); 82 } else { 83 SmedAction.panelMain.panelChan.topmarkButton.setVisible(false); 84 SmedAction.panelMain.panelChan.lightButton.setVisible(false); 85 } 86 } 87 }; 24 private SmedAction dlg; 25 public ButtonGroup shapeButtons = new ButtonGroup(); 26 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 27 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 28 public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png"))); 29 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 30 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 31 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 32 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 33 public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchPButton.png"))); 34 public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png"))); 35 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 36 public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class); 37 public ActionListener alShape = new ActionListener() { 38 @Override 39 public void actionPerformed(ActionEvent e) { 40 for (Shp shp : shapes.keySet()) { 41 JRadioButton button = shapes.get(shp); 42 if (button.isSelected()) { 43 SmedAction.panelMain.mark.setShape(shp); 44 SmedAction.panelMain.mark.setObject(objects.get(shp)); 45 button.setBorderPainted(true); 46 } else { 47 button.setBorderPainted(false); 48 } 49 } 50 if (SmedAction.panelMain.mark.testValid()) { 51 SmedAction.panelMain.panelChan.topmarkButton.setVisible(true); 52 SmedAction.panelMain.panelChan.lightButton.setVisible(true); 53 if (SmedAction.panelMain.mark.getCategory() == Cat.LAM_PORT) { 54 switch (SmedAction.panelMain.mark.getRegion()) { 55 case A: 56 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 57 SmedAction.panelMain.mark.setObjColour(Col.RED); 58 break; 59 case B: 60 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 61 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 62 break; 63 case C: 64 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 65 SmedAction.panelMain.mark.setObjColour(Col.RED); 66 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 67 SmedAction.panelMain.mark.addObjColour(Col.RED); 68 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 69 break; 70 } 71 } else { 72 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 73 switch (SmedAction.panelMain.mark.getRegion()) { 74 case A: 75 SmedAction.panelMain.mark.setObjColour(Col.RED); 76 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 77 SmedAction.panelMain.mark.addObjColour(Col.RED); 78 break; 79 case B: 80 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 81 SmedAction.panelMain.mark.addObjColour(Col.RED); 82 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 83 break; 84 case C: 85 SmedAction.panelMain.mark.setObjColour(Col.RED); 86 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 87 SmedAction.panelMain.mark.addObjColour(Col.RED); 88 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 89 break; 90 } 91 } 92 SmedAction.panelMain.panelMore.syncPanel(); 93 } else { 94 SmedAction.panelMain.panelChan.topmarkButton.setVisible(false); 95 SmedAction.panelMain.panelChan.lightButton.setVisible(false); 96 } 97 } 98 }; 88 99 89 90 91 92 93 94 95 96 97 98 99 100 101 100 public PanelPort(SmedAction dia) { 101 dlg = dia; 102 setLayout(null); 103 add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYLAT)); 104 add(getShapeButton(sparButton, 0, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYLAT)); 105 add(getShapeButton(canButton, 0, 64, 34, 32, "Can", Shp.CAN, Obj.BOYLAT)); 106 add(getShapeButton(sphereButton, 0, 96, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYLAT)); 107 add(getShapeButton(floatButton, 0, 128, 34, 32, "Float", Shp.FLOAT, Obj.FLTLAT)); 108 add(getShapeButton(beaconButton, 35, 0, 34, 32, "Beacon", Shp.BEACON, Obj.BCNLAT)); 109 add(getShapeButton(towerButton, 35, 32, 34, 32, "TowerB", Shp.TOWER, Obj.BCNLAT)); 110 add(getShapeButton(perchButton, 35, 64, 34, 32, "Perch", Shp.PERCH, Obj.BCNLAT)); 111 add(getShapeButton(stakeButton, 35, 96, 34, 32, "Stake", Shp.STAKE, Obj.BCNLAT)); 112 } 102 113 103 public void syncPanel() { 104 for (Shp shp : shapes.keySet()) { 105 JRadioButton button = shapes.get(shp); 106 if (SmedAction.panelMain.mark.getShape() == shp) { 107 button.setBorderPainted(true); 108 } else 109 button.setBorderPainted(false); 110 } 111 } 114 public void syncPanel() { 115 for (Shp shp : shapes.keySet()) { 116 JRadioButton button = shapes.get(shp); 117 if (SmedAction.panelMain.mark.getShape() == shp) { 118 button.setBorderPainted(true); 119 } else { 120 button.setBorderPainted(false); 121 } 122 } 123 } 112 124 113 114 115 116 117 118 119 120 121 122 125 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) { 126 button.setBounds(new Rectangle(x, y, w, h)); 127 button.setBorder(BorderFactory.createLoweredBevelBorder()); 128 button.setToolTipText(Messages.getString(tip)); 129 button.addActionListener(alShape); 130 shapeButtons.add(button); 131 shapes.put(shp, button); 132 objects.put(shp, obj); 133 return button; 134 } 123 135 124 136 } -
applications/editors/josm/plugins/smed/src/panels/PanelRadar.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 5 6 import javax.swing.*; 7 8 import java.util.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.awt.event.FocusAdapter; 7 import java.awt.event.FocusEvent; 8 import java.awt.event.FocusListener; 9 import java.util.EnumMap; 10 11 import javax.swing.BorderFactory; 12 import javax.swing.ButtonGroup; 13 import javax.swing.ImageIcon; 14 import javax.swing.JComboBox; 15 import javax.swing.JLabel; 16 import javax.swing.JPanel; 17 import javax.swing.JRadioButton; 18 import javax.swing.JTextField; 19 import javax.swing.JToggleButton; 20 import javax.swing.SwingConstants; 9 21 10 22 import messages.Messages; 23 import seamarks.SeaMark.Cat; 24 import seamarks.SeaMark.Rtb; 11 25 import smed.SmedAction; 12 import seamarks.SeaMark.*;13 26 14 27 public class PanelRadar extends JPanel { 15 28 16 private SmedAction dlg; 17 private JToggleButton aisButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/AISButton.png"))); 18 private ActionListener alAis = new ActionListener() { 19 public void actionPerformed(java.awt.event.ActionEvent e) { 20 if (aisButton.isSelected()) { 21 radioCatBox.setVisible(true); 22 aisButton.setBorderPainted(true); 23 } else { 24 radioCatBox.setSelectedIndex(0); 25 radioCatBox.setVisible(false); 26 aisButton.setBorderPainted(false); 27 } 28 } 29 }; 30 private JComboBox<String> radioCatBox; 31 private EnumMap<Cat, Integer> radioCats = new EnumMap<>(Cat.class); 32 private ActionListener alRadioCatBox = new ActionListener() { 33 public void actionPerformed(java.awt.event.ActionEvent e) { 34 for (Cat cat : radioCats.keySet()) { 35 int idx = radioCats.get(cat); 36 if (dlg.node != null && (idx == radioCatBox.getSelectedIndex())) { 37 SmedAction.panelMain.mark.setRadio(cat); 38 } 39 } 40 } 41 }; 42 private ButtonGroup radarButtons = new ButtonGroup(); 43 public JRadioButton noRadButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png"))); 44 public JRadioButton reflButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarReflectorButton.png"))); 45 public JRadioButton ramarkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RamarkButton.png"))); 46 public JRadioButton raconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RaconButton.png"))); 47 public JRadioButton leadingButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LeadingRaconButton.png"))); 48 private EnumMap<Rtb, JRadioButton> rads = new EnumMap<>(Rtb.class); 49 private ActionListener alRad = new ActionListener() { 50 public void actionPerformed(java.awt.event.ActionEvent e) { 51 for (Rtb rtb : rads.keySet()) { 52 JRadioButton button = rads.get(rtb); 53 if (button.isSelected()) { 54 SmedAction.panelMain.mark.setRadar(rtb); 55 } 56 } 57 syncPanel(); 58 } 59 }; 60 public JLabel groupLabel; 61 public JTextField groupBox; 62 private FocusListener flGroup = new FocusAdapter() { 63 public void focusLost(java.awt.event.FocusEvent e) { 64 SmedAction.panelMain.mark.setRaconGroup(groupBox.getText()); 65 } 66 }; 67 public JLabel periodLabel; 68 public JTextField periodBox; 69 private FocusListener flPeriod = new FocusAdapter() { 70 public void focusLost(java.awt.event.FocusEvent e) { 71 SmedAction.panelMain.mark.setRaconPeriod(periodBox.getText()); 72 } 73 }; 74 public JLabel seqLabel; 75 public JTextField seqBox; 76 private FocusListener flSeq = new FocusAdapter() { 77 public void focusLost(java.awt.event.FocusEvent e) { 78 SmedAction.panelMain.mark.setRaconSequence(seqBox.getText()); 79 } 80 }; 81 public JLabel rangeLabel; 82 public JTextField rangeBox; 83 private FocusListener flRange = new FocusAdapter() { 84 public void focusLost(java.awt.event.FocusEvent e) { 85 SmedAction.panelMain.mark.setRaconRange(rangeBox.getText()); 86 } 87 }; 88 public JLabel sector1Label; 89 public JTextField sector1Box; 90 private FocusListener flSector1 = new FocusAdapter() { 91 public void focusLost(java.awt.event.FocusEvent e) { 92 SmedAction.panelMain.mark.setRaconSector1(sector1Box.getText()); 93 } 94 }; 95 public JLabel sector2Label; 96 public JTextField sector2Box; 97 private FocusListener flSector2 = new FocusAdapter() { 98 public void focusLost(java.awt.event.FocusEvent e) { 99 SmedAction.panelMain.mark.setRaconSector2(sector2Box.getText()); 100 } 101 }; 102 public JLabel sectorsLabel; 103 104 public PanelRadar(SmedAction dia) { 105 dlg = dia; 106 setLayout(null); 107 add(getRadButton(noRadButton, 0, 3, 27, 27, "NoRadar", Rtb.NORTB)); 108 add(getRadButton(reflButton, 0, 33, 27, 27, "RadarReflector", Rtb.REFLECTOR)); 109 add(getRadButton(ramarkButton, 0, 63, 27, 27, "Ramark", Rtb.RAMARK)); 110 add(getRadButton(raconButton, 0, 93, 27, 27, "Racon", Rtb.RACON)); 111 add(getRadButton(leadingButton, 0, 123, 27, 27, "LeadingRacon", Rtb.LEADING)); 112 113 groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER); 114 groupLabel.setBounds(new Rectangle(30, 0, 100, 20)); 115 add(groupLabel); 116 groupBox = new JTextField(); 117 groupBox.setBounds(new Rectangle(55, 20, 50, 20)); 118 groupBox.setHorizontalAlignment(SwingConstants.CENTER); 119 add(groupBox); 120 groupBox.addFocusListener(flGroup); 121 122 periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER); 123 periodLabel.setBounds(new Rectangle(130, 0, 100, 20)); 124 add(periodLabel); 125 periodBox = new JTextField(); 126 periodBox.setBounds(new Rectangle(155, 20, 50, 20)); 127 periodBox.setHorizontalAlignment(SwingConstants.CENTER); 128 add(periodBox); 129 periodBox.addFocusListener(flPeriod); 130 131 seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER); 132 seqLabel.setBounds(new Rectangle(30, 40, 100, 20)); 133 add(seqLabel); 134 seqBox = new JTextField(); 135 seqBox.setBounds(new Rectangle(55, 60, 50, 20)); 136 seqBox.setHorizontalAlignment(SwingConstants.CENTER); 137 add(seqBox); 138 seqBox.addFocusListener(flSeq); 139 140 rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER); 141 rangeLabel.setBounds(new Rectangle(130, 40, 100, 20)); 142 add(rangeLabel); 143 rangeBox = new JTextField(); 144 rangeBox.setBounds(new Rectangle(155, 60, 50, 20)); 145 rangeBox.setHorizontalAlignment(SwingConstants.CENTER); 146 add(rangeBox); 147 rangeBox.addFocusListener(flRange); 148 149 sectorsLabel = new JLabel(Messages.getString("VisibleSector"), SwingConstants.CENTER); 150 sectorsLabel.setBounds(new Rectangle(75, 85, 100, 20)); 151 add(sectorsLabel); 152 153 sector1Label = new JLabel(Messages.getString("Start"), SwingConstants.CENTER); 154 sector1Label.setBounds(new Rectangle(30, 100, 100, 20)); 155 add(sector1Label); 156 sector1Box = new JTextField(); 157 sector1Box.setBounds(new Rectangle(55, 120, 50, 20)); 158 sector1Box.setHorizontalAlignment(SwingConstants.CENTER); 159 add(sector1Box); 160 sector1Box.addFocusListener(flSector1); 161 162 sector2Label = new JLabel(Messages.getString("End"), SwingConstants.CENTER); 163 sector2Label.setBounds(new Rectangle(130, 100, 100, 20)); 164 add(sector2Label); 165 sector2Box = new JTextField(); 166 sector2Box.setBounds(new Rectangle(155, 120, 50, 20)); 167 sector2Box.setHorizontalAlignment(SwingConstants.CENTER); 168 add(sector2Box); 169 sector2Box.addFocusListener(flSector2); 170 171 aisButton.setBounds(new Rectangle(270, 3, 27, 27)); 172 aisButton.setBorder(BorderFactory.createLoweredBevelBorder()); 173 aisButton.setToolTipText("AIS"); 174 aisButton.addActionListener(alAis); 175 add(aisButton); 176 177 radioCatBox = new JComboBox<>(); 178 radioCatBox.setBounds(new Rectangle(210, 40, 150, 20)); 179 add(radioCatBox); 180 radioCatBox.addActionListener(alRadioCatBox); 181 addROItem("", Cat.NOROS); 182 addROItem(Messages.getString("CircularBeacon"), Cat.ROS_OMNI); 183 addROItem(Messages.getString("DirectionalBeacon"), Cat.ROS_DIRL); 184 addROItem(Messages.getString("RotatingBeacon"), Cat.ROS_ROTP); 185 addROItem(Messages.getString("ConsolBeacon"), Cat.ROS_CNSL); 186 addROItem(Messages.getString("DirectionFinding"), Cat.ROS_RDF); 187 addROItem(Messages.getString("QTGService"), Cat.ROS_QTG); 188 addROItem(Messages.getString("AeronaticalBeacon"), Cat.ROS_AERO); 189 addROItem(Messages.getString("Decca"), Cat.ROS_DECA); 190 addROItem(Messages.getString("LoranC"), Cat.ROS_LORN); 191 addROItem(Messages.getString("DGPS"), Cat.ROS_DGPS); 192 addROItem(Messages.getString("Toran"), Cat.ROS_TORN); 193 addROItem(Messages.getString("Omega"), Cat.ROS_OMGA); 194 addROItem(Messages.getString("Syledis"), Cat.ROS_SYLD); 195 addROItem(Messages.getString("Chiaka"), Cat.ROS_CHKA); 196 addROItem(Messages.getString("PublicCommunication"), Cat.ROS_PCOM); 197 addROItem(Messages.getString("CommercialBroadcast"), Cat.ROS_COMB); 198 addROItem(Messages.getString("Facsimile"), Cat.ROS_FACS); 199 addROItem(Messages.getString("TimeSignal"), Cat.ROS_TIME); 200 addROItem(Messages.getString("AIS"), Cat.ROS_PAIS); 201 addROItem(Messages.getString("S-AIS"), Cat.ROS_SAIS); 202 radioCatBox.setVisible(false); 203 } 204 205 public void syncPanel() { 206 boolean rad = ((SmedAction.panelMain.mark.getRadar() != Rtb.NORTB) && (SmedAction.panelMain.mark.getRadar() != Rtb.REFLECTOR)); 207 groupLabel.setVisible(rad); 208 groupBox.setVisible(rad); 209 periodLabel.setVisible(rad); 210 periodBox.setVisible(rad); 211 seqLabel.setVisible(rad); 212 seqBox.setVisible(rad); 213 rangeLabel.setVisible(rad); 214 rangeBox.setVisible(rad); 215 sector1Label.setVisible(rad); 216 sector1Box.setVisible(rad); 217 sector2Label.setVisible(rad); 218 sector2Box.setVisible(rad); 219 sectorsLabel.setVisible(rad); 220 for (Rtb rtb : rads.keySet()) { 221 rads.get(rtb).setBorderPainted(SmedAction.panelMain.mark.getRadar() == rtb); 222 } 223 groupBox.setText(SmedAction.panelMain.mark.getRaconGroup()); 224 seqBox.setText(SmedAction.panelMain.mark.getRaconSequence()); 225 periodBox.setText(SmedAction.panelMain.mark.getRaconPeriod()); 226 rangeBox.setText(SmedAction.panelMain.mark.getRaconRange()); 227 sector1Box.setText(SmedAction.panelMain.mark.getRaconSector1()); 228 sector2Box.setText(SmedAction.panelMain.mark.getRaconSector2()); 229 aisButton.setSelected(SmedAction.panelMain.mark.getRadio() != Cat.NOROS); 230 aisButton.setBorderPainted(aisButton.isSelected()); 231 radioCatBox.setVisible(SmedAction.panelMain.mark.getRadio() != Cat.NOROS); 232 } 233 234 private JRadioButton getRadButton(JRadioButton button, int x, int y, int w, int h, String tip, Rtb rtb) { 235 button.setBounds(new Rectangle(x, y, w, h)); 236 button.setBorder(BorderFactory.createLoweredBevelBorder()); 237 button.setToolTipText(Messages.getString(tip)); 238 button.addActionListener(alRad); 239 radarButtons.add(button); 240 rads.put(rtb, button); 241 return button; 242 } 243 244 private void addROItem(String str, Cat cat) { 245 radioCats.put(cat, radioCatBox.getItemCount()); 246 radioCatBox.addItem(str); 247 } 29 private SmedAction dlg; 30 private JToggleButton aisButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/AISButton.png"))); 31 private ActionListener alAis = new ActionListener() { 32 @Override 33 public void actionPerformed(ActionEvent e) { 34 if (aisButton.isSelected()) { 35 radioCatBox.setVisible(true); 36 aisButton.setBorderPainted(true); 37 } else { 38 radioCatBox.setSelectedIndex(0); 39 radioCatBox.setVisible(false); 40 aisButton.setBorderPainted(false); 41 } 42 } 43 }; 44 private JComboBox<String> radioCatBox; 45 private EnumMap<Cat, Integer> radioCats = new EnumMap<>(Cat.class); 46 private ActionListener alRadioCatBox = new ActionListener() { 47 @Override 48 public void actionPerformed(ActionEvent e) { 49 for (Cat cat : radioCats.keySet()) { 50 int idx = radioCats.get(cat); 51 if (dlg.node != null && (idx == radioCatBox.getSelectedIndex())) { 52 SmedAction.panelMain.mark.setRadio(cat); 53 } 54 } 55 } 56 }; 57 private ButtonGroup radarButtons = new ButtonGroup(); 58 public JRadioButton noRadButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png"))); 59 public JRadioButton reflButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarReflectorButton.png"))); 60 public JRadioButton ramarkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RamarkButton.png"))); 61 public JRadioButton raconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RaconButton.png"))); 62 public JRadioButton leadingButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LeadingRaconButton.png"))); 63 private EnumMap<Rtb, JRadioButton> rads = new EnumMap<>(Rtb.class); 64 private ActionListener alRad = new ActionListener() { 65 @Override 66 public void actionPerformed(ActionEvent e) { 67 for (Rtb rtb : rads.keySet()) { 68 JRadioButton button = rads.get(rtb); 69 if (button.isSelected()) { 70 SmedAction.panelMain.mark.setRadar(rtb); 71 } 72 } 73 syncPanel(); 74 } 75 }; 76 public JLabel groupLabel; 77 public JTextField groupBox; 78 private FocusListener flGroup = new FocusAdapter() { 79 @Override 80 public void focusLost(FocusEvent e) { 81 SmedAction.panelMain.mark.setRaconGroup(groupBox.getText()); 82 } 83 }; 84 public JLabel periodLabel; 85 public JTextField periodBox; 86 private FocusListener flPeriod = new FocusAdapter() { 87 @Override 88 public void focusLost(FocusEvent e) { 89 SmedAction.panelMain.mark.setRaconPeriod(periodBox.getText()); 90 } 91 }; 92 public JLabel seqLabel; 93 public JTextField seqBox; 94 private FocusListener flSeq = new FocusAdapter() { 95 @Override 96 public void focusLost(FocusEvent e) { 97 SmedAction.panelMain.mark.setRaconSequence(seqBox.getText()); 98 } 99 }; 100 public JLabel rangeLabel; 101 public JTextField rangeBox; 102 private FocusListener flRange = new FocusAdapter() { 103 @Override 104 public void focusLost(FocusEvent e) { 105 SmedAction.panelMain.mark.setRaconRange(rangeBox.getText()); 106 } 107 }; 108 public JLabel sector1Label; 109 public JTextField sector1Box; 110 private FocusListener flSector1 = new FocusAdapter() { 111 @Override 112 public void focusLost(FocusEvent e) { 113 SmedAction.panelMain.mark.setRaconSector1(sector1Box.getText()); 114 } 115 }; 116 public JLabel sector2Label; 117 public JTextField sector2Box; 118 private FocusListener flSector2 = new FocusAdapter() { 119 @Override 120 public void focusLost(FocusEvent e) { 121 SmedAction.panelMain.mark.setRaconSector2(sector2Box.getText()); 122 } 123 }; 124 public JLabel sectorsLabel; 125 126 public PanelRadar(SmedAction dia) { 127 dlg = dia; 128 setLayout(null); 129 add(getRadButton(noRadButton, 0, 3, 27, 27, "NoRadar", Rtb.NORTB)); 130 add(getRadButton(reflButton, 0, 33, 27, 27, "RadarReflector", Rtb.REFLECTOR)); 131 add(getRadButton(ramarkButton, 0, 63, 27, 27, "Ramark", Rtb.RAMARK)); 132 add(getRadButton(raconButton, 0, 93, 27, 27, "Racon", Rtb.RACON)); 133 add(getRadButton(leadingButton, 0, 123, 27, 27, "LeadingRacon", Rtb.LEADING)); 134 135 groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER); 136 groupLabel.setBounds(new Rectangle(30, 0, 100, 20)); 137 add(groupLabel); 138 groupBox = new JTextField(); 139 groupBox.setBounds(new Rectangle(55, 20, 50, 20)); 140 groupBox.setHorizontalAlignment(SwingConstants.CENTER); 141 add(groupBox); 142 groupBox.addFocusListener(flGroup); 143 144 periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER); 145 periodLabel.setBounds(new Rectangle(130, 0, 100, 20)); 146 add(periodLabel); 147 periodBox = new JTextField(); 148 periodBox.setBounds(new Rectangle(155, 20, 50, 20)); 149 periodBox.setHorizontalAlignment(SwingConstants.CENTER); 150 add(periodBox); 151 periodBox.addFocusListener(flPeriod); 152 153 seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER); 154 seqLabel.setBounds(new Rectangle(30, 40, 100, 20)); 155 add(seqLabel); 156 seqBox = new JTextField(); 157 seqBox.setBounds(new Rectangle(55, 60, 50, 20)); 158 seqBox.setHorizontalAlignment(SwingConstants.CENTER); 159 add(seqBox); 160 seqBox.addFocusListener(flSeq); 161 162 rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER); 163 rangeLabel.setBounds(new Rectangle(130, 40, 100, 20)); 164 add(rangeLabel); 165 rangeBox = new JTextField(); 166 rangeBox.setBounds(new Rectangle(155, 60, 50, 20)); 167 rangeBox.setHorizontalAlignment(SwingConstants.CENTER); 168 add(rangeBox); 169 rangeBox.addFocusListener(flRange); 170 171 sectorsLabel = new JLabel(Messages.getString("VisibleSector"), SwingConstants.CENTER); 172 sectorsLabel.setBounds(new Rectangle(75, 85, 100, 20)); 173 add(sectorsLabel); 174 175 sector1Label = new JLabel(Messages.getString("Start"), SwingConstants.CENTER); 176 sector1Label.setBounds(new Rectangle(30, 100, 100, 20)); 177 add(sector1Label); 178 sector1Box = new JTextField(); 179 sector1Box.setBounds(new Rectangle(55, 120, 50, 20)); 180 sector1Box.setHorizontalAlignment(SwingConstants.CENTER); 181 add(sector1Box); 182 sector1Box.addFocusListener(flSector1); 183 184 sector2Label = new JLabel(Messages.getString("End"), SwingConstants.CENTER); 185 sector2Label.setBounds(new Rectangle(130, 100, 100, 20)); 186 add(sector2Label); 187 sector2Box = new JTextField(); 188 sector2Box.setBounds(new Rectangle(155, 120, 50, 20)); 189 sector2Box.setHorizontalAlignment(SwingConstants.CENTER); 190 add(sector2Box); 191 sector2Box.addFocusListener(flSector2); 192 193 aisButton.setBounds(new Rectangle(270, 3, 27, 27)); 194 aisButton.setBorder(BorderFactory.createLoweredBevelBorder()); 195 aisButton.setToolTipText("AIS"); 196 aisButton.addActionListener(alAis); 197 add(aisButton); 198 199 radioCatBox = new JComboBox<>(); 200 radioCatBox.setBounds(new Rectangle(210, 40, 150, 20)); 201 add(radioCatBox); 202 radioCatBox.addActionListener(alRadioCatBox); 203 addROItem("", Cat.NOROS); 204 addROItem(Messages.getString("CircularBeacon"), Cat.ROS_OMNI); 205 addROItem(Messages.getString("DirectionalBeacon"), Cat.ROS_DIRL); 206 addROItem(Messages.getString("RotatingBeacon"), Cat.ROS_ROTP); 207 addROItem(Messages.getString("ConsolBeacon"), Cat.ROS_CNSL); 208 addROItem(Messages.getString("DirectionFinding"), Cat.ROS_RDF); 209 addROItem(Messages.getString("QTGService"), Cat.ROS_QTG); 210 addROItem(Messages.getString("AeronaticalBeacon"), Cat.ROS_AERO); 211 addROItem(Messages.getString("Decca"), Cat.ROS_DECA); 212 addROItem(Messages.getString("LoranC"), Cat.ROS_LORN); 213 addROItem(Messages.getString("DGPS"), Cat.ROS_DGPS); 214 addROItem(Messages.getString("Toran"), Cat.ROS_TORN); 215 addROItem(Messages.getString("Omega"), Cat.ROS_OMGA); 216 addROItem(Messages.getString("Syledis"), Cat.ROS_SYLD); 217 addROItem(Messages.getString("Chiaka"), Cat.ROS_CHKA); 218 addROItem(Messages.getString("PublicCommunication"), Cat.ROS_PCOM); 219 addROItem(Messages.getString("CommercialBroadcast"), Cat.ROS_COMB); 220 addROItem(Messages.getString("Facsimile"), Cat.ROS_FACS); 221 addROItem(Messages.getString("TimeSignal"), Cat.ROS_TIME); 222 addROItem(Messages.getString("AIS"), Cat.ROS_PAIS); 223 addROItem(Messages.getString("S-AIS"), Cat.ROS_SAIS); 224 radioCatBox.setVisible(false); 225 } 226 227 public void syncPanel() { 228 boolean rad = ((SmedAction.panelMain.mark.getRadar() != Rtb.NORTB) && (SmedAction.panelMain.mark.getRadar() != Rtb.REFLECTOR)); 229 groupLabel.setVisible(rad); 230 groupBox.setVisible(rad); 231 periodLabel.setVisible(rad); 232 periodBox.setVisible(rad); 233 seqLabel.setVisible(rad); 234 seqBox.setVisible(rad); 235 rangeLabel.setVisible(rad); 236 rangeBox.setVisible(rad); 237 sector1Label.setVisible(rad); 238 sector1Box.setVisible(rad); 239 sector2Label.setVisible(rad); 240 sector2Box.setVisible(rad); 241 sectorsLabel.setVisible(rad); 242 for (Rtb rtb : rads.keySet()) { 243 rads.get(rtb).setBorderPainted(SmedAction.panelMain.mark.getRadar() == rtb); 244 } 245 groupBox.setText(SmedAction.panelMain.mark.getRaconGroup()); 246 seqBox.setText(SmedAction.panelMain.mark.getRaconSequence()); 247 periodBox.setText(SmedAction.panelMain.mark.getRaconPeriod()); 248 rangeBox.setText(SmedAction.panelMain.mark.getRaconRange()); 249 sector1Box.setText(SmedAction.panelMain.mark.getRaconSector1()); 250 sector2Box.setText(SmedAction.panelMain.mark.getRaconSector2()); 251 aisButton.setSelected(SmedAction.panelMain.mark.getRadio() != Cat.NOROS); 252 aisButton.setBorderPainted(aisButton.isSelected()); 253 radioCatBox.setVisible(SmedAction.panelMain.mark.getRadio() != Cat.NOROS); 254 } 255 256 private JRadioButton getRadButton(JRadioButton button, int x, int y, int w, int h, String tip, Rtb rtb) { 257 button.setBounds(new Rectangle(x, y, w, h)); 258 button.setBorder(BorderFactory.createLoweredBevelBorder()); 259 button.setToolTipText(Messages.getString(tip)); 260 button.addActionListener(alRad); 261 radarButtons.add(button); 262 rads.put(rtb, button); 263 return button; 264 } 265 266 private void addROItem(String str, Cat cat) { 267 radioCats.put(cat, radioCatBox.getItemCount()); 268 radioCatBox.addItem(str); 269 } 248 270 } -
applications/editors/josm/plugins/smed/src/panels/PanelSaw.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.util.EnumMap; 6 7 7 import java.util.*; 8 import javax.swing.BorderFactory; 9 import javax.swing.ButtonGroup; 10 import javax.swing.ImageIcon; 11 import javax.swing.JPanel; 12 import javax.swing.JRadioButton; 8 13 9 14 import messages.Messages; 15 import seamarks.SeaMark.Col; 16 import seamarks.SeaMark.Obj; 17 import seamarks.SeaMark.Pat; 18 import seamarks.SeaMark.Shp; 10 19 import smed.SmedAction; 11 import seamarks.SeaMark.*;12 20 13 21 public class PanelSaw extends JPanel { 14 22 15 private SmedAction dlg; 16 public ButtonGroup shapeButtons = new ButtonGroup(); 17 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 18 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 19 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 20 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 21 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 22 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 23 public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class); 24 public ActionListener alShape = new ActionListener() { 25 public void actionPerformed(java.awt.event.ActionEvent e) { 26 for (Shp shp : shapes.keySet()) { 27 JRadioButton button = shapes.get(shp); 28 if (button.isSelected()) { 29 SmedAction.panelMain.mark.setShape(shp); 30 SmedAction.panelMain.mark.setObject(objects.get(shp)); 31 button.setBorderPainted(true); 32 } else 33 button.setBorderPainted(false); 34 } 35 if (SmedAction.panelMain.mark.testValid()) { 36 SmedAction.panelMain.panelChan.topmarkButton.setVisible(true); 37 SmedAction.panelMain.mark.setObjPattern(Pat.VSTRP); 38 SmedAction.panelMain.mark.setObjColour(Col.RED); 39 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 40 } else { 41 SmedAction.panelMain.panelChan.topmarkButton.setVisible(false); 42 } 43 SmedAction.panelMain.panelMore.syncPanel(); 44 } 45 }; 23 private SmedAction dlg; 24 public ButtonGroup shapeButtons = new ButtonGroup(); 25 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 26 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 27 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 28 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 29 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 30 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 31 public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class); 32 public ActionListener alShape = new ActionListener() { 33 @Override 34 public void actionPerformed(ActionEvent e) { 35 for (Shp shp : shapes.keySet()) { 36 JRadioButton button = shapes.get(shp); 37 if (button.isSelected()) { 38 SmedAction.panelMain.mark.setShape(shp); 39 SmedAction.panelMain.mark.setObject(objects.get(shp)); 40 button.setBorderPainted(true); 41 } else { 42 button.setBorderPainted(false); 43 } 44 } 45 if (SmedAction.panelMain.mark.testValid()) { 46 SmedAction.panelMain.panelChan.topmarkButton.setVisible(true); 47 SmedAction.panelMain.mark.setObjPattern(Pat.VSTRP); 48 SmedAction.panelMain.mark.setObjColour(Col.RED); 49 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 50 } else { 51 SmedAction.panelMain.panelChan.topmarkButton.setVisible(false); 52 } 53 SmedAction.panelMain.panelMore.syncPanel(); 54 } 55 }; 46 56 47 48 49 50 51 52 53 54 55 57 public PanelSaw(SmedAction dia) { 58 dlg = dia; 59 setLayout(null); 60 add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSAW)); 61 add(getShapeButton(sparButton, 0, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYSAW)); 62 add(getShapeButton(sphereButton, 0, 64, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSAW)); 63 add(getShapeButton(floatButton, 0, 96, 34, 32, "Float", Shp.FLOAT, Obj.FLTSAW)); 64 add(getShapeButton(beaconButton, 0, 128, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSAW)); 65 } 56 66 57 public void syncPanel() { 58 for (Shp shp : shapes.keySet()) { 59 JRadioButton button = shapes.get(shp); 60 if (SmedAction.panelMain.mark.getShape() == shp) { 61 button.setBorderPainted(true); 62 } else 63 button.setBorderPainted(false); 64 } 65 SmedAction.panelMain.mark.testValid(); 66 } 67 68 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) { 69 button.setBounds(new Rectangle(x, y, w, h)); 70 button.setBorder(BorderFactory.createLoweredBevelBorder()); 71 button.setToolTipText(Messages.getString(tip)); 72 button.addActionListener(alShape); 73 shapeButtons.add(button); 74 shapes.put(shp, button); 75 objects.put(shp, obj); 76 return button; 77 } 67 public void syncPanel() { 68 for (Shp shp : shapes.keySet()) { 69 JRadioButton button = shapes.get(shp); 70 if (SmedAction.panelMain.mark.getShape() == shp) { 71 button.setBorderPainted(true); 72 } else { 73 button.setBorderPainted(false); 74 } 75 } 76 SmedAction.panelMain.mark.testValid(); 77 } 78 79 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) { 80 button.setBounds(new Rectangle(x, y, w, h)); 81 button.setBorder(BorderFactory.createLoweredBevelBorder()); 82 button.setToolTipText(Messages.getString(tip)); 83 button.addActionListener(alShape); 84 shapeButtons.add(button); 85 shapes.put(shp, button); 86 objects.put(shp, obj); 87 return button; 88 } 78 89 79 90 } -
applications/editors/josm/plugins/smed/src/panels/PanelSectors.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 3 import java.awt.BorderLayout; 4 import java.awt.Component; 5 import java.awt.GridLayout; 6 import java.awt.event.ActionEvent; 7 import java.awt.event.ActionListener; 5 8 import java.util.EnumMap; 6 9 7 import javax.swing.*; 8 import javax.swing.table.*; 10 import javax.swing.DefaultCellEditor; 11 import javax.swing.ImageIcon; 12 import javax.swing.JButton; 13 import javax.swing.JComboBox; 14 import javax.swing.JFrame; 15 import javax.swing.JLabel; 16 import javax.swing.JPanel; 17 import javax.swing.JScrollPane; 18 import javax.swing.JTable; 19 import javax.swing.SwingConstants; 20 import javax.swing.table.AbstractTableModel; 21 import javax.swing.table.DefaultTableCellRenderer; 22 import javax.swing.table.TableCellRenderer; 23 import javax.swing.table.TableColumn; 24 import javax.swing.table.TableModel; 9 25 10 26 import messages.Messages; 27 import seamarks.SeaMark; 28 import seamarks.SeaMark.Att; 29 import seamarks.SeaMark.Col; 30 import seamarks.SeaMark.Exh; 31 import seamarks.SeaMark.Lit; 32 import seamarks.SeaMark.Vis; 11 33 import smed.SmedAction; 12 import seamarks.SeaMark;13 import seamarks.SeaMark.*;14 34 15 35 public class PanelSectors extends JFrame { 16 36 17 private SmedAction dlg; 18 private JPanel panel; 19 private TableModel model; 20 private JTable table; 21 22 public JButton minusButton; 23 private ActionListener alMinusButton = new ActionListener() { 24 public void actionPerformed(java.awt.event.ActionEvent e) { 25 if ((getSectorCount() > 1) && (table.getSelectedRow() != 0)) 26 deleteSector(table.getSelectedRow()); 27 } 28 }; 29 public JButton plusButton; 30 private ActionListener alPlusButton = new ActionListener() { 31 public void actionPerformed(java.awt.event.ActionEvent e) { 32 if (table.getSelectedRow() < 0) 33 addSector(table.getRowCount()); 34 else 35 addSector(table.getSelectedRow()+1); 36 } 37 }; 38 public JComboBox<ImageIcon> colourBox; 39 public EnumMap<Col, ImageIcon> colours = new EnumMap<>(Col.class); 40 public JComboBox<String> visibilityBox; 41 public EnumMap<Vis, String> visibilities = new EnumMap<>(Vis.class); 42 public JComboBox<String> exhibitionBox; 43 public EnumMap<Exh, String> exhibitions = new EnumMap<>(Exh.class); 44 45 public PanelSectors(SmedAction dia) { 46 super(Messages.getString("SectorTable")); 47 dlg = dia; 48 setLayout(null); 49 setSize(900, 100); 50 setAlwaysOnTop(true); 51 setLocation(450, 0); 52 setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 53 minusButton = new JButton(new ImageIcon(getClass().getResource("/images/MinusButton.png"))); 54 minusButton.setBounds(0, 0, 32, 34); 55 minusButton.addActionListener(alMinusButton); 56 add(minusButton); 57 plusButton = new JButton(new ImageIcon(getClass().getResource("/images/PlusButton.png"))); 58 plusButton.setBounds(0, 34, 32, 34); 59 plusButton.addActionListener(alPlusButton); 60 add(plusButton); 61 panel = new JPanel(new BorderLayout()); 62 panel.setBounds(40, 0, 860, 512); 63 model = new SectorTable(); 64 table = new JTable(model); 65 table.setBounds(0, 0, 860, 34); 66 table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 67 panel.add(new JScrollPane(table)); 68 getContentPane().add(panel); 69 70 table.setSize(860, ((table.getRowCount() * 16) + 28)); 71 72 table.setDefaultRenderer(String.class, new CentreRenderer()); 73 table.getColumnModel().getColumn(1).setCellRenderer(new ColourCellRenderer()); 74 75 TableColumn colColumn = table.getColumnModel().getColumn(1); 76 colourBox = new JComboBox<>(); 77 addColItem(new ImageIcon(getClass().getResource("/images/DelButton.png")), Col.UNKCOL); 78 addColItem(new ImageIcon(getClass().getResource("/images/WhiteButton.png")), Col.WHITE); 79 addColItem(new ImageIcon(getClass().getResource("/images/RedButton.png")), Col.RED); 80 addColItem(new ImageIcon(getClass().getResource("/images/GreenButton.png")), Col.GREEN); 81 addColItem(new ImageIcon(getClass().getResource("/images/YellowButton.png")), Col.YELLOW); 82 addColItem(new ImageIcon(getClass().getResource("/images/OrangeButton.png")), Col.ORANGE); 83 addColItem(new ImageIcon(getClass().getResource("/images/AmberButton.png")), Col.AMBER); 84 addColItem(new ImageIcon(getClass().getResource("/images/BlueButton.png")), Col.BLUE); 85 addColItem(new ImageIcon(getClass().getResource("/images/VioletButton.png")), Col.VIOLET); 86 colColumn.setCellEditor(new DefaultCellEditor(colourBox)); 87 88 TableColumn visColumn = table.getColumnModel().getColumn(12); 89 visibilityBox = new JComboBox<>(); 90 addVisibItem("", Vis.UNKVIS); 91 addVisibItem(Messages.getString("Intensified"), Vis.INTEN); 92 addVisibItem(Messages.getString("Unintensified"), Vis.UNINTEN); 93 addVisibItem(Messages.getString("PartiallyObscured"), Vis.PARTOBS); 94 visColumn.setCellEditor(new DefaultCellEditor(visibilityBox)); 95 96 TableColumn exhColumn = table.getColumnModel().getColumn(13); 97 exhibitionBox = new JComboBox<>(); 98 addExhibItem("", Exh.UNKEXH); 99 addExhibItem(Messages.getString("24h"), Exh.H24); 100 addExhibItem(Messages.getString("Day"), Exh.DAY); 101 addExhibItem(Messages.getString("Night"), Exh.NIGHT); 102 addExhibItem(Messages.getString("Fog"), Exh.FOG); 103 exhColumn.setCellEditor(new DefaultCellEditor(exhibitionBox)); 104 } 105 106 private class SectorTable extends AbstractTableModel { 107 108 private String[] headings = { Messages.getString("Sector"), Messages.getString("Colour"), Messages.getString("Character"), 109 Messages.getString("Group"), Messages.getString("Sequence"), Messages.getString("Period"), Messages.getString("Directional"), 110 Messages.getString("Start"), Messages.getString("End"), Messages.getString("Radius"), Messages.getString("Height"), 111 Messages.getString("Range"), Messages.getString("Visibility"), Messages.getString("Exhibition") }; 112 113 public SectorTable() { 114 } 115 116 public String getColumnName(int col) { 117 return headings[col]; 118 } 119 120 public int getColumnCount() { 121 return headings.length; 122 } 123 124 public int getRowCount() { 125 if (SmedAction.panelMain == null) 126 return 1; 127 else 128 return SmedAction.panelMain.mark.getSectorCount(); 129 } 130 131 public boolean isCellEditable(int row, int col) { 132 return ((col > 0) && (row > 0)); 133 } 134 135 public Class getColumnClass(int col) { 136 switch (col) { 137 case 1: 138 return Col.class; 139 case 6: 140 return Boolean.class; 141 default: 142 return String.class; 143 } 144 } 145 146 public Object getValueAt(int row, int col) { 147 switch (col) { 148 case 0: 149 if (row == 0) 150 return Messages.getString("Default"); 151 else 152 return row; 153 case 1: 154 if (((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, row)).contains("Al")) { 155 if (SmedAction.panelMain.mark.getLightAtt(Att.COL, row) == Col.UNKCOL) { 156 return Col.UNKCOL; 157 } else { 158 return SmedAction.panelMain.mark.getLightAtt(Att.ALT, row); 159 } 160 } else { 161 return SmedAction.panelMain.mark.getLightAtt(Att.COL, row); 162 } 163 case 6: 164 return (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR); 165 case 7: 166 case 8: 167 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR) 168 return SmedAction.panelMain.mark.getLightAtt(Att.ORT, row); 169 else 170 return SmedAction.panelMain.mark.getLightAtt(col - 1, row); 171 case 12: 172 return visibilities.get(SmedAction.panelMain.mark.getLightAtt(Att.VIS, row)); 173 case 13: 174 return exhibitions.get(SmedAction.panelMain.mark.getLightAtt(Att.EXH, row)); 175 default: 176 return SmedAction.panelMain.mark.getLightAtt(col - 1, row); 177 } 178 } 179 180 public void setValueAt(Object value, int row, int col) { 181 switch (col) { 182 case 1: 183 for (Col colour : colours.keySet()) { 184 ImageIcon img = colours.get(colour); 185 if (img == value) 186 if (((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, row)).contains("Al")) { 187 if (((colour == Col.UNKCOL) && (SmedAction.panelMain.mark.getLightAtt(Att.ALT, row) == Col.UNKCOL)) 188 || (SmedAction.panelMain.mark.getLightAtt(Att.COL, row) == Col.UNKCOL)) { 189 SmedAction.panelMain.mark.setLightAtt(Att.COL, row, colour); 190 } else { 191 SmedAction.panelMain.mark.setLightAtt(Att.ALT, row, colour); 192 } 193 } else { 194 SmedAction.panelMain.mark.setLightAtt(Att.COL, row, colour); 195 } 196 } 197 break; 198 case 5: 199 case 9: 200 case 10: 201 case 11: 202 SmedAction.panelMain.mark.setLightAtt(col - 1, row, value); 203 break; 204 case 6: 205 if ((Boolean) value == true) { 206 SmedAction.panelMain.mark.setLightAtt(Att.LIT, row, Lit.DIR); 207 SmedAction.panelMain.mark.setLightAtt(Att.BEG, row, ""); 208 SmedAction.panelMain.mark.setLightAtt(Att.END, row, ""); 209 } else { 210 SmedAction.panelMain.mark.setLightAtt(Att.LIT, row, Lit.UNKLIT); 211 SmedAction.panelMain.mark.setLightAtt(Att.ORT, row, ""); 212 } 213 break; 214 case 7: 215 case 8: 216 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR) { 217 SmedAction.panelMain.mark.setLightAtt(Att.ORT, row, value); 218 } else { 219 SmedAction.panelMain.mark.setLightAtt(col - 1, row, value); 220 } 221 break; 222 case 12: 223 for (Vis vis : visibilities.keySet()) { 224 String str = visibilities.get(vis); 225 if (str.equals(value)) 226 SmedAction.panelMain.mark.setLightAtt(Att.VIS, row, vis); 227 } 228 break; 229 case 13: 230 for (Exh exh : exhibitions.keySet()) { 231 String str = exhibitions.get(exh); 232 if (str.equals(value)) 233 SmedAction.panelMain.mark.setLightAtt(Att.EXH, row, exh); 234 } 235 break; 236 default: 237 SmedAction.panelMain.mark.setLightAtt(col - 1, row, value); 238 } 239 } 240 } 241 242 static class CentreRenderer extends DefaultTableCellRenderer { 243 public CentreRenderer() { 244 super(); 245 setHorizontalAlignment(SwingConstants.CENTER); 246 } 247 } 248 249 public class ColourCellRenderer extends JPanel implements TableCellRenderer { 250 private JLabel col1Label; 251 private JLabel col2Label; 252 public ColourCellRenderer() { 253 super(); 254 setLayout(new GridLayout(1, 2, 0, 0)); 255 col1Label = new JLabel(); 256 col1Label.setOpaque(true); 257 add(col1Label); 258 col2Label = new JLabel(); 259 col2Label.setOpaque(true); 260 add(col2Label); 261 } 262 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { 263 if (!((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, rowIndex)).contains("Al")) { 264 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, rowIndex))); 265 } else { 266 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, rowIndex))); 267 } 268 col1Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, rowIndex))); 269 return this; 270 } 271 } 272 273 public int getSectorCount() { 274 return model.getRowCount(); 275 } 276 277 public void addSector(int idx) { 278 SmedAction.panelMain.mark.addLight(idx); 279 table.setSize(860, ((table.getRowCount() * 16) + 28)); 280 if (table.getRowCount() > 3) { 281 setSize(900, ((table.getRowCount() * 16) + 48)); 282 } else { 283 setSize(900, 100); 284 } 285 } 286 287 public void deleteSector(int idx) { 288 if (idx > 0) { 289 SmedAction.panelMain.mark.delLight(idx); 290 table.setSize(860, ((table.getRowCount() * 16) + 28)); 291 if (table.getRowCount() > 3) { 292 setSize(900, ((table.getRowCount() * 16) + 48)); 293 } else { 294 setSize(900, 100); 295 } 296 } 297 } 298 299 public void syncPanel() { 300 table.updateUI(); 301 table.setSize(860, ((table.getRowCount() * 16) + 28)); 302 if (table.getRowCount() > 3) { 303 setSize(900, ((table.getRowCount() * 16) + 48)); 304 } else { 305 setSize(900, 100); 306 } 307 } 308 309 private void addColItem(ImageIcon img, Col col) { 310 colours.put(col, img); 311 colourBox.addItem(img); 312 } 313 314 private void addVisibItem(String str, Vis vis) { 315 visibilities.put(vis, str); 316 visibilityBox.addItem(str); 317 } 318 319 private void addExhibItem(String str, Exh exh) { 320 exhibitions.put(exh, str); 321 exhibitionBox.addItem(str); 322 } 37 private SmedAction dlg; 38 private JPanel panel; 39 private TableModel model; 40 private JTable table; 41 42 public JButton minusButton; 43 private ActionListener alMinusButton = new ActionListener() { 44 @Override 45 public void actionPerformed(ActionEvent e) { 46 if ((getSectorCount() > 1) && (table.getSelectedRow() != 0)) { 47 deleteSector(table.getSelectedRow()); 48 } 49 } 50 }; 51 public JButton plusButton; 52 private ActionListener alPlusButton = new ActionListener() { 53 @Override 54 public void actionPerformed(ActionEvent e) { 55 if (table.getSelectedRow() < 0) { 56 addSector(table.getRowCount()); 57 } else { 58 addSector(table.getSelectedRow()+1); 59 } 60 } 61 }; 62 public JComboBox<ImageIcon> colourBox; 63 public EnumMap<Col, ImageIcon> colours = new EnumMap<>(Col.class); 64 public JComboBox<String> visibilityBox; 65 public EnumMap<Vis, String> visibilities = new EnumMap<>(Vis.class); 66 public JComboBox<String> exhibitionBox; 67 public EnumMap<Exh, String> exhibitions = new EnumMap<>(Exh.class); 68 69 public PanelSectors(SmedAction dia) { 70 super(Messages.getString("SectorTable")); 71 dlg = dia; 72 setLayout(null); 73 setSize(900, 100); 74 setAlwaysOnTop(true); 75 setLocation(450, 0); 76 setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 77 minusButton = new JButton(new ImageIcon(getClass().getResource("/images/MinusButton.png"))); 78 minusButton.setBounds(0, 0, 32, 34); 79 minusButton.addActionListener(alMinusButton); 80 add(minusButton); 81 plusButton = new JButton(new ImageIcon(getClass().getResource("/images/PlusButton.png"))); 82 plusButton.setBounds(0, 34, 32, 34); 83 plusButton.addActionListener(alPlusButton); 84 add(plusButton); 85 panel = new JPanel(new BorderLayout()); 86 panel.setBounds(40, 0, 860, 512); 87 model = new SectorTable(); 88 table = new JTable(model); 89 table.setBounds(0, 0, 860, 34); 90 table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 91 panel.add(new JScrollPane(table)); 92 getContentPane().add(panel); 93 94 table.setSize(860, ((table.getRowCount() * 16) + 28)); 95 96 table.setDefaultRenderer(String.class, new CentreRenderer()); 97 table.getColumnModel().getColumn(1).setCellRenderer(new ColourCellRenderer()); 98 99 TableColumn colColumn = table.getColumnModel().getColumn(1); 100 colourBox = new JComboBox<>(); 101 addColItem(new ImageIcon(getClass().getResource("/images/DelButton.png")), Col.UNKCOL); 102 addColItem(new ImageIcon(getClass().getResource("/images/WhiteButton.png")), Col.WHITE); 103 addColItem(new ImageIcon(getClass().getResource("/images/RedButton.png")), Col.RED); 104 addColItem(new ImageIcon(getClass().getResource("/images/GreenButton.png")), Col.GREEN); 105 addColItem(new ImageIcon(getClass().getResource("/images/YellowButton.png")), Col.YELLOW); 106 addColItem(new ImageIcon(getClass().getResource("/images/OrangeButton.png")), Col.ORANGE); 107 addColItem(new ImageIcon(getClass().getResource("/images/AmberButton.png")), Col.AMBER); 108 addColItem(new ImageIcon(getClass().getResource("/images/BlueButton.png")), Col.BLUE); 109 addColItem(new ImageIcon(getClass().getResource("/images/VioletButton.png")), Col.VIOLET); 110 colColumn.setCellEditor(new DefaultCellEditor(colourBox)); 111 112 TableColumn visColumn = table.getColumnModel().getColumn(12); 113 visibilityBox = new JComboBox<>(); 114 addVisibItem("", Vis.UNKVIS); 115 addVisibItem(Messages.getString("Intensified"), Vis.INTEN); 116 addVisibItem(Messages.getString("Unintensified"), Vis.UNINTEN); 117 addVisibItem(Messages.getString("PartiallyObscured"), Vis.PARTOBS); 118 visColumn.setCellEditor(new DefaultCellEditor(visibilityBox)); 119 120 TableColumn exhColumn = table.getColumnModel().getColumn(13); 121 exhibitionBox = new JComboBox<>(); 122 addExhibItem("", Exh.UNKEXH); 123 addExhibItem(Messages.getString("24h"), Exh.H24); 124 addExhibItem(Messages.getString("Day"), Exh.DAY); 125 addExhibItem(Messages.getString("Night"), Exh.NIGHT); 126 addExhibItem(Messages.getString("Fog"), Exh.FOG); 127 exhColumn.setCellEditor(new DefaultCellEditor(exhibitionBox)); 128 } 129 130 private class SectorTable extends AbstractTableModel { 131 132 private String[] headings = { Messages.getString("Sector"), Messages.getString("Colour"), Messages.getString("Character"), 133 Messages.getString("Group"), Messages.getString("Sequence"), Messages.getString("Period"), Messages.getString("Directional"), 134 Messages.getString("Start"), Messages.getString("End"), Messages.getString("Radius"), Messages.getString("Height"), 135 Messages.getString("Range"), Messages.getString("Visibility"), Messages.getString("Exhibition") }; 136 137 public SectorTable() { 138 } 139 140 @Override 141 public String getColumnName(int col) { 142 return headings[col]; 143 } 144 145 @Override 146 public int getColumnCount() { 147 return headings.length; 148 } 149 150 @Override 151 public int getRowCount() { 152 if (SmedAction.panelMain == null) 153 return 1; 154 else 155 return SmedAction.panelMain.mark.getSectorCount(); 156 } 157 158 @Override 159 public boolean isCellEditable(int row, int col) { 160 return ((col > 0) && (row > 0)); 161 } 162 163 @Override 164 public Class getColumnClass(int col) { 165 switch (col) { 166 case 1: 167 return Col.class; 168 case 6: 169 return Boolean.class; 170 default: 171 return String.class; 172 } 173 } 174 175 @Override 176 public Object getValueAt(int row, int col) { 177 switch (col) { 178 case 0: 179 if (row == 0) 180 return Messages.getString("Default"); 181 else 182 return row; 183 case 1: 184 if (((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, row)).contains("Al")) { 185 if (SmedAction.panelMain.mark.getLightAtt(Att.COL, row) == Col.UNKCOL) 186 return Col.UNKCOL; 187 else 188 return SmedAction.panelMain.mark.getLightAtt(Att.ALT, row); 189 } else 190 return SmedAction.panelMain.mark.getLightAtt(Att.COL, row); 191 case 6: 192 return (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR); 193 case 7: 194 case 8: 195 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR) 196 return SmedAction.panelMain.mark.getLightAtt(Att.ORT, row); 197 else 198 return SmedAction.panelMain.mark.getLightAtt(col - 1, row); 199 case 12: 200 return visibilities.get(SmedAction.panelMain.mark.getLightAtt(Att.VIS, row)); 201 case 13: 202 return exhibitions.get(SmedAction.panelMain.mark.getLightAtt(Att.EXH, row)); 203 default: 204 return SmedAction.panelMain.mark.getLightAtt(col - 1, row); 205 } 206 } 207 208 @Override 209 public void setValueAt(Object value, int row, int col) { 210 switch (col) { 211 case 1: 212 for (Col colour : colours.keySet()) { 213 ImageIcon img = colours.get(colour); 214 if (img == value) 215 if (((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, row)).contains("Al")) { 216 if (((colour == Col.UNKCOL) && (SmedAction.panelMain.mark.getLightAtt(Att.ALT, row) == Col.UNKCOL)) 217 || (SmedAction.panelMain.mark.getLightAtt(Att.COL, row) == Col.UNKCOL)) { 218 SmedAction.panelMain.mark.setLightAtt(Att.COL, row, colour); 219 } else { 220 SmedAction.panelMain.mark.setLightAtt(Att.ALT, row, colour); 221 } 222 } else { 223 SmedAction.panelMain.mark.setLightAtt(Att.COL, row, colour); 224 } 225 } 226 break; 227 case 5: 228 case 9: 229 case 10: 230 case 11: 231 SmedAction.panelMain.mark.setLightAtt(col - 1, row, value); 232 break; 233 case 6: 234 if ((Boolean) value == true) { 235 SmedAction.panelMain.mark.setLightAtt(Att.LIT, row, Lit.DIR); 236 SmedAction.panelMain.mark.setLightAtt(Att.BEG, row, ""); 237 SmedAction.panelMain.mark.setLightAtt(Att.END, row, ""); 238 } else { 239 SmedAction.panelMain.mark.setLightAtt(Att.LIT, row, Lit.UNKLIT); 240 SmedAction.panelMain.mark.setLightAtt(Att.ORT, row, ""); 241 } 242 break; 243 case 7: 244 case 8: 245 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR) { 246 SmedAction.panelMain.mark.setLightAtt(Att.ORT, row, value); 247 } else { 248 SmedAction.panelMain.mark.setLightAtt(col - 1, row, value); 249 } 250 break; 251 case 12: 252 for (Vis vis : visibilities.keySet()) { 253 String str = visibilities.get(vis); 254 if (str.equals(value)) { 255 SmedAction.panelMain.mark.setLightAtt(Att.VIS, row, vis); 256 } 257 } 258 break; 259 case 13: 260 for (Exh exh : exhibitions.keySet()) { 261 String str = exhibitions.get(exh); 262 if (str.equals(value)) { 263 SmedAction.panelMain.mark.setLightAtt(Att.EXH, row, exh); 264 } 265 } 266 break; 267 default: 268 SmedAction.panelMain.mark.setLightAtt(col - 1, row, value); 269 } 270 } 271 } 272 273 static class CentreRenderer extends DefaultTableCellRenderer { 274 public CentreRenderer() { 275 super(); 276 setHorizontalAlignment(SwingConstants.CENTER); 277 } 278 } 279 280 public class ColourCellRenderer extends JPanel implements TableCellRenderer { 281 private JLabel col1Label; 282 private JLabel col2Label; 283 public ColourCellRenderer() { 284 super(); 285 setLayout(new GridLayout(1, 2, 0, 0)); 286 col1Label = new JLabel(); 287 col1Label.setOpaque(true); 288 add(col1Label); 289 col2Label = new JLabel(); 290 col2Label.setOpaque(true); 291 add(col2Label); 292 } 293 @Override 294 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { 295 if (!((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, rowIndex)).contains("Al")) { 296 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, rowIndex))); 297 } else { 298 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, rowIndex))); 299 } 300 col1Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, rowIndex))); 301 return this; 302 } 303 } 304 305 public int getSectorCount() { 306 return model.getRowCount(); 307 } 308 309 public void addSector(int idx) { 310 SmedAction.panelMain.mark.addLight(idx); 311 table.setSize(860, ((table.getRowCount() * 16) + 28)); 312 if (table.getRowCount() > 3) { 313 setSize(900, ((table.getRowCount() * 16) + 48)); 314 } else { 315 setSize(900, 100); 316 } 317 } 318 319 public void deleteSector(int idx) { 320 if (idx > 0) { 321 SmedAction.panelMain.mark.delLight(idx); 322 table.setSize(860, ((table.getRowCount() * 16) + 28)); 323 if (table.getRowCount() > 3) { 324 setSize(900, ((table.getRowCount() * 16) + 48)); 325 } else { 326 setSize(900, 100); 327 } 328 } 329 } 330 331 public void syncPanel() { 332 table.updateUI(); 333 table.setSize(860, ((table.getRowCount() * 16) + 28)); 334 if (table.getRowCount() > 3) { 335 setSize(900, ((table.getRowCount() * 16) + 48)); 336 } else { 337 setSize(900, 100); 338 } 339 } 340 341 private void addColItem(ImageIcon img, Col col) { 342 colours.put(col, img); 343 colourBox.addItem(img); 344 } 345 346 private void addVisibItem(String str, Vis vis) { 347 visibilities.put(vis, str); 348 visibilityBox.addItem(str); 349 } 350 351 private void addExhibItem(String str, Exh exh) { 352 exhibitions.put(exh, str); 353 exhibitionBox.addItem(str); 354 } 323 355 324 356 } -
applications/editors/josm/plugins/smed/src/panels/PanelSpec.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 5 6 import javax.swing.*; 7 8 import java.util.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.util.EnumMap; 7 8 import javax.swing.BorderFactory; 9 import javax.swing.ButtonGroup; 10 import javax.swing.ImageIcon; 11 import javax.swing.JComboBox; 12 import javax.swing.JLabel; 13 import javax.swing.JPanel; 14 import javax.swing.JRadioButton; 15 import javax.swing.JToggleButton; 16 import javax.swing.SwingConstants; 9 17 10 18 import messages.Messages; 19 import seamarks.SeaMark; 20 import seamarks.SeaMark.Cat; 21 import seamarks.SeaMark.Col; 22 import seamarks.SeaMark.Ent; 23 import seamarks.SeaMark.Obj; 24 import seamarks.SeaMark.Pat; 25 import seamarks.SeaMark.Shp; 26 import seamarks.SeaMark.Top; 11 27 import smed.SmedAction; 12 import seamarks.SeaMark;13 import seamarks.SeaMark.*;14 28 15 29 public class PanelSpec extends JPanel { 16 30 17 private SmedAction dlg; 18 public JLabel categoryLabel; 19 public JComboBox<String> categoryBox; 20 public EnumMap<Cat, Integer> categories = new EnumMap<>(Cat.class); 21 private ActionListener alCategoryBox = new ActionListener() { 22 public void actionPerformed(java.awt.event.ActionEvent e) { 23 for (Cat cat : categories.keySet()) { 24 int idx = categories.get(cat); 25 if (dlg.node != null && (idx == categoryBox.getSelectedIndex())) 26 SmedAction.panelMain.mark.setCategory(cat); 27 } 28 } 29 }; 30 public JComboBox<String> mooringBox; 31 public EnumMap<Cat, Integer> moorings = new EnumMap<>(Cat.class); 32 private ActionListener alMooringBox = new ActionListener() { 33 public void actionPerformed(java.awt.event.ActionEvent e) { 34 for (Cat cat : moorings.keySet()) { 35 int idx = moorings.get(cat); 36 if (dlg.node != null && (idx == mooringBox.getSelectedIndex())) { 37 SmedAction.panelMain.mark.setCategory(cat); 38 if ((cat == Cat.INB_CALM) || (cat == Cat.INB_SBM)) { 39 SmedAction.panelMain.mark.setObject(Obj.BOYINB); 40 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 41 } else { 42 SmedAction.panelMain.mark.setObject(Obj.MORFAC); 43 if (cat != Cat.MOR_BUOY) 44 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 45 } 46 } 47 } 48 if (dlg.node != null) syncPanel(); 49 } 50 }; 51 public ButtonGroup shapeButtons = new ButtonGroup(); 52 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 53 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 54 public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png"))); 55 public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png"))); 56 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 57 public JRadioButton barrelButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BarrelButton.png"))); 58 public JRadioButton superButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SuperButton.png"))); 59 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 60 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 61 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 62 public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png"))); 63 public JRadioButton cairnButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CairnButton.png"))); 64 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 65 public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class); 66 public ActionListener alShape = new ActionListener() { 67 public void actionPerformed(java.awt.event.ActionEvent e) { 68 if ((SmedAction.panelMain.mark.getObject() != Obj.MORFAC) || (SmedAction.panelMain.mark.getCategory() == Cat.MOR_BUOY)) { 69 for (Shp shp : shapes.keySet()) { 70 JRadioButton button = shapes.get(shp); 71 if (button.isSelected()) { 72 SmedAction.panelMain.mark.setShape(shp); 73 if (SeaMark.EntMAP.get(SmedAction.panelMain.mark.getObject()) != Ent.MOORING) { 74 SmedAction.panelMain.mark.setObject(objects.get(shp)); 75 if (SmedAction.panelMain.mark.getObjColour(0) == Col.UNKCOL) { 76 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 77 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 78 } 79 if (button == cairnButton) { 80 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 81 SmedAction.panelMain.mark.setObjColour(Col.UNKCOL); 82 } 83 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 84 } 85 button.setBorderPainted(true); 86 } else 87 button.setBorderPainted(false); 88 } 89 SmedAction.panelMain.panelMore.syncPanel(); 90 } 91 } 92 }; 93 public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/SpecTopButton.png"))); 94 private ActionListener alTop = new ActionListener() { 95 public void actionPerformed(java.awt.event.ActionEvent e) { 96 if (topmarkButton.isSelected()) { 97 SmedAction.panelMain.mark.setTopmark(Top.X_SHAPE); 98 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 99 SmedAction.panelMain.mark.setTopColour(Col.YELLOW); 100 topmarkButton.setBorderPainted(true); 101 } else { 102 SmedAction.panelMain.mark.setTopmark(Top.NOTOP); 103 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 104 SmedAction.panelMain.mark.setTopColour(Col.UNKCOL); 105 topmarkButton.setBorderPainted(false); 106 } 107 SmedAction.panelMain.panelTop.syncPanel(); 108 } 109 }; 110 public JToggleButton noticeButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/NoticeButton.png"))); 111 private ActionListener alNotice = new ActionListener() { 112 public void actionPerformed(java.awt.event.ActionEvent e) { 113 SmedAction.panelMain.mark.clrMark(); 114 if (noticeButton.isSelected()) { 115 SmedAction.panelMain.mark.setObject(Obj.NOTMRK); 116 noticeButton.setBorderPainted(true); 117 } else { 118 SmedAction.panelMain.mark.setObject(Obj.UNKOBJ); 119 noticeButton.setBorderPainted(false); 120 } 121 SmedAction.panelMain.syncPanel(); 122 } 123 }; 124 public JToggleButton mooringButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/MooringButton.png"))); 125 private ActionListener alMooring = new ActionListener() { 126 public void actionPerformed(java.awt.event.ActionEvent e) { 127 SmedAction.panelMain.mark.setObject(Obj.UNKOBJ); 128 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 129 SmedAction.panelMain.mark.setTopmark(Top.NOTOP); 130 if (mooringButton.isSelected()) { 131 SmedAction.panelMain.mark.setObject(Obj.MORFAC); 132 categoryBox.setVisible(false); 133 mooringBox.setVisible(true); 134 pillarButton.setEnabled(false); 135 sparButton.setEnabled(false); 136 beaconButton.setEnabled(false); 137 towerButton.setEnabled(false); 138 stakeButton.setEnabled(false); 139 cairnButton.setEnabled(false); 140 mooringButton.setBorderPainted(true); 141 } else { 142 mooringBox.setVisible(false); 143 categoryBox.setVisible(true); 144 pillarButton.setEnabled(true); 145 sparButton.setEnabled(true); 146 beaconButton.setEnabled(true); 147 towerButton.setEnabled(true); 148 stakeButton.setEnabled(true); 149 cairnButton.setEnabled(true); 150 mooringButton.setBorderPainted(false); 151 } 152 syncPanel(); 153 } 154 }; 155 156 public PanelSpec(SmedAction dia) { 157 dlg = dia; 158 setLayout(null); 159 add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSPP)); 160 add(getShapeButton(sparButton, 34, 0, 34, 32, "Spar", Shp.SPAR, Obj.BOYSPP)); 161 add(getShapeButton(canButton, 68, 0, 34, 32, "Can", Shp.CAN, Obj.BOYSPP)); 162 add(getShapeButton(coneButton, 102, 0, 34, 32, "Cone", Shp.CONI, Obj.BOYSPP)); 163 add(getShapeButton(sphereButton, 0, 32, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSPP)); 164 add(getShapeButton(barrelButton, 34, 32, 34, 32, "Barrel", Shp.BARREL, Obj.BOYSPP)); 165 add(getShapeButton(superButton, 68, 32, 34, 32, "Super", Shp.SUPER, Obj.BOYSPP)); 166 add(getShapeButton(floatButton, 102, 32, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT)); 167 add(getShapeButton(beaconButton, 0, 64, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSPP)); 168 add(getShapeButton(towerButton, 34, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNSPP)); 169 add(getShapeButton(stakeButton, 68, 64, 34, 32, "Stake", Shp.STAKE, Obj.BCNSPP)); 170 add(getShapeButton(cairnButton, 102, 64, 34, 32, "CairnB", Shp.CAIRN, Obj.BCNSPP)); 171 172 categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER); 173 categoryLabel.setBounds(new Rectangle(5, 125, 160, 18)); 174 add(categoryLabel); 175 categoryBox = new JComboBox<>(); 176 categoryBox.setBounds(new Rectangle(5, 142, 160, 18)); 177 add(categoryBox); 178 categoryBox.setVisible(true); 179 categoryBox.addActionListener(alCategoryBox); 180 addCatItem("", Cat.NOCAT); 181 addCatItem(Messages.getString("UKPurpose"), Cat.SPM_UNKN); 182 addCatItem(Messages.getString("Warning"), Cat.SPM_WARN); 183 addCatItem(Messages.getString("ChanSeparation"), Cat.SPM_CHBF); 184 addCatItem(Messages.getString("Yachting"), Cat.SPM_YCHT); 185 addCatItem(Messages.getString("Cable"), Cat.SPM_CABL); 186 addCatItem(Messages.getString("Outfall"), Cat.SPM_OFAL); 187 addCatItem(Messages.getString("ODAS"), Cat.SPM_ODAS); 188 addCatItem(Messages.getString("RecreationZone"), Cat.SPM_RECN); 189 addCatItem(Messages.getString("Mooring"), Cat.SPM_MOOR); 190 addCatItem(Messages.getString("LANBY"), Cat.SPM_LNBY); 191 addCatItem(Messages.getString("Leading"), Cat.SPM_LDNG); 192 addCatItem(Messages.getString("Notice"), Cat.SPM_NOTC); 193 addCatItem(Messages.getString("TSS"), Cat.SPM_TSS); 194 addCatItem(Messages.getString("FoulGround"), Cat.SPM_FOUL); 195 addCatItem(Messages.getString("Diving"), Cat.SPM_DIVE); 196 addCatItem(Messages.getString("FerryCross"), Cat.SPM_FRRY); 197 addCatItem(Messages.getString("Anchorage"), Cat.SPM_ANCH); 198 mooringBox = new JComboBox<>(); 199 mooringBox.setBounds(new Rectangle(5, 142, 160, 18)); 200 add(mooringBox); 201 mooringBox.setVisible(false); 202 mooringBox.addActionListener(alMooringBox); 203 addMorItem("", Cat.NOCAT); 204 addMorItem(Messages.getString("Dolphin"), Cat.MOR_DLPN); 205 addMorItem(Messages.getString("DevDolphin"), Cat.MOR_DDPN); 206 addMorItem(Messages.getString("Bollard"), Cat.MOR_BLRD); 207 addMorItem(Messages.getString("Wall"), Cat.MOR_WALL); 208 addMorItem(Messages.getString("Post"), Cat.MOR_POST); 209 addMorItem(Messages.getString("Chain"), Cat.MOR_CHWR); 210 addMorItem(Messages.getString("Rope"), Cat.MOR_ROPE); 211 addMorItem(Messages.getString("Automatic"), Cat.MOR_AUTO); 212 addMorItem(Messages.getString("MooringBuoy"), Cat.MOR_BUOY); 213 addMorItem(Messages.getString("CALM"), Cat.INB_CALM); 214 addMorItem(Messages.getString("SBM"), Cat.INB_SBM); 215 216 topmarkButton.setBounds(new Rectangle(136, 0, 34, 32)); 217 topmarkButton.setToolTipText(Messages.getString("Topmark")); 218 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); 219 topmarkButton.addActionListener(alTop); 220 add(topmarkButton); 221 222 // noticeButton.setBounds(new Rectangle(136, 32, 34, 32)); 223 // noticeButton.setToolTipText(Messages.getString("Notice")); 224 // noticeButton.setBorder(BorderFactory.createLoweredBevelBorder()); 225 // noticeButton.addActionListener(alNotice); 226 // add(noticeButton); 227 228 mooringButton.setBounds(new Rectangle(136, 64, 34, 32)); 229 mooringButton.setToolTipText(Messages.getString("Mooring")); 230 mooringButton.setBorder(BorderFactory.createLoweredBevelBorder()); 231 mooringButton.addActionListener(alMooring); 232 add(mooringButton); 233 } 234 235 public void syncPanel() { 236 if (SeaMark.EntMAP.get(SmedAction.panelMain.mark.getObject()) == Ent.MOORING) { 237 mooringButton.setBorderPainted(true); 238 categoryBox.setVisible(false); 239 mooringBox.setVisible(true); 240 pillarButton.setEnabled(false); 241 sparButton.setEnabled(false); 242 beaconButton.setEnabled(false); 243 towerButton.setEnabled(false); 244 stakeButton.setEnabled(false); 245 cairnButton.setEnabled(false); 246 noticeButton.setEnabled(false); 247 topmarkButton.setVisible(false); 248 for (Cat cat : moorings.keySet()) { 249 int item = moorings.get(cat); 250 if (SmedAction.panelMain.mark.getCategory() == cat) 251 mooringBox.setSelectedIndex(item); 252 } 253 } else { 254 mooringButton.setBorderPainted(false); 255 mooringBox.setVisible(false); 256 categoryBox.setVisible(true); 257 pillarButton.setEnabled(true); 258 sparButton.setEnabled(true); 259 beaconButton.setEnabled(true); 260 towerButton.setEnabled(true); 261 stakeButton.setEnabled(true); 262 cairnButton.setEnabled(true); 263 noticeButton.setEnabled(true); 264 topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 265 topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 266 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 267 for (Cat cat : categories.keySet()) { 268 int item = categories.get(cat); 269 if (SmedAction.panelMain.mark.getCategory() == cat) 270 categoryBox.setSelectedIndex(item); 271 } 272 } 273 for (Shp shp : shapes.keySet()) { 274 JRadioButton button = shapes.get(shp); 275 if (SmedAction.panelMain.mark.getShape() == shp) { 276 button.setBorderPainted(true); 277 } else 278 button.setBorderPainted(false); 279 } 280 noticeButton.setBorderPainted(false); 281 SmedAction.panelMain.mark.testValid(); 282 } 283 284 private void addCatItem(String str, Cat cat) { 285 categories.put(cat, categoryBox.getItemCount()); 286 categoryBox.addItem(str); 287 } 288 289 private void addMorItem(String str, Cat cat) { 290 moorings.put(cat, mooringBox.getItemCount()); 291 mooringBox.addItem(str); 292 } 293 294 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) { 295 button.setBounds(new Rectangle(x, y, w, h)); 296 button.setBorder(BorderFactory.createLoweredBevelBorder()); 297 button.setToolTipText(Messages.getString(tip)); 298 button.addActionListener(alShape); 299 shapeButtons.add(button); 300 shapes.put(shp, button); 301 objects.put(shp, obj); 302 return button; 303 } 31 private SmedAction dlg; 32 public JLabel categoryLabel; 33 public JComboBox<String> categoryBox; 34 public EnumMap<Cat, Integer> categories = new EnumMap<>(Cat.class); 35 private ActionListener alCategoryBox = new ActionListener() { 36 @Override 37 public void actionPerformed(ActionEvent e) { 38 for (Cat cat : categories.keySet()) { 39 int idx = categories.get(cat); 40 if (dlg.node != null && (idx == categoryBox.getSelectedIndex())) { 41 SmedAction.panelMain.mark.setCategory(cat); 42 } 43 } 44 } 45 }; 46 public JComboBox<String> mooringBox; 47 public EnumMap<Cat, Integer> moorings = new EnumMap<>(Cat.class); 48 private ActionListener alMooringBox = new ActionListener() { 49 @Override 50 public void actionPerformed(ActionEvent e) { 51 for (Cat cat : moorings.keySet()) { 52 int idx = moorings.get(cat); 53 if (dlg.node != null && (idx == mooringBox.getSelectedIndex())) { 54 SmedAction.panelMain.mark.setCategory(cat); 55 if ((cat == Cat.INB_CALM) || (cat == Cat.INB_SBM)) { 56 SmedAction.panelMain.mark.setObject(Obj.BOYINB); 57 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 58 } else { 59 SmedAction.panelMain.mark.setObject(Obj.MORFAC); 60 if (cat != Cat.MOR_BUOY) { 61 SmedAction.panelMain.mark.setShape(Shp.UNKSHP); 62 } 63 } 64 } 65 } 66 if (dlg.node != null) { 67 syncPanel(); 68 } 69 } 70 }; 71 public ButtonGroup shapeButtons = new ButtonGroup(); 72 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 73 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 74 public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png"))); 75 public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png"))); 76 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 77 public JRadioButton barrelButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BarrelButton.png"))); 78 public JRadioButton superButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SuperButton.png"))); 79 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 80 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 81 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 82 public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png"))); 83 public JRadioButton cairnButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CairnButton.png"))); 84 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 85 public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class); 86 public ActionListener alShape = new ActionListener() { 87 @Override 88 public void actionPerformed(ActionEvent e) { 89 if ((SmedAction.panelMain.mark.getObject() != Obj.MORFAC) || (SmedAction.panelMain.mark.getCategory() == Cat.MOR_BUOY)) { 90 for (Shp shp : shapes.keySet()) { 91 JRadioButton button = shapes.get(shp); 92 if (button.isSelected()) { 93 SmedAction.panelMain.mark.setShape(shp); 94 if (SeaMark.EntMAP.get(SmedAction.panelMain.mark.getObject()) != Ent.MOORING) { 95 SmedAction.panelMain.mark.setObject(objects.get(shp)); 96 if (SmedAction.panelMain.mark.getObjColour(0) == Col.UNKCOL) { 97 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 98 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 99 } 100 if (button == cairnButton) { 101 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 102 SmedAction.panelMain.mark.setObjColour(Col.UNKCOL); 103 } 104 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 105 } 106 button.setBorderPainted(true); 107 } else { 108 button.setBorderPainted(false); 109 } 110 } 111 SmedAction.panelMain.panelMore.syncPanel(); 112 } 113 } 114 }; 115 public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/SpecTopButton.png"))); 116 private ActionListener alTop = new ActionListener() { 117 @Override 118 public void actionPerformed(ActionEvent e) { 119 if (topmarkButton.isSelected()) { 120 SmedAction.panelMain.mark.setTopmark(Top.X_SHAPE); 121 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 122 SmedAction.panelMain.mark.setTopColour(Col.YELLOW); 123 topmarkButton.setBorderPainted(true); 124 } else { 125 SmedAction.panelMain.mark.setTopmark(Top.NOTOP); 126 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 127 SmedAction.panelMain.mark.setTopColour(Col.UNKCOL); 128 topmarkButton.setBorderPainted(false); 129 } 130 SmedAction.panelMain.panelTop.syncPanel(); 131 } 132 }; 133 public JToggleButton noticeButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/NoticeButton.png"))); 134 private ActionListener alNotice = new ActionListener() { 135 @Override 136 public void actionPerformed(ActionEvent e) { 137 SmedAction.panelMain.mark.clrMark(); 138 if (noticeButton.isSelected()) { 139 SmedAction.panelMain.mark.setObject(Obj.NOTMRK); 140 noticeButton.setBorderPainted(true); 141 } else { 142 SmedAction.panelMain.mark.setObject(Obj.UNKOBJ); 143 noticeButton.setBorderPainted(false); 144 } 145 SmedAction.panelMain.syncPanel(); 146 } 147 }; 148 public JToggleButton mooringButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/MooringButton.png"))); 149 private ActionListener alMooring = new ActionListener() { 150 @Override 151 public void actionPerformed(ActionEvent e) { 152 SmedAction.panelMain.mark.setObject(Obj.UNKOBJ); 153 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 154 SmedAction.panelMain.mark.setTopmark(Top.NOTOP); 155 if (mooringButton.isSelected()) { 156 SmedAction.panelMain.mark.setObject(Obj.MORFAC); 157 categoryBox.setVisible(false); 158 mooringBox.setVisible(true); 159 pillarButton.setEnabled(false); 160 sparButton.setEnabled(false); 161 beaconButton.setEnabled(false); 162 towerButton.setEnabled(false); 163 stakeButton.setEnabled(false); 164 cairnButton.setEnabled(false); 165 mooringButton.setBorderPainted(true); 166 } else { 167 mooringBox.setVisible(false); 168 categoryBox.setVisible(true); 169 pillarButton.setEnabled(true); 170 sparButton.setEnabled(true); 171 beaconButton.setEnabled(true); 172 towerButton.setEnabled(true); 173 stakeButton.setEnabled(true); 174 cairnButton.setEnabled(true); 175 mooringButton.setBorderPainted(false); 176 } 177 syncPanel(); 178 } 179 }; 180 181 public PanelSpec(SmedAction dia) { 182 dlg = dia; 183 setLayout(null); 184 add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSPP)); 185 add(getShapeButton(sparButton, 34, 0, 34, 32, "Spar", Shp.SPAR, Obj.BOYSPP)); 186 add(getShapeButton(canButton, 68, 0, 34, 32, "Can", Shp.CAN, Obj.BOYSPP)); 187 add(getShapeButton(coneButton, 102, 0, 34, 32, "Cone", Shp.CONI, Obj.BOYSPP)); 188 add(getShapeButton(sphereButton, 0, 32, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSPP)); 189 add(getShapeButton(barrelButton, 34, 32, 34, 32, "Barrel", Shp.BARREL, Obj.BOYSPP)); 190 add(getShapeButton(superButton, 68, 32, 34, 32, "Super", Shp.SUPER, Obj.BOYSPP)); 191 add(getShapeButton(floatButton, 102, 32, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT)); 192 add(getShapeButton(beaconButton, 0, 64, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSPP)); 193 add(getShapeButton(towerButton, 34, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNSPP)); 194 add(getShapeButton(stakeButton, 68, 64, 34, 32, "Stake", Shp.STAKE, Obj.BCNSPP)); 195 add(getShapeButton(cairnButton, 102, 64, 34, 32, "CairnB", Shp.CAIRN, Obj.BCNSPP)); 196 197 categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER); 198 categoryLabel.setBounds(new Rectangle(5, 125, 160, 18)); 199 add(categoryLabel); 200 categoryBox = new JComboBox<>(); 201 categoryBox.setBounds(new Rectangle(5, 142, 160, 18)); 202 add(categoryBox); 203 categoryBox.setVisible(true); 204 categoryBox.addActionListener(alCategoryBox); 205 addCatItem("", Cat.NOCAT); 206 addCatItem(Messages.getString("UKPurpose"), Cat.SPM_UNKN); 207 addCatItem(Messages.getString("Warning"), Cat.SPM_WARN); 208 addCatItem(Messages.getString("ChanSeparation"), Cat.SPM_CHBF); 209 addCatItem(Messages.getString("Yachting"), Cat.SPM_YCHT); 210 addCatItem(Messages.getString("Cable"), Cat.SPM_CABL); 211 addCatItem(Messages.getString("Outfall"), Cat.SPM_OFAL); 212 addCatItem(Messages.getString("ODAS"), Cat.SPM_ODAS); 213 addCatItem(Messages.getString("RecreationZone"), Cat.SPM_RECN); 214 addCatItem(Messages.getString("Mooring"), Cat.SPM_MOOR); 215 addCatItem(Messages.getString("LANBY"), Cat.SPM_LNBY); 216 addCatItem(Messages.getString("Leading"), Cat.SPM_LDNG); 217 addCatItem(Messages.getString("Notice"), Cat.SPM_NOTC); 218 addCatItem(Messages.getString("TSS"), Cat.SPM_TSS); 219 addCatItem(Messages.getString("FoulGround"), Cat.SPM_FOUL); 220 addCatItem(Messages.getString("Diving"), Cat.SPM_DIVE); 221 addCatItem(Messages.getString("FerryCross"), Cat.SPM_FRRY); 222 addCatItem(Messages.getString("Anchorage"), Cat.SPM_ANCH); 223 mooringBox = new JComboBox<>(); 224 mooringBox.setBounds(new Rectangle(5, 142, 160, 18)); 225 add(mooringBox); 226 mooringBox.setVisible(false); 227 mooringBox.addActionListener(alMooringBox); 228 addMorItem("", Cat.NOCAT); 229 addMorItem(Messages.getString("Dolphin"), Cat.MOR_DLPN); 230 addMorItem(Messages.getString("DevDolphin"), Cat.MOR_DDPN); 231 addMorItem(Messages.getString("Bollard"), Cat.MOR_BLRD); 232 addMorItem(Messages.getString("Wall"), Cat.MOR_WALL); 233 addMorItem(Messages.getString("Post"), Cat.MOR_POST); 234 addMorItem(Messages.getString("Chain"), Cat.MOR_CHWR); 235 addMorItem(Messages.getString("Rope"), Cat.MOR_ROPE); 236 addMorItem(Messages.getString("Automatic"), Cat.MOR_AUTO); 237 addMorItem(Messages.getString("MooringBuoy"), Cat.MOR_BUOY); 238 addMorItem(Messages.getString("CALM"), Cat.INB_CALM); 239 addMorItem(Messages.getString("SBM"), Cat.INB_SBM); 240 241 topmarkButton.setBounds(new Rectangle(136, 0, 34, 32)); 242 topmarkButton.setToolTipText(Messages.getString("Topmark")); 243 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); 244 topmarkButton.addActionListener(alTop); 245 add(topmarkButton); 246 247 // noticeButton.setBounds(new Rectangle(136, 32, 34, 32)); 248 // noticeButton.setToolTipText(Messages.getString("Notice")); 249 // noticeButton.setBorder(BorderFactory.createLoweredBevelBorder()); 250 // noticeButton.addActionListener(alNotice); 251 // add(noticeButton); 252 253 mooringButton.setBounds(new Rectangle(136, 64, 34, 32)); 254 mooringButton.setToolTipText(Messages.getString("Mooring")); 255 mooringButton.setBorder(BorderFactory.createLoweredBevelBorder()); 256 mooringButton.addActionListener(alMooring); 257 add(mooringButton); 258 } 259 260 public void syncPanel() { 261 if (SeaMark.EntMAP.get(SmedAction.panelMain.mark.getObject()) == Ent.MOORING) { 262 mooringButton.setBorderPainted(true); 263 categoryBox.setVisible(false); 264 mooringBox.setVisible(true); 265 pillarButton.setEnabled(false); 266 sparButton.setEnabled(false); 267 beaconButton.setEnabled(false); 268 towerButton.setEnabled(false); 269 stakeButton.setEnabled(false); 270 cairnButton.setEnabled(false); 271 noticeButton.setEnabled(false); 272 topmarkButton.setVisible(false); 273 for (Cat cat : moorings.keySet()) { 274 int item = moorings.get(cat); 275 if (SmedAction.panelMain.mark.getCategory() == cat) { 276 mooringBox.setSelectedIndex(item); 277 } 278 } 279 } else { 280 mooringButton.setBorderPainted(false); 281 mooringBox.setVisible(false); 282 categoryBox.setVisible(true); 283 pillarButton.setEnabled(true); 284 sparButton.setEnabled(true); 285 beaconButton.setEnabled(true); 286 towerButton.setEnabled(true); 287 stakeButton.setEnabled(true); 288 cairnButton.setEnabled(true); 289 noticeButton.setEnabled(true); 290 topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 291 topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 292 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 293 for (Cat cat : categories.keySet()) { 294 int item = categories.get(cat); 295 if (SmedAction.panelMain.mark.getCategory() == cat) { 296 categoryBox.setSelectedIndex(item); 297 } 298 } 299 } 300 for (Shp shp : shapes.keySet()) { 301 JRadioButton button = shapes.get(shp); 302 if (SmedAction.panelMain.mark.getShape() == shp) { 303 button.setBorderPainted(true); 304 } else { 305 button.setBorderPainted(false); 306 } 307 } 308 noticeButton.setBorderPainted(false); 309 SmedAction.panelMain.mark.testValid(); 310 } 311 312 private void addCatItem(String str, Cat cat) { 313 categories.put(cat, categoryBox.getItemCount()); 314 categoryBox.addItem(str); 315 } 316 317 private void addMorItem(String str, Cat cat) { 318 moorings.put(cat, mooringBox.getItemCount()); 319 mooringBox.addItem(str); 320 } 321 322 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) { 323 button.setBounds(new Rectangle(x, y, w, h)); 324 button.setBorder(BorderFactory.createLoweredBevelBorder()); 325 button.setToolTipText(Messages.getString(tip)); 326 button.addActionListener(alShape); 327 shapeButtons.add(button); 328 shapes.put(shp, button); 329 objects.put(shp, obj); 330 return button; 331 } 304 332 305 333 } -
applications/editors/josm/plugins/smed/src/panels/PanelStbd.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.util.EnumMap; 6 7 7 import java.util.*; 8 import javax.swing.BorderFactory; 9 import javax.swing.ButtonGroup; 10 import javax.swing.ImageIcon; 11 import javax.swing.JPanel; 12 import javax.swing.JRadioButton; 8 13 9 14 import messages.Messages; 15 import seamarks.SeaMark.Cat; 16 import seamarks.SeaMark.Col; 17 import seamarks.SeaMark.Obj; 18 import seamarks.SeaMark.Pat; 19 import seamarks.SeaMark.Shp; 10 20 import smed.SmedAction; 11 import seamarks.SeaMark.*;12 21 13 22 public class PanelStbd extends JPanel { 14 23 15 private SmedAction dlg; 16 public ButtonGroup shapeButtons = new ButtonGroup(); 17 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 18 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 19 public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png"))); 20 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 21 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 22 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 23 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 24 public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchSButton.png"))); 25 public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png"))); 26 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 27 public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class); 28 public ActionListener alShape = new ActionListener() { 29 public void actionPerformed(java.awt.event.ActionEvent e) { 30 for (Shp shp : shapes.keySet()) { 31 JRadioButton button = shapes.get(shp); 32 if (button.isSelected()) { 33 SmedAction.panelMain.mark.setShape(shp); 34 SmedAction.panelMain.mark.setObject(objects.get(shp)); 35 button.setBorderPainted(true); 36 } else 37 button.setBorderPainted(false); 38 } 39 if (SmedAction.panelMain.mark.testValid()) { 40 SmedAction.panelMain.panelChan.topmarkButton.setVisible(true); 41 SmedAction.panelMain.panelChan.lightButton.setVisible(true); 42 if (SmedAction.panelMain.mark.getCategory() == Cat.LAM_STBD) { 43 switch (SmedAction.panelMain.mark.getRegion()) { 44 case A: 45 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 46 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 47 break; 48 case B: 49 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 50 SmedAction.panelMain.mark.setObjColour(Col.RED); 51 break; 52 case C: 53 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 54 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 55 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 56 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 57 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 58 break; 59 } 60 } else { 61 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 62 switch (SmedAction.panelMain.mark.getRegion()) { 63 case A: 64 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 65 SmedAction.panelMain.mark.addObjColour(Col.RED); 66 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 67 break; 68 case B: 69 SmedAction.panelMain.mark.setObjColour(Col.RED); 70 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 71 SmedAction.panelMain.mark.addObjColour(Col.RED); 72 break; 73 case C: 74 SmedAction.panelMain.mark.setObjColour(Col.RED); 75 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 76 SmedAction.panelMain.mark.addObjColour(Col.RED); 77 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 78 break; 79 } 80 } 81 SmedAction.panelMain.panelMore.syncPanel(); 82 } else { 83 SmedAction.panelMain.panelChan.topmarkButton.setVisible(false); 84 SmedAction.panelMain.panelChan.lightButton.setVisible(false); 85 } 86 } 87 }; 24 private SmedAction dlg; 25 public ButtonGroup shapeButtons = new ButtonGroup(); 26 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 27 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 28 public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png"))); 29 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 30 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 31 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 32 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 33 public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchSButton.png"))); 34 public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png"))); 35 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 36 public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class); 37 public ActionListener alShape = new ActionListener() { 38 @Override 39 public void actionPerformed(ActionEvent e) { 40 for (Shp shp : shapes.keySet()) { 41 JRadioButton button = shapes.get(shp); 42 if (button.isSelected()) { 43 SmedAction.panelMain.mark.setShape(shp); 44 SmedAction.panelMain.mark.setObject(objects.get(shp)); 45 button.setBorderPainted(true); 46 } else { 47 button.setBorderPainted(false); 48 } 49 } 50 if (SmedAction.panelMain.mark.testValid()) { 51 SmedAction.panelMain.panelChan.topmarkButton.setVisible(true); 52 SmedAction.panelMain.panelChan.lightButton.setVisible(true); 53 if (SmedAction.panelMain.mark.getCategory() == Cat.LAM_STBD) { 54 switch (SmedAction.panelMain.mark.getRegion()) { 55 case A: 56 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 57 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 58 break; 59 case B: 60 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT); 61 SmedAction.panelMain.mark.setObjColour(Col.RED); 62 break; 63 case C: 64 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 65 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 66 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 67 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 68 SmedAction.panelMain.mark.addObjColour(Col.WHITE); 69 break; 70 } 71 } else { 72 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 73 switch (SmedAction.panelMain.mark.getRegion()) { 74 case A: 75 SmedAction.panelMain.mark.setObjColour(Col.GREEN); 76 SmedAction.panelMain.mark.addObjColour(Col.RED); 77 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 78 break; 79 case B: 80 SmedAction.panelMain.mark.setObjColour(Col.RED); 81 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 82 SmedAction.panelMain.mark.addObjColour(Col.RED); 83 break; 84 case C: 85 SmedAction.panelMain.mark.setObjColour(Col.RED); 86 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 87 SmedAction.panelMain.mark.addObjColour(Col.RED); 88 SmedAction.panelMain.mark.addObjColour(Col.GREEN); 89 break; 90 } 91 } 92 SmedAction.panelMain.panelMore.syncPanel(); 93 } else { 94 SmedAction.panelMain.panelChan.topmarkButton.setVisible(false); 95 SmedAction.panelMain.panelChan.lightButton.setVisible(false); 96 } 97 } 98 }; 88 99 89 90 91 92 93 94 95 96 97 98 99 100 101 100 public PanelStbd(SmedAction dia) { 101 dlg = dia; 102 setLayout(null); 103 add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYLAT)); 104 add(getShapeButton(sparButton, 0, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYLAT)); 105 add(getShapeButton(coneButton, 0, 64, 34, 32, "Cone", Shp.CONI, Obj.BOYLAT)); 106 add(getShapeButton(sphereButton, 0, 96, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYLAT)); 107 add(getShapeButton(floatButton, 0, 128, 34, 32, "Float", Shp.FLOAT, Obj.FLTLAT)); 108 add(getShapeButton(beaconButton, 35, 0, 34, 32, "Beacon", Shp.BEACON, Obj.BCNLAT)); 109 add(getShapeButton(towerButton, 35, 32, 34, 32, "TowerB", Shp.TOWER, Obj.BCNLAT)); 110 add(getShapeButton(perchButton, 35, 64, 34, 32, "Perch", Shp.PERCH, Obj.BCNLAT)); 111 add(getShapeButton(stakeButton, 35, 96, 34, 32, "Stake", Shp.STAKE, Obj.BCNLAT)); 112 } 102 113 103 public void syncPanel() { 104 for (Shp shp : shapes.keySet()) { 105 JRadioButton button = shapes.get(shp); 106 if (SmedAction.panelMain.mark.getShape() == shp) { 107 button.setBorderPainted(true); 108 } else 109 button.setBorderPainted(false); 110 } 111 } 114 public void syncPanel() { 115 for (Shp shp : shapes.keySet()) { 116 JRadioButton button = shapes.get(shp); 117 if (SmedAction.panelMain.mark.getShape() == shp) { 118 button.setBorderPainted(true); 119 } else { 120 button.setBorderPainted(false); 121 } 122 } 123 } 112 124 113 114 115 116 117 118 119 120 121 122 125 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) { 126 button.setBounds(new Rectangle(x, y, w, h)); 127 button.setBorder(BorderFactory.createLoweredBevelBorder()); 128 button.setToolTipText(Messages.getString(tip)); 129 button.addActionListener(alShape); 130 shapeButtons.add(button); 131 shapes.put(shp, button); 132 objects.put(shp, obj); 133 return button; 134 } 123 135 124 136 } -
applications/editors/josm/plugins/smed/src/panels/PanelTop.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.util.EnumMap; 6 7 7 import java.util.*; 8 import javax.swing.BorderFactory; 9 import javax.swing.ButtonGroup; 10 import javax.swing.ImageIcon; 11 import javax.swing.JPanel; 12 import javax.swing.JRadioButton; 8 13 9 14 import messages.Messages; 15 import seamarks.SeaMark.Ent; 16 import seamarks.SeaMark.Top; 10 17 import smed.SmedAction; 11 import seamarks.SeaMark.*;12 18 13 19 public class PanelTop extends JPanel { 14 20 15 private SmedAction dlg; 16 public PanelPat panelPat = null; 17 private ButtonGroup topButtons = new ButtonGroup(); 18 public JRadioButton noTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png"))); 19 public JRadioButton canTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanTopButton.png"))); 20 public JRadioButton coneTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeTopButton.png"))); 21 public JRadioButton sphereTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereTopButton.png"))); 22 public JRadioButton XTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/XTopButton.png"))); 23 public JRadioButton northTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NorthTopButton.png"))); 24 public JRadioButton southTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SouthTopButton.png"))); 25 public JRadioButton eastTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/EastTopButton.png"))); 26 public JRadioButton westTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WestTopButton.png"))); 27 public JRadioButton spheres2TopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/Spheres2TopButton.png"))); 28 public JRadioButton boardDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BoardDayButton.png"))); 29 public JRadioButton rhombusDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiamondDayButton.png"))); 30 public JRadioButton triangleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleDayButton.png"))); 31 public JRadioButton triangleInvDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleInvDayButton.png"))); 32 public JRadioButton squareDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquareDayButton.png"))); 33 public JRadioButton circleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CircleDayButton.png"))); 34 private EnumMap<Top, JRadioButton> tops = new EnumMap<>(Top.class); 35 private ActionListener alTop = new ActionListener() { 36 public void actionPerformed(java.awt.event.ActionEvent e) { 37 for (Top top : tops.keySet()) { 38 JRadioButton button = tops.get(top); 39 if (button.isSelected()) { 40 SmedAction.panelMain.mark.setTopmark(top); 41 button.setBorderPainted(true); 42 } else 43 button.setBorderPainted(false); 44 } 45 } 46 }; 21 private SmedAction dlg; 22 public PanelPat panelPat = null; 23 private ButtonGroup topButtons = new ButtonGroup(); 24 public JRadioButton noTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png"))); 25 public JRadioButton canTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanTopButton.png"))); 26 public JRadioButton coneTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeTopButton.png"))); 27 public JRadioButton sphereTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereTopButton.png"))); 28 public JRadioButton XTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/XTopButton.png"))); 29 public JRadioButton northTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NorthTopButton.png"))); 30 public JRadioButton southTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SouthTopButton.png"))); 31 public JRadioButton eastTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/EastTopButton.png"))); 32 public JRadioButton westTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WestTopButton.png"))); 33 public JRadioButton spheres2TopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/Spheres2TopButton.png"))); 34 public JRadioButton boardDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BoardDayButton.png"))); 35 public JRadioButton rhombusDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiamondDayButton.png"))); 36 public JRadioButton triangleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleDayButton.png"))); 37 public JRadioButton triangleInvDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleInvDayButton.png"))); 38 public JRadioButton squareDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquareDayButton.png"))); 39 public JRadioButton circleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CircleDayButton.png"))); 40 private EnumMap<Top, JRadioButton> tops = new EnumMap<>(Top.class); 41 private ActionListener alTop = new ActionListener() { 42 @Override 43 public void actionPerformed(ActionEvent e) { 44 for (Top top : tops.keySet()) { 45 JRadioButton button = tops.get(top); 46 if (button.isSelected()) { 47 SmedAction.panelMain.mark.setTopmark(top); 48 button.setBorderPainted(true); 49 } else { 50 button.setBorderPainted(false); 51 } 52 } 53 } 54 }; 47 55 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 56 public PanelTop(SmedAction dia) { 57 dlg = dia; 58 setLayout(null); 59 panelPat = new PanelPat(dlg, Ent.TOPMARK); 60 panelPat.setBounds(new Rectangle(160, 0, 110, 160)); 61 add(panelPat); 62 add(getTopButton(noTopButton, 0, 5, 27, 27, "NoTop", Top.NOTOP)); 63 add(getTopButton(canTopButton, 30, 5, 27, 27, "CanTop", Top.CYL)); 64 add(getTopButton(coneTopButton, 60, 5, 27, 27, "ConeTop", Top.CONE)); 65 add(getTopButton(sphereTopButton, 90, 5, 27, 27, "SphereTop", Top.SPHERE)); 66 add(getTopButton(XTopButton, 120, 5, 27, 27, "XTop", Top.X_SHAPE)); 67 add(getTopButton(northTopButton, 0, 35, 27, 27, "NorthTop", Top.NORTH)); 68 add(getTopButton(southTopButton, 30, 35, 27, 27, "SouthTop", Top.SOUTH)); 69 add(getTopButton(eastTopButton, 60, 35, 27, 27, "EastTop", Top.EAST)); 70 add(getTopButton(westTopButton, 90, 35, 27, 27, "WestTop", Top.WEST)); 71 add(getTopButton(spheres2TopButton, 120, 35, 27, 27, "Spheres2Top", Top.SPHERES2)); 72 add(getTopButton(boardDayButton, 0, 65, 27, 27, "BoardDay", Top.BOARD)); 73 add(getTopButton(rhombusDayButton, 30, 65, 27, 27, "DiamondDay", Top.RHOMBUS)); 74 add(getTopButton(triangleDayButton, 60, 65, 27, 27, "TriangleDay", Top.TRIANGLE)); 75 add(getTopButton(triangleInvDayButton, 90, 65, 27, 27, "TriangleInvDay", Top.TRIANGLE_INV)); 76 add(getTopButton(squareDayButton, 120, 65, 27, 27, "SquareDay", Top.SQUARE)); 77 add(getTopButton(circleDayButton, 120, 95, 27, 27, "CircleDay", Top.CIRCLE)); 78 } 71 79 72 73 74 75 76 80 public void enableAll(boolean state) { 81 for (JRadioButton button : tops.values()) { 82 button.setEnabled(state); 83 } 84 } 77 85 78 public void syncPanel() { 79 for (Top top : tops.keySet()) { 80 JRadioButton button = tops.get(top); 81 if (SmedAction.panelMain.mark.getTopmark() == top) { 82 button.setBorderPainted(true); 83 } else 84 button.setBorderPainted(false); 85 } 86 panelPat.syncPanel(); 87 } 86 public void syncPanel() { 87 for (Top top : tops.keySet()) { 88 JRadioButton button = tops.get(top); 89 if (SmedAction.panelMain.mark.getTopmark() == top) { 90 button.setBorderPainted(true); 91 } else { 92 button.setBorderPainted(false); 93 } 94 } 95 panelPat.syncPanel(); 96 } 88 97 89 90 91 92 93 94 95 96 97 98 private JRadioButton getTopButton(JRadioButton button, int x, int y, int w, int h, String tip, Top top) { 99 button.setBounds(new Rectangle(x, y, w, h)); 100 button.setBorder(BorderFactory.createLoweredBevelBorder()); 101 button.setToolTipText(Messages.getString(tip)); 102 button.addActionListener(alTop); 103 topButtons.add(button); 104 tops.put(top, button); 105 return button; 106 } 98 107 99 108 } -
applications/editors/josm/plugins/smed/src/seamarks/SeaMark.java
r30738 r32767 1 1 package seamarks; 2 2 3 import javax.swing.*; 4 5 import java.awt.*; 3 import java.awt.BasicStroke; 4 import java.awt.Color; 5 import java.awt.Graphics; 6 import java.awt.Graphics2D; 7 import java.awt.RenderingHints; 6 8 import java.awt.geom.Arc2D; 7 8 import java.util.*; 9 import java.util.ArrayList; 10 import java.util.EnumMap; 11 import java.util.EnumSet; 12 import java.util.HashMap; 13 import java.util.Map; 14 15 import javax.swing.ImageIcon; 16 import javax.swing.JPanel; 9 17 10 18 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.osm.*;12 19 import org.openstreetmap.josm.command.ChangePropertyCommand; 13 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 22 import messages.Messages; 14 23 import panels.PanelMain; 15 16 import messages.Messages;17 24 import smed.SmedAction; 18 25 19 26 public class SeaMark extends JPanel { 20 27 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 28 public SmedAction dlg = null; 29 30 public SeaMark(SmedAction dia) { 31 dlg = dia; 32 clrLight(); 33 } 34 35 public enum Reg { 36 A, B, C, R, X 37 } 38 39 public static final EnumMap<Reg, String> RegSTR = new EnumMap<>(Reg.class); 40 static { 41 RegSTR.put(Reg.A, "iala-a"); 42 RegSTR.put(Reg.B, "iala-b"); 43 RegSTR.put(Reg.C, "cevni"); 44 RegSTR.put(Reg.R, "riwr"); 45 RegSTR.put(Reg.X, "other"); 46 } 47 48 private Reg region = Reg.A; 49 50 public Reg getRegion() { 51 return region; 52 } 53 54 public void setRegion(Reg reg) { 55 region = reg; 56 } 57 58 private String name = ""; 59 60 public String getName() { 61 return name; 62 } 63 64 public void setName(String str) { 65 name = str.trim(); 66 repaint(); 67 } 68 69 public enum Obj { 70 UNKOBJ, BCNCAR, BCNISD, BCNLAT, BCNSAW, BCNSPP, 71 BOYCAR, BOYISD, BOYLAT, BOYSAW, BOYSPP, NOTMRK, 72 FLTCAR, FLTISD, FLTLAT, FLTSAW, FLTSPP, 73 LITMAJ, LITMIN, LITFLT, LITVES, LITHSE, LNDMRK, 74 MORFAC, BOYINB, SISTAW, SISTAT, OFSPLF, 75 CGUSTA, PILBOP, RSCSTA, RDOSTA, RADSTA 76 } 77 78 public static final EnumMap<Obj, String> ObjSTR = new EnumMap<>(Obj.class); 79 static { 80 ObjSTR.put(Obj.BCNCAR, "beacon_cardinal"); 81 ObjSTR.put(Obj.BCNISD, "beacon_isolated_danger"); 82 ObjSTR.put(Obj.BCNLAT, "beacon_lateral"); 83 ObjSTR.put(Obj.BCNSAW, "beacon_safe_water"); 84 ObjSTR.put(Obj.BCNSPP, "beacon_special_purpose"); 85 ObjSTR.put(Obj.BOYCAR, "buoy_cardinal"); 86 ObjSTR.put(Obj.BOYISD, "buoy_isolated_danger"); 87 ObjSTR.put(Obj.BOYLAT, "buoy_lateral"); 88 ObjSTR.put(Obj.BOYSAW, "buoy_safe_water"); 89 ObjSTR.put(Obj.BOYSPP, "buoy_special_purpose"); 90 ObjSTR.put(Obj.FLTCAR, "light_float"); 91 ObjSTR.put(Obj.FLTLAT, "light_float"); 92 ObjSTR.put(Obj.FLTSAW, "light_float"); 93 ObjSTR.put(Obj.FLTISD, "light_float"); 94 ObjSTR.put(Obj.FLTSPP, "light_float"); 95 ObjSTR.put(Obj.LITMAJ, "light_major"); 96 ObjSTR.put(Obj.LITMIN, "light_minor"); 97 ObjSTR.put(Obj.LITFLT, "light_float"); 98 ObjSTR.put(Obj.LITVES, "light_vessel"); 99 ObjSTR.put(Obj.NOTMRK, "notice"); 100 ObjSTR.put(Obj.LNDMRK, "landmark"); 101 ObjSTR.put(Obj.LITHSE, "landmark"); 102 ObjSTR.put(Obj.MORFAC, "mooring"); 103 ObjSTR.put(Obj.BOYINB, "buoy_installation"); 104 ObjSTR.put(Obj.OFSPLF, "platform"); 105 ObjSTR.put(Obj.SISTAW, "signal_station_warning"); 106 ObjSTR.put(Obj.SISTAT, "signal_station_traffic"); 107 ObjSTR.put(Obj.CGUSTA, "coastguard_station"); 108 ObjSTR.put(Obj.PILBOP, "pilot_boarding"); 109 ObjSTR.put(Obj.RSCSTA, "rescue_station"); 110 ObjSTR.put(Obj.RDOSTA, "radio_station"); 111 ObjSTR.put(Obj.RADSTA, "radar_station"); 112 } 113 114 private Obj object = Obj.UNKOBJ; 115 116 public Obj getObject() { 117 return object; 118 } 119 120 public void setObject(Obj obj) { 121 object = obj; 122 if (obj == Obj.UNKOBJ) { 123 setCategory(Cat.NOCAT); 124 setFunc(Fnc.UNKFNC); 125 setShape(Shp.UNKSHP); 126 setColour(Ent.BODY, Col.UNKCOL); 127 setPattern(Ent.BODY, Pat.NOPAT); 128 setTopmark(Top.NOTOP); 129 setColour(Ent.TOPMARK, Col.UNKCOL); 130 setPattern(Ent.TOPMARK, Pat.NOPAT); 131 } 132 repaint(); 133 } 134 135 public enum Ent { 136 BODY, BUOY, BEACON, LFLOAT, TOPMARK, LIGHT, MOORING, STATION, PLATFORM, NOTICE 137 } 138 139 public static final EnumMap<Obj, Ent> EntMAP = new EnumMap<>(Obj.class); 140 static { 141 EntMAP.put(Obj.BCNCAR, Ent.BEACON); 142 EntMAP.put(Obj.BCNISD, Ent.BEACON); 143 EntMAP.put(Obj.BCNLAT, Ent.BEACON); 144 EntMAP.put(Obj.BCNSAW, Ent.BEACON); 145 EntMAP.put(Obj.BCNSPP, Ent.BEACON); 146 EntMAP.put(Obj.BOYCAR, Ent.BUOY); 147 EntMAP.put(Obj.BOYISD, Ent.BUOY); 148 EntMAP.put(Obj.BOYLAT, Ent.BUOY); 149 EntMAP.put(Obj.BOYSAW, Ent.BUOY); 150 EntMAP.put(Obj.BOYSPP, Ent.BUOY); 151 EntMAP.put(Obj.LITMAJ, Ent.LIGHT); 152 EntMAP.put(Obj.LITMIN, Ent.LIGHT); 153 EntMAP.put(Obj.LITFLT, Ent.LFLOAT); 154 EntMAP.put(Obj.FLTCAR, Ent.LFLOAT); 155 EntMAP.put(Obj.FLTLAT, Ent.LFLOAT); 156 EntMAP.put(Obj.FLTSAW, Ent.LFLOAT); 157 EntMAP.put(Obj.FLTISD, Ent.LFLOAT); 158 EntMAP.put(Obj.FLTSPP, Ent.LFLOAT); 159 EntMAP.put(Obj.LITVES, Ent.LFLOAT); 160 EntMAP.put(Obj.LITHSE, Ent.LIGHT); 161 EntMAP.put(Obj.LNDMRK, Ent.LIGHT); 162 EntMAP.put(Obj.MORFAC, Ent.MOORING); 163 EntMAP.put(Obj.BOYINB, Ent.MOORING); 164 EntMAP.put(Obj.OFSPLF, Ent.PLATFORM); 165 EntMAP.put(Obj.SISTAW, Ent.STATION); 166 EntMAP.put(Obj.SISTAT, Ent.STATION); 167 EntMAP.put(Obj.CGUSTA, Ent.STATION); 168 EntMAP.put(Obj.PILBOP, Ent.STATION); 169 EntMAP.put(Obj.RSCSTA, Ent.STATION); 170 EntMAP.put(Obj.RDOSTA, Ent.STATION); 171 EntMAP.put(Obj.RADSTA, Ent.STATION); 172 EntMAP.put(Obj.NOTMRK, Ent.NOTICE); 173 } 174 175 public enum Grp { 176 NUL, LAT, CAR, SAW, ISD, SPP, LGT, STN, PLF, NTC 177 } 178 179 public static final EnumMap<Obj, Grp> GrpMAP = new EnumMap<>(Obj.class); 180 static { 181 GrpMAP.put(Obj.UNKOBJ, Grp.NUL); 182 GrpMAP.put(Obj.BCNCAR, Grp.CAR); 183 GrpMAP.put(Obj.BCNISD, Grp.ISD); 184 GrpMAP.put(Obj.BCNLAT, Grp.LAT); 185 GrpMAP.put(Obj.BCNSAW, Grp.SAW); 186 GrpMAP.put(Obj.BCNSPP, Grp.SPP); 187 GrpMAP.put(Obj.BOYCAR, Grp.CAR); 188 GrpMAP.put(Obj.BOYISD, Grp.ISD); 189 GrpMAP.put(Obj.BOYLAT, Grp.LAT); 190 GrpMAP.put(Obj.BOYSAW, Grp.SAW); 191 GrpMAP.put(Obj.BOYSPP, Grp.SPP); 192 GrpMAP.put(Obj.FLTCAR, Grp.CAR); 193 GrpMAP.put(Obj.FLTLAT, Grp.LAT); 194 GrpMAP.put(Obj.FLTSAW, Grp.SAW); 195 GrpMAP.put(Obj.FLTISD, Grp.ISD); 196 GrpMAP.put(Obj.FLTSPP, Grp.SPP); 197 GrpMAP.put(Obj.LITFLT, Grp.LGT); 198 GrpMAP.put(Obj.LITMAJ, Grp.LGT); 199 GrpMAP.put(Obj.LITMIN, Grp.LGT); 200 GrpMAP.put(Obj.LITVES, Grp.LGT); 201 GrpMAP.put(Obj.LITHSE, Grp.LGT); 202 GrpMAP.put(Obj.LNDMRK, Grp.LGT); 203 GrpMAP.put(Obj.MORFAC, Grp.SPP); 204 GrpMAP.put(Obj.BOYINB, Grp.SPP); 205 GrpMAP.put(Obj.OFSPLF, Grp.PLF); 206 GrpMAP.put(Obj.SISTAW, Grp.STN); 207 GrpMAP.put(Obj.SISTAT, Grp.STN); 208 GrpMAP.put(Obj.CGUSTA, Grp.STN); 209 GrpMAP.put(Obj.PILBOP, Grp.STN); 210 GrpMAP.put(Obj.RSCSTA, Grp.STN); 211 GrpMAP.put(Obj.RDOSTA, Grp.STN); 212 GrpMAP.put(Obj.RADSTA, Grp.STN); 213 GrpMAP.put(Obj.NOTMRK, Grp.NTC); 214 } 215 216 public enum Cat { 217 NOCAT, LAM_PORT, LAM_STBD, LAM_PPORT, LAM_PSTBD, CAM_NORTH, CAM_EAST, CAM_SOUTH, CAM_WEST, 218 ACH_URST, ACH_DEEP, ACH_TANK, ACH_EXPL, ACH_QUAR, ACH_SPLN, ACH_SCAN, ACH_SCMO, ACH_T24H, ACH_TLIM, 219 SPM_UNKN, SPM_WARN, SPM_CHBF, SPM_YCHT, SPM_CABL, SPM_OFAL, SPM_ODAS, SPM_RECN, SPM_MOOR, SPM_LNBY, 220 SPM_LDNG, SPM_NOTC, SPM_TSS, SPM_FOUL, SPM_DIVE, SPM_FRRY, SPM_ANCH, 221 MOR_DLPN, MOR_DDPN, MOR_BLRD, MOR_WALL, MOR_POST, MOR_CHWR, MOR_ROPE, MOR_AUTO, MOR_BUOY, INB_CALM, INB_SBM, 222 SIS_PTCL, SIS_PTED, SIS_IPT, SIS_BRTH, SIS_DOCK, SIS_LOCK, SIS_FBAR, SIS_BRDG, SIS_DRDG, SIS_TRFC, 223 SIS_DNGR, SIS_OBST, SIS_CABL, SIS_MILY, SIS_DSTR, SIS_WTHR, SIS_STRM, SIS_ICE, SIS_TIME, SIS_TIDE, 224 SIS_TSTM, SIS_TGAG, SIS_TSCL, SIS_DIVE, SIS_LGAG, LIT_DIRF, LIT_LEDG, 225 LMK_CHMY, LMK_CARN, LMK_DSHA, LMK_FLGS, LMK_FLRS, LMK_MNMT, LMK_TOWR, LMK_WNDM, LMK_WTRT, LMK_MNRT, 226 LMK_MAST, LMK_WNDS, LMK_CLMN, LMK_OBLK, LMK_STAT, LMK_CROS, LMK_DOME, LMK_SCNR, LMK_WNDL, LMK_SPIR, 227 OFP_OIL, OFP_PRD, OFP_OBS, OFP_ALP, OFP_SALM, OFP_MOR, OFP_ISL, OFP_FPSO, OFP_ACC, OFP_NCCB, 228 RSC_LFB, RSC_RKT, RSC_RSW, RSC_RIT, RSC_MLB, RSC_RAD, RSC_FAE, RSC_SPL, RSC_AIR, RSC_TUG, 229 RAS_SRV, RAS_CST, PIL_VESS, PIL_HELI, PIL_SHORE, 230 NTC_A1, NTC_A1a, NTC_A2, NTC_A3, NTC_A4, NTC_A4_1, NTC_A5, NTC_A5_1, NTC_A6, NTC_A7, NTC_A8, NTC_A9, 231 NTC_A10a, NTC_A10b, NTC_A12, NTC_A13, NTC_A14, NTC_A15, NTC_A16, NTC_A17, NTC_A18, NTC_A19, NTC_A20, 232 NTC_B1a, NTC_B1b, NTC_B2a, NTC_B2b, NTC_B3a, NTC_B3b, NTC_B4a, NTC_B4b, NTC_B5, NTC_B6, NTC_B7, NTC_B8, NTC_B9a, NTC_B9b, NTC_B11, 233 NTC_C1, NTC_C2, NTC_C3, NTC_C4, NTC_C5a, NTC_C5b, NTC_D1a, NTC_D1b, NTC_D2a, NTC_D2b, NTC_D3a, NTC_D3b, 234 NOROS, ROS_UNKN, ROS_OMNI, ROS_DIRL, ROS_ROTP, ROS_CNSL, ROS_RDF, ROS_QTG, ROS_AERO, ROS_DECA, ROS_LORN, ROS_DGPS, ROS_TORN, ROS_OMGA, ROS_SYLD, ROS_CHKA, 235 ROS_PCOM, ROS_COMB, ROS_FACS, ROS_TIME, ROS_PAIS, ROS_SAIS, ROS_VAIS, ROS_VANC, ROS_VASC, ROS_VAEC, ROS_VAWC, ROS_VAPL, ROS_VASL, ROS_VAID, ROS_VASW, ROS_VASP, ROS_VAWK 236 } 237 238 public static final EnumMap<Cat, String> CatSTR = new EnumMap<>(Cat.class); 239 static { 240 CatSTR.put(Cat.LAM_PORT, "port"); 241 CatSTR.put(Cat.LAM_STBD, "starboard"); 242 CatSTR.put(Cat.LAM_PPORT, "preferred_channel_port"); 243 CatSTR.put(Cat.LAM_PSTBD, "preferred_channel_starboard"); 244 CatSTR.put(Cat.CAM_NORTH, "north"); 245 CatSTR.put(Cat.CAM_EAST, "east"); 246 CatSTR.put(Cat.CAM_SOUTH, "south"); 247 CatSTR.put(Cat.CAM_WEST, "west"); 248 CatSTR.put(Cat.SPM_UNKN, "unknown_purpose"); 249 CatSTR.put(Cat.SPM_WARN, "warning"); 250 CatSTR.put(Cat.SPM_CHBF, "channel_separation"); 251 CatSTR.put(Cat.SPM_YCHT, "yachting"); 252 CatSTR.put(Cat.SPM_CABL, "cable"); 253 CatSTR.put(Cat.SPM_OFAL, "outfall"); 254 CatSTR.put(Cat.SPM_ODAS, "odas"); 255 CatSTR.put(Cat.SPM_RECN, "recreation_zone"); 256 CatSTR.put(Cat.SPM_MOOR, "mooring"); 257 CatSTR.put(Cat.SPM_LNBY, "lanby"); 258 CatSTR.put(Cat.SPM_LDNG, "leading"); 259 CatSTR.put(Cat.SPM_NOTC, "notice"); 260 CatSTR.put(Cat.SPM_TSS, "tss"); 261 CatSTR.put(Cat.SPM_FOUL, "foul_ground"); 262 CatSTR.put(Cat.SPM_DIVE, "diving"); 263 CatSTR.put(Cat.SPM_FRRY, "ferry_crossing"); 264 CatSTR.put(Cat.SPM_ANCH, "anchorage"); 265 CatSTR.put(Cat.MOR_DLPN, "dolphin"); 266 CatSTR.put(Cat.MOR_DDPN, "deviation_dolphin"); 267 CatSTR.put(Cat.MOR_BLRD, "bollard"); 268 CatSTR.put(Cat.MOR_WALL, "wall"); 269 CatSTR.put(Cat.MOR_POST, "post"); 270 CatSTR.put(Cat.MOR_CHWR, "chain"); 271 CatSTR.put(Cat.MOR_ROPE, "shore_rope"); 272 CatSTR.put(Cat.MOR_AUTO, "automatic"); 273 CatSTR.put(Cat.MOR_BUOY, "buoy"); 274 CatSTR.put(Cat.INB_CALM, "calm"); 275 CatSTR.put(Cat.INB_SBM, "sbm"); 276 CatSTR.put(Cat.SIS_PTCL, "port_control"); 277 CatSTR.put(Cat.SIS_PTED, "port_entry"); 278 CatSTR.put(Cat.SIS_IPT, "ipt"); 279 CatSTR.put(Cat.SIS_BRTH, "berthing"); 280 CatSTR.put(Cat.SIS_DOCK, "dock"); 281 CatSTR.put(Cat.SIS_LOCK, "lock"); 282 CatSTR.put(Cat.SIS_FBAR, "barrage"); 283 CatSTR.put(Cat.SIS_BRDG, "bridge"); 284 CatSTR.put(Cat.SIS_DRDG, "dredging"); 285 CatSTR.put(Cat.SIS_TRFC, "traffic"); 286 CatSTR.put(Cat.SIS_DNGR, "danger"); 287 CatSTR.put(Cat.SIS_OBST, "obstruction"); 288 CatSTR.put(Cat.SIS_CABL, "cable"); 289 CatSTR.put(Cat.SIS_MILY, "military"); 290 CatSTR.put(Cat.SIS_DSTR, "distress"); 291 CatSTR.put(Cat.SIS_WTHR, "weather"); 292 CatSTR.put(Cat.SIS_STRM, "storm"); 293 CatSTR.put(Cat.SIS_ICE, "ice"); 294 CatSTR.put(Cat.SIS_TIME, "time"); 295 CatSTR.put(Cat.SIS_TIDE, "tide"); 296 CatSTR.put(Cat.SIS_TSTM, "stream"); 297 CatSTR.put(Cat.SIS_TGAG, "gauge"); 298 CatSTR.put(Cat.SIS_TSCL, "scale"); 299 CatSTR.put(Cat.SIS_DIVE, "diving"); 300 CatSTR.put(Cat.SIS_LGAG, "level"); 301 CatSTR.put(Cat.LMK_CHMY, "chimney"); 302 CatSTR.put(Cat.LMK_CARN, "cairn"); 303 CatSTR.put(Cat.LMK_DSHA, "dish_aerial"); 304 CatSTR.put(Cat.LMK_FLGS, "flagstaff"); 305 CatSTR.put(Cat.LMK_FLRS, "flare_stack"); 306 CatSTR.put(Cat.LMK_MNMT, "monument"); 307 CatSTR.put(Cat.LMK_TOWR, "tower"); 308 CatSTR.put(Cat.LMK_WNDM, "windmotor"); 309 CatSTR.put(Cat.LMK_WTRT, "water_tower"); 310 CatSTR.put(Cat.LMK_MAST, "mast"); 311 CatSTR.put(Cat.LMK_WNDS, "windsock"); 312 CatSTR.put(Cat.LMK_CLMN, "column"); 313 CatSTR.put(Cat.LMK_OBLK, "obelisk"); 314 CatSTR.put(Cat.LMK_STAT, "statue"); 315 CatSTR.put(Cat.LMK_CROS, "cross"); 316 CatSTR.put(Cat.LMK_DOME, "dome"); 317 CatSTR.put(Cat.LMK_SCNR, "radar_scanner"); 318 CatSTR.put(Cat.LMK_WNDL, "windmill"); 319 CatSTR.put(Cat.LMK_SPIR, "spire"); 320 CatSTR.put(Cat.LMK_MNRT, "minaret"); 321 CatSTR.put(Cat.OFP_OIL, "oil"); 322 CatSTR.put(Cat.OFP_PRD, "production"); 323 CatSTR.put(Cat.OFP_OBS, "observation"); 324 CatSTR.put(Cat.OFP_ALP, "alp"); 325 CatSTR.put(Cat.OFP_SALM, "salm"); 326 CatSTR.put(Cat.OFP_MOR, "mooring"); 327 CatSTR.put(Cat.OFP_ISL, "island"); 328 CatSTR.put(Cat.OFP_FPSO, "fpso"); 329 CatSTR.put(Cat.OFP_ACC, "accommodation"); 330 CatSTR.put(Cat.OFP_NCCB, "nccb"); 331 CatSTR.put(Cat.PIL_VESS, "cruising_vessel"); 332 CatSTR.put(Cat.PIL_HELI, "helicopter"); 333 CatSTR.put(Cat.PIL_SHORE, "from_shore"); 334 CatSTR.put(Cat.RSC_LFB, "lifeboat"); 335 CatSTR.put(Cat.RSC_RKT, "rocket"); 336 CatSTR.put(Cat.RSC_RSW, "refuge_shipwrecked"); 337 CatSTR.put(Cat.RSC_RIT, "refuge_intertidal"); 338 CatSTR.put(Cat.RSC_MLB, "lifeboat_moored"); 339 CatSTR.put(Cat.RSC_RAD, "radio"); 340 CatSTR.put(Cat.RSC_FAE, "firstaid"); 341 CatSTR.put(Cat.RSC_SPL, "seaplane"); 342 CatSTR.put(Cat.RSC_AIR, "aircraft"); 343 CatSTR.put(Cat.RSC_TUG, "tug"); 344 CatSTR.put(Cat.RAS_SRV, "surveillance"); 345 CatSTR.put(Cat.RAS_CST, "coast"); 346 CatSTR.put(Cat.ROS_OMNI, "omnidirectional"); 347 CatSTR.put(Cat.ROS_DIRL, "directional"); 348 CatSTR.put(Cat.ROS_ROTP, "rotating_pattern"); 349 CatSTR.put(Cat.ROS_CNSL, "consol"); 350 CatSTR.put(Cat.ROS_RDF, "rdf"); 351 CatSTR.put(Cat.ROS_QTG, "qtg"); 352 CatSTR.put(Cat.ROS_AERO, "aeronautical"); 353 CatSTR.put(Cat.ROS_DECA, "decca"); 354 CatSTR.put(Cat.ROS_LORN, "loran"); 355 CatSTR.put(Cat.ROS_DGPS, "dgps"); 356 CatSTR.put(Cat.ROS_TORN, "toran"); 357 CatSTR.put(Cat.ROS_OMGA, "omega"); 358 CatSTR.put(Cat.ROS_SYLD, "syledis"); 359 CatSTR.put(Cat.ROS_CHKA, "chiaka"); 360 CatSTR.put(Cat.ROS_PCOM, "public_communication"); 361 CatSTR.put(Cat.ROS_COMB, "commercial_broadcast"); 362 CatSTR.put(Cat.ROS_FACS, "facsimile"); 363 CatSTR.put(Cat.ROS_TIME, "time_signal"); 364 CatSTR.put(Cat.ROS_PAIS, "ais"); 365 CatSTR.put(Cat.ROS_SAIS, "s-ais"); 366 CatSTR.put(Cat.ROS_VAIS, "v-ais"); 367 CatSTR.put(Cat.ROS_VANC, "v-ais_north_cardinal"); 368 CatSTR.put(Cat.ROS_VASC, "v-ais_south_cardinal"); 369 CatSTR.put(Cat.ROS_VAEC, "v-ais_east_cardinal"); 370 CatSTR.put(Cat.ROS_VAWC, "v-ais_west_cardinal"); 371 CatSTR.put(Cat.ROS_VAPL, "v-ais_port_lateral"); 372 CatSTR.put(Cat.ROS_VASL, "v-ais_starboard_lateral"); 373 CatSTR.put(Cat.ROS_VAID, "v-ais_isolated_danger"); 374 CatSTR.put(Cat.ROS_VASW, "v-ais_safe_water"); 375 CatSTR.put(Cat.ROS_VASP, "v-ais_special_purpose"); 376 CatSTR.put(Cat.ROS_VAWK, "v-ais_wreck"); 377 CatSTR.put(Cat.NTC_A1, "no_entry"); 378 CatSTR.put(Cat.NTC_A1a, "closed_area"); 379 CatSTR.put(Cat.NTC_A2, "no_overtaking"); 380 CatSTR.put(Cat.NTC_A3, "no_convoy_overtaking"); 381 CatSTR.put(Cat.NTC_A4, "no_passing"); 382 CatSTR.put(Cat.NTC_A4, "no_convoy_passing"); 383 CatSTR.put(Cat.NTC_A5, "no_berthing"); 384 CatSTR.put(Cat.NTC_A5_1, "no_berthing_lateral_limit"); 385 CatSTR.put(Cat.NTC_A6, "no_anchoring"); 386 CatSTR.put(Cat.NTC_A7, "no_mooring"); 387 CatSTR.put(Cat.NTC_A8, "no_turning"); 388 CatSTR.put(Cat.NTC_A9, "no_wash"); 389 CatSTR.put(Cat.NTC_A10a, "no_passage_left"); 390 CatSTR.put(Cat.NTC_A10b, "no_passage_right"); 391 CatSTR.put(Cat.NTC_A12, "no_motor_craft"); 392 CatSTR.put(Cat.NTC_A13, "no_sport_craft"); 393 CatSTR.put(Cat.NTC_A14, "no_waterskiing"); 394 CatSTR.put(Cat.NTC_A15, "no_sailing_craft"); 395 CatSTR.put(Cat.NTC_A16, "no_unpowered_craft"); 396 CatSTR.put(Cat.NTC_A17, "no_sailboards"); 397 CatSTR.put(Cat.NTC_A18, "no_high_speeds"); 398 CatSTR.put(Cat.NTC_A19, "no_launching_beaching"); 399 CatSTR.put(Cat.NTC_A20, "no_waterbikes"); 400 CatSTR.put(Cat.NTC_B1a, ""); 401 CatSTR.put(Cat.NTC_B1b, ""); 402 CatSTR.put(Cat.NTC_B2a, ""); 403 CatSTR.put(Cat.NTC_B2a, ""); 404 CatSTR.put(Cat.NTC_B3a, ""); 405 CatSTR.put(Cat.NTC_B3a, ""); 406 CatSTR.put(Cat.NTC_B4a, ""); 407 CatSTR.put(Cat.NTC_B4a, ""); 408 CatSTR.put(Cat.NTC_B5, ""); 409 CatSTR.put(Cat.NTC_B6, ""); 410 CatSTR.put(Cat.NTC_B7, ""); 411 CatSTR.put(Cat.NTC_B8, ""); 412 CatSTR.put(Cat.NTC_B9a, ""); 413 CatSTR.put(Cat.NTC_B9b, ""); 414 CatSTR.put(Cat.NTC_B11, ""); 415 CatSTR.put(Cat.NTC_C1, ""); 416 CatSTR.put(Cat.NTC_C2, ""); 417 CatSTR.put(Cat.NTC_C3, ""); 418 CatSTR.put(Cat.NTC_C4, ""); 419 CatSTR.put(Cat.NTC_C5a, ""); 420 CatSTR.put(Cat.NTC_C5b, ""); 421 CatSTR.put(Cat.NTC_D1a, ""); 422 CatSTR.put(Cat.NTC_D1b, ""); 423 CatSTR.put(Cat.NTC_D2a, ""); 424 CatSTR.put(Cat.NTC_D2b, ""); 425 CatSTR.put(Cat.NTC_D3a, ""); 426 CatSTR.put(Cat.NTC_D3b, ""); 427 } 428 429 private Cat category = Cat.NOCAT; 430 431 public Cat getCategory() { 432 return category; 433 } 434 435 public void setCategory(Cat cat) { 436 category = cat; 437 repaint(); 438 } 439 440 public enum Shp { 441 UNKSHP, PILLAR, SPAR, CAN, CONI, SPHERI, BARREL, FLOAT, SUPER, BUOYANT, CAIRN, PILE, LATTICE, TOWER, STAKE, POLE, POST, PERCH, BUOY, BEACON 442 } 443 444 public static final EnumMap<Shp, String> ShpSTR = new EnumMap<>(Shp.class); 445 static { 446 ShpSTR.put(Shp.PILLAR, "pillar"); 447 ShpSTR.put(Shp.SPAR, "spar"); 448 ShpSTR.put(Shp.CAN, "can"); 449 ShpSTR.put(Shp.CONI, "conical"); 450 ShpSTR.put(Shp.SPHERI, "spherical"); 451 ShpSTR.put(Shp.BARREL, "barrel"); 452 ShpSTR.put(Shp.FLOAT, "float"); 453 ShpSTR.put(Shp.SUPER, "super-buoy"); 454 ShpSTR.put(Shp.BUOYANT, "buoyant"); 455 ShpSTR.put(Shp.CAIRN, "cairn"); 456 ShpSTR.put(Shp.PILE, "pile"); 457 ShpSTR.put(Shp.LATTICE, "lattice"); 458 ShpSTR.put(Shp.TOWER, "tower"); 459 ShpSTR.put(Shp.STAKE, "stake"); 460 ShpSTR.put(Shp.PERCH, "perch"); 461 } 462 463 private Shp shape = Shp.UNKSHP; 464 465 public Shp getShape() { 466 return shape; 467 } 468 469 public void setShape(Shp shp) { 470 shape = shp; 471 repaint(); 472 } 473 474 public enum Col { 475 UNKCOL, BLANK, WHITE, RED, ORANGE, AMBER, YELLOW, GREEN, BLUE, VIOLET, BLACK, GREY, BROWN, MAGENTA, PINK 476 } 477 478 public static final EnumMap<Col, Color> ColMAP = new EnumMap<>(Col.class); 479 static { 480 ColMAP.put(Col.UNKCOL, new Color(0xc0c0c0)); 481 ColMAP.put(Col.WHITE, Color.WHITE); 482 ColMAP.put(Col.RED, Color.RED); 483 ColMAP.put(Col.ORANGE, Color.ORANGE); 484 ColMAP.put(Col.AMBER, new Color(0xfbf00f)); 485 ColMAP.put(Col.YELLOW, Color.YELLOW); 486 ColMAP.put(Col.GREEN, Color.GREEN); 487 ColMAP.put(Col.BLUE, Color.BLUE); 488 ColMAP.put(Col.VIOLET, new Color(0x8f00ff)); 489 ColMAP.put(Col.BLACK, Color.BLACK); 490 ColMAP.put(Col.GREY, Color.GRAY); 491 ColMAP.put(Col.BROWN, new Color(0xa45a58)); 492 ColMAP.put(Col.MAGENTA, Color.MAGENTA); 493 ColMAP.put(Col.PINK, Color.PINK); 494 } 495 496 public static final EnumMap<Col, String> ColSTR = new EnumMap<>(Col.class); 497 static { 498 ColSTR.put(Col.WHITE, "white"); 499 ColSTR.put(Col.RED, "red"); 500 ColSTR.put(Col.ORANGE, "orange"); 501 ColSTR.put(Col.AMBER, "amber"); 502 ColSTR.put(Col.YELLOW, "yellow"); 503 ColSTR.put(Col.GREEN, "green"); 504 ColSTR.put(Col.BLUE, "blue"); 505 ColSTR.put(Col.VIOLET, "violet"); 506 ColSTR.put(Col.BLACK, "black"); 507 ColSTR.put(Col.GREY, "grey"); 508 ColSTR.put(Col.BROWN, "brown"); 509 ColSTR.put(Col.MAGENTA, "magenta"); 510 ColSTR.put(Col.PINK, "pink"); 511 } 512 513 public Col getColour(Ent ent, int idx) { 514 if (ent == Ent.BODY) 515 return getObjColour(idx); 516 else 517 return getTopColour(idx); 518 } 519 520 public void setColour(Ent ent, Col col) { 521 if (ent == Ent.BODY) 522 setObjColour(col); 523 else 524 setTopColour(col); 525 } 526 527 public void setColour(Ent ent, int idx, Col col) { 528 if (ent == Ent.BODY) 529 setObjColour(idx, col); 530 else 531 setTopColour(idx, col); 532 } 533 534 public void addColour(Ent ent, int idx, Col col) { 535 if (ent == Ent.BODY) 536 addObjColour(idx, col); 537 else 538 addTopColour(idx, col); 539 } 540 541 public void subColour(Ent ent, int idx) { 542 if (ent == Ent.BODY) 543 subObjColour(idx); 544 else 545 subTopColour(idx); 546 } 547 548 private ArrayList<Col> bodyColour = new ArrayList<>(); 549 550 public Col getObjColour(int i) { 551 if (i < bodyColour.size()) 552 return bodyColour.get(i); 553 else 554 return Col.UNKCOL; 555 } 556 557 public void setObjColour(Col col) { 558 bodyColour.clear(); 559 bodyColour.add(col); 560 repaint(); 561 } 562 563 public void setObjColour(int i, Col col) { 564 if (i < bodyColour.size()) 565 bodyColour.set(i, col); 566 repaint(); 567 } 568 569 public void addObjColour(int i, Col col) { 570 if (bodyColour.size() >= i) 571 bodyColour.add(i, col); 572 repaint(); 573 } 574 575 public void addObjColour(Col col) { 576 bodyColour.add(col); 577 repaint(); 578 } 579 580 public void subObjColour(int i) { 581 if (bodyColour.size() > i) 582 bodyColour.remove(i); 583 repaint(); 584 } 585 586 private ArrayList<Col> topmarkColour = new ArrayList<>(); 587 588 public Col getTopColour(int i) { 589 if (i < topmarkColour.size()) 590 return topmarkColour.get(i); 591 else 592 return Col.UNKCOL; 593 } 594 595 public void setTopColour(Col col) { 596 topmarkColour.clear(); 597 topmarkColour.add(col); 598 repaint(); 599 } 600 601 public void setTopColour(int i, Col col) { 602 if (topmarkColour.size() > i) 603 topmarkColour.set(i, col); 604 repaint(); 605 } 606 607 public void addTopColour(int i, Col col) { 608 if (topmarkColour.size() >= i) 609 topmarkColour.add(i, col); 610 repaint(); 611 } 612 613 public void addTopColour(Col col) { 614 topmarkColour.add(col); 615 repaint(); 616 } 617 618 public void subTopColour(int i) { 619 if (topmarkColour.size() > i) 620 topmarkColour.remove(i); 621 repaint(); 622 } 623 624 public enum Chr { 625 UNKCHR, FIXED, FLASH, LFLASH, QUICK, VQUICK, UQUICK, ISOPHASED, OCCULTING, MORSE, ALTERNATING, IQUICK, IVQUICK, IUQUICK 626 } 627 628 public static final Map<EnumSet<Chr>, String> ChrMAP = new HashMap<>(); 629 static { 630 ChrMAP.put(EnumSet.of(Chr.FIXED), "F"); 631 ChrMAP.put(EnumSet.of(Chr.FLASH), "Fl"); 632 ChrMAP.put(EnumSet.of(Chr.LFLASH), "LFl"); 633 ChrMAP.put(EnumSet.of(Chr.QUICK), "Q"); 634 ChrMAP.put(EnumSet.of(Chr.VQUICK), "VQ"); 635 ChrMAP.put(EnumSet.of(Chr.UQUICK), "UQ"); 636 ChrMAP.put(EnumSet.of(Chr.ISOPHASED), "Iso"); 637 ChrMAP.put(EnumSet.of(Chr.OCCULTING), "Oc"); 638 ChrMAP.put(EnumSet.of(Chr.IQUICK), "IQ"); 639 ChrMAP.put(EnumSet.of(Chr.IVQUICK), "IVQ"); 640 ChrMAP.put(EnumSet.of(Chr.IUQUICK), "IUQ"); 641 ChrMAP.put(EnumSet.of(Chr.MORSE), "Mo"); 642 ChrMAP.put(EnumSet.of(Chr.FIXED, Chr.FLASH), "FFl"); 643 ChrMAP.put(EnumSet.of(Chr.FLASH, Chr.LFLASH), "FlLFl"); 644 ChrMAP.put(EnumSet.of(Chr.FIXED, Chr.OCCULTING), "FOc"); 645 ChrMAP.put(EnumSet.of(Chr.FIXED, Chr.LFLASH), "FLFl"); 646 ChrMAP.put(EnumSet.of(Chr.OCCULTING, Chr.FLASH), "OcFl"); 647 ChrMAP.put(EnumSet.of(Chr.QUICK, Chr.LFLASH), "Q+LFl"); 648 ChrMAP.put(EnumSet.of(Chr.VQUICK, Chr.LFLASH), "VQ+LFl"); 649 ChrMAP.put(EnumSet.of(Chr.UQUICK, Chr.LFLASH), "UQ+LFl"); 650 ChrMAP.put(EnumSet.of(Chr.ALTERNATING), "Al"); 651 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.OCCULTING), "Al.Oc"); 652 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.LFLASH), "Al.LFl"); 653 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.FLASH), "Al.Fl"); 654 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.FIXED), "Al.F"); 655 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.FIXED, Chr.FLASH), "Al.FFl"); 656 ChrMAP.put(EnumSet.of(Chr.ALTERNATING, Chr.ISOPHASED), "Al.Iso"); 657 } 658 659 public enum Vis { 660 UNKVIS, HIGH, LOW, FAINT, INTEN, UNINTEN, REST, OBS, PARTOBS 661 } 662 663 public static final EnumMap<Vis, String> VisSTR = new EnumMap<>(Vis.class); 664 static { 665 VisSTR.put(Vis.HIGH, "high"); 666 VisSTR.put(Vis.LOW, "low"); 667 VisSTR.put(Vis.FAINT, "faint"); 668 VisSTR.put(Vis.INTEN, "intensified"); 669 VisSTR.put(Vis.UNINTEN, "unintensified"); 670 VisSTR.put(Vis.REST, "restricted"); 671 VisSTR.put(Vis.OBS, "obscured"); 672 VisSTR.put(Vis.PARTOBS, "part_obscured"); 673 } 674 675 public enum Lit { 676 UNKLIT, VERT, HORIZ, DIR, UPPER, LOWER, LEAD, REAR, FRONT, AERO, AIROBS, FOGDET, FLOOD, STRIP, SUBS, SPOT, MOIRE, EMERG, BEAR 677 } 678 679 public static final EnumMap<Lit, String> LitSTR = new EnumMap<>(Lit.class); 680 static { 681 LitSTR.put(Lit.VERT, "vertical"); 682 LitSTR.put(Lit.HORIZ, "horizontal"); 683 LitSTR.put(Lit.DIR, "directional"); 684 LitSTR.put(Lit.UPPER, "upper"); 685 LitSTR.put(Lit.LOWER, "lower"); 686 LitSTR.put(Lit.LEAD, "leading"); 687 LitSTR.put(Lit.REAR, "rear"); 688 LitSTR.put(Lit.FRONT, "front"); 689 LitSTR.put(Lit.AERO, "aero"); 690 LitSTR.put(Lit.AIROBS, "air_obstruction"); 691 LitSTR.put(Lit.FOGDET, "fog_detector"); 692 LitSTR.put(Lit.FLOOD, "floodlight"); 693 LitSTR.put(Lit.STRIP, "striplight"); 694 LitSTR.put(Lit.SUBS, "subsidairy"); 695 LitSTR.put(Lit.SPOT, "spotlight"); 696 LitSTR.put(Lit.MOIRE, "moire"); 697 LitSTR.put(Lit.EMERG, "emergency"); 698 LitSTR.put(Lit.BEAR, "bearing"); 699 } 700 701 public enum Exh { 702 UNKEXH, H24, DAY, NIGHT, FOG, WARN, STORM 703 } 704 705 public static final EnumMap<Exh, String> ExhSTR = new EnumMap<>(Exh.class); 706 static { 707 ExhSTR.put(Exh.H24, "24h"); 708 ExhSTR.put(Exh.DAY, "day"); 709 ExhSTR.put(Exh.NIGHT, "night"); 710 ExhSTR.put(Exh.FOG, "fog"); 711 ExhSTR.put(Exh.WARN, "warning"); 712 ExhSTR.put(Exh.STORM, "storm"); 713 } 714 715 public enum Att { 716 COL, CHR, GRP, SEQ, PER, LIT, BEG, END, RAD, HGT, RNG, VIS, EXH, ORT, MLT, ALT 717 } 718 719 public Object[] sector = { Col.UNKCOL, "", "", "", "", Lit.UNKLIT, "", "", 720 "", "", "", Vis.UNKVIS, Exh.UNKEXH, "", "", Col.UNKCOL }; 721 722 private ArrayList<Object[]> sectors = new ArrayList<>(); 723 724 public int getSectorCount() { 725 return sectors.size(); 726 } 727 728 public boolean isSectored() { 729 return (sectors.size() > 1); 730 } 731 732 public Object getLightAtt(Att att, int i) { 733 return getLightAtt(att.ordinal(), i); 734 } 735 736 public Object getLightAtt(int att, int i) { 737 if (i < sectors.size()) 738 return sectors.get(i)[att]; 739 else 740 return null; 741 } 742 743 public void setLightAtt(Att att, int i, Object obj) { 744 setLightAtt(att.ordinal(), i, obj); 745 } 746 747 public void setLightAtt(int att, int i, Object obj) { 748 if (sectors.size() == i) 749 addLight(i); 750 if (sectors.size() > i) 751 switch (att) { 752 case 4: 753 case 8: 754 case 9: 755 case 10: 756 sectors.get(i)[att] = validDecimal((String)obj); 757 break; 758 case 6: 759 case 7: 760 case 13: 761 sectors.get(i)[att] = validDecimal((String)obj, 360); 762 break; 763 default: 764 sectors.get(i)[att] = obj; 765 } 766 repaint(); 767 } 768 769 public void addLight(int i) { 770 if (sectors.size() >= i) { 771 if (sectors.size() == 0) 772 sectors.add(sector.clone()); 773 else 774 sectors.add(i, sectors.get(0).clone()); 775 } 776 } 777 778 public void nulLight(int i) { 779 if (i == 0) { 780 clrLight(); 781 } else { 782 sectors.add(i, sector.clone()); 783 } 784 } 785 786 public void addLight() { 787 if (sectors.size() == 0) 788 sectors.add(sector.clone()); 789 else 790 sectors.add(sectors.get(0).clone()); 791 } 792 793 public void delLight(int i) { 794 if (sectors.size() > i) 795 sectors.remove(i); 796 repaint(); 797 } 798 799 public void clrLight() { 800 sectors.clear(); 801 addLight(); 802 setLightRef(""); 803 repaint(); 804 } 805 806 public enum Pat { 807 NOPAT, HSTRP, VSTRP, DIAG, SQUARED, BORDER, CROSS, SALTIRE 808 } 809 810 public static final EnumMap<Pat, String> PatSTR = new EnumMap<>(Pat.class); 811 static { 812 PatSTR.put(Pat.HSTRP, "horizontal"); 813 PatSTR.put(Pat.VSTRP, "vertical"); 814 PatSTR.put(Pat.DIAG, "diagonal"); 815 PatSTR.put(Pat.SQUARED, "squared"); 816 PatSTR.put(Pat.BORDER, "border"); 817 PatSTR.put(Pat.CROSS, "cross"); 818 PatSTR.put(Pat.SALTIRE, "saltire"); 819 } 820 821 public Pat getPattern(Ent ent) { 822 if (ent == Ent.BODY) 823 return getObjPattern(); 824 else 825 return getTopPattern(); 826 } 827 828 public void setPattern(Ent ent, Pat pat) { 829 if (ent == Ent.BODY) 830 setObjPattern(pat); 831 else 832 setTopPattern(pat); 833 } 834 835 private Pat bodyPattern = Pat.NOPAT; 836 837 public Pat getObjPattern() { 838 return bodyPattern; 839 } 840 841 public void setObjPattern(Pat pat) { 842 bodyPattern = pat; 843 } 844 845 private Pat topPattern = Pat.NOPAT; 846 847 public Pat getTopPattern() { 848 return topPattern; 849 } 850 851 public void setTopPattern(Pat pat) { 852 topPattern = pat; 853 } 854 855 public enum Top { 856 NOTOP, CYL, CONE, SPHERE, X_SHAPE, NORTH, SOUTH, EAST, WEST, SPHERES2, BOARD, RHOMBUS, CIRCLE, TRIANGLE, TRIANGLE_INV, SQUARE 857 } 858 859 public static final EnumMap<Top, String> TopSTR = new EnumMap<>(Top.class); 860 static { 861 TopSTR.put(Top.CYL, "cylinder"); 862 TopSTR.put(Top.CONE, "cone, point up"); 863 TopSTR.put(Top.SPHERE, "sphere"); 864 TopSTR.put(Top.X_SHAPE, "x-shape"); 865 TopSTR.put(Top.NORTH, "2 cones up"); 866 TopSTR.put(Top.SOUTH, "2 cones down"); 867 TopSTR.put(Top.EAST, "2 cones base together"); 868 TopSTR.put(Top.WEST, "2 cones point together"); 869 TopSTR.put(Top.SPHERES2, "2 spheres"); 870 TopSTR.put(Top.BOARD, "board"); 871 TopSTR.put(Top.RHOMBUS, "rhombus"); 872 TopSTR.put(Top.CIRCLE, "circle"); 873 TopSTR.put(Top.TRIANGLE, "triangle, point up"); 874 TopSTR.put(Top.TRIANGLE_INV, "triangle, point down"); 875 TopSTR.put(Top.SQUARE, "square"); 876 } 877 878 private Top topShape = Top.NOTOP; 879 880 public Top getTopmark() { 881 return topShape; 882 } 883 884 public void setTopmark(Top top) { 885 topShape = top; 886 repaint(); 887 } 888 889 private Cat RoType = Cat.NOROS; 890 891 public Cat getRadio() { 892 return RoType; 893 } 894 895 public void setRadio(Cat type) { 896 RoType = type; 897 repaint(); 898 } 899 900 public enum Rtb { 901 NORTB, REFLECTOR, RACON, RAMARK, LEADING 902 } 903 904 public static final EnumMap<Rtb, String> RtbSTR = new EnumMap<>(Rtb.class); 905 static { 906 RtbSTR.put(Rtb.RACON, "racon"); 907 RtbSTR.put(Rtb.RAMARK, "ramark"); 908 RtbSTR.put(Rtb.LEADING, "leading"); 909 } 910 911 private Rtb RaType = Rtb.NORTB; 912 913 public Rtb getRadar() { 914 return RaType; 915 } 916 917 public void setRadar(Rtb type) { 918 RaType = type; 919 if (type == Rtb.NORTB) { 920 setRaconGroup(""); 921 setRaconSequence(""); 922 setRaconPeriod(""); 923 setRaconRange(""); 924 setRaconSector1(""); 925 setRaconSector2(""); 926 } 927 repaint(); 928 } 929 930 private String raconGroup = ""; 931 932 public String getRaconGroup() { 933 return raconGroup; 934 } 935 936 public void setRaconGroup(String grp) { 937 raconGroup = grp; 938 repaint(); 939 } 940 941 private String raconSequence = ""; 942 943 public String getRaconSequence() { 944 return raconSequence; 945 } 946 947 public void setRaconSequence(String seq) { 948 raconSequence = seq; 949 repaint(); 950 } 951 952 private String raconPeriod = ""; 953 954 public String getRaconPeriod() { 955 return raconPeriod; 956 } 957 958 public void setRaconPeriod(String per) { 959 raconPeriod = validDecimal(per); 960 repaint(); 961 } 962 963 private String raconRange = ""; 964 965 public String getRaconRange() { 966 return raconRange; 967 } 968 969 public void setRaconRange(String rng) { 970 raconRange = validDecimal(rng); 971 repaint(); 972 } 973 974 private String raconSector1 = ""; 975 976 public String getRaconSector1() { 977 return raconSector1; 978 } 979 980 public void setRaconSector1(String sec) { 981 raconSector1 = validDecimal(sec); 982 repaint(); 983 } 984 985 private String raconSector2 = ""; 986 987 public String getRaconSector2() { 988 return raconSector2; 989 } 990 991 public void setRaconSector2(String sec) { 992 raconSector2 = validDecimal(sec); 993 repaint(); 994 } 995 996 public enum Fog { 997 NOFOG, FOGSIG, HORN, SIREN, DIA, BELL, WHIS, GONG, EXPLOS 998 } 999 1000 public static final EnumMap<Fog, String> FogSTR = new EnumMap<>(Fog.class); 1001 static { 1002 FogSTR.put(Fog.FOGSIG, "yes"); 1003 FogSTR.put(Fog.HORN, "horn"); 1004 FogSTR.put(Fog.SIREN, "siren"); 1005 FogSTR.put(Fog.DIA, "diaphone"); 1006 FogSTR.put(Fog.BELL, "bell"); 1007 FogSTR.put(Fog.WHIS, "whistle"); 1008 FogSTR.put(Fog.GONG, "gong"); 1009 FogSTR.put(Fog.EXPLOS, "explosion"); 1010 } 1011 1012 private Fog fogSound = Fog.NOFOG; 1013 1014 public Fog getFogSound() { 1015 return fogSound; 1016 } 1017 1018 public void setFogSound(Fog sound) { 1019 fogSound = sound; 1020 if (sound == Fog.NOFOG) { 1021 setFogGroup(""); 1022 setFogSequence(""); 1023 setFogPeriod(""); 1024 setFogRange(""); 1025 } 1026 repaint(); 1027 } 1028 1029 private String fogGroup = ""; 1030 1031 public String getFogGroup() { 1032 return fogGroup; 1033 } 1034 1035 public void setFogGroup(String grp) { 1036 fogGroup = grp; 1037 repaint(); 1038 } 1039 1040 private String fogSequence = ""; 1041 1042 public String getFogSequence() { 1043 return fogSequence; 1044 } 1045 1046 public void setFogSequence(String seq) { 1047 fogSequence = seq; 1048 repaint(); 1049 } 1050 1051 private String fogRange = ""; 1052 1053 public String getFogRange() { 1054 return fogRange; 1055 } 1056 1057 public void setFogRange(String rng) { 1058 fogRange = validDecimal(rng); 1059 repaint(); 1060 } 1061 1062 private String fogPeriod = ""; 1063 1064 public String getFogPeriod() { 1065 return fogPeriod; 1066 } 1067 1068 public void setFogPeriod(String per) { 1069 fogPeriod = validDecimal(per); 1070 repaint(); 1071 } 1072 1073 public enum Sts { 1074 UNKSTS, PERM, OCC, REC, NIU, INT, RESV, TEMP, PRIV, MAND, DEST, EXT, ILLUM, HIST, PUB, SYNC, WATCH, UNWAT, DOUBT 1075 } 1076 1077 public static final EnumMap<Sts, String> StsSTR = new EnumMap<>(Sts.class); 1078 static { 1079 StsSTR.put(Sts.PERM, "permanent"); 1080 StsSTR.put(Sts.OCC, "occasional"); 1081 StsSTR.put(Sts.REC, "recommended"); 1082 StsSTR.put(Sts.NIU, "not_in_use"); 1083 StsSTR.put(Sts.INT, "intermittent"); 1084 StsSTR.put(Sts.RESV, "reserved"); 1085 StsSTR.put(Sts.TEMP, "tempory"); 1086 StsSTR.put(Sts.PRIV, "private"); 1087 StsSTR.put(Sts.MAND, "mandatory"); 1088 StsSTR.put(Sts.DEST, "destroyed"); 1089 StsSTR.put(Sts.EXT, "extinguished"); 1090 StsSTR.put(Sts.ILLUM, "illuminated"); 1091 StsSTR.put(Sts.HIST, "historic"); 1092 StsSTR.put(Sts.PUB, "public"); 1093 StsSTR.put(Sts.SYNC, "synchronized"); 1094 StsSTR.put(Sts.WATCH, "watched"); 1095 StsSTR.put(Sts.UNWAT, "unwatched"); 1096 StsSTR.put(Sts.DOUBT, "existence_doubtful"); 1097 } 1098 1099 private Sts status = Sts.UNKSTS; 1100 1101 public Sts getStatus() { 1102 return status; 1103 } 1104 1105 public void setStatus(Sts sts) { 1106 status = sts; 1107 } 1108 1109 public enum Cns { 1110 UNKCNS, BRICK, CONC, BOULD, HSURF, USURF, WOOD, METAL, GLAS, PAINT 1111 } 1112 1113 public static final EnumMap<Cns, String> CnsSTR = new EnumMap<>(Cns.class); 1114 static { 1115 CnsSTR.put(Cns.BRICK, "masonry"); 1116 CnsSTR.put(Cns.CONC, "concreted"); 1117 CnsSTR.put(Cns.BOULD, "boulders"); 1118 CnsSTR.put(Cns.HSURF, "hard_surfaced"); 1119 CnsSTR.put(Cns.USURF, "unsurfaced"); 1120 CnsSTR.put(Cns.WOOD, "wooden"); 1121 CnsSTR.put(Cns.METAL, "metal"); 1122 CnsSTR.put(Cns.GLAS, "grp"); 1123 CnsSTR.put(Cns.PAINT, "painted"); 1124 } 1125 1126 private Cns construction = Cns.UNKCNS; 1127 1128 public Cns getConstr() { 1129 return construction; 1130 } 1131 1132 public void setConstr(Cns cns) { 1133 construction = cns; 1134 } 1135 1136 public enum Con { 1137 UNKCON, CONSP, NCONS, REFL 1138 } 1139 1140 public static final EnumMap<Con, String> ConSTR = new EnumMap<>(Con.class); 1141 static { 1142 ConSTR.put(Con.CONSP, "conspicuous"); 1143 ConSTR.put(Con.NCONS, "not_conspicuous"); 1144 ConSTR.put(Con.REFL, "reflector"); 1145 } 1146 1147 private Con conspicuity = Con.UNKCON; 1148 1149 public Con getConsp() { 1150 return conspicuity; 1151 } 1152 1153 public void setConsp(Con con) { 1154 conspicuity = con; 1155 } 1156 1157 private Con reflectivity = Con.UNKCON; 1158 1159 public Con getRefl() { 1160 return reflectivity; 1161 } 1162 1163 public void setRefl(Con con) { 1164 reflectivity = con; 1165 } 1166 1167 public enum Fnc { 1168 UNKFNC, HMO, CSTM, HLTH, HOSP, POFF, HOTEL, RWSTA, POLICE, WPOL, PILO, PILL, BANK, DCHQ, TRNS, FACT, PWRS, ADMIN, EDUC, CHCH, CHPL, 1169 TMPL, PGDA, SHSH, BTMP, MOSQ, MRBT, LOOK, COMS, TV, RADO, RADR, LSUP, MWAV, COOL, OBSV, TIMB, CLK, CTRL, AMOR, STAD, BUSS, 1170 PRHB, RGLN, RSTN, RCMD, INFO 1171 } 1172 1173 public static final EnumMap<Fnc, String> FncSTR = new EnumMap<>(Fnc.class); 1174 static { 1175 FncSTR.put(Fnc.UNKFNC, ""); 1176 FncSTR.put(Fnc.HMO, "harbour-master"); 1177 FncSTR.put(Fnc.CSTM, "customs"); 1178 FncSTR.put(Fnc.HLTH, "health"); 1179 FncSTR.put(Fnc.HOSP, "hospital"); 1180 FncSTR.put(Fnc.POFF, "post_office"); 1181 FncSTR.put(Fnc.HOTEL, "hotel"); 1182 FncSTR.put(Fnc.RWSTA, "railway_station"); 1183 FncSTR.put(Fnc.POLICE, "police_station"); 1184 FncSTR.put(Fnc.WPOL, "water-police_station"); 1185 FncSTR.put(Fnc.PILO, "pilot_office"); 1186 FncSTR.put(Fnc.PILL, "pilot_lookout"); 1187 FncSTR.put(Fnc.BANK, "bank"); 1188 FncSTR.put(Fnc.DCHQ, "district_control"); 1189 FncSTR.put(Fnc.TRNS, "transit_shed"); 1190 FncSTR.put(Fnc.FACT, "factory"); 1191 FncSTR.put(Fnc.PWRS, "power_station"); 1192 FncSTR.put(Fnc.ADMIN, "administrative"); 1193 FncSTR.put(Fnc.EDUC, "educational"); 1194 FncSTR.put(Fnc.CHCH, "church"); 1195 FncSTR.put(Fnc.CHPL, "chapel"); 1196 FncSTR.put(Fnc.TMPL, "temple"); 1197 FncSTR.put(Fnc.PGDA, "pagoda"); 1198 FncSTR.put(Fnc.SHSH, "shinto_shrine"); 1199 FncSTR.put(Fnc.BTMP, "buddhist_temple"); 1200 FncSTR.put(Fnc.MOSQ, "mosque"); 1201 FncSTR.put(Fnc.MRBT, "marabout"); 1202 FncSTR.put(Fnc.LOOK, "lookout"); 1203 FncSTR.put(Fnc.COMS, "communication"); 1204 FncSTR.put(Fnc.TV, "television"); 1205 FncSTR.put(Fnc.RADO, "radio"); 1206 FncSTR.put(Fnc.RADR, "radar"); 1207 FncSTR.put(Fnc.LSUP, "light_support"); 1208 FncSTR.put(Fnc.MWAV, "microwave"); 1209 FncSTR.put(Fnc.COOL, "cooling"); 1210 FncSTR.put(Fnc.OBSV, "observation"); 1211 FncSTR.put(Fnc.TIMB, "time_ball"); 1212 FncSTR.put(Fnc.CLK, "clock"); 1213 FncSTR.put(Fnc.CTRL, "control"); 1214 FncSTR.put(Fnc.AMOR, "airship_mooring"); 1215 FncSTR.put(Fnc.STAD, "stadium"); 1216 FncSTR.put(Fnc.BUSS, "bus_station"); 1217 FncSTR.put(Fnc.PRHB, "prohibition"); 1218 FncSTR.put(Fnc.RGLN, "regulation"); 1219 FncSTR.put(Fnc.RSTN, "restriction"); 1220 FncSTR.put(Fnc.RCMD, "recommendation"); 1221 FncSTR.put(Fnc.INFO, "information"); 1222 } 1223 1224 private Fnc function = Fnc.UNKFNC; 1225 1226 public Fnc getFunc() { 1227 return function; 1228 } 1229 1230 public void setFunc(Fnc fnc) { 1231 function = fnc; 1232 repaint(); 1233 } 1234 1235 public String information = ""; 1236 1237 public String getInfo() { 1238 return information; 1239 } 1240 1241 public void setInfo(String str) { 1242 information = str.trim(); 1243 } 1244 1245 public String source = ""; 1246 1247 public String getSource() { 1248 return source; 1249 } 1250 1251 public void setSource(String str) { 1252 source = str.trim(); 1253 } 1254 1255 public String elevation = ""; 1256 1257 public String getElevation() { 1258 return elevation; 1259 } 1260 1261 public void setElevation(String str) { 1262 elevation = validDecimal(str); 1263 } 1264 1265 public String height = ""; 1266 1267 public String getObjectHeight() { 1268 return height; 1269 } 1270 1271 public void setObjectHeight(String str) { 1272 height = validDecimal(str); 1273 } 1274 1275 private String channel = ""; 1276 1277 public String getChannel() { 1278 return channel; 1279 } 1280 1281 public void setChannel(String per) { 1282 channel = validDecimal(per); 1283 repaint(); 1284 } 1285 1286 public String ref = ""; 1287 1288 public String getRef() { 1289 return ref; 1290 } 1291 1292 public void setRef(String str) { 1293 ref = str; 1294 } 1295 1296 public String lightRef = ""; 1297 1298 public String getLightRef() { 1299 return lightRef; 1300 } 1301 1302 public void setLightRef(String str) { 1303 lightRef = str; 1304 } 1305 1306 public String fixme = ""; 1307 1308 public String getFixme() { 1309 return fixme; 1310 } 1311 1312 public void setFixme(String str) { 1313 fixme = str; 1314 } 1315 1316 public boolean testValid() { 1317 if (dlg.node == null) return false; 1318 boolean tmp = false; 1319 PanelMain.messageBar.setText(""); 1320 switch (getObject()) { 1321 case BCNCAR: 1322 case BCNLAT: 1323 case BOYCAR: 1324 case BOYLAT: 1325 if ((getCategory() != Cat.NOCAT) && (getShape() != Shp.UNKSHP)) 1326 tmp = true; 1327 break; 1328 case BCNISD: 1329 case BCNSAW: 1330 case BCNSPP: 1331 case BOYISD: 1332 case BOYSAW: 1333 case BOYSPP: 1334 if (getShape() != Shp.UNKSHP) 1335 tmp = true; 1336 break; 1337 case FLTCAR: 1338 case FLTISD: 1339 case FLTLAT: 1340 case FLTSAW: 1341 case FLTSPP: 1342 if (getObjColour(0) != Col.UNKCOL) 1343 tmp = true; 1344 break; 1345 case LITMAJ: 1346 case LITMIN: 1347 case LITFLT: 1348 case LITVES: 1349 case LITHSE: 1350 case SISTAW: 1351 case SISTAT: 1352 case OFSPLF: 1353 case MORFAC: 1354 case BOYINB: 1355 case PILBOP: 1356 case RSCSTA: 1357 case RDOSTA: 1358 case RADSTA: 1359 tmp = true; 1360 break; 1361 case NOTMRK: 1362 if (getCategory() != Cat.NOCAT) 1363 tmp = true; 1364 case LNDMRK: 1365 if ((getCategory() != Cat.NOCAT) || (getFunc() != Fnc.UNKFNC)) 1366 tmp = true; 1367 break; 1368 } 1369 if (tmp) { 1370 SmedAction.panelMain.moreButton.setVisible(true); 1371 SmedAction.panelMain.saveButton.setEnabled(true); 1372 SmedAction.panelMain.topButton.setEnabled(true); 1373 SmedAction.panelMain.fogButton.setEnabled(true); 1374 SmedAction.panelMain.radButton.setEnabled(true); 1375 SmedAction.panelMain.litButton.setEnabled(true); 1376 return true; 1377 } else { 1378 SmedAction.panelMain.moreButton.setVisible(false); 1379 SmedAction.panelMain.moreButton.setText(">>"); 1380 SmedAction.panelMain.topButton.setEnabled(false); 1381 SmedAction.panelMain.fogButton.setEnabled(false); 1382 SmedAction.panelMain.radButton.setEnabled(false); 1383 SmedAction.panelMain.litButton.setEnabled(false); 1384 PanelMain.messageBar.setText("Seamark not recognised"); 1385 return false; 1386 } 1387 } 1388 1389 public void clrMark() { 1390 setName(""); 1391 setObject(Obj.UNKOBJ); 1392 clrLight(); 1393 setFogSound(Fog.NOFOG); 1394 setRadar(Rtb.NORTB); 1395 setRadio(Cat.NOROS); 1396 setStatus(Sts.UNKSTS); 1397 setConstr(Cns.UNKCNS); 1398 setConsp(Con.UNKCON); 1399 setRefl(Con.UNKCON); 1400 setRef(""); 1401 setObjectHeight(""); 1402 setElevation(""); 1403 setChannel(""); 1404 setInfo(""); 1405 setSource(""); 1406 setFixme(""); 1407 SmedAction.panelMain.syncPanel(); 1408 repaint(); 1409 } 1410 1411 public String validDecimal(String str) { 1412 str = str.trim().replace(',', '.'); 1413 if (!(str.isEmpty()) && !(str.matches("^[+-]??\\d+(\\.\\d+)??$"))) { 1414 PanelMain.messageBar.setText(Messages.getString("NotDecimal")); 1415 return ""; 1416 } else { 1417 PanelMain.messageBar.setText(""); 1418 return str; 1419 } 1420 } 1421 1422 public String validDecimal(String str, float max) { 1423 str = validDecimal(str); 1424 if (!(str.isEmpty()) && (new Float(str) > max)) { 1425 PanelMain.messageBar.setText(Messages.getString("TooBig") + " (" + max + ")"); 1426 return ""; 1427 } else { 1428 PanelMain.messageBar.setText(""); 1429 return str; 1430 } 1431 } 1432 1433 public void parseMark(OsmPrimitive node) { 1434 PanelMain.messageBar.setText(""); 1435 String str = Main.pref.get("smedplugin.IALA"); 1436 if (str.equals("C")) 1437 setRegion(Reg.C); 1438 else if (str.equals("B")) 1439 setRegion(Reg.B); 1440 else 1441 setRegion(Reg.A); 1442 1443 Map<String, String> keys = node.getKeys(); 1444 1445 str = ""; 1446 if (keys.containsKey("seamark:type")) 1447 str = keys.get("seamark:type"); 1448 1449 clrMark(); 1450 for (Obj obj : ObjSTR.keySet()) { 1451 if (ObjSTR.get(obj).equals(str)) { 1452 setObject(obj); 1453 } 1454 } 1455 1456 if (str.equals("")) { 1457 PanelMain.messageBar.setText("No seamark"); 1458 } 1459 if (getObject() == Obj.UNKOBJ) { 1460 PanelMain.messageBar.setText("Seamark not recognised"); 1461 } 1462 1463 setName(""); 1464 for (Obj obj : ObjSTR.keySet()) { 1465 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":name")) { 1466 str = keys.get("seamark:" + ObjSTR.get(obj) + ":name"); 1467 setName(str); 1468 } 1469 } 1470 if (keys.containsKey("seamark:name")) { 1471 str = keys.get("seamark:name"); 1472 setName(str); 1473 } 1474 1475 for (Obj obj : ObjSTR.keySet()) { 1476 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":category")) { 1477 str = keys.get("seamark:" + ObjSTR.get(obj) + ":category"); 1478 if (obj == getObject()) { 1479 setCategory(Cat.NOCAT); 1480 for (Cat cat : CatSTR.keySet()) { 1481 if (CatSTR.get(cat).equals(str)) { 1482 setCategory(cat); 1483 } 1484 } 1485 } 1486 } 1487 } 1488 1489 for (Obj obj : ObjSTR.keySet()) { 1490 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":shape")) { 1491 str = keys.get("seamark:" + ObjSTR.get(obj) + ":shape"); 1492 setShape(Shp.UNKSHP); 1493 for (Shp shp : ShpSTR.keySet()) { 1494 if (ShpSTR.get(shp).equals(str)) { 1495 setShape(shp); 1496 } 1497 } 1498 } 1499 } 1500 if (getShape() == Shp.UNKSHP) { 1501 if (EntMAP.get(getObject()) == Ent.BUOY) 1502 setShape(Shp.BUOY); 1503 if (EntMAP.get(getObject()) == Ent.BEACON) 1504 setShape(Shp.BEACON); 1505 if (EntMAP.get(getObject()) == Ent.LFLOAT) 1506 if (getObject() == Obj.LITVES) 1507 setShape(Shp.SUPER); 1508 else 1509 setShape(Shp.FLOAT); 1510 } 1511 1512 for (Obj obj : ObjSTR.keySet()) { 1513 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":colour")) { 1514 str = keys.get("seamark:" + ObjSTR.get(obj) + ":colour"); 1515 bodyColour.clear(); 1516 for (String item : str.split(";")) { 1517 for (Col col : ColSTR.keySet()) { 1518 if (ColSTR.get(col).equals(item)) { 1519 bodyColour.add(col); 1520 } 1521 } 1522 } 1523 } 1524 } 1525 1526 for (Obj obj : ObjSTR.keySet()) { 1527 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":colour_pattern")) { 1528 str = keys.get("seamark:" + ObjSTR.get(obj) + ":colour_pattern"); 1529 setObjPattern(Pat.NOPAT); 1530 for (Pat pat : PatSTR.keySet()) { 1531 if (PatSTR.get(pat).equals(str)) { 1532 setObjPattern(pat); 1533 } 1534 } 1535 } 1536 1537 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":height")) { 1538 setObjectHeight(keys.get("seamark:" + ObjSTR.get(obj) + ":height")); 1539 } 1540 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":elevation")) { 1541 setElevation(keys.get("seamark:" + ObjSTR.get(obj) + ":elevation")); 1542 } 1543 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":channel")) { 1544 setChannel(keys.get("seamark:" + ObjSTR.get(obj) + ":channel")); 1545 } 1546 } 1547 1548 for (Obj obj : ObjSTR.keySet()) { 1549 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":function")) { 1550 str = keys.get("seamark:" + ObjSTR.get(obj) + ":function"); 1551 setFunc(Fnc.UNKFNC); 1552 for (Fnc fnc : FncSTR.keySet()) { 1553 if (FncSTR.get(fnc).equals(str)) { 1554 setFunc(fnc); 1555 } 1556 } 1557 } 1558 } 1559 1560 if ((getObject() == Obj.LNDMRK) && (getCategory() == Cat.NOCAT) && (getFunc() == Fnc.UNKFNC)) { 1561 setObject(Obj.LITHSE); 1562 } 1563 1564 if (getObject() == Obj.LITFLT) { 1565 switch (getObjColour(0)) { 1566 case RED: 1567 if ((getObjColour(1) == Col.WHITE) && (getObjColour(2) == Col.UNKCOL)) { 1568 setObject(Obj.FLTSAW); 1569 setCategory(Cat.NOCAT); 1570 } else if (getObjColour(1) == Col.UNKCOL) { 1571 setObject(Obj.FLTLAT); 1572 if (getRegion() == Reg.B) { 1573 setCategory(Cat.LAM_STBD); 1574 } else { 1575 setCategory(Cat.LAM_PORT); 1576 } 1577 } else if ((getObjColour(1) == Col.GREEN) 1578 && (getObjColour(2) == Col.RED)) { 1579 setObject(Obj.FLTLAT); 1580 if (getRegion() == Reg.B) { 1581 setCategory(Cat.LAM_PSTBD); 1582 } else { 1583 setCategory(Cat.LAM_PPORT); 1584 } 1585 } else if ((getObjColour(1) == Col.WHITE) 1586 && (getObjColour(2) == Col.RED)) { 1587 setObject(Obj.FLTLAT); 1588 setCategory(Cat.LAM_PORT); 1589 } else { 1590 setObject(Obj.FLTSPP); 1591 setCategory(Cat.NOCAT); 1592 } 1593 break; 1594 case GREEN: 1595 if (getObjColour(1) == Col.UNKCOL) { 1596 setObject(Obj.FLTLAT); 1597 if (getRegion() == Reg.B) { 1598 setCategory(Cat.LAM_PORT); 1599 } else { 1600 setCategory(Cat.LAM_STBD); 1601 } 1602 } else if ((getObjColour(1) == Col.RED) 1603 && (getObjColour(2) == Col.GREEN)) { 1604 setObject(Obj.FLTLAT); 1605 if (getRegion() == Reg.B) { 1606 setCategory(Cat.LAM_PPORT); 1607 } else { 1608 setCategory(Cat.LAM_PSTBD); 1609 } 1610 } else if ((getObjColour(1) == Col.WHITE) 1611 && (getObjColour(2) == Col.GREEN)) { 1612 setObject(Obj.FLTLAT); 1613 setCategory(Cat.LAM_STBD); 1614 } else { 1615 setObject(Obj.FLTSPP); 1616 setCategory(Cat.NOCAT); 1617 } 1618 break; 1619 case YELLOW: 1620 if (getObjColour(1) == Col.BLACK) { 1621 setObject(Obj.FLTCAR); 1622 if (getObjColour(2) == Col.YELLOW) { 1623 setCategory(Cat.CAM_WEST); 1624 } else { 1625 setCategory(Cat.CAM_SOUTH); 1626 } 1627 } else { 1628 setObject(Obj.FLTSPP); 1629 setCategory(Cat.NOCAT); 1630 } 1631 break; 1632 case BLACK: 1633 if (getObjColour(1) == Col.RED) { 1634 setObject(Obj.FLTISD); 1635 setCategory(Cat.NOCAT); 1636 } else if (getObjColour(1) == Col.YELLOW) { 1637 setObject(Obj.FLTCAR); 1638 if (getObjColour(2) == Col.BLACK) { 1639 setCategory(Cat.CAM_EAST); 1640 } else { 1641 setCategory(Cat.CAM_NORTH); 1642 } 1643 } else { 1644 setObject(Obj.FLTSPP); 1645 setCategory(Cat.NOCAT); 1646 } 1647 break; 1648 default: 1649 setCategory(Cat.NOCAT); 1650 } 1651 } 1652 1653 for (Obj obj : ObjSTR.keySet()) { 1654 if (keys.containsKey("seamark:" + ObjSTR.get(obj) + ":system")) { 1655 str = keys.get("seamark:" + ObjSTR.get(obj) + ":system"); 1656 if (str.equals("iala-a")) 1657 setRegion(Reg.A); 1658 else if (str.equals("iala-b")) 1659 setRegion(Reg.B); 1660 else 1661 setRegion(Reg.C); 1662 } else if (GrpMAP.get(object) == Grp.LAT) { 1663 switch (getCategory()) { 1664 case LAM_PORT: 1665 if (getObjColour(0) == Col.RED) { 1666 if (getObjColour(1) == Col.WHITE) 1667 setRegion(Reg.C); 1668 else 1669 setRegion(Reg.A); 1670 } 1671 if (getObjColour(0) == Col.GREEN) 1672 setRegion(Reg.B); 1673 break; 1674 case LAM_PPORT: 1675 if (getObjColour(0) == Col.RED) { 1676 if (getObjColour(3) == Col.GREEN) 1677 setRegion(Reg.C); 1678 else 1679 setRegion(Reg.B); 1680 } 1681 if (getObjColour(0) == Col.GREEN) 1682 setRegion(Reg.A); 1683 break; 1684 case LAM_STBD: 1685 if (getObjColour(0) == Col.GREEN) { 1686 if (getObjColour(1) == Col.WHITE) 1687 setRegion(Reg.C); 1688 else 1689 setRegion(Reg.A); 1690 } 1691 if (getObjColour(0) == Col.RED) 1692 setRegion(Reg.B); 1693 break; 1694 case LAM_PSTBD: 1695 if (getObjColour(0) == Col.GREEN) 1696 setRegion(Reg.B); 1697 if (getObjColour(0) == Col.RED) { 1698 if (getObjColour(3) == Col.GREEN) 1699 setRegion(Reg.C); 1700 else 1701 setRegion(Reg.A); 1702 } 1703 break; 1704 } 1705 } 1706 } 1707 1708 if (keys.containsKey("seamark:topmark:shape")) { 1709 str = keys.get("seamark:topmark:shape"); 1710 setTopmark(Top.NOTOP); 1711 for (Top top : TopSTR.keySet()) { 1712 if (TopSTR.get(top).equals(str)) { 1713 setTopmark(top); 1714 } 1715 } 1716 } 1717 if (keys.containsKey("seamark:topmark:colour")) { 1718 str = keys.get("seamark:topmark:colour"); 1719 setTopColour(Col.UNKCOL); 1720 for (Col col : ColSTR.keySet()) { 1721 if (ColSTR.get(col).equals(str)) { 1722 setTopColour(col); 1723 } 1724 } 1725 } 1726 if (keys.containsKey("seamark:topmark:colour_pattern")) { 1727 str = keys.get("seamark:topmark:colour_pattern"); 1728 setTopPattern(Pat.NOPAT); 1729 for (Pat pat : PatSTR.keySet()) { 1730 if (PatSTR.get(pat).equals(str)) { 1731 setTopPattern(pat); 1732 } 1733 } 1734 } 1735 1736 clrLight(); 1737 for (int i = 0; i < 30; i++) { 1738 String secStr = (i == 0) ? "" : (":" + Integer.toString(i)); 1739 if (keys.containsKey("seamark:light" + secStr + ":colour")) { 1740 nulLight(i); 1741 str = keys.get("seamark:light" + secStr + ":colour"); 1742 if (str.contains(";")) { 1743 String strs[] = str.split(";"); 1744 for (Col col : ColSTR.keySet()) 1745 if ((strs.length > 1) && ColSTR.get(col).equals(strs[1])) 1746 setLightAtt(Att.ALT, i, col); 1747 str = strs[0]; 1748 } 1749 for (Col col : ColSTR.keySet()) 1750 if (ColSTR.get(col).equals(str)) 1751 setLightAtt(Att.COL, i, col); 1752 } 1753 if (keys.containsKey("seamark:light" + secStr + ":character")) { 1754 str = keys.get("seamark:light" + secStr + ":character"); 1755 if (str.contains("(") && str.contains(")")) { 1756 int i1 = str.indexOf("("); 1757 int i2 = str.indexOf(")"); 1758 setLightAtt(Att.GRP, i, str.substring((i1+1), i2)); 1759 str = str.substring(0, i1) + str.substring((i2+1), str.length()); 1760 } 1761 setLightAtt(Att.CHR, i, str); 1762 } 1763 if (keys.containsKey("seamark:light" + secStr + ":group")) 1764 setLightAtt(Att.GRP, i, keys.get("seamark:light" + secStr + ":group")); 1765 if (keys.containsKey("seamark:light" + secStr + ":sequence")) 1766 setLightAtt(Att.SEQ, i, keys.get("seamark:light" + secStr + ":sequence")); 1767 if (keys.containsKey("seamark:light" + secStr + ":period")) 1768 setLightAtt(Att.PER, i, keys.get("seamark:light" + secStr + ":period")); 1769 if (keys.containsKey("seamark:light" + secStr + ":category")) { 1770 str = keys.get("seamark:light" + secStr + ":category"); 1771 if (str.equals("vert")) 1772 str = "vertical"; 1773 if (str.equals("horiz")) 1774 str = "horizontal"; 1775 for (Lit lit : LitSTR.keySet()) 1776 if (LitSTR.get(lit).equals(str)) 1777 setLightAtt(Att.LIT, i, lit); 1778 } 1779 if (keys.containsKey("seamark:light" + secStr + ":sector_start")) 1780 setLightAtt(Att.BEG, i, keys.get("seamark:light" + secStr + ":sector_start")); 1781 if (keys.containsKey("seamark:light" + secStr + ":sector_end")) 1782 setLightAtt(Att.END, i, keys.get("seamark:light" + secStr + ":sector_end")); 1783 if (keys.containsKey("seamark:light" + secStr + ":radius")) 1784 setLightAtt(Att.RAD, i, keys.get("seamark:light" + secStr + ":radius")); 1785 if (keys.containsKey("seamark:light" + secStr + ":height")) 1786 setLightAtt(Att.HGT, i, keys.get("seamark:light" + secStr + ":height")); 1787 if (keys.containsKey("seamark:light" + secStr + ":range")) 1788 setLightAtt(Att.RNG, i, keys.get("seamark:light" + secStr + ":range")); 1789 if (keys.containsKey("seamark:light" + secStr + ":visibility")) { 1790 str = keys.get("seamark:light" + secStr + ":visibility"); 1791 for (Vis vis : VisSTR.keySet()) 1792 if (VisSTR.get(vis).equals(str)) 1793 setLightAtt(Att.VIS, i, vis); 1794 } 1795 if (keys.containsKey("seamark:light" + secStr + ":exhibition")) { 1796 str = keys.get("seamark:light" + secStr + ":exhibition"); 1797 for (Exh exh : ExhSTR.keySet()) 1798 if (ExhSTR.get(exh).equals(str)) 1799 setLightAtt(Att.EXH, i, exh); 1800 } 1801 if (keys.containsKey("seamark:light" + secStr + ":orientation")) 1802 setLightAtt(Att.ORT, i, keys.get("seamark:light" + secStr + ":orientation")); 1803 if (keys.containsKey("seamark:light" + secStr + ":multiple")) 1804 setLightAtt(Att.MLT, i, keys.get("seamark:light" + secStr + ":multiple")); 1805 1806 if (sectors.size() == i) 1807 break; 1808 } 1809 1810 if (keys.containsKey("seamark:fog_signal")) { 1811 setFogSound(Fog.FOGSIG); 1812 } 1813 if (keys.containsKey("seamark:fog_signal:category")) { 1814 str = keys.get("seamark:fog_signal:category"); 1815 setFogSound(Fog.NOFOG); 1816 for (Fog fog : FogSTR.keySet()) { 1817 if (FogSTR.get(fog).equals(str)) { 1818 setFogSound(fog); 1819 } 1820 } 1821 } 1822 if (keys.containsKey("seamark:fog_signal:group")) { 1823 setFogGroup(keys.get("seamark:fog_signal:group")); 1824 } 1825 if (keys.containsKey("seamark:fog_signal:period")) { 1826 setFogPeriod(keys.get("seamark:fog_signal:period")); 1827 } 1828 if (keys.containsKey("seamark:fog_signal:sequence")) { 1829 setFogSequence(keys.get("seamark:fog_signal:sequence")); 1830 } 1831 if (keys.containsKey("seamark:fog_signal:range")) { 1832 setFogRange(keys.get("seamark:fog_signal:range")); 1833 } 1834 1835 if (keys.containsKey("seamark:radio_station:category")) { 1836 str = keys.get("seamark:radio_station:category"); 1837 setRadio(Cat.NOROS); 1838 for (Cat rdo : CatSTR.keySet()) { 1839 if (CatSTR.get(rdo).equals(str)) { 1840 setRadio(rdo); 1841 } 1842 } 1843 } 1844 1845 if (keys.containsKey("seamark:radar_reflector")) { 1846 setRadar(Rtb.REFLECTOR); 1847 } 1848 if (keys.containsKey("seamark:radar_transponder:category")) { 1849 str = keys.get("seamark:radar_transponder:category"); 1850 setRadar(Rtb.NORTB); 1851 for (Rtb rtb : RtbSTR.keySet()) { 1852 if (RtbSTR.get(rtb).equals(str)) { 1853 setRadar(rtb); 1854 } 1855 } 1856 } 1857 if (keys.containsKey("seamark:radar_transponder:group")) { 1858 setRaconGroup(keys.get("seamark:radar_transponder:group")); 1859 } 1860 if (keys.containsKey("seamark:radar_transponder:period")) { 1861 setRaconPeriod(keys.get("seamark:radar_transponder:period")); 1862 } 1863 if (keys.containsKey("seamark:radar_transponder:sequence")) { 1864 setRaconSequence(keys.get("seamark:radar_transponder:sequence")); 1865 } 1866 if (keys.containsKey("seamark:radar_transponder:range")) { 1867 setRaconRange(keys.get("seamark:radar_transponder:range")); 1868 } 1869 if (keys.containsKey("seamark:radar_transponder:sector_start")) { 1870 setRaconSector1(keys.get("seamark:radar_transponder:sector_start")); 1871 } 1872 if (keys.containsKey("seamark:radar_transponder:sector_end")) { 1873 setRaconSector2(keys.get("seamark:radar_transponder:sector_end")); 1874 } 1875 1876 if (keys.containsKey("seamark:information")) { 1877 setInfo(keys.get("seamark:information")); 1878 } 1879 if (keys.containsKey("seamark:light:information")) { 1880 setInfo(getInfo() + keys.get("seamark:light:information")); 1881 } 1882 if (keys.containsKey("seamark:" + ObjSTR.get(getObject()) + "information")) { 1883 setInfo(getInfo() + keys.get("seamark:" + ObjSTR.get(getObject()) + "information")); 1884 } 1885 if (keys.containsKey("seamark:source")) { 1886 setSource(keys.get("seamark:source")); 1887 } 1888 if (keys.containsKey("seamark:light:source")) { 1889 setSource(getSource() + keys.get("seamark:light:source")); 1890 } 1891 if (keys.containsKey("seamark:" + ObjSTR.get(getObject()) + "source")) { 1892 setSource(getSource() + keys.get("seamark:" + ObjSTR.get(getObject()) + "source")); 1893 } 1894 if (keys.containsKey("seamark:height")) { 1895 setObjectHeight(keys.get("seamark:height")); 1896 } 1897 if (keys.containsKey("seamark:elevation")) { 1898 setElevation(keys.get("seamark:elevation")); 1899 } 1900 if (keys.containsKey("seamark:status")) { 1901 str = keys.get("seamark:status"); 1902 setStatus(Sts.UNKSTS); 1903 for (Sts sts : StsSTR.keySet()) { 1904 if (StsSTR.get(sts).equals(str)) { 1905 setStatus(sts); 1906 } 1907 } 1908 } 1909 if (keys.containsKey("seamark:construction")) { 1910 str = keys.get("seamark:construction"); 1911 setConstr(Cns.UNKCNS); 1912 for (Cns cns : CnsSTR.keySet()) { 1913 if (CnsSTR.get(cns).equals(str)) { 1914 setConstr(cns); 1915 } 1916 } 1917 } 1918 if (keys.containsKey("seamark:conspicuity")) { 1919 str = keys.get("seamark:conspicuity"); 1920 setConsp(Con.UNKCON); 1921 for (Con con : ConSTR.keySet()) { 1922 if (ConSTR.get(con).equals(str)) { 1923 setConsp(con); 1924 } 1925 } 1926 } 1927 if (keys.containsKey("seamark:reflectivity")) { 1928 str = keys.get("seamark:reflectivity"); 1929 setRefl(Con.UNKCON); 1930 for (Con con : ConSTR.keySet()) { 1931 if (ConSTR.get(con).equals(str)) { 1932 setRefl(con); 1933 } 1934 } 1935 } 1936 1937 if (keys.containsKey("seamark:ref")) { 1938 setRef(keys.get("seamark:ref")); 1939 } 1940 if (keys.containsKey("seamark:reference")) { 1941 setRef(keys.get("seamark:reference")); 1942 } 1943 if (keys.containsKey("seamark:light:ref")) { 1944 setLightRef(keys.get("seamark:light:ref")); 1945 } 1946 if (keys.containsKey("seamark:light:reference")) { 1947 setLightRef(keys.get("seamark:light:reference")); 1948 } 1949 if (keys.containsKey("seamark:fixme")) { 1950 setFixme(keys.get("seamark:fixme")); 1951 } 1952 1953 dlg.panelMain.syncPanel(); 1954 } 1955 1956 public void paintComponent(Graphics g) { 1957 super.paintComponent(g); 1958 1959 if (dlg.node == null) return; 1960 1954 1961 Graphics2D g2 = (Graphics2D) g; 1955 1962 1956 1963 String colStr; 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 1964 String lblStr; 1965 String imgStr = "/images/"; 1966 if (getShape() != Shp.UNKSHP) { 1967 switch (getShape()) { 1968 case TOWER: 1969 imgStr += "Tower"; 1970 break; 1971 case BUOY: 1972 case PILLAR: 1973 imgStr += "Pillar"; 1974 break; 1975 case SPAR: 1976 imgStr += "Spar"; 1977 break; 1978 case CAN: 1979 imgStr += "Can"; 1980 break; 1981 case CONI: 1982 imgStr += "Cone"; 1983 break; 1984 case SPHERI: 1985 imgStr += "Sphere"; 1986 break; 1987 case BARREL: 1988 imgStr += "Barrel"; 1989 break; 1990 case CAIRN: 1991 imgStr += "Cairn"; 1992 break; 1993 case FLOAT: 1994 imgStr += "Float"; 1995 break; 1996 case BEACON: 1997 case PILE: 1998 case LATTICE: 1999 case BUOYANT: 2000 imgStr += "Beacon"; 2001 break; 2002 case SUPER: 2003 imgStr += "Super"; 2004 break; 2005 case STAKE: 2006 case POLE: 2007 case POST: 2008 imgStr += "Stake"; 2009 break; 2010 case PERCH: 2011 if (getCategory() == Cat.LAM_PORT) { 2012 imgStr += "Perch_Port"; 2013 } else { 2014 imgStr += "Perch_Starboard"; 2015 } 2016 break; 2017 } 2018 colStr = imgStr; 2019 lblStr = ""; 2020 for (Col col : bodyColour) { 2021 switch (col) { 2022 case WHITE: 2023 colStr += "_White"; 2024 lblStr += "W"; 2025 break; 2026 case RED: 2027 colStr += "_Red"; 2028 lblStr += "R"; 2029 break; 2030 case ORANGE: 2031 colStr += "_Orange"; 2032 lblStr += "Or"; 2033 break; 2034 case AMBER: 2035 colStr += "_Amber"; 2036 lblStr += "Am"; 2037 break; 2038 case YELLOW: 2039 colStr += "_Yellow"; 2040 lblStr += "Y"; 2041 break; 2042 case GREEN: 2043 colStr += "_Green"; 2044 lblStr += "G"; 2045 break; 2046 case BLUE: 2047 colStr += "_Blue"; 2048 lblStr += "Bu"; 2049 break; 2050 case VIOLET: 2051 colStr += "_Violet"; 2052 lblStr += "Vi"; 2053 break; 2054 case BLACK: 2055 colStr += "_Black"; 2056 lblStr += "B"; 2057 break; 2058 case GREY: 2059 colStr += "_Grey"; 2060 lblStr += "Gr"; 2061 break; 2062 case BROWN: 2063 colStr += "_Brown"; 2064 lblStr += "Br"; 2065 break; 2066 case MAGENTA: 2067 colStr += "_Magenta"; 2068 lblStr += "Mg"; 2069 break; 2070 case PINK: 2071 colStr += "_Pink"; 2072 lblStr += "Pk"; 2073 break; 2074 } 2075 } 2076 if (!imgStr.equals("/images/")) { 2077 colStr += ".png"; 2078 if (getClass().getResource(colStr) == null) { 2079 System.out.println("Missing image1: " + colStr); 2080 imgStr += ".png"; 2081 if (getClass().getResource(imgStr) == null) { 2082 System.out.println("Missing image2: " + imgStr); 2083 } else { 2084 g2.drawImage(new ImageIcon(getClass().getResource(imgStr)).getImage(), 7, -15, null); 2085 g2.drawString(lblStr, 75, 110); 2086 } 2087 } else { 2088 g2.drawImage(new ImageIcon(getClass().getResource(colStr)).getImage(), 7, -15, null); 2089 } 2090 } 2091 } else if (getObject() != Obj.UNKOBJ) { 2092 switch (getObject()) { 2093 case LNDMRK: 2094 switch (getCategory()) { 2095 case LMK_CHMY: 2096 imgStr += "Chimney"; 2097 break; 2098 case LMK_CARN: 2099 imgStr += "Cairn"; 2100 break; 2101 case LMK_DSHA: 2102 imgStr += "DishAerial"; 2103 break; 2104 case LMK_FLGS: 2105 imgStr += "Flagstaff"; 2106 break; 2107 case LMK_FLRS: 2108 imgStr += "FlareStack"; 2109 break; 2110 case LMK_MNMT: 2111 case LMK_CLMN: 2112 case LMK_OBLK: 2113 case LMK_STAT: 2114 imgStr += "Monument"; 2115 break; 2116 case LMK_MAST: 2117 imgStr += "RadioMast"; 2118 break; 2119 case LMK_TOWR: 2120 if ((getFunc() == Fnc.CHCH) || (getFunc() == Fnc.CHPL)) 2121 imgStr += "ChurchTower"; 2122 else 2123 imgStr += "LandTower"; 2124 break; 2125 case LMK_WNDM: 2126 imgStr += "Wind_Motor"; 2127 break; 2128 case LMK_WTRT: 2129 imgStr += "WaterTower"; 2130 break; 2131 case LMK_DOME: 2132 if ((getFunc() == Fnc.CHCH) || (getFunc() == Fnc.CHPL)) 2133 imgStr += "ChurchDome"; 2134 else 2135 imgStr += "Dome"; 2136 break; 2137 case LMK_SPIR: 2138 if ((getFunc() == Fnc.CHCH) || (getFunc() == Fnc.CHPL)) 2139 imgStr += "ChurchSpire"; 2140 else 2141 imgStr += "Spire"; 2142 break; 2143 case LMK_MNRT: 2144 imgStr += "Minaret"; 2145 break; 2146 case LMK_WNDS: 2147 imgStr += "Windsock"; 2148 break; 2149 case LMK_CROS: 2150 imgStr += "Cross"; 2151 break; 2152 case LMK_SCNR: 2153 imgStr += "Signal_Station"; 2154 break; 2155 case LMK_WNDL: 2156 imgStr += "Windmill"; 2157 break; 2158 case NOCAT: 2159 switch (getFunc()) { 2160 case CHCH: 2161 case CHPL: 2162 imgStr += "Church"; 2163 break; 2164 case TMPL: 2165 case PGDA: 2166 case SHSH: 2167 case BTMP: 2168 imgStr += "Temple"; 2169 break; 2170 case MOSQ: 2171 imgStr += "Minaret"; 2172 break; 2173 case MRBT: 2174 imgStr += "Spire"; 2175 break; 2176 } 2177 } 2178 break; 2179 case LITHSE: 2180 imgStr += "Light_House"; 2181 break; 2182 case LITMAJ: 2183 imgStr += "Light_Major"; 2184 break; 2185 case LITMIN: 2186 imgStr += "Light_Minor"; 2187 break; 2188 case LITFLT: 2189 imgStr += "Float"; 2190 break; 2191 case LITVES: 2192 imgStr += "Super"; 2193 break; 2194 case SISTAW: 2195 imgStr += "Signal_Station"; 2196 break; 2197 case SISTAT: 2198 imgStr += "Signal_Station"; 2199 break; 2200 case OFSPLF: 2201 if (getCategory() == Cat.OFP_FPSO) 2202 imgStr += "Storage"; 2203 else 2204 imgStr += "Platform"; 2205 break; 2206 case MORFAC: 2207 switch (getCategory()) { 2208 case MOR_DLPN: 2209 imgStr += "Dolphin"; 2210 break; 2211 case MOR_DDPN: 2212 imgStr += "DeviationDolphin"; 2213 break; 2214 case MOR_POST: 2215 imgStr += "Post"; 2216 break; 2217 case MOR_BUOY: 2218 imgStr += "Sphere"; 2219 break; 2220 } 2221 break; 2222 case BOYINB: 2223 imgStr += "Super"; 2224 break; 2225 case CGUSTA: 2226 imgStr += "Signal_Station"; 2227 break; 2228 case PILBOP: 2229 imgStr += "Pilot"; 2230 break; 2231 case RSCSTA: 2232 imgStr += "Rescue"; 2233 break; 2234 case RDOSTA: 2235 case RADSTA: 2236 imgStr += "Signal_Station"; 2237 g2.drawImage(new ImageIcon(getClass().getResource("/images/Radar_Station.png")).getImage(), 7, -15, null); 2238 break; 2239 } 2240 if (!imgStr.equals("/images/")) { 2241 imgStr += ".png"; 2242 if (getClass().getResource(imgStr) == null) { 2243 System.out.println("Missing image3: " + imgStr); 2244 } else { 2245 g2.drawImage(new ImageIcon(getClass().getResource(imgStr)).getImage(), 7, -15, null); 2246 } 2247 } 2248 } 2249 2250 if (getTopmark() != Top.NOTOP) { 2251 imgStr = "/images/Top_"; 2252 switch (getTopmark()) { 2253 case CYL: 2254 imgStr += "Can"; 2255 break; 2256 case CONE: 2257 imgStr += "Cone"; 2258 break; 2259 case SPHERE: 2260 imgStr += "Sphere"; 2261 break; 2262 case X_SHAPE: 2263 imgStr += "X"; 2264 break; 2265 case NORTH: 2266 imgStr += "North"; 2267 break; 2268 case SOUTH: 2269 imgStr += "South"; 2270 break; 2271 case EAST: 2272 imgStr += "East"; 2273 break; 2274 case WEST: 2275 imgStr += "West"; 2276 break; 2277 case SPHERES2: 2278 imgStr += "Isol"; 2279 break; 2280 } 2281 colStr = imgStr; 2282 for (Col col : topmarkColour) { 2283 switch (col) { 2284 case WHITE: 2285 colStr += "_White"; 2286 break; 2287 case RED: 2288 colStr += "_Red"; 2289 break; 2290 case ORANGE: 2291 colStr += "_Orange"; 2292 break; 2293 case AMBER: 2294 colStr += "_Amber"; 2295 break; 2296 case YELLOW: 2297 colStr += "_Yellow"; 2298 break; 2299 case GREEN: 2300 colStr += "_Green"; 2301 break; 2302 case BLUE: 2303 colStr += "_Blue"; 2304 break; 2305 case VIOLET: 2306 colStr += "_Violet"; 2307 break; 2308 case BLACK: 2309 colStr += "_Black"; 2310 break; 2311 } 2312 } 2313 switch (getShape()) { 2314 case CAN: 2315 case CONI: 2316 case SPHERI: 2317 case BARREL: 2318 imgStr += "_Buoy_Small"; 2319 colStr += "_Buoy_Small"; 2320 break; 2321 case PILLAR: 2322 case SPAR: 2323 imgStr += "_Buoy"; 2324 colStr += "_Buoy"; 2325 break; 2326 case FLOAT: 2327 case SUPER: 2328 imgStr += "_Float"; 2329 colStr += "_Float"; 2330 break; 2331 case BUOYANT: 2332 case CAIRN: 2333 case PILE: 2334 case LATTICE: 2335 case TOWER: 2336 case STAKE: 2337 case POLE: 2338 case POST: 2339 case BEACON: 2340 imgStr += "_Beacon"; 2341 colStr += "_Beacon"; 2342 break; 2343 } 2344 colStr += ".png"; 2345 if (getClass().getResource(colStr) == null) { 2346 System.out.println("Missing image4: " + colStr); 2347 imgStr += ".png"; 2348 if (getClass().getResource(imgStr) == null) { 2349 System.out.println("Missing image5: " + imgStr); 2350 return; 2351 } else { 2352 g2.drawImage(new ImageIcon(getClass().getResource(imgStr)).getImage(), 7, -15, null); 2353 } 2354 } else { 2355 g2.drawImage(new ImageIcon(getClass().getResource(colStr)).getImage(), 7, -15, null); 2356 } 2357 } else { 2358 if ((getObject() == Obj.BOYINB) || ((getObject() == Obj.MORFAC) && (getCategory() == Cat.MOR_BUOY))) { 2359 imgStr = "/images/Top_Mooring"; 2360 switch (getShape()) { 2361 case CAN: 2362 case CONI: 2363 case SPHERI: 2364 case BARREL: 2365 imgStr += "_Buoy_Small"; 2366 break; 2367 case FLOAT: 2368 case SUPER: 2369 imgStr += "_Float"; 2370 break; 2371 default: 2372 if (getObject() == Obj.MORFAC) { 2373 imgStr += "_Buoy_Small"; 2374 } else { 2375 imgStr += "_Float"; 2376 } 2377 break; 2378 } 2379 imgStr += ".png"; 2380 if (getClass().getResource(imgStr) == null) { 2381 System.out.println("Missing image6: " + imgStr); 2382 return; 2383 } else { 2384 g2.drawImage(new ImageIcon(getClass().getResource(imgStr)).getImage(), 7, -15, null); 2385 } 2386 } 2387 } 2388 2389 for (int i = 1; i < sectors.size(); i++) { 2390 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 2391 g2.setStroke(new BasicStroke(6.0f)); 2392 if (!((String)getLightAtt(Att.BEG, i)).isEmpty() && !((String)getLightAtt(Att.END, i)).isEmpty()) { 2393 if (getLightAtt(Att.COL, i) != Col.UNKCOL) { 2394 g2.setPaint(ColMAP.get(getLightAtt(Att.COL, i))); 2395 Double a0 = 270 - Double.parseDouble((String)getLightAtt(Att.BEG, i)); 2396 Double da = 270 - Double.parseDouble((String)getLightAtt(Att.END, i)) - a0; 2397 da -= da > 0 ? 360 : 0; 2398 g2.draw(new Arc2D.Double(12, 15, 140, 140, a0, da, Arc2D.OPEN)); 2399 } 2400 if (getLightAtt(Att.ALT, i) != Col.UNKCOL) { 2401 g2.setPaint(ColMAP.get(getLightAtt(Att.ALT, i))); 2402 Double a0 = 270 - Double.parseDouble((String)getLightAtt(Att.BEG, i)); 2403 Double da = 270 - Double.parseDouble((String)getLightAtt(Att.END, i)) - a0; 2404 da -= da > 0 ? 360 : 0; 2405 g2.draw(new Arc2D.Double(17, 20, 130, 130, a0, da, Arc2D.OPEN)); 2406 } 2407 } else if ((getLightAtt(Att.LIT, i) == Lit.DIR) && !((String)getLightAtt(Att.ORT, i)).isEmpty()) { 2408 if (getLightAtt(Att.COL, i) != Col.UNKCOL) { 2409 g2.setPaint(ColMAP.get(getLightAtt(Att.COL, i))); 2410 Double a0 = 270 - Double.parseDouble((String)getLightAtt(Att.ORT, i)) + 2.0; 2411 Double da = -4.0; 2412 g2.draw(new Arc2D.Double(12, 15, 140, 140, a0, da, Arc2D.OPEN)); 2413 } 2414 if (getLightAtt(Att.ALT, i) != Col.UNKCOL) { 2415 g2.setPaint(ColMAP.get(getLightAtt(Att.ALT, i))); 2416 Double a0 = 270 - Double.parseDouble((String)getLightAtt(Att.ORT, i)) + 2.0; 2417 Double da = -4.0; 2418 g2.draw(new Arc2D.Double(17, 20, 130, 130, a0, da, Arc2D.OPEN)); 2419 } 2420 } 2421 } 2415 2422 g2.setPaint(Color.BLACK); 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2423 if ((getLightAtt(Att.COL, 0) != Col.UNKCOL) || !(((String)getLightAtt(Att.CHR, 0)).isEmpty())) { 2424 if (sectors.size() == 1) { 2425 if (((String) getLightAtt(Att.CHR, 0)).contains("Al")) { 2426 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Magenta_120.png")).getImage(), 7, -15, null); 2427 } else { 2428 switch ((Col) getLightAtt(Att.COL, 0)) { 2429 case RED: 2430 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Red_120.png")).getImage(), 7, -15, null); 2431 break; 2432 case GREEN: 2433 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Green_120.png")).getImage(), 7, -15, null); 2434 break; 2435 case WHITE: 2436 case YELLOW: 2437 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_White_120.png")).getImage(), 7, -15, null); 2438 break; 2439 default: 2440 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Magenta_120.png")).getImage(), 7, -15, null); 2441 } 2442 } 2443 } 2444 String c = (String) getLightAtt(Att.CHR, 0); 2445 String tmp = ""; 2446 if (c.contains("+")) { 2447 int i1 = c.indexOf("+"); 2448 tmp = c.substring(i1, c.length()); 2449 c = c.substring(0, i1); 2450 if (!((String) getLightAtt(Att.GRP, 0)).isEmpty()) { 2451 c += "(" + (String) getLightAtt(Att.GRP, 0) + ")"; 2452 } 2453 if (tmp != null) 2454 c += tmp; 2455 } else if (!((String) getLightAtt(Att.GRP, 0)).isEmpty()) 2456 c += "(" + (String) getLightAtt(Att.GRP, 0) + ")"; 2457 switch ((Col) getLightAtt(Att.COL, 0)) { 2458 case WHITE: 2459 c += ".W"; 2460 break; 2461 case YELLOW: 2462 c += ".Y"; 2463 break; 2464 case RED: 2465 c += ".R"; 2466 break; 2467 case GREEN: 2468 c += ".G"; 2469 break; 2470 case AMBER: 2471 c += ".Am"; 2472 break; 2473 case ORANGE: 2474 c += ".Or"; 2475 break; 2476 case BLUE: 2477 c += ".Bu"; 2478 break; 2479 case VIOLET: 2480 c += ".Vi"; 2481 break; 2482 } 2483 switch ((Col) getLightAtt(Att.ALT, 0)) { 2484 case WHITE: 2485 c += "W"; 2486 break; 2487 case YELLOW: 2488 c += "Y"; 2489 break; 2490 case RED: 2491 c += "R"; 2492 break; 2493 case GREEN: 2494 c += "G"; 2495 break; 2496 case AMBER: 2497 c += "Am"; 2498 break; 2499 case ORANGE: 2500 c += "Or"; 2501 break; 2502 case BLUE: 2503 c += "Bu"; 2504 break; 2505 case VIOLET: 2506 c += "Vi"; 2507 break; 2508 } 2509 tmp = (String) getLightAtt(Att.MLT, 0); 2510 if (!tmp.isEmpty()) 2511 c = tmp + c; 2512 if (getLightAtt(Att.LIT, 0) != Lit.UNKLIT) { 2513 switch ((Lit)getLightAtt(Att.LIT, 0)) { 2514 case VERT: 2515 c += "(Vert)"; 2516 break; 2517 case HORIZ: 2518 c += "(Horiz)"; 2519 break; 2520 } 2521 } 2522 tmp = (String) getLightAtt(Att.PER, 0); 2523 if (!tmp.isEmpty()) 2524 c += " " + tmp + "s"; 2525 g2.drawString(c, 100, 70); 2526 } 2527 2528 if (getFogSound() != Fog.NOFOG) { 2529 g2.drawImage(new ImageIcon(getClass().getResource("/images/Fog_Signal.png")).getImage(), 7, -15, null); 2530 String str = ""; 2531 if (getFogSound() != Fog.FOGSIG) 2532 switch (getFogSound()) { 2533 case HORN: 2534 str = "Horn"; 2535 break; 2536 case SIREN: 2537 str = "Siren"; 2538 break; 2539 case DIA: 2540 str = "Dia"; 2541 break; 2542 case BELL: 2543 str = "Bell"; 2544 break; 2545 case WHIS: 2546 str = "Whis"; 2547 break; 2548 case GONG: 2549 str = "Gong"; 2550 break; 2551 case EXPLOS: 2552 str = "Explos"; 2553 break; 2554 } 2555 if (!getFogGroup().isEmpty()) 2556 str += ("(" + getFogGroup() + ")"); 2557 else 2558 str += " "; 2559 if (!getFogPeriod().isEmpty()) 2560 str += getFogPeriod() + "s"; 2561 g2.drawString(str, 0, 70); 2562 } 2563 2564 if (RaType != Rtb.NORTB) { 2565 if (getRadar() == Rtb.REFLECTOR) { 2566 g2.drawImage(new ImageIcon(getClass().getResource("/images/Radar_Reflector_355.png")).getImage(), 7, -15, null); 2567 } else { 2568 g2.drawImage(new ImageIcon(getClass().getResource("/images/Radar_Station.png")).getImage(), 7, -15, null); 2569 String str = ""; 2570 if (getRadar() == Rtb.RAMARK) 2571 str += "Ramark"; 2572 else 2573 str += "Racon"; 2574 if (!getRaconGroup().isEmpty()) 2575 str += ("(" + getRaconGroup() + ")"); 2576 else 2577 str += " "; 2578 if (!getRaconPeriod().isEmpty()) 2579 str += getRaconPeriod() + "s"; 2580 g2.drawString(str, 0, 50); 2581 } 2582 } 2583 2584 if (RoType != Cat.NOROS) { 2585 g2.drawImage(new ImageIcon(getClass().getResource("/images/Radar_Station.png")).getImage(), 7, -15, null); 2586 g2.drawString("AIS", 0, 30); 2587 } 2588 } 2589 2590 public void saveSign(OsmPrimitive node) { 2591 2592 if (getObject() != Obj.UNKOBJ) { 2593 2594 Main.pref.put("smedplugin.IALA", getRegion() == Reg.C ? "C" : (getRegion() == Reg.B ? "B" : "A")); 2595 2596 for (String str : node.getKeys().keySet()) { 2597 if (str.trim().matches("^seamark:\\S+")) 2598 Main.main.undoRedo.add(new ChangePropertyCommand(node, str, null)); 2599 } 2600 2601 if (!getName().isEmpty()) 2602 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:name", getName())); 2603 2604 String objStr = ObjSTR.get(object); 2605 if (objStr != null) { 2606 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:type", objStr)); 2607 2608 if (getShape() != Shp.FLOAT) { 2609 String str = CatSTR.get(getCategory()); 2610 if (str != null) 2611 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":category", str)); 2612 if ((getShape() != Shp.BUOY) && (getShape() != Shp.BEACON)) 2613 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":shape", ShpSTR.get(getShape()))); 2614 } 2615 2616 if ((getObjColour(0) != Col.UNKCOL) && getShape() != Shp.PERCH) { 2617 String str = ColSTR.get(getObjColour(0)); 2618 for (int i = 1; bodyColour.size() > i; i++) { 2619 str += (";" + ColSTR.get(getObjColour(i))); 2620 } 2621 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":colour", str)); 2622 } 2623 2624 if (getObjPattern() != Pat.NOPAT) { 2625 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":colour_pattern", PatSTR.get(getObjPattern()))); 2626 } 2627 2628 if (getFunc() != Fnc.UNKFNC) { 2629 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":function", FncSTR.get(getFunc()))); 2630 } 2631 2632 if ((GrpMAP.get(object) == Grp.LAT) && (getShape() != Shp.PERCH) 2633 || (getObject() == Obj.FLTLAT)) { 2634 switch (region) { 2635 case A: 2636 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":system", "iala-a")); 2637 break; 2638 case B: 2639 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":system", "iala-b")); 2640 break; 2641 case C: 2642 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":system", "other")); 2643 break; 2644 } 2645 } 2646 if (!getObjectHeight().isEmpty()) { 2647 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":height", getObjectHeight())); 2648 } 2649 if (!getElevation().isEmpty()) { 2650 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":elevation", getElevation())); 2651 } 2652 if (!getChannel().isEmpty()) { 2653 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":channel", getChannel())); 2654 } 2655 } 2656 if (getTopmark() != Top.NOTOP) { 2657 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:topmark:shape", TopSTR.get(getTopmark()))); 2658 if (getTopPattern() != Pat.NOPAT) 2659 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:topmark:colour_pattern", PatSTR.get(getTopPattern()))); 2660 if (getTopColour(0) != Col.UNKCOL) { 2661 String str = ColSTR.get(getTopColour(0)); 2662 for (int i = 1; topmarkColour.size() > i; i++) { 2663 str += (";" + ColSTR.get(getTopColour(i))); 2664 } 2665 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:topmark:colour", str)); 2666 } 2667 } 2668 2669 for (int i = (sectors.size() > 1 ? 1 : 0); i < sectors.size(); i++) { 2670 String secStr = (i == 0) ? "" : (":" + Integer.toString(i)); 2671 if (sectors.get(i)[0] != Col.UNKCOL) 2672 if ((sectors.get(i)[15] != Col.UNKCOL) && ((String)sectors.get(i)[1]).contains("Al")) 2673 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":colour", (ColSTR.get(sectors.get(i)[0])) + ";" + ColSTR.get(sectors.get(i)[15]))); 2674 else 2675 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":colour", ColSTR.get(sectors.get(i)[0]))); 2676 if (!((String) sectors.get(i)[1]).isEmpty()) 2677 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":character", (String) sectors.get(i)[1])); 2678 else if (!((String) sectors.get(0)[1]).isEmpty()) 2679 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":character", (String) sectors.get(0)[1])); 2680 if (!((String) sectors.get(i)[2]).isEmpty()) 2681 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":group", (String) sectors.get(i)[2])); 2682 else if (!((String) sectors.get(0)[2]).isEmpty()) 2683 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":group", (String) sectors.get(0)[2])); 2684 if (!((String) sectors.get(i)[3]).isEmpty()) 2685 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sequence", (String) sectors.get(i)[3])); 2686 else if (!((String) sectors.get(0)[3]).isEmpty()) 2687 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sequence", (String) sectors.get(0)[3])); 2688 if (!((String) sectors.get(i)[4]).isEmpty()) 2689 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":period", (String) sectors.get(i)[4])); 2690 else if (!((String) sectors.get(0)[4]).isEmpty()) 2691 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":period", (String) sectors.get(0)[4])); 2692 if (sectors.get(i)[5] != Lit.UNKLIT) 2693 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":category", LitSTR.get(sectors.get(i)[5]))); 2694 else if (sectors.get(0)[5] != Lit.UNKLIT) 2695 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":category", LitSTR.get(sectors.get(0)[5]))); 2696 if (!((String) sectors.get(i)[6]).isEmpty()) 2697 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sector_start", (String) sectors.get(i)[6])); 2698 if (!((String) sectors.get(i)[7]).isEmpty()) 2699 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sector_end", (String) sectors.get(i)[7])); 2700 if (!((String) sectors.get(i)[8]).isEmpty()) 2701 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":radius", (String) sectors.get(i)[8])); 2702 else if (!((String) sectors.get(0)[8]).isEmpty()) 2703 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":radius", (String) sectors.get(0)[8])); 2704 if (!((String) sectors.get(i)[9]).isEmpty()) 2705 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":height", (String) sectors.get(i)[9])); 2706 else if (!((String) sectors.get(0)[9]).isEmpty()) 2707 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":height", (String) sectors.get(0)[9])); 2708 if (!((String) sectors.get(i)[10]).isEmpty()) 2709 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":range", (String) sectors.get(i)[10])); 2710 else if (!((String) sectors.get(0)[10]).isEmpty()) 2711 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":range", (String) sectors.get(0)[10])); 2712 if (sectors.get(i)[11] != Vis.UNKVIS) 2713 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":visibility", VisSTR.get(sectors.get(i)[11]))); 2714 else if (sectors.get(0)[11] != Vis.UNKVIS) 2715 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":visibility", VisSTR.get(sectors.get(0)[11]))); 2716 if (sectors.get(i)[12] != Exh.UNKEXH) 2717 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":exhibition", ExhSTR.get(sectors.get(i)[12]))); 2718 else if (sectors.get(0)[12] != Exh.UNKEXH) 2719 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":exhibition", ExhSTR.get(sectors.get(0)[12]))); 2720 if (!((String) sectors.get(i)[13]).isEmpty()) 2721 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":orientation", (String) sectors.get(i)[13])); 2722 if (!((String) sectors.get(i)[14]).isEmpty()) 2723 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":multiple", (String) sectors.get(i)[14])); 2724 else if (!((String) sectors.get(0)[14]).isEmpty()) 2725 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":multiple", (String) sectors.get(0)[14])); 2726 } 2727 2728 if (getFogSound() != Fog.NOFOG) { 2729 if (getFogSound() == Fog.FOGSIG) 2730 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal", "yes")); 2731 else 2732 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:category", FogSTR.get(getFogSound()))); 2733 if (!getFogGroup().isEmpty()) { 2734 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:group", getFogGroup())); 2735 } 2736 if (!getFogPeriod().isEmpty()) { 2737 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:period", getFogPeriod())); 2738 } 2739 if (!getFogSequence().isEmpty()) { 2740 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:sequence", getFogSequence())); 2741 } 2742 if (!getFogRange().isEmpty()) { 2743 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal:range", getFogRange())); 2744 } 2745 } 2746 2747 if (RoType != Cat.NOROS) { 2748 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radio_station:category", CatSTR.get(getRadio()))); 2749 } 2750 2751 if (RaType != Rtb.NORTB) { 2752 if (getRadar() == Rtb.REFLECTOR) { 2753 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_reflector", "yes")); 2754 } else { 2755 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:category", RtbSTR.get(getRadar()))); 2756 if (!getRaconGroup().isEmpty()) { 2757 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:group", getRaconGroup())); 2758 } 2759 if (!getRaconPeriod().isEmpty()) { 2760 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:period", getRaconPeriod())); 2761 } 2762 if (!getRaconSequence().isEmpty()) { 2763 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:sequence", getRaconSequence())); 2764 } 2765 if (!getRaconRange().isEmpty()) { 2766 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:range", getRaconRange())); 2767 } 2768 if ((!getRaconSector1().isEmpty()) && (!getRaconSector2().isEmpty())) { 2769 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:sector_start", getRaconSector1())); 2770 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:radar_transponder:sector_end", getRaconSector2())); 2771 } 2772 } 2773 } 2774 2775 if (!getInfo().isEmpty()) { 2776 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:information", getInfo())); 2777 } 2778 if (!getSource().isEmpty()) { 2779 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:source", getSource())); 2780 } 2781 if (getStatus() != Sts.UNKSTS) { 2782 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:status", StsSTR.get(getStatus()))); 2783 } 2784 if (getConstr() != Cns.UNKCNS) { 2785 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:construction", CnsSTR.get(getConstr()))); 2786 } 2787 if (getConsp() != Con.UNKCON) { 2788 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:conspicuity", ConSTR.get(getConsp()))); 2789 } 2790 if (getRefl() != Con.UNKCON) { 2791 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:reflectivity", ConSTR.get(getRefl()))); 2792 } 2793 if (!getRef().isEmpty()) { 2794 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:reference", getRef())); 2795 } 2796 if (!getLightRef().isEmpty()) { 2797 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light:reference", getLightRef())); 2798 } 2799 if (!getFixme().isEmpty()) { 2800 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fixme", getFixme())); 2801 } 2802 } 2803 } 2797 2804 2798 2805 } -
applications/editors/josm/plugins/smed/src/smed/Smed.java
r29905 r32767 9 9 public class Smed extends Plugin { 10 10 11 12 13 14 15 16 17 18 19 20 21 22 11 SmedAction dialog = new SmedAction(); 12 13 public Smed(PluginInformation info) { 14 super(info); 15 MainMenu.add(Main.main.menu.toolsMenu, dialog); 16 } 17 18 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 19 if (newFrame == null) { 20 dialog.closeDialog(); 21 } 22 } 23 23 } -
applications/editors/josm/plugins/smed/src/smed/SmedAction.java
r29918 r32767 10 10 package smed; 11 11 12 import java.awt.*; 13 import java.awt.event.*; 14 import java.util.*; 12 import static org.openstreetmap.josm.tools.I18n.tr; 15 13 16 import javax.swing.*; 14 import java.awt.Dimension; 15 import java.awt.event.ActionEvent; 16 import java.util.Collection; 17 17 18 import static org.openstreetmap.josm.tools.I18n.tr; 18 import javax.swing.JFrame; 19 import javax.swing.SwingUtilities; 20 import javax.swing.WindowConstants; 21 19 22 import org.openstreetmap.josm.actions.JosmAction; 20 23 import org.openstreetmap.josm.data.SelectionChangedListener; 21 import org.openstreetmap.josm.data.osm.*; 24 import org.openstreetmap.josm.data.osm.DataSet; 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 26 23 27 import messages.Messages; 24 25 28 import panels.PanelMain; 26 29 27 30 public class SmedAction extends JosmAction implements SelectionChangedListener { 28 31 29 30 31 32 33 32 private static final long serialVersionUID = 1L; 33 private static String editor = tr("SeaMap Editor"); 34 public static JFrame editFrame = null; 35 private boolean isOpen = false; 36 public static PanelMain panelMain = null; 34 37 35 36 38 public OsmPrimitive node = null; 39 private Collection<? extends OsmPrimitive> selection = null; 37 40 38 39 40 41 public SmedAction() { 42 super(editor, "Smed", editor, null, true); 43 } 41 44 42 43 44 45 46 47 48 49 50 51 52 53 45 @Override 46 public void actionPerformed(ActionEvent arg0) { 47 SwingUtilities.invokeLater(new Runnable() { 48 public void run() { 49 if (!isOpen) 50 createFrame(); 51 else 52 editFrame.toFront(); 53 isOpen = true; 54 } 55 }); 56 } 54 57 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 58 protected void createFrame() { 59 editFrame = new JFrame(editor); 60 editFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 61 editFrame.addWindowListener(new java.awt.event.WindowAdapter() { 62 public void windowClosing(java.awt.event.WindowEvent e) { 63 closeDialog(); 64 } 65 }); 66 editFrame.setSize(new Dimension(420, 430)); 67 editFrame.setLocation(100, 200); 68 editFrame.setResizable(true); 69 editFrame.setAlwaysOnTop(true); 70 editFrame.setVisible(true); 71 editFrame.setLayout(null); 72 panelMain = new PanelMain(this); 73 panelMain.setBounds(10, 10, 400, 400); 74 node = null; 75 panelMain.syncPanel(); 76 editFrame.add(panelMain); 77 DataSet.addSelectionListener(this); 75 78 76 77 79 // System.out.println("hello"); 80 } 78 81 79 80 81 82 83 84 85 82 public void closeDialog() { 83 if (isOpen) { 84 editFrame.setVisible(false); 85 editFrame.dispose(); 86 } 87 isOpen = false; 88 } 86 89 87 88 89 90 90 @Override 91 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 92 OsmPrimitive nextNode = null; 93 selection = newSelection; 91 94 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 95 for (OsmPrimitive osm : selection) { 96 nextNode = (OsmPrimitive) osm; 97 if (selection.size() == 1) { 98 if (nextNode.compareTo(node) != 0) { 99 node = nextNode; 100 panelMain.mark.parseMark(node); 101 } 102 } else { 103 node = null; 104 panelMain.mark.clrMark(); 105 PanelMain.messageBar.setText(Messages.getString("OneNode")); 106 } 107 } 108 if (nextNode == null) { 109 node = null; 110 panelMain.mark.clrMark(); 111 PanelMain.messageBar.setText(Messages.getString("SelectNode")); 112 } 113 } 111 114 112 115 }
Note:
See TracChangeset
for help on using the changeset viewer.