Ignore:
Timestamp:
2011-08-17T18:40:00+02:00 (13 years ago)
Author:
malcolmh
Message:

save

Location:
applications/editors/josm/plugins/smed/plugs/oseam/src
Files:
129 added
116 deleted
3 edited

Legend:

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

    r26423 r26545  
    9292                                }
    9393                                if (dlg.mark.getRegion() == Reg.B) {
    94                                         dlg.mark.setColour(Ent.BODY, Col.GREEN_RED_GREEN);
     94                                        dlg.mark.setColour(Ent.BODY, Col.GREEN);
     95                                        dlg.mark.addColour(Ent.BODY, Col.RED);
     96                                        dlg.mark.addColour(Ent.BODY, Col.GREEN);
    9597                                        panelPort.regionBButton.doClick();
    9698                                } else {
    97                                         dlg.mark.setColour(Ent.BODY, Col.RED_GREEN_RED);
     99                                        dlg.mark.setColour(Ent.BODY, Col.RED);
     100                                        dlg.mark.addColour(Ent.BODY, Col.GREEN);
     101                                        dlg.mark.addColour(Ent.BODY, Col.RED);
    98102                                        panelPort.regionAButton.doClick();
    99103                                }
     
    162166                                }
    163167                                if (dlg.mark.getRegion() == Reg.B) {
    164                                         dlg.mark.setColour(Ent.BODY, Col.RED_GREEN_RED);
     168                                        dlg.mark.setColour(Ent.BODY, Col.RED);
     169                                        dlg.mark.addColour(Ent.BODY, Col.GREEN);
     170                                        dlg.mark.addColour(Ent.BODY, Col.RED);
    165171                                        panelStbd.regionBButton.doClick();
    166172                                } else {
    167                                         dlg.mark.setColour(Ent.BODY, Col.GREEN_RED_GREEN);
     173                                        dlg.mark.setColour(Ent.BODY, Col.GREEN);
     174                                        dlg.mark.addColour(Ent.BODY, Col.RED);
     175                                        dlg.mark.addColour(Ent.BODY, Col.GREEN);
    168176                                        panelStbd.regionAButton.doClick();
    169177                                }
     
    194202                                dlg.panelMain.panelTop.panelCol.redButton.setEnabled(true);
    195203                                dlg.panelMain.panelTop.panelCol.redButton.doClick();
    196                                 dlg.mark.setColour(Ent.BODY, Col.RED_WHITE);
     204                                dlg.mark.setColour(Ent.BODY, Col.RED);
     205                                dlg.mark.addColour(Ent.BODY, Col.WHITE);
    197206                                safeWaterButton.setBorderPainted(true);
    198207                                panelSaw.setVisible(true);
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelHaz.java

    r26423 r26545  
    4444                        if (northButton.isSelected()) {
    4545                                dlg.mark.setCategory(Cat.CARD_NORTH);
    46                                 dlg.mark.setColour(Ent.BODY, Col.BLACK_YELLOW);
     46                                dlg.mark.setColour(Ent.BODY, Col.BLACK);
     47                                dlg.mark.addColour(Ent.BODY, Col.YELLOW);
    4748                                dlg.panelMain.panelTop.northTopButton.setEnabled(true);
    4849                                dlg.panelMain.panelTop.northTopButton.doClick();
     
    5354                        if (southButton.isSelected()) {
    5455                                dlg.mark.setCategory(Cat.CARD_SOUTH);
    55                                 dlg.mark.setColour(Ent.BODY, Col.YELLOW_BLACK);
     56                                dlg.mark.setColour(Ent.BODY, Col.YELLOW);
     57                                dlg.mark.addColour(Ent.BODY, Col.BLACK);
    5658                                dlg.panelMain.panelTop.southTopButton.setEnabled(true);
    5759                                dlg.panelMain.panelTop.southTopButton.doClick();
     
    6264                        if (eastButton.isSelected()) {
    6365                                dlg.mark.setCategory(Cat.CARD_EAST);
    64                                 dlg.mark.setColour(Ent.BODY, Col.BLACK_YELLOW_BLACK);
     66                                dlg.mark.setColour(Ent.BODY, Col.BLACK);
     67                                dlg.mark.addColour(Ent.BODY, Col.YELLOW);
     68                                dlg.mark.addColour(Ent.BODY, Col.BLACK);
    6569                                dlg.panelMain.panelTop.eastTopButton.setEnabled(true);
    6670                                dlg.panelMain.panelTop.eastTopButton.doClick();
     
    7175                        if (westButton.isSelected()) {
    7276                                dlg.mark.setCategory(Cat.CARD_WEST);
    73                                 dlg.mark.setColour(Ent.BODY, Col.YELLOW_BLACK_YELLOW);
     77                                dlg.mark.setColour(Ent.BODY, Col.YELLOW);
     78                                dlg.mark.addColour(Ent.BODY, Col.BLACK);
     79                                dlg.mark.addColour(Ent.BODY, Col.YELLOW);
    7480                                dlg.panelMain.panelTop.westTopButton.setEnabled(true);
    7581                                dlg.panelMain.panelTop.westTopButton.doClick();
     
    7985                        }
    8086                        if (isolButton.isSelected()) {
    81                                 dlg.mark.setColour(Ent.BODY, Col.BLACK_RED_BLACK);
     87                                dlg.mark.setColour(Ent.BODY, Col.BLACK);
     88                                dlg.mark.addColour(Ent.BODY, Col.RED);
     89                                dlg.mark.addColour(Ent.BODY, Col.BLACK);
    8290                                dlg.panelMain.panelTop.spheres2TopButton.setEnabled(true);
    8391                                dlg.panelMain.panelTop.spheres2TopButton.doClick();
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/seamarks/SeaMark.java

    r26423 r26545  
    33import javax.swing.ImageIcon;
    44
     5import java.util.ArrayList;
    56import java.util.EnumMap;
    67import java.util.EnumSet;
     
    180181                ShpMAP.put(Shp.CAN, "can");
    181182                ShpMAP.put(Shp.CONE, "conical");
    182                 ShpMAP.put(Shp.SPHERE, "sphere");
     183                ShpMAP.put(Shp.SPHERE, "spherial");
    183184                ShpMAP.put(Shp.BARREL, "barrel");
    184185                ShpMAP.put(Shp.FLOAT, "float");
     
    201202
    202203        public enum Col {
    203                 UNKNOWN, WHITE, RED, ORANGE, AMBER, YELLOW, GREEN, BLUE, VIOLET, BLACK, RED_GREEN_RED, GREEN_RED_GREEN, RED_WHITE, BLACK_YELLOW, BLACK_YELLOW_BLACK, YELLOW_BLACK, YELLOW_BLACK_YELLOW, BLACK_RED_BLACK
     204                UNKNOWN, WHITE, RED, ORANGE, AMBER, YELLOW, GREEN, BLUE, VIOLET, BLACK,
    204205        }
    205206
     
    216217                ColMAP.put(Col.VIOLET, "violet");
    217218                ColMAP.put(Col.BLACK, "black");
    218                 ColMAP.put(Col.RED_GREEN_RED, "red;green;red");
    219                 ColMAP.put(Col.GREEN_RED_GREEN, "green;red;green");
    220                 ColMAP.put(Col.RED_WHITE, "red;white");
    221                 ColMAP.put(Col.BLACK_YELLOW, "black;yellow");
    222                 ColMAP.put(Col.BLACK_YELLOW_BLACK, "black;yellow;black");
    223                 ColMAP.put(Col.YELLOW_BLACK, "yellow;black");
    224                 ColMAP.put(Col.YELLOW_BLACK_YELLOW, "yellow;black;yellow");
    225                 ColMAP.put(Col.BLACK_RED_BLACK, "black;red;black");
    226         }
    227 
    228         private Col bodyColour = Col.UNKNOWN;
    229 
    230         public Col getColour(Ent ent) {
     219        }
     220
     221        private ArrayList<Col> bodyColour = new ArrayList<Col>();
     222        private ArrayList<Col> topColour = new ArrayList<Col>();
     223        private ArrayList<Col> dayColour = new ArrayList<Col>();
     224        private ArrayList<Col> lightColour = new ArrayList<Col>();
     225
     226        public Col getColour(Ent ent, int i) {
    231227                switch (ent) {
    232228                case BODY:
     
    234230                case BEACON:
    235231                case FLOAT:
    236                         return bodyColour;
     232                        return bodyColour.get(i);
    237233                case TOPMARK:
    238                         return topColour;
     234                        return topColour.get(i);
    239235                case DAYMARK:
    240                         return dayColour;
    241                         // case LIGHT:
    242                         // return light.getLightColour();
     236                        return dayColour.get(i);
     237                case LIGHT:
     238                        return lightColour.get(i);
    243239                }
    244240                return Col.UNKNOWN;
     
    251247                case BEACON:
    252248                case FLOAT:
    253                         bodyColour = col;
     249                        bodyColour.clear();
     250                        bodyColour.add(col);
    254251                        break;
    255252                case TOPMARK:
    256                         topColour = col;
     253                        topColour.clear();
     254                        topColour.add(col);
    257255                        break;
    258256                case DAYMARK:
    259                         dayColour = col;
    260                         break;
    261                 // case LIGHT:
    262                 // light.setLightColour(col);
    263                 // break;
     257                        dayColour.clear();
     258                        dayColour.add(col);
     259                        break;
     260                case LIGHT:
     261                        lightColour.clear();
     262                        lightColour.add(col);
     263                        break;
     264                }
     265        }
     266
     267        public void setColour(Ent ent, int i, Col col) {
     268                switch (ent) {
     269                case BODY:
     270                case BUOY:
     271                case BEACON:
     272                case FLOAT:
     273                        bodyColour.set(i, col);
     274                        break;
     275                case TOPMARK:
     276                        topColour.set(i, col);
     277                        break;
     278                case DAYMARK:
     279                        dayColour.set(i, col);
     280                        break;
     281                case LIGHT:
     282                        lightColour.set(i, col);
     283                        break;
     284                }
     285        }
     286
     287        public void addColour(Ent ent, Col col) {
     288                switch (ent) {
     289                case BODY:
     290                case BUOY:
     291                case BEACON:
     292                case FLOAT:
     293                        bodyColour.add(col);
     294                        break;
     295                case TOPMARK:
     296                        topColour.add(col);
     297                        break;
     298                case DAYMARK:
     299                        dayColour.add(col);
     300                        break;
     301                case LIGHT:
     302                        lightColour.add(col);
     303                        break;
     304                }
     305        }
     306
     307        public void subColour(Ent ent, int i) {
     308                switch (ent) {
     309                case BODY:
     310                case BUOY:
     311                case BEACON:
     312                case FLOAT:
     313                        bodyColour.remove(i);
     314                        break;
     315                case TOPMARK:
     316                        topColour.remove(i);
     317                        break;
     318                case DAYMARK:
     319                        dayColour.remove(i);
     320                        break;
     321                case LIGHT:
     322                        lightColour.remove(i);
     323                        break;
     324                }
     325        }
     326
     327        public enum Pat {
     328                NONE, HORIZ, VERT, DIAG, SQUARE, BORDER
     329        }
     330
     331        public static final EnumMap<Pat, String> PatMAP = new EnumMap<Pat, String>(Pat.class);
     332        static {
     333                PatMAP.put(Pat.NONE, "");
     334                PatMAP.put(Pat.HORIZ, "horizontal_stripes");
     335                PatMAP.put(Pat.VERT, "vertical_stripes");
     336                PatMAP.put(Pat.DIAG, "diagonal_stripes");
     337                PatMAP.put(Pat.SQUARE, "squared");
     338                PatMAP.put(Pat.BORDER, "border_stripe");
     339        }
     340
     341        private Pat bodyPattern;
     342        private Pat topPattern;
     343        private Pat dayPattern;
     344
     345        public Pat getPattern(Ent ent) {
     346                switch (ent) {
     347                case BODY:
     348                case BUOY:
     349                case BEACON:
     350                case FLOAT:
     351                        return bodyPattern;
     352                case TOPMARK:
     353                        return topPattern;
     354                case DAYMARK:
     355                        return dayPattern;
     356                }
     357                return Pat.NONE;
     358        }
     359
     360        public void setPattern(Ent ent, Pat pat) {
     361                switch (ent) {
     362                case BODY:
     363                case BUOY:
     364                case BEACON:
     365                case FLOAT:
     366                        bodyPattern = pat;
     367                        break;
     368                case TOPMARK:
     369                        topPattern = pat;
     370                        break;
     371                case DAYMARK:
     372                        dayPattern = pat;
     373                        break;
    264374                }
    265375        }
     
    284394
    285395        private Top topShape = Top.NONE;
    286         private Col topColour = Col.UNKNOWN;
    287396
    288397        public boolean hasTopmark() {
     
    314423
    315424        private Day dayShape = Day.NONE;
    316         private Col dayColour = Col.UNKNOWN;
    317425
    318426        public boolean hasDaymark() {
     
    424532                dlg.panelMain.clearSelections();
    425533                dlg.manager.showVisualMessage("");
    426                 String typeStr = "";
    427                 String colStr = "";
    428534                String str = "";
    429535
     
    431537
    432538                if (keys.containsKey("seamark:type"))
    433                         typeStr = keys.get("seamark:type");
    434 
    435                 for (Obj obj : ObjMAP.keySet())
    436                         if (ObjMAP.get(obj).equals(typeStr))
     539                        str = keys.get("seamark:type");
     540
     541                setObject(Obj.UNKNOWN);
     542                for (Obj obj : ObjMAP.keySet()) {
     543                        if (ObjMAP.get(obj).equals(str)) {
    437544                                setObject(obj);
    438 
    439                 if (typeStr.equals("light_float") || typeStr.equals("") || keys.containsKey("seamark:light_float:colour")
    440                                 || keys.containsKey("seamark:light_float:colour_pattern")) {
    441                         if (keys.containsKey("seamark:light_float:colour_pattern")) {
    442                                 setObject(Obj.LITFLT);
    443                                 typeStr = "light_float";
    444                         }
    445                         if (keys.containsKey("seamark:light_float:colour")) {
    446                                 colStr = keys.get("seamark:light_float:colour");
    447                                 if (colStr.equals("red") || colStr.equals("green") || colStr.equals("red;green;red") || colStr.equals("green;red;green")) {
    448                                         setObject(Obj.BOYLAT);
    449                                 } else if (colStr.equals("black;yellow") || colStr.equals("black;yellow;black") || colStr.equals("yellow;black")
    450                                                 || colStr.equals("yellow;black;yellow")) {
    451                                         setObject(Obj.BOYCAR);
    452                                 } else if (colStr.equals("black;red;black")) {
    453                                         setObject(Obj.BOYISD);
    454                                 } else if (colStr.equals("red;white")) {
    455                                         setObject(Obj.BOYSAW);
    456                                 } else if (colStr.equals("yellow")) {
    457                                         setObject(Obj.BOYSPP);
    458                                 } else
    459                                         setObject(Obj.LITFLT);
    460                                 typeStr = "light_float";
    461                         }
    462                         if (typeStr.equals("")) {
    463                                 if (keys.containsKey("seamark:buoy_lateral:category") || keys.containsKey("seamark:buoy_lateral:shape")
    464                                                 || keys.containsKey("seamark:buoy_lateral:colour")) {
    465                                         setObject(Obj.BOYLAT);
    466                                         typeStr = "buoy_lateral";
    467                                 } else if (keys.containsKey("seamark:beacon_lateral:category") || keys.containsKey("seamark:beacon_lateral:shape")
    468                                                 || keys.containsKey("seamark:beacon_lateral:colour")) {
    469                                         setObject(Obj.BCNLAT);
    470                                         typeStr = "beacon_lateral";
    471                                 } else if (keys.containsKey("seamark:buoy_cardinal:category") || keys.containsKey("seamark:buoy_cardinal:shape")
    472                                                 || keys.containsKey("seamark:buoy_cardinal:colour")) {
    473                                         setObject(Obj.BOYCAR);
    474                                         typeStr = "buoy_cardinal";
    475                                 } else if (keys.containsKey("seamark:beacon_cardinal:category") || keys.containsKey("seamark:beacon_cardinal:shape")
    476                                                 || keys.containsKey("seamark:beacon_cardinal:colour")) {
    477                                         setObject(Obj.BCNCAR);
    478                                         typeStr = "beacon_cardinal";
    479                                 } else if (keys.containsKey("seamark:buoy_isolated_danger:category")
    480                                                 || keys.containsKey("seamark:buoy_isolated_danger:shape") || keys.containsKey("seamark:buoy_isolated_danger:colour")) {
    481                                         setObject(Obj.BOYISD);
    482                                         typeStr = "buoy_isolated_danger";
    483                                 } else if (keys.containsKey("seamark:beacon_isolated_danger:category")
    484                                                 || keys.containsKey("seamark:beacon_isolated_danger:shape")
    485                                                 || keys.containsKey("seamark:beacon_isolated_danger:colour")) {
    486                                         setObject(Obj.BCNISD);
    487                                         typeStr = "beacon_isolated_danger";
    488                                 } else if (keys.containsKey("seamark:buoy_safe_water:category") || keys.containsKey("seamark:buoy_safe_water:shape")
    489                                                 || keys.containsKey("seamark:buoy_safe_water:colour")) {
    490                                         setObject(Obj.BOYSAW);
    491                                         typeStr = "buoy_safe_water";
    492                                 } else if (keys.containsKey("seamark:beacon_safe_water:category") || keys.containsKey("seamark:beacon_safe_water:shape")
    493                                                 || keys.containsKey("seamark:beacon_safe_water:colour")) {
    494                                         setObject(Obj.BCNSAW);
    495                                         typeStr = "beacon_safe_water";
    496                                 } else if (keys.containsKey("seamark:buoy_special_purpose:category")
    497                                                 || keys.containsKey("seamark:buoy_special_purpose:shape") || keys.containsKey("seamark:buoy_special_purpose:colour")) {
    498                                         setObject(Obj.BOYSPP);
    499                                         typeStr = "buoy_special_purpose";
    500                                 } else if (keys.containsKey("seamark:beacon_special_purpose:category")
    501                                                 || keys.containsKey("seamark:beacon_special_purpose:shape")
    502                                                 || keys.containsKey("seamark:beacon_special_purpose:colour")) {
    503                                         setObject(Obj.BCNSPP);
    504                                         typeStr = "beacon_special_purpose";
    505                                 }
    506                         }
    507                 }
    508 
     545                        }
     546                }
     547
     548                if (str.equals("")) {
     549                        dlg.manager.showVisualMessage("No seamark");
     550                }
    509551                if (getObject() == Obj.UNKNOWN) {
    510                         dlg.manager.showVisualMessage(Messages.getString("NoMark"));
    511                         return;
    512                 }
    513 
    514                 if (keys.containsKey("seamark:" + typeStr + ":colour"))
    515                         colStr = keys.get("seamark:" + typeStr + ":colour");
    516                 for (Col col : ColMAP.keySet())
    517                         if (ColMAP.get(col).equals(colStr))
    518                                 setColour(Ent.BODY, col);
    519 
    520                 if (keys.containsKey("seamark:" + typeStr + ":name")) {
    521                         dlg.panelMain.nameBox.setText(keys.get("seamark:" + typeStr + ":name"));
    522                         dlg.panelMain.nameBox.postActionEvent();
    523                 } else if (keys.containsKey("seamark:name")) {
    524                         dlg.panelMain.nameBox.setText(keys.get("seamark:name"));
    525                         dlg.panelMain.nameBox.postActionEvent();
    526                 } else if (keys.containsKey("name")) {
    527                         dlg.panelMain.nameBox.setText(keys.get("name"));
    528                         dlg.panelMain.nameBox.postActionEvent();
    529                 } else
    530                         dlg.panelMain.nameBox.setText("");
    531 
    532                 switch (GrpMAP.get(getObject())) {
    533                 case LAT:
    534                         dlg.panelMain.chanButton.doClick();
    535                         switch (getObject()) {
    536                         case BCNLAT:
    537                                 if (keys.containsKey("seamark:beacon_lateral:category"))
    538                                         str = keys.get("seamark:beacon_lateral:category");
    539                                 break;
    540                         case BOYLAT:
    541                                 if (keys.containsKey("seamark:buoy_lateral:category"))
    542                                         str = keys.get("seamark:buoy_lateral:category");
    543                                 else if (typeStr.equals("light_float")) {
    544                                         if (region == Reg.A) {
    545                                                 if (colStr.equals("red"))
    546                                                         str = "port";
    547                                                 else if (colStr.equals("green"))
    548                                                         str = "starboard";
    549                                                 else if (colStr.equals("red;green;red"))
    550                                                         str = "preferred_channel_port";
    551                                                 else if (colStr.equals("green;red;green"))
    552                                                         str = "preferred_channel_starboard";
    553                                         } else {
    554                                                 if (colStr.equals("green"))
    555                                                         str = "port";
    556                                                 else if (colStr.equals("red"))
    557                                                         str = "starboard";
    558                                                 else if (colStr.equals("green;red;green"))
    559                                                         str = "preferred_channel_port";
    560                                                 else if (colStr.equals("red;green;red"))
    561                                                         str = "preferred_channel_starboard";
     552                        dlg.manager.showVisualMessage("Seamark not recognised");
     553                }
     554
     555                setName("");
     556                for (Obj obj : ObjMAP.keySet()) {
     557                        if (keys.containsKey("seamark:" + ObjMAP.get(obj) + ":name")) {
     558                                str = keys.get("seamark:" + ObjMAP.get(obj) + ":name");
     559                                setName(str);
     560                        }
     561                }
     562                if (keys.containsKey("seamark:name")) {
     563                        str = keys.get("seamark:name");
     564                        setName(str);
     565                }
     566                if (getName().isEmpty()) {
     567                        if (keys.containsKey("name")) {
     568                                str = keys.get("name");
     569                                setName(str);
     570                        }
     571                }
     572
     573                for (Obj obj : ObjMAP.keySet()) {
     574                        if (keys.containsKey("seamark:" + ObjMAP.get(obj) + ":category")) {
     575                                str = keys.get("seamark:" + ObjMAP.get(obj) + ":category");
     576                                setCategory(Cat.UNKNOWN);
     577                                for (Cat cat : CatMAP.keySet()) {
     578                                        if (CatMAP.get(cat).equals(str)) {
     579                                                setCategory(cat);
    562580                                        }
    563581                                }
    564                                 break;
    565                         }
    566                         if (str.equals("port")) {
    567                                 setCategory(Cat.LAT_PORT);
    568                                 dlg.panelMain.panelChan.portButton.doClick();
    569                         } else if (str.equals("starboard")) {
    570                                 setCategory(Cat.LAT_STBD);
    571                                 dlg.panelMain.panelChan.stbdButton.doClick();
    572                         } else if (str.equals("preferred_channel_port")) {
    573                                 setCategory(Cat.LAT_PREF_PORT);
    574                                 dlg.panelMain.panelChan.prefPortButton.doClick();
    575                         } else if (str.equals("preferred_channel_starboard")) {
    576                                 setCategory(Cat.LAT_PREF_STBD);
    577                                 dlg.panelMain.panelChan.prefStbdButton.doClick();
    578                         }
    579                         break;
    580                 case CAR:
    581                         dlg.panelMain.hazButton.doClick();
    582                         switch (getObject()) {
    583                         case BCNCAR:
    584                                 if (keys.containsKey("seamark:beacon_cardinal:category"))
    585                                         str = keys.get("seamark:beacon_cardinal:category");
    586                                 break;
    587                         case BOYCAR:
    588                                 if (keys.containsKey("seamark:buoy_cardinal:category"))
    589                                         str = keys.get("seamark:buoy_cardinal:category");
    590                                 else if (typeStr.equals("light_float")) {
    591                                         if (colStr.equals("black;yellow"))
    592                                                 str = "north";
    593                                         else if (colStr.equals("yellow;black"))
    594                                                 str = "south";
    595                                         else if (colStr.equals("black;yellow;black"))
    596                                                 str = "east";
    597                                         else if (colStr.equals("yellow;black;yellow"))
    598                                                 str = "west";
     582                        }
     583                }
     584
     585                for (Obj obj : ObjMAP.keySet()) {
     586                        if (keys.containsKey("seamark:" + ObjMAP.get(obj) + ":shape")) {
     587                                str = keys.get("seamark:" + ObjMAP.get(obj) + ":shape");
     588                                setShape(Shp.UNKNOWN);
     589                                for (Shp shp : ShpMAP.keySet()) {
     590                                        if (ShpMAP.get(shp).equals(str)) {
     591                                                setShape(shp);
     592                                        }
    599593                                }
    600                                 break;
    601                         }
    602                         if (str.equals("north")) {
    603                                 setCategory(Cat.CARD_NORTH);
    604                                 dlg.panelMain.panelHaz.northButton.doClick();
    605                         } else if (str.equals("south")) {
    606                                 setCategory(Cat.CARD_SOUTH);
    607                                 dlg.panelMain.panelHaz.southButton.doClick();
    608                         } else if (str.equals("east")) {
    609                                 setCategory(Cat.CARD_EAST);
    610                                 dlg.panelMain.panelHaz.eastButton.doClick();
    611                         } else if (str.equals("west")) {
    612                                 setCategory(Cat.CARD_WEST);
    613                                 dlg.panelMain.panelHaz.westButton.doClick();
    614                         }
    615                         break;
    616                 case SAW:
    617                         dlg.panelMain.chanButton.doClick();
    618                         dlg.panelMain.panelChan.safeWaterButton.doClick();
    619                         break;
    620                 case ISD:
    621                         dlg.panelMain.hazButton.doClick();
    622                         dlg.panelMain.panelHaz.isolButton.doClick();
    623                         break;
    624                 case SPP:
    625                         dlg.panelMain.specButton.doClick();
    626                         break;
    627                 case SIS:
    628                         dlg.panelMain.lightsButton.doClick();
    629                         dlg.panelMain.panelLights.stationButton.doClick();
    630                         break;
    631                 case LIT:
    632                         dlg.panelMain.lightsButton.doClick();
    633                         break;
    634                 }
    635 
    636                 if (keys.containsKey("seamark:" + typeStr + ":shape"))
    637                         str = keys.get("seamark:" + typeStr + ":shape");
    638                 else if (typeStr.equals("light_float"))
    639                         str = "float";
    640                 else
    641                         str = "";
    642                 if ((str.isEmpty() && (EntMAP.get(getObject()) == Ent.BEACON)) || str.equals("stake"))
    643                         str = "beacon";
    644                 if (!str.isEmpty()) {
    645                         for (Shp shp : ShpMAP.keySet()) {
    646                                 if (ShpMAP.get(shp).equals(str)) {
    647                                         switch (GrpMAP.get(getObject())) {
    648                                         case LAT:
    649                                                 switch (getCategory()) {
    650                                                 case LAT_PORT:
    651                                                 case LAT_PREF_PORT:
    652                                                         if (dlg.panelMain.panelChan.panelPort.shapes.get(shp) != null)
    653                                                                 dlg.panelMain.panelChan.panelPort.shapes.get(shp).doClick();
    654                                                         break;
    655                                                 case LAT_STBD:
    656                                                 case LAT_PREF_STBD:
    657                                                         if (dlg.panelMain.panelChan.panelStbd.shapes.get(shp) != null)
    658                                                                 dlg.panelMain.panelChan.panelStbd.shapes.get(shp).doClick();
    659                                                         break;
     594                        }
     595                }
     596
     597                for (Obj obj : ObjMAP.keySet()) {
     598                        if (keys.containsKey("seamark:" + ObjMAP.get(obj) + ":colour")) {
     599                                str = keys.get("seamark:" + ObjMAP.get(obj) + ":colour");
     600                                bodyColour.clear();
     601                                for (String item : str.split(";")) {
     602                                        for (Col col : ColMAP.keySet()) {
     603                                                if (ColMAP.get(col).equals(item)) {
     604                                                        bodyColour.add(col);
    660605                                                }
    661                                                 break;
    662                                         case SAW:
    663                                                 if (dlg.panelMain.panelChan.panelSaw.shapes.get(shp) != null)
    664                                                         dlg.panelMain.panelChan.panelSaw.shapes.get(shp).doClick();
    665                                                 break;
    666                                         case CAR:
    667                                         case ISD:
    668                                                 if (dlg.panelMain.panelHaz.shapes.get(shp) != null)
    669                                                         dlg.panelMain.panelHaz.shapes.get(shp).doClick();
    670                                                 break;
    671                                         case SPP:
    672                                                 if (dlg.panelMain.panelSpec.shapes.get(shp) != null)
    673                                                         dlg.panelMain.panelSpec.shapes.get(shp).doClick();
    674                                                 break;
    675606                                        }
    676                                         break;
    677607                                }
    678608                        }
    679609                }
    680610
    681                 if (keys.containsKey("seamark:topmark:shape")) {
    682                         str = keys.get("seamark:topmark:shape");
    683                 }
    684                 /*
    685                  * for (Map.Entry<String, String> entry : keys.entrySet()) { String key =
    686                  * entry.getKey(); String value = entry.getValue().trim(); if
    687                  * (key.contains("seamark:light:")) { light.setFired(true); int index = 0;
    688                  * key = key.substring(14); if (key.matches("^\\d:.*")) { index =
    689                  * key.charAt(0) - '0'; key = key.substring(2); } else if
    690                  * (key.matches("^\\d$")) { index = key.charAt(0) - '0'; String values[] =
    691                  * value.split(":"); if (values[0].equals("red")) lightColour[index] =
    692                  * Col.RED; else if (values[0].equals("green")) lightColour[index] =
    693                  * Col.GREEN; else if (values[0].equals("white")) lightColour[index] =
    694                  * Col.WHITE; if (values.length > 1) Bearing1[index] = values[1]; if
    695                  * (values.length > 2) Bearing2[index] = values[2]; } else { index = 0; } if
    696                  * (index != 0) setSectored(true); if (key.equals("colour")) { if
    697                  * (value.equals("red")) lightColour[index] = Col.RED; else if
    698                  * (value.equals("green")) lightColour[index] = Col.GREEN; else if
    699                  * (value.equals("white")) lightColour[index] = Col.WHITE; } else if
    700                  * (key.equals("character")) { LightChar[index] = value; } else if
    701                  * (key.equals("group")) { LightGroup[index] = value; } else if
    702                  * (key.equals("period")) { LightPeriod[index] = value; } else if
    703                  * (key.equals("height")) { Height[index] = value; } else if
    704                  * (key.equals("range")) { Range[index] = value; } } }
    705                  */
    706                 if (keys.containsKey("seamark:fog_signal") || keys.containsKey("seamark:fog_signal:category")
    707                                 || keys.containsKey("seamark:fog_signal:group") || keys.containsKey("seamark:fog_signal:period")) {
    708                         setFog(true);
    709                         if (keys.containsKey("seamark:fog_signal:category")) {
    710                                 str = keys.get("seamark:fog_signal:category");
    711                                 if (str.equals("horn"))
    712                                         setFogSound(Fog.HORN);
    713                                 else if (str.equals("siren"))
    714                                         setFogSound(Fog.SIREN);
    715                                 else if (str.equals("diaphone"))
    716                                         setFogSound(Fog.DIA);
    717                                 else if (str.equals("bell"))
    718                                         setFogSound(Fog.BELL);
    719                                 else if (str.equals("whis"))
    720                                         setFogSound(Fog.WHIS);
    721                                 else if (str.equals("gong"))
    722                                         setFogSound(Fog.GONG);
    723                                 else if (str.equals("explosive"))
    724                                         setFogSound(Fog.EXPLOS);
    725                                 else
    726                                         setFogSound(Fog.UNKNOWN);
    727                         }
    728                         if (keys.containsKey("seamark:fog_signal:group"))
    729                                 setFogGroup(keys.get("seamark:fog_signal:group"));
    730                         if (keys.containsKey("seamark:fog_signal:period"))
    731                                 setFogPeriod(keys.get("seamark:fog_signal:period"));
    732                 }
    733 
    734                 if (keys.containsKey("seamark:radar_transponder") || keys.containsKey("seamark:radar_transponder:category")
    735                                 || keys.containsKey("seamark:radar_transponder:group")) {
    736                         setRacon(true);
    737                         if (keys.containsKey("seamark:radar_transponder:category")) {
    738                                 str = keys.get("seamark:radar_transponder:category");
    739                                 if (str.equals("racon"))
    740                                         setRaType(Rtb.RACON);
    741                                 else if (str.equals("ramark"))
    742                                         setRaType(Rtb.RAMARK);
    743                                 else if (str.equals("leading"))
    744                                         setRaType(Rtb.LEADING);
    745                                 else
    746                                         setRaType(Rtb.UNKNOWN);
    747                         }
    748                         if (keys.containsKey("seamark:radar_transponder:group"))
    749                                 setRaconGroup(keys.get("seamark:radar_transponder:group"));
    750                 } else if (keys.containsKey("seamark:radar_reflector"))
    751                         setRadar(true);
     611                for (Obj obj : ObjMAP.keySet()) {
     612                        if (keys.containsKey("seamark:" + ObjMAP.get(obj) + ":colour_pattern")) {
     613                                str = keys.get("seamark:" + ObjMAP.get(obj) + ":colour_pattern");
     614                                setPattern(Ent.BODY, Pat.NONE);
     615                                for (Pat pat : PatMAP.keySet()) {
     616                                        if (PatMAP.get(pat).equals(str)) {
     617                                                setPattern(Ent.BODY, pat);
     618                                        }
     619                                }
     620                        }
     621                }
     622
    752623        }
    753624
     
    764635
    765636                String imgStr = "/images/";
    766                 switch (dlg.mark.getObject()) {
    767                 case BCNCAR:
    768                 case BOYCAR:
    769                 case FLTCAR:
    770                         switch (dlg.mark.getShape()) {
    771                         case TOWER:
    772                                 imgStr += "Cardinal_Tower_";
    773                                 break;
    774                         case PILLAR:
    775                                 imgStr += "Cardinal_Pillar_";
    776                                 break;
    777                         case SPAR:
    778                                 imgStr += "Cardinal_Spar_";
    779                                 break;
    780                         case CAN:
    781                                 imgStr += "Cardinal_Can_";
    782                                 break;
    783                         case CONE:
    784                                 imgStr += "Cardinal_Cone_";
    785                                 break;
    786                         case SPHERE:
    787                                 imgStr += "Cardinal_Sphere_";
    788                                 break;
    789                         case FLOAT:
    790                                 imgStr += "Cardinal_Float_";
    791                                 break;
    792                         case BEACON:
    793                                 imgStr += "Cardinal_Beacon_";
    794                                 break;
    795                         default:
    796                                 if (dlg.mark.getObject() == Obj.BCNCAR)
    797                                         imgStr += "Cardinal_Beacon_";
    798                                 else
    799                                         imgStr += "Cardinal_Pillar_";
    800                         }
    801                         switch (dlg.mark.getCategory()) {
    802                         case CARD_NORTH:
    803                                 imgStr += "North.png";
    804                                 break;
    805                         case CARD_SOUTH:
    806                                 imgStr += "South.png";
    807                                 break;
    808                         case CARD_EAST:
    809                                 imgStr += "East.png";
    810                                 break;
    811                         case CARD_WEST:
    812                                 imgStr += "West.png";
    813                                 break;
    814                         }
    815                         break;
    816                 case BCNLAT:
    817                 case BOYLAT:
    818                 case FLTLAT:
    819                         switch (dlg.mark.getShape()) {
    820                         case TOWER:
    821                                 imgStr += "Lateral_Tower_";
    822                                 break;
    823                         case PILLAR:
    824                                 imgStr += "Lateral_Pillar_";
    825                                 break;
    826                         case SPAR:
    827                                 imgStr += "Lateral_Spar_";
    828                                 break;
    829                         case CAN:
    830                                 imgStr += "Lateral_Can_";
    831                                 break;
    832                         case CONE:
    833                                 imgStr += "Lateral_Cone_";
    834                                 break;
    835                         case SPHERE:
    836                                 imgStr += "Lateral_Sphere_";
    837                                 break;
    838                         case FLOAT:
    839                                 imgStr += "Lateral_Float_";
    840                                 break;
    841                         case BEACON:
    842                                 imgStr += "Lateral_Beacon_";
    843                                 break;
    844                         case STAKE:
    845                                 imgStr += "Lateral_Stake_";
    846                                 break;
    847                         case PERCH:
    848                                 imgStr += "Lateral_Perch_";
    849                                 break;
    850                         default:
    851                                 if (dlg.mark.getObject() == Obj.BCNLAT)
    852                                         imgStr += "Lateral_Beacon_";
    853                                 else
    854                                         imgStr += "Lateral_Pillar_";
    855                         }
    856                         switch (dlg.mark.getCategory()) {
    857                         case LAT_PORT:
    858                                 if (getShape() == Shp.PERCH) {
    859                                         imgStr += "Port.png";
    860                                         break;
    861                                 }
    862                                 switch (getRegion()) {
    863                                 case A:
    864                                         imgStr += "Red.png";
    865                                         break;
    866                                 case B:
    867                                         imgStr += "Green.png";
    868                                         break;
    869                                 case C:
    870                                         imgStr += "Red_White_Red_White.png";
    871                                         break;
    872                                 }
    873                                 break;
    874                         case LAT_STBD:
    875                                 if (getShape() == Shp.PERCH) {
    876                                         imgStr += "Starboard.png";
    877                                         break;
    878                                 }
    879                                 switch (getRegion()) {
    880                                 case A:
    881                                         imgStr += "Green.png";
    882                                         break;
    883                                 case B:
    884                                         imgStr += "Red.png";
    885                                         break;
    886                                 case C:
    887                                         imgStr += "Green_White_Green_White.png";
    888                                         break;
    889                                 }
    890                                 break;
    891                         case LAT_PREF_PORT:
    892                                 if (getShape() == Shp.STAKE || getShape() == Shp.PERCH) {
    893                                         imgStr = "/images/";
    894                                         break;
    895                                 }
    896                                 switch (getRegion()) {
    897                                 case A:
    898                                         imgStr += "Red_Green_Red.png";
    899                                         break;
    900                                 case B:
    901                                         imgStr += "Green_Red_Green.png";
    902                                         break;
    903                                 case C:
    904                                         imgStr = imgStr.replaceFirst("Lateral", "Special_Purpose");
    905                                         imgStr += "Red_Green_Red_Green.png";
    906                                         break;
    907                                 }
    908                                 break;
    909                         case LAT_PREF_STBD:
    910                                 if (getShape() == Shp.STAKE || getShape() == Shp.PERCH) {
    911                                         imgStr = "/images/";
    912                                         break;
    913                                 }
    914                                 switch (getRegion()) {
    915                                 case A:
    916                                         imgStr += "Green_Red_Green.png";
    917                                         break;
    918                                 case B:
    919                                         imgStr += "Red_Green_Red.png";
    920                                         break;
    921                                 case C:
    922                                         imgStr = imgStr.replaceFirst("Lateral", "Special_Purpose");
    923                                         imgStr += "Red_Green_Red_Green.png";
    924                                         break;
    925                                 }
    926                                 break;
    927                         }
    928                         break;
    929                 case BCNSAW:
    930                 case BOYSAW:
    931                 case FLTSAW:
    932                         switch (dlg.mark.getShape()) {
    933                         case PILLAR:
    934                                 imgStr += "Safe_Water_Pillar.png";
    935                                 break;
    936                         case SPAR:
    937                                 imgStr += "Safe_Water_Spar.png";
    938                                 break;
    939                         case SPHERE:
    940                                 imgStr += "Safe_Water_Sphere.png";
    941                                 break;
    942                         case FLOAT:
    943                                 imgStr += "Safe_Water_Float.png";
    944                                 break;
    945                         case BEACON:
    946                                 imgStr += "Safe_Water_Beacon.png";
    947                                 break;
    948                         default:
    949                                 if (dlg.mark.getObject() == Obj.BCNSAW)
    950                                         imgStr += "Safe_Water_Beacon.png";
    951                                 else
    952                                         imgStr += "Safe_Water_Pillar.png";
    953                         }
    954                         break;
     637                switch (dlg.mark.getShape()) {
     638                case TOWER:
     639                        imgStr += "Tower";
     640                        break;
     641                case PILLAR:
     642                        imgStr += "Pillar";
     643                        break;
     644                case SPAR:
     645                        imgStr += "Spar";
     646                        break;
     647                case CAN:
     648                        imgStr += "Can";
     649                        break;
     650                case CONE:
     651                        imgStr += "Cone";
     652                        break;
     653                case SPHERE:
     654                        imgStr += "Sphere";
     655                        break;
     656                case FLOAT:
     657                        imgStr += "Float_Minor";
     658                        break;
     659                case BEACON:
     660                        imgStr += "Beacon";
     661                        break;
     662                case SUPER:
     663                        imgStr += "Float_Major";
     664                        break;
     665                case STAKE:
     666                        imgStr += "Stake";
     667                        break;
     668                case PERCH:
     669                        imgStr += "Perch";
     670                        break;
     671                default:
     672                        if (EntMAP.get(dlg.mark.getObject()) == Ent.BEACON)
     673                                imgStr += "Beacon";
     674                        else
     675                                imgStr += "Pillar";
     676                }
     677                for (Col col : bodyColour) {
     678                        switch (col) {
     679                        case WHITE:
     680                                imgStr += "_White";
     681                                break;
     682                        case RED:
     683                                imgStr += "_Red";
     684                                break;
     685                        case ORANGE:
     686                                imgStr += "_Orange";
     687                                break;
     688                        case AMBER:
     689                                imgStr += "_Amber";
     690                                break;
     691                        case YELLOW:
     692                                imgStr += "_Yellow";
     693                                break;
     694                        case GREEN:
     695                                imgStr += "_Green";
     696                                break;
     697                        case BLUE:
     698                                imgStr += "_Blue";
     699                                break;
     700                        case VIOLET:
     701                                imgStr += "_Violet";
     702                                break;
     703                        case BLACK:
     704                                imgStr += "_Black";
     705                                break;
     706                        }
    955707                }
    956708                if (!imgStr.equals("/images/")) {
     709                        imgStr += ".png";
    957710                        if (getClass().getResource(imgStr) == null) {
    958711                                System.out.println("Missing image: " + imgStr);
     
    991744                        if (str != null)
    992745                                Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":colour", str));
    993 
    994                         switch (bodyColour) {
    995                         case RED_GREEN_RED:
    996                         case GREEN_RED_GREEN:
    997                         case BLACK_YELLOW:
    998                         case BLACK_YELLOW_BLACK:
    999                         case YELLOW_BLACK:
    1000                         case YELLOW_BLACK_YELLOW:
    1001                         case BLACK_RED_BLACK:
    1002                                 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":colour_pattern", "horizontal stripes"));
    1003                                 break;
    1004                         case RED_WHITE:
    1005                                 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" + objStr + ":colour_pattern", "vertical stripes"));
    1006                                 break;
    1007                         }
    1008                 }
     746                        /*
     747                         * switch (bodyColour) { case RED_GREEN_RED: case GREEN_RED_GREEN: case
     748                         * BLACK_YELLOW: case BLACK_YELLOW_BLACK: case YELLOW_BLACK: case
     749                         * YELLOW_BLACK_YELLOW: case BLACK_RED_BLACK: Main.main.undoRedo.add(new
     750                         * ChangePropertyCommand(node, "seamark:" + objStr + ":colour_pattern",
     751                         * "horizontal stripes")); break; case RED_WHITE:
     752                         * Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:" +
     753                         * objStr + ":colour_pattern", "vertical stripes")); break; }
     754                         */}
    1009755
    1010756                String str = TopMAP.get(topShape);
Note: See TracChangeset for help on using the changeset viewer.