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