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

code style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed/src/panels/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}
Note: See TracChangeset for help on using the changeset viewer.