Ignore:
Timestamp:
2011-01-01T19:28:28+01:00 (14 years ago)
Author:
malcolmh
Message:

save

Location:
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/dialogs/OSeaMAction.java

    r24925 r24931  
    11package oseam.dialogs;
    2 
    3 import static org.openstreetmap.josm.tools.I18n.tr;
    42
    53import oseam.panels.*;
     
    75import java.awt.Dimension;
    86import java.util.Collection;
    9 import java.util.Iterator;
    10 import java.util.Map;
    117
    128import javax.swing.JPanel;
     
    2016import oseam.Messages;
    2117import oseam.seamarks.SeaMark;
    22 import oseam.seamarks.SeaMark.Obj;
    2318import smed.plug.ifc.SmedPluginManager;
    2419
    2520public class OSeaMAction {
    2621
    27         private SmedPluginManager manager;
     22        private OSeaMAction dlg = null;
     23        public SmedPluginManager manager = null;;
    2824        public PanelMain panelMain = null;
    2925
     
    4440                                                if (nextNode.compareTo(node) != 0) {
    4541                                                        node = nextNode;
    46                                                         parseNode();
     42                                                        mark = new SeaMark(dlg);
    4743                                                }
    4844                                        } else
     
    6157        public OSeaMAction(SmedPluginManager mngr) {
    6258
     59                dlg = this;
     60                manager = mngr;
    6361                DataSet.addSelectionListener(SmpListener);
    64                 manager = mngr;
    6562                String str = Main.pref.get("mappaint.style.sources");
    6663                if (!str.contains("dev.openseamap.org")) {
     
    8279                return panelMain;
    8380        }
    84 
    85         private void parseNode() {
    86 
    87                 Map<String, String> keys;
    88 
    89                 manager.showVisualMessage("");
    90                 String type = "";
    91                 String str = "";
    92 
    93                 mark = new SeaMark(this);
    94                 keys = node.getKeys();
    95 
    96                 if (keys.containsKey("seamark:type"))
    97                         type = keys.get("seamark:type");
    98 
    99                 Iterator<Obj> it = mark.objects.keySet().iterator();
    100                 while (it.hasNext()) {
    101                         Obj obj = it.next();
    102                         if (mark.objects.get(obj).equals(type)) {
    103                                 mark.setObject(obj);
    104                         }
    105                 }
    106 
    107                 if (type.equals("light_float")) {
    108                         if (keys.containsKey("seamark:light_float:colour")) {
    109                                 str = keys.get("seamark:light_float:colour");
    110                                 if (str.equals("red") || str.equals("green") || str.equals("red;green;red") || str.equals("green;red;green")) {
    111                                         mark.setObject(Obj.BOYLAT);
    112                                 } else if (str.equals("black;yellow") || str.equals("black;yellow;black") || str.equals("yellow;black")
    113                                                 || str.equals("yellow;black;yellow")) {
    114                                         mark.setObject(Obj.BOYCAR);
    115                                 } else if (str.equals("black;red;black")) {
    116                                         mark.setObject(Obj.BOYISD);
    117                                 } else if (str.equals("red;white")) {
    118                                         mark.setObject(Obj.BOYSAW);
    119                                 } else if (str.equals("yellow")) {
    120                                         mark.setObject(Obj.BOYSPP);
    121                                 }
    122                         } else if (keys.containsKey("seamark:light_float:topmark:shape")) {
    123                                 str = keys.get("seamark:light_float:topmark:shape");
    124                                 if (str.equals("cylinder") || str.equals("cone, point up")) {
    125                                         mark.setObject(Obj.BOYLAT);
    126                                 }
    127                         } else if (keys.containsKey("seamark:light_float:topmark:colour")) {
    128                                 str = keys.get("seamark:light_float:topmark:colour");
    129                                 if (str.equals("red") || str.equals("green")) {
    130                                         mark.setObject(Obj.BOYLAT);
    131                                 }
    132                         }
    133                 } else if (keys.containsKey("buoy_lateral:category") || keys.containsKey("buoy_lateral:shape") || keys.containsKey("buoy_lateral:colour")) {
    134                         mark.setObject(Obj.BOYLAT);
    135                 } else if (keys.containsKey("beacon_lateral:category") || keys.containsKey("beacon_lateral:shape") || keys.containsKey("beacon_lateral:colour")) {
    136                         mark.setObject(Obj.BCNLAT);
    137                 } else if (keys.containsKey("buoy_cardinal:category") || keys.containsKey("buoy_cardinal:shape") || keys.containsKey("buoy_cardinal:colour")) {
    138                         mark.setObject(Obj.BOYCAR);
    139                 } else if (keys.containsKey("beacon_cardinal:category") || keys.containsKey("beacon_cardinal:shape") || keys.containsKey("beacon_cardinal:colour")) {
    140                         mark.setObject(Obj.BCNCAR);
    141                 } else if (keys.containsKey("buoy_isolated_danger:category") || keys.containsKey("buoy_isolated_danger:shape") || keys.containsKey("buoy_isolated_danger:colour")) {
    142                         mark.setObject(Obj.BOYISD);
    143                 } else if (keys.containsKey("beacon_isolated_danger:category") || keys.containsKey("beacon_isolated_danger:shape") || keys.containsKey("beacon_isolated_danger:colour")) {
    144                         mark.setObject(Obj.BCNISD);
    145                 } else if (keys.containsKey("buoy_safe_water:category") || keys.containsKey("buoy_safe_water:shape") || keys.containsKey("buoy_safe_water:colour")) {
    146                         mark.setObject(Obj.BOYSAW);
    147                 } else if (keys.containsKey("beacon_safe_water:category") || keys.containsKey("beacon_safe_water:shape") || keys.containsKey("beacon_safe_water:colour")) {
    148                         mark.setObject(Obj.BCNSAW);
    149                 } else if (keys.containsKey("buoy_special_purpose:category") || keys.containsKey("buoy_special_purpose:shape") || keys.containsKey("buoy_special_purpose:colour")) {
    150                         mark.setObject(Obj.BOYSPP);
    151                 } else if (keys.containsKey("beacon_special_purpose:category") || keys.containsKey("beacon_special_purpose:shape") || keys.containsKey("beacon_special_purpose:colour")) {
    152                         mark.setObject(Obj.BCNSPP);
    153                 }
    154 
    155                 if (mark.getObject() == Obj.UNKNOWN) {
    156                         manager.showVisualMessage(Messages.getString("NoMark"));
    157                         panelMain.clearSelections();
    158                 } else {
    159                         if (keys.containsKey("seamark:" + type + ":name")) {
    160                                 panelMain.nameBox.setText(keys.get("seamark:" + type + ":name"));
    161                                 panelMain.nameBox.postActionEvent();
    162                         } else if (keys.containsKey("seamark:name")) {
    163                                 panelMain.nameBox.setText(keys.get("seamark:name"));
    164                                 panelMain.nameBox.postActionEvent();
    165                         } else if (keys.containsKey("name")) {
    166                                 panelMain.nameBox.setText(keys.get("name"));
    167                                 panelMain.nameBox.postActionEvent();
    168                         } else
    169                                 panelMain.nameBox.setText("");
    170                         mark.parseMark();
    171                         mark.paintSign();
    172                 }
    173         }
     81       
    17482}
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelChan.java

    r24925 r24931  
    4242                                shp = dlg.mark.getShape();
    4343                        if (portButton.isSelected() || prefPortButton.isSelected()) {
    44 //                              if (!(dlg.mark instanceof MarkLat)) {
    45 //                                      dlg.mark = new MarkLat(dlg);
    46                                         dlg.panelMain.topButton.setEnabled(true);
    47                                         dlg.panelMain.fogButton.setEnabled(true);
    48                                         dlg.panelMain.radButton.setEnabled(true);
    49                                         dlg.panelMain.litButton.setEnabled(true);
    50 //                              }
     44                                dlg.panelMain.topButton.setEnabled(true);
     45                                dlg.panelMain.fogButton.setEnabled(true);
     46                                dlg.panelMain.radButton.setEnabled(true);
     47                                dlg.panelMain.litButton.setEnabled(true);
    5148                                dlg.panelMain.panelTop.enableAll(false);
    5249                                dlg.panelMain.panelTop.noTopButton.setEnabled(true);
     
    107104                        }
    108105                        if (stbdButton.isSelected() || prefStbdButton.isSelected()) {
    109 //                              if (!(dlg.mark instanceof MarkLat)) {
    110 //                                      dlg.mark = new MarkLat(dlg);
    111                                         dlg.panelMain.topButton.setEnabled(true);
    112                                         dlg.panelMain.fogButton.setEnabled(true);
    113                                         dlg.panelMain.radButton.setEnabled(true);
    114                                         dlg.panelMain.litButton.setEnabled(true);
    115 //                              }
     106                                dlg.panelMain.topButton.setEnabled(true);
     107                                dlg.panelMain.fogButton.setEnabled(true);
     108                                dlg.panelMain.radButton.setEnabled(true);
     109                                dlg.panelMain.litButton.setEnabled(true);
    116110                                dlg.panelMain.panelTop.enableAll(false);
    117111                                dlg.panelMain.panelTop.noTopButton.setEnabled(true);
     
    172166                        }
    173167                        if (safeWaterButton.isSelected()) {
    174 //                              if (!(dlg.mark instanceof MarkSaw)) {
    175 //                                      dlg.mark = new MarkSaw(dlg);
    176                                         if (panelSaw.shapes.containsKey(shp)) {
    177                                                 panelSaw.shapes.get(shp).doClick();
    178                                         } else {
    179                                                 panelSaw.clearSelections();
    180                                                 dlg.mark.setShape(Shp.UNKNOWN);
    181                                         }
    182                                         dlg.panelMain.panelTop.enableAll(false);
    183                                         dlg.panelMain.panelTop.noTopButton.setEnabled(true);
    184                                         dlg.panelMain.panelTop.sphereTopButton.setEnabled(true);
    185                                         dlg.panelMain.panelTop.panelCol.enableAll(false);
    186                                         dlg.panelMain.panelTop.panelCol.redButton.setEnabled(true);
    187                                         dlg.panelMain.panelTop.panelCol.redButton.doClick();
    188 //                              }
     168                                if (panelSaw.shapes.containsKey(shp)) {
     169                                        panelSaw.shapes.get(shp).doClick();
     170                                } else {
     171                                        panelSaw.clearSelections();
     172                                        dlg.mark.setShape(Shp.UNKNOWN);
     173                                }
     174                                dlg.panelMain.panelTop.enableAll(false);
     175                                dlg.panelMain.panelTop.noTopButton.setEnabled(true);
     176                                dlg.panelMain.panelTop.sphereTopButton.setEnabled(true);
     177                                dlg.panelMain.panelTop.panelCol.enableAll(false);
     178                                dlg.panelMain.panelTop.panelCol.redButton.setEnabled(true);
     179                                dlg.panelMain.panelTop.panelCol.redButton.doClick();
    189180                                dlg.mark.setColour(Ent.BODY, Col.RED_WHITE);
    190181                                safeWaterButton.setBorderPainted(true);
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelCol.java

    r24904 r24931  
    1414
    1515import java.util.EnumMap;
    16 import java.util.Iterator;
    1716
    1817import oseam.dialogs.OSeaMAction;
     
    3837        private ActionListener alColour = new ActionListener() {
    3938                public void actionPerformed(java.awt.event.ActionEvent e) {
    40                         Iterator<Col> it = colours.keySet().iterator();
    41                         while (it.hasNext()) {
    42                                 Col col = it.next();
     39                        for (Col col : colours.keySet()) {
    4340                                JRadioButton button = colours.get(col);
    4441                                if (button.isSelected()) {
     
    7370
    7471        public void enableAll(boolean state) {
    75                 Iterator<Col> it = colours.keySet().iterator();
    76                 while (it.hasNext()) {
    77                         colours.get(it.next()).setEnabled(state);
     72                for (JRadioButton button : colours.values()) {
     73                        button.setEnabled(state);
    7874                }
    7975        }
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelHaz.java

    r24925 r24931  
    1212
    1313import java.util.EnumMap;
    14 import java.util.Iterator;
    1514
    1615import oseam.Messages;
     
    111110        private ActionListener alShape = new ActionListener() {
    112111                public void actionPerformed(java.awt.event.ActionEvent e) {
    113                         Iterator<Shp> it = shapes.keySet().iterator();
    114                         while (it.hasNext()) {
    115                                 Shp shp = it.next();
     112                        for (Shp shp : shapes.keySet()) {
    116113                                JRadioButton button = shapes.get(shp);
    117114                                if (button.isSelected()) {
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelLights.java

    r24917 r24931  
    1212
    1313import java.util.EnumMap;
    14 import java.util.Iterator;
    1514
    1615import oseam.Messages;
     
    2322        private OSeaMAction dlg;
    2423        private ButtonGroup catButtons = new ButtonGroup();
    25         private JRadioButton houseButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LighthouseButton.png")));
    26         private JRadioButton majorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightMajorButton.png")));
    27         private JRadioButton minorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightMinorButton.png")));
    28         private JRadioButton vesselButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightVesselButton.png")));
    29         private JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightFloatButton.png")));
     24        public JRadioButton houseButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LighthouseButton.png")));
     25        public JRadioButton majorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightMajorButton.png")));
     26        public JRadioButton minorButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightMinorButton.png")));
     27        public JRadioButton vesselButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightVesselButton.png")));
     28        public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/LightFloatButton.png")));
    3029        private EnumMap<Cat, JRadioButton> categories = new EnumMap<Cat, JRadioButton>(Cat.class);
    3130        private EnumMap<Cat, Obj> objects = new EnumMap<Cat, Obj>(Cat.class);
    3231        private ActionListener alCat = new ActionListener() {
    3332                public void actionPerformed(java.awt.event.ActionEvent e) {
    34                         Iterator<Cat> it = categories.keySet().iterator();
    35                         while (it.hasNext()) {
    36                                 Cat cat = it.next();
     33                        for (Cat cat : categories.keySet()) {
    3734                                JRadioButton button = categories.get(cat);
    3835                                if (button.isSelected()) {
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelLit.java

    r24896 r24931  
    55import java.awt.Rectangle;
    66
    7 import oseam.Messages;
    87import oseam.dialogs.OSeaMAction;
    98import oseam.seamarks.SeaMark.Ent;
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelMain.java

    r24925 r24931  
    119119                                }
    120120                                if (chanButton.isSelected()) {
    121 //                                      if (!((dlg.mark instanceof MarkLat) || (dlg.mark instanceof MarkSaw))) {
    122 //                                              dlg.mark = null;
    123 //                                              clearType();
    124 //                                      }
    125121                                        chanButton.setBorderPainted(true);
    126122                                        panelChan.setVisible(true);
     
    131127                                }
    132128                                if (hazButton.isSelected()) {
    133 //                                      if (!((dlg.mark instanceof MarkCard) || (dlg.mark instanceof MarkIsol))) {
    134 //                                              dlg.mark = null;
    135 //                                              clearType();
    136 //                                      }
    137129                                        hazButton.setBorderPainted(true);
    138130                                        panelHaz.setVisible(true);
     
    143135                                }
    144136                                if (specButton.isSelected()) {
    145 //                                      if (!(dlg.mark instanceof MarkSpec)) {
    146 //                                              dlg.mark = new MarkSpec(dlg);
    147 //                                              clearType();
    148                                                 dlg.panelMain.panelSpec.panelCol.yellowButton.doClick();
    149                                                 dlg.panelMain.panelTop.enableAll(true);
    150                                                 dlg.panelMain.panelTop.noTopButton.doClick();
    151                                                 dlg.panelMain.panelTop.panelCol.enableAll(true);
    152                                                 dlg.panelMain.panelTop.panelCol.yellowButton.doClick();
    153                                                 topButton.setEnabled(true);
    154                                                 fogButton.setEnabled(true);
    155                                                 radButton.setEnabled(true);
    156                                                 litButton.setEnabled(true);
    157 //                                      }
     137                                        dlg.panelMain.panelSpec.panelCol.yellowButton.doClick();
     138                                        dlg.panelMain.panelTop.enableAll(true);
     139                                        dlg.panelMain.panelTop.noTopButton.doClick();
     140                                        dlg.panelMain.panelTop.panelCol.enableAll(true);
     141                                        dlg.panelMain.panelTop.panelCol.yellowButton.doClick();
     142                                        topButton.setEnabled(true);
     143                                        fogButton.setEnabled(true);
     144                                        radButton.setEnabled(true);
     145                                        litButton.setEnabled(true);
    158146                                        specButton.setBorderPainted(true);
    159147                                        panelSpec.setVisible(true);
     
    164152                                }
    165153                                if (lightsButton.isSelected()) {
    166 //                                      if (!(dlg.mark instanceof MarkLight)) {
    167 //                                              dlg.mark = new MarkLight(dlg);
    168 //                                              clearType();
    169                                                 fogButton.setEnabled(true);
    170                                                 radButton.setEnabled(true);
    171                                                 litButton.setEnabled(true);
    172                                                 litButton.doClick();
    173 //                                      }
     154                                        fogButton.setEnabled(true);
     155                                        radButton.setEnabled(true);
     156                                        litButton.setEnabled(true);
     157                                        litButton.doClick();
    174158                                        lightsButton.setBorderPainted(true);
    175159                                        panelLights.setVisible(true);
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelPort.java

    r24896 r24931  
    1212
    1313import java.util.EnumMap;
    14 import java.util.Iterator;
    1514
    1615import oseam.Messages;
     
    4443        private ActionListener alShape = new ActionListener() {
    4544                public void actionPerformed(java.awt.event.ActionEvent e) {
    46                         Iterator<Shp> it = shapes.keySet().iterator();
    47                         while (it.hasNext()) {
    48                                 Shp shp = it.next();
     45                        for (Shp shp : shapes.keySet()) {
    4946                                JRadioButton button = shapes.get(shp);
    5047                                if (button.isSelected()) {
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelRadar.java

    r24839 r24931  
    33import javax.swing.JPanel;
    44
    5 import java.awt.Color;
    6 import java.awt.Dimension;
    7 import java.awt.Rectangle;
    8 import java.awt.Font;
    9 
    10 import javax.swing.ButtonGroup;
    11 import javax.swing.ImageIcon;
    12 import javax.swing.JLabel;
    13 import javax.swing.JTextField;
    14 import javax.swing.JComboBox;
    15 import javax.swing.JCheckBox;
    16 import javax.swing.JRadioButton;
    17 
    18 import oseam.Messages;
    195import oseam.dialogs.OSeaMAction;
    20 
    21 import java.awt.Cursor;
    22 import java.awt.event.ActionListener;
    236
    247public class PanelRadar extends JPanel {
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelSaw.java

    r24896 r24931  
    1212
    1313import java.util.EnumMap;
    14 import java.util.Iterator;
    1514
    1615import oseam.Messages;
     
    3231        private ActionListener alShape = new ActionListener() {
    3332                public void actionPerformed(java.awt.event.ActionEvent e) {
    34                         Iterator<Shp> it = shapes.keySet().iterator();
    35                         while (it.hasNext()) {
    36                                 Shp shp = it.next();
     33                        for (Shp shp : shapes.keySet()) {
    3734                                JRadioButton button = shapes.get(shp);
    3835                                if (button.isSelected()) {
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelSpec.java

    r24896 r24931  
    1212
    1313import java.util.EnumMap;
    14 import java.util.Iterator;
    1514
    1615import oseam.Messages;
     
    3938        private ActionListener alShape = new ActionListener() {
    4039                public void actionPerformed(java.awt.event.ActionEvent e) {
    41                         Iterator<Shp> it = shapes.keySet().iterator();
    42                         while (it.hasNext()) {
    43                                 Shp shp = it.next();
     40                        for (Shp shp : shapes.keySet()) {
    4441                                JRadioButton button = shapes.get(shp);
    4542                                if (button.isSelected()) {
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelStbd.java

    r24896 r24931  
    1212
    1313import java.util.EnumMap;
    14 import java.util.Iterator;
    1514
    1615import oseam.Messages;
     
    4443        private ActionListener alShape = new ActionListener() {
    4544                public void actionPerformed(java.awt.event.ActionEvent e) {
    46                         Iterator<Shp> it = shapes.keySet().iterator();
    47                         while (it.hasNext()) {
    48                                 Shp shp = it.next();
     45                        for (Shp shp : shapes.keySet()) {
    4946                                JRadioButton button = shapes.get(shp);
    5047                                if (button.isSelected()) {
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelTop.java

    r24919 r24931  
    1111import java.awt.event.ActionListener;
    1212import java.util.EnumMap;
    13 import java.util.Iterator;
    1413
    1514import oseam.Messages;
    1615import oseam.dialogs.OSeaMAction;
    17 import oseam.seamarks.SeaMark.Col;
    1816import oseam.seamarks.SeaMark.Top;
    1917import oseam.seamarks.SeaMark.Day;
     
    4644        private ActionListener alTop = new ActionListener() {
    4745                public void actionPerformed(java.awt.event.ActionEvent e) {
    48                         Iterator<Top> it = tops.keySet().iterator();
    49                         while (it.hasNext()) {
    50                                 Top top = it.next();
     46                        for (Top top : tops.keySet()) {
    5147                                JRadioButton button = tops.get(top);
    5248                                if (button.isSelected()) {
     
    5753                                        button.setBorderPainted(false);
    5854                        }
    59                         Iterator<Day> id = days.keySet().iterator();
    60                         while (id.hasNext()) {
    61                                 Day day = id.next();
     55                        for (Day day : days.keySet()) {
    6256                                JRadioButton button = days.get(day);
    6357                                if (button.isSelected()) {
     
    10498
    10599        public void enableAll(boolean state) {
    106                 Iterator<Top> it = tops.keySet().iterator();
    107                 while (it.hasNext()) {
    108                         tops.get(it.next()).setEnabled(state);
     100        for (JRadioButton button : tops.values()) {
     101                        button.setEnabled(state);
    109102                }
    110103        }
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/seamarks/SeaMark.java

    r24925 r24931  
    22
    33import javax.swing.ImageIcon;
    4 import javax.swing.JRadioButton;
    54
    65import java.util.EnumMap;
    7 import java.util.Iterator;
    86import java.util.Map;
    97import java.util.regex.Matcher;
     
    1311import org.openstreetmap.josm.command.ChangePropertyCommand;
    1412
     13import oseam.Messages;
    1514import oseam.dialogs.OSeaMAction;
    1615
     
    2625                dlg = dia;
    2726                region = Main.pref.get("tomsplugin.IALA").equals("A") ? Reg.A : Reg.B;
     27                parseNode();
    2828        }
    2929
     
    113113                groups.put(Obj.MORFAC, Grp.SPP);
    114114        }
    115        
     115
    116116        public enum Cat {
    117117                UNKNOWN, LAT_PORT, LAT_STBD, LAT_PREF_PORT, LAT_PREF_STBD, CARD_NORTH, CARD_EAST, CARD_SOUTH, CARD_WEST, LIGHT_HOUSE, LIGHT_MAJOR, LIGHT_MINOR, LIGHT_VESSEL, LIGHT_FLOAT, MOORING_BUOY
     
    576576        }
    577577
    578         public void parseMark() {
    579 
    580                 String str;
    581                 Map<String, String> keys;
    582                 keys = dlg.node.getKeys();
     578        public void parseNode() {
     579
     580                dlg.panelMain.clearSelections();
     581                dlg.manager.showVisualMessage("");
     582                String type = "";
     583                String str = "";
     584                String col = "";
     585
     586                Map<String, String> keys = dlg.node.getKeys();
     587
     588                if (keys.containsKey("seamark:type"))
     589                        type = keys.get("seamark:type");
     590
     591                for (Obj obj : objects.keySet()) {
     592                        if (objects.get(obj).equals(type))
     593                                setObject(obj);
     594                }
     595
     596                if (type.equals("light_float") || type.equals("") || keys.containsKey("seamark:light_float:colour")
     597                                || keys.containsKey("seamark:light_float:colour_pattern")) {
     598                        if (keys.containsKey("seamark:light_float:colour_pattern")) {
     599                                setObject(Obj.LITFLT);
     600                                type = "light_float";
     601                        }
     602                        if (keys.containsKey("seamark:light_float:colour")) {
     603                                col = keys.get("seamark:light_float:colour");
     604                                if (col.equals("red") || col.equals("green") || col.equals("red;green;red") || col.equals("green;red;green")) {
     605                                        setObject(Obj.BOYLAT);
     606                                } else if (col.equals("black;yellow") || col.equals("black;yellow;black") || col.equals("yellow;black")
     607                                                || col.equals("yellow;black;yellow")) {
     608                                        setObject(Obj.BOYCAR);
     609                                } else if (col.equals("black;red;black")) {
     610                                        setObject(Obj.BOYISD);
     611                                } else if (col.equals("red;white")) {
     612                                        setObject(Obj.BOYSAW);
     613                                } else if (col.equals("yellow")) {
     614                                        setObject(Obj.BOYSPP);
     615                                } else
     616                                        setObject(Obj.LITFLT);
     617                                type = "light_float";
     618                        }
     619                        if (type.equals("")) {
     620                                if (keys.containsKey("seamark:buoy_lateral:category") || keys.containsKey("seamark:buoy_lateral:shape")
     621                                                || keys.containsKey("seamark:buoy_lateral:colour")) {
     622                                        setObject(Obj.BOYLAT);
     623                                } else if (keys.containsKey("seamark:beacon_lateral:category") || keys.containsKey("seamark:beacon_lateral:shape")
     624                                                || keys.containsKey("seamark:beacon_lateral:colour")) {
     625                                        setObject(Obj.BCNLAT);
     626                                } else if (keys.containsKey("seamark:buoy_cardinal:category") || keys.containsKey("seamark:buoy_cardinal:shape")
     627                                                || keys.containsKey("seamark:buoy_cardinal:colour")) {
     628                                        setObject(Obj.BOYCAR);
     629                                } else if (keys.containsKey("seamark:beacon_cardinal:category") || keys.containsKey("seamark:beacon_cardinal:shape")
     630                                                || keys.containsKey("seamark:beacon_cardinal:colour")) {
     631                                        setObject(Obj.BCNCAR);
     632                                } else if (keys.containsKey("seamark:buoy_isolated_danger:category") || keys.containsKey("seamark:buoy_isolated_danger:shape")
     633                                                || keys.containsKey("seamark:buoy_isolated_danger:colour")) {
     634                                        setObject(Obj.BOYISD);
     635                                } else if (keys.containsKey("seamark:beacon_isolated_danger:category") || keys.containsKey("seamark:beacon_isolated_danger:shape")
     636                                                || keys.containsKey("seamark:beacon_isolated_danger:colour")) {
     637                                        setObject(Obj.BCNISD);
     638                                } else if (keys.containsKey("seamark:buoy_safe_water:category") || keys.containsKey("seamark:buoy_safe_water:shape")
     639                                                || keys.containsKey("seamark:buoy_safe_water:colour")) {
     640                                        setObject(Obj.BOYSAW);
     641                                } else if (keys.containsKey("seamark:beacon_safe_water:category") || keys.containsKey("seamark:beacon_safe_water:shape")
     642                                                || keys.containsKey("seamark:beacon_safe_water:colour")) {
     643                                        setObject(Obj.BCNSAW);
     644                                } else if (keys.containsKey("seamark:buoy_special_purpose:category") || keys.containsKey("seamark:buoy_special_purpose:shape")
     645                                                || keys.containsKey("seamark:buoy_special_purpose:colour")) {
     646                                        setObject(Obj.BOYSPP);
     647                                } else if (keys.containsKey("seamark:beacon_special_purpose:category") || keys.containsKey("seamark:beacon_special_purpose:shape")
     648                                                || keys.containsKey("seamark:beacon_special_purpose:colour")) {
     649                                        setObject(Obj.BCNSPP);
     650                                }
     651                        }
     652                }
     653
     654                if (getObject() == Obj.UNKNOWN) {
     655                        dlg.manager.showVisualMessage(Messages.getString("NoMark"));
     656                        return;
     657                }
     658
     659                if (keys.containsKey("seamark:" + type + ":name")) {
     660                        dlg.panelMain.nameBox.setText(keys.get("seamark:" + type + ":name"));
     661                        dlg.panelMain.nameBox.postActionEvent();
     662                } else if (keys.containsKey("seamark:name")) {
     663                        dlg.panelMain.nameBox.setText(keys.get("seamark:name"));
     664                        dlg.panelMain.nameBox.postActionEvent();
     665                } else if (keys.containsKey("name")) {
     666                        dlg.panelMain.nameBox.setText(keys.get("name"));
     667                        dlg.panelMain.nameBox.postActionEvent();
     668                } else
     669                        dlg.panelMain.nameBox.setText("");
     670
     671                switch (groups.get(getObject())) {
     672                case LAT:
     673                        dlg.panelMain.chanButton.doClick();
     674                        switch (getObject()) {
     675                        case BCNLAT:
     676                                if (keys.containsKey("seamark:beacon_lateral:category"))
     677                                        str = keys.get("seamark:beacon_lateral:category");
     678                                break;
     679                        case BOYLAT:
     680                                if (keys.containsKey("seamark:buoy_lateral:category"))
     681                                        str = keys.get("seamark:buoy_lateral:category");
     682                                else if (type.equals("light_float")) {
     683                                        if (region == Reg.A) {
     684                                                if (col.equals("red"))
     685                                                        dlg.panelMain.panelChan.portButton.doClick();
     686                                                else if (col.equals("green"))
     687                                                        dlg.panelMain.panelChan.stbdButton.doClick();
     688                                                else if (col.equals("red;green;red"))
     689                                                        dlg.panelMain.panelChan.prefPortButton.doClick();
     690                                                else if (col.equals("green;red;green"))
     691                                                        dlg.panelMain.panelChan.prefStbdButton.doClick();
     692                                        } else {
     693                                                if (col.equals("green"))
     694                                                        dlg.panelMain.panelChan.portButton.doClick();
     695                                                else if (col.equals("red"))
     696                                                        dlg.panelMain.panelChan.stbdButton.doClick();
     697                                                else if (col.equals("green;red;green"))
     698                                                        dlg.panelMain.panelChan.prefPortButton.doClick();
     699                                                else if (col.equals("red;green;red"))
     700                                                        dlg.panelMain.panelChan.prefStbdButton.doClick();
     701                                        }
     702                                }
     703                                break;
     704                        }
     705                        if (str.equals("port"))
     706                                dlg.panelMain.panelChan.portButton.doClick();
     707                        else if (str.equals("starboard"))
     708                                dlg.panelMain.panelChan.stbdButton.doClick();
     709                        else if (str.equals("preferred_channel_port"))
     710                                dlg.panelMain.panelChan.prefPortButton.doClick();
     711                        else if (str.equals("preferred_channel_starboard"))
     712                                dlg.panelMain.panelChan.prefStbdButton.doClick();
     713                        break;
     714                case CAR:
     715                        dlg.panelMain.hazButton.doClick();
     716                        switch (getObject()) {
     717                        case BCNCAR:
     718                                if (keys.containsKey("seamark:beacon_cardinal:category"))
     719                                        str = keys.get("seamark:beacon_cardinal:category");
     720                                break;
     721                        case BOYCAR:
     722                                if (keys.containsKey("seamark:buoy_cardinal:category"))
     723                                        str = keys.get("seamark:buoy_cardinal:category");
     724                                else if (type.equals("light_float")) {
     725                                        if (col.equals("black;yellow"))
     726                                                dlg.panelMain.panelHaz.northButton.doClick();
     727                                        else if (col.equals("yellow;black"))
     728                                                dlg.panelMain.panelHaz.southButton.doClick();
     729                                        else if (col.equals("black;yellow;black"))
     730                                                dlg.panelMain.panelHaz.eastButton.doClick();
     731                                        else if (col.equals("yellow;black;yellow"))
     732                                                dlg.panelMain.panelHaz.westButton.doClick();
     733                                }
     734                                break;
     735                        }
     736                        if (str.equals("north"))
     737                                dlg.panelMain.panelHaz.northButton.doClick();
     738                        else if (str.equals("south"))
     739                                dlg.panelMain.panelHaz.southButton.doClick();
     740                        else if (str.equals("east"))
     741                                dlg.panelMain.panelHaz.eastButton.doClick();
     742                        else if (str.equals("west"))
     743                                dlg.panelMain.panelHaz.westButton.doClick();
     744                        break;
     745                case SAW:
     746                        dlg.panelMain.chanButton.doClick();
     747                        dlg.panelMain.panelChan.safeWaterButton.doClick();
     748                        break;
     749                case ISD:
     750                        dlg.panelMain.hazButton.doClick();
     751                        dlg.panelMain.panelHaz.isolButton.doClick();
     752                        break;
     753                case SPP:
     754                        dlg.panelMain.specButton.doClick();
     755                        break;
     756                case FLT:
     757                        dlg.panelMain.lightsButton.doClick();
     758                        dlg.panelMain.panelLights.floatButton.doClick();
     759                        break;
     760                case LIT:
     761                        dlg.panelMain.lightsButton.doClick();
     762                        break;
     763                }
    583764
    584765                if (keys.containsKey("seamark:topmark:shape")) {
     
    586767                }
    587768
    588                 setFired(false);
    589                 setSectored(false);
    590                 Iterator it = keys.entrySet().iterator();
    591                 while (it.hasNext()) {
    592                         Map.Entry entry = (Map.Entry) it.next();
    593                         String key = (String) entry.getKey();
    594                         String value = ((String) entry.getValue()).trim();
     769                for (Map.Entry<String, String> entry : keys.entrySet()) {
     770                        String key = entry.getKey();
     771                        String value = entry.getValue().trim();
    595772                        if (key.contains("seamark:light:")) {
    596773                                setFired(true);
     
    641818                }
    642819
    643                 setFog(false);
    644                 setRadar(false);
    645                 setRacon(false);
    646820                if (keys.containsKey("seamark:fog_signal") || keys.containsKey("seamark:fog_signal:category")
    647821                                || keys.containsKey("seamark:fog_signal:group") || keys.containsKey("seamark:fog_signal:period")) {
     
    708882                        }
    709883                        imgStr += ".png";
    710 if (getClass().getResource(imgStr) == null)
    711 System.out.println(imgStr);
    712 else
    713                         dlg.panelMain.shapeIcon.setIcon(new ImageIcon(getClass().getResource(imgStr)));
     884                        if (getClass().getResource(imgStr) == null)
     885                                System.out.println(imgStr);
     886                        else
     887                                dlg.panelMain.shapeIcon.setIcon(new ImageIcon(getClass().getResource(imgStr)));
    714888                }
    715889
     
    749923                                        imgStr += ("_" + colStr);
    750924                                imgStr += ".png";
    751 if (getClass().getResource(imgStr) == null)
    752 System.out.println(imgStr);
    753 else
    754                                 dlg.panelMain.topIcon.setIcon(new ImageIcon(getClass().getResource(imgStr)));
    755                         }
    756                 }
    757 /*
    758                 if (hasRadar()) {
    759                         dlg.panelMain.radarIcon.setIcon(new ImageIcon(getClass().getResource("/images/Radar_Reflector_355.png")));
    760                 } else if (hasRacon()) {
    761                         dlg.panelMain.radarIcon.setIcon(new ImageIcon(getClass().getResource("/images/Radar_Station.png")));
    762                         // if (getRaType() != 0) {
    763                         // String c = (String) dlg.cbM01Racon.getSelectedItem();
    764                         // if ((getRaType() == RATYPE_RACON) && !getRaconGroup().isEmpty())
    765                         // c += ("(" + getRaconGroup() + ")");
    766                         // dlg.lM01RadarMarkeys.setText(c);
    767                         // }
    768                 }
    769 
    770                 if (hasFog()) {
    771                         dlg.panelMain.fogIcon.setIcon(new ImageIcon(getClass().getResource("/images/Fog_Signal.png")));
    772                         // if (getFogSound() != 0) {
    773                         // String c = (String) dlg.cbM01Fog.getSelectedItem();
    774                         // if (!getFogGroup().isEmpty())
    775                         // c += ("(" + getFogGroup() + ")");
    776                         // if (!getFogPeriod().isEmpty())
    777                         // c += (" " + getFogPeriod() + "s");
    778                         // dlg.lM01FogMarkeys.setText(c);
    779                         // }
    780                 }
    781 
    782                 if (isFired()) {
    783                         String lp, c;
    784                         String tmp = null;
    785                         int i1;
    786 
    787                         Col col = getColour(Ent.LIGHT);
    788                         if (col == Col.WHITE) {
    789                                 dlg.panelMain.lightIcon.setIcon(new ImageIcon(getClass().getResource("/images/Light_White_120.png")));
    790                         } else if (col == Col.RED) {
    791                                 dlg.panelMain.lightIcon.setIcon(new ImageIcon(getClass().getResource("/images/Light_Red_120.png")));
    792                         } else if (col == Col.GREEN) {
    793                                 dlg.panelMain.lightIcon.setIcon(new ImageIcon(getClass().getResource("/images/Light_Green_120.png")));
    794                         } else {
    795                                 dlg.panelMain.lightIcon.setIcon(new ImageIcon(getClass().getResource("/images/Light_Magenta_120.png")));
    796                         }
    797 
    798                          c = getLightChar(); if (c.contains("+")) { i1 = c.indexOf("+"); tmp =
    799                          c.substring(i1, c.length()); c = c.substring(0, i1); if
    800                          (!getLightGroup().isEmpty()) { c = c + "(" + getLightGroup() + ")"; }
    801                          if (tmp != null) c = c + tmp; } else if (!getLightGroup().isEmpty()) c
    802                          = c + "(" + getLightGroup() + ")"; c = c + " " + getLightColour(); lp =
    803                          getLightPeriod(); if (!lp.isEmpty()) c = c + " " + lp + "s";
    804                          }*/
     925                                if (getClass().getResource(imgStr) == null)
     926                                        System.out.println(imgStr);
     927                                else
     928                                        dlg.panelMain.topIcon.setIcon(new ImageIcon(getClass().getResource(imgStr)));
     929                        }
     930                }
     931                /*
     932                 * if (hasRadar()) { dlg.panelMain.radarIcon.setIcon(new
     933                 * ImageIcon(getClass().getResource("/images/Radar_Reflector_355.png"))); }
     934                 * else if (hasRacon()) { dlg.panelMain.radarIcon.setIcon(new
     935                 * ImageIcon(getClass().getResource("/images/Radar_Station.png"))); // if
     936                 * (getRaType() != 0) { // String c = (String)
     937                 * dlg.cbM01Racon.getSelectedItem(); // if ((getRaType() == RATYPE_RACON) &&
     938                 * !getRaconGroup().isEmpty()) // c += ("(" + getRaconGroup() + ")"); //
     939                 * dlg.lM01RadarMarkeys.setText(c); // } }
     940                 *
     941                 * if (hasFog()) { dlg.panelMain.fogIcon.setIcon(new
     942                 * ImageIcon(getClass().getResource("/images/Fog_Signal.png"))); // if
     943                 * (getFogSound() != 0) { // String c = (String)
     944                 * dlg.cbM01Fog.getSelectedItem(); // if (!getFogGroup().isEmpty()) // c +=
     945                 * ("(" + getFogGroup() + ")"); // if (!getFogPeriod().isEmpty()) // c +=
     946                 * (" " + getFogPeriod() + "s"); // dlg.lM01FogMarkeys.setText(c); // } }
     947                 *
     948                 * if (isFired()) { String lp, c; String tmp = null; int i1;
     949                 *
     950                 * Col col = getColour(Ent.LIGHT); if (col == Col.WHITE) {
     951                 * dlg.panelMain.lightIcon.setIcon(new
     952                 * ImageIcon(getClass().getResource("/images/Light_White_120.png"))); } else
     953                 * if (col == Col.RED) { dlg.panelMain.lightIcon.setIcon(new
     954                 * ImageIcon(getClass().getResource("/images/Light_Red_120.png"))); } else
     955                 * if (col == Col.GREEN) { dlg.panelMain.lightIcon.setIcon(new
     956                 * ImageIcon(getClass().getResource("/images/Light_Green_120.png"))); } else
     957                 * { dlg.panelMain.lightIcon.setIcon(new
     958                 * ImageIcon(getClass().getResource("/images/Light_Magenta_120.png"))); }
     959                 *
     960                 * c = getLightChar(); if (c.contains("+")) { i1 = c.indexOf("+"); tmp =
     961                 * c.substring(i1, c.length()); c = c.substring(0, i1); if
     962                 * (!getLightGroup().isEmpty()) { c = c + "(" + getLightGroup() + ")"; } if
     963                 * (tmp != null) c = c + tmp; } else if (!getLightGroup().isEmpty()) c = c +
     964                 * "(" + getLightGroup() + ")"; c = c + " " + getLightColour(); lp =
     965                 * getLightPeriod(); if (!lp.isEmpty()) c = c + " " + lp + "s"; }
     966                 */
    805967        }
    806968
    807969        public void saveSign() {
    808                 Iterator<String> it = dlg.node.getKeys().keySet().iterator();
    809                 String str;
    810970
    811971                Main.pref.put("tomsplugin.IALA", getRegion() == Reg.A ? "A" : "B");
    812972
    813                 while (it.hasNext()) {
    814                         str = it.next();
     973                for (String str : dlg.node.getKeys().keySet()) {
    815974                        if (str.contains("seamark"))
    816975                                if (!str.equals("seamark")) {
     
    825984                        Main.main.undoRedo.add(new ChangePropertyCommand(dlg.node, "seamark:type", objStr));
    826985
    827                         str = categories.get(category);
     986                        String str = categories.get(category);
    828987                        if (str != null)
    829988                                Main.main.undoRedo.add(new ChangePropertyCommand(dlg.node, "seamark:" + objStr + ":category", str));
     
    8511010                }
    8521011
    853                 str = tops.get(topShape);
     1012                String str = tops.get(topShape);
    8541013                if (str != null) {
    8551014                        Main.main.undoRedo.add(new ChangePropertyCommand(dlg.node, "seamark:topmark:shape", str));
Note: See TracChangeset for help on using the changeset viewer.