Ignore:
Timestamp:
2010-08-21T20:25:09+02:00 (14 years ago)
Author:
malcolmh
Message:

error tolerant parsing

Location:
applications/editors/josm/plugins/toms/src
Files:
4 added
76 edited

Legend:

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

    r22704 r22722  
    7878                public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    7979                        Node node;
    80                         Map<String, String> keys = null;
    8180                        Selection = newSelection;
    8281
     
    8988                                                if (node.compareTo(SelNode) != 0) {
    9089                                                        SelNode = node;
    91 
    92                                                         keys = node.getKeys();
    93                                                         if (keys.containsKey("seamark")
    94                                                                         || keys.containsKey("seamark:type")) {
    95                                                                 parseSeaMark();
    96                                                         }
     90                                                        parseSeaMark();
    9791                                                }
    9892                                }
     
    318312
    319313                // Soweit das Vorspiel. Ab hier beginnt das Parsen
    320                 String str = null;
    321                 String name;
     314                String type = "";
     315                String str = "";
    322316
    323317                keys = node.getKeys();
    324                 name = "";
    325318
    326319                // vorsorglich den Namen holen und verwenden, wenn es ein
    327320                // Seezeichen ist. Name kann durch die weiteren Tags ueber-
    328321                // schrieben werden
    329                 if (keys.containsKey("name"))
    330                         name = keys.get("name");
    331 
    332                 if (keys.containsKey("seamark:name")) {
    333                         name = keys.get("seamark:name");
    334                 }
    335 
    336                 if (keys.containsKey("seamark") || keys.containsKey("seamark:type")) {
    337 
    338                         if (keys.containsKey("seamark:buoy_lateral:category")
    339                                         || keys.containsKey("seamark:beacon_lateral:category")) {
    340 
    341                                 buoy = null; // Prototyp der Lateraltonne
    342                                 String cat; // Kathegorie
    343 
    344                                 if ((keys.containsKey("seamark:buoy_lateral:colour") == false)
    345                                                 && (keys.containsKey("seamark:beacon_lateral:colour") == false)) {
    346                                         buoy = new BuoyUkn(this, "Parse-Error: Buoy without colour");
    347                                         buoy.setNode(node);
    348                                         return;
    349                                 }
    350 
    351                                 if (name.equals("")) {
    352                                         if (keys.containsKey("seamark:buoy_lateral:name"))
    353                                                 name = keys.get("seamark:buoy_lateral:name");
    354                                         if (keys.containsKey("seamark:beacon_lateral:name"))
    355                                                 name = keys.get("seamark:beacon_lateral:name");
    356                                 }
    357 
    358                                 if (keys.containsKey("seamark:buoy_lateral:category") == true) {
    359                                         str = keys.get("seamark:buoy_lateral:colour");
    360                                         cat = keys.get("seamark:buoy_lateral:category");
    361                                 } else {
    362                                         str = keys.get("seamark:beacon_lateral:colour");
    363                                         cat = keys.get("seamark:beacon_lateral:category");
    364                                 }
    365 
    366                                 if (cat.equals("port")) {
    367 
    368                                         buoy = new BuoyLat(this, SeaMark.PORT_HAND);
    369                                         if (str.compareTo("red") == 0) {
    370                                                 buoy.setRegion(SeaMark.IALA_A);
    371                                                 buoy.setColour(SeaMark.RED);
     322
     323                if (keys.containsKey("seamark:type")) {
     324                        type = keys.get("seamark:type");
     325
     326                        if (type.equals("buoy_lateral") || type.equals("beacon_lateral")
     327                                        || keys.containsKey("seamark:buoy_lateral")
     328                                        || keys.containsKey("seamark:beacon_lateral")) {
     329                                buoy = new BuoyLat(this, node);
     330                                return;
     331
     332                        } else if (type.equals("buoy_cardinal") || type.equals("beacon_cardinal")
     333                                        || keys.containsKey("seamark:buoy_cardinal")
     334                                        || keys.containsKey("seamark:beacon_cardinal")) {
     335                                buoy = new BuoyCard(this, node);
     336                                return;
     337
     338                        } else if (type.equals("buoy_safe_water")
     339                                        || type.equals("beacon_safe_water")
     340                                        || keys.containsKey("seamark:buoy_safe_water")
     341                                        || keys.containsKey("seamark:beacon_safe_water")) {
     342                                buoy = new BuoySaw(this, node);
     343                                return;
     344
     345                        } else if (type.equals("buoy_special_purpose")
     346                                        || type.equals("beacon_special_purpose")
     347                                        || keys.containsKey("seamark:buoy_special_purpose")
     348                                        || keys.containsKey("seamark:beacon_special_purpose")) {
     349                                buoy = new BuoySpec(this, node);
     350                                return;
     351
     352                        } else if (type.equals("buoy_isolated_danger")
     353                                        || type.equals("beacon_isolated_danger")
     354                                        || (keys.containsKey("seamark:buoy_isolated_danger"))
     355                                        || (keys.containsKey("seamark:beacon_isolated_danger"))) {
     356                                buoy = new BuoyIsol(this, node);
     357                                return;
     358
     359                        } else if (type.equals("light_float")) {
     360                                if (keys.containsKey("seamark:light_float:colour")) {
     361                                        str = keys.get("seamark:light_float:colour");
     362                                        if (str.equals("red") || str.equals("green")
     363                                                        || str.equals("red;green;red") || str.equals("green;red;green")) {
     364                                                buoy = new BuoyLat(this, node);
     365                                                return;
     366                                        } else if (str.equals("black;yellow")
     367                                                        || str.equals("black;yellow;black") || str.equals("yellow;black")
     368                                                        || str.equals("yellow;black;yellow")) {
     369                                                buoy = new BuoyCard(this, node);
     370                                                return;
     371                                        } else if (str.equals("black;red;black")) {
     372                                                buoy = new BuoyIsol(this, node);
     373                                                return;
     374                                        } else if (str.equals("red;white")) {
     375                                                buoy = new BuoySaw(this, node);
     376                                                return;
     377                                        } else if (str.equals("yellow")) {
     378                                                buoy = new BuoySaw(this, node);
     379                                                return;
    372380                                        } else {
    373                                                 buoy.setRegion(SeaMark.IALA_B);
    374                                                 buoy.setColour(SeaMark.GREEN);
    375                                         }
    376                                         buoy.setName(name);
    377                                 }
    378 
    379                                 if (cat.compareTo("starboard") == 0) {
    380 
    381                                         buoy = new BuoyLat(this, SeaMark.STARBOARD_HAND);
    382                                         if (str.compareTo("green") == 0) {
    383                                                 buoy.setRegion(SeaMark.IALA_A);
    384                                                 buoy.setColour(SeaMark.GREEN);
    385                                         } else {
    386                                                 buoy.setRegion(SeaMark.IALA_B);
    387                                                 buoy.setColour(SeaMark.RED);
    388                                         }
    389                                         buoy.setName(name);
    390                                 }
    391 
    392                                 if (cat.compareTo("preferred_channel_port") == 0) {
    393 
    394                                         buoy = new BuoyLat(this, SeaMark.PREF_PORT_HAND);
    395                                         if (str.compareTo("red;green;red") == 0) {
    396                                                 buoy.setRegion(SeaMark.IALA_A);
    397                                                 buoy.setColour(SeaMark.RED_GREEN_RED);
    398                                         } else {
    399                                                 buoy.setRegion(SeaMark.IALA_B);
    400                                                 buoy.setColour(SeaMark.GREEN_RED_GREEN);
    401                                         }
    402 
    403                                         buoy.setName(name);
    404                                 }
    405 
    406                                 if (cat.compareTo("preferred_channel_starboard") == 0) {
    407 
    408                                         buoy = new BuoyLat(this, SeaMark.PREF_STARBOARD_HAND);
    409                                         if (str.compareTo("green;red;green") == 0) {
    410                                                 buoy.setRegion(SeaMark.IALA_A);
    411                                                 buoy.setColour(SeaMark.GREEN_RED_GREEN);
    412                                         } else {
    413                                                 buoy.setRegion(SeaMark.IALA_B);
    414                                                 buoy.setColour(SeaMark.RED_GREEN_RED);
    415                                         }
    416 
    417                                         buoy.setName(name);
    418                                 }
    419 
    420                                 // b != null true, wenn eine gültige Lateraltonne gefunden wurde
    421                                 if (buoy != null) {
    422                                         if (buoy.parseTopMark(node) == false) {
    423                                                 str = buoy.getErrMsg();
    424                                                 if (str == null)
    425                                                         buoy.setValid(false);
    426                                         }
    427 
    428                                         if (buoy.parseLight(node) == false) {
    429                                                 str = buoy.getErrMsg();
    430                                                 if (str == null)
    431                                                         buoy.setValid(false);
    432                                         }
    433 
    434                                         if (buoy.parseShape(node) == false) {
    435                                                 str = buoy.getErrMsg();
    436                                                 if (str == null)
    437                                                         buoy = new BuoyUkn(this, str);
    438                                                 return;
    439                                         }
    440 
    441                                         buoy.setNode(node);
    442                                         buoy.setValid(true);
    443                                         cbM01StyleOfMark.setSelectedIndex(buoy.getStyleIndex());
    444                                         buoy.paintSign();
    445 
    446                                         return;
    447 
    448                                 } else { // Ende if(b != null)
    449                                         buoy = new BuoyUkn(this, "Parse-Error: Seamark not set");
    450                                         buoy.setNode(node);
    451                                         return;
    452                                 } // Ende else if(b != null)
    453                         } else // Ende if(keys.containsKey("seamark:buoy_lateral:category") ==
    454                                                         // true)
    455                         // Test auf Kardinal-
    456                         if ((keys.containsKey("seamark:buoy_cardinal:category") == true)
    457                                         || (keys.containsKey("seamark:beacon_cardinal:category") == true)) {
    458 
    459                                 buoy = null; // Prototyp der Kardinaltonne
    460                                 String cat; // Kathegorie
    461 
    462                                 if ((keys.containsKey("seamark:buoy_cardinal:colour") == false)
    463                                                 && (keys.containsKey("seamark:beacon_cardinal:colour") == false)) {
    464                                         buoy = new BuoyUkn(this, "Parse-Error: No colour set");
    465                                         buoy.setNode(node);
    466                                         return;
    467                                 }
    468 
    469                                 if (name.compareTo("") == 0) {
    470                                         if (keys.containsKey("seamark:buoy_cardinal:name"))
    471                                                 name = keys.get("seamark:buoy_cardinal:name");
    472                                         if (keys.containsKey("seamark:beacon_cardinal:name"))
    473                                                 name = keys.get("seamark:beacon_cardinal:name");
    474                                 }
    475 
    476                                 if (keys.containsKey("seamark:buoy_cardinal:category") == true) {
    477                                         str = keys.get("seamark:buoy_cardinal:colour");
    478                                         cat = keys.get("seamark:buoy_cardinal:category");
    479                                 } else {
    480                                         str = keys.get("seamark:beacon_cardinal:colour");
    481                                         cat = keys.get("seamark:beacon_cardinal:category");
    482                                 }
    483 
    484                                 // Test auf Kardinaltonne Nord
    485                                 if (str.compareTo("black;yellow") == 0) {
    486 
    487                                         buoy = new BuoyCard(this, SeaMark.CARD_NORTH);
    488 
    489                                         if (cat.compareTo("north") != 0)
    490                                                 buoy.setErrMsg("Parse-Error: falsche category");
    491 
    492                                         buoy.setName(name);
    493                                 } // Ende if(str.compareTo("black;yellow")== 0)
    494 
    495                                 // Test auf Kardinaltonne Ost
    496                                 if (str.compareTo("black;yellow;black") == 0) {
    497 
    498                                         buoy = new BuoyCard(this, SeaMark.CARD_EAST);
    499 
    500                                         if (cat.compareTo("east") != 0)
    501                                                 buoy.setErrMsg("Parse-Error: falsche category");
    502 
    503                                         buoy.setName(name);
    504                                 } // Ende if(str.compareTo("black;yellow;black")== 0)
    505 
    506                                 // Test auf Kardinaltonne Sued
    507                                 if (str.compareTo("yellow;black") == 0) {
    508 
    509                                         buoy = new BuoyCard(this, SeaMark.CARD_SOUTH);
    510 
    511                                         if (cat.compareTo("south") != 0)
    512                                                 buoy.setErrMsg("Parse-Error: falsche category");
    513 
    514                                         buoy.setName(name);
    515                                 } // Ende if(str.compareTo("yellow;black")== 0)
    516 
    517                                 // Test auf Kardinaltonne West
    518                                 if (str.compareTo("yellow;black;yellow") == 0) {
    519 
    520                                         buoy = new BuoyCard(this, SeaMark.CARD_WEST);
    521 
    522                                         if (cat.compareTo("west") != 0)
    523                                                 buoy.setErrMsg("Parse-Error: falsche category");
    524 
    525                                         buoy.setName(name);
    526                                 } // Ende if(str.compareTo("yellow;black;black")== 0)
    527 
    528                                 // b != null true, wenn eine gültige Kardinaltonne gefunden wurde
    529                                 if (buoy != null) {
    530 
    531                                         if (buoy.parseLight(node) == false) {
    532                                                 str = buoy.getErrMsg();
    533                                                 if (str == null)
    534                                                         buoy.setValid(false);
    535                                         }
    536 
    537                                         if (buoy.parseShape(node) == false) {
    538                                                 str = buoy.getErrMsg();
    539                                                 if (str == null)
    540                                                         buoy = new BuoyUkn(this, str);
    541                                                 return;
    542                                         }
    543 
    544                                         buoy.setNode(node);
    545                                         buoy.setValid(true);
    546                                         cbM01StyleOfMark.setSelectedIndex(buoy.getStyleIndex());
    547                                         buoy.paintSign();
    548 
    549                                         return;
    550 
    551                                 } else { // Ende if(b != null)
    552                                         buoy = new BuoyUkn(this, "Parse-Error: Seamark not set");
    553                                         buoy.setNode(node);
    554                                         return;
    555                                 } // Ende else if(b != null)
    556 
     381                                                buoy = new BuoyUkn(this, "Parse-Error: Invalid colour");
     382                                                buoy.setNode(node);
     383                                                return;
     384                                        }
     385                                } else if (keys.containsKey("seamark:light_float:topmark")) {
     386                                        if (keys.containsKey("seamark:light_float:topmark:shape")) {
     387                                                str = keys.get("seamark:light_float:topmark:shape");
     388                                                if (str.equals("cylinder") || str.equals("cone, point up")) {
     389                                                        buoy = new BuoyLat(this, node);
     390                                                        return;
     391                                                }
     392                                        } else if (keys.containsKey("seamark:light_float:topmark:colour")) {
     393                                                str = keys.get("seamark:light_float:topmark:colour");
     394                                                if (str.equals("red") || str.equals("green")) {
     395                                                        buoy = new BuoyLat(this, node);
     396                                                        return;
     397                                                }
     398                                        }
     399                                }
    557400                        }
    558 
    559                         // Test buoy_safewater
    560                         if (keys.containsKey("seamark:buoy_safe_water:shape") == true) {
    561 
    562                                 if (keys.containsKey("seamark:buoy_safe_water:colour") == false) {
    563                                         buoy = new BuoyUkn(this, "Parse-Error: No colour set");
    564                                         buoy.setNode(node);
    565                                         return;
    566                                 }
    567 
    568                                 str = keys.get("seamark:buoy_safe_water:colour");
    569                                 if (str.compareTo("red;white") != 0) {
    570                                         buoy = new BuoyUkn(this, "Parse-Error: Invalid colour");
    571                                         buoy.setNode(node);
    572                                         return;
    573                                 }
    574 
    575                                 buoy = new BuoySaw(this, SeaMark.SAFE_WATER);
    576                                 buoy.setName(name);
    577                                 buoy.setColour(SeaMark.RED_WHITE);
    578 
    579                                 if (buoy.parseTopMark(node) == false) {
    580                                         str = buoy.getErrMsg();
    581                                         if (str == null)
    582                                                 buoy.setValid(false);
    583                                 }
    584 
    585                                 if (buoy.parseLight(node) == false) {
    586                                         str = buoy.getErrMsg();
    587                                         if (str == null)
    588                                                 buoy.setValid(false);
    589                                 }
    590 
    591                                 if (buoy.parseShape(node) == false) {
    592                                         str = buoy.getErrMsg();
    593                                         if (str == null)
    594                                                 buoy = new BuoyUkn(this, str);
    595                                         buoy.setNode(node);
    596                                         return;
    597                                 }
    598 
    599                                 buoy.setValid(true);
    600                                 buoy.setNode(node);
    601                                 cbM01StyleOfMark.setSelectedIndex(buoy.getStyleIndex());
    602                                 buoy.paintSign();
    603 
    604                                 return;
    605 
    606                         }
    607 
    608                         // Test buoy_special_purpose
    609                         if (keys.containsKey("seamark:buoy_special_purpose:shape") == true) {
    610 
    611                                 if (keys.containsKey("seamark:buoy_special_purpose:colour") == false) {
    612                                         buoy = new BuoyUkn(this, "Parse-Error: No colour set");
    613                                         buoy.setNode(node);
    614                                         return;
    615                                 }
    616 
    617                                 str = keys.get("seamark:buoy_special_purpose:colour");
    618                                 if (str.compareTo("yellow") != 0) {
    619                                         buoy = new BuoyUkn(this, "Parse-Error: Invalid colour");
    620                                         buoy.setNode(node);
    621                                         return;
    622                                 }
    623 
    624                                 buoy = new BuoySpec(this, SeaMark.SPECIAL_PURPOSE);
    625                                 buoy.setName(name);
    626                                 buoy.setColour(SeaMark.YELLOW);
    627 
    628                                 if (buoy.parseTopMark(node) == false) {
    629                                         str = buoy.getErrMsg();
    630                                         if (str == null)
    631                                                 buoy.setValid(false);
    632                                 }
    633 
    634                                 if (buoy.parseLight(node) == false) {
    635                                         str = buoy.getErrMsg();
    636                                         if (str == null)
    637                                                 buoy.setValid(false);
    638                                 }
    639 
    640                                 if (buoy.parseShape(node) == false) {
    641                                         str = buoy.getErrMsg();
    642                                         if (str == null)
    643                                                 buoy = new BuoyUkn(this, str);
    644                                         buoy.setNode(node);
    645                                         return;
    646                                 }
    647 
    648                                 buoy.setValid(true);
    649                                 buoy.setNode(node);
    650                                 cbM01StyleOfMark.setSelectedIndex(buoy.getStyleIndex());
    651                                 buoy.paintSign();
    652 
    653                                 return;
    654 
    655                         }
    656 
    657                         // Test buoy_isolated_danger
    658                         if ((keys.containsKey("seamark:buoy_isolated_danger:colour") == true)
    659                                         || (keys.containsKey("seamark:beacon_isolated_danger:colour") == true)) {
    660 
    661                                 if ((keys.containsKey("seamark:buoy_isolated_danger:colour") == true)
    662                                                 && (keys.containsKey("seamark:buoy_isolated_danger:shape") == false)) {
    663                                         buoy = new BuoyUkn(this, "Parse-Error: No shape set");
    664                                         buoy.setNode(node);
    665                                         return;
    666                                 }
    667 
    668                                 if (keys.containsKey("seamark:buoy_isolated_danger:colour") == true)
    669                                         str = keys.get("seamark:buoy_isolated_danger:colour");
    670                                 else
    671                                         str = keys.get("seamark:beacon_isolated_danger:colour");
    672                                 if (str.compareTo("black;red;black") != 0) {
    673                                         buoy = new BuoyUkn(this, "Parse-Error: Invalid colour");
    674                                         buoy.setNode(node);
    675                                         return;
    676                                 }
    677 
    678                                 buoy = new BuoyIsol(this, SeaMark.ISOLATED_DANGER);
    679                                 buoy.setName(name);
    680                                 buoy.setColour(SeaMark.BLACK_RED_BLACK);
    681 
    682                                 if (buoy.parseTopMark(node) == false) {
    683                                         str = buoy.getErrMsg();
    684                                         if (str == null)
    685                                                 buoy.setValid(false);
    686                                 }
    687 
    688                                 if (buoy.parseLight(node) == false) {
    689                                         str = buoy.getErrMsg();
    690                                         if (str == null)
    691                                                 buoy.setValid(false);
    692                                 }
    693 
    694                                 if (buoy.parseShape(node) == false) {
    695                                         str = buoy.getErrMsg();
    696                                         if (str == null)
    697                                                 buoy = new BuoyUkn(this, str);
    698                                         buoy.setNode(node);
    699                                         return;
    700                                 }
    701 
    702                                 buoy.setValid(true);
    703                                 buoy.setNode(node);
    704                                 cbM01StyleOfMark.setSelectedIndex(buoy.getStyleIndex());
    705                                 buoy.paintSign();
    706 
    707                                 return;
    708 
    709                         }
    710 
    711                         // Test light_float
    712 
    713                         if ((keys.containsKey("seamark:type") == true)
    714                                         && (keys.get("seamark:type").equals("light_float"))) {
    715 
    716                                 if (keys.containsKey("seamark:light_float:colour") == false) {
    717                                         buoy = new BuoyUkn(this, "Parse-Error: No colour set");
    718                                         buoy.setNode(node);
    719                                         return;
    720                                 }
    721 
    722                                 str = keys.get("seamark:light_float:colour");
    723                                 if (str.equals("red") || str.equals("green")
    724                                                 || str.equals("red;green;red") || str.equals("green;red;green")) {
    725                                         boolean region = Main.pref.get("tomsplugin.IALA").equals("B");
    726                                         if (str.equals("red")) {
    727                                                 if ((keys.containsKey("seamark:topmark:shape") && keys.get(
    728                                                                 "seamark:topmark:shape").equals("cylinder"))
    729                                                                 || (region == SeaMark.IALA_A)) {
    730                                                         buoy = new BuoyLat(this, SeaMark.PORT_HAND);
    731                                                 } else {
    732                                                         buoy = new BuoyLat(this, SeaMark.STARBOARD_HAND);
    733                                                 }
    734                                                 buoy.setColour(SeaMark.RED);
    735                                         } else if (str.equals("green")) {
    736                                                 if ((keys.containsKey("seamark:topmark:shape") && keys.get(
    737                                                                 "seamark:topmark:shape").equals("cone, point up"))
    738                                                                 || (region == SeaMark.IALA_A)) {
    739                                                         buoy = new BuoyLat(this, SeaMark.STARBOARD_HAND);
    740                                                 } else {
    741                                                         buoy = new BuoyLat(this, SeaMark.PORT_HAND);
    742                                                 }
    743                                                 buoy.setColour(SeaMark.GREEN);
    744                                         } else if (str.equals("red;green;red")) {
    745                                                 if ((keys.containsKey("seamark:topmark:shape") && keys.get(
    746                                                                 "seamark:topmark:shape").equals("cylinder"))
    747                                                                 || (region == SeaMark.IALA_A)) {
    748                                                         buoy = new BuoyLat(this, SeaMark.PREF_PORT_HAND);
    749                                                 } else {
    750                                                         buoy = new BuoyLat(this, SeaMark.PREF_STARBOARD_HAND);
    751                                                 }
    752                                                 buoy.setColour(SeaMark.RED_GREEN_RED);
    753                                         } else if (str.equals("green;red;green")) {
    754                                                 if ((keys.containsKey("seamark:topmark:shape") && keys.get(
    755                                                                 "seamark:topmark:shape").equals("cone, point up"))
    756                                                                 || (region == SeaMark.IALA_A)) {
    757                                                         buoy = new BuoyLat(this, SeaMark.PREF_STARBOARD_HAND);
    758                                                 } else {
    759                                                         buoy = new BuoyLat(this, SeaMark.PREF_PORT_HAND);
    760                                                 }
    761                                                 buoy.setColour(SeaMark.GREEN_RED_GREEN);
    762                                         }
    763                                 } else if (str.equals("black;yellow")) {
    764                                         buoy = new BuoyCard(this, SeaMark.CARD_NORTH);
    765                                         buoy.setColour(SeaMark.BLACK_YELLOW);
    766                                 } else if (str.equals("black;yellow;black")) {
    767                                         buoy = new BuoyCard(this, SeaMark.CARD_EAST);
    768                                         buoy.setColour(SeaMark.BLACK_YELLOW_BLACK);
    769                                 } else if (str.equals("yellow;black")) {
    770                                         buoy = new BuoyCard(this, SeaMark.CARD_SOUTH);
    771                                         buoy.setColour(SeaMark.YELLOW_BLACK);
    772                                 } else if (str.equals("yellow;black;yellow")) {
    773                                         buoy = new BuoyCard(this, SeaMark.CARD_WEST);
    774                                         buoy.setColour(SeaMark.YELLOW_BLACK_YELLOW);
    775                                 } else if (str.equals("black;red;black")) {
    776                                         buoy = new BuoyIsol(this, SeaMark.ISOLATED_DANGER);
    777                                         buoy.setColour(SeaMark.BLACK_RED_BLACK);
    778                                 } else if (str.equals("red;white")) {
    779                                         buoy = new BuoySaw(this, SeaMark.SAFE_WATER);
    780                                         buoy.setColour(SeaMark.RED_WHITE);
    781                                 } else if (str.equals("yellow")) {
    782                                         buoy = new BuoySaw(this, SeaMark.SPECIAL_PURPOSE);
    783                                         buoy.setColour(SeaMark.YELLOW);
    784                                 } else {
    785                                         buoy = new BuoyUkn(this, "Parse-Error: Invalid colour");
    786                                         buoy.setNode(node);
    787                                         return;
    788                                 }
    789 
    790                                 buoy.setName(name);
    791 
    792                                 if (buoy.parseTopMark(node) == false) {
    793                                         str = buoy.getErrMsg();
    794                                         if (str == null)
    795                                                 buoy.setValid(false);
    796                                 }
    797 
    798                                 if (buoy.parseLight(node) == false) {
    799                                         str = buoy.getErrMsg();
    800                                         if (str == null)
    801                                                 buoy.setValid(false);
    802                                 }
    803 
    804                                 if (buoy.parseShape(node) == false) {
    805                                         str = buoy.getErrMsg();
    806                                         if (str == null)
    807                                                 buoy = new BuoyUkn(this, str);
    808                                         buoy.setNode(node);
    809                                         return;
    810                                 }
    811 
    812                                 buoy.setValid(true);
    813                                 buoy.setNode(node);
    814                                 cbM01StyleOfMark.setSelectedIndex(buoy.getStyleIndex());
    815                                 buoy.paintSign();
    816 
    817                                 return;
    818 
    819                         }
    820                 } // Ende if(keys.containsKey("seamark") || keys.containsKey("seamark:type")
    821                         // )
    822 
    823                 buoy = new BuoyUkn(this, "Parse-Error: Seamark not set");
     401                }
     402
     403                buoy = new BuoyUkn(this, "Seamark not set");
    824404                buoy.setNode(node);
    825405                return;
     
    831411                        dM01SeaMap = new JDialog();
    832412                        dM01SeaMap.setSize(new Dimension(353, 373));
     413                        // dM01SeaMap.setSize(new Dimension(400, 400));
    833414                        dM01SeaMap.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    834415                        dM01SeaMap.setModal(false);
     
    978559                                        int type = cbM01TypeOfMark.getSelectedIndex();
    979560
    980                                         if (buoy == null)
     561                                        if (buoy == null) {
    981562                                                buoy = new BuoyUkn(dia, "Seamark not set");
    982                                         ;
    983                                         if (type == buoy.getBuoyIndex() && type != 0) {
    984                                                 return;
    985                                         }
     563                                                return;
     564                                        }
     565                                        if ((type == 0) || (type == buoy.getBuoyIndex()))
     566                                                return;
    986567
    987568                                        n = buoy.getNode();
     569                                        if (n == null)
     570                                                n = onode;
    988571                                        name = buoy.getName();
    989 
    990572                                        switch (type) {
     573
    991574                                        case SeaMark.UNKNOWN_CAT:
    992575                                                if (!(buoy instanceof BuoyUkn))
     
    996579
    997580                                        case SeaMark.PORT_HAND:
    998                                                 if (!(buoy instanceof BuoyLat))
    999                                                         buoy = new BuoyLat(dia, SeaMark.PORT_HAND);
    1000                                                 if (buoy.getRegion() != SeaMark.IALA_B) {
    1001                                                         buoy.setColour(SeaMark.RED);
    1002                                                         buoy.setRegion(SeaMark.IALA_A);
    1003                                                         tbM01Region.setSelected(SeaMark.IALA_A);
    1004                                                 } else {
    1005                                                         buoy.setColour(SeaMark.GREEN);
    1006                                                 }
    1007                                                 break;
    1008 
    1009581                                        case SeaMark.STARBOARD_HAND:
    1010                                                 if (!(buoy instanceof BuoyLat))
    1011                                                         buoy = new BuoyLat(dia, SeaMark.STARBOARD_HAND);
    1012                                                 if (buoy.getRegion() != SeaMark.IALA_B) {
    1013                                                         buoy.setColour(SeaMark.GREEN);
    1014                                                         buoy.setRegion(SeaMark.IALA_A);
    1015                                                         tbM01Region.setSelected(SeaMark.IALA_A);
    1016                                                 } else {
    1017                                                         buoy.setColour(SeaMark.RED);
    1018                                                 }
    1019                                                 break;
    1020 
    1021582                                        case SeaMark.PREF_PORT_HAND:
    1022                                                 if (!(buoy instanceof BuoyLat))
    1023                                                         buoy = new BuoyLat(dia, SeaMark.PREF_PORT_HAND);
    1024                                                 if (buoy.getRegion() != SeaMark.IALA_B) {
    1025                                                         buoy.setColour(SeaMark.RED_GREEN_RED);
    1026                                                         buoy.setRegion(SeaMark.IALA_A);
    1027                                                         tbM01Region.setSelected(SeaMark.IALA_A);
    1028                                                 } else {
    1029                                                         buoy.setColour(SeaMark.GREEN_RED_GREEN);
    1030                                                 }
    1031                                                 break;
    1032 
    1033583                                        case SeaMark.PREF_STARBOARD_HAND:
    1034584                                                if (!(buoy instanceof BuoyLat))
    1035                                                         buoy = new BuoyLat(dia, SeaMark.PREF_STARBOARD_HAND);
    1036                                                 if (buoy.getRegion() != SeaMark.IALA_B) {
    1037                                                         buoy.setColour(SeaMark.GREEN_RED_GREEN);
    1038                                                         buoy.setRegion(SeaMark.IALA_A);
    1039                                                         tbM01Region.setSelected(SeaMark.IALA_A);
    1040                                                 } else {
    1041                                                         buoy.setColour(SeaMark.RED_GREEN_RED);
    1042                                                 }
     585                                                        buoy = new BuoyLat(dia, n);
    1043586                                                break;
    1044587
    1045588                                        case SeaMark.SAFE_WATER:
    1046589                                                if (!(buoy instanceof BuoySaw))
    1047                                                         buoy = new BuoySaw(dia, SeaMark.SAFE_WATER);
     590                                                        buoy = new BuoySaw(dia, n);
    1048591                                                break;
    1049592
     
    1053596                                        case SeaMark.CARD_WEST:
    1054597                                                if (!(buoy instanceof BuoyCard))
    1055                                                         buoy = new BuoyCard(dia, type);
     598                                                        buoy = new BuoyCard(dia, n);
    1056599                                                break;
    1057600
    1058601                                        case SeaMark.ISOLATED_DANGER:
    1059602                                                if (!(buoy instanceof BuoyIsol))
    1060                                                         buoy = new BuoyIsol(dia, SeaMark.ISOLATED_DANGER);
     603                                                        buoy = new BuoyIsol(dia, n);
    1061604                                                break;
    1062605
    1063606                                        case SeaMark.SPECIAL_PURPOSE:
    1064607                                                if (!(buoy instanceof BuoySpec))
    1065                                                         buoy = new BuoySpec(dia, SeaMark.SPECIAL_PURPOSE);
     608                                                        buoy = new BuoySpec(dia, n);
    1066609                                                break;
    1067                                         /*
    1068                                          * case SeaMark.LIGHT: if (!(buoy instanceof BuoyNota)) buoy = new
    1069                                          * BuoyNota(dia, type); break;
    1070                                          */
    1071610                                        default:
    1072611                                                if (!(buoy instanceof BuoyUkn))
  • applications/editors/josm/plugins/toms/src/toms/seamarks/SeaMark.java

    r22683 r22722  
    107107        public abstract void paintSign();
    108108
    109         public abstract boolean parseTopMark(Node node);
    110 
    111         public abstract boolean parseLight(Node node);
    112 
    113109        public abstract void saveSign();
    114110
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/Buoy.java

    r22704 r22722  
    191191        }
    192192
    193         public boolean parseShape(Node node, String str) {
    194                 boolean ret = true;
    195                 Map<String, String> keys;
    196 
    197                 keys = node.getKeys();
    198                 if (keys.containsKey(str) == false) {
    199                         setErrMsg("Parse-Error: Seezeichen ohne Form");
    200                         return false;
    201                 }
    202                 return ret;
    203         }
    204 
    205193        private boolean TopMark = false;
    206194
     
    236224
    237225                dlg.cbM01TypeOfMark.setSelectedIndex(getBuoyIndex());
     226                dlg.cbM01StyleOfMark.setSelectedIndex(getStyleIndex());
    238227
    239228                dlg.cM01TopMark.setSelected(hasTopMark());
     
    337326        }
    338327
    339         public boolean parseShape(Node node) {
    340                 return false;
    341         }
    342 
    343328        public void refreshStyles() {
    344329        }
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyCard.java

    r22704 r22722  
    1717public class BuoyCard extends Buoy {
    1818
    19         public BuoyCard(SmpDialogAction dia, int type) {
     19        public BuoyCard(SmpDialogAction dia, Node node) {
    2020                super(dia);
     21
     22                String str;
     23                Map<String, String> keys;
     24                keys = node.getKeys();
     25                setNode(node);
    2126
    2227                dlg.cbM01StyleOfMark.removeAllItems();
     
    3237                dlg.tbM01Region.setEnabled(false);
    3338
    34                 setBuoyIndex(type);
    35                 setStyleIndex(0);
    36                 setLightColour("W");
    37 
    38                 switch (type) {
    39                 case CARD_NORTH:
    40                         setColour(SeaMark.BLACK_YELLOW);
    41                         break;
    42                 case CARD_EAST:
    43                         setColour(SeaMark.BLACK_YELLOW_BLACK);
    44                         break;
    45                 case CARD_SOUTH:
    46                         setColour(SeaMark.YELLOW_BLACK);
    47                         break;
    48                 case CARD_WEST:
    49                         setColour(SeaMark.YELLOW_BLACK_YELLOW);
    50                         break;
    51                 default:
    52                 }
    53 
    54                 refreshLights();
    55                 paintSign();
    56         }
    57 
    58         public void refreshLights() {
    59                 int type = getBuoyIndex();
    60 
    61                 dlg.cbM01Kennung.removeAllItems();
    62                 dlg.cbM01Kennung.addItem("Not set");
    63                 dlg.cbM01Kennung.setSelectedIndex(0);
    64 
    65                 switch (type) {
    66                 case SeaMark.CARD_NORTH:
    67                         dlg.cbM01Kennung.addItem("Q");
    68                         dlg.cbM01Kennung.addItem("VQ");
    69                         break;
    70 
    71                 case SeaMark.CARD_EAST:
    72                         dlg.cbM01Kennung.addItem("Q(3)");
    73                         dlg.cbM01Kennung.addItem("VQ(3)");
    74                         break;
    75 
    76                 case SeaMark.CARD_SOUTH:
    77                         dlg.cbM01Kennung.addItem("Q(6)+LFl");
    78                         dlg.cbM01Kennung.addItem("VQ(6)+LFl");
    79                         break;
    80 
    81                 case SeaMark.CARD_WEST:
    82                         dlg.cbM01Kennung.addItem("Q(9)");
    83                         dlg.cbM01Kennung.addItem("VQ(9)");
    84                         break;
    85 
    86                 default:
    87                 }
    88 
    89         }
    90 
    91         public void paintSign() {
    92                 super.paintSign();
    93 
    94                 dlg.sM01StatusBar.setText(getErrMsg());
    95 
    96                 dlg.tfM01Name.setEnabled(true);
    97                 dlg.tfM01Name.setText(getName());
    98 
    99                 dlg.cM01TopMark.setSelected(true);
    100                 dlg.cM01TopMark.setEnabled(false);
    101                 dlg.cM01Fired.setEnabled(true);
    102 
    103                 String image = "/images/Cardinal";
    104 
    105                 switch (getStyleIndex()) {
    106                 case SeaMark.CARD_PILLAR:
    107                         image += "_Pillar";
    108                         break;
    109 
    110                 case SeaMark.CARD_SPAR:
    111                         image += "_Spar";
    112                         break;
    113 
    114                 case SeaMark.CARD_BEACON:
    115                         image += "_Beacon";
    116                         break;
    117 
    118                 case SeaMark.CARD_TOWER:
    119                         image += "_Tower";
    120                         break;
    121 
    122                 case SeaMark.CARD_FLOAT:
    123                         image += "_Float";
    124                         break;
    125 
    126                 default:
    127                         return;
    128                 }
    129 
    130                 switch (getBuoyIndex()) {
    131                 case CARD_NORTH:
    132                         image += "_North";
    133                         break;
    134                 case CARD_EAST:
    135                         image += "_East";
    136                         break;
    137                 case CARD_SOUTH:
    138                         image += "_South";
    139                         break;
    140                 case CARD_WEST:
    141                         image += "_West";
    142                         break;
    143                 default:
    144                         return;
    145                 }
    146 
    147                 if (image != "") {
    148                         if (isFired()) {
    149                                 image += "_Lit";
    150 
    151                                 if (getLightChar() != "") {
    152                                         String tmp = null;
    153                                         String c;
    154                                         int i1;
    155 
    156                                         c = getLightChar();
    157                                         if (c.contains("+")) {
    158                                                 i1 = c.indexOf("+");
    159                                                 tmp = c.substring(i1, c.length());
    160                                                 c = c.substring(0, i1);
    161                                         }
    162 
    163                                         if (getLightGroup() != "")
    164                                                 c = c + "(" + getLightGroup() + ")";
    165                                         if (tmp != null)
    166                                                 c = c + tmp;
    167 
    168                                         dlg.cbM01Kennung.setSelectedItem(c);
    169                                         if (dlg.cbM01Kennung.getSelectedItem().equals("Not set"))
    170                                                 c = "";
    171                                 }
    172                         }
    173 
    174                         image += ".png";
    175 
    176                         dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
    177                 } else
    178                         dlg.lM01Icon01.setIcon(null);
    179         }
    180 
    181         public boolean parseLight(Node node) {
    182                 String str;
    183                 boolean ret = true;
    184                 Map<String, String> keys;
    185 
    186                 setFired(false);
    187 
    188                 keys = node.getKeys();
    189                 if (keys.containsKey("seamark:light:colour")) {
    190                         str = keys.get("seamark:light:colour");
    191 
    192                         if (keys.containsKey("seamark:light:character")) {
    193                                 int i1;
    194                                 String tmp = null;
    195 
    196                                 setLightGroup(keys);
    197 
    198                                 String c = keys.get("seamark:light:character");
    199 
    200                                 if (c.contains("+")) {
    201                                         i1 = c.indexOf("+");
    202                                         tmp = c.substring(i1, c.length());
    203                                         c = c.substring(0, i1);
    204                                 }
    205 
    206                                 if (getLightGroup() != "")
    207                                         if (tmp != null) {
    208                                                 c = c + tmp;
    209                                         }
    210 
    211                                 setLightChar(c);
    212                                 setLightPeriod(keys);
    213                         }
    214 
    215                         if (str.equals("white")) {
    216                                 setFired(true);
    217                                 setLightColour("W");
    218 
    219                         } else {
    220                                 if (getErrMsg() == null)
    221                                         setErrMsg("Parse-Error: Licht falsch");
    222                                 else
    223                                         setErrMsg(getErrMsg() + " / Licht falsch");
    224 
    225                                 ret = false;
    226                         }
    227                 }
    228 
    229                 return ret;
    230         }
    231 
    232         public void setLightColour() {
    233                 super.setLightColour("W");
    234         }
    235 
    236         public boolean parseShape(Node node) {
    237                 String str;
    238                 boolean ret = true;
    239                 Map<String, String> keys;
    240 
    241                 keys = node.getKeys();
     39                if (keys.containsKey("name"))
     40                        setName(keys.get("name"));
     41
     42                if (keys.containsKey("seamark:name"))
     43                        setName(keys.get("seamark:name"));
     44
     45                if (keys.containsKey("seamark:buoy_cardinal:name"))
     46                        setName(keys.get("seamark:buoy_cardinal:name"));
     47                else if (keys.containsKey("seamark:beacon_cardinal:name"))
     48                        setName(keys.get("seamark:beacon_cardinal:name"));
     49                else if (keys.containsKey("seamark:light_float:name"))
     50                        setName(keys.get("seamark:light_float:name"));
     51
     52                String cat = "";
     53                String col = "";
     54
     55                if (keys.containsKey("seamark:buoy_cardinal:category"))
     56                        cat = keys.get("seamark:buoy_cardinal:category");
     57                else if (keys.containsKey("seamark:beacon_cardinal:category"))
     58                        cat = keys.get("seamark:beacon_cardinal:category");
     59
     60                if (keys.containsKey("seamark:buoy_cardinal:colour"))
     61                        col = keys.get("seamark:buoy_cardinal:colour");
     62                else if (keys.containsKey("seamark:beacon_cardinal:colour"))
     63                        col = keys.get("seamark:beacon_cardinal:colour");
     64                else if (keys.containsKey("seamark:light_float:colour"))
     65                        col = keys.get("seamark:light_float:colour");
     66
     67                if (cat.equals("")) {
     68                        if (col.equals("black;yellow")) {
     69                                setBuoyIndex(CARD_NORTH);
     70                                setColour(BLACK_YELLOW);
     71                        } else if (col.equals("black;yellow;black")) {
     72                                setBuoyIndex(CARD_EAST);
     73                                setColour(BLACK_YELLOW_BLACK);
     74                        } else if (col.equals("yellow;black")) {
     75                                setBuoyIndex(CARD_SOUTH);
     76                                setColour(YELLOW_BLACK);
     77                        } else if (col.equals("yellow;black;yellow")) {
     78                                setBuoyIndex(CARD_WEST);
     79                                setColour(YELLOW_BLACK_YELLOW);
     80                        }
     81                } else if (cat.equals("north")) {
     82                        setBuoyIndex(CARD_NORTH);
     83                        setColour(BLACK_YELLOW);
     84                } else if (cat.equals("east")) {
     85                        setBuoyIndex(CARD_EAST);
     86                        setColour(BLACK_YELLOW_BLACK);
     87                } else if (cat.equals("south")) {
     88                        setBuoyIndex(CARD_SOUTH);
     89                        setColour(YELLOW_BLACK);
     90                } else if (cat.equals("west")) {
     91                        setBuoyIndex(CARD_WEST);
     92                        setColour(YELLOW_BLACK_YELLOW);
     93                }
    24294
    24395                if (keys.containsKey("seamark:buoy_cardinal:shape")) {
     
    248100                        else if (str.equals("spar"))
    249101                                setStyleIndex(CARD_SPAR);
    250                         else
    251                                 ret = false;
    252102                } else if (keys.containsKey("seamark:beacon_cardinal:colour")) {
    253103                        if (keys.containsKey("seamark:beacon_cardinal:shape")) {
     
    264114                        setStyleIndex(CARD_FLOAT);
    265115                }
    266                 return ret;
     116
     117                refreshLights();
     118
     119                if (keys.containsKey("seamark:light:colour")) {
     120                        str = keys.get("seamark:light:colour");
     121
     122                        if (keys.containsKey("seamark:light:character")) {
     123                                int i1;
     124                                String tmp = null;
     125
     126                                setLightGroup(keys);
     127
     128                                String c = keys.get("seamark:light:character");
     129
     130                                if (c.contains("+")) {
     131                                        i1 = c.indexOf("+");
     132                                        tmp = c.substring(i1, c.length());
     133                                        c = c.substring(0, i1);
     134                                }
     135
     136                                if (getLightGroup() != "")
     137                                        if (tmp != null) {
     138                                                c = c + tmp;
     139                                        }
     140
     141                                setLightChar(c);
     142                                setLightPeriod(keys);
     143                        }
     144
     145                        if (str.equals("white")) {
     146                                setFired(true);
     147                                setLightColour("W");
     148                        }
     149                }
     150
     151                paintSign();
    267152        }
    268153
    269         public boolean parseTopMark(Node node) {
    270                 return false;
     154        public void refreshLights() {
     155                int type = getBuoyIndex();
     156
     157                dlg.cbM01Kennung.removeAllItems();
     158                dlg.cbM01Kennung.addItem("Not set");
     159                dlg.cbM01Kennung.setSelectedIndex(0);
     160
     161                switch (type) {
     162                case SeaMark.CARD_NORTH:
     163                        dlg.cbM01Kennung.addItem("Q");
     164                        dlg.cbM01Kennung.addItem("VQ");
     165                        break;
     166
     167                case SeaMark.CARD_EAST:
     168                        dlg.cbM01Kennung.addItem("Q(3)");
     169                        dlg.cbM01Kennung.addItem("VQ(3)");
     170                        break;
     171
     172                case SeaMark.CARD_SOUTH:
     173                        dlg.cbM01Kennung.addItem("Q(6)+LFl");
     174                        dlg.cbM01Kennung.addItem("VQ(6)+LFl");
     175                        break;
     176
     177                case SeaMark.CARD_WEST:
     178                        dlg.cbM01Kennung.addItem("Q(9)");
     179                        dlg.cbM01Kennung.addItem("VQ(9)");
     180                        break;
     181
     182                default:
     183                }
     184
    271185        }
    272186
     187        public void paintSign() {
     188                super.paintSign();
     189
     190                dlg.sM01StatusBar.setText(getErrMsg());
     191
     192                dlg.tfM01Name.setEnabled(true);
     193                dlg.tfM01Name.setText(getName());
     194
     195                dlg.cM01TopMark.setSelected(true);
     196                dlg.cM01TopMark.setEnabled(false);
     197                dlg.cM01Fired.setEnabled(true);
     198
     199                String image = "/images/Cardinal";
     200
     201                switch (getStyleIndex()) {
     202                case SeaMark.CARD_PILLAR:
     203                        image += "_Pillar";
     204                        break;
     205
     206                case SeaMark.CARD_SPAR:
     207                        image += "_Spar";
     208                        break;
     209
     210                case SeaMark.CARD_BEACON:
     211                        image += "_Beacon";
     212                        break;
     213
     214                case SeaMark.CARD_TOWER:
     215                        image += "_Tower";
     216                        break;
     217
     218                case SeaMark.CARD_FLOAT:
     219                        image += "_Float";
     220                        break;
     221
     222                default:
     223                        return;
     224                }
     225
     226                switch (getBuoyIndex()) {
     227                case CARD_NORTH:
     228                        image += "_North";
     229                        break;
     230                case CARD_EAST:
     231                        image += "_East";
     232                        break;
     233                case CARD_SOUTH:
     234                        image += "_South";
     235                        break;
     236                case CARD_WEST:
     237                        image += "_West";
     238                        break;
     239                default:
     240                        return;
     241                }
     242
     243                if (!image.equals("")) {
     244                        if (isFired()) {
     245                                image += "_Lit";
     246
     247                                if (getLightChar() != "") {
     248                                        String tmp = null;
     249                                        String c;
     250                                        int i1;
     251
     252                                        c = getLightChar();
     253                                        if (c.contains("+")) {
     254                                                i1 = c.indexOf("+");
     255                                                tmp = c.substring(i1, c.length());
     256                                                c = c.substring(0, i1);
     257                                        }
     258
     259                                        if (getLightGroup() != "")
     260                                                c = c + "(" + getLightGroup() + ")";
     261                                        if (tmp != null)
     262                                                c = c + tmp;
     263
     264                                        dlg.cbM01Kennung.setSelectedItem(c);
     265                                        if (dlg.cbM01Kennung.getSelectedItem().equals("Not set"))
     266                                                c = "";
     267                                }
     268                        }
     269
     270                        image += ".png";
     271
     272                        dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
     273                } else
     274                        dlg.lM01Icon01.setIcon(null);
     275        }
     276
     277        public void setLightColour() {
     278                super.setLightColour("W");
     279        }
     280       
    273281        public void saveSign() {
    274282                Node node = getNode();
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyIsol.java

    r22704 r22722  
    1616
    1717public class BuoyIsol extends Buoy {
    18         public BuoyIsol(SmpDialogAction dia, int type) {
     18        public BuoyIsol(SmpDialogAction dia, Node node) {
    1919                super(dia);
     20
     21                String str;
     22                Map<String, String> keys;
     23                keys = node.getKeys();
     24                setNode(node);
    2025
    2126                dlg.cbM01StyleOfMark.removeAllItems();
     
    3843                setColour(SeaMark.BLACK_RED_BLACK);
    3944                setLightColour("W");
    40                 setBuoyIndex(type);
     45                setBuoyIndex(ISOLATED_DANGER);
    4146                setTopMark(true);
    42 
    43                 paintSign();
    44         }
    45 
    46         public void paintSign() {
    47                 super.paintSign();
    48 
    49                 dlg.sM01StatusBar.setText(getErrMsg());
    50 
    51                 dlg.tfM01Name.setEnabled(true);
    52                 dlg.tfM01Name.setText(getName());
    53                 dlg.cM01Fired.setEnabled(true);
    54                 dlg.cM01TopMark.setEnabled(false);
    55 
    56                 String image = "/images/Cardinal";
    57 
    58                 switch (getStyleIndex()) {
    59                 case ISOL_PILLAR:
    60                         image += "_Pillar_Single";
    61                         break;
    62                 case ISOL_SPAR:
    63                         image += "_Spar_Single";
    64                         break;
    65                 case ISOL_BEACON:
    66                         image += "_Beacon_Single";
    67                         break;
    68                 case ISOL_TOWER:
    69                         image += "_Tower_Single";
    70                         break;
    71                 case ISOL_FLOAT:
    72                         image += "_Float_Single";
    73                         break;
    74                 default:
    75                 }
    76 
    77                 if (image != "/images/Cardinal") {
    78                         if (isFired()) {
    79                                 image += "_Lit";
    80                                 if (getLightChar() != "") {
    81                                         String c;
    82 
    83                                         c = getLightChar();
    84                                         if (getLightGroup() != "")
    85                                                 c = c + "(" + getLightGroup() + ")";
    86                                         dlg.cbM01Kennung.setSelectedItem(c);
    87                                 }
    88                         }
    89                         image += ".png";
    90                         dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
    91                 } else
    92                         dlg.lM01Icon01.setIcon(null);
    93         }
    94 
    95         public void saveSign() {
    96                 Node node = getNode();
    97 
    98                 if (node == null) {
    99                         return;
    100                 }
    101 
    102                 switch (getStyleIndex()) {
    103                 case ISOL_PILLAR:
    104                         super.saveSign("buoy_isolated_danger");
    105                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    106                                         "seamark:buoy_isolated_danger:shape", "pillar"));
    107                         break;
    108                 case ISOL_SPAR:
    109                         super.saveSign("buoy_isolated_danger");
    110                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    111                                         "seamark:buoy_isolated_danger:shape", "spar"));
    112                         break;
    113                 case ISOL_BEACON:
    114                         super.saveSign("beacon_isolated_danger");
    115                         break;
    116                 case ISOL_TOWER:
    117                         super.saveSign("beacon_isolated_danger");
    118                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    119                                         "seamark:beacon_isolated_danger:shape", "tower"));
    120                         break;
    121                 case ISOL_FLOAT:
    122                         super.saveSign("light_float");
    123                         break;
    124                 default:
    125                 }
    126                
    127                 switch (getStyleIndex()) {
    128                 case ISOL_PILLAR:
    129                 case ISOL_SPAR:
    130                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    131                                         "seamark:buoy_isolated_danger:colour_pattern", "horizontal stripes"));
    132                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    133                                         "seamark:buoy_isolated_danger:colour", "black;red;black"));
    134                         break;
    135                 case ISOL_BEACON:
    136                 case ISOL_TOWER:
    137                         Main.main.undoRedo
    138                                         .add(new ChangePropertyCommand(node,
    139                                                         "seamark:beacon_isolated_danger:colour_pattern",
    140                                                         "horizontal stripes"));
    141                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    142                                         "seamark:beacon_isolated_danger:colour", "black;red;black"));
    143                         break;
    144                 case ISOL_FLOAT:
    145                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    146                                         "seamark:light_float:colour_pattern", "horizontal stripes"));
    147                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    148                                         "seamark:light_float:colour", "black;red;black"));
    149                         break;
    150                 }
    151 
    152                 saveTopMarkData("2 spheres", "black");
    153 
    154                 saveLightData("white");
    155 
    156         }
    157 
    158         public boolean parseTopMark(Node node) {
    159                 if (node == null) {
    160                         return false;
    161                 }
    162 
    163                 String str;
    164                 boolean ret = true;
    165                 Map<String, String> keys;
    166 
    167                 setTopMark(false);
    168 
    169                 keys = node.getKeys();
    170                 if (keys.containsKey("seamark:topmark:shape")) {
    171                         str = keys.get("seamark:topmark:shape");
    172 
    173                         if (str.equals("2 spheres")) {
    174                                 setTopMark(true);
    175 
    176                         } else {
    177                                 setErrMsg("Parse-Error: Topmark invalid");
    178                                 ret = false;
    179                         }
    180                 }
    181 
    182                 return ret;
    183         }
    184 
    185         public boolean parseLight(Node node) {
    186                 String str;
    187                 boolean ret = true;
    188                 Map<String, String> keys;
    189 
    190                 setFired(false);
    191 
    192                 keys = node.getKeys();
    193                 if (keys.containsKey("seamark:light:colour")) {
    194                         str = keys.get("seamark:light:colour");
    195 
    196                         if (keys.containsKey("seamark:light:character")) {
    197                                 setLightGroup(keys);
    198                                 String c = keys.get("seamark:light:character");
    199                                 setLightChar(c);
    200                                 setLightPeriod(keys);
    201                         }
    202 
    203                         if (str.equals("white")) {
    204                                 setFired(true);
    205                                 setLightColour("W");
    206 
    207                         } else {
    208                                 if (getErrMsg() == null)
    209                                         setErrMsg("Parse-Error: Invalid light");
    210                                 else
    211                                         setErrMsg(getErrMsg() + " / Invalid light");
    212 
    213                                 ret = false;
    214                         }
    215 
    216                 }
    217 
    218                 return ret;
    219         }
    220 
    221         public void setLightColour() {
    222                 super.setLightColour("W");
    223         }
    224 
    225         public boolean parseShape(Node node) {
    226                 String str;
    227                 boolean ret = true;
    228                 Map<String, String> keys;
    229 
    230                 keys = node.getKeys();
    23147
    23248                if (keys.containsKey("seamark:buoy_isolated_danger:shape")) {
     
    23753                        else if (str.equals("spar"))
    23854                                setStyleIndex(ISOL_SPAR);
    239                         else
    240                                 ret = false;
    24155                } else if (keys.containsKey("seamark:beacon_isolated_danger:colour")) {
    24256                        if (keys.containsKey("seamark:beacon_isolated_danger:shape")) {
     
    25367                        setStyleIndex(CARD_FLOAT);
    25468                }
    255                 return ret;
     69
     70                if (keys.containsKey("seamark:topmark:shape")) {
     71                        str = keys.get("seamark:topmark:shape");
     72                        if (str.equals("2 spheres")) {
     73                                setTopMark(true);
     74                        }
     75                }
     76
     77                if (keys.containsKey("seamark:light:colour")) {
     78                        str = keys.get("seamark:light:colour");
     79
     80                        if (keys.containsKey("seamark:light:character")) {
     81                                setLightGroup(keys);
     82                                String c = keys.get("seamark:light:character");
     83                                setLightChar(c);
     84                                setLightPeriod(keys);
     85                        }
     86
     87                        if (str.equals("white")) {
     88                                setFired(true);
     89                                setLightColour("W");
     90                        }
     91                }
     92
     93                paintSign();
     94        }
     95
     96        public void paintSign() {
     97                super.paintSign();
     98
     99                dlg.sM01StatusBar.setText(getErrMsg());
     100
     101                dlg.tfM01Name.setEnabled(true);
     102                dlg.tfM01Name.setText(getName());
     103                dlg.cM01Fired.setEnabled(true);
     104                dlg.cM01TopMark.setEnabled(false);
     105
     106                String image = "/images/Cardinal";
     107
     108                switch (getStyleIndex()) {
     109                case ISOL_PILLAR:
     110                        image += "_Pillar_Single";
     111                        break;
     112                case ISOL_SPAR:
     113                        image += "_Spar_Single";
     114                        break;
     115                case ISOL_BEACON:
     116                        image += "_Beacon_Single";
     117                        break;
     118                case ISOL_TOWER:
     119                        image += "_Tower_Single";
     120                        break;
     121                case ISOL_FLOAT:
     122                        image += "_Float_Single";
     123                        break;
     124                default:
     125                }
     126
     127                if (!image.equals("/images/Cardinal")) {
     128                        if (isFired()) {
     129                                image += "_Lit";
     130                                if (getLightChar() != "") {
     131                                        String c;
     132
     133                                        c = getLightChar();
     134                                        if (getLightGroup() != "")
     135                                                c = c + "(" + getLightGroup() + ")";
     136                                        dlg.cbM01Kennung.setSelectedItem(c);
     137                                }
     138                        }
     139                        image += ".png";
     140                        dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
     141                } else
     142                        dlg.lM01Icon01.setIcon(null);
     143        }
     144
     145        public void saveSign() {
     146                Node node = getNode();
     147
     148                if (node == null) {
     149                        return;
     150                }
     151
     152                switch (getStyleIndex()) {
     153                case ISOL_PILLAR:
     154                        super.saveSign("buoy_isolated_danger");
     155                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     156                                        "seamark:buoy_isolated_danger:shape", "pillar"));
     157                        break;
     158                case ISOL_SPAR:
     159                        super.saveSign("buoy_isolated_danger");
     160                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     161                                        "seamark:buoy_isolated_danger:shape", "spar"));
     162                        break;
     163                case ISOL_BEACON:
     164                        super.saveSign("beacon_isolated_danger");
     165                        break;
     166                case ISOL_TOWER:
     167                        super.saveSign("beacon_isolated_danger");
     168                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     169                                        "seamark:beacon_isolated_danger:shape", "tower"));
     170                        break;
     171                case ISOL_FLOAT:
     172                        super.saveSign("light_float");
     173                        break;
     174                default:
     175                }
     176
     177                switch (getStyleIndex()) {
     178                case ISOL_PILLAR:
     179                case ISOL_SPAR:
     180                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     181                                        "seamark:buoy_isolated_danger:colour_pattern", "horizontal stripes"));
     182                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     183                                        "seamark:buoy_isolated_danger:colour", "black;red;black"));
     184                        break;
     185                case ISOL_BEACON:
     186                case ISOL_TOWER:
     187                        Main.main.undoRedo
     188                                        .add(new ChangePropertyCommand(node,
     189                                                        "seamark:beacon_isolated_danger:colour_pattern",
     190                                                        "horizontal stripes"));
     191                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     192                                        "seamark:beacon_isolated_danger:colour", "black;red;black"));
     193                        break;
     194                case ISOL_FLOAT:
     195                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     196                                        "seamark:light_float:colour_pattern", "horizontal stripes"));
     197                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     198                                        "seamark:light_float:colour", "black;red;black"));
     199                        break;
     200                }
     201
     202                saveTopMarkData("2 spheres", "black");
     203
     204                saveLightData("white");
     205
     206        }
     207
     208        public void setLightColour() {
     209                super.setLightColour("W");
    256210        }
    257211
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyLat.java

    r22692 r22722  
    1616
    1717public class BuoyLat extends Buoy {
    18         public BuoyLat(SmpDialogAction dia, int type) {
     18        public BuoyLat(SmpDialogAction dia, Node node) {
    1919                super(dia);
     20
     21                String str;
     22                Map<String, String> keys;
     23                keys = node.getKeys();
     24                setNode(node);
    2025
    2126                dlg.cbM01Kennung.removeAllItems();
     
    3237                dlg.cbM01Kennung.setSelectedIndex(0);
    3338
    34                 setBuoyIndex(type);
    3539                setStyleIndex(0);
    3640                setLightColour();
     
    4347                dlg.tbM01Region.setEnabled(true);
    4448
     49                if (keys.containsKey("name"))
     50                        setName(keys.get("name"));
     51
     52                if (keys.containsKey("seamark:name"))
     53                        setName(keys.get("seamark:name"));
     54
     55                if (keys.containsKey("seamark:buoy_lateral:name"))
     56                        setName(keys.get("seamark:buoy_lateral:name"));
     57                else if (keys.containsKey("seamark:beacon_lateral:name"))
     58                        setName(keys.get("seamark:beacon_lateral:name"));
     59                else if (keys.containsKey("seamark:light_float:name"))
     60                        setName(keys.get("seamark:light_float:name"));
     61
     62                String cat = "";
     63                String col = "";
     64
     65                if (keys.containsKey("seamark:buoy_lateral:category"))
     66                        cat = keys.get("seamark:buoy_lateral:category");
     67                else if (keys.containsKey("seamark:beacon_lateral:category"))
     68                        cat = keys.get("seamark:beacon_lateral:category");
     69
     70                if (keys.containsKey("seamark:buoy_lateral:colour"))
     71                        col = keys.get("seamark:buoy_lateral:colour");
     72                else if (keys.containsKey("seamark:beacon_lateral:colour"))
     73                        col = keys.get("seamark:beacon_lateral:colour");
     74                else if (keys.containsKey("seamark:light_float:colour"))
     75                        col = keys.get("seamark:light_float:colour");
     76
     77                if (cat.equals("")) {
     78                        if (col.equals("red")) {
     79                                setColour(RED);
     80                                if (getRegion() == IALA_A)
     81                                        setBuoyIndex(PORT_HAND);
     82                                else
     83                                        setBuoyIndex(STARBOARD_HAND);
     84                        } else if (col.equals("green")) {
     85                                setColour(GREEN);
     86                                if (getRegion() == IALA_A)
     87                                        setBuoyIndex(STARBOARD_HAND);
     88                                else
     89                                        setBuoyIndex(PORT_HAND);
     90                        } else if (col.equals("red;green;red")) {
     91                                setColour(RED_GREEN_RED);
     92                                if (getRegion() == IALA_A)
     93                                        setBuoyIndex(PREF_PORT_HAND);
     94                                else
     95                                        setBuoyIndex(PREF_STARBOARD_HAND);
     96                        } else if (col.equals("green;red;green")) {
     97                                setColour(GREEN_RED_GREEN);
     98                                if (getRegion() == IALA_A)
     99                                        setBuoyIndex(PREF_STARBOARD_HAND);
     100                                else
     101                                        setBuoyIndex(PREF_PORT_HAND);
     102                        }
     103                } else if (cat.equals("port")) {
     104
     105                        setBuoyIndex(PORT_HAND);
     106
     107                        if (col.equals("red")) {
     108                                setRegion(SeaMark.IALA_A);
     109                                setColour(SeaMark.RED);
     110                        } else if (col.equals("green")) {
     111                                setRegion(SeaMark.IALA_B);
     112                                setColour(SeaMark.GREEN);
     113                        } else {
     114                                if (getRegion() == IALA_A)
     115                                        setColour(SeaMark.RED);
     116                                else
     117                                        setColour(SeaMark.GREEN);
     118                        }
     119                } else if (cat.compareTo("starboard") == 0) {
     120
     121                        setBuoyIndex(STARBOARD_HAND);
     122
     123                        if (col.compareTo("green") == 0) {
     124                                setRegion(SeaMark.IALA_A);
     125                                setColour(SeaMark.GREEN);
     126                        } else if (col.equals("red")) {
     127                                setRegion(SeaMark.IALA_B);
     128                                setColour(SeaMark.RED);
     129                        } else {
     130                                if (getRegion() == IALA_A)
     131                                        setColour(SeaMark.GREEN);
     132                                else
     133                                        setColour(SeaMark.RED);
     134                        }
     135                } else if (cat.compareTo("preferred_channel_port") == 0) {
     136
     137                        setBuoyIndex(PREF_PORT_HAND);
     138
     139                        if (col.compareTo("red;green;red") == 0) {
     140                                setRegion(SeaMark.IALA_A);
     141                                setColour(SeaMark.RED_GREEN_RED);
     142                        } else if (col.compareTo("green;red;green") == 0) {
     143                                setRegion(SeaMark.IALA_B);
     144                                setColour(SeaMark.GREEN_RED_GREEN);
     145                        } else {
     146                                if (getRegion() == IALA_A)
     147                                        setColour(SeaMark.RED_GREEN_RED);
     148                                else
     149                                        setColour(SeaMark.GREEN_RED_GREEN);
     150                        }
     151
     152                } else if (cat.compareTo("preferred_channel_starboard") == 0) {
     153
     154                        setBuoyIndex(PREF_STARBOARD_HAND);
     155
     156                        if (col.compareTo("green;red;green") == 0) {
     157                                setRegion(SeaMark.IALA_A);
     158                                setColour(SeaMark.GREEN_RED_GREEN);
     159                        } else if (col.compareTo("red;green;red") == 0) {
     160                                setRegion(SeaMark.IALA_B);
     161                                setColour(SeaMark.RED_GREEN_RED);
     162                        } else {
     163                                if (getRegion() == IALA_A)
     164                                        setColour(SeaMark.GREEN_RED_GREEN);
     165                                else
     166                                        setColour(SeaMark.RED_GREEN_RED);
     167                        }
     168                }
     169
    45170                refreshStyles();
    46 
    47                 paintSign();
    48         }
    49 
    50         public void refreshStyles() {
    51                 int type = getBuoyIndex();
    52                 int style = getStyleIndex();
    53 
    54                 dlg.cbM01StyleOfMark.removeAllItems();
    55                 dlg.cbM01StyleOfMark.addItem("Not set");
    56 
    57                 switch (type) {
    58                 case PORT_HAND:
    59                         dlg.cbM01StyleOfMark.addItem("Can Buoy");
    60                         dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
    61                         dlg.cbM01StyleOfMark.addItem("Spar Buoy");
    62                         dlg.cbM01StyleOfMark.addItem("Beacon");
    63                         dlg.cbM01StyleOfMark.addItem("Tower");
    64                         dlg.cbM01StyleOfMark.addItem("Float");
    65                         dlg.cbM01StyleOfMark.addItem("Perch");
    66                         break;
    67 
    68                 case STARBOARD_HAND:
    69                         dlg.cbM01StyleOfMark.addItem("Cone Buoy");
    70                         dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
    71                         dlg.cbM01StyleOfMark.addItem("Spar Buoy");
    72                         dlg.cbM01StyleOfMark.addItem("Beacon");
    73                         dlg.cbM01StyleOfMark.addItem("Tower");
    74                         dlg.cbM01StyleOfMark.addItem("Float");
    75                         dlg.cbM01StyleOfMark.addItem("Perch");
    76                         break;
    77 
    78                 case PREF_PORT_HAND:
    79                         dlg.cbM01StyleOfMark.addItem("Can Buoy");
    80                         dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
    81                         dlg.cbM01StyleOfMark.addItem("Spar Buoy");
    82                         dlg.cbM01StyleOfMark.addItem("Beacon");
    83                         dlg.cbM01StyleOfMark.addItem("Tower");
    84                         dlg.cbM01StyleOfMark.addItem("Float");
    85                         break;
    86 
    87                 case PREF_STARBOARD_HAND:
    88                         dlg.cbM01StyleOfMark.addItem("Cone Buoy");
    89                         dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
    90                         dlg.cbM01StyleOfMark.addItem("Spar Buoy");
    91                         dlg.cbM01StyleOfMark.addItem("Beacon");
    92                         dlg.cbM01StyleOfMark.addItem("Tower");
    93                         dlg.cbM01StyleOfMark.addItem("Float");
    94                         break;
    95 
    96                 default:
    97                 }
    98 
    99                 if (style >= dlg.cbM01StyleOfMark.getItemCount())
    100                         style = 0;
    101                 setStyleIndex(style);
    102                 dlg.cbM01StyleOfMark.setSelectedIndex(style);
    103 
    104         }
    105 
    106         public void paintSign() {
    107                 super.paintSign();
    108 
    109                 dlg.sM01StatusBar.setText(getErrMsg());
    110 
    111                 dlg.tfM01Name.setEnabled(true);
    112                 dlg.tfM01Name.setText(getName());
    113                 dlg.cM01Fired.setEnabled(true);
    114                 dlg.cM01TopMark.setEnabled(true);
    115 
    116                 String image = "/images/Lateral";
    117 
    118                 int cat = getBuoyIndex();
    119                 boolean region = getRegion();
    120                 int style = getStyleIndex();
    121 
    122                 switch (getBuoyIndex()) {
    123                 case SeaMark.PORT_HAND:
    124                         if (region != SeaMark.IALA_B)
    125                                 switch (style) {
    126                                 case LAT_CAN:
    127                                         image += "_Can_Red";
    128                                         break;
    129                                 case LAT_PILLAR:
    130                                         image += "_Pillar_Red";
    131                                         break;
    132                                 case LAT_SPAR:
    133                                         image += "_Spar_Red";
    134                                         break;
    135                                 case LAT_BEACON:
    136                                         image += "_Beacon_Red";
    137                                         break;
    138                                 case LAT_TOWER:
    139                                         image += "_Tower_Red";
    140                                         break;
    141                                 case LAT_FLOAT:
    142                                         image += "_Float_Red";
    143                                         break;
    144                                 case LAT_PERCH:
    145                                         image += "_Perch_Port";
    146                                         break;
    147                                 default:
    148                                 }
    149                         else
    150                                 switch (style) {
    151                                 case LAT_CAN:
    152                                         image += "_Can_Green";
    153                                         break;
    154                                 case LAT_PILLAR:
    155                                         image += "_Pillar_Green";
    156                                         break;
    157                                 case LAT_SPAR:
    158                                         image += "_Spar_Green";
    159                                         break;
    160                                 case LAT_BEACON:
    161                                         image += "_Beacon_Green";
    162                                         break;
    163                                 case LAT_TOWER:
    164                                         image += "_Tower_Green";
    165                                         break;
    166                                 case LAT_FLOAT:
    167                                         image += "_Float_Green";
    168                                         break;
    169                                 case LAT_PERCH:
    170                                         image += "_Perch_Port";
    171                                         break;
    172                                 default:
    173                                 }
    174                         break;
    175 
    176                 case SeaMark.STARBOARD_HAND:
    177                         if (region != SeaMark.IALA_B)
    178                                 switch (style) {
    179                                 case LAT_CONE:
    180                                         image += "_Cone_Green";
    181                                         break;
    182                                 case LAT_PILLAR:
    183                                         image += "_Pillar_Green";
    184                                         break;
    185                                 case LAT_SPAR:
    186                                         image += "_Spar_Green";
    187                                         break;
    188                                 case LAT_BEACON:
    189                                         image += "_Beacon_Green";
    190                                         break;
    191                                 case LAT_TOWER:
    192                                         image += "_Tower_Green";
    193                                         break;
    194                                 case LAT_FLOAT:
    195                                         image += "_Float_Green";
    196                                         break;
    197                                 case LAT_PERCH:
    198                                         image += "_Perch_Starboard";
    199                                         break;
    200                                 default:
    201                                 }
    202                         else
    203                                 switch (style) {
    204                                 case LAT_CONE:
    205                                         image += "_Cone_Red";
    206                                         break;
    207                                 case LAT_PILLAR:
    208                                         image += "_Pillar_Red";
    209                                         break;
    210                                 case LAT_SPAR:
    211                                         image += "_Spar_Red";
    212                                         break;
    213                                 case LAT_BEACON:
    214                                         image += "_Beacon_Red";
    215                                         break;
    216                                 case LAT_TOWER:
    217                                         image += "_Tower_Red";
    218                                         break;
    219                                 case LAT_FLOAT:
    220                                         image += "_Float_Red";
    221                                         break;
    222                                 case LAT_PERCH:
    223                                         image += "_Perch_Starboard";
    224                                         break;
    225                                 default:
    226                                 }
    227                         break;
    228 
    229                 case SeaMark.PREF_PORT_HAND:
    230                         if (region != SeaMark.IALA_B)
    231                                 switch (style) {
    232                                 case LAT_CAN:
    233                                         image += "_Can_Red_Green_Red";
    234                                         break;
    235                                 case LAT_PILLAR:
    236                                         image += "_Pillar_Red_Green_Red";
    237                                         break;
    238                                 case LAT_SPAR:
    239                                         image += "_Spar_Red_Green_Red";
    240                                         break;
    241                                 case LAT_BEACON:
    242                                         image += "_Beacon_Red_Green_Red";
    243                                         break;
    244                                 case LAT_TOWER:
    245                                         image += "_Tower_Red_Green_Red";
    246                                         break;
    247                                 case LAT_FLOAT:
    248                                         image += "_Float_Red_Green_Red";
    249                                         break;
    250                                 default:
    251                                 }
    252                         else
    253                                 switch (style) {
    254                                 case LAT_CAN:
    255                                         image += "_Can_Green_Red_Green";
    256                                         break;
    257                                 case LAT_PILLAR:
    258                                         image += "_Pillar_Green_Red_Green";
    259                                         break;
    260                                 case LAT_SPAR:
    261                                         image += "_Spar_Green_Red_Green";
    262                                         break;
    263                                 case LAT_BEACON:
    264                                         image += "_Beacon_Green_Red_Green";
    265                                         break;
    266                                 case LAT_TOWER:
    267                                         image += "_Tower_Green_Red_Green";
    268                                         break;
    269                                 case LAT_FLOAT:
    270                                         image += "_Float_Green_Red_Green";
    271                                         break;
    272                                 default:
    273                                 }
    274                         break;
    275 
    276                 case SeaMark.PREF_STARBOARD_HAND:
    277                         if (region != SeaMark.IALA_B)
    278                                 switch (style) {
    279                                 case LAT_CONE:
    280                                         image += "_Cone_Green_Red_Green";
    281                                         break;
    282                                 case LAT_PILLAR:
    283                                         image += "_Pillar_Green_Red_Green";
    284                                         break;
    285                                 case LAT_SPAR:
    286                                         image += "_Spar_Green_Red_Green";
    287                                         break;
    288                                 case LAT_BEACON:
    289                                         image += "_Beacon_Green_Red_Green";
    290                                         break;
    291                                 case LAT_TOWER:
    292                                         image += "_Tower_Green_Red_Green";
    293                                         break;
    294                                 case LAT_FLOAT:
    295                                         image += "_Float_Green_Red_Green";
    296                                         break;
    297                                 default:
    298                                 }
    299                         else
    300                                 switch (style) {
    301                                 case LAT_CONE:
    302                                         image += "_Cone_Red_Green_Red";
    303                                         break;
    304                                 case LAT_PILLAR:
    305                                         image += "_Pillar_Red_Green_Red";
    306                                         break;
    307                                 case LAT_SPAR:
    308                                         image += "_Spar_Red_Green_Red";
    309                                         break;
    310                                 case LAT_BEACON:
    311                                         image += "_Beacon_Red_Green_Red";
    312                                         break;
    313                                 case LAT_TOWER:
    314                                         image += "_Tower_Red_Green_Red";
    315                                         break;
    316                                 case LAT_FLOAT:
    317                                         image += "_Float_Red_Green_Red";
    318                                         break;
    319                                 default:
    320                                 }
    321                         break;
    322 
    323                 default:
    324                 }
    325 
    326                 if (image != "/images/Lateral") {
    327 
    328                         if (hasTopMark()) {
    329                                 if (cat == PORT_HAND || cat == PREF_PORT_HAND)
    330                                         image += "_Can";
    331                                 else
    332                                         image += "_Cone";
    333                         }
    334 
    335                         if (isFired())
    336                                 image += "_Lit";
    337                         if (getLightChar() != "") {
    338                                 String c;
    339 
    340                                 c = getLightChar();
    341                                 if (getLightGroup() != "")
    342                                         c = c + "(" + getLightGroup() + ")";
    343 
    344                                 dlg.cbM01Kennung.setSelectedItem(c);
    345                                 if (dlg.cbM01Kennung.getSelectedItem().equals("Not set"))
    346                                         c = "";
    347                         }
    348 
    349                         image += ".png";
    350 
    351                         dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
    352                 } else
    353                         dlg.lM01Icon01.setIcon(null);
    354         }
    355 
    356         public void saveSign() {
    357                 Node node = getNode();
    358 
    359                 if (node == null) {
    360                         return;
    361                 }
    362 
    363                 int cat = getBuoyIndex();
    364                 String shape = "";
    365                 String colour = "";
    366 
    367                 switch (cat) {
    368 
    369                 case PORT_HAND:
    370                         switch (getStyleIndex()) {
    371                         case LAT_CAN:
    372                                 super.saveSign("buoy_lateral");
    373                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    374                                                 "seamark:buoy_lateral:shape", "can"));
    375                                 break;
    376                         case LAT_PILLAR:
    377                                 super.saveSign("buoy_lateral");
    378                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    379                                                 "seamark:buoy_lateral:shape", "pillar"));
    380                                 break;
    381                         case LAT_SPAR:
    382                                 super.saveSign("buoy_lateral");
    383                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    384                                                 "seamark:buoy_lateral:shape", "spar"));
    385                                 break;
    386                         case LAT_BEACON:
    387                                 super.saveSign("beacon_lateral");
    388                                 break;
    389                         case LAT_TOWER:
    390                                 super.saveSign("beacon_lateral");
    391                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    392                                                 "seamark:beacon_lateral:shape", "tower"));
    393                                 break;
    394                         case LAT_FLOAT:
    395                                 super.saveSign("light_float");
    396                                 break;
    397                         case LAT_PERCH:
    398                                 super.saveSign("buoy_lateral");
    399                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    400                                                 "seamark:buoy_lateral:shape", "perch"));
    401                                 break;
    402                         default:
    403                         }
    404                         switch (getStyleIndex()) {
    405                         case LAT_CAN:
    406                         case LAT_PILLAR:
    407                         case LAT_SPAR:
    408                         case LAT_PERCH:
    409                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    410                                                 "seamark:buoy_lateral:category", "port"));
    411                                 if (getRegion() != SeaMark.IALA_B) {
    412                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    413                                                         "seamark:buoy_lateral:colour", "red"));
    414                                         colour = "red";
    415                                 } else {
    416                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    417                                                         "seamark:buoy_lateral:colour", "green"));
    418                                         colour = "green";
    419                                 }
    420                                 break;
    421                         case LAT_BEACON:
    422                         case LAT_TOWER:
    423                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    424                                                 "seamark:beacon_lateral:category", "port"));
    425                                 if (getRegion() != SeaMark.IALA_B) {
    426                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    427                                                         "seamark:beacon_lateral:colour", "red"));
    428                                         colour = "red";
    429                                 } else {
    430                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    431                                                         "seamark:beacon_lateral:colour", "green"));
    432                                         colour = "green";
    433                                 }
    434                                 break;
    435                         case LAT_FLOAT:
    436                                 if (getRegion() != SeaMark.IALA_B) {
    437                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    438                                                         "seamark:light_float:colour", "red"));
    439                                         colour = "red";
    440                                 } else {
    441                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    442                                                         "seamark:light_float:colour", "green"));
    443                                         colour = "green";
    444                                 }
    445                                 break;
    446                         }
    447                         shape = "cylinder";
    448                         break;
    449 
    450                 case PREF_PORT_HAND:
    451                         switch (getStyleIndex()) {
    452                         case LAT_CAN:
    453                                 super.saveSign("buoy_lateral");
    454                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    455                                                 "seamark:buoy_lateral:shape", "can"));
    456                                 break;
    457                         case LAT_PILLAR:
    458                                 super.saveSign("buoy_lateral");
    459                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    460                                                 "seamark:buoy_lateral:shape", "pillar"));
    461                                 break;
    462                         case LAT_SPAR:
    463                                 super.saveSign("buoy_lateral");
    464                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    465                                                 "seamark:buoy_lateral:shape", "spar"));
    466                                 break;
    467                         case LAT_BEACON:
    468                                 super.saveSign("beacon_lateral");
    469                                 break;
    470                         case LAT_TOWER:
    471                                 super.saveSign("beacon_lateral");
    472                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    473                                                 "seamark:beacon_lateral:shape", "tower"));
    474                                 break;
    475                         case LAT_FLOAT:
    476                                 super.saveSign("light_float");
    477                                 break;
    478                         default:
    479                         }
    480                         switch (getStyleIndex()) {
    481                         case LAT_CAN:
    482                         case LAT_PILLAR:
    483                         case LAT_SPAR:
    484                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    485                                                 "seamark:buoy_lateral:category", "preferred_channel_port"));
    486                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    487                                                 "seamark:buoy_lateral:colour_pattern", "horizontal stripes"));
    488                                 if (getRegion() != SeaMark.IALA_B) {
    489                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    490                                                         "seamark:buoy_lateral:colour", "red;green;red"));
    491                                         colour = "red";
    492                                 } else {
    493                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    494                                                         "seamark:buoy_lateral:colour", "green;red;green"));
    495                                         colour = "green";
    496                                 }
    497                                 break;
    498                         case LAT_BEACON:
    499                         case LAT_TOWER:
    500                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    501                                                 "seamark:beacon_lateral:category", "preferred_channel_port"));
    502                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    503                                                 "seamark:beacon_lateral:colour_pattern", "horizontal stripes"));
    504                                 if (getRegion() != SeaMark.IALA_B) {
    505                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    506                                                         "seamark:beacon_lateral:colour", "red;green;red"));
    507                                         colour = "red";
    508                                 } else {
    509                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    510                                                         "seamark:beacon_lateral:colour", "green;red;green"));
    511                                         colour = "green";
    512                                 }
    513                                 break;
    514                         case LAT_FLOAT:
    515                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    516                                                 "seamark:light_float:colour_pattern", "horizontal stripes"));
    517                                 if (getRegion() != SeaMark.IALA_B) {
    518                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    519                                                         "seamark:light_float:colour", "red;green;red"));
    520                                         colour = "red";
    521                                 } else {
    522                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    523                                                         "seamark:light_float:colour", "green;red;green"));
    524                                         colour = "green";
    525                                 }
    526                                 break;
    527                         }
    528                         shape = "cylinder";
    529                         break;
    530 
    531                 case STARBOARD_HAND:
    532                         switch (getStyleIndex()) {
    533                         case LAT_CONE:
    534                                 super.saveSign("buoy_lateral");
    535                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    536                                                 "seamark:buoy_lateral:shape", "conical"));
    537                                 break;
    538                         case LAT_PILLAR:
    539                                 super.saveSign("buoy_lateral");
    540                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    541                                                 "seamark:buoy_lateral:shape", "pillar"));
    542                                 break;
    543                         case LAT_SPAR:
    544                                 super.saveSign("buoy_lateral");
    545                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    546                                                 "seamark:buoy_lateral:shape", "spar"));
    547                                 break;
    548                         case LAT_BEACON:
    549                                 super.saveSign("beacon_lateral");
    550                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    551                                                 "seamark:beacon_lateral:shape", "stake"));
    552                                 break;
    553                         case LAT_TOWER:
    554                                 super.saveSign("beacon_lateral");
    555                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    556                                                 "seamark:beacon_lateral:shape", "tower"));
    557                                 break;
    558                         case LAT_FLOAT:
    559                                 super.saveSign("light_float");
    560                                 break;
    561                         case LAT_PERCH:
    562                                 super.saveSign("buoy_lateral");
    563                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    564                                                 "seamark:buoy_lateral:shape", "perch"));
    565                                 break;
    566                         default:
    567                         }
    568                         switch (getStyleIndex()) {
    569                         case LAT_CAN:
    570                         case LAT_PILLAR:
    571                         case LAT_SPAR:
    572                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    573                                                 "seamark:buoy_lateral:category", "starboard"));
    574                                 if (getRegion() != SeaMark.IALA_B) {
    575                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    576                                                         "seamark:buoy_lateral:colour", "green"));
    577                                         colour = "green";
    578                                 } else {
    579                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    580                                                         "seamark:buoy_lateral:colour", "red"));
    581                                         colour = "red";
    582                                 }
    583                                 break;
    584                         case LAT_BEACON:
    585                         case LAT_TOWER:
    586                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    587                                                 "seamark:beacon_lateral:category", "starboard"));
    588                                 if (getRegion() != SeaMark.IALA_B) {
    589                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    590                                                         "seamark:beacon_lateral:colour", "green"));
    591                                         colour = "green";
    592                                 } else {
    593                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    594                                                         "seamark:beacon_lateral:colour", "red"));
    595                                         colour = "red";
    596                                 }
    597                                 break;
    598                         case LAT_FLOAT:
    599                                 if (getRegion() != SeaMark.IALA_B) {
    600                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    601                                                         "seamark:light_float:colour", "green"));
    602                                         colour = "green";
    603                                 } else {
    604                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    605                                                         "seamark:light_float:colour", "red"));
    606                                         colour = "red";
    607                                 }
    608                                 break;
    609                         }
    610                         shape = "cone, point up";
    611                         break;
    612 
    613                 case PREF_STARBOARD_HAND:
    614                         switch (getStyleIndex()) {
    615                         case LAT_CONE:
    616                                 super.saveSign("buoy_lateral");
    617                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    618                                                 "seamark:buoy_lateral:shape", "conical"));
    619                                 break;
    620                         case LAT_PILLAR:
    621                                 super.saveSign("buoy_lateral");
    622                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    623                                                 "seamark:buoy_lateral:shape", "pillar"));
    624                                 break;
    625                         case LAT_SPAR:
    626                                 super.saveSign("buoy_lateral");
    627                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    628                                                 "seamark:buoy_lateral:shape", "spar"));
    629                                 break;
    630                         case LAT_BEACON:
    631                                 super.saveSign("beacon_lateral");
    632                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    633                                                 "seamark:beacon_lateral:shape", "stake"));
    634                                 break;
    635                         case LAT_TOWER:
    636                                 super.saveSign("beacon_lateral");
    637                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    638                                                 "seamark:beacon_lateral:shape", "tower"));
    639                                 break;
    640                         case LAT_FLOAT:
    641                                 super.saveSign("light_float");
    642                                 break;
    643                         default:
    644                         }
    645                         switch (getStyleIndex()) {
    646                         case LAT_CAN:
    647                         case LAT_PILLAR:
    648                         case LAT_SPAR:
    649                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    650                                                 "seamark:buoy_lateral:category", "preferred_channel_starboard"));
    651                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    652                                                 "seamark:buoy_lateral:colour_pattern", "horizontal stripes"));
    653                                 if (getRegion() != SeaMark.IALA_B) {
    654                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    655                                                         "seamark:buoy_lateral:colour", "green;red;green"));
    656                                         colour = "green";
    657                                 } else {
    658                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    659                                                         "seamark:buoy_lateral:colour", "red;green;red"));
    660                                         colour = "red";
    661                                 }
    662                                 break;
    663                         case LAT_BEACON:
    664                         case LAT_TOWER:
    665                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    666                                                 "seamark:beacon_lateral:category", "preferred_channel_starboard"));
    667                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    668                                                 "seamark:beacon_lateral:colour_pattern", "horizontal stripes"));
    669                                 if (getRegion() != SeaMark.IALA_B) {
    670                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    671                                                         "seamark:beacon_lateral:colour", "green;red;green"));
    672                                         colour = "green";
    673                                 } else {
    674                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    675                                                         "seamark:beacon_lateral:colour", "red;green;red"));
    676                                         colour = "red";
    677                                 }
    678                                 break;
    679                         case LAT_FLOAT:
    680                                 Main.main.undoRedo.add(new ChangePropertyCommand(node,
    681                                                 "seamark:light_float:colour_pattern", "horizontal stripes"));
    682                                 if (getRegion() != SeaMark.IALA_B) {
    683                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    684                                                         "seamark:light_float:colour", "green;red;green"));
    685                                         colour = "green";
    686                                 } else {
    687                                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    688                                                         "seamark:light_float:colour", "red;green;red"));
    689                                         colour = "red";
    690                                 }
    691                                 break;
    692                         }
    693                         shape = "cone, point up";
    694                         break;
    695 
    696                 default:
    697                 }
    698 
    699                 saveTopMarkData(shape, colour);
    700                 saveLightData(colour);
    701 
    702                 Main.pref.put("tomsplugin.IALA", getRegion() ? "B" : "A");
    703         }
    704 
    705         public boolean parseTopMark(Node node) {
    706                 if (node == null) {
    707                         return false;
    708                 }
    709 
    710                 String str;
    711                 boolean ret = true;
    712                 Map<String, String> keys;
    713 
    714                 keys = node.getKeys();
    715 
    716                 if (keys.containsKey("seamark:topmark:shape")) {
    717                         str = keys.get("seamark:topmark:shape");
    718 
    719                         int cat = getBuoyIndex();
    720                         switch (cat) {
    721                         case PORT_HAND:
    722                         case PREF_PORT_HAND:
    723                                 if (str.equals("cylinder")) {
    724                                         setTopMark(true);
    725                                         setRegion(IALA_A);
    726                                 } else if (str.equals("cone, point up")) {
    727                                         setTopMark(true);
    728                                         setRegion(IALA_B);
    729                                 } else {
    730                                         setTopMark(false);
    731                                         ret = false;
    732                                 }
    733                                 break;
    734 
    735                         case STARBOARD_HAND:
    736                         case PREF_STARBOARD_HAND:
    737                                 if (str.equals("cone, point up")) {
    738                                         setTopMark(true);
    739                                         setRegion(IALA_A);
    740                                 } else if (str.equals("cylinder")) {
    741                                         setTopMark(true);
    742                                         setRegion(IALA_B);
    743                                 } else {
    744                                         setTopMark(false);
    745                                         ret = false;
    746                                 }
    747                                 break;
    748 
    749                         default:
    750                                 ret = false;
    751                         }
    752                         if (!hasTopMark()) {
    753                                 setErrMsg("Parse-Error: Invalid topmark");
    754                                 ret = false;
    755                         }
    756                 }
    757                 return ret;
    758         }
    759 
    760         public boolean parseLight(Node node) {
    761                 String str;
    762                 boolean ret = true;
    763                 Map<String, String> keys;
    764 
    765                 setFired(false);
    766 
    767                 keys = node.getKeys();
    768 
    769                 if (keys.containsKey("seamark:light:colour")) {
    770                         str = keys.get("seamark:light:colour");
    771 
    772                         if (keys.containsKey("seamark:light:character")) {
    773                                 setLightGroup(keys);
    774                                 String c = keys.get("seamark:light:character");
    775                                 setLightChar(c);
    776                                 setLightPeriod(keys);
    777                         }
    778 
    779                         setLightColour(str);
    780 
    781                         if (isFired()) {
    782 
    783                         } else {
    784                                 if (getErrMsg() == null)
    785                                         setErrMsg("Parse-Error: Invalid light");
    786                                 else
    787                                         setErrMsg(getErrMsg() + " / Invalid light");
    788                         }
    789 
    790                 }
    791 
    792                 return ret;
    793         }
    794 
    795         public void setLightColour() {
    796                 if (getRegion() == IALA_A
    797                                 && (getBuoyIndex() == PORT_HAND || getBuoyIndex() == PREF_PORT_HAND)) {
    798                         super.setLightColour("R");
    799                 } else {
    800                         super.setLightColour("G");
    801                 }
    802         }
    803 
    804         public void setLightColour(String str) {
    805                 int cat = getBuoyIndex();
    806 
    807                 if (str == null) {
    808                         return;
    809                 }
    810 
    811                 switch (cat) {
    812                 case PORT_HAND:
    813                 case PREF_PORT_HAND:
    814                         if (getRegion() == IALA_A) {
    815                                 if (str.equals("red")) {
    816                                         setFired(true);
    817                                         super.setLightColour("R");
    818                                 } else {
    819                                         super.setLightColour("");
    820                                 }
    821                         } else {
    822                                 if (str.equals("green")) {
    823                                         setFired(true);
    824                                         super.setLightColour("G");
    825                                 } else {
    826                                         super.setLightColour("");
    827                                 }
    828                         }
    829                         break;
    830 
    831                 case STARBOARD_HAND:
    832                 case PREF_STARBOARD_HAND:
    833                         if (getRegion() == IALA_A) {
    834                                 if (str.equals("green")) {
    835                                         setFired(true);
    836                                         super.setLightColour("G");
    837                                 } else {
    838                                         super.setLightColour("");
    839                                 }
    840                         } else {
    841                                 if (str.equals("red")) {
    842                                         setFired(true);
    843                                         super.setLightColour("R");
    844                                 } else {
    845                                         super.setLightColour("");
    846                                 }
    847                         }
    848                         break;
    849 
    850                 default:
    851                 }
    852 
    853         }
    854 
    855         public boolean parseShape(Node node) {
    856                 String str;
    857                 boolean ret = true;
    858                 Map<String, String> keys;
    859 
    860                 keys = node.getKeys();
    861171
    862172                if (keys.containsKey("seamark:buoy_lateral:shape")) {
    863173                        str = keys.get("seamark:buoy_lateral:shape");
    864174
    865                         int cat = getBuoyIndex();
    866                         switch (cat) {
     175                        switch (getBuoyIndex()) {
    867176                        case PORT_HAND:
    868177                                if (str.compareTo("can") == 0)
     
    872181                                else if (str.compareTo("spar") == 0)
    873182                                        setStyleIndex(LAT_SPAR);
    874                                 else
    875                                         ret = false;
    876183                                break;
    877184
     
    883190                                else if (str.compareTo("spar") == 0)
    884191                                        setStyleIndex(LAT_SPAR);
    885                                 else
    886                                         ret = false;
    887192                                break;
    888193
     
    894199                                else if (str.compareTo("spar") == 0)
    895200                                        setStyleIndex(LAT_SPAR);
    896                                 else
    897                                         ret = false;
    898201                                break;
    899202
     
    905208                                else if (str.compareTo("spar") == 0)
    906209                                        setStyleIndex(LAT_SPAR);
    907                                 else
    908                                         ret = false;
    909                                 break;
    910 
    911                         default:
    912                                 ret = false;
     210                                break;
    913211                        }
    914212                } else if (keys.containsKey("seamark:beacon_lateral:colour")) {
     
    925223                        setStyleIndex(LAT_FLOAT);
    926224                }
    927                 return ret;
     225
     226                if (keys.containsKey("seamark:topmark:shape")) {
     227                        str = keys.get("seamark:topmark:shape");
     228
     229                        switch (getBuoyIndex()) {
     230                        case PORT_HAND:
     231                        case PREF_PORT_HAND:
     232                                if (str.equals("cylinder")) {
     233                                        setTopMark(true);
     234                                        setRegion(IALA_A);
     235                                } else if (str.equals("cone, point up")) {
     236                                        setTopMark(true);
     237                                        setRegion(IALA_B);
     238                                } else {
     239                                        setTopMark(false);
     240                                }
     241                                break;
     242
     243                        case STARBOARD_HAND:
     244                        case PREF_STARBOARD_HAND:
     245                                if (str.equals("cone, point up")) {
     246                                        setTopMark(true);
     247                                        setRegion(IALA_A);
     248                                } else if (str.equals("cylinder")) {
     249                                        setTopMark(true);
     250                                        setRegion(IALA_B);
     251                                } else {
     252                                        setTopMark(false);
     253                                }
     254                                break;
     255                        }
     256                }
     257
     258                if (keys.containsKey("seamark:light:colour")) {
     259                        setLightColour(keys.get("seamark:light:colour"));
     260                        setFired(true);
     261                }
     262
     263                if (keys.containsKey("seamark:light:character")) {
     264                        setLightGroup(keys);
     265                        setLightChar(keys.get("seamark:light:character"));
     266                        setLightPeriod(keys);
     267                }
     268
     269                paintSign();
    928270        }
     271
     272        public void refreshStyles() {
     273                int type = getBuoyIndex();
     274                int style = getStyleIndex();
     275
     276                dlg.cbM01StyleOfMark.removeAllItems();
     277                dlg.cbM01StyleOfMark.addItem("Not set");
     278
     279                switch (type) {
     280                case PORT_HAND:
     281                        dlg.cbM01StyleOfMark.addItem("Can Buoy");
     282                        dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
     283                        dlg.cbM01StyleOfMark.addItem("Spar Buoy");
     284                        dlg.cbM01StyleOfMark.addItem("Beacon");
     285                        dlg.cbM01StyleOfMark.addItem("Tower");
     286                        dlg.cbM01StyleOfMark.addItem("Float");
     287                        dlg.cbM01StyleOfMark.addItem("Perch");
     288                        break;
     289
     290                case STARBOARD_HAND:
     291                        dlg.cbM01StyleOfMark.addItem("Cone Buoy");
     292                        dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
     293                        dlg.cbM01StyleOfMark.addItem("Spar Buoy");
     294                        dlg.cbM01StyleOfMark.addItem("Beacon");
     295                        dlg.cbM01StyleOfMark.addItem("Tower");
     296                        dlg.cbM01StyleOfMark.addItem("Float");
     297                        dlg.cbM01StyleOfMark.addItem("Perch");
     298                        break;
     299
     300                case PREF_PORT_HAND:
     301                        dlg.cbM01StyleOfMark.addItem("Can Buoy");
     302                        dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
     303                        dlg.cbM01StyleOfMark.addItem("Spar Buoy");
     304                        dlg.cbM01StyleOfMark.addItem("Beacon");
     305                        dlg.cbM01StyleOfMark.addItem("Tower");
     306                        dlg.cbM01StyleOfMark.addItem("Float");
     307                        break;
     308
     309                case PREF_STARBOARD_HAND:
     310                        dlg.cbM01StyleOfMark.addItem("Cone Buoy");
     311                        dlg.cbM01StyleOfMark.addItem("Pillar Buoy");
     312                        dlg.cbM01StyleOfMark.addItem("Spar Buoy");
     313                        dlg.cbM01StyleOfMark.addItem("Beacon");
     314                        dlg.cbM01StyleOfMark.addItem("Tower");
     315                        dlg.cbM01StyleOfMark.addItem("Float");
     316                        break;
     317
     318                default:
     319                }
     320
     321                if (style >= dlg.cbM01StyleOfMark.getItemCount())
     322                        style = 0;
     323                setStyleIndex(style);
     324                dlg.cbM01StyleOfMark.setSelectedIndex(style);
     325
     326        }
     327
     328        public void paintSign() {
     329                super.paintSign();
     330
     331                dlg.sM01StatusBar.setText(getErrMsg());
     332
     333                dlg.tfM01Name.setEnabled(true);
     334                dlg.tfM01Name.setText(getName());
     335                dlg.cM01Fired.setEnabled(true);
     336                dlg.cM01TopMark.setEnabled(true);
     337
     338                String image = "/images/Lateral";
     339
     340                int cat = getBuoyIndex();
     341                boolean region = getRegion();
     342                int style = getStyleIndex();
     343
     344                switch (getBuoyIndex()) {
     345                case SeaMark.PORT_HAND:
     346                        if (region != SeaMark.IALA_B)
     347                                switch (style) {
     348                                case LAT_CAN:
     349                                        image += "_Can_Red";
     350                                        break;
     351                                case LAT_PILLAR:
     352                                        image += "_Pillar_Red";
     353                                        break;
     354                                case LAT_SPAR:
     355                                        image += "_Spar_Red";
     356                                        break;
     357                                case LAT_BEACON:
     358                                        image += "_Beacon_Red";
     359                                        break;
     360                                case LAT_TOWER:
     361                                        image += "_Tower_Red";
     362                                        break;
     363                                case LAT_FLOAT:
     364                                        image += "_Float_Red";
     365                                        break;
     366                                case LAT_PERCH:
     367                                        image += "_Perch_Port";
     368                                        break;
     369                                default:
     370                                }
     371                        else
     372                                switch (style) {
     373                                case LAT_CAN:
     374                                        image += "_Can_Green";
     375                                        break;
     376                                case LAT_PILLAR:
     377                                        image += "_Pillar_Green";
     378                                        break;
     379                                case LAT_SPAR:
     380                                        image += "_Spar_Green";
     381                                        break;
     382                                case LAT_BEACON:
     383                                        image += "_Beacon_Green";
     384                                        break;
     385                                case LAT_TOWER:
     386                                        image += "_Tower_Green";
     387                                        break;
     388                                case LAT_FLOAT:
     389                                        image += "_Float_Green";
     390                                        break;
     391                                case LAT_PERCH:
     392                                        image += "_Perch_Port";
     393                                        break;
     394                                default:
     395                                }
     396                        break;
     397
     398                case SeaMark.STARBOARD_HAND:
     399                        if (region != SeaMark.IALA_B)
     400                                switch (style) {
     401                                case LAT_CONE:
     402                                        image += "_Cone_Green";
     403                                        break;
     404                                case LAT_PILLAR:
     405                                        image += "_Pillar_Green";
     406                                        break;
     407                                case LAT_SPAR:
     408                                        image += "_Spar_Green";
     409                                        break;
     410                                case LAT_BEACON:
     411                                        image += "_Beacon_Green";
     412                                        break;
     413                                case LAT_TOWER:
     414                                        image += "_Tower_Green";
     415                                        break;
     416                                case LAT_FLOAT:
     417                                        image += "_Float_Green";
     418                                        break;
     419                                case LAT_PERCH:
     420                                        image += "_Perch_Starboard";
     421                                        break;
     422                                default:
     423                                }
     424                        else
     425                                switch (style) {
     426                                case LAT_CONE:
     427                                        image += "_Cone_Red";
     428                                        break;
     429                                case LAT_PILLAR:
     430                                        image += "_Pillar_Red";
     431                                        break;
     432                                case LAT_SPAR:
     433                                        image += "_Spar_Red";
     434                                        break;
     435                                case LAT_BEACON:
     436                                        image += "_Beacon_Red";
     437                                        break;
     438                                case LAT_TOWER:
     439                                        image += "_Tower_Red";
     440                                        break;
     441                                case LAT_FLOAT:
     442                                        image += "_Float_Red";
     443                                        break;
     444                                case LAT_PERCH:
     445                                        image += "_Perch_Starboard";
     446                                        break;
     447                                default:
     448                                }
     449                        break;
     450
     451                case SeaMark.PREF_PORT_HAND:
     452                        if (region != SeaMark.IALA_B)
     453                                switch (style) {
     454                                case LAT_CAN:
     455                                        image += "_Can_Red_Green_Red";
     456                                        break;
     457                                case LAT_PILLAR:
     458                                        image += "_Pillar_Red_Green_Red";
     459                                        break;
     460                                case LAT_SPAR:
     461                                        image += "_Spar_Red_Green_Red";
     462                                        break;
     463                                case LAT_BEACON:
     464                                        image += "_Beacon_Red_Green_Red";
     465                                        break;
     466                                case LAT_TOWER:
     467                                        image += "_Tower_Red_Green_Red";
     468                                        break;
     469                                case LAT_FLOAT:
     470                                        image += "_Float_Red_Green_Red";
     471                                        break;
     472                                default:
     473                                }
     474                        else
     475                                switch (style) {
     476                                case LAT_CAN:
     477                                        image += "_Can_Green_Red_Green";
     478                                        break;
     479                                case LAT_PILLAR:
     480                                        image += "_Pillar_Green_Red_Green";
     481                                        break;
     482                                case LAT_SPAR:
     483                                        image += "_Spar_Green_Red_Green";
     484                                        break;
     485                                case LAT_BEACON:
     486                                        image += "_Beacon_Green_Red_Green";
     487                                        break;
     488                                case LAT_TOWER:
     489                                        image += "_Tower_Green_Red_Green";
     490                                        break;
     491                                case LAT_FLOAT:
     492                                        image += "_Float_Green_Red_Green";
     493                                        break;
     494                                default:
     495                                }
     496                        break;
     497
     498                case SeaMark.PREF_STARBOARD_HAND:
     499                        if (region != SeaMark.IALA_B)
     500                                switch (style) {
     501                                case LAT_CONE:
     502                                        image += "_Cone_Green_Red_Green";
     503                                        break;
     504                                case LAT_PILLAR:
     505                                        image += "_Pillar_Green_Red_Green";
     506                                        break;
     507                                case LAT_SPAR:
     508                                        image += "_Spar_Green_Red_Green";
     509                                        break;
     510                                case LAT_BEACON:
     511                                        image += "_Beacon_Green_Red_Green";
     512                                        break;
     513                                case LAT_TOWER:
     514                                        image += "_Tower_Green_Red_Green";
     515                                        break;
     516                                case LAT_FLOAT:
     517                                        image += "_Float_Green_Red_Green";
     518                                        break;
     519                                default:
     520                                }
     521                        else
     522                                switch (style) {
     523                                case LAT_CONE:
     524                                        image += "_Cone_Red_Green_Red";
     525                                        break;
     526                                case LAT_PILLAR:
     527                                        image += "_Pillar_Red_Green_Red";
     528                                        break;
     529                                case LAT_SPAR:
     530                                        image += "_Spar_Red_Green_Red";
     531                                        break;
     532                                case LAT_BEACON:
     533                                        image += "_Beacon_Red_Green_Red";
     534                                        break;
     535                                case LAT_TOWER:
     536                                        image += "_Tower_Red_Green_Red";
     537                                        break;
     538                                case LAT_FLOAT:
     539                                        image += "_Float_Red_Green_Red";
     540                                        break;
     541                                default:
     542                                }
     543                        break;
     544
     545                default:
     546                }
     547
     548                if (!image.equals("/images/Lateral")) {
     549
     550                        if (hasTopMark()) {
     551                                if (cat == PORT_HAND || cat == PREF_PORT_HAND)
     552                                        image += "_Can";
     553                                else
     554                                        image += "_Cone";
     555                        }
     556
     557                        if (isFired())
     558                                image += "_Lit";
     559                        if (getLightChar() != "") {
     560                                String c;
     561
     562                                c = getLightChar();
     563                                if (getLightGroup() != "")
     564                                        c = c + "(" + getLightGroup() + ")";
     565
     566                                dlg.cbM01Kennung.setSelectedItem(c);
     567                                if (dlg.cbM01Kennung.getSelectedItem().equals("Not set"))
     568                                        c = "";
     569                        }
     570
     571                        image += ".png";
     572
     573                        dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
     574                } else
     575                        dlg.lM01Icon01.setIcon(null);
     576        }
     577
     578        public void saveSign() {
     579                Node node = getNode();
     580
     581                if (node == null) {
     582                        return;
     583                }
     584
     585                int cat = getBuoyIndex();
     586                String shape = "";
     587                String colour = "";
     588
     589                switch (cat) {
     590
     591                case PORT_HAND:
     592                        switch (getStyleIndex()) {
     593                        case LAT_CAN:
     594                                super.saveSign("buoy_lateral");
     595                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     596                                                "seamark:buoy_lateral:shape", "can"));
     597                                break;
     598                        case LAT_PILLAR:
     599                                super.saveSign("buoy_lateral");
     600                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     601                                                "seamark:buoy_lateral:shape", "pillar"));
     602                                break;
     603                        case LAT_SPAR:
     604                                super.saveSign("buoy_lateral");
     605                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     606                                                "seamark:buoy_lateral:shape", "spar"));
     607                                break;
     608                        case LAT_BEACON:
     609                                super.saveSign("beacon_lateral");
     610                                break;
     611                        case LAT_TOWER:
     612                                super.saveSign("beacon_lateral");
     613                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     614                                                "seamark:beacon_lateral:shape", "tower"));
     615                                break;
     616                        case LAT_FLOAT:
     617                                super.saveSign("light_float");
     618                                break;
     619                        case LAT_PERCH:
     620                                super.saveSign("buoy_lateral");
     621                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     622                                                "seamark:buoy_lateral:shape", "perch"));
     623                                break;
     624                        default:
     625                        }
     626                        switch (getStyleIndex()) {
     627                        case LAT_CAN:
     628                        case LAT_PILLAR:
     629                        case LAT_SPAR:
     630                        case LAT_PERCH:
     631                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     632                                                "seamark:buoy_lateral:category", "port"));
     633                                if (getRegion() != SeaMark.IALA_B) {
     634                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     635                                                        "seamark:buoy_lateral:colour", "red"));
     636                                        colour = "red";
     637                                } else {
     638                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     639                                                        "seamark:buoy_lateral:colour", "green"));
     640                                        colour = "green";
     641                                }
     642                                break;
     643                        case LAT_BEACON:
     644                        case LAT_TOWER:
     645                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     646                                                "seamark:beacon_lateral:category", "port"));
     647                                if (getRegion() != SeaMark.IALA_B) {
     648                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     649                                                        "seamark:beacon_lateral:colour", "red"));
     650                                        colour = "red";
     651                                } else {
     652                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     653                                                        "seamark:beacon_lateral:colour", "green"));
     654                                        colour = "green";
     655                                }
     656                                break;
     657                        case LAT_FLOAT:
     658                                if (getRegion() != SeaMark.IALA_B) {
     659                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     660                                                        "seamark:light_float:colour", "red"));
     661                                        colour = "red";
     662                                } else {
     663                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     664                                                        "seamark:light_float:colour", "green"));
     665                                        colour = "green";
     666                                }
     667                                break;
     668                        }
     669                        shape = "cylinder";
     670                        break;
     671
     672                case PREF_PORT_HAND:
     673                        switch (getStyleIndex()) {
     674                        case LAT_CAN:
     675                                super.saveSign("buoy_lateral");
     676                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     677                                                "seamark:buoy_lateral:shape", "can"));
     678                                break;
     679                        case LAT_PILLAR:
     680                                super.saveSign("buoy_lateral");
     681                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     682                                                "seamark:buoy_lateral:shape", "pillar"));
     683                                break;
     684                        case LAT_SPAR:
     685                                super.saveSign("buoy_lateral");
     686                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     687                                                "seamark:buoy_lateral:shape", "spar"));
     688                                break;
     689                        case LAT_BEACON:
     690                                super.saveSign("beacon_lateral");
     691                                break;
     692                        case LAT_TOWER:
     693                                super.saveSign("beacon_lateral");
     694                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     695                                                "seamark:beacon_lateral:shape", "tower"));
     696                                break;
     697                        case LAT_FLOAT:
     698                                super.saveSign("light_float");
     699                                break;
     700                        default:
     701                        }
     702                        switch (getStyleIndex()) {
     703                        case LAT_CAN:
     704                        case LAT_PILLAR:
     705                        case LAT_SPAR:
     706                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     707                                                "seamark:buoy_lateral:category", "preferred_channel_port"));
     708                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     709                                                "seamark:buoy_lateral:colour_pattern", "horizontal stripes"));
     710                                if (getRegion() != SeaMark.IALA_B) {
     711                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     712                                                        "seamark:buoy_lateral:colour", "red;green;red"));
     713                                        colour = "red";
     714                                } else {
     715                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     716                                                        "seamark:buoy_lateral:colour", "green;red;green"));
     717                                        colour = "green";
     718                                }
     719                                break;
     720                        case LAT_BEACON:
     721                        case LAT_TOWER:
     722                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     723                                                "seamark:beacon_lateral:category", "preferred_channel_port"));
     724                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     725                                                "seamark:beacon_lateral:colour_pattern", "horizontal stripes"));
     726                                if (getRegion() != SeaMark.IALA_B) {
     727                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     728                                                        "seamark:beacon_lateral:colour", "red;green;red"));
     729                                        colour = "red";
     730                                } else {
     731                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     732                                                        "seamark:beacon_lateral:colour", "green;red;green"));
     733                                        colour = "green";
     734                                }
     735                                break;
     736                        case LAT_FLOAT:
     737                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     738                                                "seamark:light_float:colour_pattern", "horizontal stripes"));
     739                                if (getRegion() != SeaMark.IALA_B) {
     740                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     741                                                        "seamark:light_float:colour", "red;green;red"));
     742                                        colour = "red";
     743                                } else {
     744                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     745                                                        "seamark:light_float:colour", "green;red;green"));
     746                                        colour = "green";
     747                                }
     748                                break;
     749                        }
     750                        shape = "cylinder";
     751                        break;
     752
     753                case STARBOARD_HAND:
     754                        switch (getStyleIndex()) {
     755                        case LAT_CONE:
     756                                super.saveSign("buoy_lateral");
     757                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     758                                                "seamark:buoy_lateral:shape", "conical"));
     759                                break;
     760                        case LAT_PILLAR:
     761                                super.saveSign("buoy_lateral");
     762                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     763                                                "seamark:buoy_lateral:shape", "pillar"));
     764                                break;
     765                        case LAT_SPAR:
     766                                super.saveSign("buoy_lateral");
     767                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     768                                                "seamark:buoy_lateral:shape", "spar"));
     769                                break;
     770                        case LAT_BEACON:
     771                                super.saveSign("beacon_lateral");
     772                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     773                                                "seamark:beacon_lateral:shape", "stake"));
     774                                break;
     775                        case LAT_TOWER:
     776                                super.saveSign("beacon_lateral");
     777                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     778                                                "seamark:beacon_lateral:shape", "tower"));
     779                                break;
     780                        case LAT_FLOAT:
     781                                super.saveSign("light_float");
     782                                break;
     783                        case LAT_PERCH:
     784                                super.saveSign("buoy_lateral");
     785                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     786                                                "seamark:buoy_lateral:shape", "perch"));
     787                                break;
     788                        default:
     789                        }
     790                        switch (getStyleIndex()) {
     791                        case LAT_CAN:
     792                        case LAT_PILLAR:
     793                        case LAT_SPAR:
     794                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     795                                                "seamark:buoy_lateral:category", "starboard"));
     796                                if (getRegion() != SeaMark.IALA_B) {
     797                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     798                                                        "seamark:buoy_lateral:colour", "green"));
     799                                        colour = "green";
     800                                } else {
     801                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     802                                                        "seamark:buoy_lateral:colour", "red"));
     803                                        colour = "red";
     804                                }
     805                                break;
     806                        case LAT_BEACON:
     807                        case LAT_TOWER:
     808                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     809                                                "seamark:beacon_lateral:category", "starboard"));
     810                                if (getRegion() != SeaMark.IALA_B) {
     811                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     812                                                        "seamark:beacon_lateral:colour", "green"));
     813                                        colour = "green";
     814                                } else {
     815                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     816                                                        "seamark:beacon_lateral:colour", "red"));
     817                                        colour = "red";
     818                                }
     819                                break;
     820                        case LAT_FLOAT:
     821                                if (getRegion() != SeaMark.IALA_B) {
     822                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     823                                                        "seamark:light_float:colour", "green"));
     824                                        colour = "green";
     825                                } else {
     826                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     827                                                        "seamark:light_float:colour", "red"));
     828                                        colour = "red";
     829                                }
     830                                break;
     831                        }
     832                        shape = "cone, point up";
     833                        break;
     834
     835                case PREF_STARBOARD_HAND:
     836                        switch (getStyleIndex()) {
     837                        case LAT_CONE:
     838                                super.saveSign("buoy_lateral");
     839                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     840                                                "seamark:buoy_lateral:shape", "conical"));
     841                                break;
     842                        case LAT_PILLAR:
     843                                super.saveSign("buoy_lateral");
     844                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     845                                                "seamark:buoy_lateral:shape", "pillar"));
     846                                break;
     847                        case LAT_SPAR:
     848                                super.saveSign("buoy_lateral");
     849                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     850                                                "seamark:buoy_lateral:shape", "spar"));
     851                                break;
     852                        case LAT_BEACON:
     853                                super.saveSign("beacon_lateral");
     854                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     855                                                "seamark:beacon_lateral:shape", "stake"));
     856                                break;
     857                        case LAT_TOWER:
     858                                super.saveSign("beacon_lateral");
     859                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     860                                                "seamark:beacon_lateral:shape", "tower"));
     861                                break;
     862                        case LAT_FLOAT:
     863                                super.saveSign("light_float");
     864                                break;
     865                        default:
     866                        }
     867                        switch (getStyleIndex()) {
     868                        case LAT_CAN:
     869                        case LAT_PILLAR:
     870                        case LAT_SPAR:
     871                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     872                                                "seamark:buoy_lateral:category", "preferred_channel_starboard"));
     873                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     874                                                "seamark:buoy_lateral:colour_pattern", "horizontal stripes"));
     875                                if (getRegion() != SeaMark.IALA_B) {
     876                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     877                                                        "seamark:buoy_lateral:colour", "green;red;green"));
     878                                        colour = "green";
     879                                } else {
     880                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     881                                                        "seamark:buoy_lateral:colour", "red;green;red"));
     882                                        colour = "red";
     883                                }
     884                                break;
     885                        case LAT_BEACON:
     886                        case LAT_TOWER:
     887                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     888                                                "seamark:beacon_lateral:category", "preferred_channel_starboard"));
     889                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     890                                                "seamark:beacon_lateral:colour_pattern", "horizontal stripes"));
     891                                if (getRegion() != SeaMark.IALA_B) {
     892                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     893                                                        "seamark:beacon_lateral:colour", "green;red;green"));
     894                                        colour = "green";
     895                                } else {
     896                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     897                                                        "seamark:beacon_lateral:colour", "red;green;red"));
     898                                        colour = "red";
     899                                }
     900                                break;
     901                        case LAT_FLOAT:
     902                                Main.main.undoRedo.add(new ChangePropertyCommand(node,
     903                                                "seamark:light_float:colour_pattern", "horizontal stripes"));
     904                                if (getRegion() != SeaMark.IALA_B) {
     905                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     906                                                        "seamark:light_float:colour", "green;red;green"));
     907                                        colour = "green";
     908                                } else {
     909                                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     910                                                        "seamark:light_float:colour", "red;green;red"));
     911                                        colour = "red";
     912                                }
     913                                break;
     914                        }
     915                        shape = "cone, point up";
     916                        break;
     917
     918                default:
     919                }
     920
     921                saveTopMarkData(shape, colour);
     922                saveLightData(colour);
     923
     924                Main.pref.put("tomsplugin.IALA", getRegion() ? "B" : "A");
     925        }
     926
     927        public void setLightColour() {
     928                if (getRegion() == IALA_A
     929                                && (getBuoyIndex() == PORT_HAND || getBuoyIndex() == PREF_PORT_HAND)) {
     930                        super.setLightColour("R");
     931                } else {
     932                        super.setLightColour("G");
     933                }
     934        }
     935
     936        public void setLightColour(String str) {
     937                int cat = getBuoyIndex();
     938
     939                if (str == null) {
     940                        return;
     941                }
     942
     943                switch (cat) {
     944                case PORT_HAND:
     945                case PREF_PORT_HAND:
     946                        if (getRegion() == IALA_A) {
     947                                if (str.equals("red")) {
     948                                        setFired(true);
     949                                        super.setLightColour("R");
     950                                } else {
     951                                        super.setLightColour("");
     952                                }
     953                        } else {
     954                                if (str.equals("green")) {
     955                                        setFired(true);
     956                                        super.setLightColour("G");
     957                                } else {
     958                                        super.setLightColour("");
     959                                }
     960                        }
     961                        break;
     962
     963                case STARBOARD_HAND:
     964                case PREF_STARBOARD_HAND:
     965                        if (getRegion() == IALA_A) {
     966                                if (str.equals("green")) {
     967                                        setFired(true);
     968                                        super.setLightColour("G");
     969                                } else {
     970                                        super.setLightColour("");
     971                                }
     972                        } else {
     973                                if (str.equals("red")) {
     974                                        setFired(true);
     975                                        super.setLightColour("R");
     976                                } else {
     977                                        super.setLightColour("");
     978                                }
     979                        }
     980                        break;
     981
     982                default:
     983                }
     984
     985        }
     986
    929987}
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoySaw.java

    r22692 r22722  
    1616
    1717public class BuoySaw extends Buoy {
    18         public BuoySaw(SmpDialogAction dia, int type) {
     18        public BuoySaw(SmpDialogAction dia,  Node node) {
    1919                super(dia);
     20
     21                String str;
     22                Map<String, String> keys;
     23                keys = node.getKeys();
     24                setNode(node);
    2025
    2126                dlg.cbM01StyleOfMark.removeAllItems();
     
    4045                setColour(SeaMark.RED_WHITE);
    4146                setLightColour("W");
    42                 setBuoyIndex(type);
    43 
    44                 paintSign();
    45         }
    46 
    47         public void paintSign() {
    48                 super.paintSign();
    49 
    50                 dlg.sM01StatusBar.setText(getErrMsg());
    51 
    52                 dlg.tfM01Name.setEnabled(true);
    53                 dlg.tfM01Name.setText(getName());
    54                 dlg.cM01Fired.setEnabled(true);
    55                 dlg.cM01TopMark.setEnabled(true);
    56 
    57                 String image = "/images/Safe_Water";
    58 
    59                 switch (getStyleIndex()) {
    60                 case SAFE_PILLAR:
    61                         image += "_Pillar";
    62                         break;
    63                 case SAFE_SPAR:
    64                         image += "_Spar";
    65                         break;
    66                 case SAFE_SPHERE:
    67                         image += "_Sphere";
    68                         break;
    69                 case SAFE_BEACON:
    70                         image += "_Beacon";
    71                         break;
    72                 case SAFE_FLOAT:
    73                         image += "_Float";
    74                         break;
    75                 default:
    76                 }
    77 
    78                 if (image != "/images/Safe_Water") {
    79 
    80                         if (hasTopMark())
    81                                 image += "_Sphere";
    82 
    83                         if (isFired()) {
    84                                 image += "_Lit";
    85                                 if (getLightChar() != "") {
    86                                         String c;
    87 
    88                                         c = getLightChar();
    89 
    90                                         dlg.cbM01Kennung.setSelectedItem(c);
    91                                         if (dlg.cbM01Kennung.getSelectedItem().equals("Not set"))
    92                                                 c = "";
    93                                 }
    94                         }
    95                         image += ".png";
    96 
    97                         dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
    98                 } else
    99                         dlg.lM01Icon01.setIcon(null);
    100         }
    101 
    102         public void saveSign() {
    103                 Node node = getNode();
    104 
    105                 if (node == null) {
    106                         return;
    107                 }
    108 
    109                 switch (getStyleIndex()) {
    110                 case SAFE_PILLAR:
    111                         super.saveSign("buoy_safe_water");
    112                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    113                                         "seamark:buoy_safe_water:shape", "pillar"));
    114                         break;
    115                 case SAFE_SPAR:
    116                         super.saveSign("buoy_safe_water");
    117                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    118                                         "seamark:buoy_safe_water:shape", "spar"));
    119                         break;
    120                 case SAFE_SPHERE:
    121                         super.saveSign("buoy_safe_water");
    122                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    123                                         "seamark:buoy_safe_water:shape", "sphere"));
    124                         break;
    125                 case SAFE_BEACON:
    126                         super.saveSign("beacon_safe_water");
    127                         break;
    128                 case SAFE_FLOAT:
    129                         super.saveSign("light_float");
    130                         break;
    131                 default:
    132                 }
    133 
    134                 switch (getStyleIndex()) {
    135                 case SAFE_PILLAR:
    136                 case SAFE_SPAR:
    137                 case SAFE_SPHERE:
    138                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    139                                         "seamark:buoy_safe_water:colour_pattern", "vertical stripes"));
    140                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    141                                         "seamark:buoy_safe_water:colour", "red;white"));
    142                         break;
    143                 case SAFE_BEACON:
    144                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    145                                         "seamark:beacon_safe_water:colour_pattern", "vertical stripes"));
    146                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    147                                         "seamark:beacon_safe_water:colour", "red;white"));
    148                         break;
    149                 case SAFE_FLOAT:
    150                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    151                                         "seamark:light_float:colour_pattern", "vertical stripes"));
    152                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    153                                         "seamark:light_float:colour", "red;white"));
    154                         break;
    155                 default:
    156                 }
    157 
    158                 saveTopMarkData("spherical", "red");
    159 
    160                 saveLightData("white");
    161 
    162         }
    163 
    164         public boolean parseTopMark(Node node) {
    165                 if (node == null) {
    166                         return false;
    167                 }
    168 
    169                 String str;
    170                 boolean ret = true;
    171                 Map<String, String> keys;
    172 
    173                 setTopMark(false);
    174 
    175                 keys = node.getKeys();
    176                 if (keys.containsKey("seamark:topmark:shape")) {
    177                         str = keys.get("seamark:topmark:shape");
    178 
    179                         if (str.compareTo("spherical") == 0 || str.compareTo("sphere") == 0) {
    180                                 setTopMark(true);
    181 
    182                         } else {
    183                                 setErrMsg("Parse-Error: Unknown topmark");
    184                                 ret = false;
    185                         }
    186                 }
    187 
    188                 return ret;
    189         }
    190 
    191         public boolean parseLight(Node node) {
    192                 String str;
    193                 boolean ret = true;
    194                 Map<String, String> keys;
    195 
    196                 setFired(false);
    197 
    198                 keys = node.getKeys();
     47                setBuoyIndex(SAFE_WATER);
     48
     49                if (keys.containsKey("seamark:buoy_safe_water:shape")) {
     50                        str = keys.get("seamark:buoy_safe_water:shape");
     51
     52                        if (str.equals("pillar"))
     53                                setStyleIndex(SAFE_PILLAR);
     54                        else if (str.equals("spar"))
     55                                setStyleIndex(SAFE_SPAR);
     56                        else if (str.equals("sphere"))
     57                                setStyleIndex(SAFE_SPHERE);
     58                } else if ((keys.containsKey("seamark:type"))
     59                                && (keys.get("seamark:type").equals("light_float"))) {
     60                        setStyleIndex(SAFE_FLOAT);
     61                } else if ((keys.containsKey("seamark:type"))
     62                                && (keys.get("seamark:type").equals("beacon_safe_water"))) {
     63                        setStyleIndex(SAFE_BEACON);
     64                }
     65
    19966                if (keys.containsKey("seamark:light:colour")) {
    20067                        str = keys.get("seamark:light:colour");
     
    20976                        }
    21077
    211                         if (str.compareTo("white") == 0) {
     78                        if (str.equals("white")) {
    21279                                setFired(true);
    21380                                setLightColour("W");
    214 
    215                         } else {
    216                                 if (getErrMsg() == null)
    217                                         setErrMsg("Parse-Error: Licht falsch");
    218                                 else
    219                                         setErrMsg(getErrMsg() + " / Licht falsch");
    220 
    221                                 ret = false;
    222                         }
    223 
    224                 }
    225 
    226                 return ret;
     81                        }
     82                }
     83
     84                if (keys.containsKey("seamark:topmark:shape")) {
     85                        str = keys.get("seamark:topmark:shape");
     86
     87                        if (str.equals("spherical") || str.equals("sphere")) {
     88                                setTopMark(true);
     89                        }
     90                }
     91
     92                paintSign();
     93        }
     94
     95        public void paintSign() {
     96                super.paintSign();
     97
     98                dlg.sM01StatusBar.setText(getErrMsg());
     99
     100                dlg.tfM01Name.setEnabled(true);
     101                dlg.tfM01Name.setText(getName());
     102                dlg.cM01Fired.setEnabled(true);
     103                dlg.cM01TopMark.setEnabled(true);
     104
     105                String image = "/images/Safe_Water";
     106
     107                switch (getStyleIndex()) {
     108                case SAFE_PILLAR:
     109                        image += "_Pillar";
     110                        break;
     111                case SAFE_SPAR:
     112                        image += "_Spar";
     113                        break;
     114                case SAFE_SPHERE:
     115                        image += "_Sphere";
     116                        break;
     117                case SAFE_BEACON:
     118                        image += "_Beacon";
     119                        break;
     120                case SAFE_FLOAT:
     121                        image += "_Float";
     122                        break;
     123                default:
     124                }
     125
     126                if (!image.equals("/images/Safe_Water")) {
     127
     128                        if (hasTopMark())
     129                                image += "_Sphere";
     130
     131                        if (isFired()) {
     132                                image += "_Lit";
     133                                if (getLightChar() != "") {
     134                                        String c;
     135
     136                                        c = getLightChar();
     137
     138                                        dlg.cbM01Kennung.setSelectedItem(c);
     139                                        if (dlg.cbM01Kennung.getSelectedItem().equals("Not set"))
     140                                                c = "";
     141                                }
     142                        }
     143                        image += ".png";
     144
     145                        dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
     146                } else
     147                        dlg.lM01Icon01.setIcon(null);
     148        }
     149
     150        public void saveSign() {
     151                Node node = getNode();
     152
     153                if (node == null) {
     154                        return;
     155                }
     156
     157                switch (getStyleIndex()) {
     158                case SAFE_PILLAR:
     159                        super.saveSign("buoy_safe_water");
     160                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     161                                        "seamark:buoy_safe_water:shape", "pillar"));
     162                        break;
     163                case SAFE_SPAR:
     164                        super.saveSign("buoy_safe_water");
     165                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     166                                        "seamark:buoy_safe_water:shape", "spar"));
     167                        break;
     168                case SAFE_SPHERE:
     169                        super.saveSign("buoy_safe_water");
     170                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     171                                        "seamark:buoy_safe_water:shape", "sphere"));
     172                        break;
     173                case SAFE_BEACON:
     174                        super.saveSign("beacon_safe_water");
     175                        break;
     176                case SAFE_FLOAT:
     177                        super.saveSign("light_float");
     178                        break;
     179                default:
     180                }
     181
     182                switch (getStyleIndex()) {
     183                case SAFE_PILLAR:
     184                case SAFE_SPAR:
     185                case SAFE_SPHERE:
     186                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     187                                        "seamark:buoy_safe_water:colour_pattern", "vertical stripes"));
     188                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     189                                        "seamark:buoy_safe_water:colour", "red;white"));
     190                        break;
     191                case SAFE_BEACON:
     192                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     193                                        "seamark:beacon_safe_water:colour_pattern", "vertical stripes"));
     194                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     195                                        "seamark:beacon_safe_water:colour", "red;white"));
     196                        break;
     197                case SAFE_FLOAT:
     198                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     199                                        "seamark:light_float:colour_pattern", "vertical stripes"));
     200                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     201                                        "seamark:light_float:colour", "red;white"));
     202                        break;
     203                default:
     204                }
     205
     206                saveTopMarkData("spherical", "red");
     207
     208                saveLightData("white");
     209
    227210        }
    228211
     
    231214        }
    232215
    233         public boolean parseShape(Node node) {
    234                 String str;
    235                 boolean ret = true;
    236                 Map<String, String> keys;
    237 
    238                 keys = node.getKeys();
    239 
    240                 if (keys.containsKey("seamark:buoy_safe_water:shape")) {
    241                         str = keys.get("seamark:buoy_safe_water:shape");
    242 
    243                         if (str.compareTo("pillar") == 0)
    244                                 setStyleIndex(SAFE_PILLAR);
    245                         else if (str.compareTo("spar") == 0)
    246                                 setStyleIndex(SAFE_SPAR);
    247                         else if (str.compareTo("sphere") == 0)
    248                                 setStyleIndex(SAFE_SPHERE);
    249                         else
    250                                 ret = false;
    251                 } else if ((keys.containsKey("seamark:type") == true)
    252                                 && (keys.get("seamark:type").equals("light_float"))) {
    253                         setStyleIndex(SAFE_FLOAT);
    254                 } else if ((keys.containsKey("seamark:type") == true)
    255                                 && (keys.get("seamark:type").equals("beacon_safe_water"))) {
    256                         setStyleIndex(SAFE_BEACON);
    257                 }
    258 
    259                 return ret;
    260         }
    261 
    262216}
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoySpec.java

    r22692 r22722  
    1616
    1717public class BuoySpec extends Buoy {
    18         public BuoySpec(SmpDialogAction dia, int type) {
     18        public BuoySpec(SmpDialogAction dia,  Node node) {
    1919                super(dia);
     20
     21                String str;
     22                Map<String, String> keys;
     23                keys = node.getKeys();
     24                setNode(node);
    2025
    2126                dlg.cbM01StyleOfMark.removeAllItems();
     
    4752                setColour(SeaMark.YELLOW);
    4853                setLightColour("W");
    49                 setBuoyIndex(type);
    50 
    51                 paintSign();
    52         }
    53 
    54         public void paintSign() {
    55                 super.paintSign();
    56 
    57                 dlg.sM01StatusBar.setText(getErrMsg());
    58 
    59                 dlg.tfM01Name.setEnabled(true);
    60                 dlg.tfM01Name.setText(getName());
    61                 dlg.cM01Fired.setEnabled(true);
    62                 dlg.cM01TopMark.setEnabled(true);
    63 
    64                 String image = "/images/Special_Purpose";
    65 
    66                 switch (getStyleIndex()) {
    67                 case SPEC_PILLAR:
    68                         image += "_Pillar";
    69                         break;
    70                 case SPEC_SPAR:
    71                         image += "_Spar";
    72                         break;
    73                 case SPEC_SPHERE:
    74                         image += "_Sphere";
    75                         break;
    76                 case SPEC_BARREL:
    77                         image += "_Barrel";
    78                         break;
    79                 case SPEC_FLOAT:
    80                         image += "_Float";
    81                         break;
    82                 case SPEC_BEACON:
    83                         image += "_Beacon";
    84                         break;
    85                 default:
    86                 }
    87 
    88                 if (image != "/images/Special_Purpose") {
    89 
    90                         if (hasTopMark())
    91                                 image += "_CrossY";
    92 
    93                         if (isFired()) {
    94                                 image += "_Lit";
    95                                 if (getLightChar() != "") {
    96                                         String c;
    97 
    98                                         c = getLightChar();
    99 
    100                                         dlg.cbM01Kennung.setSelectedItem(c);
    101                                         if (dlg.cbM01Kennung.getSelectedItem().equals("Not set"))
    102                                                 c = "";
    103                                 }
    104                         }
    105                         image += ".png";
    106 
    107                         dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
    108                 } else
    109                         dlg.lM01Icon01.setIcon(null);
    110         }
    111 
    112         public void saveSign() {
    113                 Node node = getNode();
    114 
    115                 if (node == null) {
    116                         return;
    117                 }
    118 
    119                 switch (getStyleIndex()) {
    120                 case SPEC_PILLAR:
    121                         super.saveSign("buoy_special_purpose");
    122                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    123                                         "seamark:buoy_special_purpose:shape", "pillar"));
    124                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    125                                         "seamark:buoy_special_purpose:colour", "yellow"));
    126                         break;
    127                 case SPEC_SPAR:
    128                         super.saveSign("buoy_special_purpose");
    129                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    130                                         "seamark:buoy_special_purpose:shape", "spar"));
    131                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    132                                         "seamark:buoy_special_purpose:colour", "yellow"));
    133                         break;
    134                 case SPEC_SPHERE:
    135                         super.saveSign("buoy_special_purpose");
    136                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    137                                         "seamark:buoy_special_purpose:shape", "sphere"));
    138                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    139                                         "seamark:buoy_special_purpose:colour", "yellow"));
    140                         break;
    141                 case SPEC_BARREL:
    142                         super.saveSign("buoy_special_purpose");
    143                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    144                                         "seamark:buoy_special_purpose:shape", "barrel"));
    145                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    146                                         "seamark:buoy_special_purpose:colour", "yellow"));
    147                         break;
    148                 case SPEC_FLOAT:
    149                         super.saveSign("light_float");
    150                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    151                                         "seamark:light_float:colour", "yellow"));
    152                         break;
    153                 case SPEC_BEACON:
    154                         super.saveSign("beacon_special_purpose");
    155                         Main.main.undoRedo.add(new ChangePropertyCommand(node,
    156                                         "seamark:beacon_special_purpose:colour", "yellow"));
    157                         break;
    158                 default:
    159                 }
    160 
    161                 saveTopMarkData("x-shape", "yellow");
    162 
    163                 saveLightData("white");
    164 
    165         }
    166 
    167         public boolean parseTopMark(Node node) {
    168                 if (node == null) {
    169                         return false;
    170                 }
    171 
    172                 String str;
    173                 boolean ret = true;
    174                 Map<String, String> keys;
    175 
    176                 setTopMark(false);
    177 
    178                 keys = node.getKeys();
    179                 if (keys.containsKey("seamark:topmark:shape")) {
    180                         str = keys.get("seamark:topmark:shape");
    181 
    182                         if (str.equals("x-shape")) {
    183                                 setTopMark(true);
    184 
    185                         } else {
    186                                 setErrMsg("Parse-Error: Topmark unbekannt");
    187                                 ret = false;
    188                         }
    189                 }
    190 
    191                 return ret;
    192         }
    193 
    194         public boolean parseLight(Node node) {
    195                 String str;
    196                 boolean ret = true;
    197                 Map<String, String> keys;
    198 
    199                 setFired(false);
    200 
    201                 keys = node.getKeys();
    202                 if (keys.containsKey("seamark:light:colour")) {
    203                         str = keys.get("seamark:light:colour");
    204 
    205                         if (keys.containsKey("seamark:light:character")) {
    206                                 setLightGroup(keys);
    207 
    208                                 String c = keys.get("seamark:light:character");
    209                                 if (getLightGroup() != "")
    210                                         c = c + "(" + getLightGroup() + ")";
    211 
    212                                 setLightChar(c);
    213                                 setLightPeriod(keys);
    214                         }
    215 
    216                         if (str.equals("white")) {
    217                                 setFired(true);
    218                                 setLightColour("W");
    219 
    220                         } else {
    221                                 if (getErrMsg() == null)
    222                                         setErrMsg("Parse-Error: Invalid light");
    223                                 else
    224                                         setErrMsg(getErrMsg() + " / Invalid light");
    225 
    226                                 ret = false;
    227                         }
    228 
    229                 }
    230 
    231                 return ret;
    232         }
    233 
    234         public void setLightColour() {
    235                 super.setLightColour("W");
    236         }
    237 
    238         public boolean parseShape(Node node) {
    239                 String str;
    240                 boolean ret = true;
    241                 Map<String, String> keys;
    242 
    243                 keys = node.getKeys();
     54                setBuoyIndex(SPECIAL_PURPOSE);
    24455
    24556                if (keys.containsKey("seamark:buoy_special_purpose:shape")) {
     
    25465                        else if (str.equals("barrel"))
    25566                                setStyleIndex(SPEC_BARREL);
    256                         else
    257                                 ret = false;
    25867                }
    25968
     
    26574                        setStyleIndex(SPEC_FLOAT);
    26675
    267                 return ret;
     76                keys = node.getKeys();
     77                if (keys.containsKey("seamark:topmark:shape")) {
     78                        str = keys.get("seamark:topmark:shape");
     79
     80                        if (str.equals("x-shape")) {
     81                                setTopMark(true);
     82                        }
     83                }
     84
     85                if (keys.containsKey("seamark:light:colour")) {
     86                        str = keys.get("seamark:light:colour");
     87
     88                        if (keys.containsKey("seamark:light:character")) {
     89                                setLightGroup(keys);
     90
     91                                String c = keys.get("seamark:light:character");
     92                                if (getLightGroup() != "")
     93                                        c = c + "(" + getLightGroup() + ")";
     94
     95                                setLightChar(c);
     96                                setLightPeriod(keys);
     97                        }
     98
     99                        if (str.equals("white")) {
     100                                setFired(true);
     101                                setLightColour("W");
     102                        }
     103                }
     104
     105                paintSign();
     106        }
     107
     108        public void paintSign() {
     109                super.paintSign();
     110
     111                dlg.sM01StatusBar.setText(getErrMsg());
     112
     113                dlg.tfM01Name.setEnabled(true);
     114                dlg.tfM01Name.setText(getName());
     115                dlg.cM01Fired.setEnabled(true);
     116                dlg.cM01TopMark.setEnabled(true);
     117
     118                String image = "/images/Special_Purpose";
     119
     120                switch (getStyleIndex()) {
     121                case SPEC_PILLAR:
     122                        image += "_Pillar";
     123                        break;
     124                case SPEC_SPAR:
     125                        image += "_Spar";
     126                        break;
     127                case SPEC_SPHERE:
     128                        image += "_Sphere";
     129                        break;
     130                case SPEC_BARREL:
     131                        image += "_Barrel";
     132                        break;
     133                case SPEC_FLOAT:
     134                        image += "_Float";
     135                        break;
     136                case SPEC_BEACON:
     137                        image += "_Beacon";
     138                        break;
     139                default:
     140                }
     141
     142                if (!image.equals("/images/Special_Purpose")) {
     143
     144                        if (hasTopMark())
     145                                image += "_CrossY";
     146
     147                        if (isFired()) {
     148                                image += "_Lit";
     149                                if (getLightChar() != "") {
     150                                        String c;
     151
     152                                        c = getLightChar();
     153
     154                                        dlg.cbM01Kennung.setSelectedItem(c);
     155                                        if (dlg.cbM01Kennung.getSelectedItem().equals("Not set"))
     156                                                c = "";
     157                                }
     158                        }
     159                        image += ".png";
     160
     161                        dlg.lM01Icon01.setIcon(new ImageIcon(getClass().getResource(image)));
     162                } else
     163                        dlg.lM01Icon01.setIcon(null);
     164        }
     165
     166        public void saveSign() {
     167                Node node = getNode();
     168
     169                if (node == null) {
     170                        return;
     171                }
     172
     173                switch (getStyleIndex()) {
     174                case SPEC_PILLAR:
     175                        super.saveSign("buoy_special_purpose");
     176                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     177                                        "seamark:buoy_special_purpose:shape", "pillar"));
     178                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     179                                        "seamark:buoy_special_purpose:colour", "yellow"));
     180                        break;
     181                case SPEC_SPAR:
     182                        super.saveSign("buoy_special_purpose");
     183                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     184                                        "seamark:buoy_special_purpose:shape", "spar"));
     185                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     186                                        "seamark:buoy_special_purpose:colour", "yellow"));
     187                        break;
     188                case SPEC_SPHERE:
     189                        super.saveSign("buoy_special_purpose");
     190                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     191                                        "seamark:buoy_special_purpose:shape", "sphere"));
     192                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     193                                        "seamark:buoy_special_purpose:colour", "yellow"));
     194                        break;
     195                case SPEC_BARREL:
     196                        super.saveSign("buoy_special_purpose");
     197                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     198                                        "seamark:buoy_special_purpose:shape", "barrel"));
     199                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     200                                        "seamark:buoy_special_purpose:colour", "yellow"));
     201                        break;
     202                case SPEC_FLOAT:
     203                        super.saveSign("light_float");
     204                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     205                                        "seamark:light_float:colour", "yellow"));
     206                        break;
     207                case SPEC_BEACON:
     208                        super.saveSign("beacon_special_purpose");
     209                        Main.main.undoRedo.add(new ChangePropertyCommand(node,
     210                                        "seamark:beacon_special_purpose:colour", "yellow"));
     211                        break;
     212                default:
     213                }
     214
     215                saveTopMarkData("x-shape", "yellow");
     216
     217                saveLightData("white");
     218
     219        }
     220
     221        public void setLightColour() {
     222                super.setLightColour("W");
    268223        }
    269224
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyUkn.java

    r22692 r22722  
    5959        }
    6060
    61         public boolean parseTopMark(Node node) {
    62                 return false;
    63         }
    64 
    65         public boolean parseLight(Node node) {
    66                 return false;
    67         }
    68 
    6961        public void saveSign() {
    7062        }
Note: See TracChangeset for help on using the changeset viewer.