Changeset 32767 in osm for applications/editors/josm/plugins/smed/src/panels/PanelChan.java
- Timestamp:
- 2016-08-04T02:27:43+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.