Ignore:
Timestamp:
2010-08-04T10:41:59+02:00 (14 years ago)
Author:
malcolmh
Message:

parseSeaMark extended for new types

Location:
applications/editors/josm/plugins/toms/src/toms
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/toms/src/toms/dialogs/SmpDialogAction.java

    r22557 r22561  
    347347                        }
    348348
    349                         if (keys.containsKey("seamark:buoy_lateral:category") == true) {
     349                        if ((keys.containsKey("seamark:buoy_lateral:category") == true)
     350                                        || (keys.containsKey("seamark:beacon_lateral:category") == true)) {
    350351
    351352                                buoy = null; // Prototyp der Lateraltonne
     
    353354                                String cat; // Kathegorie
    354355
    355                                 if (keys.containsKey("seamark:buoy_lateral:colour") == false) {
     356                                if ((keys.containsKey("seamark:buoy_lateral:colour") == false)
     357                                                && (keys.containsKey("seamark:beacon_lateral:colour") == false)) {
    356358                                        buoy = new BuoyUkn(this, "Parse-Error: Buoy without colour");
    357359                                        buoy.setNode(node);
     
    359361                                }
    360362
    361                                 if (keys.containsKey("seamark:buoy_lateral:name"))
    362                                         if (name.compareTo("") == 0) {
    363                                                 // name nur ueberschreiben, wenn nicht anderweitig gesetzt
     363                                if (name.compareTo("") == 0) {
     364                                        if (keys.containsKey("seamark:buoy_lateral:name"))
    364365                                                name = keys.get("seamark:buoy_lateral:name");
    365 
    366                                         }
    367 
    368                                 str = keys.get("seamark:buoy_lateral:colour");
    369                                 cat = keys.get("seamark:buoy_lateral:category");
     366                                        if (keys.containsKey("seamark:beacon_lateral:name"))
     367                                                name = keys.get("seamark:beacon_lateral:name");
     368                                }
     369
     370                                if (keys.containsKey("seamark:buoy_lateral:category") == true) {
     371                                        str = keys.get("seamark:buoy_lateral:colour");
     372                                        cat = keys.get("seamark:buoy_lateral:category");
     373                                } else {
     374                                        str = keys.get("seamark:beacon_lateral:colour");
     375                                        cat = keys.get("seamark:beacon_lateral:category");
     376                                }
    370377
    371378                                if (cat.compareTo("port") == 0) {
     
    400407
    401408                                        buoy = new BuoyLat(this, SeaMark.PREF_PORT_HAND);
    402                                         if (str.compareTo("red;green;red") == 0
    403                                                         || str.compareTo("red-green-red") == 0) {
     409                                        if (str.compareTo("red;green;red") == 0) {
    404410                                                buoy.setRegion(SeaMark.IALA_A);
    405411                                                buoy.setColour(SeaMark.RED_GREEN_RED);
     
    416422
    417423                                        buoy = new BuoyLat(this, SeaMark.PREF_STARBOARD_HAND);
    418                                         if (str.compareTo("green;red;green") == 0
    419                                                         || str.compareTo("green-red-green") == 0) {
     424                                        if (str.compareTo("green;red;green") == 0) {
    420425                                                buoy.setRegion(SeaMark.IALA_A);
    421426                                                buoy.setColour(SeaMark.GREEN_RED_GREEN);
     
    466471                                                        // true)
    467472                        // Test auf Kardinal-
    468                         if (keys.containsKey("seamark:buoy_cardinal:category") == true) {
     473                        if ((keys.containsKey("seamark:buoy_cardinal:category") == true)
     474                                        || (keys.containsKey("seamark:beacon_cardinal:category") == true)) {
    469475
    470476                                buoy = null; // Prototyp der Kardinaltonne
     
    472478                                String cat; // Kathegorie
    473479
    474                                 if (keys.containsKey("seamark:buoy_cardinal:colour") == false) {
    475                                         buoy = new BuoyUkn(this, "Parse-Error: Tonne ohne Farbe");
     480                                if ((keys.containsKey("seamark:buoy_cardinal:colour") == false)
     481                                                && (keys.containsKey("seamark:beacon_cardinal:colour") == false)) {
     482                                        buoy = new BuoyUkn(this, "Parse-Error: No colour set");
    476483                                        buoy.setNode(node);
    477484                                        return;
    478485                                }
    479486
    480                                 if (keys.containsKey("seamark:buoy_cardinal:name"))
    481                                         if (name.compareTo("") == 0) {
    482                                                 // name nur ueberschreiben, wenn nicht anderweitig gesetzt
     487                                if (name.compareTo("") == 0) {
     488                                        if (keys.containsKey("seamark:buoy_cardinal:name"))
    483489                                                name = keys.get("seamark:buoy_lateral:name");
    484                                         }
    485 
    486                                 str = keys.get("seamark:buoy_cardinal:colour");
    487                                 cat = keys.get("seamark:buoy_cardinal:category");
     490                                        if (keys.containsKey("seamark:beacon_cardinal:name"))
     491                                                name = keys.get("seamark:beacon_lateral:name");
     492                                }
     493
     494                                if (keys.containsKey("seamark:buoy_cardinal:category") == true) {
     495                                        str = keys.get("seamark:buoy_cardinal:colour");
     496                                        cat = keys.get("seamark:buoy_cardinal:category");
     497                                } else {
     498                                        str = keys.get("seamark:beacon_cardinal:colour");
     499                                        cat = keys.get("seamark:beacon_cardinal:category");
     500                                }
    488501
    489502                                // Test auf Kardinaltonne Nord
    490                                 if (str.compareTo("black;yellow") == 0
    491                                                 || str.compareTo("black-yellow") == 0) {
     503                                if (str.compareTo("black;yellow") == 0) {
    492504
    493505                                        buoy = new BuoyCard(this, SeaMark.CARD_NORTH);
     
    501513
    502514                                // Test auf Kardinaltonne Ost
    503                                 if (str.compareTo("black;yellow;black") == 0
    504                                                 || str.compareTo("black-yellow-black") == 0) {
     515                                if (str.compareTo("black;yellow;black") == 0) {
    505516
    506517                                        buoy = new BuoyCard(this, SeaMark.CARD_EAST);
     
    514525
    515526                                // Test auf Kardinaltonne Sued
    516                                 if (str.compareTo("yellow;black") == 0
    517                                                 || str.compareTo("yellow-black") == 0) {
     527                                if (str.compareTo("yellow;black") == 0) {
    518528
    519529                                        buoy = new BuoyCard(this, SeaMark.CARD_SOUTH);
     
    527537
    528538                                // Test auf Kardinaltonne West
    529                                 if (str.compareTo("yellow;black;yellow") == 0
    530                                                 || str.compareTo("yellow-black-yellow") == 0) {
     539                                if (str.compareTo("yellow;black;yellow") == 0) {
    531540
    532541                                        buoy = new BuoyCard(this, SeaMark.CARD_WEST);
     
    571580                        }
    572581
    573                         // Test auf Ansteuertonne (buoy_safewater
     582                        // Test buoy_safewater
    574583                        if (keys.containsKey("seamark:buoy_safewater:shape") == true) {
    575584
    576585                                if (keys.containsKey("seamark:buoy_safewater:colour") == false) {
    577                                         buoy = new BuoyUkn(this, "Parse-Error: Tonne ohne Farbe");
     586                                        buoy = new BuoyUkn(this, "Parse-Error: No colour set");
    578587                                        buoy.setNode(node);
    579588                                        return;
     
    582591                                str = keys.get("seamark:buoy_safewater:colour");
    583592                                if (str.compareTo("red;white") != 0) {
    584                                         buoy = new BuoyUkn(this, "Parse-Error: Tonne mit falscher Farbe");
     593                                        buoy = new BuoyUkn(this, "Parse-Error: Invalid colour");
    585594                                        buoy.setNode(node);
    586595                                        return;
    587596                                }
    588597
     598                                buoy = new BuoySaw(this, SeaMark.SAFE_WATER);
    589599                                buoy.setName(name);
    590600                                buoy.setColour(SeaMark.RED_WHITE);
     601
     602                                if (buoy.parseTopMark(node) == false) {
     603                                        str = buoy.getErrMsg();
     604                                        if (str == null)
     605                                                buoy.setValid(false);
     606                                }
     607
     608                                if (buoy.parseLight(node) == false) {
     609                                        str = buoy.getErrMsg();
     610                                        if (str == null)
     611                                                buoy.setValid(false);
     612                                }
     613
     614                                if (buoy.parseShape(node) == false) {
     615                                        str = buoy.getErrMsg();
     616                                        if (str == null)
     617                                                buoy = new BuoyUkn(this, str);
     618                                        buoy.setNode(node);
     619                                        return;
     620                                }
     621
     622                                buoy.setValid(true);
     623                                buoy.setNode(node);
     624                                buoy.setBuoyIndex(5);
     625                                cbM01StyleOfMark.setSelectedIndex(buoy.getStyleIndex());
     626                                buoy.paintSign();
     627
     628                                return;
     629
     630                        }
     631
     632                        // Test buoy_special_purpose
     633                        if (keys.containsKey("seamark:buoy_special_purpose:shape") == true) {
     634
     635                                if (keys.containsKey("seamark:buoy_special_purpose:colour") == false) {
     636                                        buoy = new BuoyUkn(this, "Parse-Error: No colour set");
     637                                        buoy.setNode(node);
     638                                        return;
     639                                }
     640
     641                                str = keys.get("seamark:buoy_special_purpose:colour");
     642                                if (str.compareTo("yellow") != 0) {
     643                                        buoy = new BuoyUkn(this, "Parse-Error: Invalid colour");
     644                                        buoy.setNode(node);
     645                                        return;
     646                                }
     647
     648                                buoy = new BuoySpec(this, SeaMark.SPECIAL_PURPOSE);
     649                                buoy.setName(name);
     650                                buoy.setColour(SeaMark.YELLOW);
     651
     652                                if (buoy.parseTopMark(node) == false) {
     653                                        str = buoy.getErrMsg();
     654                                        if (str == null)
     655                                                buoy.setValid(false);
     656                                }
     657
     658                                if (buoy.parseLight(node) == false) {
     659                                        str = buoy.getErrMsg();
     660                                        if (str == null)
     661                                                buoy.setValid(false);
     662                                }
     663
     664                                if (buoy.parseShape(node) == false) {
     665                                        str = buoy.getErrMsg();
     666                                        if (str == null)
     667                                                buoy = new BuoyUkn(this, str);
     668                                        buoy.setNode(node);
     669                                        return;
     670                                }
     671
     672                                buoy.setValid(true);
     673                                buoy.setNode(node);
     674                                buoy.setBuoyIndex(5);
     675                                cbM01StyleOfMark.setSelectedIndex(buoy.getStyleIndex());
     676                                buoy.paintSign();
     677
     678                                return;
     679
     680                        }
     681
     682                        // Test buoy_isolated_danger
     683                        if ((keys.containsKey("seamark:buoy_isolated_danger:shape") == true)
     684                                        || (keys.containsKey("seamark:beacon_isolated_danger:shape") == true)) {
     685
     686                                if ((keys.containsKey("seamark:buoy_isolated_danger:colour") == false)
     687                                                && (keys.containsKey("seamark:beacon_isolated_danger:colour") == false)) {
     688                                        buoy = new BuoyUkn(this, "Parse-Error: No colour set");
     689                                        buoy.setNode(node);
     690                                        return;
     691                                }
     692
     693                                if (keys.containsKey("seamark:buoy_isolated_danger:shape") == true)
     694                                        str = keys.get("seamark:buoy_isolated_danger:colour");
     695                                else
     696                                        str = keys.get("seamark:beacon_isolated_danger:colour");
     697                                if (str.compareTo("black;red;black") != 0) {
     698                                        buoy = new BuoyUkn(this, "Parse-Error: Invalid colour");
     699                                        buoy.setNode(node);
     700                                        return;
     701                                }
     702
     703                                buoy = new BuoyIsol(this, SeaMark.ISOLATED_DANGER);
     704                                buoy.setName(name);
     705                                buoy.setColour(SeaMark.BLACK_RED_BLACK);
    591706
    592707                                if (buoy.parseTopMark(node) == false) {
  • applications/editors/josm/plugins/toms/src/toms/seamarks/SeaMark.java

    r22557 r22561  
    8686        public final static int SPEC_PILLAR = 1;
    8787        public final static int SPEC_SPAR = 2;
    88         public final static int SPEC_BEACON = 3;
    89         public final static int SPEC_SPHERE = 4;
    90         public final static int SPEC_BARREL = 5;
    91         public final static int LIGHT_MAJOR = 1;
    92         public final static int LIGHT_MINOR = 2;
    93         public final static int LIGHT_FLOAT = 3;
    94         public final static int LIGHT_HOUSE = 4;
     88        public final static int SPEC_SPHERE = 3;
     89        public final static int SPEC_BARREL = 4;
     90        public final static int LIGHT_HOUSE = 1;
     91        public final static int LIGHT_MAJOR = 2;
     92        public final static int LIGHT_MINOR = 3;
     93        public final static int LIGHT_FLOAT = 4;
    9594
    9695        /**
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyCard.java

    r22527 r22561  
    311311
    312312                                String c = keys.get("seamark:light:character");
    313                                 String ce = c;
    314313
    315314                                if (c.contains("+")) {
     
    320319
    321320                                if (getLightGroup() != "")
    322                                         ce = c + "(" + getLightGroup() + ")";
    323321                                if (tmp != null) {
    324322                                        c = c + tmp;
    325                                         ce = ce + tmp;
    326323                                }
    327324
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyIsol.java

    r22557 r22561  
    121121                default:
    122122                }
     123                if (getStyleIndex() == ISOL_BEACON) {
    123124                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    124                                 "seamark:buoy_isolated_danger:colour_pattern", "horizontal stripes"));
     125                                "seamark:beacon_isolated_danger:colour_pattern", "horizontal stripes"));
    125126                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    126                                 "seamark:buoy_isolated_danger:colour", "black;red;black"));
     127                                "seamark:beacon_isolated_danger:colour", "black;red;black"));
     128                } else {
     129                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     130                                        "seamark:buoy_isolated_danger:colour_pattern", "horizontal stripes"));
     131                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     132                                        "seamark:buoy_isolated_danger:colour", "black;red;black"));
     133                }
    127134
    128135                saveTopMarkData("2 spheres", "black");
     
    172179                        if (keys.containsKey("seamark:light:character")) {
    173180                                setLightGroup(keys);
    174 
    175181                                String c = keys.get("seamark:light:character");
    176                                 String ce = c;
    177 
    178182                                setLightChar(c);
    179183                                setLightPeriod(keys);
     
    186190                        } else {
    187191                                if (getErrMsg() == null)
    188                                         setErrMsg("Parse-Error: Licht falsch");
     192                                        setErrMsg("Parse-Error: Invalid light");
    189193                                else
    190                                         setErrMsg(getErrMsg() + " / Licht falsch");
     194                                        setErrMsg(getErrMsg() + " / Invalid light");
    191195
    192196                                ret = false;
     
    216220                        else if (str.compareTo("spar") == 0)
    217221                                setStyleIndex(ISOL_SPAR);
    218                         else if (str.compareTo("beacon") == 0)
     222                        else
     223                                ret = false;
     224                }
     225                if (keys.containsKey("seamark:beacon_isolated_danger:shape")) {
     226                        str = keys.get("seamark:beacon_isolated_danger:shape");
     227
     228                        if (str.compareTo("stake") == 0)
    219229                                setStyleIndex(ISOL_BEACON);
    220230                        else
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyLat.java

    r22557 r22561  
    488488                                super.saveSign("beacon_lateral");
    489489                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    490                                                 "seamark:buoy_lateral:shape", "stake"));
     490                                                "seamark:beacon_lateral:shape", "stake"));
    491491                                break;
    492492                        case LAT_TOWER:
    493493                                super.saveSign("beacon_lateral");
    494494                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    495                                                 "seamark:buoy_lateral:shape", "tower"));
     495                                                "seamark:beacon_lateral:shape", "tower"));
    496496                                break;
    497497                        case LAT_FLOAT:
     
    563563                                super.saveSign("beacon_lateral");
    564564                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    565                                                 "seamark:buoy_lateral:shape", "stake"));
     565                                                "seamark:beacon_lateral:shape", "stake"));
    566566                                break;
    567567                        case LAT_TOWER:
    568568                                super.saveSign("beacon_lateral");
    569569                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    570                                                 "seamark:buoy_lateral:shape", "tower"));
     570                                                "seamark:beacon_lateral:shape", "tower"));
    571571                                break;
    572572                        case LAT_FLOAT:
     
    636636                                super.saveSign("beacon_lateral");
    637637                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    638                                                 "seamark:buoy_lateral:shape", "stake"));
     638                                                "seamark:beacon_lateral:shape", "stake"));
    639639                                break;
    640640                        case LAT_TOWER:
    641641                                super.saveSign("beacon_lateral");
    642642                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    643                                                 "seamark:buoy_lateral:shape", "tower"));
     643                                                "seamark:beacon_lateral:shape", "tower"));
    644644                                break;
    645645                        case LAT_FLOAT:
     
    710710                                super.saveSign("beacon_lateral");
    711711                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    712                                                 "seamark:buoy_lateral:shape", "stake"));
     712                                                "seamark:beacon_lateral:shape", "stake"));
    713713                                break;
    714714                        case LAT_TOWER:
    715715                                super.saveSign("beacon_lateral");
    716716                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
    717                                                 "seamark:buoy_lateral:shape", "tower"));
     717                                                "seamark:beacon_lateral:shape", "tower"));
    718718                                break;
    719719                        default:
     
    832832                        if (keys.containsKey("seamark:light:character")) {
    833833                                setLightGroup(keys);
    834 
    835834                                String c = keys.get("seamark:light:character");
    836                                 String ce = c;
    837835                                setLightChar(c);
    838836                                setLightPeriod(keys);
     
    973971                        switch (cat) {
    974972                        case PORT_HAND:
    975                                 if (str.compareTo("beacon") == 0)
     973                                if (str.compareTo("stake") == 0)
    976974                                        setStyleIndex(LAT_BEACON);
    977975                                else if (str.compareTo("tower") == 0)
     
    982980
    983981                        case PREF_PORT_HAND:
    984                                 if (str.compareTo("beacon") == 0)
     982                                if (str.compareTo("stake") == 0)
    985983                                        setStyleIndex(LAT_BEACON);
    986984                                else if (str.compareTo("tower") == 0)
     
    991989
    992990                        case STARBOARD_HAND:
    993                                 if (str.compareTo("beacon") == 0)
     991                                if (str.compareTo("stake") == 0)
    994992                                        setStyleIndex(LAT_BEACON);
    995993                                else if (str.compareTo("tower") == 0)
     
    1000998
    1001999                        case PREF_STARBOARD_HAND:
    1002                                 if (str.compareTo("beacon") == 0)
     1000                                if (str.compareTo("stake") == 0)
    10031001                                        setStyleIndex(LAT_BEACON);
    10041002                                else if (str.compareTo("tower") == 0)
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyNota.java

    r22557 r22561  
    5555                dlg.cbM01StyleOfMark.removeAllItems();
    5656                dlg.cbM01StyleOfMark.addItem("Not set");
     57                dlg.cbM01StyleOfMark.addItem("Lighthouse");
    5758                dlg.cbM01StyleOfMark.addItem("Major Light");
    5859                dlg.cbM01StyleOfMark.addItem("Minor Light");
    5960                dlg.cbM01StyleOfMark.addItem("Light Float");
    60                 dlg.cbM01StyleOfMark.addItem("Lighthouse");
    6161
    6262                if (style >= dlg.cbM01StyleOfMark.getItemCount())
     
    8080
    8181                switch (getStyleIndex()) {
     82                case SeaMark.LIGHT_HOUSE:
    8283                case SeaMark.LIGHT_MAJOR:
    83                 case SeaMark.LIGHT_HOUSE:
    8484                        dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(
    8585                                        "/images/Light_Major.png")));
     
    119119
    120120                switch (getStyleIndex()) {
     121                case LIGHT_HOUSE:
     122                        super.saveSign("lighthouse");
     123                        break;
    121124                case LIGHT_MAJOR:
    122125                        super.saveSign("major_light");
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoySaw.java

    r22527 r22561  
    160160
    161161                        } else {
    162                                 setErrMsg("Parse-Error: Topmark unbekannt");
     162                                setErrMsg("Parse-Error: Unknown topmark");
    163163                                ret = false;
    164164                        }
     
    181181                        if (keys.containsKey("seamark:light:character")) {
    182182                                setLightGroup(keys);
    183 
    184183                                String c = keys.get("seamark:light:character");
    185                                 String ce = c;
    186 
    187184                                setLightChar(c);
    188185                                setLightPeriod(keys);
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoySpec.java

    r22557 r22561  
    2323                dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
    2424                dlg.cbM01StyleOfMark.addItem("Spar Buoy");
    25                 dlg.cbM01StyleOfMark.addItem("Beacon");
    2625                dlg.cbM01StyleOfMark.addItem("Sphere Buoy");
    2726                dlg.cbM01StyleOfMark.addItem("Barrel");
     
    6362                                        "/images/Special_Purpose_Spar.png")));
    6463                        break;
    65                 case SPEC_BEACON:
    66                         if (isFired())
    67                                 dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(
    68                                                 "/images/Special_Purpose_Beacon_Lit.png")));
    69                         else
    70                                 dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(
    71                                                 "/images/Special_Purpose_Beacon.png")));
    72                         break;
    7364                case SPEC_SPHERE:
    7465                        dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(
     
    9788                        Checker("/images/Cross_Top_Buoy_Yellow.png", "/images/Light_White.png");
    9889                        break;
    99                 case SPEC_BEACON:
    100                         Checker("/images/Cross_Top_Post_Yellow.png", "/images/Light_White.png");
    101                         break;
    10290                case SPEC_SPHERE:
    10391                case SPEC_BARREL:
     
    115103                }
    116104
    117                 if (getStyleIndex() == SPEC_BEACON)
    118                         super.saveSign("beacon_special_purpose");
    119                 else
    120                         super.saveSign("buoy_special_purpose");
     105                super.saveSign("buoy_special_purpose");
    121106
    122107                switch (getStyleIndex()) {
     
    132117                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
    133118                                        "seamark:buoy_special_purpose:shape", "sphere"));
    134                         break;
    135                 case SPEC_BEACON:
    136                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    137                                         "seamark:beacon_special_purpose:shape", "stake"));
    138119                        break;
    139120                case SPEC_BARREL:
     
    194175
    195176                                String c = keys.get("seamark:light:character");
    196                                 String ce = c;
    197177
    198178                                setLightChar(c);
Note: See TracChangeset for help on using the changeset viewer.