Ignore:
Timestamp:
2016-08-04T02:27:43+02:00 (9 years ago)
Author:
donvip
Message:

code style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed/src/panels/PanelLights.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.event.*;
    4 import java.awt.*;
    5 
    6 import javax.swing.*;
    7 
    8 import java.util.*;
     3import java.awt.Rectangle;
     4import java.awt.event.ActionEvent;
     5import java.awt.event.ActionListener;
     6import java.awt.event.FocusAdapter;
     7import java.awt.event.FocusEvent;
     8import java.awt.event.FocusListener;
     9import java.util.EnumMap;
     10
     11import javax.swing.BorderFactory;
     12import javax.swing.ButtonGroup;
     13import javax.swing.ImageIcon;
     14import javax.swing.JComboBox;
     15import javax.swing.JLabel;
     16import javax.swing.JPanel;
     17import javax.swing.JRadioButton;
     18import javax.swing.JTextField;
     19import javax.swing.SwingConstants;
    920
    1021import messages.Messages;
     22import seamarks.SeaMark.Cat;
     23import seamarks.SeaMark.Fnc;
     24import seamarks.SeaMark.Obj;
     25import seamarks.SeaMark.Shp;
    1126import smed.SmedAction;
    12 import seamarks.SeaMark.*;
    1327
    1428public class PanelLights extends JPanel {
    1529
    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    }
    608645
    609646}
Note: See TracChangeset for help on using the changeset viewer.