Ignore:
Timestamp:
2010-09-08T13:52:26+02:00 (14 years ago)
Author:
malcolmh
Message:

saves

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

Legend:

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

    r23072 r23073  
    10161016                        cbM01Racon.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$
    10171017                        cbM01Racon.removeAllItems();
    1018                         cbM01Racon.addItem("Not Set");
     1018                        cbM01Racon.addItem("Any");
    10191019                        cbM01Racon.addItem("Racon");
    10201020                        cbM01Racon.addItem("Ramark");
     
    10661066                        cbM01Fog.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$
    10671067                        cbM01Fog.removeAllItems();
    1068                         cbM01Fog.addItem("Not Set");
     1068                        cbM01Fog.addItem("Any");
    10691069                        cbM01Fog.addItem("Horn");
    10701070                        cbM01Fog.addItem("Siren");
     
    10771077                                public void actionPerformed(ActionEvent e) {
    10781078                                        if (cbM01Fog.getSelectedIndex() > 0)
    1079                                                 buoy.setFogSound((String) cbM01Fog.getSelectedItem());
     1079                                                buoy.setFogSound(cbM01Fog.getSelectedIndex());
    10801080                                        else
    1081                                                 buoy.setFogSound("");
     1081                                                buoy.setFogSound(0);
    10821082                                        buoy.paintSign();
    10831083                                }
  • applications/editors/josm/plugins/toms/src/toms/seamarks/SeaMark.java

    r23058 r23073  
    107107       
    108108        /**
    109          * Radar Beacons - correspond to Ratyp
     109         * Radar Beacons - correspond to Ratyp Index
    110110         */
    111111       
     
    116116
    117117        /**
     118         * Fog Signals - correspond to FogSound Index
     119         */
     120       
     121        public final static int UNKNOWN_FOG = 0;
     122        public final static int FOG_HORN = 1;
     123        public final static int FOG_SIREN = 2;
     124        public final static int FOG_DIA = 3;
     125        public final static int FOG_BELL = 4;
     126        public final static int FOG_WHIS = 5;
     127        public final static int FOG_GONG = 6;
     128        public final static int FOG_EXPLOS = 7;
     129
     130        /**
    118131         * Variables
    119132         */
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/Buoy.java

    r23072 r23073  
    107107        }
    108108
    109         private String FogSound = "";
    110 
    111         public String getFogSound() {
     109        private int FogSound = 0;
     110
     111        public int getFogSound() {
    112112                return FogSound;
    113113        }
    114114
    115         public void setFogSound(String fogSound) {
     115        public void setFogSound(int fogSound) {
    116116                FogSound = fogSound;
    117117        }
     
    124124
    125125        public void setFogGroup(String fogGroup) {
    126                 FogSound = fogGroup;
     126                FogGroup = fogGroup;
    127127        }
    128128
     
    290290        protected Buoy(SmpDialogAction dia) {
    291291                dlg = dia;
     292        }
     293
     294        public boolean isValid() {
     295                return false;
    292296        }
    293297
     
    305309                dlg.rbM01RegionB.setSelected(getRegion());
    306310
    307                 dlg.cM01TopMark.setSelected(hasTopMark());
    308                 dlg.cM01Fired.setSelected(isFired());
    309 
    310                 dlg.tfM01RepeatTime.setText(LightPeriod);
    311 
    312                 dlg.tfM01Name.setText(getName());
    313 
    314                 if (hasRadar()) {
    315                         dlg.lM03Icon.setIcon(new ImageIcon(getClass().getResource(
    316                                         "/images/Radar_Reflector.png")));
    317                 }
    318 
    319                 if (hasRacon()) {
    320                         dlg.lM04Icon.setIcon(new ImageIcon(getClass().getResource(
    321                                         "/images/Radar_Station.png")));
    322                         dlg.cbM01Racon.setVisible(true);
    323                         if (getRaType() == RATYP_RACON) {
    324                                 dlg.lM01Racon.setVisible(true);
    325                                 dlg.tfM01Racon.setVisible(true);
    326                                 dlg.tfM01Racon.setEnabled(true);
     311                if (isValid()) {
     312                        dlg.bM01Save.setEnabled(true);
     313
     314                        dlg.cM01TopMark.setSelected(hasTopMark());
     315                        dlg.cM01Fired.setSelected(isFired());
     316
     317                        dlg.tfM01RepeatTime.setText(LightPeriod);
     318
     319                        dlg.tfM01Name.setText(getName());
     320
     321                        if (hasRadar()) {
     322                                dlg.lM03Icon.setIcon(new ImageIcon(getClass().getResource(
     323                                                "/images/Radar_Reflector.png")));
     324                        }
     325
     326                        if (hasRacon()) {
     327                                dlg.lM04Icon.setIcon(new ImageIcon(getClass().getResource(
     328                                                "/images/Radar_Station.png")));
     329                                dlg.cbM01Racon.setVisible(true);
     330                                if (getRaType() == RATYP_RACON) {
     331                                        dlg.lM01Racon.setVisible(true);
     332                                        dlg.tfM01Racon.setVisible(true);
     333                                        dlg.tfM01Racon.setEnabled(true);
     334                                } else {
     335                                        dlg.lM01Racon.setVisible(false);
     336                                        dlg.tfM01Racon.setVisible(false);
     337                                }
    327338                        } else {
     339                                dlg.cbM01Racon.setVisible(false);
    328340                                dlg.lM01Racon.setVisible(false);
    329341                                dlg.tfM01Racon.setVisible(false);
    330342                        }
    331                 } else {
    332                         dlg.cbM01Racon.setVisible(false);
    333                         dlg.lM01Racon.setVisible(false);
    334                         dlg.tfM01Racon.setVisible(false);
    335                 }
    336 
    337                 if (hasFog()) {
    338                         dlg.lM05Icon.setIcon(new ImageIcon(getClass().getResource(
    339                                         "/images/Fog_Signal.png")));
    340                         dlg.cbM01Fog.setVisible(true);
    341                         if (getFogSound().equals("")) {
     343
     344                        if (hasFog()) {
     345                                dlg.lM05Icon.setIcon(new ImageIcon(getClass().getResource(
     346                                                "/images/Fog_Signal.png")));
     347                                dlg.cbM01Fog.setVisible(true);
     348                                if (getFogSound() == 0) {
     349                                        dlg.lM01FogGroup.setVisible(false);
     350                                        dlg.tfM01FogGroup.setVisible(false);
     351                                        dlg.lM01FogPeriod.setVisible(false);
     352                                        dlg.tfM01FogPeriod.setVisible(false);
     353                                } else {
     354                                        dlg.lM01FogGroup.setVisible(true);
     355                                        dlg.tfM01FogGroup.setVisible(true);
     356                                        dlg.lM01FogPeriod.setVisible(true);
     357                                        dlg.tfM01FogPeriod.setVisible(true);
     358                                }
     359                        } else {
     360                                dlg.cbM01Fog.setVisible(false);
    342361                                dlg.lM01FogGroup.setVisible(false);
    343362                                dlg.tfM01FogGroup.setVisible(false);
    344363                                dlg.lM01FogPeriod.setVisible(false);
    345364                                dlg.tfM01FogPeriod.setVisible(false);
     365                        }
     366
     367                        if (isFired()) {
     368                                String lp, c;
     369                                String tmp = null;
     370                                int i1;
     371
     372                                String col = getLightColour();
     373                                if (col.equals("W"))
     374                                        dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource(
     375                                                        "/images/Light_White_120.png")));
     376                                else if (col.equals("R"))
     377                                        dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource(
     378                                                        "/images/Light_Red_120.png")));
     379                                else if (col.equals("G"))
     380                                        dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource(
     381                                                        "/images/Light_Green_120.png")));
     382                                else
     383                                        dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource(
     384                                                        "/images/Light_Magenta_120.png")));
     385
     386                                dlg.cbM01Kennung.setEnabled(true);
     387
     388                                c = getLightChar();
     389                                if (dlg.cbM01Kennung.getSelectedIndex() == 0)
     390                                        dlg.tfM01RepeatTime.setEnabled(false);
     391                                else
     392                                        dlg.tfM01RepeatTime.setEnabled(true);
     393
     394                                if (c.contains("+")) {
     395                                        i1 = c.indexOf("+");
     396                                        tmp = c.substring(i1, c.length());
     397                                        c = c.substring(0, i1);
     398                                }
     399
     400                                if (getLightGroup() != "")
     401                                        c = c + "(" + getLightGroup() + ")";
     402                                if (tmp != null)
     403                                        c = c + tmp;
     404
     405                                c = c + " " + getLightColour();
     406                                lp = getLightPeriod();
     407                                if (lp != "" && lp != " ")
     408                                        c = c + " " + lp + "s";
     409                                dlg.lM01FireMark.setText(c);
    346410                        } else {
    347                                 dlg.lM01FogGroup.setVisible(true);
    348                                 dlg.tfM01FogGroup.setVisible(true);
    349                                 dlg.lM01FogPeriod.setVisible(true);
    350                                 dlg.tfM01FogPeriod.setVisible(true);
     411                                dlg.tfM01RepeatTime.setEnabled(false);
     412                                dlg.cbM01Kennung.setEnabled(false);
     413                                dlg.lM01FireMark.setText("");
    351414                        }
    352415                } else {
     416                        dlg.bM01Save.setEnabled(false);
     417                        dlg.cM01TopMark.setVisible(false);
     418                        dlg.cbM01TopMark.setVisible(false);
     419                        dlg.cM01Radar.setVisible(false);
     420                        dlg.cM01Racon.setVisible(false);
     421                        dlg.cbM01Racon.setVisible(false);
     422                        dlg.tfM01Racon.setVisible(false);
     423                        dlg.lM01Racon.setVisible(false);
     424                        dlg.cM01Fog.setVisible(false);
    353425                        dlg.cbM01Fog.setVisible(false);
     426                        dlg.tfM01FogGroup.setVisible(false);
    354427                        dlg.lM01FogGroup.setVisible(false);
    355                         dlg.tfM01FogGroup.setVisible(false);
     428                        dlg.tfM01FogPeriod.setVisible(false);
    356429                        dlg.lM01FogPeriod.setVisible(false);
    357                         dlg.tfM01FogPeriod.setVisible(false);
    358                 }
    359 
    360                 if (isFired()) {
    361                         String lp, c;
    362                         String tmp = null;
    363                         int i1;
    364 
    365                         String col = getLightColour();
    366                         if (col.equals("W"))
    367                                 dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource(
    368                                                 "/images/Light_White_120.png")));
    369                         else if (col.equals("R"))
    370                                 dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource(
    371                                                 "/images/Light_Red_120.png")));
    372                         else if (col.equals("G"))
    373                                 dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource(
    374                                                 "/images/Light_Green_120.png")));
    375                         else
    376                                 dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource(
    377                                                 "/images/Light_Magenta_120.png")));
    378 
    379                         dlg.cbM01Kennung.setEnabled(true);
    380 
    381                         c = getLightChar();
    382                         if (dlg.cbM01Kennung.getSelectedIndex() == 0)
    383                                 dlg.tfM01RepeatTime.setEnabled(false);
    384                         else
    385                                 dlg.tfM01RepeatTime.setEnabled(true);
    386 
    387                         if (c.contains("+")) {
    388                                 i1 = c.indexOf("+");
    389                                 tmp = c.substring(i1, c.length());
    390                                 c = c.substring(0, i1);
    391                         }
    392 
    393                         if (getLightGroup() != "")
    394                                 c = c + "(" + getLightGroup() + ")";
    395                         if (tmp != null)
    396                                 c = c + tmp;
    397 
    398                         c = c + " " + getLightColour();
    399                         lp = getLightPeriod();
    400                         if (lp != "" && lp != " ")
    401                                 c = c + " " + lp + "s";
    402                         dlg.lM01FireMark.setText(c);
    403                 } else {
    404                         dlg.tfM01RepeatTime.setEnabled(false);
    405                         dlg.cbM01Kennung.setEnabled(false);
    406                         dlg.lM01FireMark.setText("");
     430                        dlg.cM01Fired.setVisible(false);
     431                        dlg.rbM01Fired1.setVisible(false);
     432                        dlg.rbM01FiredN.setVisible(false);
     433                        dlg.cbM01Kennung.setVisible(false);
     434                        dlg.lM01Kennung.setVisible(false);
     435                        dlg.tfM01Height.setVisible(false);
     436                        dlg.lM01Height.setVisible(false);
     437                        dlg.tfM01Range.setVisible(false);
     438                        dlg.lM01Range.setVisible(false);
     439                        dlg.cbM01Colour.setVisible(false);
     440                        dlg.lM01Colour.setVisible(false);
     441                        dlg.cbM01Sector.setVisible(false);
     442                        dlg.lM01Sector.setVisible(false);
     443                        dlg.tfM01Group.setVisible(false);
     444                        dlg.lM01Group.setVisible(false);
     445                        dlg.tfM01RepeatTime.setVisible(false);
     446                        dlg.lM01RepeatTime.setVisible(false);
     447                        dlg.tfM01Bearing.setVisible(false);
     448                        dlg.lM01Bearing.setVisible(false);
     449                        dlg.tfM02Bearing.setVisible(false);
     450                        dlg.tfM01Radius.setVisible(false);
    407451                }
    408452        }
     
    450494                                                "seamark:light:group", LightGroup));
    451495                }
    452 
    453496        }
    454497
     
    460503                                        "seamark:topmark:colour", colour));
    461504                }
    462 
    463         }
     505        }
     506
     507        protected void saveRadarFogData() {
     508                if (hasRadar()) {
     509                        Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     510                                        "seamark:radar_reflector", "yes"));
     511                }
     512                if (hasRacon()) {
     513                        switch (RaType) {
     514                        case RATYP_RACON:
     515                                Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     516                                                "seamark:radar_transponder:category", "racon"));
     517                                if (!getRaconGroup().equals(""))
     518                                        Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     519                                                        "seamark:radar_transponder:group", getRaconGroup()));
     520                                break;
     521                        case RATYP_RAMARK:
     522                                Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     523                                                "seamark:radar_transponder:category", "ramark"));
     524                                break;
     525                        case RATYP_LEADING:
     526                                Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     527                                                "seamark:radar_transponder:category", "leading"));
     528                                break;
     529                        default:
     530                                Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     531                                                "seamark:radar_transponder", "yes"));
     532                        }
     533                }
     534                if (hasFog()) {
     535                        if (FogSound == 0) {
     536                                Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     537                                                "seamark:fog_signal", "yes"));
     538                        } else {
     539                                switch (FogSound) {
     540                                case FOG_HORN:
     541                                        Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     542                                                        "seamark:fog_signal:category", "horn"));
     543                                        break;
     544                                case FOG_SIREN:
     545                                        Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     546                                                        "seamark:fog_signal:category", "siren"));
     547                                        break;
     548                                case FOG_DIA:
     549                                        Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     550                                                        "seamark:fog_signal:category", "diaphone"));
     551                                        break;
     552                                case FOG_BELL:
     553                                        Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     554                                                        "seamark:fog_signal:category", "bell"));
     555                                        break;
     556                                case FOG_WHIS:
     557                                        Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     558                                                        "seamark:fog_signal:category", "whistle"));
     559                                        break;
     560                                case FOG_GONG:
     561                                        Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     562                                                        "seamark:fog_signal:category", "gong"));
     563                                        break;
     564                                case FOG_EXPLOS:
     565                                        Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     566                                                        "seamark:fog_signal:category", "explosive"));
     567                                        break;
     568                                }
     569                        if (!getFogGroup().equals(""))
     570                                Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     571                                                "seamark:fog_group:group", getFogGroup()));
     572                        if (!getFogPeriod().equals(""))
     573                                Main.main.undoRedo.add(new ChangePropertyCommand(Node,
     574                                                "seamark:fog_period:group", getFogPeriod()));
     575                        }
     576                }
     577        }
     578
     579        public final static int FOG_HORN = 1;
     580        public final static int FOG_SIREN = 2;
     581        public final static int FOG_DIA = 3;
     582        public final static int FOG_BELL = 4;
     583        public final static int FOG_WHIS = 5;
     584        public final static int FOG_GONG = 6;
     585        public final static int FOG_EXPLOS = 7;
    464586
    465587        public void refreshStyles() {
     
    507629                dlg.cM01Fog.setVisible(false);
    508630                dlg.cbM01Fog.setVisible(false);
    509                 setFogSound("");
     631                setFogSound(0);
    510632                dlg.tfM01FogGroup.setText("");
    511633                dlg.tfM01FogGroup.setVisible(false);
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyCard.java

    r23061 r23073  
    185185                }
    186186
     187        }
     188
     189        public boolean isValid() {
     190                return (getBuoyIndex() > 0) && (getStyleIndex() > 0);
    187191        }
    188192
     
    408412                saveTopMarkData(shape, "black");
    409413                saveLightData("white");
    410 
     414                saveRadarFogData();
    411415        }
    412416}
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyIsol.java

    r23061 r23073  
    102102                }
    103103        }
     104       
     105        public boolean isValid() {
     106                return (getBuoyIndex() > 0) && (getStyleIndex() > 0);
     107        }
    104108
    105109        public void paintSign() {
    106110                if (dlg.paintlock)
    107111                        return;
     112               
    108113                super.paintSign();
    109114
    110115                dlg.sM01StatusBar.setText(getErrMsg());
    111116
    112                 if ((getBuoyIndex() > 0) && (getStyleIndex() > 0)) {
     117                if (isValid()) {
    113118                        dlg.tfM01Name.setEnabled(true);
    114119                        dlg.tfM01Name.setText(getName());
    115                         dlg.cM01TopMark.setEnabled(false);
    116120                        dlg.cM01TopMark.setVisible(true);
    117                         dlg.cM01Radar.setEnabled(true);
    118121                        dlg.cM01Radar.setVisible(true);
    119                         dlg.cM01Racon.setEnabled(true);
    120122                        dlg.cM01Racon.setVisible(true);
    121                         dlg.cM01Fog.setEnabled(true);
    122123                        dlg.cM01Fog.setVisible(true);
    123 
    124124                        dlg.cM01Fired.setVisible(true);
    125                         dlg.cM01Fired.setEnabled(true);
    126 
     125                       
    127126                        String image = "/images/Cardinal";
    128127
     
    151150                        } else
    152151                                dlg.lM01Icon.setIcon(null);
     152                } else {
     153                        dlg.tfM01Name.setEnabled(false);
     154                        dlg.tfM01Name.setText("");
     155                        dlg.cM01TopMark.setVisible(false);
     156                        dlg.cM01Radar.setVisible(false);
     157                        dlg.cM01Racon.setVisible(false);
     158                        dlg.cM01Fog.setVisible(false);
     159                        dlg.cM01Fired.setVisible(false);
    153160                }
    154161        }
     
    212219
    213220                saveTopMarkData("2 spheres", "black");
    214 
    215221                saveLightData("white");
     222                saveRadarFogData();
    216223
    217224        }
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyLat.java

    r23066 r23073  
    345345        }
    346346
     347        public boolean isValid() {
     348                return (getBuoyIndex() > 0) && (getStyleIndex() > 0);
     349        }
     350
    347351        public void paintSign() {
    348352                if (dlg.paintlock)
     
    957961                default:
    958962                }
    959 
    960963                saveTopMarkData(shape, colour);
    961964                saveLightData(colour);
     965                saveRadarFogData();
    962966
    963967                Main.pref.put("tomsplugin.IALA", getRegion() ? "B" : "A"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyNota.java

    r23061 r23073  
    4343                setTopMark(false);
    4444                paintSign();
     45        }
     46
     47        public boolean isValid() {
     48                return (getBuoyIndex() > 0);
    4549        }
    4650
     
    106110                default:
    107111                }
    108 
    109112                saveLightData("white");
     113                saveRadarFogData();
    110114        }
    111115
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoySaw.java

    r23061 r23073  
    102102        }
    103103
     104        public boolean isValid() {
     105                return (getBuoyIndex() > 0) && (getStyleIndex() > 0);
     106        }
     107
    104108        public void paintSign() {
    105109                if (dlg.paintlock)
     
    212216                default:
    213217                }
    214 
    215218                saveTopMarkData("spherical", "red");
    216 
    217219                saveLightData("white");
    218 
     220                saveRadarFogData();
    219221        }
    220222
  • applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoySpec.java

    r23061 r23073  
    136136        }
    137137
     138        public boolean isValid() {
     139                return (getBuoyIndex() > 0) && (getStyleIndex() > 0);
     140        }
     141
    138142        public void paintSign() {
    139143                if (dlg.paintlock)
     
    258262                default:
    259263                }
    260 
    261264                saveTopMarkData("x-shape", "yellow");
    262 
    263265                saveLightData("white");
    264 
     266                saveRadarFogData();
    265267        }
    266268
Note: See TracChangeset for help on using the changeset viewer.