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

code style

Location:
applications/editors/josm/plugins/smed/src/panels
Files:
17 edited

Legend:

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

    r30738 r32767  
    11package panels;
    22
    3 import javax.swing.*;
    4 
    5 import java.awt.*;
    6 import java.awt.event.*;
     3import java.awt.Rectangle;
     4import java.awt.event.ActionEvent;
     5import java.awt.event.ActionListener;
     6
     7import javax.swing.BorderFactory;
     8import javax.swing.ButtonGroup;
     9import javax.swing.ImageIcon;
     10import javax.swing.JPanel;
     11import javax.swing.JRadioButton;
     12import javax.swing.JToggleButton;
    713
    814import messages.Messages;
     15import seamarks.SeaMark;
     16import seamarks.SeaMark.Att;
     17import seamarks.SeaMark.Cat;
     18import seamarks.SeaMark.Col;
     19import seamarks.SeaMark.Grp;
     20import seamarks.SeaMark.Pat;
     21import seamarks.SeaMark.Shp;
     22import seamarks.SeaMark.Top;
    923import smed.SmedAction;
    10 import seamarks.SeaMark;
    11 import seamarks.SeaMark.*;
    1224
    1325public class PanelChan extends JPanel {
    1426
    15         private SmedAction dlg;
    16         public PanelPort panelPort = null;
    17         public PanelStbd panelStbd = null;
    18         public PanelSaw panelSaw = null;
    19         public ButtonGroup catButtons = new ButtonGroup();
    20         public JRadioButton portButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PortButton.png")));
    21         public JRadioButton stbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StbdButton.png")));
    22         public JRadioButton prefStbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PrefStbdButton.png")));
    23         public JRadioButton prefPortButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PrefPortButton.png")));
    24         public JRadioButton safeWaterButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SafeWaterButton.png")));
    25         private ActionListener alCat = new ActionListener() {
    26                 public void actionPerformed(java.awt.event.ActionEvent e) {
    27                         panelPort.setVisible(false);
    28                         panelStbd.setVisible(false);
    29                         panelSaw.setVisible(false);
    30                         SmedAction.panelMain.moreButton.setVisible(false);
    31                         SmedAction.panelMain.saveButton.setEnabled(false);
    32                         topmarkButton.setVisible(false);
    33                         lightButton.setVisible(false);
    34                         Shp shp = SmedAction.panelMain.mark.getShape();
    35                         if (portButton.isSelected()) {
    36                                 SmedAction.panelMain.mark.setCategory(Cat.LAM_PORT);
    37                                 if (panelPort.shapes.containsKey(shp)) {
    38                                         panelPort.shapes.get(shp).setSelected(true);
    39                                 } else {
    40                                         panelPort.shapeButtons.clearSelection();
    41                                         SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
    42                                 }
    43                                 panelPort.alShape.actionPerformed(null);
    44                                 panelPort.setVisible(true);
    45                                 portButton.setBorderPainted(true);
    46                         } else {
    47                                 portButton.setBorderPainted(false);
    48                         }
    49                         if (stbdButton.isSelected()) {
    50                                 SmedAction.panelMain.mark.setCategory(Cat.LAM_STBD);
    51                                 if (panelStbd.shapes.containsKey(shp)) {
    52                                         panelStbd.shapes.get(shp).setSelected(true);
    53                                 } else {
    54                                         panelStbd.shapeButtons.clearSelection();
    55                                         SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
    56                                 }
    57                                 panelStbd.alShape.actionPerformed(null);
    58                                 panelStbd.setVisible(true);
    59                                 stbdButton.setBorderPainted(true);
    60                         } else {
    61                                 stbdButton.setBorderPainted(false);
    62                         }
    63                         if (prefStbdButton.isSelected()) {
    64                                 SmedAction.panelMain.mark.setCategory(Cat.LAM_PSTBD);
    65                                 if (panelPort.shapes.containsKey(shp)) {
    66                                         panelPort.shapes.get(shp).setSelected(true);
    67                                 } else {
    68                                         panelPort.shapeButtons.clearSelection();
    69                                         SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
    70                                 }
    71                                 panelPort.alShape.actionPerformed(null);
    72                                 panelPort.setVisible(true);
    73                                 prefStbdButton.setBorderPainted(true);
    74                         } else {
    75                                 prefStbdButton.setBorderPainted(false);
    76                         }
    77                         if (prefPortButton.isSelected()) {
    78                                 SmedAction.panelMain.mark.setCategory(Cat.LAM_PPORT);
    79                                 if (panelStbd.shapes.containsKey(shp)) {
    80                                         panelStbd.shapes.get(shp).setSelected(true);
    81                                 } else {
    82                                         panelStbd.shapeButtons.clearSelection();
    83                                         SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
    84                                 }
    85                                 panelStbd.alShape.actionPerformed(null);
    86                                 panelStbd.setVisible(true);
    87                                 prefPortButton.setBorderPainted(true);
    88                         } else {
    89                                 prefPortButton.setBorderPainted(false);
    90                         }
    91                         if (safeWaterButton.isSelected()) {
    92                                 SmedAction.panelMain.mark.setCategory(Cat.NOCAT);
    93                                 panelSaw.setVisible(true);
    94                                 if (panelSaw.shapes.containsKey(shp)) {
    95                                         panelSaw.shapes.get(shp).setSelected(true);
    96                                 } else {
    97                                         panelSaw.shapeButtons.clearSelection();
    98                                         SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
    99                                 }
    100                                 panelSaw.alShape.actionPerformed(null);
    101                                 panelSaw.setVisible(true);
    102                                 safeWaterButton.setBorderPainted(true);
    103                         } else {
    104                                 safeWaterButton.setBorderPainted(false);
    105                         }
    106                         topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
    107                         lightButton.setVisible(SmedAction.panelMain.mark.testValid());
    108                         SmedAction.panelMain.panelMore.syncPanel();
    109                 }
    110         };
    111         public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/ChanTopButton.png")));
    112         private ActionListener alTop = new ActionListener() {
    113                 public void actionPerformed(java.awt.event.ActionEvent e) {
    114                         if (topmarkButton.isSelected()) {
    115                                 if (SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.SAW) {
    116                                         SmedAction.panelMain.mark.setTopmark(Top.SPHERE);
    117                                         SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
    118                                         SmedAction.panelMain.mark.setTopColour(Col.RED);
    119                                 } else {
    120                                         switch (dlg.panelMain.mark.getCategory()) {
    121                                         case LAM_PORT:
    122                                         case LAM_PSTBD:
    123                                                 dlg.panelMain.mark.setTopmark(Top.CYL);
    124                                                 switch (dlg.panelMain.mark.getRegion()) {
    125                                                 case A:
    126                                                         dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
    127                                                         dlg.panelMain.mark.setTopColour(Col.RED);
    128                                                         break;
    129                                                 case B:
    130                                                         dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
    131                                                         dlg.panelMain.mark.setTopColour(Col.GREEN);
    132                                                         break;
    133                                                 case C:
    134                                                         if (dlg.panelMain.mark.getCategory() == Cat.LAM_PORT) {
    135                                                                 dlg.panelMain.mark.setTopPattern(Pat.HSTRP);
    136                                                                 dlg.panelMain.mark.setTopColour(Col.RED);
    137                                                                 dlg.panelMain.mark.addTopColour(Col.WHITE);
    138                                                         } else {
    139                                                                 dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
    140                                                                 dlg.panelMain.mark.setTopColour(Col.RED);
    141                                                         }
    142                                                         break;
    143                                                 }
    144                                                 break;
    145                                         case LAM_STBD:
    146                                         case LAM_PPORT:
    147                                                 dlg.panelMain.mark.setTopmark(Top.CONE);
    148                                                 switch (dlg.panelMain.mark.getRegion()) {
    149                                                 case A:
    150                                                         dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
    151                                                         dlg.panelMain.mark.setTopColour(Col.GREEN);
    152                                                         break;
    153                                                 case B:
    154                                                         dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
    155                                                         dlg.panelMain.mark.setTopColour(Col.RED);
    156                                                         break;
    157                                                 case C:
    158                                                         if (dlg.panelMain.mark.getCategory() == Cat.LAM_STBD) {
    159                                                                 dlg.panelMain.mark.setTopPattern(Pat.HSTRP);
    160                                                                 dlg.panelMain.mark.setTopColour(Col.GREEN);
    161                                                                 dlg.panelMain.mark.addTopColour(Col.WHITE);
    162                                                         } else {
    163                                                                 dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
    164                                                                 dlg.panelMain.mark.setTopColour(Col.GREEN);
    165                                                         }
    166                                                         break;
    167                                                 }
    168                                                 break;
    169                                         }
    170                                 }
    171                                 topmarkButton.setBorderPainted(true);
    172                         } else {
    173                                 dlg.panelMain.mark.setTopmark(Top.NOTOP);
    174                                 dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
    175                                 dlg.panelMain.mark.setTopColour(Col.UNKCOL);
    176                                 topmarkButton.setBorderPainted(false);
    177                         }
    178                         dlg.panelMain.panelTop.syncPanel();
    179                 }
    180         };
    181         public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png")));
    182         private ActionListener alLit = new ActionListener() {
    183                 public void actionPerformed(java.awt.event.ActionEvent e) {
    184                         if (lightButton.isSelected()) {
    185                                 if (SeaMark.GrpMAP.get(dlg.panelMain.mark.getObject()) == Grp.SAW) {
    186                                         dlg.panelMain.mark.setLightAtt(Att.CHR, 0, "LFl");
    187                                         dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE);
    188                                 } else {
    189                                         dlg.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl");
    190                                         switch (dlg.panelMain.mark.getCategory()) {
    191                                         case LAM_PORT:
    192                                         case LAM_PPORT:
    193                                                 switch (dlg.panelMain.mark.getRegion()) {
    194                                                 case A:
    195                                                 case C:
    196                                                         dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.RED);
    197                                                         break;
    198                                                 case B:
    199                                                         dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.GREEN);
    200                                                         break;
    201                                                 }
    202                                                 break;
    203                                         case LAM_STBD:
    204                                         case LAM_PSTBD:
    205                                                 switch (dlg.panelMain.mark.getRegion()) {
    206                                                 case A:
    207                                                 case C:
    208                                                         dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.GREEN);
    209                                                         break;
    210                                                 case B:
    211                                                         dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.RED);
    212                                                         break;
    213                                                 }
    214                                                 break;
    215                                         }
    216                                 }
    217                                 lightButton.setBorderPainted(true);
    218                         } else {
    219                                 dlg.panelMain.mark.clrLight();
    220                                 lightButton.setBorderPainted(false);
    221                         }
    222                         dlg.panelMain.panelLit.syncPanel();
    223                 }
    224         };
    225 
    226         public PanelChan(SmedAction dia) {
    227                 dlg = dia;
    228                 setLayout(null);
    229                 panelPort = new PanelPort(dlg);
    230                 panelPort.setBounds(new Rectangle(55, 0, 70, 160));
    231                 panelPort.setVisible(false);
    232                 panelStbd = new PanelStbd(dlg);
    233                 panelStbd.setBounds(new Rectangle(55, 0, 70, 160));
    234                 panelStbd.setVisible(false);
    235                 panelSaw = new PanelSaw(dlg);
    236                 panelSaw.setBounds(new Rectangle(55, 0, 70, 160));
    237                 panelSaw.setVisible(false);
    238                 add(panelPort);
    239                 add(panelStbd);
    240                 add(panelSaw);
    241                 add(getCatButton(portButton, 0, 0, 52, 32, "Port"));
    242                 add(getCatButton(stbdButton, 0, 32, 52, 32, "Stbd"));
    243                 add(getCatButton(prefStbdButton, 0, 64, 52, 32, "PrefStbd"));
    244                 add(getCatButton(prefPortButton, 0, 96, 52, 32, "PrefPort"));
    245                 add(getCatButton(safeWaterButton, 0, 128, 52, 32, "SafeWater"));
    246 
    247                 topmarkButton.setBounds(new Rectangle(130, 0, 34, 32));
    248                 topmarkButton.setToolTipText(Messages.getString("Topmark"));
    249                 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder());
    250                 topmarkButton.addActionListener(alTop);
    251                 topmarkButton.setVisible(false);
    252                 add(topmarkButton);
    253                 lightButton.setBounds(new Rectangle(130, 32, 34, 32));
    254                 lightButton.setToolTipText(Messages.getString("Light"));
    255                 lightButton.setBorder(BorderFactory.createLoweredBevelBorder());
    256                 lightButton.addActionListener(alLit);
    257                 lightButton.setVisible(false);
    258                 add(lightButton);
    259         }
    260 
    261         public void syncPanel() {
    262                 panelPort.setVisible(false);
    263                 panelStbd.setVisible(false);
    264                 panelSaw.setVisible(false);
    265                 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PORT) {
    266                         panelPort.setVisible(true);
    267                         portButton.setBorderPainted(true);
    268                 } else {
    269                         portButton.setBorderPainted(false);
    270                 }
    271                 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PPORT) {
    272                         panelStbd.setVisible(true);
    273                         prefPortButton.setBorderPainted(true);
    274                 } else {
    275                         prefPortButton.setBorderPainted(false);
    276                 }
    277                 if (dlg.panelMain.mark.getCategory() == Cat.LAM_STBD) {
    278                         panelStbd.setVisible(true);
    279                         stbdButton.setBorderPainted(true);
    280                 } else {
    281                         stbdButton.setBorderPainted(false);
    282                 }
    283                 if (dlg.panelMain.mark.getCategory() == Cat.LAM_PSTBD) {
    284                         panelPort.setVisible(true);
    285                         prefStbdButton.setBorderPainted(true);
    286                 } else {
    287                         prefStbdButton.setBorderPainted(false);
    288                 }
    289                 if (SeaMark.GrpMAP.get(dlg.panelMain.mark.getObject()) == Grp.SAW) {
    290                         panelSaw.setVisible(true);
    291                         safeWaterButton.setBorderPainted(true);
    292                 } else {
    293                         safeWaterButton.setBorderPainted(false);
    294                 }
    295                 topmarkButton.setBorderPainted(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
    296                 topmarkButton.setSelected(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
    297                 topmarkButton.setVisible(dlg.panelMain.mark.testValid());
    298                 Boolean lit = (dlg.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)dlg.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty();
    299                 lightButton.setBorderPainted(lit);
    300                 lightButton.setSelected(lit);
    301                 lightButton.setVisible(dlg.panelMain.mark.testValid());
    302                 panelPort.syncPanel();
    303                 panelStbd.syncPanel();
    304                 panelSaw.syncPanel();
    305                 dlg.panelMain.mark.testValid();
    306         }
    307 
    308         private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) {
    309                 button.setBounds(new Rectangle(x, y, w, h));
    310                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    311                 button.setToolTipText(Messages.getString(tip));
    312                 button.addActionListener(alCat);
    313                 catButtons.add(button);
    314                 return button;
    315         }
     27    private SmedAction dlg;
     28    public PanelPort panelPort = null;
     29    public PanelStbd panelStbd = null;
     30    public PanelSaw panelSaw = null;
     31    public ButtonGroup catButtons = new ButtonGroup();
     32    public JRadioButton portButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PortButton.png")));
     33    public JRadioButton stbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StbdButton.png")));
     34    public JRadioButton prefStbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PrefStbdButton.png")));
     35    public JRadioButton prefPortButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PrefPortButton.png")));
     36    public JRadioButton safeWaterButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SafeWaterButton.png")));
     37    private ActionListener alCat = new ActionListener() {
     38        @Override
     39        public void actionPerformed(ActionEvent e) {
     40            panelPort.setVisible(false);
     41            panelStbd.setVisible(false);
     42            panelSaw.setVisible(false);
     43            SmedAction.panelMain.moreButton.setVisible(false);
     44            SmedAction.panelMain.saveButton.setEnabled(false);
     45            topmarkButton.setVisible(false);
     46            lightButton.setVisible(false);
     47            Shp shp = SmedAction.panelMain.mark.getShape();
     48            if (portButton.isSelected()) {
     49                SmedAction.panelMain.mark.setCategory(Cat.LAM_PORT);
     50                if (panelPort.shapes.containsKey(shp)) {
     51                    panelPort.shapes.get(shp).setSelected(true);
     52                } else {
     53                    panelPort.shapeButtons.clearSelection();
     54                    SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
     55                }
     56                panelPort.alShape.actionPerformed(null);
     57                panelPort.setVisible(true);
     58                portButton.setBorderPainted(true);
     59            } else {
     60                portButton.setBorderPainted(false);
     61            }
     62            if (stbdButton.isSelected()) {
     63                SmedAction.panelMain.mark.setCategory(Cat.LAM_STBD);
     64                if (panelStbd.shapes.containsKey(shp)) {
     65                    panelStbd.shapes.get(shp).setSelected(true);
     66                } else {
     67                    panelStbd.shapeButtons.clearSelection();
     68                    SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
     69                }
     70                panelStbd.alShape.actionPerformed(null);
     71                panelStbd.setVisible(true);
     72                stbdButton.setBorderPainted(true);
     73            } else {
     74                stbdButton.setBorderPainted(false);
     75            }
     76            if (prefStbdButton.isSelected()) {
     77                SmedAction.panelMain.mark.setCategory(Cat.LAM_PSTBD);
     78                if (panelPort.shapes.containsKey(shp)) {
     79                    panelPort.shapes.get(shp).setSelected(true);
     80                } else {
     81                    panelPort.shapeButtons.clearSelection();
     82                    SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
     83                }
     84                panelPort.alShape.actionPerformed(null);
     85                panelPort.setVisible(true);
     86                prefStbdButton.setBorderPainted(true);
     87            } else {
     88                prefStbdButton.setBorderPainted(false);
     89            }
     90            if (prefPortButton.isSelected()) {
     91                SmedAction.panelMain.mark.setCategory(Cat.LAM_PPORT);
     92                if (panelStbd.shapes.containsKey(shp)) {
     93                    panelStbd.shapes.get(shp).setSelected(true);
     94                } else {
     95                    panelStbd.shapeButtons.clearSelection();
     96                    SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
     97                }
     98                panelStbd.alShape.actionPerformed(null);
     99                panelStbd.setVisible(true);
     100                prefPortButton.setBorderPainted(true);
     101            } else {
     102                prefPortButton.setBorderPainted(false);
     103            }
     104            if (safeWaterButton.isSelected()) {
     105                SmedAction.panelMain.mark.setCategory(Cat.NOCAT);
     106                panelSaw.setVisible(true);
     107                if (panelSaw.shapes.containsKey(shp)) {
     108                    panelSaw.shapes.get(shp).setSelected(true);
     109                } else {
     110                    panelSaw.shapeButtons.clearSelection();
     111                    SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
     112                }
     113                panelSaw.alShape.actionPerformed(null);
     114                panelSaw.setVisible(true);
     115                safeWaterButton.setBorderPainted(true);
     116            } else {
     117                safeWaterButton.setBorderPainted(false);
     118            }
     119            topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
     120            lightButton.setVisible(SmedAction.panelMain.mark.testValid());
     121            SmedAction.panelMain.panelMore.syncPanel();
     122        }
     123    };
     124    public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/ChanTopButton.png")));
     125    private ActionListener alTop = new ActionListener() {
     126        @Override
     127        public void actionPerformed(ActionEvent e) {
     128            if (topmarkButton.isSelected()) {
     129                if (SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.SAW) {
     130                    SmedAction.panelMain.mark.setTopmark(Top.SPHERE);
     131                    SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
     132                    SmedAction.panelMain.mark.setTopColour(Col.RED);
     133                } else {
     134                    switch (dlg.panelMain.mark.getCategory()) {
     135                    case LAM_PORT:
     136                    case LAM_PSTBD:
     137                        dlg.panelMain.mark.setTopmark(Top.CYL);
     138                        switch (dlg.panelMain.mark.getRegion()) {
     139                        case A:
     140                            dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
     141                            dlg.panelMain.mark.setTopColour(Col.RED);
     142                            break;
     143                        case B:
     144                            dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
     145                            dlg.panelMain.mark.setTopColour(Col.GREEN);
     146                            break;
     147                        case C:
     148                            if (dlg.panelMain.mark.getCategory() == Cat.LAM_PORT) {
     149                                dlg.panelMain.mark.setTopPattern(Pat.HSTRP);
     150                                dlg.panelMain.mark.setTopColour(Col.RED);
     151                                dlg.panelMain.mark.addTopColour(Col.WHITE);
     152                            } else {
     153                                dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
     154                                dlg.panelMain.mark.setTopColour(Col.RED);
     155                            }
     156                            break;
     157                        }
     158                        break;
     159                    case LAM_STBD:
     160                    case LAM_PPORT:
     161                        dlg.panelMain.mark.setTopmark(Top.CONE);
     162                        switch (dlg.panelMain.mark.getRegion()) {
     163                        case A:
     164                            dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
     165                            dlg.panelMain.mark.setTopColour(Col.GREEN);
     166                            break;
     167                        case B:
     168                            dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
     169                            dlg.panelMain.mark.setTopColour(Col.RED);
     170                            break;
     171                        case C:
     172                            if (dlg.panelMain.mark.getCategory() == Cat.LAM_STBD) {
     173                                dlg.panelMain.mark.setTopPattern(Pat.HSTRP);
     174                                dlg.panelMain.mark.setTopColour(Col.GREEN);
     175                                dlg.panelMain.mark.addTopColour(Col.WHITE);
     176                            } else {
     177                                dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
     178                                dlg.panelMain.mark.setTopColour(Col.GREEN);
     179                            }
     180                            break;
     181                        }
     182                        break;
     183                    }
     184                }
     185                topmarkButton.setBorderPainted(true);
     186            } else {
     187                dlg.panelMain.mark.setTopmark(Top.NOTOP);
     188                dlg.panelMain.mark.setTopPattern(Pat.NOPAT);
     189                dlg.panelMain.mark.setTopColour(Col.UNKCOL);
     190                topmarkButton.setBorderPainted(false);
     191            }
     192            dlg.panelMain.panelTop.syncPanel();
     193        }
     194    };
     195    public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png")));
     196    private ActionListener alLit = new ActionListener() {
     197        @Override
     198        public void actionPerformed(ActionEvent e) {
     199            if (lightButton.isSelected()) {
     200                if (SeaMark.GrpMAP.get(dlg.panelMain.mark.getObject()) == Grp.SAW) {
     201                    dlg.panelMain.mark.setLightAtt(Att.CHR, 0, "LFl");
     202                    dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE);
     203                } else {
     204                    dlg.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl");
     205                    switch (dlg.panelMain.mark.getCategory()) {
     206                    case LAM_PORT:
     207                    case LAM_PPORT:
     208                        switch (dlg.panelMain.mark.getRegion()) {
     209                        case A:
     210                        case C:
     211                            dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.RED);
     212                            break;
     213                        case B:
     214                            dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.GREEN);
     215                            break;
     216                        }
     217                        break;
     218                    case LAM_STBD:
     219                    case LAM_PSTBD:
     220                        switch (dlg.panelMain.mark.getRegion()) {
     221                        case A:
     222                        case C:
     223                            dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.GREEN);
     224                            break;
     225                        case B:
     226                            dlg.panelMain.mark.setLightAtt(Att.COL, 0, Col.RED);
     227                            break;
     228                        }
     229                        break;
     230                    }
     231                }
     232                lightButton.setBorderPainted(true);
     233            } else {
     234                dlg.panelMain.mark.clrLight();
     235                lightButton.setBorderPainted(false);
     236            }
     237            dlg.panelMain.panelLit.syncPanel();
     238        }
     239    };
     240
     241    public PanelChan(SmedAction dia) {
     242        dlg = dia;
     243        setLayout(null);
     244        panelPort = new PanelPort(dlg);
     245        panelPort.setBounds(new Rectangle(55, 0, 70, 160));
     246        panelPort.setVisible(false);
     247        panelStbd = new PanelStbd(dlg);
     248        panelStbd.setBounds(new Rectangle(55, 0, 70, 160));
     249        panelStbd.setVisible(false);
     250        panelSaw = new PanelSaw(dlg);
     251        panelSaw.setBounds(new Rectangle(55, 0, 70, 160));
     252        panelSaw.setVisible(false);
     253        add(panelPort);
     254        add(panelStbd);
     255        add(panelSaw);
     256        add(getCatButton(portButton, 0, 0, 52, 32, "Port"));
     257        add(getCatButton(stbdButton, 0, 32, 52, 32, "Stbd"));
     258        add(getCatButton(prefStbdButton, 0, 64, 52, 32, "PrefStbd"));
     259        add(getCatButton(prefPortButton, 0, 96, 52, 32, "PrefPort"));
     260        add(getCatButton(safeWaterButton, 0, 128, 52, 32, "SafeWater"));
     261
     262        topmarkButton.setBounds(new Rectangle(130, 0, 34, 32));
     263        topmarkButton.setToolTipText(Messages.getString("Topmark"));
     264        topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder());
     265        topmarkButton.addActionListener(alTop);
     266        topmarkButton.setVisible(false);
     267        add(topmarkButton);
     268        lightButton.setBounds(new Rectangle(130, 32, 34, 32));
     269        lightButton.setToolTipText(Messages.getString("Light"));
     270        lightButton.setBorder(BorderFactory.createLoweredBevelBorder());
     271        lightButton.addActionListener(alLit);
     272        lightButton.setVisible(false);
     273        add(lightButton);
     274    }
     275
     276    public void syncPanel() {
     277        panelPort.setVisible(false);
     278        panelStbd.setVisible(false);
     279        panelSaw.setVisible(false);
     280        if (dlg.panelMain.mark.getCategory() == Cat.LAM_PORT) {
     281            panelPort.setVisible(true);
     282            portButton.setBorderPainted(true);
     283        } else {
     284            portButton.setBorderPainted(false);
     285        }
     286        if (dlg.panelMain.mark.getCategory() == Cat.LAM_PPORT) {
     287            panelStbd.setVisible(true);
     288            prefPortButton.setBorderPainted(true);
     289        } else {
     290            prefPortButton.setBorderPainted(false);
     291        }
     292        if (dlg.panelMain.mark.getCategory() == Cat.LAM_STBD) {
     293            panelStbd.setVisible(true);
     294            stbdButton.setBorderPainted(true);
     295        } else {
     296            stbdButton.setBorderPainted(false);
     297        }
     298        if (dlg.panelMain.mark.getCategory() == Cat.LAM_PSTBD) {
     299            panelPort.setVisible(true);
     300            prefStbdButton.setBorderPainted(true);
     301        } else {
     302            prefStbdButton.setBorderPainted(false);
     303        }
     304        if (SeaMark.GrpMAP.get(dlg.panelMain.mark.getObject()) == Grp.SAW) {
     305            panelSaw.setVisible(true);
     306            safeWaterButton.setBorderPainted(true);
     307        } else {
     308            safeWaterButton.setBorderPainted(false);
     309        }
     310        topmarkButton.setBorderPainted(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
     311        topmarkButton.setSelected(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
     312        topmarkButton.setVisible(dlg.panelMain.mark.testValid());
     313        Boolean lit = (dlg.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)dlg.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty();
     314        lightButton.setBorderPainted(lit);
     315        lightButton.setSelected(lit);
     316        lightButton.setVisible(dlg.panelMain.mark.testValid());
     317        panelPort.syncPanel();
     318        panelStbd.syncPanel();
     319        panelSaw.syncPanel();
     320        dlg.panelMain.mark.testValid();
     321    }
     322
     323    private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) {
     324        button.setBounds(new Rectangle(x, y, w, h));
     325        button.setBorder(BorderFactory.createLoweredBevelBorder());
     326        button.setToolTipText(Messages.getString(tip));
     327        button.addActionListener(alCat);
     328        catButtons.add(button);
     329        return button;
     330    }
    316331
    317332}
  • applications/editors/josm/plugins/smed/src/panels/PanelChr.java

    r30738 r32767  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
    5 import java.awt.*;
    6 import java.awt.event.*;
     5import java.awt.Rectangle;
     6import java.awt.event.ActionEvent;
     7import java.awt.event.ActionListener;
     8import java.awt.event.FocusEvent;
     9import java.awt.event.FocusListener;
     10import java.util.EnumMap;
     11import java.util.EnumSet;
    712
    8 import javax.swing.*;
    9 
    10 import java.util.*;
     13import javax.swing.BorderFactory;
     14import javax.swing.ImageIcon;
     15import javax.swing.JLabel;
     16import javax.swing.JPanel;
     17import javax.swing.JTextField;
     18import javax.swing.JToggleButton;
     19import javax.swing.SwingConstants;
    1120
    1221import messages.Messages;
     22import seamarks.SeaMark;
     23import seamarks.SeaMark.Att;
     24import seamarks.SeaMark.Chr;
     25import seamarks.SeaMark.Col;
    1326import smed.SmedAction;
    14 import seamarks.SeaMark;
    15 import seamarks.SeaMark.*;
    1627
    1728public class PanelChr extends JPanel {
    1829
    19         private SmedAction dlg;
    20         public JLabel col1Label = new JLabel();
    21         public JLabel col2Label = new JLabel();
    22         public JLabel charLabel = new JLabel();
    23         public JTextField charBox = new JTextField();
    24         public JToggleButton noneButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/NoCharButton.png")));
    25         public JToggleButton fixedButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/FixedButton.png")));
    26         public JToggleButton flashButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/FlashButton.png")));
    27         public JToggleButton longFlashButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/LongFlashButton.png")));
    28         public JToggleButton quickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/QuickButton.png")));
    29         public JToggleButton veryQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/VeryQuickButton.png")));
    30         public JToggleButton ultraQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/UltraQuickButton.png")));
    31         public JToggleButton interruptedQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedQuickButton.png")));
    32         public JToggleButton interruptedVeryQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedVeryQuickButton.png")));
    33         public JToggleButton interruptedUltraQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedUltraQuickButton.png")));
    34         public JToggleButton isophasedButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/IsophasedButton.png")));
    35         public JToggleButton occultingButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/OccultingButton.png")));
    36         public JToggleButton morseButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/MorseButton.png")));
    37         public JToggleButton alternatingButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/AlternatingButton.png")));
    38         private EnumMap<Chr, JToggleButton> buttons = new EnumMap<>(Chr.class);
    39         private ActionListener alCharButton = new ActionListener() {
    40                 public void actionPerformed(java.awt.event.ActionEvent e) {
    41                         JToggleButton source = (JToggleButton) e.getSource();
    42                         EnumSet<Chr> combo = EnumSet.noneOf(Chr.class);
    43                         for (Chr chr : buttons.keySet()) {
    44                                 JToggleButton button = buttons.get(chr);
    45                                 if (button.isSelected()) {
    46                                         combo.add(chr);
    47                                         button.setBorderPainted(true);
    48                                 } else {
    49                                         combo.remove(chr);
    50                                         button.setBorderPainted(false);
    51                                 }
    52                         }
    53                         if (SeaMark.ChrMAP.containsKey(combo)) {
    54                                 charBox.setText(SeaMark.ChrMAP.get(combo));
    55                         } else {
    56                                 for (Chr chr : buttons.keySet()) {
    57                                         JToggleButton button = buttons.get(chr);
    58                                         if (button == source) {
    59                                                 charBox.setText(SeaMark.ChrMAP.get(EnumSet.of(chr)));
    60                                                 button.setSelected(true);
    61                                                 button.setBorderPainted(true);
    62                                         } else {
    63                                                 button.setSelected(false);
    64                                                 button.setBorderPainted(false);
    65                                         }
    66                                 }
    67                         }
    68                         String str = charBox.getText();
    69                         SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, str);
    70                         if (!str.contains("Al")) {
    71                                 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0)));
    72                                 SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKCOL);
    73                         } else {
    74                                 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0)));
    75                         }
    76                 }
    77         };
    78         private FocusListener flCharBox = new FocusListener() {
    79                 public void focusGained(java.awt.event.FocusEvent e) {}
    80                         public void focusLost(java.awt.event.FocusEvent e) {
    81                         String str = charBox.getText();
    82                         SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, str);
    83                         EnumSet<Chr> set = EnumSet.noneOf(Chr.class);
    84                         for (EnumSet<Chr> map : SeaMark.ChrMAP.keySet()) {
    85                                 if (str.equals(SeaMark.ChrMAP.get(map))) {
    86                                         set = map;
    87                                         break;
    88                                 }
    89                         }
    90                         for (Chr chr : buttons.keySet()) {
    91                                 JToggleButton button = buttons.get(chr);
    92                                 if (set.contains(chr)) {
    93                                         button.setSelected(true);
    94                                         button.setBorderPainted(true);
    95                                 } else {
    96                                         button.setSelected(false);
    97                                         button.setBorderPainted(false);
    98                                 }
    99                         }
    100                         if (!str.contains("Al")) {
    101                                 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0)));
    102                                 SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKCOL);
    103                         } else {
    104                                 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0)));
    105                         }
    106                 }
    107         };
     30    private SmedAction dlg;
     31    public JLabel col1Label = new JLabel();
     32    public JLabel col2Label = new JLabel();
     33    public JLabel charLabel = new JLabel();
     34    public JTextField charBox = new JTextField();
     35    public JToggleButton noneButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/NoCharButton.png")));
     36    public JToggleButton fixedButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/FixedButton.png")));
     37    public JToggleButton flashButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/FlashButton.png")));
     38    public JToggleButton longFlashButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/LongFlashButton.png")));
     39    public JToggleButton quickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/QuickButton.png")));
     40    public JToggleButton veryQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/VeryQuickButton.png")));
     41    public JToggleButton ultraQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/UltraQuickButton.png")));
     42    public JToggleButton interruptedQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedQuickButton.png")));
     43    public JToggleButton interruptedVeryQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedVeryQuickButton.png")));
     44    public JToggleButton interruptedUltraQuickButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/InterruptedUltraQuickButton.png")));
     45    public JToggleButton isophasedButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/IsophasedButton.png")));
     46    public JToggleButton occultingButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/OccultingButton.png")));
     47    public JToggleButton morseButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/MorseButton.png")));
     48    public JToggleButton alternatingButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/AlternatingButton.png")));
     49    private EnumMap<Chr, JToggleButton> buttons = new EnumMap<>(Chr.class);
     50    private ActionListener alCharButton = new ActionListener() {
     51        @Override
     52        public void actionPerformed(ActionEvent e) {
     53            JToggleButton source = (JToggleButton) e.getSource();
     54            EnumSet<Chr> combo = EnumSet.noneOf(Chr.class);
     55            for (Chr chr : buttons.keySet()) {
     56                JToggleButton button = buttons.get(chr);
     57                if (button.isSelected()) {
     58                    combo.add(chr);
     59                    button.setBorderPainted(true);
     60                } else {
     61                    combo.remove(chr);
     62                    button.setBorderPainted(false);
     63                }
     64            }
     65            if (SeaMark.ChrMAP.containsKey(combo)) {
     66                charBox.setText(SeaMark.ChrMAP.get(combo));
     67            } else {
     68                for (Chr chr : buttons.keySet()) {
     69                    JToggleButton button = buttons.get(chr);
     70                    if (button == source) {
     71                        charBox.setText(SeaMark.ChrMAP.get(EnumSet.of(chr)));
     72                        button.setSelected(true);
     73                        button.setBorderPainted(true);
     74                    } else {
     75                        button.setSelected(false);
     76                        button.setBorderPainted(false);
     77                    }
     78                }
     79            }
     80            String str = charBox.getText();
     81            SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, str);
     82            if (!str.contains("Al")) {
     83                col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0)));
     84                SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKCOL);
     85            } else {
     86                col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0)));
     87            }
     88        }
     89    };
     90    private FocusListener flCharBox = new FocusListener() {
     91        @Override
     92        public void focusGained(FocusEvent e) {}
     93        @Override
     94        public void focusLost(FocusEvent e) {
     95            String str = charBox.getText();
     96            SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, str);
     97            EnumSet<Chr> set = EnumSet.noneOf(Chr.class);
     98            for (EnumSet<Chr> map : SeaMark.ChrMAP.keySet()) {
     99                if (str.equals(SeaMark.ChrMAP.get(map))) {
     100                    set = map;
     101                    break;
     102                }
     103            }
     104            for (Chr chr : buttons.keySet()) {
     105                JToggleButton button = buttons.get(chr);
     106                if (set.contains(chr)) {
     107                    button.setSelected(true);
     108                    button.setBorderPainted(true);
     109                } else {
     110                    button.setSelected(false);
     111                    button.setBorderPainted(false);
     112                }
     113            }
     114            if (!str.contains("Al")) {
     115                col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0)));
     116                SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKCOL);
     117            } else {
     118                col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0)));
     119            }
     120        }
     121    };
    108122
    109         public PanelChr(SmedAction dia) {
    110                 dlg = dia;
    111                 setLayout(null);
    112                 add(getChrButton(noneButton, 0, 0, 44, 16, Messages.getString("NoChar"), Chr.UNKCHR));
    113                 add(getChrButton(fixedButton, 0, 16, 44, 16, Messages.getString("FChar"), Chr.FIXED));
    114                 add(getChrButton(flashButton, 0, 32, 44, 16, Messages.getString("FlChar"), Chr.FLASH));
    115                 add(getChrButton(longFlashButton, 0, 48, 44, 16, Messages.getString("LFlChar"), Chr.LFLASH));
    116                 add(getChrButton(quickButton, 0, 64, 44, 16, Messages.getString("QChar"), Chr.QUICK));
    117                 add(getChrButton(veryQuickButton, 0, 80, 44, 16, Messages.getString("VQChar"), Chr.VQUICK));
    118                 add(getChrButton(ultraQuickButton, 0, 96, 44, 16, Messages.getString("UQChar"), Chr.UQUICK));
    119                 add(getChrButton(alternatingButton, 44, 0, 44, 16, Messages.getString("AlChar"), Chr.ALTERNATING));
    120                 add(getChrButton(isophasedButton, 44, 16, 44, 16, Messages.getString("IsoChar"), Chr.ISOPHASED));
    121                 add(getChrButton(occultingButton, 44, 32, 44, 16, Messages.getString("OcChar"), Chr.OCCULTING));
    122                 add(getChrButton(morseButton, 44, 48, 44, 16, Messages.getString("MoChar"), Chr.MORSE));
    123                 add(getChrButton(interruptedQuickButton, 44, 64, 44, 16, Messages.getString("IQChar"), Chr.IQUICK));
    124                 add(getChrButton(interruptedVeryQuickButton, 44, 80, 44, 16, Messages.getString("IVQChar"), Chr.IVQUICK));
    125                 add(getChrButton(interruptedUltraQuickButton, 44, 96, 44, 16, Messages.getString("IUQChar"), Chr.IUQUICK));
    126                 charLabel.setBounds(new Rectangle(0, 113, 88, 20));
    127                 charLabel.setHorizontalAlignment(SwingConstants.CENTER);
    128                 charLabel.setText(Messages.getString("Character"));
    129                 add(charLabel);
    130                 col1Label.setBounds(new Rectangle(10, 135, 10, 20));
    131                 col1Label.setOpaque(true);
    132                 add(col1Label);
    133                 col2Label.setBounds(new Rectangle(70, 135, 10, 20));
    134                 col2Label.setOpaque(true);
    135                 add(col2Label);
    136                 charBox.setBounds(new Rectangle(20, 135, 50, 20));
    137                 charBox.setHorizontalAlignment(SwingConstants.CENTER);
    138                 add(charBox);
    139                 charBox.addFocusListener(flCharBox);
    140         }
     123    public PanelChr(SmedAction dia) {
     124        dlg = dia;
     125        setLayout(null);
     126        add(getChrButton(noneButton, 0, 0, 44, 16, Messages.getString("NoChar"), Chr.UNKCHR));
     127        add(getChrButton(fixedButton, 0, 16, 44, 16, Messages.getString("FChar"), Chr.FIXED));
     128        add(getChrButton(flashButton, 0, 32, 44, 16, Messages.getString("FlChar"), Chr.FLASH));
     129        add(getChrButton(longFlashButton, 0, 48, 44, 16, Messages.getString("LFlChar"), Chr.LFLASH));
     130        add(getChrButton(quickButton, 0, 64, 44, 16, Messages.getString("QChar"), Chr.QUICK));
     131        add(getChrButton(veryQuickButton, 0, 80, 44, 16, Messages.getString("VQChar"), Chr.VQUICK));
     132        add(getChrButton(ultraQuickButton, 0, 96, 44, 16, Messages.getString("UQChar"), Chr.UQUICK));
     133        add(getChrButton(alternatingButton, 44, 0, 44, 16, Messages.getString("AlChar"), Chr.ALTERNATING));
     134        add(getChrButton(isophasedButton, 44, 16, 44, 16, Messages.getString("IsoChar"), Chr.ISOPHASED));
     135        add(getChrButton(occultingButton, 44, 32, 44, 16, Messages.getString("OcChar"), Chr.OCCULTING));
     136        add(getChrButton(morseButton, 44, 48, 44, 16, Messages.getString("MoChar"), Chr.MORSE));
     137        add(getChrButton(interruptedQuickButton, 44, 64, 44, 16, Messages.getString("IQChar"), Chr.IQUICK));
     138        add(getChrButton(interruptedVeryQuickButton, 44, 80, 44, 16, Messages.getString("IVQChar"), Chr.IVQUICK));
     139        add(getChrButton(interruptedUltraQuickButton, 44, 96, 44, 16, Messages.getString("IUQChar"), Chr.IUQUICK));
     140        charLabel.setBounds(new Rectangle(0, 113, 88, 20));
     141        charLabel.setHorizontalAlignment(SwingConstants.CENTER);
     142        charLabel.setText(Messages.getString("Character"));
     143        add(charLabel);
     144        col1Label.setBounds(new Rectangle(10, 135, 10, 20));
     145        col1Label.setOpaque(true);
     146        add(col1Label);
     147        col2Label.setBounds(new Rectangle(70, 135, 10, 20));
     148        col2Label.setOpaque(true);
     149        add(col2Label);
     150        charBox.setBounds(new Rectangle(20, 135, 50, 20));
     151        charBox.setHorizontalAlignment(SwingConstants.CENTER);
     152        add(charBox);
     153        charBox.addFocusListener(flCharBox);
     154    }
    141155
    142         public void syncPanel() {
    143                 String str = (String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0);
    144                 charBox.setText(str);
    145                 EnumSet<Chr> set = EnumSet.noneOf(Chr.class);
    146                 for (EnumSet<Chr> map : SeaMark.ChrMAP.keySet()) {
    147                         if (dlg.node != null && str.equals(SeaMark.ChrMAP.get(map))) {
    148                                 set = map;
    149                                 break;
    150                         }
    151                 }
    152                 if (!str.contains("Al")) {
    153                         col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0)));
    154                 } else {
    155                         col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0)));
    156                 }
    157                 col1Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0)));
    158                 for (Chr chr : buttons.keySet()) {
    159                         JToggleButton button = buttons.get(chr);
    160                         if (set.contains(chr)) {
    161                                 button.setSelected(true);
    162                                 button.setBorderPainted(true);
    163                         } else {
    164                                 button.setSelected(false);
    165                                 button.setBorderPainted(false);
    166                         }
    167                 }
    168         }
     156    public void syncPanel() {
     157        String str = (String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0);
     158        charBox.setText(str);
     159        EnumSet<Chr> set = EnumSet.noneOf(Chr.class);
     160        for (EnumSet<Chr> map : SeaMark.ChrMAP.keySet()) {
     161            if (dlg.node != null && str.equals(SeaMark.ChrMAP.get(map))) {
     162                set = map;
     163                break;
     164            }
     165        }
     166        if (!str.contains("Al")) {
     167            col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0)));
     168        } else {
     169            col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0)));
     170        }
     171        col1Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, 0)));
     172        for (Chr chr : buttons.keySet()) {
     173            JToggleButton button = buttons.get(chr);
     174            if (set.contains(chr)) {
     175                button.setSelected(true);
     176                button.setBorderPainted(true);
     177            } else {
     178                button.setSelected(false);
     179                button.setBorderPainted(false);
     180            }
     181        }
     182    }
    169183
    170         private JToggleButton getChrButton(JToggleButton button, int x, int y, int w, int h, String tip, Chr chr) {
    171                 button.setBounds(new Rectangle(x, y, w, h));
    172                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    173                 button.setBorderPainted(false);
    174                 button.setToolTipText(tr(tip));
    175                 button.addActionListener(alCharButton);
    176                 buttons.put(chr, button);
    177                 return button;
    178         }
     184    private JToggleButton getChrButton(JToggleButton button, int x, int y, int w, int h, String tip, Chr chr) {
     185        button.setBounds(new Rectangle(x, y, w, h));
     186        button.setBorder(BorderFactory.createLoweredBevelBorder());
     187        button.setBorderPainted(false);
     188        button.setToolTipText(tr(tip));
     189        button.addActionListener(alCharButton);
     190        buttons.put(chr, button);
     191        return button;
     192    }
    179193
    180194}
  • applications/editors/josm/plugins/smed/src/panels/PanelCol.java

    r30738 r32767  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
    5 import java.awt.*;
    6 import java.awt.event.*;
    7 import javax.swing.*;
    8 
    9 import java.util.*;
     5import java.awt.Color;
     6import java.awt.Rectangle;
     7import java.awt.event.ActionEvent;
     8import java.awt.event.ActionListener;
     9import java.util.ArrayList;
     10import java.util.EnumMap;
     11
     12import javax.swing.BorderFactory;
     13import javax.swing.ButtonGroup;
     14import javax.swing.ImageIcon;
     15import javax.swing.JPanel;
     16import javax.swing.JRadioButton;
    1017
    1118import messages.Messages;
     19import seamarks.SeaMark;
     20import seamarks.SeaMark.Att;
     21import seamarks.SeaMark.Col;
     22import seamarks.SeaMark.Ent;
    1223import smed.SmedAction;
    13 import seamarks.SeaMark;
    14 import seamarks.SeaMark.*;
    1524
    1625public class PanelCol extends JPanel {
    1726
    18         private SmedAction dlg;
    19         private Ent ent;
    20         private ButtonGroup colourButtons = new ButtonGroup();
    21         public JRadioButton delButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DelButton.png")));
    22         public JRadioButton addButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/AddButton.png")));
    23         public JRadioButton whiteButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WhiteButton.png")));
    24         public JRadioButton redButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RedButton.png")));
    25         public JRadioButton greenButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/GreenButton.png")));
    26         public JRadioButton yellowButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/YellowButton.png")));
    27         public JRadioButton orangeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OrangeButton.png")));
    28         public JRadioButton amberButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/AmberButton.png")));
    29         public JRadioButton blueButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BlueButton.png")));
    30         public JRadioButton violetButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/VioletButton.png")));
    31         public JRadioButton blackButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BlackButton.png")));
    32         public JRadioButton greyButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/GreyButton.png")));
    33         public JRadioButton brownButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BrownButton.png")));
    34         public JRadioButton magentaButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/MagentaButton.png")));
    35         public JRadioButton pinkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PinkButton.png")));
    36         public EnumMap<Col, JRadioButton> colours = new EnumMap<>(Col.class);
    37         private ActionListener alColour = new ActionListener() {
    38                 public void actionPerformed(java.awt.event.ActionEvent e) {
    39                         for (Col col : colours.keySet()) {
    40                                 JRadioButton button = colours.get(col);
    41                                 if (button.isSelected()) {
    42                                         if (ent == Ent.LIGHT) {
    43                                                 if (((String) SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).contains("Al")) {
    44                                                         if (((button == delButton) && (SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0) == Col.UNKCOL))
    45                                                                         || (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) == Col.UNKCOL)) {
    46                                                                 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, col);
    47                                                                 SmedAction.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col));
    48                                                         } else {
    49                                                                 SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, col);
    50                                                                 SmedAction.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col));
    51                                                         }
    52                                                 } else {
    53                                                         SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, col);
    54                                                         SmedAction.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col));
    55                                                         SmedAction.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col));
    56                                                 }
    57                                                 button.setBorderPainted(true);
    58                                         } else {
    59                                                 if (button == delButton) {
    60                                                         SmedAction.panelMain.mark.subColour(ent, stackIdx);
    61                                                 } else if (button == addButton) {
    62                                                         if (stackCol.size() != 0)
    63                                                                 stackIdx++;
    64                                                         if (stackCol.size() == 0)
    65                                                                 SmedAction.panelMain.mark.setColour(ent, col);
    66                                                         else
    67                                                                 switch (SmedAction.panelMain.mark.getPattern(ent)) {
    68                                                                 case NOPAT:
    69                                                                         break;
    70                                                                 case BORDER:
    71                                                                 case CROSS:
    72                                                                         if (stackCol.size() < 2)
    73                                                                                 SmedAction.panelMain.mark.addColour(ent, stackIdx, col);
    74                                                                         break;
    75                                                                 case SQUARED:
    76                                                                         if (stackCol.size() < 4)
    77                                                                                 SmedAction.panelMain.mark.addColour(ent, stackIdx, col);
    78                                                                         break;
    79                                                                 default:
    80                                                                         SmedAction.panelMain.mark.addColour(ent, stackIdx, col);
    81                                                                         break;
    82                                                                 }
    83                                                 } else {
    84                                                         SmedAction.panelMain.mark.setColour(ent, stackIdx, col);
    85                                                 }
    86                                                 syncPanel();
    87                                         }
    88                                 } else {
    89                                         button.setBorderPainted(false);
    90                                 }
    91                         }
    92                 }
    93         };
    94         private JPanel stack;
    95         private ButtonGroup stackColours = new ButtonGroup();
    96         private ArrayList<JRadioButton> stackCol = new ArrayList<>();
    97         private int stackIdx = 0;
    98         private ActionListener alStack = new ActionListener() {
    99                 public void actionPerformed(java.awt.event.ActionEvent e) {
    100                         for (int i = 0; stackCol.size() > i; i++) {
    101                                 JRadioButton button = stackCol.get(i);
    102                                 if (button.isSelected()) {
    103                                         stackIdx = i;
    104                                         button.setBorderPainted(true);
    105                                 } else {
    106                                         button.setBorderPainted(false);
    107                                 }
    108                         }
    109                 }
    110         };
    111 
    112         public PanelCol(SmedAction dia, Ent entity) {
    113                 dlg = dia;
    114                 ent = entity;
    115                 setLayout(null);
    116                 add(getColButton(delButton, 0, 0, 34, 16, Messages.getString("RemColour"), Col.UNKCOL));
    117                 add(getColButton(whiteButton, 0, 16, 34, 16, Messages.getString("White"), Col.WHITE));
    118                 add(getColButton(redButton, 0, 32, 34, 16, Messages.getString("Red"), Col.RED));
    119                 add(getColButton(orangeButton, 0, 48, 34, 16, Messages.getString("Orange"), Col.ORANGE));
    120                 add(getColButton(amberButton, 0, 64, 34, 16, Messages.getString("Amber"), Col.AMBER));
    121                 add(getColButton(yellowButton, 0, 80, 34, 16, Messages.getString("Yellow"), Col.YELLOW));
    122                 add(getColButton(greenButton, 0, 96, 34, 16, Messages.getString("Green"), Col.GREEN));
    123                 add(getColButton(blueButton, 0, 112, 34, 16, Messages.getString("Blue"), Col.BLUE));
    124                 add(getColButton(violetButton, 0, 128, 34, 16, Messages.getString("Violet"), Col.VIOLET));
    125                 if (ent != Ent.LIGHT) {
    126                         add(getColButton(addButton, 0, 144, 34, 16, Messages.getString("AddColour"), Col.BLANK));
    127                         add(getColButton(blackButton, 37, 0, 34, 16, Messages.getString("Black"), Col.BLACK));
    128                         add(getColButton(greyButton, 37, 16, 34, 16, Messages.getString("Grey"), Col.GREY));
    129                         add(getColButton(brownButton, 37, 32, 34, 16, Messages.getString("Brown"), Col.BROWN));
    130                         add(getColButton(magentaButton, 37, 48, 34, 16, Messages.getString("Magenta"), Col.MAGENTA));
    131                         add(getColButton(pinkButton, 37, 64, 34, 16, Messages.getString("Pink"), Col.PINK));
    132 
    133                         stack = new JPanel();
    134                         stack.setBorder(BorderFactory.createLineBorder(Color.black, 2));
    135                         stack.setBounds(38, 87, 34, 64);
    136                         stack.setLayout(null);
    137                         add(stack);
    138                 }
    139         }
    140 
    141         public void trimStack(int max) {
    142                 while (stackCol.size() > max) {
    143                         stackCol.get(stackCol.size() - 1).setSelected(true);
    144                         delButton.doClick();
    145                 }
    146         }
    147 
    148         public void syncPanel() {
    149                 if (ent == Ent.LIGHT) {
    150                         for (Col col : colours.keySet()) {
    151                                 JRadioButton button = colours.get(col);
    152                                 if (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) == col) {
    153                                         button.setBorderPainted(true);
    154                                 } else
    155                                         button.setBorderPainted(false);
    156                         }
    157                 } else {
    158                         int idx;
    159                         for (idx = 0; SmedAction.panelMain.mark.getColour(ent, idx) != Col.UNKCOL; idx++) {
    160                                 if (stackCol.size() <= idx) {
    161                                         stackCol.add(idx, new JRadioButton(new ImageIcon(getClass().getResource("/images/ColourButton.png"))));
    162                                         JRadioButton btnI = stackCol.get(idx);
    163                                         btnI.setBorder(BorderFactory.createLoweredBevelBorder());
    164                                         stack.add(btnI);
    165                                         stackColours.add(btnI);
    166                                         btnI.addActionListener(alStack);
    167                                 }
    168                         }
    169                         while (idx < stackCol.size()) {
    170                                 JRadioButton btnI = stackCol.get(idx);
    171                                 btnI.removeActionListener(alStack);
    172                                 stackColours.remove(btnI);
    173                                 stack.remove(btnI);
    174                                 stackCol.remove(idx);
    175                         }
    176                         if (stackIdx >= stackCol.size())
    177                                 stackIdx = stackCol.size() - 1;
    178                         if (stackIdx < 0)
    179                                 stackIdx = 0;
    180                         if (stackCol.size() == 0) {
    181                                 stack.repaint();
    182                         } else {
    183                                 int height = 60 / stackCol.size();
    184                                 for (idx = 0; stackCol.size() > idx; idx++) {
    185                                         JRadioButton btnI = stackCol.get(idx);
    186                                         btnI.setBounds(2, (2 + (idx * height)), 30, height);
    187                                         btnI.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getColour(ent, idx)));
    188                                         if (stackIdx == idx) {
    189                                                 btnI.setBorderPainted(true);
    190                                         } else {
    191                                                 btnI.setBorderPainted(false);
    192                                         }
    193                                 }
    194                         }
    195                 }
    196         }
    197 
    198         private JRadioButton getColButton(JRadioButton button, int x, int y, int w, int h, String tip, Col col) {
    199                 button.setBounds(new Rectangle(x, y, w, h));
    200                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    201                 button.setToolTipText(tr(tip));
    202                 button.addActionListener(alColour);
    203                 colourButtons.add(button);
    204                 colours.put(col, button);
    205                 return button;
    206         }
     27    private SmedAction dlg;
     28    private Ent ent;
     29    private ButtonGroup colourButtons = new ButtonGroup();
     30    public JRadioButton delButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DelButton.png")));
     31    public JRadioButton addButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/AddButton.png")));
     32    public JRadioButton whiteButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WhiteButton.png")));
     33    public JRadioButton redButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RedButton.png")));
     34    public JRadioButton greenButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/GreenButton.png")));
     35    public JRadioButton yellowButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/YellowButton.png")));
     36    public JRadioButton orangeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OrangeButton.png")));
     37    public JRadioButton amberButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/AmberButton.png")));
     38    public JRadioButton blueButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BlueButton.png")));
     39    public JRadioButton violetButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/VioletButton.png")));
     40    public JRadioButton blackButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BlackButton.png")));
     41    public JRadioButton greyButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/GreyButton.png")));
     42    public JRadioButton brownButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BrownButton.png")));
     43    public JRadioButton magentaButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/MagentaButton.png")));
     44    public JRadioButton pinkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PinkButton.png")));
     45    public EnumMap<Col, JRadioButton> colours = new EnumMap<>(Col.class);
     46    private ActionListener alColour = new ActionListener() {
     47        @Override
     48        public void actionPerformed(ActionEvent e) {
     49            for (Col col : colours.keySet()) {
     50                JRadioButton button = colours.get(col);
     51                if (button.isSelected()) {
     52                    if (ent == Ent.LIGHT) {
     53                        if (((String) SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).contains("Al")) {
     54                            if (((button == delButton) && (SmedAction.panelMain.mark.getLightAtt(Att.ALT, 0) == Col.UNKCOL))
     55                                    || (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) == Col.UNKCOL)) {
     56                                SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, col);
     57                                SmedAction.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col));
     58                            } else {
     59                                SmedAction.panelMain.mark.setLightAtt(Att.ALT, 0, col);
     60                                SmedAction.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col));
     61                            }
     62                        } else {
     63                            SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, col);
     64                            SmedAction.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col));
     65                            SmedAction.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col));
     66                        }
     67                        button.setBorderPainted(true);
     68                    } else {
     69                        if (button == delButton) {
     70                            SmedAction.panelMain.mark.subColour(ent, stackIdx);
     71                        } else if (button == addButton) {
     72                            if (stackCol.size() != 0) {
     73                                stackIdx++;
     74                            }
     75                            if (stackCol.size() == 0) {
     76                                SmedAction.panelMain.mark.setColour(ent, col);
     77                            } else {
     78                                switch (SmedAction.panelMain.mark.getPattern(ent)) {
     79                                case NOPAT:
     80                                    break;
     81                                case BORDER:
     82                                case CROSS:
     83                                    if (stackCol.size() < 2) {
     84                                        SmedAction.panelMain.mark.addColour(ent, stackIdx, col);
     85                                    }
     86                                    break;
     87                                case SQUARED:
     88                                    if (stackCol.size() < 4) {
     89                                        SmedAction.panelMain.mark.addColour(ent, stackIdx, col);
     90                                    }
     91                                    break;
     92                                default:
     93                                    SmedAction.panelMain.mark.addColour(ent, stackIdx, col);
     94                                    break;
     95                                }
     96                            }
     97                        } else {
     98                            SmedAction.panelMain.mark.setColour(ent, stackIdx, col);
     99                        }
     100                        syncPanel();
     101                    }
     102                } else {
     103                    button.setBorderPainted(false);
     104                }
     105            }
     106        }
     107    };
     108    private JPanel stack;
     109    private ButtonGroup stackColours = new ButtonGroup();
     110    private ArrayList<JRadioButton> stackCol = new ArrayList<>();
     111    private int stackIdx = 0;
     112    private ActionListener alStack = new ActionListener() {
     113        @Override
     114        public void actionPerformed(ActionEvent e) {
     115            for (int i = 0; stackCol.size() > i; i++) {
     116                JRadioButton button = stackCol.get(i);
     117                if (button.isSelected()) {
     118                    stackIdx = i;
     119                    button.setBorderPainted(true);
     120                } else {
     121                    button.setBorderPainted(false);
     122                }
     123            }
     124        }
     125    };
     126
     127    public PanelCol(SmedAction dia, Ent entity) {
     128        dlg = dia;
     129        ent = entity;
     130        setLayout(null);
     131        add(getColButton(delButton, 0, 0, 34, 16, Messages.getString("RemColour"), Col.UNKCOL));
     132        add(getColButton(whiteButton, 0, 16, 34, 16, Messages.getString("White"), Col.WHITE));
     133        add(getColButton(redButton, 0, 32, 34, 16, Messages.getString("Red"), Col.RED));
     134        add(getColButton(orangeButton, 0, 48, 34, 16, Messages.getString("Orange"), Col.ORANGE));
     135        add(getColButton(amberButton, 0, 64, 34, 16, Messages.getString("Amber"), Col.AMBER));
     136        add(getColButton(yellowButton, 0, 80, 34, 16, Messages.getString("Yellow"), Col.YELLOW));
     137        add(getColButton(greenButton, 0, 96, 34, 16, Messages.getString("Green"), Col.GREEN));
     138        add(getColButton(blueButton, 0, 112, 34, 16, Messages.getString("Blue"), Col.BLUE));
     139        add(getColButton(violetButton, 0, 128, 34, 16, Messages.getString("Violet"), Col.VIOLET));
     140        if (ent != Ent.LIGHT) {
     141            add(getColButton(addButton, 0, 144, 34, 16, Messages.getString("AddColour"), Col.BLANK));
     142            add(getColButton(blackButton, 37, 0, 34, 16, Messages.getString("Black"), Col.BLACK));
     143            add(getColButton(greyButton, 37, 16, 34, 16, Messages.getString("Grey"), Col.GREY));
     144            add(getColButton(brownButton, 37, 32, 34, 16, Messages.getString("Brown"), Col.BROWN));
     145            add(getColButton(magentaButton, 37, 48, 34, 16, Messages.getString("Magenta"), Col.MAGENTA));
     146            add(getColButton(pinkButton, 37, 64, 34, 16, Messages.getString("Pink"), Col.PINK));
     147
     148            stack = new JPanel();
     149            stack.setBorder(BorderFactory.createLineBorder(Color.black, 2));
     150            stack.setBounds(38, 87, 34, 64);
     151            stack.setLayout(null);
     152            add(stack);
     153        }
     154    }
     155
     156    public void trimStack(int max) {
     157        while (stackCol.size() > max) {
     158            stackCol.get(stackCol.size() - 1).setSelected(true);
     159            delButton.doClick();
     160        }
     161    }
     162
     163    public void syncPanel() {
     164        if (ent == Ent.LIGHT) {
     165            for (Col col : colours.keySet()) {
     166                JRadioButton button = colours.get(col);
     167                if (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) == col) {
     168                    button.setBorderPainted(true);
     169                } else {
     170                    button.setBorderPainted(false);
     171                }
     172            }
     173        } else {
     174            int idx;
     175            for (idx = 0; SmedAction.panelMain.mark.getColour(ent, idx) != Col.UNKCOL; idx++) {
     176                if (stackCol.size() <= idx) {
     177                    stackCol.add(idx, new JRadioButton(new ImageIcon(getClass().getResource("/images/ColourButton.png"))));
     178                    JRadioButton btnI = stackCol.get(idx);
     179                    btnI.setBorder(BorderFactory.createLoweredBevelBorder());
     180                    stack.add(btnI);
     181                    stackColours.add(btnI);
     182                    btnI.addActionListener(alStack);
     183                }
     184            }
     185            while (idx < stackCol.size()) {
     186                JRadioButton btnI = stackCol.get(idx);
     187                btnI.removeActionListener(alStack);
     188                stackColours.remove(btnI);
     189                stack.remove(btnI);
     190                stackCol.remove(idx);
     191            }
     192            if (stackIdx >= stackCol.size()) {
     193                stackIdx = stackCol.size() - 1;
     194            }
     195            if (stackIdx < 0) {
     196                stackIdx = 0;
     197            }
     198            if (stackCol.size() == 0) {
     199                stack.repaint();
     200            } else {
     201                int height = 60 / stackCol.size();
     202                for (idx = 0; stackCol.size() > idx; idx++) {
     203                    JRadioButton btnI = stackCol.get(idx);
     204                    btnI.setBounds(2, (2 + (idx * height)), 30, height);
     205                    btnI.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getColour(ent, idx)));
     206                    if (stackIdx == idx) {
     207                        btnI.setBorderPainted(true);
     208                    } else {
     209                        btnI.setBorderPainted(false);
     210                    }
     211                }
     212            }
     213        }
     214    }
     215
     216    private JRadioButton getColButton(JRadioButton button, int x, int y, int w, int h, String tip, Col col) {
     217        button.setBounds(new Rectangle(x, y, w, h));
     218        button.setBorder(BorderFactory.createLoweredBevelBorder());
     219        button.setToolTipText(tr(tip));
     220        button.addActionListener(alColour);
     221        colourButtons.add(button);
     222        colours.put(col, button);
     223        return button;
     224    }
    207225
    208226}
  • applications/editors/josm/plugins/smed/src/panels/PanelFog.java

    r30738 r32767  
    11package panels;
    22
    3 import javax.swing.*;
    4 
    5 import java.awt.*;
    6 import java.awt.event.*;
     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;
    79import java.util.EnumMap;
    810
     11import javax.swing.BorderFactory;
     12import javax.swing.ButtonGroup;
     13import javax.swing.ImageIcon;
     14import javax.swing.JLabel;
     15import javax.swing.JPanel;
     16import javax.swing.JRadioButton;
     17import javax.swing.JTextField;
     18import javax.swing.SwingConstants;
     19
    920import messages.Messages;
     21import seamarks.SeaMark.Fog;
    1022import smed.SmedAction;
    11 import seamarks.SeaMark.*;
    1223
    1324public class PanelFog extends JPanel {
    1425
    15         private SmedAction dlg;
    16         private ButtonGroup fogButtons = new ButtonGroup();
    17         public JRadioButton noFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
    18         public JRadioButton yesFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogYesButton.png")));
    19         public JRadioButton hornButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogHornButton.png")));
    20         public JRadioButton sirenButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogSirenButton.png")));
    21         public JRadioButton diaButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogDiaButton.png")));
    22         public JRadioButton bellButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogBellButton.png")));
    23         public JRadioButton whisButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogWhisButton.png")));
    24         public JRadioButton gongButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogGongButton.png")));
    25         public JRadioButton explosButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogExplosButton.png")));
    26         private EnumMap<Fog, JRadioButton> fogs = new EnumMap<>(Fog.class);
    27         private ActionListener alFog = new ActionListener() {
    28                 public void actionPerformed(java.awt.event.ActionEvent e) {
    29                         for (Fog fog : fogs.keySet()) {
    30                                 JRadioButton button = fogs.get(fog);
    31                                 if (button.isSelected()) {
    32                                         SmedAction.panelMain.mark.setFogSound(fog);
    33                                         button.setBorderPainted(true);
    34                                 } else
    35                                         button.setBorderPainted(false);
    36                         }
    37                 }
    38         };
    39         public JLabel groupLabel;
    40         public JTextField groupBox;
    41         private FocusListener flGroup = new FocusAdapter() {
    42                 public void focusLost(java.awt.event.FocusEvent e) {
    43                         SmedAction.panelMain.mark.setFogGroup(groupBox.getText());
    44                 }
    45         };
    46         public JLabel periodLabel;
    47         public JTextField periodBox;
    48         private FocusListener flPeriod = new FocusAdapter() {
    49                 public void focusLost(java.awt.event.FocusEvent e) {
    50                         SmedAction.panelMain.mark.setFogPeriod(periodBox.getText());
    51                 }
    52         };
    53         public JLabel seqLabel;
    54         public JTextField seqBox;
    55         private FocusListener flSeq = new FocusAdapter() {
    56                 public void focusLost(java.awt.event.FocusEvent e) {
    57                         SmedAction.panelMain.mark.setFogSequence(seqBox.getText());
    58                 }
    59         };
    60         public JLabel rangeLabel;
    61         public JTextField rangeBox;
    62         private FocusListener flRange = new FocusAdapter() {
    63                 public void focusLost(java.awt.event.FocusEvent e) {
    64                         SmedAction.panelMain.mark.setFogRange(rangeBox.getText());
    65                 }
    66         };
     26    private SmedAction dlg;
     27    private ButtonGroup fogButtons = new ButtonGroup();
     28    public JRadioButton noFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
     29    public JRadioButton yesFogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogYesButton.png")));
     30    public JRadioButton hornButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogHornButton.png")));
     31    public JRadioButton sirenButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogSirenButton.png")));
     32    public JRadioButton diaButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogDiaButton.png")));
     33    public JRadioButton bellButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogBellButton.png")));
     34    public JRadioButton whisButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogWhisButton.png")));
     35    public JRadioButton gongButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogGongButton.png")));
     36    public JRadioButton explosButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogExplosButton.png")));
     37    private EnumMap<Fog, JRadioButton> fogs = new EnumMap<>(Fog.class);
     38    private ActionListener alFog = new ActionListener() {
     39        @Override
     40        public void actionPerformed(ActionEvent e) {
     41            for (Fog fog : fogs.keySet()) {
     42                JRadioButton button = fogs.get(fog);
     43                if (button.isSelected()) {
     44                    SmedAction.panelMain.mark.setFogSound(fog);
     45                    button.setBorderPainted(true);
     46                } else {
     47                    button.setBorderPainted(false);
     48                }
     49            }
     50        }
     51    };
     52    public JLabel groupLabel;
     53    public JTextField groupBox;
     54    private FocusListener flGroup = new FocusAdapter() {
     55        @Override
     56        public void focusLost(FocusEvent e) {
     57            SmedAction.panelMain.mark.setFogGroup(groupBox.getText());
     58        }
     59    };
     60    public JLabel periodLabel;
     61    public JTextField periodBox;
     62    private FocusListener flPeriod = new FocusAdapter() {
     63        @Override
     64        public void focusLost(FocusEvent e) {
     65            SmedAction.panelMain.mark.setFogPeriod(periodBox.getText());
     66        }
     67    };
     68    public JLabel seqLabel;
     69    public JTextField seqBox;
     70    private FocusListener flSeq = new FocusAdapter() {
     71        @Override
     72        public void focusLost(FocusEvent e) {
     73            SmedAction.panelMain.mark.setFogSequence(seqBox.getText());
     74        }
     75    };
     76    public JLabel rangeLabel;
     77    public JTextField rangeBox;
     78    private FocusListener flRange = new FocusAdapter() {
     79        @Override
     80        public void focusLost(FocusEvent e) {
     81            SmedAction.panelMain.mark.setFogRange(rangeBox.getText());
     82        }
     83    };
    6784
    68         public PanelFog(SmedAction dia) {
    69                 dlg = dia;
    70                 setLayout(null);
    71                 add(getFogButton(noFogButton, 0, 2, 27, 27, "NoFog", Fog.NOFOG));
    72                 add(getFogButton(yesFogButton, 0, 32, 27, 27, "FogSignal", Fog.FOGSIG));
    73                 add(getFogButton(hornButton, 0, 62, 27, 27, "Horn", Fog.HORN));
    74                 add(getFogButton(sirenButton, 0, 92, 27, 27, "Siren", Fog.SIREN));
    75                 add(getFogButton(gongButton, 0, 122, 27, 27, "Gong", Fog.GONG));
    76                 add(getFogButton(diaButton, 30, 2, 27, 27, "Diaphone", Fog.DIA));
    77                 add(getFogButton(bellButton, 30, 32, 27, 27, "Bell", Fog.BELL));
    78                 add(getFogButton(whisButton, 30, 62, 27, 27, "Whistle", Fog.WHIS));
    79                 add(getFogButton(explosButton, 30, 92, 27, 27, "Explosion", Fog.EXPLOS));
     85    public PanelFog(SmedAction dia) {
     86        dlg = dia;
     87        setLayout(null);
     88        add(getFogButton(noFogButton, 0, 2, 27, 27, "NoFog", Fog.NOFOG));
     89        add(getFogButton(yesFogButton, 0, 32, 27, 27, "FogSignal", Fog.FOGSIG));
     90        add(getFogButton(hornButton, 0, 62, 27, 27, "Horn", Fog.HORN));
     91        add(getFogButton(sirenButton, 0, 92, 27, 27, "Siren", Fog.SIREN));
     92        add(getFogButton(gongButton, 0, 122, 27, 27, "Gong", Fog.GONG));
     93        add(getFogButton(diaButton, 30, 2, 27, 27, "Diaphone", Fog.DIA));
     94        add(getFogButton(bellButton, 30, 32, 27, 27, "Bell", Fog.BELL));
     95        add(getFogButton(whisButton, 30, 62, 27, 27, "Whistle", Fog.WHIS));
     96        add(getFogButton(explosButton, 30, 92, 27, 27, "Explosion", Fog.EXPLOS));
    8097
    81                 groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER);
    82                 groupLabel.setBounds(new Rectangle(75, 0, 100, 20));
    83                 add(groupLabel);
    84                 groupBox = new JTextField();
    85                 groupBox.setBounds(new Rectangle(100, 20, 50, 20));
    86                 groupBox.setHorizontalAlignment(SwingConstants.CENTER);
    87                 add(groupBox);
    88                 groupBox.addFocusListener(flGroup);
     98        groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER);
     99        groupLabel.setBounds(new Rectangle(75, 0, 100, 20));
     100        add(groupLabel);
     101        groupBox = new JTextField();
     102        groupBox.setBounds(new Rectangle(100, 20, 50, 20));
     103        groupBox.setHorizontalAlignment(SwingConstants.CENTER);
     104        add(groupBox);
     105        groupBox.addFocusListener(flGroup);
    89106
    90                 periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER);
    91                 periodLabel.setBounds(new Rectangle(75, 40, 100, 20));
    92                 add(periodLabel);
    93                 periodBox = new JTextField();
    94                 periodBox.setBounds(new Rectangle(100, 60, 50, 20));
    95                 periodBox.setHorizontalAlignment(SwingConstants.CENTER);
    96                 add(periodBox);
    97                 periodBox.addFocusListener(flPeriod);
     107        periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER);
     108        periodLabel.setBounds(new Rectangle(75, 40, 100, 20));
     109        add(periodLabel);
     110        periodBox = new JTextField();
     111        periodBox.setBounds(new Rectangle(100, 60, 50, 20));
     112        periodBox.setHorizontalAlignment(SwingConstants.CENTER);
     113        add(periodBox);
     114        periodBox.addFocusListener(flPeriod);
    98115
    99                 seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER);
    100                 seqLabel.setBounds(new Rectangle(75, 80, 100, 20));
    101                 add(seqLabel);
    102                 seqBox = new JTextField();
    103                 seqBox.setBounds(new Rectangle(100, 100, 50, 20));
    104                 seqBox.setHorizontalAlignment(SwingConstants.CENTER);
    105                 add(seqBox);
    106                 seqBox.addFocusListener(flSeq);
     116        seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER);
     117        seqLabel.setBounds(new Rectangle(75, 80, 100, 20));
     118        add(seqLabel);
     119        seqBox = new JTextField();
     120        seqBox.setBounds(new Rectangle(100, 100, 50, 20));
     121        seqBox.setHorizontalAlignment(SwingConstants.CENTER);
     122        add(seqBox);
     123        seqBox.addFocusListener(flSeq);
    107124
    108                 rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER);
    109                 rangeLabel.setBounds(new Rectangle(75, 120, 100, 20));
    110                 add(rangeLabel);
    111                 rangeBox = new JTextField();
    112                 rangeBox.setBounds(new Rectangle(100, 140, 50, 20));
    113                 rangeBox.setHorizontalAlignment(SwingConstants.CENTER);
    114                 add(rangeBox);
    115                 rangeBox.addFocusListener(flRange);
     125        rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER);
     126        rangeLabel.setBounds(new Rectangle(75, 120, 100, 20));
     127        add(rangeLabel);
     128        rangeBox = new JTextField();
     129        rangeBox.setBounds(new Rectangle(100, 140, 50, 20));
     130        rangeBox.setHorizontalAlignment(SwingConstants.CENTER);
     131        add(rangeBox);
     132        rangeBox.addFocusListener(flRange);
    116133
    117         }
     134    }
    118135
    119         public void syncPanel() {
    120                 for (Fog fog : fogs.keySet()) {
    121                         JRadioButton button = fogs.get(fog);
    122                         button.setBorderPainted(SmedAction.panelMain.mark.getFogSound() == fog);
    123                 }
    124                 groupBox.setText(SmedAction.panelMain.mark.getFogGroup());
    125                 seqBox.setText(SmedAction.panelMain.mark.getFogSequence());
    126                 periodBox.setText(SmedAction.panelMain.mark.getFogPeriod());
    127                 rangeBox.setText(SmedAction.panelMain.mark.getFogRange());
    128         }
     136    public void syncPanel() {
     137        for (Fog fog : fogs.keySet()) {
     138            JRadioButton button = fogs.get(fog);
     139            button.setBorderPainted(SmedAction.panelMain.mark.getFogSound() == fog);
     140        }
     141        groupBox.setText(SmedAction.panelMain.mark.getFogGroup());
     142        seqBox.setText(SmedAction.panelMain.mark.getFogSequence());
     143        periodBox.setText(SmedAction.panelMain.mark.getFogPeriod());
     144        rangeBox.setText(SmedAction.panelMain.mark.getFogRange());
     145    }
    129146
    130         private JRadioButton getFogButton(JRadioButton button, int x, int y, int w, int h, String tip, Fog fog) {
    131                 button.setBounds(new Rectangle(x, y, w, h));
    132                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    133                 button.setToolTipText(Messages.getString(tip));
    134                 button.addActionListener(alFog);
    135                 fogButtons.add(button);
    136                 fogs.put(fog, button);
    137                 return button;
    138         }
     147    private JRadioButton getFogButton(JRadioButton button, int x, int y, int w, int h, String tip, Fog fog) {
     148        button.setBounds(new Rectangle(x, y, w, h));
     149        button.setBorder(BorderFactory.createLoweredBevelBorder());
     150        button.setToolTipText(Messages.getString(tip));
     151        button.addActionListener(alFog);
     152        fogButtons.add(button);
     153        fogs.put(fog, button);
     154        return button;
     155    }
    139156
    140157}
  • applications/editors/josm/plugins/smed/src/panels/PanelHaz.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.util.EnumMap;
     7
     8import javax.swing.BorderFactory;
     9import javax.swing.ButtonGroup;
     10import javax.swing.ImageIcon;
     11import javax.swing.JPanel;
     12import javax.swing.JRadioButton;
     13import javax.swing.JToggleButton;
    914
    1015import messages.Messages;
     16import seamarks.SeaMark;
     17import seamarks.SeaMark.Att;
     18import seamarks.SeaMark.Cat;
     19import seamarks.SeaMark.Col;
     20import seamarks.SeaMark.Grp;
     21import seamarks.SeaMark.Obj;
     22import seamarks.SeaMark.Pat;
     23import seamarks.SeaMark.Shp;
     24import seamarks.SeaMark.Top;
    1125import smed.SmedAction;
    12 import seamarks.SeaMark;
    13 import seamarks.SeaMark.*;
    1426
    1527public class PanelHaz extends JPanel {
    1628
    17         private SmedAction dlg;
    18         public ButtonGroup catButtons = new ButtonGroup();
    19         public JRadioButton northButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardNButton.png")));
    20         public JRadioButton southButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardSButton.png")));
    21         public JRadioButton eastButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardEButton.png")));
    22         public JRadioButton westButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardWButton.png")));
    23         public JRadioButton isolButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/IsolButton.png")));
    24         private ActionListener alCat = new ActionListener() {
    25                 public void actionPerformed(java.awt.event.ActionEvent e) {
    26                         SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
    27                         if (northButton.isSelected()) {
    28                                 SmedAction.panelMain.mark.setCategory(Cat.CAM_NORTH);
    29                                 SmedAction.panelMain.mark.setObjColour(Col.BLACK);
    30                                 SmedAction.panelMain.mark.addObjColour(Col.YELLOW);
    31                                 northButton.setBorderPainted(true);
    32                         } else {
    33                                 northButton.setBorderPainted(false);
    34                         }
    35                         if (southButton.isSelected()) {
    36                                 SmedAction.panelMain.mark.setCategory(Cat.CAM_SOUTH);
    37                                 SmedAction.panelMain.mark.setObjColour(Col.YELLOW);
    38                                 SmedAction.panelMain.mark.addObjColour(Col.BLACK);
    39                                 southButton.setBorderPainted(true);
    40                         } else {
    41                                 southButton.setBorderPainted(false);
    42                         }
    43                         if (eastButton.isSelected()) {
    44                                 SmedAction.panelMain.mark.setCategory(Cat.CAM_EAST);
    45                                 SmedAction.panelMain.mark.setObjColour(Col.BLACK);
    46                                 SmedAction.panelMain.mark.addObjColour(Col.YELLOW);
    47                                 SmedAction.panelMain.mark.addObjColour(Col.BLACK);
    48                                 eastButton.setBorderPainted(true);
    49                         } else {
    50                                 eastButton.setBorderPainted(false);
    51                         }
    52                         if (westButton.isSelected()) {
    53                                 SmedAction.panelMain.mark.setCategory(Cat.CAM_WEST);
    54                                 SmedAction.panelMain.mark.setObjColour(Col.YELLOW);
    55                                 SmedAction.panelMain.mark.addObjColour(Col.BLACK);
    56                                 SmedAction.panelMain.mark.addObjColour(Col.YELLOW);
    57                                 westButton.setBorderPainted(true);
    58                         } else {
    59                                 westButton.setBorderPainted(false);
    60                         }
    61                         if (isolButton.isSelected()) {
    62                                 SmedAction.panelMain.mark.setCategory(Cat.NOCAT);
    63                                 SmedAction.panelMain.mark.setObjColour(Col.BLACK);
    64                                 SmedAction.panelMain.mark.addObjColour(Col.RED);
    65                                 SmedAction.panelMain.mark.addObjColour(Col.BLACK);
    66                                 isolButton.setBorderPainted(true);
    67                         } else {
    68                                 isolButton.setBorderPainted(false);
    69                         }
    70                         topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
    71                         lightButton.setVisible(SmedAction.panelMain.mark.testValid());
    72                         SmedAction.panelMain.panelMore.syncPanel();
    73                 }
    74         };
    75         private ButtonGroup shapeButtons = new ButtonGroup();
    76         public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
    77         public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
    78         public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
    79         public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png")));
    80         public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png")));
    81         public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
    82         public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
    83         public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png")));
    84         public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
    85         public EnumMap<Shp, Obj> carObjects = new EnumMap<>(Shp.class);
    86         public EnumMap<Shp, Obj> isdObjects = new EnumMap<>(Shp.class);
    87         private ActionListener alShape = new ActionListener() {
    88                 public void actionPerformed(java.awt.event.ActionEvent e) {
    89                         for (Shp shp : shapes.keySet()) {
    90                                 JRadioButton button = shapes.get(shp);
    91                                 if (button.isSelected()) {
    92                                         SmedAction.panelMain.mark.setShape(shp);
    93                                         if (isolButton.isSelected())
    94                                                 SmedAction.panelMain.mark.setObject(isdObjects.get(shp));
    95                                         else
    96                                                 SmedAction.panelMain.mark.setObject(carObjects.get(shp));
    97                                         button.setBorderPainted(true);
    98                                 } else
    99                                         button.setBorderPainted(false);
    100                         }
    101                         topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
    102                         lightButton.setVisible(SmedAction.panelMain.mark.testValid());
    103                 }
    104         };
    105         public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/HazTopButton.png")));
    106         private ActionListener alTop = new ActionListener() {
    107                 public void actionPerformed(java.awt.event.ActionEvent e) {
    108                         if (topmarkButton.isSelected()) {
    109                                 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
    110                                 SmedAction.panelMain.mark.setTopColour(Col.BLACK);
    111                                 switch (SmedAction.panelMain.mark.getCategory()) {
    112                                 case CAM_NORTH:
    113                                         SmedAction.panelMain.mark.setTopmark(Top.NORTH);
    114                                         break;
    115                                 case CAM_SOUTH:
    116                                         SmedAction.panelMain.mark.setTopmark(Top.SOUTH);
    117                                         break;
    118                                 case CAM_EAST:
    119                                         SmedAction.panelMain.mark.setTopmark(Top.EAST);
    120                                         break;
    121                                 case CAM_WEST:
    122                                         SmedAction.panelMain.mark.setTopmark(Top.WEST);
    123                                         break;
    124                                 default:
    125                                         SmedAction.panelMain.mark.setTopmark(Top.SPHERES2);
    126                                         break;
    127                                 }
    128                                 topmarkButton.setBorderPainted(true);
    129                         } else {
    130                                 SmedAction.panelMain.mark.setTopmark(Top.NOTOP);
    131                                 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
    132                                 SmedAction.panelMain.mark.setTopColour(Col.UNKCOL);
    133                                 topmarkButton.setBorderPainted(false);
    134                         }
    135                         SmedAction.panelMain.panelTop.syncPanel();
    136                 }
    137         };
    138         public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png")));
    139         private ActionListener alLit = new ActionListener() {
    140                 public void actionPerformed(java.awt.event.ActionEvent e) {
    141                         if (lightButton.isSelected()) {
    142                                 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE);
    143                                 switch (SmedAction.panelMain.mark.getCategory()) {
    144                                 case CAM_NORTH:
    145                                         SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q");
    146                                         SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "");
    147                                         break;
    148                                 case CAM_SOUTH:
    149                                         SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q+LFl");
    150                                         SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "6");
    151                                         break;
    152                                 case CAM_EAST:
    153                                         SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q");
    154                                         SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "3");
    155                                         break;
    156                                 case CAM_WEST:
    157                                         SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q");
    158                                         SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "9");
    159                                         break;
    160                                 default:
    161                                         SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl");
    162                                         SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "2");
    163                                         break;
    164                                 }
    165                                 lightButton.setBorderPainted(true);
    166                         } else {
    167                                 SmedAction.panelMain.mark.clrLight();
    168                                 lightButton.setBorderPainted(false);
    169                         }
    170                         SmedAction.panelMain.panelLit.syncPanel();
    171                 }
    172         };
    173 
    174         public PanelHaz(SmedAction dia) {
    175                 dlg = dia;
    176                 setLayout(null);
    177                 add(getCatButton(northButton, 0, 0, 52, 32, "North"));
    178                 add(getCatButton(southButton, 0, 32, 52, 32, "South"));
    179                 add(getCatButton(eastButton, 0, 64, 52, 32, "East"));
    180                 add(getCatButton(westButton, 0, 96, 52, 32, "West"));
    181                 add(getCatButton(isolButton, 0, 128, 52, 32, "Isol"));
    182 
    183                 add(getShapeButton(pillarButton, 55, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYCAR, Obj.BOYISD));
    184                 add(getShapeButton(sparButton, 55, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYCAR, Obj.BOYISD));
    185                 add(getShapeButton(canButton, 55, 64, 34, 32, "Can", Shp.CAN, Obj.BOYCAR, Obj.BOYISD));
    186                 add(getShapeButton(coneButton, 55, 96, 34, 32, "Cone", Shp.CONI, Obj.BOYCAR, Obj.BOYISD));
    187                 add(getShapeButton(sphereButton, 55, 128, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYCAR, Obj.BOYISD));
    188                 add(getShapeButton(floatButton, 90, 0, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT, Obj.LITFLT));
    189                 add(getShapeButton(beaconButton, 90, 32, 34, 32, "Beacon", Shp.BEACON, Obj.BCNCAR, Obj.BCNISD));
    190                 add(getShapeButton(towerButton, 90, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNCAR, Obj.BCNISD));
    191 
    192                 topmarkButton.setBounds(new Rectangle(130, 0, 34, 32));
    193                 topmarkButton.setToolTipText(Messages.getString("Topmark"));
    194                 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder());
    195                 topmarkButton.addActionListener(alTop);
    196                 topmarkButton.setVisible(false);
    197                 add(topmarkButton);
    198                 lightButton.setBounds(new Rectangle(130, 32, 34, 32));
    199                 lightButton.setToolTipText(Messages.getString("Light"));
    200                 lightButton.setBorder(BorderFactory.createLoweredBevelBorder());
    201                 lightButton.addActionListener(alLit);
    202                 lightButton.setVisible(false);
    203                 add(lightButton);
    204         }
    205 
    206         public void syncPanel() {
    207                 northButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_NORTH);
    208                 southButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_SOUTH);
    209                 eastButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_EAST);
    210                 westButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_WEST);
    211                 isolButton.setBorderPainted(SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.ISD);
    212                 for (Shp shp : shapes.keySet()) {
    213                         JRadioButton button = shapes.get(shp);
    214                         button.setBorderPainted(SmedAction.panelMain.mark.getShape() == shp);
    215                 }
    216                 topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP);
    217                 topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP);
    218                 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
    219                 Boolean lit = (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty();
    220                 lightButton.setBorderPainted(lit);
    221                 lightButton.setSelected(lit);
    222                 lightButton.setVisible(SmedAction.panelMain.mark.testValid());
    223         }
    224 
    225         private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) {
    226                 button.setBounds(new Rectangle(x, y, w, h));
    227                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    228                 button.setToolTipText(Messages.getString(tip));
    229                 button.addActionListener(alCat);
    230                 catButtons.add(button);
    231                 return button;
    232         }
    233 
    234         private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj car, Obj isd) {
    235                 button.setBounds(new Rectangle(x, y, w, h));
    236                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    237                 button.setToolTipText(Messages.getString(tip));
    238                 button.addActionListener(alShape);
    239                 shapeButtons.add(button);
    240                 shapes.put(shp, button);
    241                 carObjects.put(shp, car);
    242                 isdObjects.put(shp, isd);
    243                 return button;
    244         }
     29    private SmedAction dlg;
     30    public ButtonGroup catButtons = new ButtonGroup();
     31    public JRadioButton northButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardNButton.png")));
     32    public JRadioButton southButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardSButton.png")));
     33    public JRadioButton eastButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardEButton.png")));
     34    public JRadioButton westButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardWButton.png")));
     35    public JRadioButton isolButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/IsolButton.png")));
     36    private ActionListener alCat = new ActionListener() {
     37        @Override
     38        public void actionPerformed(ActionEvent e) {
     39            SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
     40            if (northButton.isSelected()) {
     41                SmedAction.panelMain.mark.setCategory(Cat.CAM_NORTH);
     42                SmedAction.panelMain.mark.setObjColour(Col.BLACK);
     43                SmedAction.panelMain.mark.addObjColour(Col.YELLOW);
     44                northButton.setBorderPainted(true);
     45            } else {
     46                northButton.setBorderPainted(false);
     47            }
     48            if (southButton.isSelected()) {
     49                SmedAction.panelMain.mark.setCategory(Cat.CAM_SOUTH);
     50                SmedAction.panelMain.mark.setObjColour(Col.YELLOW);
     51                SmedAction.panelMain.mark.addObjColour(Col.BLACK);
     52                southButton.setBorderPainted(true);
     53            } else {
     54                southButton.setBorderPainted(false);
     55            }
     56            if (eastButton.isSelected()) {
     57                SmedAction.panelMain.mark.setCategory(Cat.CAM_EAST);
     58                SmedAction.panelMain.mark.setObjColour(Col.BLACK);
     59                SmedAction.panelMain.mark.addObjColour(Col.YELLOW);
     60                SmedAction.panelMain.mark.addObjColour(Col.BLACK);
     61                eastButton.setBorderPainted(true);
     62            } else {
     63                eastButton.setBorderPainted(false);
     64            }
     65            if (westButton.isSelected()) {
     66                SmedAction.panelMain.mark.setCategory(Cat.CAM_WEST);
     67                SmedAction.panelMain.mark.setObjColour(Col.YELLOW);
     68                SmedAction.panelMain.mark.addObjColour(Col.BLACK);
     69                SmedAction.panelMain.mark.addObjColour(Col.YELLOW);
     70                westButton.setBorderPainted(true);
     71            } else {
     72                westButton.setBorderPainted(false);
     73            }
     74            if (isolButton.isSelected()) {
     75                SmedAction.panelMain.mark.setCategory(Cat.NOCAT);
     76                SmedAction.panelMain.mark.setObjColour(Col.BLACK);
     77                SmedAction.panelMain.mark.addObjColour(Col.RED);
     78                SmedAction.panelMain.mark.addObjColour(Col.BLACK);
     79                isolButton.setBorderPainted(true);
     80            } else {
     81                isolButton.setBorderPainted(false);
     82            }
     83            topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
     84            lightButton.setVisible(SmedAction.panelMain.mark.testValid());
     85            SmedAction.panelMain.panelMore.syncPanel();
     86        }
     87    };
     88    private ButtonGroup shapeButtons = new ButtonGroup();
     89    public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
     90    public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
     91    public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
     92    public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png")));
     93    public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png")));
     94    public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
     95    public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
     96    public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png")));
     97    public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
     98    public EnumMap<Shp, Obj> carObjects = new EnumMap<>(Shp.class);
     99    public EnumMap<Shp, Obj> isdObjects = new EnumMap<>(Shp.class);
     100    private ActionListener alShape = new ActionListener() {
     101        @Override
     102        public void actionPerformed(ActionEvent e) {
     103            for (Shp shp : shapes.keySet()) {
     104                JRadioButton button = shapes.get(shp);
     105                if (button.isSelected()) {
     106                    SmedAction.panelMain.mark.setShape(shp);
     107                    if (isolButton.isSelected()) {
     108                        SmedAction.panelMain.mark.setObject(isdObjects.get(shp));
     109                    } else {
     110                        SmedAction.panelMain.mark.setObject(carObjects.get(shp));
     111                    }
     112                    button.setBorderPainted(true);
     113                } else {
     114                    button.setBorderPainted(false);
     115                }
     116            }
     117            topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
     118            lightButton.setVisible(SmedAction.panelMain.mark.testValid());
     119        }
     120    };
     121    public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/HazTopButton.png")));
     122    private ActionListener alTop = new ActionListener() {
     123        @Override
     124        public void actionPerformed(ActionEvent e) {
     125            if (topmarkButton.isSelected()) {
     126                SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
     127                SmedAction.panelMain.mark.setTopColour(Col.BLACK);
     128                switch (SmedAction.panelMain.mark.getCategory()) {
     129                case CAM_NORTH:
     130                    SmedAction.panelMain.mark.setTopmark(Top.NORTH);
     131                    break;
     132                case CAM_SOUTH:
     133                    SmedAction.panelMain.mark.setTopmark(Top.SOUTH);
     134                    break;
     135                case CAM_EAST:
     136                    SmedAction.panelMain.mark.setTopmark(Top.EAST);
     137                    break;
     138                case CAM_WEST:
     139                    SmedAction.panelMain.mark.setTopmark(Top.WEST);
     140                    break;
     141                default:
     142                    SmedAction.panelMain.mark.setTopmark(Top.SPHERES2);
     143                    break;
     144                }
     145                topmarkButton.setBorderPainted(true);
     146            } else {
     147                SmedAction.panelMain.mark.setTopmark(Top.NOTOP);
     148                SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
     149                SmedAction.panelMain.mark.setTopColour(Col.UNKCOL);
     150                topmarkButton.setBorderPainted(false);
     151            }
     152            SmedAction.panelMain.panelTop.syncPanel();
     153        }
     154    };
     155    public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png")));
     156    private ActionListener alLit = new ActionListener() {
     157        @Override
     158        public void actionPerformed(ActionEvent e) {
     159            if (lightButton.isSelected()) {
     160                SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE);
     161                switch (SmedAction.panelMain.mark.getCategory()) {
     162                case CAM_NORTH:
     163                    SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q");
     164                    SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "");
     165                    break;
     166                case CAM_SOUTH:
     167                    SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q+LFl");
     168                    SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "6");
     169                    break;
     170                case CAM_EAST:
     171                    SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q");
     172                    SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "3");
     173                    break;
     174                case CAM_WEST:
     175                    SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q");
     176                    SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "9");
     177                    break;
     178                default:
     179                    SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl");
     180                    SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "2");
     181                    break;
     182                }
     183                lightButton.setBorderPainted(true);
     184            } else {
     185                SmedAction.panelMain.mark.clrLight();
     186                lightButton.setBorderPainted(false);
     187            }
     188            SmedAction.panelMain.panelLit.syncPanel();
     189        }
     190    };
     191
     192    public PanelHaz(SmedAction dia) {
     193        dlg = dia;
     194        setLayout(null);
     195        add(getCatButton(northButton, 0, 0, 52, 32, "North"));
     196        add(getCatButton(southButton, 0, 32, 52, 32, "South"));
     197        add(getCatButton(eastButton, 0, 64, 52, 32, "East"));
     198        add(getCatButton(westButton, 0, 96, 52, 32, "West"));
     199        add(getCatButton(isolButton, 0, 128, 52, 32, "Isol"));
     200
     201        add(getShapeButton(pillarButton, 55, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYCAR, Obj.BOYISD));
     202        add(getShapeButton(sparButton, 55, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYCAR, Obj.BOYISD));
     203        add(getShapeButton(canButton, 55, 64, 34, 32, "Can", Shp.CAN, Obj.BOYCAR, Obj.BOYISD));
     204        add(getShapeButton(coneButton, 55, 96, 34, 32, "Cone", Shp.CONI, Obj.BOYCAR, Obj.BOYISD));
     205        add(getShapeButton(sphereButton, 55, 128, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYCAR, Obj.BOYISD));
     206        add(getShapeButton(floatButton, 90, 0, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT, Obj.LITFLT));
     207        add(getShapeButton(beaconButton, 90, 32, 34, 32, "Beacon", Shp.BEACON, Obj.BCNCAR, Obj.BCNISD));
     208        add(getShapeButton(towerButton, 90, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNCAR, Obj.BCNISD));
     209
     210        topmarkButton.setBounds(new Rectangle(130, 0, 34, 32));
     211        topmarkButton.setToolTipText(Messages.getString("Topmark"));
     212        topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder());
     213        topmarkButton.addActionListener(alTop);
     214        topmarkButton.setVisible(false);
     215        add(topmarkButton);
     216        lightButton.setBounds(new Rectangle(130, 32, 34, 32));
     217        lightButton.setToolTipText(Messages.getString("Light"));
     218        lightButton.setBorder(BorderFactory.createLoweredBevelBorder());
     219        lightButton.addActionListener(alLit);
     220        lightButton.setVisible(false);
     221        add(lightButton);
     222    }
     223
     224    public void syncPanel() {
     225        northButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_NORTH);
     226        southButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_SOUTH);
     227        eastButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_EAST);
     228        westButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_WEST);
     229        isolButton.setBorderPainted(SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.ISD);
     230        for (Shp shp : shapes.keySet()) {
     231            JRadioButton button = shapes.get(shp);
     232            button.setBorderPainted(SmedAction.panelMain.mark.getShape() == shp);
     233        }
     234        topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP);
     235        topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP);
     236        topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
     237        Boolean lit = (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty();
     238        lightButton.setBorderPainted(lit);
     239        lightButton.setSelected(lit);
     240        lightButton.setVisible(SmedAction.panelMain.mark.testValid());
     241    }
     242
     243    private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) {
     244        button.setBounds(new Rectangle(x, y, w, h));
     245        button.setBorder(BorderFactory.createLoweredBevelBorder());
     246        button.setToolTipText(Messages.getString(tip));
     247        button.addActionListener(alCat);
     248        catButtons.add(button);
     249        return button;
     250    }
     251
     252    private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj car, Obj isd) {
     253        button.setBounds(new Rectangle(x, y, w, h));
     254        button.setBorder(BorderFactory.createLoweredBevelBorder());
     255        button.setToolTipText(Messages.getString(tip));
     256        button.addActionListener(alShape);
     257        shapeButtons.add(button);
     258        shapes.put(shp, button);
     259        carObjects.put(shp, car);
     260        isdObjects.put(shp, isd);
     261        return button;
     262    }
    245263
    246264}
  • 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}
  • applications/editors/josm/plugins/smed/src/panels/PanelLit.java

    r30738 r32767  
    11package panels;
    22
    3 import javax.swing.*;
    4 
    5 import java.awt.*;
    6 import java.awt.event.*;
     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;
    79import java.util.EnumMap;
    810
     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;
     20
    921import messages.Messages;
     22import seamarks.SeaMark.Att;
     23import seamarks.SeaMark.Ent;
     24import seamarks.SeaMark.Exh;
     25import seamarks.SeaMark.Lit;
     26import seamarks.SeaMark.Vis;
    1027import smed.SmedAction;
    11 import seamarks.SeaMark.*;
    1228
    1329public class PanelLit extends JPanel {
    1430
    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    }
    350387
    351388}
  • applications/editors/josm/plugins/smed/src/panels/PanelMain.java

    r30295 r32767  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
    5 import java.awt.*;
    6 import java.awt.event.*;
    7 import javax.swing.*;
     5import java.awt.Color;
     6import java.awt.Insets;
     7import java.awt.Rectangle;
     8import java.awt.event.ActionEvent;
     9import java.awt.event.ActionListener;
     10import java.awt.event.FocusEvent;
     11import java.awt.event.FocusListener;
     12
     13import javax.swing.BorderFactory;
     14import javax.swing.ButtonGroup;
     15import javax.swing.ImageIcon;
     16import javax.swing.JButton;
     17import javax.swing.JLabel;
     18import javax.swing.JPanel;
     19import javax.swing.JRadioButton;
     20import javax.swing.JTextField;
     21import javax.swing.SwingConstants;
    822
    923import messages.Messages;
     24import seamarks.SeaMark;
    1025import smed.SmedAction;
    11 import seamarks.SeaMark;
    1226
    1327public class PanelMain extends JPanel {
    1428
    15         private SmedAction dlg;
    16         public SeaMark mark = null;
    17         public PanelChan panelChan = null;
    18         public PanelHaz panelHaz = null;
    19         public PanelSpec panelSpec = null;
    20         public PanelLights panelLights = null;
    21         public PanelMore panelMore = null;
    22         public PanelTop panelTop = null;
    23         public PanelFog panelFog = null;
    24         public PanelRadar panelRadar = null;
    25         public PanelLit panelLit = null;
    26         public JLabel nameLabel = null;
    27         public JTextField nameBox = null;
    28         public static JTextField messageBar = null;
    29         private FocusListener flName = new FocusListener() {
    30                 public void focusLost(java.awt.event.FocusEvent e) {
    31                         mark.setName(nameBox.getText());
    32                 }
    33                 public void focusGained(java.awt.event.FocusEvent e) {
    34                 }
    35         };
    36         public JButton saveButton = null;
    37         private ActionListener alSave = new ActionListener() {
    38                 public void actionPerformed(java.awt.event.ActionEvent e) {
    39                         mark.saveSign(dlg.node);
    40                 }
    41         };
    42         public JButton moreButton = null;
    43         private ActionListener alMore = new ActionListener() {
    44                 public void actionPerformed(java.awt.event.ActionEvent e) {
    45                         if (panelMore.isVisible()) {
    46                                 moreButton.setText(">>");
    47                                 panelMore.setVisible(false);
    48                                 topButton.setEnabled(true);
    49                                 radButton.setEnabled(true);
    50                                 fogButton.setEnabled(true);
    51                                 litButton.setEnabled(true);
    52                         } else {
    53                                 panelMore.setVisible(true);
    54                                 moreButton.setText("<<");
    55                                 miscButtons.clearSelection();
    56                                 panelTop.setVisible(false);
    57                                 topButton.setBorderPainted(false);
    58                                 topButton.setEnabled(false);
    59                                 panelRadar.setVisible(false);
    60                                 radButton.setBorderPainted(false);
    61                                 radButton.setEnabled(false);
    62                                 panelFog.setVisible(false);
    63                                 fogButton.setBorderPainted(false);
    64                                 fogButton.setEnabled(false);
    65                                 panelLit.setVisible(false);
    66                                 litButton.setBorderPainted(false);
    67                                 litButton.setEnabled(false);
    68                         }
    69                 }
    70         };
    71         public ButtonGroup typeButtons = null;
    72         public JRadioButton chanButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ChanButton.png")));
    73         public JRadioButton hazButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/HazButton.png")));
    74         public JRadioButton specButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SpecButton.png")));
    75         public JRadioButton lightsButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightsButton.png")));
    76         private ActionListener alType = new ActionListener() {
    77                 public void actionPerformed(java.awt.event.ActionEvent e) {
    78                         if (chanButton.isSelected()) {
    79                                 chanButton.setBorderPainted(true);
    80                                 panelChan.syncPanel();
    81                                 panelChan.setVisible(true);
    82                         } else {
    83                                 chanButton.setBorderPainted(false);
    84                                 panelChan.setVisible(false);
    85                         }
    86                         if (hazButton.isSelected()) {
    87                                 hazButton.setBorderPainted(true);
    88                                 panelHaz.syncPanel();
    89                                 panelHaz.setVisible(true);
    90                         } else {
    91                                 hazButton.setBorderPainted(false);
    92                                 panelHaz.setVisible(false);
    93                         }
    94                         if (specButton.isSelected()) {
    95                                 specButton.setBorderPainted(true);
    96                                 panelSpec.syncPanel();
    97                                 panelSpec.setVisible(true);
    98                         } else {
    99                                 specButton.setBorderPainted(false);
    100                                 panelSpec.setVisible(false);
    101                         }
    102                         if (lightsButton.isSelected()) {
    103                                 lightsButton.setBorderPainted(true);
    104                                 panelLights.syncPanel();
    105                                 panelLights.setVisible(true);
    106                         } else {
    107                                 lightsButton.setBorderPainted(false);
    108                                 panelLights.setVisible(false);
    109                         }
    110                 }
    111         };
    112         private ButtonGroup miscButtons = null;
    113         public JRadioButton topButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TopButton.png")));
    114         public JRadioButton fogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogButton.png")));
    115         public JRadioButton radButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarButton.png")));
    116         public JRadioButton litButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LitButton.png")));
    117         private ActionListener alMisc = new ActionListener() {
    118                 public void actionPerformed(java.awt.event.ActionEvent e) {
    119                         if (topButton.isSelected()) {
    120                                 moreButton.setText(">>");
    121                                 panelMore.setVisible(false);
    122                                 topButton.setBorderPainted(true);
    123                                 panelTop.setVisible(true);
    124                                 panelTop.syncPanel();
    125                         } else {
    126                                 topButton.setBorderPainted(false);
    127                                 panelTop.setVisible(false);
    128                         }
    129                         if (fogButton.isSelected()) {
    130                                 moreButton.setText(">>");
    131                                 panelMore.setVisible(false);
    132                                 fogButton.setBorderPainted(true);
    133                                 panelFog.setVisible(true);
    134                                 panelFog.syncPanel();
    135                         } else {
    136                                 fogButton.setBorderPainted(false);
    137                                 panelFog.setVisible(false);
    138                         }
    139                         if (radButton.isSelected()) {
    140                                 moreButton.setText(">>");
    141                                 panelMore.setVisible(false);
    142                                 radButton.setBorderPainted(true);
    143                                 panelRadar.setVisible(true);
    144                                 panelRadar.syncPanel();
    145                         } else {
    146                                 radButton.setBorderPainted(false);
    147                                 panelRadar.setVisible(false);
    148                         }
    149                         if (litButton.isSelected()) {
    150                                 moreButton.setText(">>");
    151                                 panelMore.setVisible(false);
    152                                 litButton.setBorderPainted(true);
    153                                 panelLit.setVisible(true);
    154                                 panelLit.syncPanel();
    155                         } else {
    156                                 litButton.setBorderPainted(false);
    157                                 panelLit.setVisible(false);
    158                         }
    159                 }
    160         };
    161        
    162         public PanelMain(SmedAction dia) {
    163 
    164                 dlg = dia;
    165                 setLayout(null);
    166                 mark = new SeaMark(dlg);
    167                 mark.setBounds(new Rectangle(235, 0, 165, 160));
    168                 add(mark);
    169                 panelChan = new PanelChan(dlg);
    170                 panelChan.setBounds(new Rectangle(65, 0, 170, 160));
    171                 panelChan.setVisible(false);
    172                 add(panelChan);
    173                 panelHaz = new PanelHaz(dlg);
    174                 panelHaz.setBounds(new Rectangle(65, 0, 170, 160));
    175                 panelHaz.setVisible(false);
    176                 add(panelHaz);
    177                 panelSpec = new PanelSpec(dlg);
    178                 panelSpec.setBounds(new Rectangle(65, 0, 170, 160));
    179                 panelSpec.setVisible(false);
    180                 add(panelSpec);
    181                 panelLights = new PanelLights(dlg);
    182                 panelLights.setBounds(new Rectangle(65, 0, 170, 160));
    183                 panelLights.setVisible(false);
    184                 add(panelLights);
    185                 panelMore = new PanelMore(dlg);
    186                 panelMore.setBounds(new Rectangle(40, 165, 360, 160));
    187                 panelMore.setVisible(false);
    188                 add(panelMore);
    189                 panelTop = new PanelTop(dlg);
    190                 panelTop.setBounds(new Rectangle(40, 165, 360, 160));
    191                 panelTop.setVisible(false);
    192                 add(panelTop);
    193                 panelFog = new PanelFog(dlg);
    194                 panelFog.setBounds(new Rectangle(40, 165, 360, 160));
    195                 panelFog.setVisible(false);
    196                 add(panelFog);
    197                 panelRadar = new PanelRadar(dlg);
    198                 panelRadar.setBounds(new Rectangle(40, 165, 360, 160));
    199                 panelRadar.setVisible(false);
    200                 add(panelRadar);
    201                 panelLit = new PanelLit(dlg);
    202                 panelLit.setBounds(new Rectangle(40, 165, 360, 160));
    203                 panelLit.setVisible(false);
    204                 add(panelLit);
    205 
    206                 add(getButton(chanButton, 0, 0, 62, 40, "Chan"), null);
    207                 add(getButton(hazButton, 0, 40, 62, 40, "Haz"), null);
    208                 add(getButton(specButton, 0, 80, 62, 40, "Spec"), null);
    209                 add(getButton(lightsButton, 0, 120, 62, 40, "Lights"), null);
    210                 typeButtons = new ButtonGroup();
    211                 typeButtons.add(chanButton);
    212                 typeButtons.add(hazButton);
    213                 typeButtons.add(specButton);
    214                 typeButtons.add(lightsButton);
    215                 chanButton.addActionListener(alType);
    216                 hazButton.addActionListener(alType);
    217                 specButton.addActionListener(alType);
    218                 lightsButton.addActionListener(alType);
    219 
    220                 add(getButton(topButton, 0, 185, 34, 32, "Topmarks"));
    221                 add(getButton(fogButton, 0, 220, 34, 32, "FogSignals"));
    222                 add(getButton(radButton, 0, 255, 34, 32, "Radar"));
    223                 add(getButton(litButton, 0, 290, 34, 32, "Lit"));
    224                 miscButtons = new ButtonGroup();
    225                 miscButtons.add(topButton);
    226                 miscButtons.add(fogButton);
    227                 miscButtons.add(radButton);
    228                 miscButtons.add(litButton);
    229                 topButton.addActionListener(alMisc);
    230                 fogButton.addActionListener(alMisc);
    231                 radButton.addActionListener(alMisc);
    232                 litButton.addActionListener(alMisc);
    233 
    234                 nameLabel = new JLabel();
    235                 nameLabel.setBounds(new Rectangle(5, 329, 60, 20));
    236                 nameLabel.setText(tr("Name:"));
    237                 add(nameLabel);
    238                 nameBox = new JTextField();
    239                 nameBox.setBounds(new Rectangle(60, 330, 200, 20));
    240                 nameBox.setHorizontalAlignment(SwingConstants.CENTER);
    241                 add(nameBox);
    242                 nameBox.addFocusListener(flName);
    243 
    244                 saveButton = new JButton();
    245                 saveButton.setBounds(new Rectangle(285, 330, 100, 20));
    246                 saveButton.setText(tr("Save"));
    247                 add(saveButton);
    248                 saveButton.addActionListener(alSave);
    249 
    250                 moreButton = new JButton();
    251                 moreButton.setBounds(new Rectangle(0, 165, 34, 15));
    252                 moreButton.setMargin(new Insets(0, 0, 0, 0));
    253                 moreButton.setText(">>");
    254                 add(moreButton);
    255                 moreButton.addActionListener(alMore);
    256 
    257             messageBar = new JTextField();
    258             messageBar.setBounds(10, 355, 380, 20);
    259             messageBar.setEditable(false);
    260             messageBar.setBackground(Color.WHITE);
    261             add(messageBar);
    262         }
    263 
    264         public void syncPanel() {
    265                 typeButtons.clearSelection();
    266                 chanButton.setBorderPainted(false);
    267                 chanButton.setEnabled(false);
    268                 hazButton.setBorderPainted(false);
    269                 hazButton.setEnabled(false);
    270                 specButton.setBorderPainted(false);
    271                 specButton.setEnabled(false);
    272                 lightsButton.setBorderPainted(false);
    273                 lightsButton.setEnabled(false);
    274                 miscButtons.clearSelection();
    275                 topButton.setEnabled(false);
    276                 topButton.setBorderPainted(false);
    277                 fogButton.setEnabled(false);
    278                 fogButton.setBorderPainted(false);
    279                 radButton.setEnabled(false);
    280                 radButton.setBorderPainted(false);
    281                 litButton.setEnabled(false);
    282                 litButton.setBorderPainted(false);
    283                 saveButton.setEnabled(false);
    284                 moreButton.setVisible(false);
    285                 moreButton.setText(">>");
    286                 moreButton.setSelected(false);
    287                 panelChan.setVisible(false);
    288                 panelHaz.setVisible(false);
    289                 panelSpec.setVisible(false);
    290                 panelLights.setVisible(false);
    291                 panelMore.setVisible(false);
    292                 panelTop.setVisible(false);
    293                 panelFog.setVisible(false);
    294                 panelRadar.setVisible(false);
    295                 panelLit.setVisible(false);
    296                 nameBox.setEnabled(false);
    297                 if (mark != null) {
    298                         nameBox.setEnabled(true);
    299                         chanButton.setEnabled(true);
    300                         hazButton.setEnabled(true);
    301                         specButton.setEnabled(true);
    302                         lightsButton.setEnabled(true);
    303                         nameBox.setText(mark.getName());
    304                         switch (SeaMark.GrpMAP.get(mark.getObject())) {
    305                         case LAT:
    306                         case SAW:
    307                                 chanButton.setBorderPainted(true);
    308                                 panelChan.setVisible(true);
    309                                 panelChan.syncPanel();
    310                                 break;
    311                         case CAR:
    312                         case ISD:
    313                                 hazButton.setBorderPainted(true);
    314                                 panelHaz.setVisible(true);
    315                                 panelHaz.syncPanel();
    316                                 break;
    317                         case SPP:
    318                                 specButton.setBorderPainted(true);
    319                                 panelSpec.setVisible(true);
    320                                 panelSpec.syncPanel();
    321                                 break;
    322                         case LGT:
    323                         case STN:
    324                         case PLF:
    325                                 lightsButton.setBorderPainted(true);
    326                                 panelLights.setVisible(true);
    327                                 panelLights.syncPanel();
    328                                 break;
    329                         }
    330                         panelMore.syncPanel();
    331                         panelTop.syncPanel();
    332                         panelFog.syncPanel();
    333                         panelRadar.syncPanel();
    334                         panelLit.syncPanel();
    335                 }
    336         }
    337 
    338         private JRadioButton getButton(JRadioButton button, int x, int y, int w, int h, String tip) {
    339                 button.setBounds(new Rectangle(x, y, w, h));
    340                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    341                 button.setToolTipText(Messages.getString(tip));
    342                 return button;
    343         }
     29    private SmedAction dlg;
     30    public SeaMark mark = null;
     31    public PanelChan panelChan = null;
     32    public PanelHaz panelHaz = null;
     33    public PanelSpec panelSpec = null;
     34    public PanelLights panelLights = null;
     35    public PanelMore panelMore = null;
     36    public PanelTop panelTop = null;
     37    public PanelFog panelFog = null;
     38    public PanelRadar panelRadar = null;
     39    public PanelLit panelLit = null;
     40    public JLabel nameLabel = null;
     41    public JTextField nameBox = null;
     42    public static JTextField messageBar = null;
     43    private FocusListener flName = new FocusListener() {
     44        @Override
     45        public void focusLost(FocusEvent e) {
     46            mark.setName(nameBox.getText());
     47        }
     48        @Override
     49        public void focusGained(FocusEvent e) {
     50        }
     51    };
     52    public JButton saveButton = null;
     53    private ActionListener alSave = new ActionListener() {
     54        @Override
     55        public void actionPerformed(ActionEvent e) {
     56            mark.saveSign(dlg.node);
     57        }
     58    };
     59    public JButton moreButton = null;
     60    private ActionListener alMore = new ActionListener() {
     61        @Override
     62        public void actionPerformed(ActionEvent e) {
     63            if (panelMore.isVisible()) {
     64                moreButton.setText(">>");
     65                panelMore.setVisible(false);
     66                topButton.setEnabled(true);
     67                radButton.setEnabled(true);
     68                fogButton.setEnabled(true);
     69                litButton.setEnabled(true);
     70            } else {
     71                panelMore.setVisible(true);
     72                moreButton.setText("<<");
     73                miscButtons.clearSelection();
     74                panelTop.setVisible(false);
     75                topButton.setBorderPainted(false);
     76                topButton.setEnabled(false);
     77                panelRadar.setVisible(false);
     78                radButton.setBorderPainted(false);
     79                radButton.setEnabled(false);
     80                panelFog.setVisible(false);
     81                fogButton.setBorderPainted(false);
     82                fogButton.setEnabled(false);
     83                panelLit.setVisible(false);
     84                litButton.setBorderPainted(false);
     85                litButton.setEnabled(false);
     86            }
     87        }
     88    };
     89    public ButtonGroup typeButtons = null;
     90    public JRadioButton chanButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ChanButton.png")));
     91    public JRadioButton hazButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/HazButton.png")));
     92    public JRadioButton specButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SpecButton.png")));
     93    public JRadioButton lightsButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightsButton.png")));
     94    private ActionListener alType = new ActionListener() {
     95        @Override
     96        public void actionPerformed(ActionEvent e) {
     97            if (chanButton.isSelected()) {
     98                chanButton.setBorderPainted(true);
     99                panelChan.syncPanel();
     100                panelChan.setVisible(true);
     101            } else {
     102                chanButton.setBorderPainted(false);
     103                panelChan.setVisible(false);
     104            }
     105            if (hazButton.isSelected()) {
     106                hazButton.setBorderPainted(true);
     107                panelHaz.syncPanel();
     108                panelHaz.setVisible(true);
     109            } else {
     110                hazButton.setBorderPainted(false);
     111                panelHaz.setVisible(false);
     112            }
     113            if (specButton.isSelected()) {
     114                specButton.setBorderPainted(true);
     115                panelSpec.syncPanel();
     116                panelSpec.setVisible(true);
     117            } else {
     118                specButton.setBorderPainted(false);
     119                panelSpec.setVisible(false);
     120            }
     121            if (lightsButton.isSelected()) {
     122                lightsButton.setBorderPainted(true);
     123                panelLights.syncPanel();
     124                panelLights.setVisible(true);
     125            } else {
     126                lightsButton.setBorderPainted(false);
     127                panelLights.setVisible(false);
     128            }
     129        }
     130    };
     131    private ButtonGroup miscButtons = null;
     132    public JRadioButton topButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TopButton.png")));
     133    public JRadioButton fogButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FogButton.png")));
     134    public JRadioButton radButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarButton.png")));
     135    public JRadioButton litButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LitButton.png")));
     136    private ActionListener alMisc = new ActionListener() {
     137        @Override
     138        public void actionPerformed(ActionEvent e) {
     139            if (topButton.isSelected()) {
     140                moreButton.setText(">>");
     141                panelMore.setVisible(false);
     142                topButton.setBorderPainted(true);
     143                panelTop.setVisible(true);
     144                panelTop.syncPanel();
     145            } else {
     146                topButton.setBorderPainted(false);
     147                panelTop.setVisible(false);
     148            }
     149            if (fogButton.isSelected()) {
     150                moreButton.setText(">>");
     151                panelMore.setVisible(false);
     152                fogButton.setBorderPainted(true);
     153                panelFog.setVisible(true);
     154                panelFog.syncPanel();
     155            } else {
     156                fogButton.setBorderPainted(false);
     157                panelFog.setVisible(false);
     158            }
     159            if (radButton.isSelected()) {
     160                moreButton.setText(">>");
     161                panelMore.setVisible(false);
     162                radButton.setBorderPainted(true);
     163                panelRadar.setVisible(true);
     164                panelRadar.syncPanel();
     165            } else {
     166                radButton.setBorderPainted(false);
     167                panelRadar.setVisible(false);
     168            }
     169            if (litButton.isSelected()) {
     170                moreButton.setText(">>");
     171                panelMore.setVisible(false);
     172                litButton.setBorderPainted(true);
     173                panelLit.setVisible(true);
     174                panelLit.syncPanel();
     175            } else {
     176                litButton.setBorderPainted(false);
     177                panelLit.setVisible(false);
     178            }
     179        }
     180    };
     181
     182    public PanelMain(SmedAction dia) {
     183
     184        dlg = dia;
     185        setLayout(null);
     186        mark = new SeaMark(dlg);
     187        mark.setBounds(new Rectangle(235, 0, 165, 160));
     188        add(mark);
     189        panelChan = new PanelChan(dlg);
     190        panelChan.setBounds(new Rectangle(65, 0, 170, 160));
     191        panelChan.setVisible(false);
     192        add(panelChan);
     193        panelHaz = new PanelHaz(dlg);
     194        panelHaz.setBounds(new Rectangle(65, 0, 170, 160));
     195        panelHaz.setVisible(false);
     196        add(panelHaz);
     197        panelSpec = new PanelSpec(dlg);
     198        panelSpec.setBounds(new Rectangle(65, 0, 170, 160));
     199        panelSpec.setVisible(false);
     200        add(panelSpec);
     201        panelLights = new PanelLights(dlg);
     202        panelLights.setBounds(new Rectangle(65, 0, 170, 160));
     203        panelLights.setVisible(false);
     204        add(panelLights);
     205        panelMore = new PanelMore(dlg);
     206        panelMore.setBounds(new Rectangle(40, 165, 360, 160));
     207        panelMore.setVisible(false);
     208        add(panelMore);
     209        panelTop = new PanelTop(dlg);
     210        panelTop.setBounds(new Rectangle(40, 165, 360, 160));
     211        panelTop.setVisible(false);
     212        add(panelTop);
     213        panelFog = new PanelFog(dlg);
     214        panelFog.setBounds(new Rectangle(40, 165, 360, 160));
     215        panelFog.setVisible(false);
     216        add(panelFog);
     217        panelRadar = new PanelRadar(dlg);
     218        panelRadar.setBounds(new Rectangle(40, 165, 360, 160));
     219        panelRadar.setVisible(false);
     220        add(panelRadar);
     221        panelLit = new PanelLit(dlg);
     222        panelLit.setBounds(new Rectangle(40, 165, 360, 160));
     223        panelLit.setVisible(false);
     224        add(panelLit);
     225
     226        add(getButton(chanButton, 0, 0, 62, 40, "Chan"), null);
     227        add(getButton(hazButton, 0, 40, 62, 40, "Haz"), null);
     228        add(getButton(specButton, 0, 80, 62, 40, "Spec"), null);
     229        add(getButton(lightsButton, 0, 120, 62, 40, "Lights"), null);
     230        typeButtons = new ButtonGroup();
     231        typeButtons.add(chanButton);
     232        typeButtons.add(hazButton);
     233        typeButtons.add(specButton);
     234        typeButtons.add(lightsButton);
     235        chanButton.addActionListener(alType);
     236        hazButton.addActionListener(alType);
     237        specButton.addActionListener(alType);
     238        lightsButton.addActionListener(alType);
     239
     240        add(getButton(topButton, 0, 185, 34, 32, "Topmarks"));
     241        add(getButton(fogButton, 0, 220, 34, 32, "FogSignals"));
     242        add(getButton(radButton, 0, 255, 34, 32, "Radar"));
     243        add(getButton(litButton, 0, 290, 34, 32, "Lit"));
     244        miscButtons = new ButtonGroup();
     245        miscButtons.add(topButton);
     246        miscButtons.add(fogButton);
     247        miscButtons.add(radButton);
     248        miscButtons.add(litButton);
     249        topButton.addActionListener(alMisc);
     250        fogButton.addActionListener(alMisc);
     251        radButton.addActionListener(alMisc);
     252        litButton.addActionListener(alMisc);
     253
     254        nameLabel = new JLabel();
     255        nameLabel.setBounds(new Rectangle(5, 329, 60, 20));
     256        nameLabel.setText(tr("Name:"));
     257        add(nameLabel);
     258        nameBox = new JTextField();
     259        nameBox.setBounds(new Rectangle(60, 330, 200, 20));
     260        nameBox.setHorizontalAlignment(SwingConstants.CENTER);
     261        add(nameBox);
     262        nameBox.addFocusListener(flName);
     263
     264        saveButton = new JButton();
     265        saveButton.setBounds(new Rectangle(285, 330, 100, 20));
     266        saveButton.setText(tr("Save"));
     267        add(saveButton);
     268        saveButton.addActionListener(alSave);
     269
     270        moreButton = new JButton();
     271        moreButton.setBounds(new Rectangle(0, 165, 34, 15));
     272        moreButton.setMargin(new Insets(0, 0, 0, 0));
     273        moreButton.setText(">>");
     274        add(moreButton);
     275        moreButton.addActionListener(alMore);
     276
     277        messageBar = new JTextField();
     278        messageBar.setBounds(10, 355, 380, 20);
     279        messageBar.setEditable(false);
     280        messageBar.setBackground(Color.WHITE);
     281        add(messageBar);
     282    }
     283
     284    public void syncPanel() {
     285        typeButtons.clearSelection();
     286        chanButton.setBorderPainted(false);
     287        chanButton.setEnabled(false);
     288        hazButton.setBorderPainted(false);
     289        hazButton.setEnabled(false);
     290        specButton.setBorderPainted(false);
     291        specButton.setEnabled(false);
     292        lightsButton.setBorderPainted(false);
     293        lightsButton.setEnabled(false);
     294        miscButtons.clearSelection();
     295        topButton.setEnabled(false);
     296        topButton.setBorderPainted(false);
     297        fogButton.setEnabled(false);
     298        fogButton.setBorderPainted(false);
     299        radButton.setEnabled(false);
     300        radButton.setBorderPainted(false);
     301        litButton.setEnabled(false);
     302        litButton.setBorderPainted(false);
     303        saveButton.setEnabled(false);
     304        moreButton.setVisible(false);
     305        moreButton.setText(">>");
     306        moreButton.setSelected(false);
     307        panelChan.setVisible(false);
     308        panelHaz.setVisible(false);
     309        panelSpec.setVisible(false);
     310        panelLights.setVisible(false);
     311        panelMore.setVisible(false);
     312        panelTop.setVisible(false);
     313        panelFog.setVisible(false);
     314        panelRadar.setVisible(false);
     315        panelLit.setVisible(false);
     316        nameBox.setEnabled(false);
     317        if (mark != null) {
     318            nameBox.setEnabled(true);
     319            chanButton.setEnabled(true);
     320            hazButton.setEnabled(true);
     321            specButton.setEnabled(true);
     322            lightsButton.setEnabled(true);
     323            nameBox.setText(mark.getName());
     324            switch (SeaMark.GrpMAP.get(mark.getObject())) {
     325            case LAT:
     326            case SAW:
     327                chanButton.setBorderPainted(true);
     328                panelChan.setVisible(true);
     329                panelChan.syncPanel();
     330                break;
     331            case CAR:
     332            case ISD:
     333                hazButton.setBorderPainted(true);
     334                panelHaz.setVisible(true);
     335                panelHaz.syncPanel();
     336                break;
     337            case SPP:
     338                specButton.setBorderPainted(true);
     339                panelSpec.setVisible(true);
     340                panelSpec.syncPanel();
     341                break;
     342            case LGT:
     343            case STN:
     344            case PLF:
     345                lightsButton.setBorderPainted(true);
     346                panelLights.setVisible(true);
     347                panelLights.syncPanel();
     348                break;
     349            }
     350            panelMore.syncPanel();
     351            panelTop.syncPanel();
     352            panelFog.syncPanel();
     353            panelRadar.syncPanel();
     354            panelLit.syncPanel();
     355        }
     356    }
     357
     358    private JRadioButton getButton(JRadioButton button, int x, int y, int w, int h, String tip) {
     359        button.setBounds(new Rectangle(x, y, w, h));
     360        button.setBorder(BorderFactory.createLoweredBevelBorder());
     361        button.setToolTipText(Messages.getString(tip));
     362        return button;
     363    }
    344364
    345365}
  • applications/editors/josm/plugins/smed/src/panels/PanelMore.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.*;
    4 import java.awt.event.*;
    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.Cns;
     23import seamarks.SeaMark.Col;
     24import seamarks.SeaMark.Con;
     25import seamarks.SeaMark.Ent;
     26import seamarks.SeaMark.Pat;
     27import seamarks.SeaMark.Reg;
     28import seamarks.SeaMark.Sts;
    1129import smed.SmedAction;
    12 import seamarks.SeaMark.*;
    1330
    1431public class PanelMore extends JPanel {
    1532
    16         private SmedAction dlg;
    17         public JLabel infoLabel;
    18         public JTextField infoBox;
    19         private FocusListener flInfo = new FocusAdapter() {
    20                 public void focusLost(java.awt.event.FocusEvent e) {
    21                         SmedAction.panelMain.mark.setInfo(infoBox.getText());
    22                 }
    23         };
    24         public JLabel sourceLabel;
    25         public JTextField sourceBox;
    26         private FocusListener flSource = new FocusAdapter() {
    27                 public void focusLost(java.awt.event.FocusEvent e) {
    28                         SmedAction.panelMain.mark.setSource(sourceBox.getText());
    29                 }
    30         };
    31         public JLabel elevLabel;
    32         public JTextField elevBox;
    33         private FocusListener flElev = new FocusAdapter() {
    34                 public void focusLost(java.awt.event.FocusEvent e) {
    35                         SmedAction.panelMain.mark.setElevation(elevBox.getText());
    36                 }
    37         };
    38         public JLabel heightLabel;
    39         public JTextField heightBox;
    40         private FocusListener flHeight = new FocusAdapter() {
    41                 public void focusLost(java.awt.event.FocusEvent e) {
    42                         SmedAction.panelMain.mark.setObjectHeight(heightBox.getText());
    43                 }
    44         };
    45         public JLabel statusLabel;
    46         public JComboBox<String> statusBox;
    47         public EnumMap<Sts, Integer> statuses = new EnumMap<>(Sts.class);
    48         private ActionListener alStatus = new ActionListener() {
    49                 public void actionPerformed(java.awt.event.ActionEvent e) {
    50                         for (Sts sts : statuses.keySet()) {
    51                                 int idx = statuses.get(sts);
    52                                 if (SmedAction.panelMain.mark != null && (idx == statusBox.getSelectedIndex()))
    53                                         SmedAction.panelMain.mark.setStatus(sts);
    54                         }
    55                 }
    56         };
    57         public JLabel constrLabel;
    58         public JComboBox<String> constrBox;
    59         public EnumMap<Cns, Integer> constructions = new EnumMap<>(Cns.class);
    60         private ActionListener alConstr = new ActionListener() {
    61                 public void actionPerformed(java.awt.event.ActionEvent e) {
    62                         for (Cns cns : constructions.keySet()) {
    63                                 int idx = constructions.get(cns);
    64                                 if (SmedAction.panelMain.mark != null && (idx == constrBox.getSelectedIndex()))
    65                                         SmedAction.panelMain.mark.setConstr(cns);
    66                         }
    67                 }
    68         };
    69         public JLabel conLabel;
    70         public JComboBox<String> conBox;
    71         public EnumMap<Con, Integer> conspicuities = new EnumMap<>(Con.class);
    72         private ActionListener alCon = new ActionListener() {
    73                 public void actionPerformed(java.awt.event.ActionEvent e) {
    74                         for (Con con : conspicuities.keySet()) {
    75                                 int idx = conspicuities.get(con);
    76                                 if (SmedAction.panelMain.mark != null && (idx == conBox.getSelectedIndex()))
    77                                         SmedAction.panelMain.mark.setConsp(con);
    78                         }
    79                 }
    80         };
    81         public JLabel reflLabel;
    82         public JComboBox<String> reflBox;
    83         public EnumMap<Con, Integer> reflectivities = new EnumMap<>(Con.class);
    84         private ActionListener alRefl = new ActionListener() {
    85                 public void actionPerformed(java.awt.event.ActionEvent e) {
    86                         for (Con con : reflectivities.keySet()) {
    87                                 int idx = reflectivities.get(con);
    88                                 if (SmedAction.panelMain.mark != null && (idx == reflBox.getSelectedIndex()))
    89                                         SmedAction.panelMain.mark.setRefl(con);
    90                         }
    91                 }
    92         };
    93         public PanelPat panelPat;
    94         private ButtonGroup regionButtons = new ButtonGroup();
    95         public JRadioButton regionAButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionAButton.png")));
    96         public JRadioButton regionBButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionBButton.png")));
    97         public JRadioButton regionCButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionCButton.png")));
    98         private ActionListener alRegion = new ActionListener() {
    99                 public void actionPerformed(java.awt.event.ActionEvent e) {
    100                         if (regionAButton.isSelected()) {
    101                                 SmedAction.panelMain.mark.setRegion(Reg.A);
    102                                 switch (dlg.panelMain.mark.getCategory()) {
    103                                 case LAM_PORT:
    104                                         dlg.panelMain.mark.setObjColour(Col.RED);
    105                                         dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
    106                                         break;
    107                                 case LAM_PPORT:
    108                                         dlg.panelMain.mark.setObjColour(Col.RED);
    109                                         dlg.panelMain.mark.addObjColour(Col.GREEN);
    110                                         dlg.panelMain.mark.addObjColour(Col.RED);
    111                                         dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
    112                                         break;
    113                                 case LAM_STBD:
    114                                         dlg.panelMain.mark.setObjColour(Col.GREEN);
    115                                         dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
    116                                         break;
    117                                 case LAM_PSTBD:
    118                                         dlg.panelMain.mark.setObjColour(Col.GREEN);
    119                                         dlg.panelMain.mark.addObjColour(Col.RED);
    120                                         dlg.panelMain.mark.addObjColour(Col.GREEN);
    121                                         dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
    122                                         break;
    123                                 }
    124                                 regionAButton.setBorderPainted(true);
    125                         } else {
    126                                 regionAButton.setBorderPainted(false);
    127                         }
    128                         if (regionBButton.isSelected()) {
    129                                 dlg.panelMain.mark.setRegion(Reg.B);
    130                                 switch (dlg.panelMain.mark.getCategory()) {
    131                                 case LAM_PORT:
    132                                         dlg.panelMain.mark.setObjColour(Col.GREEN);
    133                                         dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
    134                                         break;
    135                                 case LAM_PPORT:
    136                                         dlg.panelMain.mark.setObjColour(Col.GREEN);
    137                                         dlg.panelMain.mark.addObjColour(Col.RED);
    138                                         dlg.panelMain.mark.addObjColour(Col.GREEN);
    139                                         dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
    140                                         break;
    141                                 case LAM_STBD:
    142                                         dlg.panelMain.mark.setObjColour(Col.RED);
    143                                         dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
    144                                         break;
    145                                 case LAM_PSTBD:
    146                                         dlg.panelMain.mark.setObjColour(Col.RED);
    147                                         dlg.panelMain.mark.addObjColour(Col.GREEN);
    148                                         dlg.panelMain.mark.addObjColour(Col.RED);
    149                                         dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
    150                                         break;
    151                                 }
    152                                 regionBButton.setBorderPainted(true);
    153                         } else {
    154                                 regionBButton.setBorderPainted(false);
    155                         }
    156                         if (regionCButton.isSelected()) {
    157                                 dlg.panelMain.mark.setRegion(Reg.C);
    158                                 dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
    159                                 switch (dlg.panelMain.mark.getCategory()) {
    160                                 case LAM_PORT:
    161                                         dlg.panelMain.mark.setObjColour(Col.RED);
    162                                         dlg.panelMain.mark.addObjColour(Col.WHITE);
    163                                         dlg.panelMain.mark.addObjColour(Col.RED);
    164                                         dlg.panelMain.mark.addObjColour(Col.WHITE);
    165                                         break;
    166                                 case LAM_PPORT:
    167                                 case LAM_PSTBD:
    168                                         dlg.panelMain.mark.setObjColour(Col.RED);
    169                                         dlg.panelMain.mark.addObjColour(Col.GREEN);
    170                                         dlg.panelMain.mark.addObjColour(Col.RED);
    171                                         dlg.panelMain.mark.addObjColour(Col.GREEN);
    172                                         break;
    173                                 case LAM_STBD:
    174                                         dlg.panelMain.mark.setObjColour(Col.GREEN);
    175                                         dlg.panelMain.mark.addObjColour(Col.WHITE);
    176                                         dlg.panelMain.mark.addObjColour(Col.GREEN);
    177                                         dlg.panelMain.mark.addObjColour(Col.WHITE);
    178                                         break;
    179                                 }
    180                                 regionCButton.setBorderPainted(true);
    181                         } else {
    182                                 regionCButton.setBorderPainted(false);
    183                         }
    184                         panelPat.syncPanel();
    185                 }
    186         };
    187 
    188         public PanelMore(SmedAction dia) {
    189                 dlg = dia;
    190                 setLayout(null);
    191                 panelPat = new PanelPat(dlg, Ent.BODY);
    192                 panelPat.setBounds(new Rectangle(0, 0, 110, 160));
    193                 add(panelPat);
    194                 add(getRegionButton(regionAButton, 110, 0, 34, 30, "RegionA"));
    195                 add(getRegionButton(regionBButton, 110, 32, 34, 30, "RegionB"));
    196                 add(getRegionButton(regionCButton, 110, 64, 34, 30, "RegionC"));
    197 
    198                 elevLabel = new JLabel(Messages.getString("Elevation"), SwingConstants.CENTER);
    199                 elevLabel.setBounds(new Rectangle(140, 0, 90, 20));
    200                 add(elevLabel);
    201                 elevBox = new JTextField();
    202                 elevBox.setBounds(new Rectangle(160, 20, 50, 20));
    203                 elevBox.setHorizontalAlignment(SwingConstants.CENTER);
    204                 add(elevBox);
    205                 elevBox.addFocusListener(flElev);
    206 
    207                 heightLabel = new JLabel(Messages.getString("Height"), SwingConstants.CENTER);
    208                 heightLabel.setBounds(new Rectangle(140, 40, 90, 20));
    209                 add(heightLabel);
    210                 heightBox = new JTextField();
    211                 heightBox.setBounds(new Rectangle(160, 60, 50, 20));
    212                 heightBox.setHorizontalAlignment(SwingConstants.CENTER);
    213                 add(heightBox);
    214                 heightBox.addFocusListener(flHeight);
    215 
    216                 sourceLabel = new JLabel(Messages.getString("Source"), SwingConstants.CENTER);
    217                 sourceLabel.setBounds(new Rectangle(110, 80, 130, 20));
    218                 add(sourceLabel);
    219                 sourceBox = new JTextField();
    220                 sourceBox.setBounds(new Rectangle(110, 100, 130, 20));
    221                 sourceBox.setHorizontalAlignment(SwingConstants.CENTER);
    222                 add(sourceBox);
    223                 sourceBox.addFocusListener(flSource);
    224 
    225                 infoLabel = new JLabel(Messages.getString("Information"), SwingConstants.CENTER);
    226                 infoLabel.setBounds(new Rectangle(110, 120, 130, 20));
    227                 add(infoLabel);
    228                 infoBox = new JTextField();
    229                 infoBox.setBounds(new Rectangle(110, 140, 130, 20));
    230                 infoBox.setHorizontalAlignment(SwingConstants.CENTER);
    231                 add(infoBox);
    232                 infoBox.addFocusListener(flInfo);
    233 
    234                 statusLabel = new JLabel(Messages.getString("Status"), SwingConstants.CENTER);
    235                 statusLabel.setBounds(new Rectangle(250, 0, 100, 20));
    236                 add(statusLabel);
    237                 statusBox = new JComboBox<>();
    238                 statusBox.setBounds(new Rectangle(250, 20, 100, 20));
    239                 addStsItem("", Sts.UNKSTS);
    240                 addStsItem(Messages.getString("Permanent"), Sts.PERM);
    241                 addStsItem(Messages.getString("Occasional"), Sts.OCC);
    242                 addStsItem(Messages.getString("Recommended"), Sts.REC);
    243                 addStsItem(Messages.getString("NotInUse"), Sts.NIU);
    244                 addStsItem(Messages.getString("Intermittent"), Sts.INT);
    245                 addStsItem(Messages.getString("Reserved"), Sts.RESV);
    246                 addStsItem(Messages.getString("Temporary"), Sts.TEMP);
    247                 addStsItem(Messages.getString("Private"), Sts.PRIV);
    248                 addStsItem(Messages.getString("Mandatory"), Sts.MAND);
    249                 addStsItem(Messages.getString("Destroyed"), Sts.DEST);
    250                 addStsItem(Messages.getString("Extinguished"), Sts.EXT);
    251                 addStsItem(Messages.getString("Illuminated"), Sts.ILLUM);
    252                 addStsItem(Messages.getString("Historic"), Sts.HIST);
    253                 addStsItem(Messages.getString("Public"), Sts.PUB);
    254                 addStsItem(Messages.getString("Synchronized"), Sts.SYNC);
    255                 addStsItem(Messages.getString("Watched"), Sts.WATCH);
    256                 addStsItem(Messages.getString("UnWatched"), Sts.UNWAT);
    257                 addStsItem(Messages.getString("Doubtful"), Sts.DOUBT);
    258                 add(statusBox);
    259                 statusBox.addActionListener(alStatus);
    260 
    261                 constrLabel = new JLabel(Messages.getString("Construction"), SwingConstants.CENTER);
    262                 constrLabel.setBounds(new Rectangle(250, 40, 100, 20));
    263                 add(constrLabel);
    264                 constrBox = new JComboBox<>();
    265                 constrBox.setBounds(new Rectangle(250, 60, 100, 20));
    266                 addCnsItem("", Cns.UNKCNS);
    267                 addCnsItem(Messages.getString("Masonry"), Cns.BRICK);
    268                 addCnsItem(Messages.getString("Concreted"), Cns.CONC);
    269                 addCnsItem(Messages.getString("Boulders"), Cns.BOULD);
    270                 addCnsItem(Messages.getString("HardSurfaced"), Cns.HSURF);
    271                 addCnsItem(Messages.getString("Unsurfaced"), Cns.USURF);
    272                 addCnsItem(Messages.getString("Wooden"), Cns.WOOD);
    273                 addCnsItem(Messages.getString("Metal"), Cns.METAL);
    274                 addCnsItem(Messages.getString("GRP"), Cns.GLAS);
    275                 addCnsItem(Messages.getString("Painted"), Cns.PAINT);
    276                 add(constrBox);
    277                 constrBox.addActionListener(alConstr);
    278 
    279                 conLabel = new JLabel(Messages.getString("Conspicuity"), SwingConstants.CENTER);
    280                 conLabel.setBounds(new Rectangle(250, 80, 100, 20));
    281                 add(conLabel);
    282                 conBox = new JComboBox<>();
    283                 conBox.setBounds(new Rectangle(250, 100, 100, 20));
    284                 addConItem("", Con.UNKCON);
    285                 addConItem(Messages.getString("Conspicuous"), Con.CONSP);
    286                 addConItem(Messages.getString("NotConspicuous"), Con.NCONS);
    287                 add(conBox);
    288                 conBox.addActionListener(alCon);
    289 
    290                 reflLabel = new JLabel(Messages.getString("Reflectivity"), SwingConstants.CENTER);
    291                 reflLabel.setBounds(new Rectangle(250, 120, 100, 20));
    292                 add(reflLabel);
    293                 reflBox = new JComboBox<>();
    294                 reflBox.setBounds(new Rectangle(250, 140, 100, 20));
    295                 addReflItem("", Con.UNKCON);
    296                 addReflItem(Messages.getString("Conspicuous"), Con.CONSP);
    297                 addReflItem(Messages.getString("NotConspicuous"), Con.NCONS);
    298                 addReflItem(Messages.getString("Reflector"), Con.REFL);
    299                 add(reflBox);
    300                 reflBox.addActionListener(alRefl);
    301 
    302         }
    303 
    304         public void syncPanel() {
    305                 panelPat.syncPanel();
    306                 regionAButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.A);
    307                 regionBButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.B);
    308                 regionCButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.C);
    309                 elevBox.setText(dlg.panelMain.mark.getElevation());
    310                 heightBox.setText(dlg.panelMain.mark.getObjectHeight());
    311                 sourceBox.setText(dlg.panelMain.mark.getSource());
    312                 infoBox.setText(dlg.panelMain.mark.getInfo());
    313                 for (Sts sts : statuses.keySet()) {
    314                         int item = statuses.get(sts);
    315                         if (dlg.panelMain.mark.getStatus() == sts)
    316                                 statusBox.setSelectedIndex(item);
    317                 }
    318                 for (Cns cns : constructions.keySet()) {
    319                         int item = constructions.get(cns);
    320                         if (dlg.panelMain.mark.getConstr() == cns)
    321                                 constrBox.setSelectedIndex(item);
    322                 }
    323                 for (Con con : conspicuities.keySet()) {
    324                         int item = conspicuities.get(con);
    325                         if (dlg.panelMain.mark.getConsp() == con)
    326                                 conBox.setSelectedIndex(item);
    327                 }
    328                 for (Con con : reflectivities.keySet()) {
    329                         int item = reflectivities.get(con);
    330                         if (dlg.panelMain.mark.getRefl() == con)
    331                                 reflBox.setSelectedIndex(item);
    332                 }
    333         }
    334 
    335         private void addStsItem(String str, Sts sts) {
    336                 statuses.put(sts, statusBox.getItemCount());
    337                 statusBox.addItem(str);
    338         }
    339 
    340         private void addCnsItem(String str, Cns cns) {
    341                 constructions.put(cns, constrBox.getItemCount());
    342                 constrBox.addItem(str);
    343         }
    344 
    345         private void addConItem(String str, Con con) {
    346                 conspicuities.put(con, conBox.getItemCount());
    347                 conBox.addItem(str);
    348         }
    349 
    350         private void addReflItem(String str, Con con) {
    351                 reflectivities.put(con, reflBox.getItemCount());
    352                 reflBox.addItem(str);
    353         }
    354 
    355         private JRadioButton getRegionButton(JRadioButton button, int x, int y, int w, int h, String tip) {
    356                 button.setBounds(new Rectangle(x, y, w, h));
    357                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    358                 button.setToolTipText(Messages.getString(tip));
    359                 button.addActionListener(alRegion);
    360                 regionButtons.add(button);
    361                 return button;
    362         }
     33    private SmedAction dlg;
     34    public JLabel infoLabel;
     35    public JTextField infoBox;
     36    private FocusListener flInfo = new FocusAdapter() {
     37        @Override
     38        public void focusLost(FocusEvent e) {
     39            SmedAction.panelMain.mark.setInfo(infoBox.getText());
     40        }
     41    };
     42    public JLabel sourceLabel;
     43    public JTextField sourceBox;
     44    private FocusListener flSource = new FocusAdapter() {
     45        @Override
     46        public void focusLost(FocusEvent e) {
     47            SmedAction.panelMain.mark.setSource(sourceBox.getText());
     48        }
     49    };
     50    public JLabel elevLabel;
     51    public JTextField elevBox;
     52    private FocusListener flElev = new FocusAdapter() {
     53        @Override
     54        public void focusLost(FocusEvent e) {
     55            SmedAction.panelMain.mark.setElevation(elevBox.getText());
     56        }
     57    };
     58    public JLabel heightLabel;
     59    public JTextField heightBox;
     60    private FocusListener flHeight = new FocusAdapter() {
     61        @Override
     62        public void focusLost(FocusEvent e) {
     63            SmedAction.panelMain.mark.setObjectHeight(heightBox.getText());
     64        }
     65    };
     66    public JLabel statusLabel;
     67    public JComboBox<String> statusBox;
     68    public EnumMap<Sts, Integer> statuses = new EnumMap<>(Sts.class);
     69    private ActionListener alStatus = new ActionListener() {
     70        @Override
     71        public void actionPerformed(ActionEvent e) {
     72            for (Sts sts : statuses.keySet()) {
     73                int idx = statuses.get(sts);
     74                if (SmedAction.panelMain.mark != null && (idx == statusBox.getSelectedIndex())) {
     75                    SmedAction.panelMain.mark.setStatus(sts);
     76                }
     77            }
     78        }
     79    };
     80    public JLabel constrLabel;
     81    public JComboBox<String> constrBox;
     82    public EnumMap<Cns, Integer> constructions = new EnumMap<>(Cns.class);
     83    private ActionListener alConstr = new ActionListener() {
     84        @Override
     85        public void actionPerformed(ActionEvent e) {
     86            for (Cns cns : constructions.keySet()) {
     87                int idx = constructions.get(cns);
     88                if (SmedAction.panelMain.mark != null && (idx == constrBox.getSelectedIndex())) {
     89                    SmedAction.panelMain.mark.setConstr(cns);
     90                }
     91            }
     92        }
     93    };
     94    public JLabel conLabel;
     95    public JComboBox<String> conBox;
     96    public EnumMap<Con, Integer> conspicuities = new EnumMap<>(Con.class);
     97    private ActionListener alCon = new ActionListener() {
     98        @Override
     99        public void actionPerformed(ActionEvent e) {
     100            for (Con con : conspicuities.keySet()) {
     101                int idx = conspicuities.get(con);
     102                if (SmedAction.panelMain.mark != null && (idx == conBox.getSelectedIndex())) {
     103                    SmedAction.panelMain.mark.setConsp(con);
     104                }
     105            }
     106        }
     107    };
     108    public JLabel reflLabel;
     109    public JComboBox<String> reflBox;
     110    public EnumMap<Con, Integer> reflectivities = new EnumMap<>(Con.class);
     111    private ActionListener alRefl = new ActionListener() {
     112        @Override
     113        public void actionPerformed(ActionEvent e) {
     114            for (Con con : reflectivities.keySet()) {
     115                int idx = reflectivities.get(con);
     116                if (SmedAction.panelMain.mark != null && (idx == reflBox.getSelectedIndex())) {
     117                    SmedAction.panelMain.mark.setRefl(con);
     118                }
     119            }
     120        }
     121    };
     122    public PanelPat panelPat;
     123    private ButtonGroup regionButtons = new ButtonGroup();
     124    public JRadioButton regionAButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionAButton.png")));
     125    public JRadioButton regionBButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionBButton.png")));
     126    public JRadioButton regionCButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionCButton.png")));
     127    private ActionListener alRegion = new ActionListener() {
     128        @Override
     129        public void actionPerformed(ActionEvent e) {
     130            if (regionAButton.isSelected()) {
     131                SmedAction.panelMain.mark.setRegion(Reg.A);
     132                switch (dlg.panelMain.mark.getCategory()) {
     133                case LAM_PORT:
     134                    dlg.panelMain.mark.setObjColour(Col.RED);
     135                    dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
     136                    break;
     137                case LAM_PPORT:
     138                    dlg.panelMain.mark.setObjColour(Col.RED);
     139                    dlg.panelMain.mark.addObjColour(Col.GREEN);
     140                    dlg.panelMain.mark.addObjColour(Col.RED);
     141                    dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
     142                    break;
     143                case LAM_STBD:
     144                    dlg.panelMain.mark.setObjColour(Col.GREEN);
     145                    dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
     146                    break;
     147                case LAM_PSTBD:
     148                    dlg.panelMain.mark.setObjColour(Col.GREEN);
     149                    dlg.panelMain.mark.addObjColour(Col.RED);
     150                    dlg.panelMain.mark.addObjColour(Col.GREEN);
     151                    dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
     152                    break;
     153                }
     154                regionAButton.setBorderPainted(true);
     155            } else {
     156                regionAButton.setBorderPainted(false);
     157            }
     158            if (regionBButton.isSelected()) {
     159                dlg.panelMain.mark.setRegion(Reg.B);
     160                switch (dlg.panelMain.mark.getCategory()) {
     161                case LAM_PORT:
     162                    dlg.panelMain.mark.setObjColour(Col.GREEN);
     163                    dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
     164                    break;
     165                case LAM_PPORT:
     166                    dlg.panelMain.mark.setObjColour(Col.GREEN);
     167                    dlg.panelMain.mark.addObjColour(Col.RED);
     168                    dlg.panelMain.mark.addObjColour(Col.GREEN);
     169                    dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
     170                    break;
     171                case LAM_STBD:
     172                    dlg.panelMain.mark.setObjColour(Col.RED);
     173                    dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
     174                    break;
     175                case LAM_PSTBD:
     176                    dlg.panelMain.mark.setObjColour(Col.RED);
     177                    dlg.panelMain.mark.addObjColour(Col.GREEN);
     178                    dlg.panelMain.mark.addObjColour(Col.RED);
     179                    dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
     180                    break;
     181                }
     182                regionBButton.setBorderPainted(true);
     183            } else {
     184                regionBButton.setBorderPainted(false);
     185            }
     186            if (regionCButton.isSelected()) {
     187                dlg.panelMain.mark.setRegion(Reg.C);
     188                dlg.panelMain.mark.setObjPattern(Pat.HSTRP);
     189                switch (dlg.panelMain.mark.getCategory()) {
     190                case LAM_PORT:
     191                    dlg.panelMain.mark.setObjColour(Col.RED);
     192                    dlg.panelMain.mark.addObjColour(Col.WHITE);
     193                    dlg.panelMain.mark.addObjColour(Col.RED);
     194                    dlg.panelMain.mark.addObjColour(Col.WHITE);
     195                    break;
     196                case LAM_PPORT:
     197                case LAM_PSTBD:
     198                    dlg.panelMain.mark.setObjColour(Col.RED);
     199                    dlg.panelMain.mark.addObjColour(Col.GREEN);
     200                    dlg.panelMain.mark.addObjColour(Col.RED);
     201                    dlg.panelMain.mark.addObjColour(Col.GREEN);
     202                    break;
     203                case LAM_STBD:
     204                    dlg.panelMain.mark.setObjColour(Col.GREEN);
     205                    dlg.panelMain.mark.addObjColour(Col.WHITE);
     206                    dlg.panelMain.mark.addObjColour(Col.GREEN);
     207                    dlg.panelMain.mark.addObjColour(Col.WHITE);
     208                    break;
     209                }
     210                regionCButton.setBorderPainted(true);
     211            } else {
     212                regionCButton.setBorderPainted(false);
     213            }
     214            panelPat.syncPanel();
     215        }
     216    };
     217
     218    public PanelMore(SmedAction dia) {
     219        dlg = dia;
     220        setLayout(null);
     221        panelPat = new PanelPat(dlg, Ent.BODY);
     222        panelPat.setBounds(new Rectangle(0, 0, 110, 160));
     223        add(panelPat);
     224        add(getRegionButton(regionAButton, 110, 0, 34, 30, "RegionA"));
     225        add(getRegionButton(regionBButton, 110, 32, 34, 30, "RegionB"));
     226        add(getRegionButton(regionCButton, 110, 64, 34, 30, "RegionC"));
     227
     228        elevLabel = new JLabel(Messages.getString("Elevation"), SwingConstants.CENTER);
     229        elevLabel.setBounds(new Rectangle(140, 0, 90, 20));
     230        add(elevLabel);
     231        elevBox = new JTextField();
     232        elevBox.setBounds(new Rectangle(160, 20, 50, 20));
     233        elevBox.setHorizontalAlignment(SwingConstants.CENTER);
     234        add(elevBox);
     235        elevBox.addFocusListener(flElev);
     236
     237        heightLabel = new JLabel(Messages.getString("Height"), SwingConstants.CENTER);
     238        heightLabel.setBounds(new Rectangle(140, 40, 90, 20));
     239        add(heightLabel);
     240        heightBox = new JTextField();
     241        heightBox.setBounds(new Rectangle(160, 60, 50, 20));
     242        heightBox.setHorizontalAlignment(SwingConstants.CENTER);
     243        add(heightBox);
     244        heightBox.addFocusListener(flHeight);
     245
     246        sourceLabel = new JLabel(Messages.getString("Source"), SwingConstants.CENTER);
     247        sourceLabel.setBounds(new Rectangle(110, 80, 130, 20));
     248        add(sourceLabel);
     249        sourceBox = new JTextField();
     250        sourceBox.setBounds(new Rectangle(110, 100, 130, 20));
     251        sourceBox.setHorizontalAlignment(SwingConstants.CENTER);
     252        add(sourceBox);
     253        sourceBox.addFocusListener(flSource);
     254
     255        infoLabel = new JLabel(Messages.getString("Information"), SwingConstants.CENTER);
     256        infoLabel.setBounds(new Rectangle(110, 120, 130, 20));
     257        add(infoLabel);
     258        infoBox = new JTextField();
     259        infoBox.setBounds(new Rectangle(110, 140, 130, 20));
     260        infoBox.setHorizontalAlignment(SwingConstants.CENTER);
     261        add(infoBox);
     262        infoBox.addFocusListener(flInfo);
     263
     264        statusLabel = new JLabel(Messages.getString("Status"), SwingConstants.CENTER);
     265        statusLabel.setBounds(new Rectangle(250, 0, 100, 20));
     266        add(statusLabel);
     267        statusBox = new JComboBox<>();
     268        statusBox.setBounds(new Rectangle(250, 20, 100, 20));
     269        addStsItem("", Sts.UNKSTS);
     270        addStsItem(Messages.getString("Permanent"), Sts.PERM);
     271        addStsItem(Messages.getString("Occasional"), Sts.OCC);
     272        addStsItem(Messages.getString("Recommended"), Sts.REC);
     273        addStsItem(Messages.getString("NotInUse"), Sts.NIU);
     274        addStsItem(Messages.getString("Intermittent"), Sts.INT);
     275        addStsItem(Messages.getString("Reserved"), Sts.RESV);
     276        addStsItem(Messages.getString("Temporary"), Sts.TEMP);
     277        addStsItem(Messages.getString("Private"), Sts.PRIV);
     278        addStsItem(Messages.getString("Mandatory"), Sts.MAND);
     279        addStsItem(Messages.getString("Destroyed"), Sts.DEST);
     280        addStsItem(Messages.getString("Extinguished"), Sts.EXT);
     281        addStsItem(Messages.getString("Illuminated"), Sts.ILLUM);
     282        addStsItem(Messages.getString("Historic"), Sts.HIST);
     283        addStsItem(Messages.getString("Public"), Sts.PUB);
     284        addStsItem(Messages.getString("Synchronized"), Sts.SYNC);
     285        addStsItem(Messages.getString("Watched"), Sts.WATCH);
     286        addStsItem(Messages.getString("UnWatched"), Sts.UNWAT);
     287        addStsItem(Messages.getString("Doubtful"), Sts.DOUBT);
     288        add(statusBox);
     289        statusBox.addActionListener(alStatus);
     290
     291        constrLabel = new JLabel(Messages.getString("Construction"), SwingConstants.CENTER);
     292        constrLabel.setBounds(new Rectangle(250, 40, 100, 20));
     293        add(constrLabel);
     294        constrBox = new JComboBox<>();
     295        constrBox.setBounds(new Rectangle(250, 60, 100, 20));
     296        addCnsItem("", Cns.UNKCNS);
     297        addCnsItem(Messages.getString("Masonry"), Cns.BRICK);
     298        addCnsItem(Messages.getString("Concreted"), Cns.CONC);
     299        addCnsItem(Messages.getString("Boulders"), Cns.BOULD);
     300        addCnsItem(Messages.getString("HardSurfaced"), Cns.HSURF);
     301        addCnsItem(Messages.getString("Unsurfaced"), Cns.USURF);
     302        addCnsItem(Messages.getString("Wooden"), Cns.WOOD);
     303        addCnsItem(Messages.getString("Metal"), Cns.METAL);
     304        addCnsItem(Messages.getString("GRP"), Cns.GLAS);
     305        addCnsItem(Messages.getString("Painted"), Cns.PAINT);
     306        add(constrBox);
     307        constrBox.addActionListener(alConstr);
     308
     309        conLabel = new JLabel(Messages.getString("Conspicuity"), SwingConstants.CENTER);
     310        conLabel.setBounds(new Rectangle(250, 80, 100, 20));
     311        add(conLabel);
     312        conBox = new JComboBox<>();
     313        conBox.setBounds(new Rectangle(250, 100, 100, 20));
     314        addConItem("", Con.UNKCON);
     315        addConItem(Messages.getString("Conspicuous"), Con.CONSP);
     316        addConItem(Messages.getString("NotConspicuous"), Con.NCONS);
     317        add(conBox);
     318        conBox.addActionListener(alCon);
     319
     320        reflLabel = new JLabel(Messages.getString("Reflectivity"), SwingConstants.CENTER);
     321        reflLabel.setBounds(new Rectangle(250, 120, 100, 20));
     322        add(reflLabel);
     323        reflBox = new JComboBox<>();
     324        reflBox.setBounds(new Rectangle(250, 140, 100, 20));
     325        addReflItem("", Con.UNKCON);
     326        addReflItem(Messages.getString("Conspicuous"), Con.CONSP);
     327        addReflItem(Messages.getString("NotConspicuous"), Con.NCONS);
     328        addReflItem(Messages.getString("Reflector"), Con.REFL);
     329        add(reflBox);
     330        reflBox.addActionListener(alRefl);
     331
     332    }
     333
     334    public void syncPanel() {
     335        panelPat.syncPanel();
     336        regionAButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.A);
     337        regionBButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.B);
     338        regionCButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.C);
     339        elevBox.setText(dlg.panelMain.mark.getElevation());
     340        heightBox.setText(dlg.panelMain.mark.getObjectHeight());
     341        sourceBox.setText(dlg.panelMain.mark.getSource());
     342        infoBox.setText(dlg.panelMain.mark.getInfo());
     343        for (Sts sts : statuses.keySet()) {
     344            int item = statuses.get(sts);
     345            if (dlg.panelMain.mark.getStatus() == sts) {
     346                statusBox.setSelectedIndex(item);
     347            }
     348        }
     349        for (Cns cns : constructions.keySet()) {
     350            int item = constructions.get(cns);
     351            if (dlg.panelMain.mark.getConstr() == cns) {
     352                constrBox.setSelectedIndex(item);
     353            }
     354        }
     355        for (Con con : conspicuities.keySet()) {
     356            int item = conspicuities.get(con);
     357            if (dlg.panelMain.mark.getConsp() == con) {
     358                conBox.setSelectedIndex(item);
     359            }
     360        }
     361        for (Con con : reflectivities.keySet()) {
     362            int item = reflectivities.get(con);
     363            if (dlg.panelMain.mark.getRefl() == con) {
     364                reflBox.setSelectedIndex(item);
     365            }
     366        }
     367    }
     368
     369    private void addStsItem(String str, Sts sts) {
     370        statuses.put(sts, statusBox.getItemCount());
     371        statusBox.addItem(str);
     372    }
     373
     374    private void addCnsItem(String str, Cns cns) {
     375        constructions.put(cns, constrBox.getItemCount());
     376        constrBox.addItem(str);
     377    }
     378
     379    private void addConItem(String str, Con con) {
     380        conspicuities.put(con, conBox.getItemCount());
     381        conBox.addItem(str);
     382    }
     383
     384    private void addReflItem(String str, Con con) {
     385        reflectivities.put(con, reflBox.getItemCount());
     386        reflBox.addItem(str);
     387    }
     388
     389    private JRadioButton getRegionButton(JRadioButton button, int x, int y, int w, int h, String tip) {
     390        button.setBounds(new Rectangle(x, y, w, h));
     391        button.setBorder(BorderFactory.createLoweredBevelBorder());
     392        button.setToolTipText(Messages.getString(tip));
     393        button.addActionListener(alRegion);
     394        regionButtons.add(button);
     395        return button;
     396    }
    363397}
  • applications/editors/josm/plugins/smed/src/panels/PanelPat.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.*;
    4 import java.awt.event.*;
     3import java.awt.Rectangle;
     4import java.awt.event.ActionEvent;
     5import java.awt.event.ActionListener;
     6import java.util.EnumMap;
    57
    6 import javax.swing.*;
    7 
    8 import java.util.*;
     8import javax.swing.BorderFactory;
     9import javax.swing.ButtonGroup;
     10import javax.swing.ImageIcon;
     11import javax.swing.JPanel;
     12import javax.swing.JRadioButton;
    913
    1014import messages.Messages;
     15import seamarks.SeaMark.Ent;
     16import seamarks.SeaMark.Pat;
    1117import smed.SmedAction;
    12 import seamarks.SeaMark.*;
    1318
    1419public class PanelPat extends JPanel {
    1520
    16         private SmedAction dlg;
    17         private Ent ent;
    18         public PanelCol panelCol;
     21    private SmedAction dlg;
     22    private Ent ent;
     23    public PanelCol panelCol;
    1924
    20         private ButtonGroup patButtons = new ButtonGroup();
    21         public JRadioButton noneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NoneButton.png")));
    22         public JRadioButton horizButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/HorizontalButton.png")));
    23         public JRadioButton vertButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/VerticalButton.png")));
    24         public JRadioButton diagButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiagonalButton.png")));
    25         public JRadioButton squareButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquaredButton.png")));
    26         public JRadioButton borderButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BorderButton.png")));
    27         public EnumMap<Pat, JRadioButton> patterns = new EnumMap<>(Pat.class);
    28         private ActionListener alPat = new ActionListener() {
    29                 public void actionPerformed(java.awt.event.ActionEvent e) {
    30                         for (Pat pat : patterns.keySet()) {
    31                                 JRadioButton button = patterns.get(pat);
    32                                 if (button.isSelected()) {
    33                                         SmedAction.panelMain.mark.setPattern(ent, pat);
    34                                         button.setBorderPainted(true);
    35                                 } else
    36                                         button.setBorderPainted(false);
    37                         }
    38                         switch (SmedAction.panelMain.mark.getPattern(ent)) {
    39                         case NOPAT:
    40                                 panelCol.trimStack(1);
    41                                 break;
    42                         case HSTRP:
    43                         case VSTRP:
    44                         case DIAG:
    45                                 break;
    46                         case SQUARED:
    47                                 panelCol.trimStack(4);
    48                                 break;
    49                         case BORDER:
    50                         case CROSS:
    51                                 panelCol.trimStack(2);
    52                                 break;
    53                         }
    54                 }
    55         };
     25    private ButtonGroup patButtons = new ButtonGroup();
     26    public JRadioButton noneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NoneButton.png")));
     27    public JRadioButton horizButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/HorizontalButton.png")));
     28    public JRadioButton vertButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/VerticalButton.png")));
     29    public JRadioButton diagButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiagonalButton.png")));
     30    public JRadioButton squareButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquaredButton.png")));
     31    public JRadioButton borderButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BorderButton.png")));
     32    public EnumMap<Pat, JRadioButton> patterns = new EnumMap<>(Pat.class);
     33    private ActionListener alPat = new ActionListener() {
     34        @Override
     35        public void actionPerformed(ActionEvent e) {
     36            for (Pat pat : patterns.keySet()) {
     37                JRadioButton button = patterns.get(pat);
     38                if (button.isSelected()) {
     39                    SmedAction.panelMain.mark.setPattern(ent, pat);
     40                    button.setBorderPainted(true);
     41                } else {
     42                    button.setBorderPainted(false);
     43                }
     44            }
     45            switch (SmedAction.panelMain.mark.getPattern(ent)) {
     46            case NOPAT:
     47                panelCol.trimStack(1);
     48                break;
     49            case HSTRP:
     50            case VSTRP:
     51            case DIAG:
     52                break;
     53            case SQUARED:
     54                panelCol.trimStack(4);
     55                break;
     56            case BORDER:
     57            case CROSS:
     58                panelCol.trimStack(2);
     59                break;
     60            }
     61        }
     62    };
    5663
    57         public PanelPat(SmedAction dia, Ent entity) {
    58                 dlg = dia;
    59                 ent = entity;
    60                 setLayout(null);
    61                 panelCol = new PanelCol(dlg, ent);
    62                 panelCol.setBounds(new Rectangle(0, 0, 72, 160));
    63                 add(panelCol);
    64                 add(getPatButton(noneButton, 76, 0, 27, 27, "NoPat", Pat.NOPAT));
    65                 add(getPatButton(horizButton, 76, 26, 27, 27, "HorizPat", Pat.HSTRP));
    66                 add(getPatButton(vertButton, 76, 52, 27, 27, "VertPat", Pat.VSTRP));
    67                 add(getPatButton(diagButton, 76, 78, 27, 27, "DiagPat", Pat.DIAG));
    68                 add(getPatButton(squareButton, 76, 104, 27, 27, "SquarePat", Pat.SQUARED));
    69                 add(getPatButton(borderButton, 76, 130, 27, 27, "BorderPat", Pat.BORDER));
     64    public PanelPat(SmedAction dia, Ent entity) {
     65        dlg = dia;
     66        ent = entity;
     67        setLayout(null);
     68        panelCol = new PanelCol(dlg, ent);
     69        panelCol.setBounds(new Rectangle(0, 0, 72, 160));
     70        add(panelCol);
     71        add(getPatButton(noneButton, 76, 0, 27, 27, "NoPat", Pat.NOPAT));
     72        add(getPatButton(horizButton, 76, 26, 27, 27, "HorizPat", Pat.HSTRP));
     73        add(getPatButton(vertButton, 76, 52, 27, 27, "VertPat", Pat.VSTRP));
     74        add(getPatButton(diagButton, 76, 78, 27, 27, "DiagPat", Pat.DIAG));
     75        add(getPatButton(squareButton, 76, 104, 27, 27, "SquarePat", Pat.SQUARED));
     76        add(getPatButton(borderButton, 76, 130, 27, 27, "BorderPat", Pat.BORDER));
    7077
    71         }
     78    }
    7279
    73         public void syncPanel() {
    74                 for (Pat pat : patterns.keySet()) {
    75                         JRadioButton button = patterns.get(pat);
    76                         if (SmedAction.panelMain.mark.getPattern(ent) == pat) {
    77                                 button.setBorderPainted(true);
    78                         } else
    79                                 button.setBorderPainted(false);
    80                 }
    81                 panelCol.syncPanel();
    82         }
     80    public void syncPanel() {
     81        for (Pat pat : patterns.keySet()) {
     82            JRadioButton button = patterns.get(pat);
     83            if (SmedAction.panelMain.mark.getPattern(ent) == pat) {
     84                button.setBorderPainted(true);
     85            } else {
     86                button.setBorderPainted(false);
     87            }
     88        }
     89        panelCol.syncPanel();
     90    }
    8391
    84         private JRadioButton getPatButton(JRadioButton button, int x, int y, int w, int h, String tip, Pat pat) {
    85                 button.setBounds(new Rectangle(x, y, w, h));
    86                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    87                 button.setToolTipText(Messages.getString(tip));
    88                 button.addActionListener(alPat);
    89                 patButtons.add(button);
    90                 patterns.put(pat, button);
    91                 return button;
    92         }
     92    private JRadioButton getPatButton(JRadioButton button, int x, int y, int w, int h, String tip, Pat pat) {
     93        button.setBounds(new Rectangle(x, y, w, h));
     94        button.setBorder(BorderFactory.createLoweredBevelBorder());
     95        button.setToolTipText(Messages.getString(tip));
     96        button.addActionListener(alPat);
     97        patButtons.add(button);
     98        patterns.put(pat, button);
     99        return button;
     100    }
    93101
    94102}
  • applications/editors/josm/plugins/smed/src/panels/PanelPort.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.*;
    4 import java.awt.event.*;
    5 import javax.swing.*;
     3import java.awt.Rectangle;
     4import java.awt.event.ActionEvent;
     5import java.awt.event.ActionListener;
     6import java.util.EnumMap;
    67
    7 import java.util.*;
     8import javax.swing.BorderFactory;
     9import javax.swing.ButtonGroup;
     10import javax.swing.ImageIcon;
     11import javax.swing.JPanel;
     12import javax.swing.JRadioButton;
    813
    914import messages.Messages;
     15import seamarks.SeaMark.Cat;
     16import seamarks.SeaMark.Col;
     17import seamarks.SeaMark.Obj;
     18import seamarks.SeaMark.Pat;
     19import seamarks.SeaMark.Shp;
    1020import smed.SmedAction;
    11 import seamarks.SeaMark.*;
    1221
    1322public class PanelPort extends JPanel {
    1423
    15         private SmedAction dlg;
    16         public ButtonGroup shapeButtons = new ButtonGroup();
    17         public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
    18         public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
    19         public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png")));
    20         public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
    21         public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
    22         public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
    23         public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png")));
    24         public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchPButton.png")));
    25         public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png")));
    26         public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
    27         public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class);
    28         public ActionListener alShape = new ActionListener() {
    29                 public void actionPerformed(java.awt.event.ActionEvent e) {
    30                         for (Shp shp : shapes.keySet()) {
    31                                 JRadioButton button = shapes.get(shp);
    32                                 if (button.isSelected()) {
    33                                         SmedAction.panelMain.mark.setShape(shp);
    34                                         SmedAction.panelMain.mark.setObject(objects.get(shp));
    35                                         button.setBorderPainted(true);
    36                                 } else
    37                                         button.setBorderPainted(false);
    38                         }
    39                         if (SmedAction.panelMain.mark.testValid()) {
    40                                 SmedAction.panelMain.panelChan.topmarkButton.setVisible(true);
    41                                 SmedAction.panelMain.panelChan.lightButton.setVisible(true);
    42                                 if (SmedAction.panelMain.mark.getCategory() == Cat.LAM_PORT) {
    43                                         switch (SmedAction.panelMain.mark.getRegion()) {
    44                                         case A:
    45                                                 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
    46                                                 SmedAction.panelMain.mark.setObjColour(Col.RED);
    47                                                 break;
    48                                         case B:
    49                                                 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
    50                                                 SmedAction.panelMain.mark.setObjColour(Col.GREEN);
    51                                                 break;
    52                                         case C:
    53                                                 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
    54                                                 SmedAction.panelMain.mark.setObjColour(Col.RED);
    55                                                 SmedAction.panelMain.mark.addObjColour(Col.WHITE);
    56                                                 SmedAction.panelMain.mark.addObjColour(Col.RED);
    57                                                 SmedAction.panelMain.mark.addObjColour(Col.WHITE);
    58                                                 break;
    59                                         }
    60                                 } else {
    61                                         SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
    62                                         switch (SmedAction.panelMain.mark.getRegion()) {
    63                                         case A:
    64                                                 SmedAction.panelMain.mark.setObjColour(Col.RED);
    65                                                 SmedAction.panelMain.mark.addObjColour(Col.GREEN);
    66                                                 SmedAction.panelMain.mark.addObjColour(Col.RED);
    67                                                 break;
    68                                         case B:
    69                                                 SmedAction.panelMain.mark.setObjColour(Col.GREEN);
    70                                                 SmedAction.panelMain.mark.addObjColour(Col.RED);
    71                                                 SmedAction.panelMain.mark.addObjColour(Col.GREEN);
    72                                                 break;
    73                                         case C:
    74                                                 SmedAction.panelMain.mark.setObjColour(Col.RED);
    75                                                 SmedAction.panelMain.mark.addObjColour(Col.GREEN);
    76                                                 SmedAction.panelMain.mark.addObjColour(Col.RED);
    77                                                 SmedAction.panelMain.mark.addObjColour(Col.GREEN);
    78                                                 break;
    79                                         }
    80                                 }
    81                                 SmedAction.panelMain.panelMore.syncPanel();
    82                         } else {
    83                                 SmedAction.panelMain.panelChan.topmarkButton.setVisible(false);
    84                                 SmedAction.panelMain.panelChan.lightButton.setVisible(false);
    85                         }
    86                 }
    87         };
     24    private SmedAction dlg;
     25    public ButtonGroup shapeButtons = new ButtonGroup();
     26    public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
     27    public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
     28    public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png")));
     29    public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
     30    public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
     31    public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
     32    public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png")));
     33    public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchPButton.png")));
     34    public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png")));
     35    public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
     36    public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class);
     37    public ActionListener alShape = new ActionListener() {
     38        @Override
     39        public void actionPerformed(ActionEvent e) {
     40            for (Shp shp : shapes.keySet()) {
     41                JRadioButton button = shapes.get(shp);
     42                if (button.isSelected()) {
     43                    SmedAction.panelMain.mark.setShape(shp);
     44                    SmedAction.panelMain.mark.setObject(objects.get(shp));
     45                    button.setBorderPainted(true);
     46                } else {
     47                    button.setBorderPainted(false);
     48                }
     49            }
     50            if (SmedAction.panelMain.mark.testValid()) {
     51                SmedAction.panelMain.panelChan.topmarkButton.setVisible(true);
     52                SmedAction.panelMain.panelChan.lightButton.setVisible(true);
     53                if (SmedAction.panelMain.mark.getCategory() == Cat.LAM_PORT) {
     54                    switch (SmedAction.panelMain.mark.getRegion()) {
     55                    case A:
     56                        SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
     57                        SmedAction.panelMain.mark.setObjColour(Col.RED);
     58                        break;
     59                    case B:
     60                        SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
     61                        SmedAction.panelMain.mark.setObjColour(Col.GREEN);
     62                        break;
     63                    case C:
     64                        SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
     65                        SmedAction.panelMain.mark.setObjColour(Col.RED);
     66                        SmedAction.panelMain.mark.addObjColour(Col.WHITE);
     67                        SmedAction.panelMain.mark.addObjColour(Col.RED);
     68                        SmedAction.panelMain.mark.addObjColour(Col.WHITE);
     69                        break;
     70                    }
     71                } else {
     72                    SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
     73                    switch (SmedAction.panelMain.mark.getRegion()) {
     74                    case A:
     75                        SmedAction.panelMain.mark.setObjColour(Col.RED);
     76                        SmedAction.panelMain.mark.addObjColour(Col.GREEN);
     77                        SmedAction.panelMain.mark.addObjColour(Col.RED);
     78                        break;
     79                    case B:
     80                        SmedAction.panelMain.mark.setObjColour(Col.GREEN);
     81                        SmedAction.panelMain.mark.addObjColour(Col.RED);
     82                        SmedAction.panelMain.mark.addObjColour(Col.GREEN);
     83                        break;
     84                    case C:
     85                        SmedAction.panelMain.mark.setObjColour(Col.RED);
     86                        SmedAction.panelMain.mark.addObjColour(Col.GREEN);
     87                        SmedAction.panelMain.mark.addObjColour(Col.RED);
     88                        SmedAction.panelMain.mark.addObjColour(Col.GREEN);
     89                        break;
     90                    }
     91                }
     92                SmedAction.panelMain.panelMore.syncPanel();
     93            } else {
     94                SmedAction.panelMain.panelChan.topmarkButton.setVisible(false);
     95                SmedAction.panelMain.panelChan.lightButton.setVisible(false);
     96            }
     97        }
     98    };
    8899
    89         public PanelPort(SmedAction dia) {
    90                 dlg = dia;
    91                 setLayout(null);
    92                 add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYLAT));
    93                 add(getShapeButton(sparButton, 0, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYLAT));
    94                 add(getShapeButton(canButton, 0, 64, 34, 32, "Can", Shp.CAN, Obj.BOYLAT));
    95                 add(getShapeButton(sphereButton, 0, 96, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYLAT));
    96                 add(getShapeButton(floatButton, 0, 128, 34, 32, "Float", Shp.FLOAT, Obj.FLTLAT));
    97                 add(getShapeButton(beaconButton, 35, 0, 34, 32, "Beacon", Shp.BEACON, Obj.BCNLAT));
    98                 add(getShapeButton(towerButton, 35, 32, 34, 32, "TowerB", Shp.TOWER, Obj.BCNLAT));
    99                 add(getShapeButton(perchButton, 35, 64, 34, 32, "Perch", Shp.PERCH, Obj.BCNLAT));
    100                 add(getShapeButton(stakeButton, 35, 96, 34, 32, "Stake", Shp.STAKE, Obj.BCNLAT));
    101         }
     100    public PanelPort(SmedAction dia) {
     101        dlg = dia;
     102        setLayout(null);
     103        add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYLAT));
     104        add(getShapeButton(sparButton, 0, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYLAT));
     105        add(getShapeButton(canButton, 0, 64, 34, 32, "Can", Shp.CAN, Obj.BOYLAT));
     106        add(getShapeButton(sphereButton, 0, 96, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYLAT));
     107        add(getShapeButton(floatButton, 0, 128, 34, 32, "Float", Shp.FLOAT, Obj.FLTLAT));
     108        add(getShapeButton(beaconButton, 35, 0, 34, 32, "Beacon", Shp.BEACON, Obj.BCNLAT));
     109        add(getShapeButton(towerButton, 35, 32, 34, 32, "TowerB", Shp.TOWER, Obj.BCNLAT));
     110        add(getShapeButton(perchButton, 35, 64, 34, 32, "Perch", Shp.PERCH, Obj.BCNLAT));
     111        add(getShapeButton(stakeButton, 35, 96, 34, 32, "Stake", Shp.STAKE, Obj.BCNLAT));
     112    }
    102113
    103         public void syncPanel() {
    104                 for (Shp shp : shapes.keySet()) {
    105                         JRadioButton button = shapes.get(shp);
    106                         if (SmedAction.panelMain.mark.getShape() == shp) {
    107                                 button.setBorderPainted(true);
    108                         } else
    109                                 button.setBorderPainted(false);
    110                 }
    111         }
     114    public void syncPanel() {
     115        for (Shp shp : shapes.keySet()) {
     116            JRadioButton button = shapes.get(shp);
     117            if (SmedAction.panelMain.mark.getShape() == shp) {
     118                button.setBorderPainted(true);
     119            } else {
     120                button.setBorderPainted(false);
     121            }
     122        }
     123    }
    112124
    113         private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
    114                 button.setBounds(new Rectangle(x, y, w, h));
    115                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    116                 button.setToolTipText(Messages.getString(tip));
    117                 button.addActionListener(alShape);
    118                 shapeButtons.add(button);
    119                 shapes.put(shp, button);
    120                 objects.put(shp, obj);
    121                 return button;
    122         }
     125    private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
     126        button.setBounds(new Rectangle(x, y, w, h));
     127        button.setBorder(BorderFactory.createLoweredBevelBorder());
     128        button.setToolTipText(Messages.getString(tip));
     129        button.addActionListener(alShape);
     130        shapeButtons.add(button);
     131        shapes.put(shp, button);
     132        objects.put(shp, obj);
     133        return button;
     134    }
    123135
    124136}
  • applications/editors/josm/plugins/smed/src/panels/PanelRadar.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.*;
    4 import java.awt.event.*;
    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.JToggleButton;
     20import javax.swing.SwingConstants;
    921
    1022import messages.Messages;
     23import seamarks.SeaMark.Cat;
     24import seamarks.SeaMark.Rtb;
    1125import smed.SmedAction;
    12 import seamarks.SeaMark.*;
    1326
    1427public class PanelRadar extends JPanel {
    1528
    16         private SmedAction dlg;
    17         private JToggleButton aisButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/AISButton.png")));
    18         private ActionListener alAis = new ActionListener() {
    19                 public void actionPerformed(java.awt.event.ActionEvent e) {
    20                         if (aisButton.isSelected()) {
    21                                 radioCatBox.setVisible(true);
    22                                 aisButton.setBorderPainted(true);
    23                         } else {
    24                                 radioCatBox.setSelectedIndex(0);
    25                                 radioCatBox.setVisible(false);
    26                                 aisButton.setBorderPainted(false);
    27                         }
    28                 }
    29         };
    30         private JComboBox<String> radioCatBox;
    31         private EnumMap<Cat, Integer> radioCats = new EnumMap<>(Cat.class);
    32         private ActionListener alRadioCatBox = new ActionListener() {
    33                 public void actionPerformed(java.awt.event.ActionEvent e) {
    34                         for (Cat cat : radioCats.keySet()) {
    35                                 int idx = radioCats.get(cat);
    36                                 if (dlg.node != null && (idx == radioCatBox.getSelectedIndex())) {
    37                                         SmedAction.panelMain.mark.setRadio(cat);
    38                                 }
    39                         }
    40                 }
    41         };
    42         private ButtonGroup radarButtons = new ButtonGroup();
    43         public JRadioButton noRadButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
    44         public JRadioButton reflButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarReflectorButton.png")));
    45         public JRadioButton ramarkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RamarkButton.png")));
    46         public JRadioButton raconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RaconButton.png")));
    47         public JRadioButton leadingButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LeadingRaconButton.png")));
    48         private EnumMap<Rtb, JRadioButton> rads = new EnumMap<>(Rtb.class);
    49         private ActionListener alRad = new ActionListener() {
    50                 public void actionPerformed(java.awt.event.ActionEvent e) {
    51                         for (Rtb rtb : rads.keySet()) {
    52                                 JRadioButton button = rads.get(rtb);
    53                                 if (button.isSelected()) {
    54                                         SmedAction.panelMain.mark.setRadar(rtb);
    55                                 }
    56                         }
    57                         syncPanel();
    58                 }
    59         };
    60         public JLabel groupLabel;
    61         public JTextField groupBox;
    62         private FocusListener flGroup = new FocusAdapter() {
    63                 public void focusLost(java.awt.event.FocusEvent e) {
    64                         SmedAction.panelMain.mark.setRaconGroup(groupBox.getText());
    65                 }
    66         };
    67         public JLabel periodLabel;
    68         public JTextField periodBox;
    69         private FocusListener flPeriod = new FocusAdapter() {
    70                 public void focusLost(java.awt.event.FocusEvent e) {
    71                         SmedAction.panelMain.mark.setRaconPeriod(periodBox.getText());
    72                 }
    73         };
    74         public JLabel seqLabel;
    75         public JTextField seqBox;
    76         private FocusListener flSeq = new FocusAdapter() {
    77                 public void focusLost(java.awt.event.FocusEvent e) {
    78                         SmedAction.panelMain.mark.setRaconSequence(seqBox.getText());
    79                 }
    80         };
    81         public JLabel rangeLabel;
    82         public JTextField rangeBox;
    83         private FocusListener flRange = new FocusAdapter() {
    84                 public void focusLost(java.awt.event.FocusEvent e) {
    85                         SmedAction.panelMain.mark.setRaconRange(rangeBox.getText());
    86                 }
    87         };
    88         public JLabel sector1Label;
    89         public JTextField sector1Box;
    90         private FocusListener flSector1 = new FocusAdapter() {
    91                 public void focusLost(java.awt.event.FocusEvent e) {
    92                         SmedAction.panelMain.mark.setRaconSector1(sector1Box.getText());
    93                 }
    94         };
    95         public JLabel sector2Label;
    96         public JTextField sector2Box;
    97         private FocusListener flSector2 = new FocusAdapter() {
    98                 public void focusLost(java.awt.event.FocusEvent e) {
    99                         SmedAction.panelMain.mark.setRaconSector2(sector2Box.getText());
    100                 }
    101         };
    102         public JLabel sectorsLabel;
    103 
    104         public PanelRadar(SmedAction dia) {
    105                 dlg = dia;
    106                 setLayout(null);
    107                 add(getRadButton(noRadButton, 0, 3, 27, 27, "NoRadar", Rtb.NORTB));
    108                 add(getRadButton(reflButton, 0, 33, 27, 27, "RadarReflector", Rtb.REFLECTOR));
    109                 add(getRadButton(ramarkButton, 0, 63, 27, 27, "Ramark", Rtb.RAMARK));
    110                 add(getRadButton(raconButton, 0, 93, 27, 27, "Racon", Rtb.RACON));
    111                 add(getRadButton(leadingButton, 0, 123, 27, 27, "LeadingRacon", Rtb.LEADING));
    112                
    113                 groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER);
    114                 groupLabel.setBounds(new Rectangle(30, 0, 100, 20));
    115                 add(groupLabel);
    116                 groupBox = new JTextField();
    117                 groupBox.setBounds(new Rectangle(55, 20, 50, 20));
    118                 groupBox.setHorizontalAlignment(SwingConstants.CENTER);
    119                 add(groupBox);
    120                 groupBox.addFocusListener(flGroup);
    121 
    122                 periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER);
    123                 periodLabel.setBounds(new Rectangle(130, 0, 100, 20));
    124                 add(periodLabel);
    125                 periodBox = new JTextField();
    126                 periodBox.setBounds(new Rectangle(155, 20, 50, 20));
    127                 periodBox.setHorizontalAlignment(SwingConstants.CENTER);
    128                 add(periodBox);
    129                 periodBox.addFocusListener(flPeriod);
    130 
    131                 seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER);
    132                 seqLabel.setBounds(new Rectangle(30, 40, 100, 20));
    133                 add(seqLabel);
    134                 seqBox = new JTextField();
    135                 seqBox.setBounds(new Rectangle(55, 60, 50, 20));
    136                 seqBox.setHorizontalAlignment(SwingConstants.CENTER);
    137                 add(seqBox);
    138                 seqBox.addFocusListener(flSeq);
    139 
    140                 rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER);
    141                 rangeLabel.setBounds(new Rectangle(130, 40, 100, 20));
    142                 add(rangeLabel);
    143                 rangeBox = new JTextField();
    144                 rangeBox.setBounds(new Rectangle(155, 60, 50, 20));
    145                 rangeBox.setHorizontalAlignment(SwingConstants.CENTER);
    146                 add(rangeBox);
    147                 rangeBox.addFocusListener(flRange);
    148                
    149                 sectorsLabel = new JLabel(Messages.getString("VisibleSector"), SwingConstants.CENTER);
    150                 sectorsLabel.setBounds(new Rectangle(75, 85, 100, 20));
    151                 add(sectorsLabel);
    152 
    153                 sector1Label = new JLabel(Messages.getString("Start"), SwingConstants.CENTER);
    154                 sector1Label.setBounds(new Rectangle(30, 100, 100, 20));
    155                 add(sector1Label);
    156                 sector1Box = new JTextField();
    157                 sector1Box.setBounds(new Rectangle(55, 120, 50, 20));
    158                 sector1Box.setHorizontalAlignment(SwingConstants.CENTER);
    159                 add(sector1Box);
    160                 sector1Box.addFocusListener(flSector1);
    161 
    162                 sector2Label = new JLabel(Messages.getString("End"), SwingConstants.CENTER);
    163                 sector2Label.setBounds(new Rectangle(130, 100, 100, 20));
    164                 add(sector2Label);
    165                 sector2Box = new JTextField();
    166                 sector2Box.setBounds(new Rectangle(155, 120, 50, 20));
    167                 sector2Box.setHorizontalAlignment(SwingConstants.CENTER);
    168                 add(sector2Box);
    169                 sector2Box.addFocusListener(flSector2);
    170 
    171                 aisButton.setBounds(new Rectangle(270, 3, 27, 27));
    172                 aisButton.setBorder(BorderFactory.createLoweredBevelBorder());
    173                 aisButton.setToolTipText("AIS");
    174                 aisButton.addActionListener(alAis);
    175                 add(aisButton);
    176 
    177                 radioCatBox = new JComboBox<>();
    178                 radioCatBox.setBounds(new Rectangle(210, 40, 150, 20));
    179                 add(radioCatBox);
    180                 radioCatBox.addActionListener(alRadioCatBox);
    181                 addROItem("", Cat.NOROS);
    182                 addROItem(Messages.getString("CircularBeacon"), Cat.ROS_OMNI);
    183                 addROItem(Messages.getString("DirectionalBeacon"), Cat.ROS_DIRL);
    184                 addROItem(Messages.getString("RotatingBeacon"), Cat.ROS_ROTP);
    185                 addROItem(Messages.getString("ConsolBeacon"), Cat.ROS_CNSL);
    186                 addROItem(Messages.getString("DirectionFinding"), Cat.ROS_RDF);
    187                 addROItem(Messages.getString("QTGService"), Cat.ROS_QTG);
    188                 addROItem(Messages.getString("AeronaticalBeacon"), Cat.ROS_AERO);
    189                 addROItem(Messages.getString("Decca"), Cat.ROS_DECA);
    190                 addROItem(Messages.getString("LoranC"), Cat.ROS_LORN);
    191                 addROItem(Messages.getString("DGPS"), Cat.ROS_DGPS);
    192                 addROItem(Messages.getString("Toran"), Cat.ROS_TORN);
    193                 addROItem(Messages.getString("Omega"), Cat.ROS_OMGA);
    194                 addROItem(Messages.getString("Syledis"), Cat.ROS_SYLD);
    195                 addROItem(Messages.getString("Chiaka"), Cat.ROS_CHKA);
    196                 addROItem(Messages.getString("PublicCommunication"), Cat.ROS_PCOM);
    197                 addROItem(Messages.getString("CommercialBroadcast"), Cat.ROS_COMB);
    198                 addROItem(Messages.getString("Facsimile"), Cat.ROS_FACS);
    199                 addROItem(Messages.getString("TimeSignal"), Cat.ROS_TIME);
    200                 addROItem(Messages.getString("AIS"), Cat.ROS_PAIS);
    201                 addROItem(Messages.getString("S-AIS"), Cat.ROS_SAIS);
    202                 radioCatBox.setVisible(false);
    203         }
    204 
    205         public void syncPanel() {
    206                 boolean rad = ((SmedAction.panelMain.mark.getRadar() != Rtb.NORTB) && (SmedAction.panelMain.mark.getRadar() != Rtb.REFLECTOR));
    207                 groupLabel.setVisible(rad);
    208                 groupBox.setVisible(rad);
    209                 periodLabel.setVisible(rad);
    210                 periodBox.setVisible(rad);
    211                 seqLabel.setVisible(rad);
    212                 seqBox.setVisible(rad);
    213                 rangeLabel.setVisible(rad);
    214                 rangeBox.setVisible(rad);
    215                 sector1Label.setVisible(rad);
    216                 sector1Box.setVisible(rad);
    217                 sector2Label.setVisible(rad);
    218                 sector2Box.setVisible(rad);
    219                 sectorsLabel.setVisible(rad);
    220                 for (Rtb rtb : rads.keySet()) {
    221                         rads.get(rtb).setBorderPainted(SmedAction.panelMain.mark.getRadar() == rtb);
    222                 }
    223                 groupBox.setText(SmedAction.panelMain.mark.getRaconGroup());
    224                 seqBox.setText(SmedAction.panelMain.mark.getRaconSequence());
    225                 periodBox.setText(SmedAction.panelMain.mark.getRaconPeriod());
    226                 rangeBox.setText(SmedAction.panelMain.mark.getRaconRange());
    227                 sector1Box.setText(SmedAction.panelMain.mark.getRaconSector1());
    228                 sector2Box.setText(SmedAction.panelMain.mark.getRaconSector2());
    229                 aisButton.setSelected(SmedAction.panelMain.mark.getRadio() != Cat.NOROS);
    230                 aisButton.setBorderPainted(aisButton.isSelected());
    231                 radioCatBox.setVisible(SmedAction.panelMain.mark.getRadio() != Cat.NOROS);
    232         }
    233 
    234         private JRadioButton getRadButton(JRadioButton button, int x, int y, int w, int h, String tip, Rtb rtb) {
    235                 button.setBounds(new Rectangle(x, y, w, h));
    236                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    237                 button.setToolTipText(Messages.getString(tip));
    238                 button.addActionListener(alRad);
    239                 radarButtons.add(button);
    240                 rads.put(rtb, button);
    241                 return button;
    242         }
    243 
    244         private void addROItem(String str, Cat cat) {
    245                 radioCats.put(cat, radioCatBox.getItemCount());
    246                 radioCatBox.addItem(str);
    247         }
     29    private SmedAction dlg;
     30    private JToggleButton aisButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/AISButton.png")));
     31    private ActionListener alAis = new ActionListener() {
     32        @Override
     33        public void actionPerformed(ActionEvent e) {
     34            if (aisButton.isSelected()) {
     35                radioCatBox.setVisible(true);
     36                aisButton.setBorderPainted(true);
     37            } else {
     38                radioCatBox.setSelectedIndex(0);
     39                radioCatBox.setVisible(false);
     40                aisButton.setBorderPainted(false);
     41            }
     42        }
     43    };
     44    private JComboBox<String> radioCatBox;
     45    private EnumMap<Cat, Integer> radioCats = new EnumMap<>(Cat.class);
     46    private ActionListener alRadioCatBox = new ActionListener() {
     47        @Override
     48        public void actionPerformed(ActionEvent e) {
     49            for (Cat cat : radioCats.keySet()) {
     50                int idx = radioCats.get(cat);
     51                if (dlg.node != null && (idx == radioCatBox.getSelectedIndex())) {
     52                    SmedAction.panelMain.mark.setRadio(cat);
     53                }
     54            }
     55        }
     56    };
     57    private ButtonGroup radarButtons = new ButtonGroup();
     58    public JRadioButton noRadButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
     59    public JRadioButton reflButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RadarReflectorButton.png")));
     60    public JRadioButton ramarkButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RamarkButton.png")));
     61    public JRadioButton raconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RaconButton.png")));
     62    public JRadioButton leadingButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LeadingRaconButton.png")));
     63    private EnumMap<Rtb, JRadioButton> rads = new EnumMap<>(Rtb.class);
     64    private ActionListener alRad = new ActionListener() {
     65        @Override
     66        public void actionPerformed(ActionEvent e) {
     67            for (Rtb rtb : rads.keySet()) {
     68                JRadioButton button = rads.get(rtb);
     69                if (button.isSelected()) {
     70                    SmedAction.panelMain.mark.setRadar(rtb);
     71                }
     72            }
     73            syncPanel();
     74        }
     75    };
     76    public JLabel groupLabel;
     77    public JTextField groupBox;
     78    private FocusListener flGroup = new FocusAdapter() {
     79        @Override
     80        public void focusLost(FocusEvent e) {
     81            SmedAction.panelMain.mark.setRaconGroup(groupBox.getText());
     82        }
     83    };
     84    public JLabel periodLabel;
     85    public JTextField periodBox;
     86    private FocusListener flPeriod = new FocusAdapter() {
     87        @Override
     88        public void focusLost(FocusEvent e) {
     89            SmedAction.panelMain.mark.setRaconPeriod(periodBox.getText());
     90        }
     91    };
     92    public JLabel seqLabel;
     93    public JTextField seqBox;
     94    private FocusListener flSeq = new FocusAdapter() {
     95        @Override
     96        public void focusLost(FocusEvent e) {
     97            SmedAction.panelMain.mark.setRaconSequence(seqBox.getText());
     98        }
     99    };
     100    public JLabel rangeLabel;
     101    public JTextField rangeBox;
     102    private FocusListener flRange = new FocusAdapter() {
     103        @Override
     104        public void focusLost(FocusEvent e) {
     105            SmedAction.panelMain.mark.setRaconRange(rangeBox.getText());
     106        }
     107    };
     108    public JLabel sector1Label;
     109    public JTextField sector1Box;
     110    private FocusListener flSector1 = new FocusAdapter() {
     111        @Override
     112        public void focusLost(FocusEvent e) {
     113            SmedAction.panelMain.mark.setRaconSector1(sector1Box.getText());
     114        }
     115    };
     116    public JLabel sector2Label;
     117    public JTextField sector2Box;
     118    private FocusListener flSector2 = new FocusAdapter() {
     119        @Override
     120        public void focusLost(FocusEvent e) {
     121            SmedAction.panelMain.mark.setRaconSector2(sector2Box.getText());
     122        }
     123    };
     124    public JLabel sectorsLabel;
     125
     126    public PanelRadar(SmedAction dia) {
     127        dlg = dia;
     128        setLayout(null);
     129        add(getRadButton(noRadButton, 0, 3, 27, 27, "NoRadar", Rtb.NORTB));
     130        add(getRadButton(reflButton, 0, 33, 27, 27, "RadarReflector", Rtb.REFLECTOR));
     131        add(getRadButton(ramarkButton, 0, 63, 27, 27, "Ramark", Rtb.RAMARK));
     132        add(getRadButton(raconButton, 0, 93, 27, 27, "Racon", Rtb.RACON));
     133        add(getRadButton(leadingButton, 0, 123, 27, 27, "LeadingRacon", Rtb.LEADING));
     134
     135        groupLabel = new JLabel(Messages.getString("Group"), SwingConstants.CENTER);
     136        groupLabel.setBounds(new Rectangle(30, 0, 100, 20));
     137        add(groupLabel);
     138        groupBox = new JTextField();
     139        groupBox.setBounds(new Rectangle(55, 20, 50, 20));
     140        groupBox.setHorizontalAlignment(SwingConstants.CENTER);
     141        add(groupBox);
     142        groupBox.addFocusListener(flGroup);
     143
     144        periodLabel = new JLabel(Messages.getString("Period"), SwingConstants.CENTER);
     145        periodLabel.setBounds(new Rectangle(130, 0, 100, 20));
     146        add(periodLabel);
     147        periodBox = new JTextField();
     148        periodBox.setBounds(new Rectangle(155, 20, 50, 20));
     149        periodBox.setHorizontalAlignment(SwingConstants.CENTER);
     150        add(periodBox);
     151        periodBox.addFocusListener(flPeriod);
     152
     153        seqLabel = new JLabel(Messages.getString("Sequence"), SwingConstants.CENTER);
     154        seqLabel.setBounds(new Rectangle(30, 40, 100, 20));
     155        add(seqLabel);
     156        seqBox = new JTextField();
     157        seqBox.setBounds(new Rectangle(55, 60, 50, 20));
     158        seqBox.setHorizontalAlignment(SwingConstants.CENTER);
     159        add(seqBox);
     160        seqBox.addFocusListener(flSeq);
     161
     162        rangeLabel = new JLabel(Messages.getString("Range"), SwingConstants.CENTER);
     163        rangeLabel.setBounds(new Rectangle(130, 40, 100, 20));
     164        add(rangeLabel);
     165        rangeBox = new JTextField();
     166        rangeBox.setBounds(new Rectangle(155, 60, 50, 20));
     167        rangeBox.setHorizontalAlignment(SwingConstants.CENTER);
     168        add(rangeBox);
     169        rangeBox.addFocusListener(flRange);
     170
     171        sectorsLabel = new JLabel(Messages.getString("VisibleSector"), SwingConstants.CENTER);
     172        sectorsLabel.setBounds(new Rectangle(75, 85, 100, 20));
     173        add(sectorsLabel);
     174
     175        sector1Label = new JLabel(Messages.getString("Start"), SwingConstants.CENTER);
     176        sector1Label.setBounds(new Rectangle(30, 100, 100, 20));
     177        add(sector1Label);
     178        sector1Box = new JTextField();
     179        sector1Box.setBounds(new Rectangle(55, 120, 50, 20));
     180        sector1Box.setHorizontalAlignment(SwingConstants.CENTER);
     181        add(sector1Box);
     182        sector1Box.addFocusListener(flSector1);
     183
     184        sector2Label = new JLabel(Messages.getString("End"), SwingConstants.CENTER);
     185        sector2Label.setBounds(new Rectangle(130, 100, 100, 20));
     186        add(sector2Label);
     187        sector2Box = new JTextField();
     188        sector2Box.setBounds(new Rectangle(155, 120, 50, 20));
     189        sector2Box.setHorizontalAlignment(SwingConstants.CENTER);
     190        add(sector2Box);
     191        sector2Box.addFocusListener(flSector2);
     192
     193        aisButton.setBounds(new Rectangle(270, 3, 27, 27));
     194        aisButton.setBorder(BorderFactory.createLoweredBevelBorder());
     195        aisButton.setToolTipText("AIS");
     196        aisButton.addActionListener(alAis);
     197        add(aisButton);
     198
     199        radioCatBox = new JComboBox<>();
     200        radioCatBox.setBounds(new Rectangle(210, 40, 150, 20));
     201        add(radioCatBox);
     202        radioCatBox.addActionListener(alRadioCatBox);
     203        addROItem("", Cat.NOROS);
     204        addROItem(Messages.getString("CircularBeacon"), Cat.ROS_OMNI);
     205        addROItem(Messages.getString("DirectionalBeacon"), Cat.ROS_DIRL);
     206        addROItem(Messages.getString("RotatingBeacon"), Cat.ROS_ROTP);
     207        addROItem(Messages.getString("ConsolBeacon"), Cat.ROS_CNSL);
     208        addROItem(Messages.getString("DirectionFinding"), Cat.ROS_RDF);
     209        addROItem(Messages.getString("QTGService"), Cat.ROS_QTG);
     210        addROItem(Messages.getString("AeronaticalBeacon"), Cat.ROS_AERO);
     211        addROItem(Messages.getString("Decca"), Cat.ROS_DECA);
     212        addROItem(Messages.getString("LoranC"), Cat.ROS_LORN);
     213        addROItem(Messages.getString("DGPS"), Cat.ROS_DGPS);
     214        addROItem(Messages.getString("Toran"), Cat.ROS_TORN);
     215        addROItem(Messages.getString("Omega"), Cat.ROS_OMGA);
     216        addROItem(Messages.getString("Syledis"), Cat.ROS_SYLD);
     217        addROItem(Messages.getString("Chiaka"), Cat.ROS_CHKA);
     218        addROItem(Messages.getString("PublicCommunication"), Cat.ROS_PCOM);
     219        addROItem(Messages.getString("CommercialBroadcast"), Cat.ROS_COMB);
     220        addROItem(Messages.getString("Facsimile"), Cat.ROS_FACS);
     221        addROItem(Messages.getString("TimeSignal"), Cat.ROS_TIME);
     222        addROItem(Messages.getString("AIS"), Cat.ROS_PAIS);
     223        addROItem(Messages.getString("S-AIS"), Cat.ROS_SAIS);
     224        radioCatBox.setVisible(false);
     225    }
     226
     227    public void syncPanel() {
     228        boolean rad = ((SmedAction.panelMain.mark.getRadar() != Rtb.NORTB) && (SmedAction.panelMain.mark.getRadar() != Rtb.REFLECTOR));
     229        groupLabel.setVisible(rad);
     230        groupBox.setVisible(rad);
     231        periodLabel.setVisible(rad);
     232        periodBox.setVisible(rad);
     233        seqLabel.setVisible(rad);
     234        seqBox.setVisible(rad);
     235        rangeLabel.setVisible(rad);
     236        rangeBox.setVisible(rad);
     237        sector1Label.setVisible(rad);
     238        sector1Box.setVisible(rad);
     239        sector2Label.setVisible(rad);
     240        sector2Box.setVisible(rad);
     241        sectorsLabel.setVisible(rad);
     242        for (Rtb rtb : rads.keySet()) {
     243            rads.get(rtb).setBorderPainted(SmedAction.panelMain.mark.getRadar() == rtb);
     244        }
     245        groupBox.setText(SmedAction.panelMain.mark.getRaconGroup());
     246        seqBox.setText(SmedAction.panelMain.mark.getRaconSequence());
     247        periodBox.setText(SmedAction.panelMain.mark.getRaconPeriod());
     248        rangeBox.setText(SmedAction.panelMain.mark.getRaconRange());
     249        sector1Box.setText(SmedAction.panelMain.mark.getRaconSector1());
     250        sector2Box.setText(SmedAction.panelMain.mark.getRaconSector2());
     251        aisButton.setSelected(SmedAction.panelMain.mark.getRadio() != Cat.NOROS);
     252        aisButton.setBorderPainted(aisButton.isSelected());
     253        radioCatBox.setVisible(SmedAction.panelMain.mark.getRadio() != Cat.NOROS);
     254    }
     255
     256    private JRadioButton getRadButton(JRadioButton button, int x, int y, int w, int h, String tip, Rtb rtb) {
     257        button.setBounds(new Rectangle(x, y, w, h));
     258        button.setBorder(BorderFactory.createLoweredBevelBorder());
     259        button.setToolTipText(Messages.getString(tip));
     260        button.addActionListener(alRad);
     261        radarButtons.add(button);
     262        rads.put(rtb, button);
     263        return button;
     264    }
     265
     266    private void addROItem(String str, Cat cat) {
     267        radioCats.put(cat, radioCatBox.getItemCount());
     268        radioCatBox.addItem(str);
     269    }
    248270}
  • applications/editors/josm/plugins/smed/src/panels/PanelSaw.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.*;
    4 import java.awt.event.*;
    5 import javax.swing.*;
     3import java.awt.Rectangle;
     4import java.awt.event.ActionEvent;
     5import java.awt.event.ActionListener;
     6import java.util.EnumMap;
    67
    7 import java.util.*;
     8import javax.swing.BorderFactory;
     9import javax.swing.ButtonGroup;
     10import javax.swing.ImageIcon;
     11import javax.swing.JPanel;
     12import javax.swing.JRadioButton;
    813
    914import messages.Messages;
     15import seamarks.SeaMark.Col;
     16import seamarks.SeaMark.Obj;
     17import seamarks.SeaMark.Pat;
     18import seamarks.SeaMark.Shp;
    1019import smed.SmedAction;
    11 import seamarks.SeaMark.*;
    1220
    1321public class PanelSaw extends JPanel {
    1422
    15         private SmedAction dlg;
    16         public ButtonGroup shapeButtons = new ButtonGroup();
    17         public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
    18         public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
    19         public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
    20         public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
    21         public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
    22         public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
    23         public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class);
    24         public ActionListener alShape = new ActionListener() {
    25                 public void actionPerformed(java.awt.event.ActionEvent e) {
    26                         for (Shp shp : shapes.keySet()) {
    27                                 JRadioButton button = shapes.get(shp);
    28                                 if (button.isSelected()) {
    29                                         SmedAction.panelMain.mark.setShape(shp);
    30                                         SmedAction.panelMain.mark.setObject(objects.get(shp));
    31                                         button.setBorderPainted(true);
    32                                 } else
    33                                         button.setBorderPainted(false);
    34                         }
    35                         if (SmedAction.panelMain.mark.testValid()) {
    36                                 SmedAction.panelMain.panelChan.topmarkButton.setVisible(true);
    37                                 SmedAction.panelMain.mark.setObjPattern(Pat.VSTRP);
    38                                 SmedAction.panelMain.mark.setObjColour(Col.RED);
    39                                 SmedAction.panelMain.mark.addObjColour(Col.WHITE);
    40                         } else {
    41                                 SmedAction.panelMain.panelChan.topmarkButton.setVisible(false);
    42                         }
    43                         SmedAction.panelMain.panelMore.syncPanel();
    44                 }
    45         };
     23    private SmedAction dlg;
     24    public ButtonGroup shapeButtons = new ButtonGroup();
     25    public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
     26    public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
     27    public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
     28    public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
     29    public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
     30    public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
     31    public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class);
     32    public ActionListener alShape = new ActionListener() {
     33        @Override
     34        public void actionPerformed(ActionEvent e) {
     35            for (Shp shp : shapes.keySet()) {
     36                JRadioButton button = shapes.get(shp);
     37                if (button.isSelected()) {
     38                    SmedAction.panelMain.mark.setShape(shp);
     39                    SmedAction.panelMain.mark.setObject(objects.get(shp));
     40                    button.setBorderPainted(true);
     41                } else {
     42                    button.setBorderPainted(false);
     43                }
     44            }
     45            if (SmedAction.panelMain.mark.testValid()) {
     46                SmedAction.panelMain.panelChan.topmarkButton.setVisible(true);
     47                SmedAction.panelMain.mark.setObjPattern(Pat.VSTRP);
     48                SmedAction.panelMain.mark.setObjColour(Col.RED);
     49                SmedAction.panelMain.mark.addObjColour(Col.WHITE);
     50            } else {
     51                SmedAction.panelMain.panelChan.topmarkButton.setVisible(false);
     52            }
     53            SmedAction.panelMain.panelMore.syncPanel();
     54        }
     55    };
    4656
    47         public PanelSaw(SmedAction dia) {
    48                 dlg = dia;
    49                 setLayout(null);
    50                 add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSAW));
    51                 add(getShapeButton(sparButton, 0, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYSAW));
    52                 add(getShapeButton(sphereButton, 0, 64, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSAW));
    53                 add(getShapeButton(floatButton, 0, 96, 34, 32, "Float", Shp.FLOAT, Obj.FLTSAW));
    54                 add(getShapeButton(beaconButton, 0, 128, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSAW));
    55         }
     57    public PanelSaw(SmedAction dia) {
     58        dlg = dia;
     59        setLayout(null);
     60        add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSAW));
     61        add(getShapeButton(sparButton, 0, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYSAW));
     62        add(getShapeButton(sphereButton, 0, 64, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSAW));
     63        add(getShapeButton(floatButton, 0, 96, 34, 32, "Float", Shp.FLOAT, Obj.FLTSAW));
     64        add(getShapeButton(beaconButton, 0, 128, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSAW));
     65    }
    5666
    57         public void syncPanel() {
    58                 for (Shp shp : shapes.keySet()) {
    59                         JRadioButton button = shapes.get(shp);
    60                         if (SmedAction.panelMain.mark.getShape() == shp) {
    61                                 button.setBorderPainted(true);
    62                         } else
    63                                 button.setBorderPainted(false);
    64                 }
    65                 SmedAction.panelMain.mark.testValid();
    66         }
    67        
    68         private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
    69                 button.setBounds(new Rectangle(x, y, w, h));
    70                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    71                 button.setToolTipText(Messages.getString(tip));
    72                 button.addActionListener(alShape);
    73                 shapeButtons.add(button);
    74                 shapes.put(shp, button);
    75                 objects.put(shp, obj);
    76                 return button;
    77         }
     67    public void syncPanel() {
     68        for (Shp shp : shapes.keySet()) {
     69            JRadioButton button = shapes.get(shp);
     70            if (SmedAction.panelMain.mark.getShape() == shp) {
     71                button.setBorderPainted(true);
     72            } else {
     73                button.setBorderPainted(false);
     74            }
     75        }
     76        SmedAction.panelMain.mark.testValid();
     77    }
     78
     79    private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
     80        button.setBounds(new Rectangle(x, y, w, h));
     81        button.setBorder(BorderFactory.createLoweredBevelBorder());
     82        button.setToolTipText(Messages.getString(tip));
     83        button.addActionListener(alShape);
     84        shapeButtons.add(button);
     85        shapes.put(shp, button);
     86        objects.put(shp, obj);
     87        return button;
     88    }
    7889
    7990}
  • applications/editors/josm/plugins/smed/src/panels/PanelSectors.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.*;
    4 import java.awt.event.*;
     3import java.awt.BorderLayout;
     4import java.awt.Component;
     5import java.awt.GridLayout;
     6import java.awt.event.ActionEvent;
     7import java.awt.event.ActionListener;
    58import java.util.EnumMap;
    69
    7 import javax.swing.*;
    8 import javax.swing.table.*;
     10import javax.swing.DefaultCellEditor;
     11import javax.swing.ImageIcon;
     12import javax.swing.JButton;
     13import javax.swing.JComboBox;
     14import javax.swing.JFrame;
     15import javax.swing.JLabel;
     16import javax.swing.JPanel;
     17import javax.swing.JScrollPane;
     18import javax.swing.JTable;
     19import javax.swing.SwingConstants;
     20import javax.swing.table.AbstractTableModel;
     21import javax.swing.table.DefaultTableCellRenderer;
     22import javax.swing.table.TableCellRenderer;
     23import javax.swing.table.TableColumn;
     24import javax.swing.table.TableModel;
    925
    1026import messages.Messages;
     27import seamarks.SeaMark;
     28import seamarks.SeaMark.Att;
     29import seamarks.SeaMark.Col;
     30import seamarks.SeaMark.Exh;
     31import seamarks.SeaMark.Lit;
     32import seamarks.SeaMark.Vis;
    1133import smed.SmedAction;
    12 import seamarks.SeaMark;
    13 import seamarks.SeaMark.*;
    1434
    1535public class PanelSectors extends JFrame {
    1636
    17         private SmedAction dlg;
    18         private JPanel panel;
    19         private TableModel model;
    20         private JTable table;
    21 
    22         public JButton minusButton;
    23         private ActionListener alMinusButton = new ActionListener() {
    24                 public void actionPerformed(java.awt.event.ActionEvent e) {
    25                         if ((getSectorCount() > 1) && (table.getSelectedRow() != 0))
    26                                 deleteSector(table.getSelectedRow());
    27                 }
    28         };
    29         public JButton plusButton;
    30         private ActionListener alPlusButton = new ActionListener() {
    31                 public void actionPerformed(java.awt.event.ActionEvent e) {
    32                         if (table.getSelectedRow() < 0)
    33                                 addSector(table.getRowCount());
    34                         else
    35                                 addSector(table.getSelectedRow()+1);
    36                 }
    37         };
    38         public JComboBox<ImageIcon> colourBox;
    39         public EnumMap<Col, ImageIcon> colours = new EnumMap<>(Col.class);
    40         public JComboBox<String> visibilityBox;
    41         public EnumMap<Vis, String> visibilities = new EnumMap<>(Vis.class);
    42         public JComboBox<String> exhibitionBox;
    43         public EnumMap<Exh, String> exhibitions = new EnumMap<>(Exh.class);
    44 
    45         public PanelSectors(SmedAction dia) {
    46                 super(Messages.getString("SectorTable"));
    47                 dlg = dia;
    48                 setLayout(null);
    49                 setSize(900, 100);
    50                 setAlwaysOnTop(true);
    51                 setLocation(450, 0);
    52                 setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    53                 minusButton = new JButton(new ImageIcon(getClass().getResource("/images/MinusButton.png")));
    54                 minusButton.setBounds(0, 0, 32, 34);
    55                 minusButton.addActionListener(alMinusButton);
    56                 add(minusButton);
    57                 plusButton = new JButton(new ImageIcon(getClass().getResource("/images/PlusButton.png")));
    58                 plusButton.setBounds(0, 34, 32, 34);
    59                 plusButton.addActionListener(alPlusButton);
    60                 add(plusButton);
    61                 panel = new JPanel(new BorderLayout());
    62                 panel.setBounds(40, 0, 860, 512);
    63                 model = new SectorTable();
    64                 table = new JTable(model);
    65                 table.setBounds(0, 0, 860, 34);
    66                 table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    67                 panel.add(new JScrollPane(table));
    68                 getContentPane().add(panel);
    69 
    70                 table.setSize(860, ((table.getRowCount() * 16) + 28));
    71                
    72                 table.setDefaultRenderer(String.class, new CentreRenderer());
    73                 table.getColumnModel().getColumn(1).setCellRenderer(new ColourCellRenderer());
    74 
    75                 TableColumn colColumn = table.getColumnModel().getColumn(1);
    76                 colourBox = new JComboBox<>();
    77                 addColItem(new ImageIcon(getClass().getResource("/images/DelButton.png")), Col.UNKCOL);
    78                 addColItem(new ImageIcon(getClass().getResource("/images/WhiteButton.png")), Col.WHITE);
    79                 addColItem(new ImageIcon(getClass().getResource("/images/RedButton.png")), Col.RED);
    80                 addColItem(new ImageIcon(getClass().getResource("/images/GreenButton.png")), Col.GREEN);
    81                 addColItem(new ImageIcon(getClass().getResource("/images/YellowButton.png")), Col.YELLOW);
    82                 addColItem(new ImageIcon(getClass().getResource("/images/OrangeButton.png")), Col.ORANGE);
    83                 addColItem(new ImageIcon(getClass().getResource("/images/AmberButton.png")), Col.AMBER);
    84                 addColItem(new ImageIcon(getClass().getResource("/images/BlueButton.png")), Col.BLUE);
    85                 addColItem(new ImageIcon(getClass().getResource("/images/VioletButton.png")), Col.VIOLET);
    86                 colColumn.setCellEditor(new DefaultCellEditor(colourBox));
    87                
    88                 TableColumn visColumn = table.getColumnModel().getColumn(12);
    89                 visibilityBox = new JComboBox<>();
    90                 addVisibItem("", Vis.UNKVIS);
    91                 addVisibItem(Messages.getString("Intensified"), Vis.INTEN);
    92                 addVisibItem(Messages.getString("Unintensified"), Vis.UNINTEN);
    93                 addVisibItem(Messages.getString("PartiallyObscured"), Vis.PARTOBS);
    94                 visColumn.setCellEditor(new DefaultCellEditor(visibilityBox));
    95                
    96                 TableColumn exhColumn = table.getColumnModel().getColumn(13);
    97                 exhibitionBox = new JComboBox<>();
    98                 addExhibItem("", Exh.UNKEXH);
    99                 addExhibItem(Messages.getString("24h"), Exh.H24);
    100                 addExhibItem(Messages.getString("Day"), Exh.DAY);
    101                 addExhibItem(Messages.getString("Night"), Exh.NIGHT);
    102                 addExhibItem(Messages.getString("Fog"), Exh.FOG);
    103                 exhColumn.setCellEditor(new DefaultCellEditor(exhibitionBox));
    104         }
    105 
    106         private class SectorTable extends AbstractTableModel {
    107 
    108                 private String[] headings = { Messages.getString("Sector"), Messages.getString("Colour"), Messages.getString("Character"),
    109                                 Messages.getString("Group"), Messages.getString("Sequence"), Messages.getString("Period"), Messages.getString("Directional"),
    110                                 Messages.getString("Start"), Messages.getString("End"), Messages.getString("Radius"), Messages.getString("Height"),
    111                                 Messages.getString("Range"), Messages.getString("Visibility"), Messages.getString("Exhibition") };
    112 
    113                 public SectorTable() {
    114                 }
    115 
    116                 public String getColumnName(int col) {
    117                         return headings[col];
    118                 }
    119 
    120                 public int getColumnCount() {
    121                         return headings.length;
    122                 }
    123 
    124                 public int getRowCount() {
    125                         if (SmedAction.panelMain == null)
    126                                 return 1;
    127                         else
    128                                 return SmedAction.panelMain.mark.getSectorCount();
    129                 }
    130 
    131                 public boolean isCellEditable(int row, int col) {
    132                         return ((col > 0) && (row > 0));
    133                 }
    134 
    135                 public Class getColumnClass(int col) {
    136                         switch (col) {
    137                         case 1:
    138                                 return Col.class;
    139                         case 6:
    140                                 return Boolean.class;
    141                         default:
    142                                 return String.class;
    143                         }
    144                 }
    145 
    146                 public Object getValueAt(int row, int col) {
    147                         switch (col) {
    148                         case 0:
    149                                 if (row == 0)
    150                                         return Messages.getString("Default");
    151                                 else
    152                                         return row;
    153                         case 1:
    154                                 if (((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, row)).contains("Al")) {
    155                                         if (SmedAction.panelMain.mark.getLightAtt(Att.COL, row) == Col.UNKCOL) {
    156                                                 return Col.UNKCOL;
    157                                         } else {
    158                                                 return SmedAction.panelMain.mark.getLightAtt(Att.ALT, row);
    159                                         }
    160                                 } else {
    161                                         return SmedAction.panelMain.mark.getLightAtt(Att.COL, row);
    162                                 }
    163                         case 6:
    164                                 return (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR);
    165                         case 7:
    166                         case 8:
    167                                 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR)
    168                                         return SmedAction.panelMain.mark.getLightAtt(Att.ORT, row);
    169                                 else
    170                                         return SmedAction.panelMain.mark.getLightAtt(col - 1, row);
    171                         case 12:
    172                                 return visibilities.get(SmedAction.panelMain.mark.getLightAtt(Att.VIS, row));
    173                         case 13:
    174                                 return exhibitions.get(SmedAction.panelMain.mark.getLightAtt(Att.EXH, row));
    175                         default:
    176                                 return SmedAction.panelMain.mark.getLightAtt(col - 1, row);
    177                         }
    178                 }
    179 
    180                 public void setValueAt(Object value, int row, int col) {
    181                         switch (col) {
    182                         case 1:
    183                                 for (Col colour : colours.keySet()) {
    184                                         ImageIcon img = colours.get(colour);
    185                                         if (img == value)
    186                                                 if (((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, row)).contains("Al")) {
    187                                                         if (((colour == Col.UNKCOL) && (SmedAction.panelMain.mark.getLightAtt(Att.ALT, row) == Col.UNKCOL))
    188                                                                         || (SmedAction.panelMain.mark.getLightAtt(Att.COL, row) == Col.UNKCOL)) {
    189                                                                 SmedAction.panelMain.mark.setLightAtt(Att.COL, row, colour);
    190                                                         } else {
    191                                                                 SmedAction.panelMain.mark.setLightAtt(Att.ALT, row, colour);
    192                                                         }
    193                                                 } else {
    194                                                         SmedAction.panelMain.mark.setLightAtt(Att.COL, row, colour);
    195                                                 }
    196                                 }
    197                                 break;
    198                         case 5:
    199                         case 9:
    200                         case 10:
    201                         case 11:
    202                                 SmedAction.panelMain.mark.setLightAtt(col - 1, row, value);
    203                                 break;
    204                         case 6:
    205                                 if ((Boolean) value == true) {
    206                                         SmedAction.panelMain.mark.setLightAtt(Att.LIT, row, Lit.DIR);
    207                                         SmedAction.panelMain.mark.setLightAtt(Att.BEG, row, "");
    208                                         SmedAction.panelMain.mark.setLightAtt(Att.END, row, "");
    209                                 } else {
    210                                         SmedAction.panelMain.mark.setLightAtt(Att.LIT, row, Lit.UNKLIT);
    211                                         SmedAction.panelMain.mark.setLightAtt(Att.ORT, row, "");
    212                                 }
    213                                 break;
    214                         case 7:
    215                         case 8:
    216                                 if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR) {
    217                                         SmedAction.panelMain.mark.setLightAtt(Att.ORT, row, value);
    218                                 } else {
    219                                         SmedAction.panelMain.mark.setLightAtt(col - 1, row, value);
    220                                 }
    221                                 break;
    222                         case 12:
    223                                 for (Vis vis : visibilities.keySet()) {
    224                                         String str = visibilities.get(vis);
    225                                         if (str.equals(value))
    226                                                 SmedAction.panelMain.mark.setLightAtt(Att.VIS, row, vis);
    227                                 }
    228                                 break;
    229                         case 13:
    230                                 for (Exh exh : exhibitions.keySet()) {
    231                                         String str = exhibitions.get(exh);
    232                                         if (str.equals(value))
    233                                                 SmedAction.panelMain.mark.setLightAtt(Att.EXH, row, exh);
    234                                 }
    235                                 break;
    236                         default:
    237                                 SmedAction.panelMain.mark.setLightAtt(col - 1, row, value);
    238                         }
    239                 }
    240         }
    241 
    242         static class CentreRenderer extends DefaultTableCellRenderer {
    243                 public CentreRenderer() {
    244                         super();
    245                         setHorizontalAlignment(SwingConstants.CENTER);
    246                 }
    247         }
    248 
    249         public class ColourCellRenderer extends JPanel implements TableCellRenderer {
    250                 private JLabel col1Label;
    251                 private JLabel col2Label;
    252                 public ColourCellRenderer() {
    253                         super();
    254                         setLayout(new GridLayout(1, 2, 0, 0));
    255                         col1Label = new JLabel();
    256                         col1Label.setOpaque(true);
    257                         add(col1Label);
    258                         col2Label = new JLabel();
    259                         col2Label.setOpaque(true);
    260                         add(col2Label);
    261                 }
    262                 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
    263                         if (!((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, rowIndex)).contains("Al")) {
    264                                 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, rowIndex)));
    265                         } else {
    266                                 col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, rowIndex)));
    267                         }
    268                         col1Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, rowIndex)));
    269                         return this;
    270                 }
    271         }
    272 
    273         public int getSectorCount() {
    274                 return model.getRowCount();
    275         }
    276 
    277         public void addSector(int idx) {
    278                 SmedAction.panelMain.mark.addLight(idx);
    279                 table.setSize(860, ((table.getRowCount() * 16) + 28));
    280                 if (table.getRowCount() > 3) {
    281                         setSize(900, ((table.getRowCount() * 16) + 48));
    282                 } else {
    283                         setSize(900, 100);
    284                 }
    285         }
    286 
    287         public void deleteSector(int idx) {
    288                 if (idx > 0) {
    289                         SmedAction.panelMain.mark.delLight(idx);
    290                         table.setSize(860, ((table.getRowCount() * 16) + 28));
    291                         if (table.getRowCount() > 3) {
    292                                 setSize(900, ((table.getRowCount() * 16) + 48));
    293                         } else {
    294                                 setSize(900, 100);
    295                         }
    296                 }
    297         }
    298        
    299         public void syncPanel() {
    300                 table.updateUI();
    301                 table.setSize(860, ((table.getRowCount() * 16) + 28));
    302                 if (table.getRowCount() > 3) {
    303                         setSize(900, ((table.getRowCount() * 16) + 48));
    304                 } else {
    305                         setSize(900, 100);
    306                 }
    307         }
    308 
    309         private void addColItem(ImageIcon img, Col col) {
    310                 colours.put(col, img);
    311                 colourBox.addItem(img);
    312         }
    313 
    314         private void addVisibItem(String str, Vis vis) {
    315                 visibilities.put(vis, str);
    316                 visibilityBox.addItem(str);
    317         }
    318 
    319         private void addExhibItem(String str, Exh exh) {
    320                 exhibitions.put(exh, str);
    321                 exhibitionBox.addItem(str);
    322         }
     37    private SmedAction dlg;
     38    private JPanel panel;
     39    private TableModel model;
     40    private JTable table;
     41
     42    public JButton minusButton;
     43    private ActionListener alMinusButton = new ActionListener() {
     44        @Override
     45        public void actionPerformed(ActionEvent e) {
     46            if ((getSectorCount() > 1) && (table.getSelectedRow() != 0)) {
     47                deleteSector(table.getSelectedRow());
     48            }
     49        }
     50    };
     51    public JButton plusButton;
     52    private ActionListener alPlusButton = new ActionListener() {
     53        @Override
     54        public void actionPerformed(ActionEvent e) {
     55            if (table.getSelectedRow() < 0) {
     56                addSector(table.getRowCount());
     57            } else {
     58                addSector(table.getSelectedRow()+1);
     59            }
     60        }
     61    };
     62    public JComboBox<ImageIcon> colourBox;
     63    public EnumMap<Col, ImageIcon> colours = new EnumMap<>(Col.class);
     64    public JComboBox<String> visibilityBox;
     65    public EnumMap<Vis, String> visibilities = new EnumMap<>(Vis.class);
     66    public JComboBox<String> exhibitionBox;
     67    public EnumMap<Exh, String> exhibitions = new EnumMap<>(Exh.class);
     68
     69    public PanelSectors(SmedAction dia) {
     70        super(Messages.getString("SectorTable"));
     71        dlg = dia;
     72        setLayout(null);
     73        setSize(900, 100);
     74        setAlwaysOnTop(true);
     75        setLocation(450, 0);
     76        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
     77        minusButton = new JButton(new ImageIcon(getClass().getResource("/images/MinusButton.png")));
     78        minusButton.setBounds(0, 0, 32, 34);
     79        minusButton.addActionListener(alMinusButton);
     80        add(minusButton);
     81        plusButton = new JButton(new ImageIcon(getClass().getResource("/images/PlusButton.png")));
     82        plusButton.setBounds(0, 34, 32, 34);
     83        plusButton.addActionListener(alPlusButton);
     84        add(plusButton);
     85        panel = new JPanel(new BorderLayout());
     86        panel.setBounds(40, 0, 860, 512);
     87        model = new SectorTable();
     88        table = new JTable(model);
     89        table.setBounds(0, 0, 860, 34);
     90        table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
     91        panel.add(new JScrollPane(table));
     92        getContentPane().add(panel);
     93
     94        table.setSize(860, ((table.getRowCount() * 16) + 28));
     95
     96        table.setDefaultRenderer(String.class, new CentreRenderer());
     97        table.getColumnModel().getColumn(1).setCellRenderer(new ColourCellRenderer());
     98
     99        TableColumn colColumn = table.getColumnModel().getColumn(1);
     100        colourBox = new JComboBox<>();
     101        addColItem(new ImageIcon(getClass().getResource("/images/DelButton.png")), Col.UNKCOL);
     102        addColItem(new ImageIcon(getClass().getResource("/images/WhiteButton.png")), Col.WHITE);
     103        addColItem(new ImageIcon(getClass().getResource("/images/RedButton.png")), Col.RED);
     104        addColItem(new ImageIcon(getClass().getResource("/images/GreenButton.png")), Col.GREEN);
     105        addColItem(new ImageIcon(getClass().getResource("/images/YellowButton.png")), Col.YELLOW);
     106        addColItem(new ImageIcon(getClass().getResource("/images/OrangeButton.png")), Col.ORANGE);
     107        addColItem(new ImageIcon(getClass().getResource("/images/AmberButton.png")), Col.AMBER);
     108        addColItem(new ImageIcon(getClass().getResource("/images/BlueButton.png")), Col.BLUE);
     109        addColItem(new ImageIcon(getClass().getResource("/images/VioletButton.png")), Col.VIOLET);
     110        colColumn.setCellEditor(new DefaultCellEditor(colourBox));
     111
     112        TableColumn visColumn = table.getColumnModel().getColumn(12);
     113        visibilityBox = new JComboBox<>();
     114        addVisibItem("", Vis.UNKVIS);
     115        addVisibItem(Messages.getString("Intensified"), Vis.INTEN);
     116        addVisibItem(Messages.getString("Unintensified"), Vis.UNINTEN);
     117        addVisibItem(Messages.getString("PartiallyObscured"), Vis.PARTOBS);
     118        visColumn.setCellEditor(new DefaultCellEditor(visibilityBox));
     119
     120        TableColumn exhColumn = table.getColumnModel().getColumn(13);
     121        exhibitionBox = new JComboBox<>();
     122        addExhibItem("", Exh.UNKEXH);
     123        addExhibItem(Messages.getString("24h"), Exh.H24);
     124        addExhibItem(Messages.getString("Day"), Exh.DAY);
     125        addExhibItem(Messages.getString("Night"), Exh.NIGHT);
     126        addExhibItem(Messages.getString("Fog"), Exh.FOG);
     127        exhColumn.setCellEditor(new DefaultCellEditor(exhibitionBox));
     128    }
     129
     130    private class SectorTable extends AbstractTableModel {
     131
     132        private String[] headings = { Messages.getString("Sector"), Messages.getString("Colour"), Messages.getString("Character"),
     133                Messages.getString("Group"), Messages.getString("Sequence"), Messages.getString("Period"), Messages.getString("Directional"),
     134                Messages.getString("Start"), Messages.getString("End"), Messages.getString("Radius"), Messages.getString("Height"),
     135                Messages.getString("Range"), Messages.getString("Visibility"), Messages.getString("Exhibition") };
     136
     137        public SectorTable() {
     138        }
     139
     140        @Override
     141        public String getColumnName(int col) {
     142            return headings[col];
     143        }
     144
     145        @Override
     146        public int getColumnCount() {
     147            return headings.length;
     148        }
     149
     150        @Override
     151        public int getRowCount() {
     152            if (SmedAction.panelMain == null)
     153                return 1;
     154            else
     155                return SmedAction.panelMain.mark.getSectorCount();
     156        }
     157
     158        @Override
     159        public boolean isCellEditable(int row, int col) {
     160            return ((col > 0) && (row > 0));
     161        }
     162
     163        @Override
     164        public Class getColumnClass(int col) {
     165            switch (col) {
     166            case 1:
     167                return Col.class;
     168            case 6:
     169                return Boolean.class;
     170            default:
     171                return String.class;
     172            }
     173        }
     174
     175        @Override
     176        public Object getValueAt(int row, int col) {
     177            switch (col) {
     178            case 0:
     179                if (row == 0)
     180                    return Messages.getString("Default");
     181                else
     182                    return row;
     183            case 1:
     184                if (((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, row)).contains("Al")) {
     185                    if (SmedAction.panelMain.mark.getLightAtt(Att.COL, row) == Col.UNKCOL)
     186                        return Col.UNKCOL;
     187                    else
     188                        return SmedAction.panelMain.mark.getLightAtt(Att.ALT, row);
     189                } else
     190                    return SmedAction.panelMain.mark.getLightAtt(Att.COL, row);
     191            case 6:
     192                return (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR);
     193            case 7:
     194            case 8:
     195                if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR)
     196                    return SmedAction.panelMain.mark.getLightAtt(Att.ORT, row);
     197                else
     198                    return SmedAction.panelMain.mark.getLightAtt(col - 1, row);
     199            case 12:
     200                return visibilities.get(SmedAction.panelMain.mark.getLightAtt(Att.VIS, row));
     201            case 13:
     202                return exhibitions.get(SmedAction.panelMain.mark.getLightAtt(Att.EXH, row));
     203            default:
     204                return SmedAction.panelMain.mark.getLightAtt(col - 1, row);
     205            }
     206        }
     207
     208        @Override
     209        public void setValueAt(Object value, int row, int col) {
     210            switch (col) {
     211            case 1:
     212                for (Col colour : colours.keySet()) {
     213                    ImageIcon img = colours.get(colour);
     214                    if (img == value)
     215                        if (((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, row)).contains("Al")) {
     216                            if (((colour == Col.UNKCOL) && (SmedAction.panelMain.mark.getLightAtt(Att.ALT, row) == Col.UNKCOL))
     217                                    || (SmedAction.panelMain.mark.getLightAtt(Att.COL, row) == Col.UNKCOL)) {
     218                                SmedAction.panelMain.mark.setLightAtt(Att.COL, row, colour);
     219                            } else {
     220                                SmedAction.panelMain.mark.setLightAtt(Att.ALT, row, colour);
     221                            }
     222                        } else {
     223                            SmedAction.panelMain.mark.setLightAtt(Att.COL, row, colour);
     224                        }
     225                }
     226                break;
     227            case 5:
     228            case 9:
     229            case 10:
     230            case 11:
     231                SmedAction.panelMain.mark.setLightAtt(col - 1, row, value);
     232                break;
     233            case 6:
     234                if ((Boolean) value == true) {
     235                    SmedAction.panelMain.mark.setLightAtt(Att.LIT, row, Lit.DIR);
     236                    SmedAction.panelMain.mark.setLightAtt(Att.BEG, row, "");
     237                    SmedAction.panelMain.mark.setLightAtt(Att.END, row, "");
     238                } else {
     239                    SmedAction.panelMain.mark.setLightAtt(Att.LIT, row, Lit.UNKLIT);
     240                    SmedAction.panelMain.mark.setLightAtt(Att.ORT, row, "");
     241                }
     242                break;
     243            case 7:
     244            case 8:
     245                if (SmedAction.panelMain.mark.getLightAtt(Att.LIT, row) == Lit.DIR) {
     246                    SmedAction.panelMain.mark.setLightAtt(Att.ORT, row, value);
     247                } else {
     248                    SmedAction.panelMain.mark.setLightAtt(col - 1, row, value);
     249                }
     250                break;
     251            case 12:
     252                for (Vis vis : visibilities.keySet()) {
     253                    String str = visibilities.get(vis);
     254                    if (str.equals(value)) {
     255                        SmedAction.panelMain.mark.setLightAtt(Att.VIS, row, vis);
     256                    }
     257                }
     258                break;
     259            case 13:
     260                for (Exh exh : exhibitions.keySet()) {
     261                    String str = exhibitions.get(exh);
     262                    if (str.equals(value)) {
     263                        SmedAction.panelMain.mark.setLightAtt(Att.EXH, row, exh);
     264                    }
     265                }
     266                break;
     267            default:
     268                SmedAction.panelMain.mark.setLightAtt(col - 1, row, value);
     269            }
     270        }
     271    }
     272
     273    static class CentreRenderer extends DefaultTableCellRenderer {
     274        public CentreRenderer() {
     275            super();
     276            setHorizontalAlignment(SwingConstants.CENTER);
     277        }
     278    }
     279
     280    public class ColourCellRenderer extends JPanel implements TableCellRenderer {
     281        private JLabel col1Label;
     282        private JLabel col2Label;
     283        public ColourCellRenderer() {
     284            super();
     285            setLayout(new GridLayout(1, 2, 0, 0));
     286            col1Label = new JLabel();
     287            col1Label.setOpaque(true);
     288            add(col1Label);
     289            col2Label = new JLabel();
     290            col2Label.setOpaque(true);
     291            add(col2Label);
     292        }
     293        @Override
     294        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
     295            if (!((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, rowIndex)).contains("Al")) {
     296                col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, rowIndex)));
     297            } else {
     298                col2Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.ALT, rowIndex)));
     299            }
     300            col1Label.setBackground(SeaMark.ColMAP.get(SmedAction.panelMain.mark.getLightAtt(Att.COL, rowIndex)));
     301            return this;
     302        }
     303    }
     304
     305    public int getSectorCount() {
     306        return model.getRowCount();
     307    }
     308
     309    public void addSector(int idx) {
     310        SmedAction.panelMain.mark.addLight(idx);
     311        table.setSize(860, ((table.getRowCount() * 16) + 28));
     312        if (table.getRowCount() > 3) {
     313            setSize(900, ((table.getRowCount() * 16) + 48));
     314        } else {
     315            setSize(900, 100);
     316        }
     317    }
     318
     319    public void deleteSector(int idx) {
     320        if (idx > 0) {
     321            SmedAction.panelMain.mark.delLight(idx);
     322            table.setSize(860, ((table.getRowCount() * 16) + 28));
     323            if (table.getRowCount() > 3) {
     324                setSize(900, ((table.getRowCount() * 16) + 48));
     325            } else {
     326                setSize(900, 100);
     327            }
     328        }
     329    }
     330
     331    public void syncPanel() {
     332        table.updateUI();
     333        table.setSize(860, ((table.getRowCount() * 16) + 28));
     334        if (table.getRowCount() > 3) {
     335            setSize(900, ((table.getRowCount() * 16) + 48));
     336        } else {
     337            setSize(900, 100);
     338        }
     339    }
     340
     341    private void addColItem(ImageIcon img, Col col) {
     342        colours.put(col, img);
     343        colourBox.addItem(img);
     344    }
     345
     346    private void addVisibItem(String str, Vis vis) {
     347        visibilities.put(vis, str);
     348        visibilityBox.addItem(str);
     349    }
     350
     351    private void addExhibItem(String str, Exh exh) {
     352        exhibitions.put(exh, str);
     353        exhibitionBox.addItem(str);
     354    }
    323355
    324356}
  • applications/editors/josm/plugins/smed/src/panels/PanelSpec.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.*;
    4 import java.awt.event.*;
    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.util.EnumMap;
     7
     8import javax.swing.BorderFactory;
     9import javax.swing.ButtonGroup;
     10import javax.swing.ImageIcon;
     11import javax.swing.JComboBox;
     12import javax.swing.JLabel;
     13import javax.swing.JPanel;
     14import javax.swing.JRadioButton;
     15import javax.swing.JToggleButton;
     16import javax.swing.SwingConstants;
    917
    1018import messages.Messages;
     19import seamarks.SeaMark;
     20import seamarks.SeaMark.Cat;
     21import seamarks.SeaMark.Col;
     22import seamarks.SeaMark.Ent;
     23import seamarks.SeaMark.Obj;
     24import seamarks.SeaMark.Pat;
     25import seamarks.SeaMark.Shp;
     26import seamarks.SeaMark.Top;
    1127import smed.SmedAction;
    12 import seamarks.SeaMark;
    13 import seamarks.SeaMark.*;
    1428
    1529public class PanelSpec extends JPanel {
    1630
    17         private SmedAction dlg;
    18         public JLabel categoryLabel;
    19         public JComboBox<String> categoryBox;
    20         public EnumMap<Cat, Integer> categories = new EnumMap<>(Cat.class);
    21         private ActionListener alCategoryBox = new ActionListener() {
    22                 public void actionPerformed(java.awt.event.ActionEvent e) {
    23                         for (Cat cat : categories.keySet()) {
    24                                 int idx = categories.get(cat);
    25                                 if (dlg.node != null && (idx == categoryBox.getSelectedIndex()))
    26                                         SmedAction.panelMain.mark.setCategory(cat);
    27                         }
    28                 }
    29         };
    30         public JComboBox<String> mooringBox;
    31         public EnumMap<Cat, Integer> moorings = new EnumMap<>(Cat.class);
    32         private ActionListener alMooringBox = new ActionListener() {
    33                 public void actionPerformed(java.awt.event.ActionEvent e) {
    34                         for (Cat cat : moorings.keySet()) {
    35                                 int idx = moorings.get(cat);
    36                                 if (dlg.node != null && (idx == mooringBox.getSelectedIndex())) {
    37                                         SmedAction.panelMain.mark.setCategory(cat);
    38                                         if ((cat == Cat.INB_CALM) || (cat == Cat.INB_SBM)) {
    39                                                 SmedAction.panelMain.mark.setObject(Obj.BOYINB);
    40                                                 SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
    41                                         } else {
    42                                                 SmedAction.panelMain.mark.setObject(Obj.MORFAC);
    43                                                 if (cat != Cat.MOR_BUOY)
    44                                                         SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
    45                                         }
    46                                 }
    47                         }
    48                         if (dlg.node != null) syncPanel();
    49                 }
    50         };
    51         public ButtonGroup shapeButtons = new ButtonGroup();
    52         public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
    53         public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
    54         public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png")));
    55         public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png")));
    56         public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
    57         public JRadioButton barrelButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BarrelButton.png")));
    58         public JRadioButton superButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SuperButton.png")));
    59         public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
    60         public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
    61         public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png")));
    62         public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png")));
    63         public JRadioButton cairnButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CairnButton.png")));
    64         public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
    65         public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class);
    66         public ActionListener alShape = new ActionListener() {
    67                 public void actionPerformed(java.awt.event.ActionEvent e) {
    68                         if ((SmedAction.panelMain.mark.getObject() != Obj.MORFAC) || (SmedAction.panelMain.mark.getCategory() == Cat.MOR_BUOY)) {
    69                                 for (Shp shp : shapes.keySet()) {
    70                                         JRadioButton button = shapes.get(shp);
    71                                         if (button.isSelected()) {
    72                                                 SmedAction.panelMain.mark.setShape(shp);
    73                                                 if (SeaMark.EntMAP.get(SmedAction.panelMain.mark.getObject()) != Ent.MOORING) {
    74                                                         SmedAction.panelMain.mark.setObject(objects.get(shp));
    75                                                         if (SmedAction.panelMain.mark.getObjColour(0) == Col.UNKCOL) {
    76                                                                 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
    77                                                                 SmedAction.panelMain.mark.setObjColour(Col.YELLOW);
    78                                                         }
    79                                                         if (button == cairnButton) {
    80                                                                 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
    81                                                                 SmedAction.panelMain.mark.setObjColour(Col.UNKCOL);
    82                                                         }
    83                                                         topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
    84                                                 }
    85                                                 button.setBorderPainted(true);
    86                                         } else
    87                                                 button.setBorderPainted(false);
    88                                 }
    89                                 SmedAction.panelMain.panelMore.syncPanel();
    90                         }
    91                 }
    92         };
    93         public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/SpecTopButton.png")));
    94         private ActionListener alTop = new ActionListener() {
    95                 public void actionPerformed(java.awt.event.ActionEvent e) {
    96                         if (topmarkButton.isSelected()) {
    97                                 SmedAction.panelMain.mark.setTopmark(Top.X_SHAPE);
    98                                 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
    99                                 SmedAction.panelMain.mark.setTopColour(Col.YELLOW);
    100                                 topmarkButton.setBorderPainted(true);
    101                         } else {
    102                                 SmedAction.panelMain.mark.setTopmark(Top.NOTOP);
    103                                 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
    104                                 SmedAction.panelMain.mark.setTopColour(Col.UNKCOL);
    105                                 topmarkButton.setBorderPainted(false);
    106                         }
    107                         SmedAction.panelMain.panelTop.syncPanel();
    108                 }
    109         };
    110         public JToggleButton noticeButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/NoticeButton.png")));
    111         private ActionListener alNotice = new ActionListener() {
    112                 public void actionPerformed(java.awt.event.ActionEvent e) {
    113                         SmedAction.panelMain.mark.clrMark();
    114                         if (noticeButton.isSelected()) {
    115                                 SmedAction.panelMain.mark.setObject(Obj.NOTMRK);
    116                                 noticeButton.setBorderPainted(true);
    117                         } else {
    118                                 SmedAction.panelMain.mark.setObject(Obj.UNKOBJ);
    119                                 noticeButton.setBorderPainted(false);
    120                         }
    121                         SmedAction.panelMain.syncPanel();
    122                 }
    123         };
    124         public JToggleButton mooringButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/MooringButton.png")));
    125         private ActionListener alMooring = new ActionListener() {
    126                 public void actionPerformed(java.awt.event.ActionEvent e) {
    127                         SmedAction.panelMain.mark.setObject(Obj.UNKOBJ);
    128                         SmedAction.panelMain.mark.setCategory(Cat.NOCAT);
    129                         SmedAction.panelMain.mark.setTopmark(Top.NOTOP);
    130                         if (mooringButton.isSelected()) {
    131                                 SmedAction.panelMain.mark.setObject(Obj.MORFAC);
    132                                 categoryBox.setVisible(false);
    133                                 mooringBox.setVisible(true);
    134                                 pillarButton.setEnabled(false);
    135                                 sparButton.setEnabled(false);
    136                                 beaconButton.setEnabled(false);
    137                                 towerButton.setEnabled(false);
    138                                 stakeButton.setEnabled(false);
    139                                 cairnButton.setEnabled(false);
    140                                 mooringButton.setBorderPainted(true);
    141                         } else {
    142                                 mooringBox.setVisible(false);
    143                                 categoryBox.setVisible(true);
    144                                 pillarButton.setEnabled(true);
    145                                 sparButton.setEnabled(true);
    146                                 beaconButton.setEnabled(true);
    147                                 towerButton.setEnabled(true);
    148                                 stakeButton.setEnabled(true);
    149                                 cairnButton.setEnabled(true);
    150                                 mooringButton.setBorderPainted(false);
    151                         }
    152                         syncPanel();
    153                 }
    154         };
    155 
    156         public PanelSpec(SmedAction dia) {
    157                 dlg = dia;
    158                 setLayout(null);
    159                 add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSPP));
    160                 add(getShapeButton(sparButton, 34, 0, 34, 32, "Spar", Shp.SPAR, Obj.BOYSPP));
    161                 add(getShapeButton(canButton, 68, 0, 34, 32, "Can", Shp.CAN, Obj.BOYSPP));
    162                 add(getShapeButton(coneButton, 102, 0, 34, 32, "Cone", Shp.CONI, Obj.BOYSPP));
    163                 add(getShapeButton(sphereButton, 0, 32, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSPP));
    164                 add(getShapeButton(barrelButton, 34, 32, 34, 32, "Barrel", Shp.BARREL, Obj.BOYSPP));
    165                 add(getShapeButton(superButton, 68, 32, 34, 32, "Super", Shp.SUPER, Obj.BOYSPP));
    166                 add(getShapeButton(floatButton, 102, 32, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT));
    167                 add(getShapeButton(beaconButton, 0, 64, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSPP));
    168                 add(getShapeButton(towerButton, 34, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNSPP));
    169                 add(getShapeButton(stakeButton, 68, 64, 34, 32, "Stake", Shp.STAKE, Obj.BCNSPP));
    170                 add(getShapeButton(cairnButton, 102, 64, 34, 32, "CairnB", Shp.CAIRN, Obj.BCNSPP));
    171 
    172                 categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER);
    173                 categoryLabel.setBounds(new Rectangle(5, 125, 160, 18));
    174                 add(categoryLabel);
    175                 categoryBox = new JComboBox<>();
    176                 categoryBox.setBounds(new Rectangle(5, 142, 160, 18));
    177                 add(categoryBox);
    178                 categoryBox.setVisible(true);
    179                 categoryBox.addActionListener(alCategoryBox);
    180                 addCatItem("", Cat.NOCAT);
    181                 addCatItem(Messages.getString("UKPurpose"), Cat.SPM_UNKN);
    182                 addCatItem(Messages.getString("Warning"), Cat.SPM_WARN);
    183                 addCatItem(Messages.getString("ChanSeparation"), Cat.SPM_CHBF);
    184                 addCatItem(Messages.getString("Yachting"), Cat.SPM_YCHT);
    185                 addCatItem(Messages.getString("Cable"), Cat.SPM_CABL);
    186                 addCatItem(Messages.getString("Outfall"), Cat.SPM_OFAL);
    187                 addCatItem(Messages.getString("ODAS"), Cat.SPM_ODAS);
    188                 addCatItem(Messages.getString("RecreationZone"), Cat.SPM_RECN);
    189                 addCatItem(Messages.getString("Mooring"), Cat.SPM_MOOR);
    190                 addCatItem(Messages.getString("LANBY"), Cat.SPM_LNBY);
    191                 addCatItem(Messages.getString("Leading"), Cat.SPM_LDNG);
    192                 addCatItem(Messages.getString("Notice"), Cat.SPM_NOTC);
    193                 addCatItem(Messages.getString("TSS"), Cat.SPM_TSS);
    194                 addCatItem(Messages.getString("FoulGround"), Cat.SPM_FOUL);
    195                 addCatItem(Messages.getString("Diving"), Cat.SPM_DIVE);
    196                 addCatItem(Messages.getString("FerryCross"), Cat.SPM_FRRY);
    197                 addCatItem(Messages.getString("Anchorage"), Cat.SPM_ANCH);
    198                 mooringBox = new JComboBox<>();
    199                 mooringBox.setBounds(new Rectangle(5, 142, 160, 18));
    200                 add(mooringBox);
    201                 mooringBox.setVisible(false);
    202                 mooringBox.addActionListener(alMooringBox);
    203                 addMorItem("", Cat.NOCAT);
    204                 addMorItem(Messages.getString("Dolphin"), Cat.MOR_DLPN);
    205                 addMorItem(Messages.getString("DevDolphin"), Cat.MOR_DDPN);
    206                 addMorItem(Messages.getString("Bollard"), Cat.MOR_BLRD);
    207                 addMorItem(Messages.getString("Wall"), Cat.MOR_WALL);
    208                 addMorItem(Messages.getString("Post"), Cat.MOR_POST);
    209                 addMorItem(Messages.getString("Chain"), Cat.MOR_CHWR);
    210                 addMorItem(Messages.getString("Rope"), Cat.MOR_ROPE);
    211                 addMorItem(Messages.getString("Automatic"), Cat.MOR_AUTO);
    212                 addMorItem(Messages.getString("MooringBuoy"), Cat.MOR_BUOY);
    213                 addMorItem(Messages.getString("CALM"), Cat.INB_CALM);
    214                 addMorItem(Messages.getString("SBM"), Cat.INB_SBM);
    215 
    216                 topmarkButton.setBounds(new Rectangle(136, 0, 34, 32));
    217                 topmarkButton.setToolTipText(Messages.getString("Topmark"));
    218                 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder());
    219                 topmarkButton.addActionListener(alTop);
    220                 add(topmarkButton);
    221 
    222 //              noticeButton.setBounds(new Rectangle(136, 32, 34, 32));
    223 //              noticeButton.setToolTipText(Messages.getString("Notice"));
    224 //              noticeButton.setBorder(BorderFactory.createLoweredBevelBorder());
    225 //              noticeButton.addActionListener(alNotice);
    226 //              add(noticeButton);
    227 
    228                 mooringButton.setBounds(new Rectangle(136, 64, 34, 32));
    229                 mooringButton.setToolTipText(Messages.getString("Mooring"));
    230                 mooringButton.setBorder(BorderFactory.createLoweredBevelBorder());
    231                 mooringButton.addActionListener(alMooring);
    232                 add(mooringButton);
    233         }
    234 
    235         public void syncPanel() {
    236                 if (SeaMark.EntMAP.get(SmedAction.panelMain.mark.getObject()) == Ent.MOORING) {
    237                         mooringButton.setBorderPainted(true);
    238                         categoryBox.setVisible(false);
    239                         mooringBox.setVisible(true);
    240                         pillarButton.setEnabled(false);
    241                         sparButton.setEnabled(false);
    242                         beaconButton.setEnabled(false);
    243                         towerButton.setEnabled(false);
    244                         stakeButton.setEnabled(false);
    245                         cairnButton.setEnabled(false);
    246                         noticeButton.setEnabled(false);
    247                         topmarkButton.setVisible(false);
    248                         for (Cat cat : moorings.keySet()) {
    249                                 int item = moorings.get(cat);
    250                                 if (SmedAction.panelMain.mark.getCategory() == cat)
    251                                         mooringBox.setSelectedIndex(item);
    252                         }
    253                 } else {
    254                         mooringButton.setBorderPainted(false);
    255                         mooringBox.setVisible(false);
    256                         categoryBox.setVisible(true);
    257                         pillarButton.setEnabled(true);
    258                         sparButton.setEnabled(true);
    259                         beaconButton.setEnabled(true);
    260                         towerButton.setEnabled(true);
    261                         stakeButton.setEnabled(true);
    262                         cairnButton.setEnabled(true);
    263                         noticeButton.setEnabled(true);
    264                         topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP);
    265                         topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP);
    266                         topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
    267                         for (Cat cat : categories.keySet()) {
    268                                 int item = categories.get(cat);
    269                                 if (SmedAction.panelMain.mark.getCategory() == cat)
    270                                         categoryBox.setSelectedIndex(item);
    271                         }
    272                 }
    273                 for (Shp shp : shapes.keySet()) {
    274                         JRadioButton button = shapes.get(shp);
    275                         if (SmedAction.panelMain.mark.getShape() == shp) {
    276                                 button.setBorderPainted(true);
    277                         } else
    278                                 button.setBorderPainted(false);
    279                 }
    280                 noticeButton.setBorderPainted(false);
    281                 SmedAction.panelMain.mark.testValid();
    282         }
    283 
    284         private void addCatItem(String str, Cat cat) {
    285                 categories.put(cat, categoryBox.getItemCount());
    286                 categoryBox.addItem(str);
    287         }
    288 
    289         private void addMorItem(String str, Cat cat) {
    290                 moorings.put(cat, mooringBox.getItemCount());
    291                 mooringBox.addItem(str);
    292         }
    293 
    294         private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
    295                 button.setBounds(new Rectangle(x, y, w, h));
    296                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    297                 button.setToolTipText(Messages.getString(tip));
    298                 button.addActionListener(alShape);
    299                 shapeButtons.add(button);
    300                 shapes.put(shp, button);
    301                 objects.put(shp, obj);
    302                 return button;
    303         }
     31    private SmedAction dlg;
     32    public JLabel categoryLabel;
     33    public JComboBox<String> categoryBox;
     34    public EnumMap<Cat, Integer> categories = new EnumMap<>(Cat.class);
     35    private ActionListener alCategoryBox = new ActionListener() {
     36        @Override
     37        public void actionPerformed(ActionEvent e) {
     38            for (Cat cat : categories.keySet()) {
     39                int idx = categories.get(cat);
     40                if (dlg.node != null && (idx == categoryBox.getSelectedIndex())) {
     41                    SmedAction.panelMain.mark.setCategory(cat);
     42                }
     43            }
     44        }
     45    };
     46    public JComboBox<String> mooringBox;
     47    public EnumMap<Cat, Integer> moorings = new EnumMap<>(Cat.class);
     48    private ActionListener alMooringBox = new ActionListener() {
     49        @Override
     50        public void actionPerformed(ActionEvent e) {
     51            for (Cat cat : moorings.keySet()) {
     52                int idx = moorings.get(cat);
     53                if (dlg.node != null && (idx == mooringBox.getSelectedIndex())) {
     54                    SmedAction.panelMain.mark.setCategory(cat);
     55                    if ((cat == Cat.INB_CALM) || (cat == Cat.INB_SBM)) {
     56                        SmedAction.panelMain.mark.setObject(Obj.BOYINB);
     57                        SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
     58                    } else {
     59                        SmedAction.panelMain.mark.setObject(Obj.MORFAC);
     60                        if (cat != Cat.MOR_BUOY) {
     61                            SmedAction.panelMain.mark.setShape(Shp.UNKSHP);
     62                        }
     63                    }
     64                }
     65            }
     66            if (dlg.node != null) {
     67                syncPanel();
     68            }
     69        }
     70    };
     71    public ButtonGroup shapeButtons = new ButtonGroup();
     72    public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
     73    public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
     74    public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png")));
     75    public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png")));
     76    public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
     77    public JRadioButton barrelButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BarrelButton.png")));
     78    public JRadioButton superButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SuperButton.png")));
     79    public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
     80    public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
     81    public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png")));
     82    public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png")));
     83    public JRadioButton cairnButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CairnButton.png")));
     84    public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
     85    public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class);
     86    public ActionListener alShape = new ActionListener() {
     87        @Override
     88        public void actionPerformed(ActionEvent e) {
     89            if ((SmedAction.panelMain.mark.getObject() != Obj.MORFAC) || (SmedAction.panelMain.mark.getCategory() == Cat.MOR_BUOY)) {
     90                for (Shp shp : shapes.keySet()) {
     91                    JRadioButton button = shapes.get(shp);
     92                    if (button.isSelected()) {
     93                        SmedAction.panelMain.mark.setShape(shp);
     94                        if (SeaMark.EntMAP.get(SmedAction.panelMain.mark.getObject()) != Ent.MOORING) {
     95                            SmedAction.panelMain.mark.setObject(objects.get(shp));
     96                            if (SmedAction.panelMain.mark.getObjColour(0) == Col.UNKCOL) {
     97                                SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
     98                                SmedAction.panelMain.mark.setObjColour(Col.YELLOW);
     99                            }
     100                            if (button == cairnButton) {
     101                                SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
     102                                SmedAction.panelMain.mark.setObjColour(Col.UNKCOL);
     103                            }
     104                            topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
     105                        }
     106                        button.setBorderPainted(true);
     107                    } else {
     108                        button.setBorderPainted(false);
     109                    }
     110                }
     111                SmedAction.panelMain.panelMore.syncPanel();
     112            }
     113        }
     114    };
     115    public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/SpecTopButton.png")));
     116    private ActionListener alTop = new ActionListener() {
     117        @Override
     118        public void actionPerformed(ActionEvent e) {
     119            if (topmarkButton.isSelected()) {
     120                SmedAction.panelMain.mark.setTopmark(Top.X_SHAPE);
     121                SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
     122                SmedAction.panelMain.mark.setTopColour(Col.YELLOW);
     123                topmarkButton.setBorderPainted(true);
     124            } else {
     125                SmedAction.panelMain.mark.setTopmark(Top.NOTOP);
     126                SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT);
     127                SmedAction.panelMain.mark.setTopColour(Col.UNKCOL);
     128                topmarkButton.setBorderPainted(false);
     129            }
     130            SmedAction.panelMain.panelTop.syncPanel();
     131        }
     132    };
     133    public JToggleButton noticeButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/NoticeButton.png")));
     134    private ActionListener alNotice = new ActionListener() {
     135        @Override
     136        public void actionPerformed(ActionEvent e) {
     137            SmedAction.panelMain.mark.clrMark();
     138            if (noticeButton.isSelected()) {
     139                SmedAction.panelMain.mark.setObject(Obj.NOTMRK);
     140                noticeButton.setBorderPainted(true);
     141            } else {
     142                SmedAction.panelMain.mark.setObject(Obj.UNKOBJ);
     143                noticeButton.setBorderPainted(false);
     144            }
     145            SmedAction.panelMain.syncPanel();
     146        }
     147    };
     148    public JToggleButton mooringButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/MooringButton.png")));
     149    private ActionListener alMooring = new ActionListener() {
     150        @Override
     151        public void actionPerformed(ActionEvent e) {
     152            SmedAction.panelMain.mark.setObject(Obj.UNKOBJ);
     153            SmedAction.panelMain.mark.setCategory(Cat.NOCAT);
     154            SmedAction.panelMain.mark.setTopmark(Top.NOTOP);
     155            if (mooringButton.isSelected()) {
     156                SmedAction.panelMain.mark.setObject(Obj.MORFAC);
     157                categoryBox.setVisible(false);
     158                mooringBox.setVisible(true);
     159                pillarButton.setEnabled(false);
     160                sparButton.setEnabled(false);
     161                beaconButton.setEnabled(false);
     162                towerButton.setEnabled(false);
     163                stakeButton.setEnabled(false);
     164                cairnButton.setEnabled(false);
     165                mooringButton.setBorderPainted(true);
     166            } else {
     167                mooringBox.setVisible(false);
     168                categoryBox.setVisible(true);
     169                pillarButton.setEnabled(true);
     170                sparButton.setEnabled(true);
     171                beaconButton.setEnabled(true);
     172                towerButton.setEnabled(true);
     173                stakeButton.setEnabled(true);
     174                cairnButton.setEnabled(true);
     175                mooringButton.setBorderPainted(false);
     176            }
     177            syncPanel();
     178        }
     179    };
     180
     181    public PanelSpec(SmedAction dia) {
     182        dlg = dia;
     183        setLayout(null);
     184        add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSPP));
     185        add(getShapeButton(sparButton, 34, 0, 34, 32, "Spar", Shp.SPAR, Obj.BOYSPP));
     186        add(getShapeButton(canButton, 68, 0, 34, 32, "Can", Shp.CAN, Obj.BOYSPP));
     187        add(getShapeButton(coneButton, 102, 0, 34, 32, "Cone", Shp.CONI, Obj.BOYSPP));
     188        add(getShapeButton(sphereButton, 0, 32, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSPP));
     189        add(getShapeButton(barrelButton, 34, 32, 34, 32, "Barrel", Shp.BARREL, Obj.BOYSPP));
     190        add(getShapeButton(superButton, 68, 32, 34, 32, "Super", Shp.SUPER, Obj.BOYSPP));
     191        add(getShapeButton(floatButton, 102, 32, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT));
     192        add(getShapeButton(beaconButton, 0, 64, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSPP));
     193        add(getShapeButton(towerButton, 34, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNSPP));
     194        add(getShapeButton(stakeButton, 68, 64, 34, 32, "Stake", Shp.STAKE, Obj.BCNSPP));
     195        add(getShapeButton(cairnButton, 102, 64, 34, 32, "CairnB", Shp.CAIRN, Obj.BCNSPP));
     196
     197        categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER);
     198        categoryLabel.setBounds(new Rectangle(5, 125, 160, 18));
     199        add(categoryLabel);
     200        categoryBox = new JComboBox<>();
     201        categoryBox.setBounds(new Rectangle(5, 142, 160, 18));
     202        add(categoryBox);
     203        categoryBox.setVisible(true);
     204        categoryBox.addActionListener(alCategoryBox);
     205        addCatItem("", Cat.NOCAT);
     206        addCatItem(Messages.getString("UKPurpose"), Cat.SPM_UNKN);
     207        addCatItem(Messages.getString("Warning"), Cat.SPM_WARN);
     208        addCatItem(Messages.getString("ChanSeparation"), Cat.SPM_CHBF);
     209        addCatItem(Messages.getString("Yachting"), Cat.SPM_YCHT);
     210        addCatItem(Messages.getString("Cable"), Cat.SPM_CABL);
     211        addCatItem(Messages.getString("Outfall"), Cat.SPM_OFAL);
     212        addCatItem(Messages.getString("ODAS"), Cat.SPM_ODAS);
     213        addCatItem(Messages.getString("RecreationZone"), Cat.SPM_RECN);
     214        addCatItem(Messages.getString("Mooring"), Cat.SPM_MOOR);
     215        addCatItem(Messages.getString("LANBY"), Cat.SPM_LNBY);
     216        addCatItem(Messages.getString("Leading"), Cat.SPM_LDNG);
     217        addCatItem(Messages.getString("Notice"), Cat.SPM_NOTC);
     218        addCatItem(Messages.getString("TSS"), Cat.SPM_TSS);
     219        addCatItem(Messages.getString("FoulGround"), Cat.SPM_FOUL);
     220        addCatItem(Messages.getString("Diving"), Cat.SPM_DIVE);
     221        addCatItem(Messages.getString("FerryCross"), Cat.SPM_FRRY);
     222        addCatItem(Messages.getString("Anchorage"), Cat.SPM_ANCH);
     223        mooringBox = new JComboBox<>();
     224        mooringBox.setBounds(new Rectangle(5, 142, 160, 18));
     225        add(mooringBox);
     226        mooringBox.setVisible(false);
     227        mooringBox.addActionListener(alMooringBox);
     228        addMorItem("", Cat.NOCAT);
     229        addMorItem(Messages.getString("Dolphin"), Cat.MOR_DLPN);
     230        addMorItem(Messages.getString("DevDolphin"), Cat.MOR_DDPN);
     231        addMorItem(Messages.getString("Bollard"), Cat.MOR_BLRD);
     232        addMorItem(Messages.getString("Wall"), Cat.MOR_WALL);
     233        addMorItem(Messages.getString("Post"), Cat.MOR_POST);
     234        addMorItem(Messages.getString("Chain"), Cat.MOR_CHWR);
     235        addMorItem(Messages.getString("Rope"), Cat.MOR_ROPE);
     236        addMorItem(Messages.getString("Automatic"), Cat.MOR_AUTO);
     237        addMorItem(Messages.getString("MooringBuoy"), Cat.MOR_BUOY);
     238        addMorItem(Messages.getString("CALM"), Cat.INB_CALM);
     239        addMorItem(Messages.getString("SBM"), Cat.INB_SBM);
     240
     241        topmarkButton.setBounds(new Rectangle(136, 0, 34, 32));
     242        topmarkButton.setToolTipText(Messages.getString("Topmark"));
     243        topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder());
     244        topmarkButton.addActionListener(alTop);
     245        add(topmarkButton);
     246
     247        //        noticeButton.setBounds(new Rectangle(136, 32, 34, 32));
     248        //        noticeButton.setToolTipText(Messages.getString("Notice"));
     249        //        noticeButton.setBorder(BorderFactory.createLoweredBevelBorder());
     250        //        noticeButton.addActionListener(alNotice);
     251        //        add(noticeButton);
     252
     253        mooringButton.setBounds(new Rectangle(136, 64, 34, 32));
     254        mooringButton.setToolTipText(Messages.getString("Mooring"));
     255        mooringButton.setBorder(BorderFactory.createLoweredBevelBorder());
     256        mooringButton.addActionListener(alMooring);
     257        add(mooringButton);
     258    }
     259
     260    public void syncPanel() {
     261        if (SeaMark.EntMAP.get(SmedAction.panelMain.mark.getObject()) == Ent.MOORING) {
     262            mooringButton.setBorderPainted(true);
     263            categoryBox.setVisible(false);
     264            mooringBox.setVisible(true);
     265            pillarButton.setEnabled(false);
     266            sparButton.setEnabled(false);
     267            beaconButton.setEnabled(false);
     268            towerButton.setEnabled(false);
     269            stakeButton.setEnabled(false);
     270            cairnButton.setEnabled(false);
     271            noticeButton.setEnabled(false);
     272            topmarkButton.setVisible(false);
     273            for (Cat cat : moorings.keySet()) {
     274                int item = moorings.get(cat);
     275                if (SmedAction.panelMain.mark.getCategory() == cat) {
     276                    mooringBox.setSelectedIndex(item);
     277                }
     278            }
     279        } else {
     280            mooringButton.setBorderPainted(false);
     281            mooringBox.setVisible(false);
     282            categoryBox.setVisible(true);
     283            pillarButton.setEnabled(true);
     284            sparButton.setEnabled(true);
     285            beaconButton.setEnabled(true);
     286            towerButton.setEnabled(true);
     287            stakeButton.setEnabled(true);
     288            cairnButton.setEnabled(true);
     289            noticeButton.setEnabled(true);
     290            topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP);
     291            topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP);
     292            topmarkButton.setVisible(SmedAction.panelMain.mark.testValid());
     293            for (Cat cat : categories.keySet()) {
     294                int item = categories.get(cat);
     295                if (SmedAction.panelMain.mark.getCategory() == cat) {
     296                    categoryBox.setSelectedIndex(item);
     297                }
     298            }
     299        }
     300        for (Shp shp : shapes.keySet()) {
     301            JRadioButton button = shapes.get(shp);
     302            if (SmedAction.panelMain.mark.getShape() == shp) {
     303                button.setBorderPainted(true);
     304            } else {
     305                button.setBorderPainted(false);
     306            }
     307        }
     308        noticeButton.setBorderPainted(false);
     309        SmedAction.panelMain.mark.testValid();
     310    }
     311
     312    private void addCatItem(String str, Cat cat) {
     313        categories.put(cat, categoryBox.getItemCount());
     314        categoryBox.addItem(str);
     315    }
     316
     317    private void addMorItem(String str, Cat cat) {
     318        moorings.put(cat, mooringBox.getItemCount());
     319        mooringBox.addItem(str);
     320    }
     321
     322    private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
     323        button.setBounds(new Rectangle(x, y, w, h));
     324        button.setBorder(BorderFactory.createLoweredBevelBorder());
     325        button.setToolTipText(Messages.getString(tip));
     326        button.addActionListener(alShape);
     327        shapeButtons.add(button);
     328        shapes.put(shp, button);
     329        objects.put(shp, obj);
     330        return button;
     331    }
    304332
    305333}
  • applications/editors/josm/plugins/smed/src/panels/PanelStbd.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.*;
    4 import java.awt.event.*;
    5 import javax.swing.*;
     3import java.awt.Rectangle;
     4import java.awt.event.ActionEvent;
     5import java.awt.event.ActionListener;
     6import java.util.EnumMap;
    67
    7 import java.util.*;
     8import javax.swing.BorderFactory;
     9import javax.swing.ButtonGroup;
     10import javax.swing.ImageIcon;
     11import javax.swing.JPanel;
     12import javax.swing.JRadioButton;
    813
    914import messages.Messages;
     15import seamarks.SeaMark.Cat;
     16import seamarks.SeaMark.Col;
     17import seamarks.SeaMark.Obj;
     18import seamarks.SeaMark.Pat;
     19import seamarks.SeaMark.Shp;
    1020import smed.SmedAction;
    11 import seamarks.SeaMark.*;
    1221
    1322public class PanelStbd extends JPanel {
    1423
    15         private SmedAction dlg;
    16         public ButtonGroup shapeButtons = new ButtonGroup();
    17         public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
    18         public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
    19         public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png")));
    20         public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
    21         public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
    22         public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
    23         public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png")));
    24         public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchSButton.png")));
    25         public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png")));
    26         public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
    27         public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class);
    28         public ActionListener alShape = new ActionListener() {
    29                 public void actionPerformed(java.awt.event.ActionEvent e) {
    30                         for (Shp shp : shapes.keySet()) {
    31                                 JRadioButton button = shapes.get(shp);
    32                                 if (button.isSelected()) {
    33                                         SmedAction.panelMain.mark.setShape(shp);
    34                                         SmedAction.panelMain.mark.setObject(objects.get(shp));
    35                                         button.setBorderPainted(true);
    36                                 } else
    37                                         button.setBorderPainted(false);
    38                         }
    39                         if (SmedAction.panelMain.mark.testValid()) {
    40                                 SmedAction.panelMain.panelChan.topmarkButton.setVisible(true);
    41                                 SmedAction.panelMain.panelChan.lightButton.setVisible(true);
    42                                 if (SmedAction.panelMain.mark.getCategory() == Cat.LAM_STBD) {
    43                                         switch (SmedAction.panelMain.mark.getRegion()) {
    44                                         case A:
    45                                                 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
    46                                                 SmedAction.panelMain.mark.setObjColour(Col.GREEN);
    47                                                 break;
    48                                         case B:
    49                                                 SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
    50                                                 SmedAction.panelMain.mark.setObjColour(Col.RED);
    51                                                 break;
    52                                         case C:
    53                                                 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
    54                                                 SmedAction.panelMain.mark.setObjColour(Col.GREEN);
    55                                                 SmedAction.panelMain.mark.addObjColour(Col.WHITE);
    56                                                 SmedAction.panelMain.mark.addObjColour(Col.GREEN);
    57                                                 SmedAction.panelMain.mark.addObjColour(Col.WHITE);
    58                                                 break;
    59                                         }
    60                                 } else {
    61                                         SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
    62                                         switch (SmedAction.panelMain.mark.getRegion()) {
    63                                         case A:
    64                                                 SmedAction.panelMain.mark.setObjColour(Col.GREEN);
    65                                                 SmedAction.panelMain.mark.addObjColour(Col.RED);
    66                                                 SmedAction.panelMain.mark.addObjColour(Col.GREEN);
    67                                                 break;
    68                                         case B:
    69                                                 SmedAction.panelMain.mark.setObjColour(Col.RED);
    70                                                 SmedAction.panelMain.mark.addObjColour(Col.GREEN);
    71                                                 SmedAction.panelMain.mark.addObjColour(Col.RED);
    72                                                 break;
    73                                         case C:
    74                                                 SmedAction.panelMain.mark.setObjColour(Col.RED);
    75                                                 SmedAction.panelMain.mark.addObjColour(Col.GREEN);
    76                                                 SmedAction.panelMain.mark.addObjColour(Col.RED);
    77                                                 SmedAction.panelMain.mark.addObjColour(Col.GREEN);
    78                                                 break;
    79                                         }
    80                                 }
    81                                 SmedAction.panelMain.panelMore.syncPanel();
    82                         } else {
    83                                 SmedAction.panelMain.panelChan.topmarkButton.setVisible(false);
    84                                 SmedAction.panelMain.panelChan.lightButton.setVisible(false);
    85                         }
    86                 }
    87         };
     24    private SmedAction dlg;
     25    public ButtonGroup shapeButtons = new ButtonGroup();
     26    public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png")));
     27    public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png")));
     28    public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png")));
     29    public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png")));
     30    public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png")));
     31    public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png")));
     32    public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png")));
     33    public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchSButton.png")));
     34    public JRadioButton stakeButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StakeButton.png")));
     35    public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class);
     36    public EnumMap<Shp, Obj> objects = new EnumMap<>(Shp.class);
     37    public ActionListener alShape = new ActionListener() {
     38        @Override
     39        public void actionPerformed(ActionEvent e) {
     40            for (Shp shp : shapes.keySet()) {
     41                JRadioButton button = shapes.get(shp);
     42                if (button.isSelected()) {
     43                    SmedAction.panelMain.mark.setShape(shp);
     44                    SmedAction.panelMain.mark.setObject(objects.get(shp));
     45                    button.setBorderPainted(true);
     46                } else {
     47                    button.setBorderPainted(false);
     48                }
     49            }
     50            if (SmedAction.panelMain.mark.testValid()) {
     51                SmedAction.panelMain.panelChan.topmarkButton.setVisible(true);
     52                SmedAction.panelMain.panelChan.lightButton.setVisible(true);
     53                if (SmedAction.panelMain.mark.getCategory() == Cat.LAM_STBD) {
     54                    switch (SmedAction.panelMain.mark.getRegion()) {
     55                    case A:
     56                        SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
     57                        SmedAction.panelMain.mark.setObjColour(Col.GREEN);
     58                        break;
     59                    case B:
     60                        SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
     61                        SmedAction.panelMain.mark.setObjColour(Col.RED);
     62                        break;
     63                    case C:
     64                        SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
     65                        SmedAction.panelMain.mark.setObjColour(Col.GREEN);
     66                        SmedAction.panelMain.mark.addObjColour(Col.WHITE);
     67                        SmedAction.panelMain.mark.addObjColour(Col.GREEN);
     68                        SmedAction.panelMain.mark.addObjColour(Col.WHITE);
     69                        break;
     70                    }
     71                } else {
     72                    SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
     73                    switch (SmedAction.panelMain.mark.getRegion()) {
     74                    case A:
     75                        SmedAction.panelMain.mark.setObjColour(Col.GREEN);
     76                        SmedAction.panelMain.mark.addObjColour(Col.RED);
     77                        SmedAction.panelMain.mark.addObjColour(Col.GREEN);
     78                        break;
     79                    case B:
     80                        SmedAction.panelMain.mark.setObjColour(Col.RED);
     81                        SmedAction.panelMain.mark.addObjColour(Col.GREEN);
     82                        SmedAction.panelMain.mark.addObjColour(Col.RED);
     83                        break;
     84                    case C:
     85                        SmedAction.panelMain.mark.setObjColour(Col.RED);
     86                        SmedAction.panelMain.mark.addObjColour(Col.GREEN);
     87                        SmedAction.panelMain.mark.addObjColour(Col.RED);
     88                        SmedAction.panelMain.mark.addObjColour(Col.GREEN);
     89                        break;
     90                    }
     91                }
     92                SmedAction.panelMain.panelMore.syncPanel();
     93            } else {
     94                SmedAction.panelMain.panelChan.topmarkButton.setVisible(false);
     95                SmedAction.panelMain.panelChan.lightButton.setVisible(false);
     96            }
     97        }
     98    };
    8899
    89         public PanelStbd(SmedAction dia) {
    90                 dlg = dia;
    91                 setLayout(null);
    92                 add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYLAT));
    93                 add(getShapeButton(sparButton, 0, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYLAT));
    94                 add(getShapeButton(coneButton, 0, 64, 34, 32, "Cone", Shp.CONI, Obj.BOYLAT));
    95                 add(getShapeButton(sphereButton, 0, 96, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYLAT));
    96                 add(getShapeButton(floatButton, 0, 128, 34, 32, "Float", Shp.FLOAT, Obj.FLTLAT));
    97                 add(getShapeButton(beaconButton, 35, 0, 34, 32, "Beacon", Shp.BEACON, Obj.BCNLAT));
    98                 add(getShapeButton(towerButton, 35, 32, 34, 32, "TowerB", Shp.TOWER, Obj.BCNLAT));
    99                 add(getShapeButton(perchButton, 35, 64, 34, 32, "Perch", Shp.PERCH, Obj.BCNLAT));
    100                 add(getShapeButton(stakeButton, 35, 96, 34, 32, "Stake", Shp.STAKE, Obj.BCNLAT));
    101         }
     100    public PanelStbd(SmedAction dia) {
     101        dlg = dia;
     102        setLayout(null);
     103        add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYLAT));
     104        add(getShapeButton(sparButton, 0, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYLAT));
     105        add(getShapeButton(coneButton, 0, 64, 34, 32, "Cone", Shp.CONI, Obj.BOYLAT));
     106        add(getShapeButton(sphereButton, 0, 96, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYLAT));
     107        add(getShapeButton(floatButton, 0, 128, 34, 32, "Float", Shp.FLOAT, Obj.FLTLAT));
     108        add(getShapeButton(beaconButton, 35, 0, 34, 32, "Beacon", Shp.BEACON, Obj.BCNLAT));
     109        add(getShapeButton(towerButton, 35, 32, 34, 32, "TowerB", Shp.TOWER, Obj.BCNLAT));
     110        add(getShapeButton(perchButton, 35, 64, 34, 32, "Perch", Shp.PERCH, Obj.BCNLAT));
     111        add(getShapeButton(stakeButton, 35, 96, 34, 32, "Stake", Shp.STAKE, Obj.BCNLAT));
     112    }
    102113
    103         public void syncPanel() {
    104                 for (Shp shp : shapes.keySet()) {
    105                         JRadioButton button = shapes.get(shp);
    106                         if (SmedAction.panelMain.mark.getShape() == shp) {
    107                                 button.setBorderPainted(true);
    108                         } else
    109                                 button.setBorderPainted(false);
    110                 }
    111         }
     114    public void syncPanel() {
     115        for (Shp shp : shapes.keySet()) {
     116            JRadioButton button = shapes.get(shp);
     117            if (SmedAction.panelMain.mark.getShape() == shp) {
     118                button.setBorderPainted(true);
     119            } else {
     120                button.setBorderPainted(false);
     121            }
     122        }
     123    }
    112124
    113         private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
    114                 button.setBounds(new Rectangle(x, y, w, h));
    115                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    116                 button.setToolTipText(Messages.getString(tip));
    117                 button.addActionListener(alShape);
    118                 shapeButtons.add(button);
    119                 shapes.put(shp, button);
    120                 objects.put(shp, obj);
    121                 return button;
    122         }
     125    private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
     126        button.setBounds(new Rectangle(x, y, w, h));
     127        button.setBorder(BorderFactory.createLoweredBevelBorder());
     128        button.setToolTipText(Messages.getString(tip));
     129        button.addActionListener(alShape);
     130        shapeButtons.add(button);
     131        shapes.put(shp, button);
     132        objects.put(shp, obj);
     133        return button;
     134    }
    123135
    124136}
  • applications/editors/josm/plugins/smed/src/panels/PanelTop.java

    r30738 r32767  
    11package panels;
    22
    3 import java.awt.*;
    4 import java.awt.event.*;
    5 import javax.swing.*;
     3import java.awt.Rectangle;
     4import java.awt.event.ActionEvent;
     5import java.awt.event.ActionListener;
     6import java.util.EnumMap;
    67
    7 import java.util.*;
     8import javax.swing.BorderFactory;
     9import javax.swing.ButtonGroup;
     10import javax.swing.ImageIcon;
     11import javax.swing.JPanel;
     12import javax.swing.JRadioButton;
    813
    914import messages.Messages;
     15import seamarks.SeaMark.Ent;
     16import seamarks.SeaMark.Top;
    1017import smed.SmedAction;
    11 import seamarks.SeaMark.*;
    1218
    1319public class PanelTop extends JPanel {
    1420
    15         private SmedAction dlg;
    16         public PanelPat panelPat = null;
    17         private ButtonGroup topButtons = new ButtonGroup();
    18         public JRadioButton noTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
    19         public JRadioButton canTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanTopButton.png")));
    20         public JRadioButton coneTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeTopButton.png")));
    21         public JRadioButton sphereTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereTopButton.png")));
    22         public JRadioButton XTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/XTopButton.png")));
    23         public JRadioButton northTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NorthTopButton.png")));
    24         public JRadioButton southTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SouthTopButton.png")));
    25         public JRadioButton eastTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/EastTopButton.png")));
    26         public JRadioButton westTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WestTopButton.png")));
    27         public JRadioButton spheres2TopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/Spheres2TopButton.png")));
    28         public JRadioButton boardDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BoardDayButton.png")));
    29         public JRadioButton rhombusDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiamondDayButton.png")));
    30         public JRadioButton triangleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleDayButton.png")));
    31         public JRadioButton triangleInvDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleInvDayButton.png")));
    32         public JRadioButton squareDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquareDayButton.png")));
    33         public JRadioButton circleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CircleDayButton.png")));
    34         private EnumMap<Top, JRadioButton> tops = new EnumMap<>(Top.class);
    35         private ActionListener alTop = new ActionListener() {
    36                 public void actionPerformed(java.awt.event.ActionEvent e) {
    37                         for (Top top : tops.keySet()) {
    38                                 JRadioButton button = tops.get(top);
    39                                 if (button.isSelected()) {
    40                                         SmedAction.panelMain.mark.setTopmark(top);
    41                                         button.setBorderPainted(true);
    42                                 } else
    43                                         button.setBorderPainted(false);
    44                         }
    45                 }
    46         };
     21    private SmedAction dlg;
     22    public PanelPat panelPat = null;
     23    private ButtonGroup topButtons = new ButtonGroup();
     24    public JRadioButton noTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
     25    public JRadioButton canTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanTopButton.png")));
     26    public JRadioButton coneTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeTopButton.png")));
     27    public JRadioButton sphereTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereTopButton.png")));
     28    public JRadioButton XTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/XTopButton.png")));
     29    public JRadioButton northTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NorthTopButton.png")));
     30    public JRadioButton southTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SouthTopButton.png")));
     31    public JRadioButton eastTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/EastTopButton.png")));
     32    public JRadioButton westTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WestTopButton.png")));
     33    public JRadioButton spheres2TopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/Spheres2TopButton.png")));
     34    public JRadioButton boardDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BoardDayButton.png")));
     35    public JRadioButton rhombusDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiamondDayButton.png")));
     36    public JRadioButton triangleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleDayButton.png")));
     37    public JRadioButton triangleInvDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleInvDayButton.png")));
     38    public JRadioButton squareDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquareDayButton.png")));
     39    public JRadioButton circleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CircleDayButton.png")));
     40    private EnumMap<Top, JRadioButton> tops = new EnumMap<>(Top.class);
     41    private ActionListener alTop = new ActionListener() {
     42        @Override
     43        public void actionPerformed(ActionEvent e) {
     44            for (Top top : tops.keySet()) {
     45                JRadioButton button = tops.get(top);
     46                if (button.isSelected()) {
     47                    SmedAction.panelMain.mark.setTopmark(top);
     48                    button.setBorderPainted(true);
     49                } else {
     50                    button.setBorderPainted(false);
     51                }
     52            }
     53        }
     54    };
    4755
    48         public PanelTop(SmedAction dia) {
    49                 dlg = dia;
    50                 setLayout(null);
    51                 panelPat = new PanelPat(dlg, Ent.TOPMARK);
    52                 panelPat.setBounds(new Rectangle(160, 0, 110, 160));
    53                 add(panelPat);
    54                 add(getTopButton(noTopButton, 0, 5, 27, 27, "NoTop", Top.NOTOP));
    55                 add(getTopButton(canTopButton, 30, 5, 27, 27, "CanTop", Top.CYL));
    56                 add(getTopButton(coneTopButton, 60, 5, 27, 27, "ConeTop", Top.CONE));
    57                 add(getTopButton(sphereTopButton, 90, 5, 27, 27, "SphereTop", Top.SPHERE));
    58                 add(getTopButton(XTopButton, 120, 5, 27, 27, "XTop", Top.X_SHAPE));
    59                 add(getTopButton(northTopButton, 0, 35, 27, 27, "NorthTop", Top.NORTH));
    60                 add(getTopButton(southTopButton, 30, 35, 27, 27, "SouthTop", Top.SOUTH));
    61                 add(getTopButton(eastTopButton, 60, 35, 27, 27, "EastTop", Top.EAST));
    62                 add(getTopButton(westTopButton, 90, 35, 27, 27, "WestTop", Top.WEST));
    63                 add(getTopButton(spheres2TopButton, 120, 35, 27, 27, "Spheres2Top", Top.SPHERES2));
    64                 add(getTopButton(boardDayButton, 0, 65, 27, 27, "BoardDay", Top.BOARD));
    65                 add(getTopButton(rhombusDayButton, 30, 65, 27, 27, "DiamondDay", Top.RHOMBUS));
    66                 add(getTopButton(triangleDayButton, 60, 65, 27, 27, "TriangleDay", Top.TRIANGLE));
    67                 add(getTopButton(triangleInvDayButton, 90, 65, 27, 27, "TriangleInvDay", Top.TRIANGLE_INV));
    68                 add(getTopButton(squareDayButton, 120, 65, 27, 27, "SquareDay", Top.SQUARE));
    69                 add(getTopButton(circleDayButton, 120, 95, 27, 27, "CircleDay", Top.CIRCLE));
    70         }
     56    public PanelTop(SmedAction dia) {
     57        dlg = dia;
     58        setLayout(null);
     59        panelPat = new PanelPat(dlg, Ent.TOPMARK);
     60        panelPat.setBounds(new Rectangle(160, 0, 110, 160));
     61        add(panelPat);
     62        add(getTopButton(noTopButton, 0, 5, 27, 27, "NoTop", Top.NOTOP));
     63        add(getTopButton(canTopButton, 30, 5, 27, 27, "CanTop", Top.CYL));
     64        add(getTopButton(coneTopButton, 60, 5, 27, 27, "ConeTop", Top.CONE));
     65        add(getTopButton(sphereTopButton, 90, 5, 27, 27, "SphereTop", Top.SPHERE));
     66        add(getTopButton(XTopButton, 120, 5, 27, 27, "XTop", Top.X_SHAPE));
     67        add(getTopButton(northTopButton, 0, 35, 27, 27, "NorthTop", Top.NORTH));
     68        add(getTopButton(southTopButton, 30, 35, 27, 27, "SouthTop", Top.SOUTH));
     69        add(getTopButton(eastTopButton, 60, 35, 27, 27, "EastTop", Top.EAST));
     70        add(getTopButton(westTopButton, 90, 35, 27, 27, "WestTop", Top.WEST));
     71        add(getTopButton(spheres2TopButton, 120, 35, 27, 27, "Spheres2Top", Top.SPHERES2));
     72        add(getTopButton(boardDayButton, 0, 65, 27, 27, "BoardDay", Top.BOARD));
     73        add(getTopButton(rhombusDayButton, 30, 65, 27, 27, "DiamondDay", Top.RHOMBUS));
     74        add(getTopButton(triangleDayButton, 60, 65, 27, 27, "TriangleDay", Top.TRIANGLE));
     75        add(getTopButton(triangleInvDayButton, 90, 65, 27, 27, "TriangleInvDay", Top.TRIANGLE_INV));
     76        add(getTopButton(squareDayButton, 120, 65, 27, 27, "SquareDay", Top.SQUARE));
     77        add(getTopButton(circleDayButton, 120, 95, 27, 27, "CircleDay", Top.CIRCLE));
     78    }
    7179
    72         public void enableAll(boolean state) {
    73                 for (JRadioButton button : tops.values()) {
    74                         button.setEnabled(state);
    75                 }
    76         }
     80    public void enableAll(boolean state) {
     81        for (JRadioButton button : tops.values()) {
     82            button.setEnabled(state);
     83        }
     84    }
    7785
    78         public void syncPanel() {
    79                 for (Top top : tops.keySet()) {
    80                         JRadioButton button = tops.get(top);
    81                         if (SmedAction.panelMain.mark.getTopmark() == top) {
    82                                 button.setBorderPainted(true);
    83                         } else
    84                                 button.setBorderPainted(false);
    85                 }
    86                 panelPat.syncPanel();
    87         }
     86    public void syncPanel() {
     87        for (Top top : tops.keySet()) {
     88            JRadioButton button = tops.get(top);
     89            if (SmedAction.panelMain.mark.getTopmark() == top) {
     90                button.setBorderPainted(true);
     91            } else {
     92                button.setBorderPainted(false);
     93            }
     94        }
     95        panelPat.syncPanel();
     96    }
    8897
    89         private JRadioButton getTopButton(JRadioButton button, int x, int y, int w, int h, String tip, Top top) {
    90                 button.setBounds(new Rectangle(x, y, w, h));
    91                 button.setBorder(BorderFactory.createLoweredBevelBorder());
    92                 button.setToolTipText(Messages.getString(tip));
    93                 button.addActionListener(alTop);
    94                 topButtons.add(button);
    95                 tops.put(top, button);
    96                 return button;
    97         }
     98    private JRadioButton getTopButton(JRadioButton button, int x, int y, int w, int h, String tip, Top top) {
     99        button.setBounds(new Rectangle(x, y, w, h));
     100        button.setBorder(BorderFactory.createLoweredBevelBorder());
     101        button.setToolTipText(Messages.getString(tip));
     102        button.addActionListener(alTop);
     103        topButtons.add(button);
     104        tops.put(top, button);
     105        return button;
     106    }
    98107
    99108}
Note: See TracChangeset for help on using the changeset viewer.