probCrater = 0; minRadius = 0; maxRadius = 0; minCraters = 0; maxCraters = 0;
s = choCraters.getSelectedItem(); if(s.equals(NONE)) { probCrater = 0; minRadius = 0; maxRadius = 0; minCraters = 0; maxCraters = 0; } else if (s.equals(LOW)) { probCrater = 25; minRadius = 1; maxRadius = 3; minCraters = 1; maxCraters = 3; } else if (s.equals(MEDIUM)) { probCrater = 50; minRadius = 1; maxRadius = 5; minCraters = 3; maxCraters = 8; } else { probCrater = 75; minRadius = 3; maxRadius = 9; minCraters = 6; maxCraters = 14; }
    private boolean applyValues() {        int boardWidth;        int boardHeight;        int hilliness, range;        int minWaterSpots, maxWaterSpots, minWaterSize, maxWaterSize, probDeep;        int minForestSpots, maxForestSpots, minForestSize, maxForestSize, probHeavy;        int minRoughSpots, maxRoughSpots, minRoughSize, maxRoughSize;        int minSwampSpots, maxSwampSpots, minSwampSize, maxSwampSize;        int probRoad, probRiver, probInvert;        int minRadius, maxRadius, minCraters, maxCraters, probCrater;        int algorithmToUse;        try {            boardWidth = Integer.parseInt(texBoardWidth.getText());            boardHeight = Integer.parseInt(texBoardHeight.getText());        } catch (NumberFormatException ex) {            new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.OnlyIntegersWarn")).show(); //$NON-NLS-1$            return false;        }                if (boardHeight <= 0 || boardHeight <= 0) {            new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.BoardSizeWarn")).show(); //$NON-NLS-1$            return false;        }        if (advanced) {            try {                hilliness = Integer.parseInt(texHilliness.getText());                range = Integer.parseInt(texRange.getText());                probInvert = Integer.parseInt(texProbInvert.getText());                minWaterSpots = Integer.parseInt(texMinWaterSpots.getText());                maxWaterSpots = Integer.parseInt(texMaxWaterSpots.getText());                minWaterSize = Integer.parseInt(texMinWaterSize.getText());                maxWaterSize = Integer.parseInt(texMaxWaterSize.getText());                minForestSpots = Integer.parseInt(texMinForestSpots.getText());                maxForestSpots = Integer.parseInt(texMaxForestSpots.getText());                minForestSize = Integer.parseInt(texMinForestSize.getText());                maxForestSize = Integer.parseInt(texMaxForestSize.getText());                minRoughSpots = Integer.parseInt(texMinRoughSpots.getText());                maxRoughSpots = Integer.parseInt(texMaxRoughSpots.getText());                minRoughSize = Integer.parseInt(texMinRoughSize.getText());                maxRoughSize = Integer.parseInt(texMaxRoughSize.getText());                minSwampSpots = Integer.parseInt(texMinSwampSpots.getText());                maxSwampSpots = Integer.parseInt(texMaxSwampSpots.getText());                minSwampSize = Integer.parseInt(texMinSwampSize.getText());                maxSwampSize = Integer.parseInt(texMaxSwampSize.getText());                probRoad = Integer.parseInt(texProbRoad.getText());                probRiver = Integer.parseInt(texProbRiver.getText());                probHeavy = Integer.parseInt(texProbHeavy.getText());                probDeep = Integer.parseInt(texProbDeep.getText());                probCrater = Integer.parseInt(texProbCrater.getText());                minRadius = Integer.parseInt(texMinRadius.getText());                maxRadius = Integer.parseInt(texMaxRadius.getText());                maxCraters = Integer.parseInt(texMaxCraters.getText());                minCraters = Integer.parseInt(texMinCraters.getText());                algorithmToUse = Integer.parseInt(texAlgorithmToUse.getText());            } catch (NumberFormatException ex) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.OnlyIntegersWarn")).show(); //$NON-NLS-1$                return false;            }                        if (hilliness < 0 || hilliness > 99) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.AmmountOfElevationWarn")).show(); //$NON-NLS-1$                return false;            }            if (range < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.elevRangeWarn")).show(); //$NON-NLS-1$                return false;            }            if (probInvert < 0 || probInvert > 100) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.depressionWarn")).show(); //$NON-NLS-1$                return false;            }            if (minWaterSpots < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinLakesWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxWaterSpots < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxLakesWarn1")).show(); //$NON-NLS-1$                return false;            }            if (maxWaterSpots < minWaterSpots) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxLakesWarn2")).show(); //$NON-NLS-1$                return false;            }            if (minWaterSize < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinLakeSizeWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxWaterSize < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxLakeSizeWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxWaterSize < minWaterSize) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxLakeSizeWarn1")).show(); //$NON-NLS-1$                return false;            }            if (probDeep < 0 || probDeep > 100) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.DeepWaterProbWarn")).show(); //$NON-NLS-1$                return false;            }            if (minForestSpots < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinForestsWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxForestSpots < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxForestsWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxForestSpots < minForestSpots) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxForestsWarn1")).show(); //$NON-NLS-1$                return false;            }            if (minForestSize < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinForestSizeWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxForestSize < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxForestSizeWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxForestSize < minForestSize) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxForestSizeWarn1")).show(); //$NON-NLS-1$                return false;            }            if (probHeavy < 0 || probHeavy > 100) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.HeavyForestProbWarn")).show(); //$NON-NLS-1$                return false;            }            if (minRoughSpots < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinRoughsWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxRoughSpots < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxRoughsWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxRoughSpots < minRoughSpots) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxRoughsWarn1")).show(); //$NON-NLS-1$                return false;            }            if (minRoughSize < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinRoughSizeWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxRoughSize < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxRoughSizeWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxRoughSize < minRoughSize) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxRoughSizeWarn1")).show(); //$NON-NLS-1$                return false;            }            if (minSwampSpots < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinSwampsWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxSwampSpots < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxSwampsWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxSwampSpots < minSwampSpots) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxSwampsWarn1")).show(); //$NON-NLS-1$                return false;            }            if (minSwampSize < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinSwampSizeWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxSwampSize < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxSwampSizeWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxSwampSize < minSwampSize) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxSwampSizeWarn1")).show(); //$NON-NLS-1$                return false;            }            if (probRiver < 0 || probRiver > 100) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.RiverProbWarn")).show(); //$NON-NLS-1$                return false;            }            if (probRoad < 0 || probRoad > 100) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.RoadProbWarn")).show(); //$NON-NLS-1$                return false;            }            if (probCrater < 0 || probCrater > 100) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.CratersProbWarn")).show(); //$NON-NLS-1$                return false;            }            if (minRadius < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinCraterRadiusWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxRadius < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxCraterRadiusWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxRadius < minRadius) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxCraterRadiusWarn1")).show(); //$NON-NLS-1$                return false;            }            if (maxCraters < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxCratersWarn")).show(); //$NON-NLS-1$                return false;            }            if (minCraters < 0) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MinCratersWarn")).show(); //$NON-NLS-1$                return false;            }            if (maxCraters < minCraters) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.MaxCratersWarn1")).show(); //$NON-NLS-1$                return false;            }            if (algorithmToUse < 0 || algorithmToUse > 2) {                new AlertDialog(frame, INVALID_SETTING, Messages.getString("RandomMapDialog.AlgorithmWarn")).show(); //$NON-NLS-1$                return false;            }                                } else {            String s = choElevation.getSelectedItem();            if (s.equals(NONE)) {                hilliness = 0;                range = 0;            } else if (s.equals(LOW)) {                hilliness = 25;                range = 3;            } else if (s.equals(MEDIUM)) {                hilliness = 50;                range = 5;            } else {                hilliness = 75;                range = 8;            }            s = choWoods.getSelectedItem();            if (s.equals(NONE)) {                minForestSize = 0;                maxForestSize = 0;                minForestSpots = 0;                maxForestSpots = 0;                probHeavy = 0;            } else if (s.equals(LOW)) {                minForestSize = 3;                maxForestSize = 6;                minForestSpots = 3;                maxForestSpots = 6;                probHeavy = 20;            } else if (s.equals(MEDIUM)) {                minForestSize = 3;                maxForestSize = 10;                minForestSpots = 4;                maxForestSpots = 8;                probHeavy = 30;            } else {                minForestSize = 8;                maxForestSize = 13;                minForestSpots = 6;                maxForestSpots = 10;                probHeavy = 45;            }            s = choLakes.getSelectedItem();            if (s.equals(NONE)) {                minWaterSize = 0;                maxWaterSize = 0;                minWaterSpots = 0;                maxWaterSpots = 0;                probDeep = 0;            } else if (s.equals(LOW)) {                minWaterSize = 1;                maxWaterSize = 5;                minWaterSpots = 1;                maxWaterSpots = 5;                probDeep = 20;            } else if (s.equals(MEDIUM)) {                minWaterSize = 6;                maxWaterSize = 10;                minWaterSpots = 2;                maxWaterSpots = 5;                probDeep = 30;            } else {                minWaterSize = 8;                maxWaterSize = 15;                minWaterSpots = 3;                maxWaterSpots = 6;                probDeep = 45;            }            s = choRough.getSelectedItem();            if (s.equals(NONE)) {                minRoughSize = 0;                maxRoughSize = 0;                minRoughSpots = 0;                maxRoughSpots = 0;            } else if (s.equals(LOW)) {                minRoughSize = 1;                maxRoughSize = 2;                minRoughSpots = 2;                maxRoughSpots = 6;            } else if (s.equals(MEDIUM)) {                minRoughSize = 2;                maxRoughSize = 5;                minRoughSpots = 3;                maxRoughSpots = 8;            } else {                minRoughSize = 3;                maxRoughSize = 7;                minRoughSpots = 5;                maxRoughSpots = 10;            }            s = choSwamp.getSelectedItem();            if (s.equals(NONE)) {                minSwampSize = 0;                maxSwampSize = 0;                minSwampSpots = 0;                maxSwampSpots = 0;            } else if (s.equals(LOW)) {                minSwampSize = 1;                maxSwampSize = 2;                minSwampSpots = 2;                maxSwampSpots = 6;            } else if (s.equals(MEDIUM)) {                minSwampSize = 2;                maxSwampSize = 5;                minSwampSpots = 3;                maxSwampSpots = 8;            } else {                minSwampSize = 3;                maxSwampSize = 7;                minSwampSpots = 5;                maxSwampSpots = 10;            }            s = choRoads.getSelectedItem();            if (s.equals(NONE)) {                probRoad = 0;            } else if (s.equals(LOW)) {                probRoad = 25;            } else if (s.equals(MEDIUM)) {                probRoad = 50;            } else {                probRoad = 75;            }            s = choRivers.getSelectedItem();            if (s.equals(NONE)) {                probRiver = 0;            } else if (s.equals(LOW)) {                probRiver = 25;            } else if (s.equals(MEDIUM)) {                probRiver = 50;            } else {                probRiver = 75;            }                        probCrater = 0;            minRadius = 0;            maxRadius = 0;            minCraters = 0;            maxCraters = 0;            algorithmToUse = 0;            probInvert = 0;        }                mapSettings.setBoardSize(boardWidth, boardHeight);        mapSettings.setElevationParams(hilliness, range, probInvert);        mapSettings.setWaterParams(minWaterSpots, maxWaterSpots,                                     minWaterSize, maxWaterSize, probDeep);        mapSettings.setForestParams(minForestSpots, maxForestSpots,                                    minForestSize, maxForestSize, probHeavy);        mapSettings.setRoughParams(minRoughSpots, maxRoughSpots,                                    minRoughSize, maxRoughSize);        mapSettings.setSwampParams(minSwampSpots, maxSwampSpots,                                    minSwampSize, maxSwampSize);        mapSettings.setRiverParam(probRiver);        mapSettings.setRoadParam(probRoad);        mapSettings.setCraterParam(probCrater, minCraters, maxCraters, minRadius, maxRadius);        mapSettings.setAlgorithmToUse(algorithmToUse);                if (!advanced) {            loadValues();        }        bsd.updateMapSettings(mapSettings);        return true;    }