Changeset 3671 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2010-11-25T09:45:38+01:00 (13 years ago)
Author:
bastiK
Message:

adapt coding style (to some degree); there shouldn't be any semantic changes in this commit

Location:
trunk/src/org/openstreetmap/josm
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r3669 r3671  
    136136        // FIXME: this should become an asynchronous task
    137137        //
    138         for(UploadHook hook : uploadHooks)
    139             if(!hook.checkUpload(apiData))
     138        for (UploadHook hook : uploadHooks) {
     139            if (!hook.checkUpload(apiData))
    140140                return false;
     141        }
    141142
    142143        return true;
  • trunk/src/org/openstreetmap/josm/actions/ValidateAction.java

    r3669 r3671  
    3434 */
    3535public class ValidateAction extends JosmAction {
     36   
    3637    /** Serializable ID */
    3738    private static final long serialVersionUID = -2304521273582574603L;
     
    8485            }
    8586        } else {
    86             if (lastSelection == null)
     87            if (lastSelection == null) {
    8788                selection = Main.main.getCurrentDataSet().allNonDeletedPrimitives();
    88             else
     89            } else {
    8990                selection = lastSelection;
     91            }
    9092        }
    9193
     
    104106     *
    105107     */
    106 
    107108    class ValidationTask extends PleaseWaitRunnable {
    108109        private Collection<Test> tests;
     
    137138            //
    138139            Runnable r = new Runnable()  {
     140                @Override
    139141                public void run() {
    140142                    Main.map.validatorDialog.tree.setErrors(errors);
     
    153155        protected void realRun() throws SAXException, IOException,
    154156                OsmTransferException {
    155             if (tests == null || tests.isEmpty()) return;
     157            if (tests == null || tests.isEmpty())
     158                return;
    156159            errors = new ArrayList<TestError>(200);
    157160            getProgressMonitor().setTicksCount(tests.size() * validatedPrimitmives.size());
    158161            int testCounter = 0;
    159162            for (Test test : tests) {
    160                 if (canceled) return;
     163                if (canceled)
     164                    return;
    161165                testCounter++;
    162166                getProgressMonitor().setCustomText(tr("Test {0}/{1}: Starting {2}", testCounter, tests.size(),test.getName()));
  • trunk/src/org/openstreetmap/josm/actions/upload/ValidateUploadHook.java

    r3669 r3671  
    4141     * Validate the modified data before uploading
    4242     */
    43     public boolean checkUpload(APIDataSet apiDataSet)
    44     {
     43    public boolean checkUpload(APIDataSet apiDataSet) {
     44
    4545        Collection<Test> tests = OsmValidator.getEnabledTests(true);
    4646        if (tests.isEmpty())
     
    5252
    5353        List<TestError> errors = new ArrayList<TestError>(30);
    54         for(Test test : tests)
    55         {
     54        for (Test test : tests) {
    5655            test.setBeforeUpload(true);
    5756            test.setPartialSelection(true);
     
    5958            test.visit(selection);
    6059            test.endTest();
    61             if(Main.pref.getBoolean(ValidatorPreference.PREF_OTHER_UPLOAD, false))
     60            if (Main.pref.getBoolean(ValidatorPreference.PREF_OTHER_UPLOAD, false)) {
    6261                errors.addAll( test.getErrors() );
    63             else
    64             {
    65                 for(TestError e : test.getErrors())
    66                 {
    67                     if(e.getSeverity() != Severity.OTHER)
     62            }
     63            else {
     64                for (TestError e : test.getErrors()) {
     65                    if (e.getSeverity() != Severity.OTHER) {
    6866                        errors.add(e);
     67                    }
    6968                }
    7069            }
    7170        }
    7271        tests = null;
    73         if(errors == null || errors.isEmpty())
     72        if (errors == null || errors.isEmpty())
    7473            return true;
    7574
    76         if(Main.pref.getBoolean(ValidatorPreference.PREF_USE_IGNORE, true))
    77         {
     75        if (Main.pref.getBoolean(ValidatorPreference.PREF_USE_IGNORE, true)) {
    7876            int nume = 0;
    79             for(TestError error : errors)
    80             {
     77            for (TestError error : errors) {
    8178                List<String> s = new ArrayList<String>();
    8279                s.add(error.getIgnoreState());
    8380                s.add(error.getIgnoreGroup());
    8481                s.add(error.getIgnoreSubGroup());
    85                 for(String state : s)
    86                 {
    87                     if(state != null && OsmValidator.hasIgnoredError(state))
    88                     {
     82                for (String state : s) {
     83                    if (state != null && OsmValidator.hasIgnoredError(state)) {
    8984                        error.setIgnored(true);
    9085                    }
    9186                }
    92                 if(!error.getIgnored())
     87                if (!error.getIgnored()) {
    9388                    ++nume;
     89                }
    9490            }
    95             if(nume == 0)
     91            if (nume == 0)
    9692                return true;
    9793        }
     
    106102     *          if the user requested cancel.
    107103     */
    108     private boolean displayErrorScreen(List<TestError> errors)
    109     {
     104    private boolean displayErrorScreen(List<TestError> errors) {
    110105        JPanel p = new JPanel(new GridBagLayout());
    111106        ValidatorTreePanel errorPanel = new ValidatorTreePanel(errors);
     
    113108        p.add(new JScrollPane(errorPanel), GBC.eol());
    114109
    115         int res  = JOptionPane.showConfirmDialog(Main.parent, p,
    116         tr("Data with errors. Upload anyway?"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    117         if(res == JOptionPane.NO_OPTION)
    118         {
     110        int res = JOptionPane.showConfirmDialog(Main.parent, p,
     111            tr("Data with errors. Upload anyway?"),
     112            JOptionPane.YES_NO_OPTION,
     113            JOptionPane.QUESTION_MESSAGE);
     114        if (res == JOptionPane.NO_OPTION) {
    119115            OsmValidator.initializeErrorLayer();
    120116            Main.map.validatorDialog.unfurlDialog();
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r3669 r3671  
    4747import org.openstreetmap.josm.data.validation.tests.WronglyOrderedWays;
    4848import org.openstreetmap.josm.data.validation.util.ValUtil;
    49 import org.openstreetmap.josm.gui.MapFrame;
    5049import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    5150import org.openstreetmap.josm.gui.dialogs.ValidatorDialog;
     
    115114    private void checkPluginDir() {
    116115        try {
    117         File pathDir = new File(ValUtil.getPluginDir());
    118         if (!pathDir.exists())
    119             pathDir.mkdirs();
     116            File pathDir = new File(ValUtil.getPluginDir());
     117            if (!pathDir.exists()) {
     118                pathDir.mkdirs();
     119            }
    120120        } catch (Exception e){
    121121            e.printStackTrace();
     
    150150        try {
    151151            final PrintWriter out = new PrintWriter(new FileWriter(ValUtil.getPluginDir() + "ignorederrors"), false);
    152             for (String e : ignoredErrors)
     152            for (String e : ignoredErrors) {
    153153                out.println(e);
     154            }
    154155            out.close();
    155156        } catch (final IOException e) {
     
    221222        Collection<Test> enabledTests = getTests();
    222223        for (Test t : new ArrayList<Test>(enabledTests)) {
    223             if (beforeUpload ? t.testBeforeUpload : t.enabled)
     224            if (beforeUpload ? t.testBeforeUpload : t.enabled) {
    224225                continue;
     226            }
    225227            enabledTests.remove(t);
    226228        }
     
    243245     */
    244246    public void initializeGridDetail() {
    245         if (Main.proj.toString().equals(new Epsg4326().toString()))
     247        if (Main.proj.toString().equals(new Epsg4326().toString())) {
    246248            OsmValidator.griddetail = 10000;
    247         else if (Main.proj.toString().equals(new Mercator().toString()))
     249        } else if (Main.proj.toString().equals(new Mercator().toString())) {
    248250            OsmValidator.griddetail = 100000;
    249         else if (Main.proj.toString().equals(new Lambert().toString()))
     251        } else if (Main.proj.toString().equals(new Lambert().toString())) {
    250252            OsmValidator.griddetail = 0.1;
     253        }
    251254    }
    252255
     
    275278    /* interface LayerChangeListener                                              */
    276279    /* -------------------------------------------------------------------------- */
    277     public void activeLayerChange(Layer oldLayer, Layer newLayer) {}
    278 
    279     public void layerAdded(Layer newLayer) {}
    280 
     280    @Override
     281    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     282    }
     283
     284    @Override
     285    public void layerAdded(Layer newLayer) {
     286    }
     287
     288    @Override
    281289    public void layerRemoved(Layer oldLayer) {
    282290        if (oldLayer instanceof OsmDataLayer && Main.map.mapView.getActiveLayer() == oldLayer) {
  • trunk/src/org/openstreetmap/josm/data/validation/Severity.java

    r3669 r3671  
    3434     * @param color The color of this severity
    3535     */
    36     Severity(String message, String icon, Color color)
    37     {
     36    Severity(String message, String icon, Color color) {
    3837        this.message = message;
    3938        this.icon = icon;
     
    4241
    4342    @Override
    44     public String toString()
    45     {
     43    public String toString() {
    4644        return message;
    4745    }
     
    5149     * @return the associated icon
    5250     */
    53     public String getIcon()
    54     {
     51    public String getIcon() {
    5552        return icon;
    5653    }
     
    6057     * @return The associated color
    6158     */
    62     public Color getColor()
    63     {
     59    public Color getColor() {
    6460        return color;
    6561    }
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r3669 r3671  
    6767     * @param description Description of the test
    6868     */
    69     public Test(String name, String description)
    70     {
     69    public Test(String name, String description) {
    7170        this.name = name;
    7271        this.description = description;
     
    7776     * @param name Name of the test
    7877     */
    79     public Test(String name)
    80     {
     78    public Test(String name) {
    8179        this(name, null);
    8280    }
     
    8684     * @throws Exception When cannot initialize the test
    8785     */
    88     public void initialize() throws Exception {}
     86    public void initialize() throws Exception {
     87    }
    8988
    9089    /**
     
    9594    public void startTest(ProgressMonitor progressMonitor) {
    9695        if (progressMonitor == null) {
    97                 this.progressMonitor = NullProgressMonitor.INSTANCE;
     96            this.progressMonitor = NullProgressMonitor.INSTANCE;
    9897        } else {
    99                 this.progressMonitor = progressMonitor;
     98            this.progressMonitor = progressMonitor;
    10099        }
    101100        this.progressMonitor.beginTask(tr("Running test {0}", name));
     
    107106     * @param partialSelection Whether the test is on a partial selection data
    108107     */
    109     public void setPartialSelection(boolean partialSelection)
    110     {
     108    public void setPartialSelection(boolean partialSelection) {
    111109        this.partialSelection = partialSelection;
    112110    }
     
    116114     * @return The list of errors
    117115     */
    118     public List<TestError> getErrors()
    119     {
     116    public List<TestError> getErrors() {
    120117        return errors;
    121118    }
     
    136133     * @param selection The primitives to be tested
    137134     */
    138     public void visit(Collection<OsmPrimitive> selection)
    139     {
     135    public void visit(Collection<OsmPrimitive> selection) {
    140136        progressMonitor.setTicksCount(selection.size());
    141137        for (OsmPrimitive p : selection) {
    142             if( p.isUsable() )
     138            if (p.isUsable()) {
    143139                p.visit(this);
     140            }
    144141            progressMonitor.worked(1);
    145142        }
    146143    }
    147144
     145    @Override
    148146    public void visit(Node n) {}
    149147
     148    @Override
    150149    public void visit(Way w) {}
    151150
     151    @Override
    152152    public void visit(Relation r) {}
    153153
     
    156156     * @param testPanel The panel to add any preferences component
    157157     */
    158     public void addGui(JPanel testPanel)
    159     {
     158    public void addGui(JPanel testPanel) {
    160159        checkEnabled = new JCheckBox(name, enabled);
    161160        checkEnabled.setToolTipText(description);
     
    172171     * Called when the used submits the preferences
    173172     */
    174     public boolean ok()
    175     {
     173    public boolean ok() {
    176174        enabled = checkEnabled.isSelected();
    177175        testBeforeUpload = checkBeforeUpload.isSelected();
     
    180178
    181179    /**
    182      * Fixes the error with the appropiate command
     180     * Fixes the error with the appropriate command
    183181     *
    184182     * @param testError
    185183     * @return The command to fix the error
    186184     */
    187     public Command fixError(TestError testError)
    188     {
     185    public Command fixError(TestError testError) {
    189186        return null;
    190187    }
     
    196193     * @return true if the error can be fixed
    197194     */
    198     public boolean isFixable(TestError testError)
    199     {
     195    public boolean isFixable(TestError testError) {
    200196        return false;
    201197    }
     
    205201     * @return true if this plugin must check the uploaded data before uploading
    206202     */
    207     public boolean testBeforeUpload()
    208     {
     203    public boolean testBeforeUpload() {
    209204        return testBeforeUpload;
    210205    }
     
    214209     * @param isUpload if true, the test is before upload
    215210     */
    216     public void setBeforeUpload(boolean isUpload)
    217     {
     211    public void setBeforeUpload(boolean isUpload) {
    218212        this.isBeforeUpload = isUpload;
    219213    }
  • trunk/src/org/openstreetmap/josm/data/validation/TestError.java

    r3669 r3671  
    157157                return null;
    158158            String type = "u";
    159             if (o instanceof Way)
     159            if (o instanceof Way) {
    160160                type = "w";
    161             else if (o instanceof Relation)
     161            } else if (o instanceof Relation) {
    162162                type = "r";
    163             else if (o instanceof Node)
     163            } else if (o instanceof Node) {
    164164                type = "n";
     165            }
    165166            strings.add(type + "_" + o.getId());
    166167        }
     
    173174    public String getIgnoreSubGroup() {
    174175        String ignorestring = getIgnoreGroup();
    175         if (description_en != null)
     176        if (description_en != null) {
    176177            ignorestring += "_" + description_en;
     178        }
    177179        return ignorestring;
    178180    }
     
    216218
    217219    /**
    218      * Fixes the error with the appropiate command
     220     * Fixes the error with the appropriate command
    219221     *
    220222     * @return The command to fix the error
     
    243245    public void visitHighlighted(ValidatorVisitor v) {
    244246        for (Object o : highlighted) {
    245             if (o instanceof OsmPrimitive)
     247            if (o instanceof OsmPrimitive) {
    246248                v.visit((OsmPrimitive) o);
    247             else if (o instanceof WaySegment)
     249            } else if (o instanceof WaySegment) {
    248250                v.visit((WaySegment) o);
    249             else if (o instanceof List<?>) {
     251            } else if (o instanceof List<?>) {
    250252                v.visit((List<Node>)o);
    251253            }
     
    273275        }
    274276
     277        @Override
    275278        public void visit(OsmPrimitive p) {
    276279            if (p.isUsable()) {
     
    289292            if (selected) {
    290293                g.fillOval(p.x - 5, p.y - 5, 10, 10);
    291             } else
     294            } else {
    292295                g.drawOval(p.x - 5, p.y - 5, 10, 10);
     296            }
    293297        }
    294298
     
    301305            int deg = (int) Math.toDegrees(t);
    302306            if (selected) {
    303                 int[] x = new int[] { (int) (p1.x + 5 * cosT), (int) (p2.x + 5 * cosT), (int) (p2.x - 5 * cosT),
    304                         (int) (p1.x - 5 * cosT) };
    305                 int[] y = new int[] { (int) (p1.y - 5 * sinT), (int) (p2.y - 5 * sinT), (int) (p2.y + 5 * sinT),
    306                         (int) (p1.y + 5 * sinT) };
     307                int[] x = new int[] { (int) (p1.x + 5 * cosT), (int) (p2.x + 5 * cosT),
     308                                      (int) (p2.x - 5 * cosT), (int) (p1.x - 5 * cosT) };
     309                int[] y = new int[] { (int) (p1.y - 5 * sinT), (int) (p2.y - 5 * sinT),
     310                                      (int) (p2.y + 5 * sinT), (int) (p1.y + 5 * sinT) };
    307311                g.fillPolygon(x, y, 4);
    308312                g.fillArc(p1.x - 5, p1.y - 5, 10, 10, deg, 180);
    309313                g.fillArc(p2.x - 5, p2.y - 5, 10, 10, deg, -180);
    310314            } else {
    311                 g.drawLine((int) (p1.x + 5 * cosT), (int) (p1.y - 5 * sinT), (int) (p2.x + 5 * cosT),
    312                         (int) (p2.y - 5 * sinT));
    313                 g.drawLine((int) (p1.x - 5 * cosT), (int) (p1.y + 5 * sinT), (int) (p2.x - 5 * cosT),
    314                         (int) (p2.y + 5 * sinT));
     315                g.drawLine((int) (p1.x + 5 * cosT), (int) (p1.y - 5 * sinT),
     316                           (int) (p2.x + 5 * cosT), (int) (p2.y - 5 * sinT));
     317                g.drawLine((int) (p1.x - 5 * cosT), (int) (p1.y + 5 * sinT),
     318                           (int) (p2.x - 5 * cosT), (int) (p2.y + 5 * sinT));
    315319                g.drawArc(p1.x - 5, p1.y - 5, 10, 10, deg, 180);
    316320                g.drawArc(p2.x - 5, p2.y - 5, 10, 10, deg, -180);
     
    334338         * @param n The node to draw.
    335339         */
     340        @Override
    336341        public void visit(Node n) {
    337             if (isNodeVisible(n))
     342            if (isNodeVisible(n)) {
    338343                drawNode(n, severity.getColor());
    339         }
    340 
     344            }
     345        }
     346
     347        @Override
    341348        public void visit(Way w) {
    342349            visit(w.getNodes());
    343350        }
    344351
     352        @Override
    345353        public void visit(WaySegment ws) {
    346354            if (ws.lowerIndex < 0 || ws.lowerIndex + 1 >= ws.way.getNodesCount())
     
    352360        }
    353361
     362        @Override
    354363        public void visit(Relation r) {
    355364            /* No idea how to draw a relation. */
     
    387396        }
    388397
     398        @Override
    389399        public void visit(List<Node> nodes) {
    390400            Node lastN = null;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/ChangePropertyKeyCommand.java

    r3669 r3671  
    5050    }
    5151
    52     @Override public boolean executeCommand() {
    53         if (!super.executeCommand()) return false; // save old
     52    @Override
     53    public boolean executeCommand() {
     54        if (!super.executeCommand())
     55            return false; // save old
    5456        for (OsmPrimitive osm : objects) {
    55             if(osm.hasKeys())
    56             {
     57            if (osm.hasKeys()) {
    5758                osm.setModified(true);
    5859                String oldValue = osm.get(key);
     
    6465    }
    6566
    66     @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
     67    @Override
     68    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
    6769        modified.addAll(objects);
    6870    }
    6971
    70     @Override public JLabel getDescription() {
     72    @Override
     73    public JLabel getDescription() {
    7174        String text = tr( "Replace \"{0}\" by \"{1}\" for", key, newKey);
    7275        if (objects.size() == 1) {
     
    7477            objects.iterator().next().visit(v);
    7578            text += " "+tr(v.className)+" "+v.name;
    76         } else
     79        } else {
    7780            text += " "+objects.size()+" "+trn("object","objects",objects.size());
     81        }
    7882        return new JLabel(text, ImageProvider.get("data", "key"), JLabel.HORIZONTAL);
    7983    }
    8084
    81     @Override public Collection<PseudoCommand> getChildren() {
     85    @Override
     86    public Collection<PseudoCommand> getChildren() {
    8287        if (objects.size() == 1)
    8388            return null;
     
    8893            osm.visit(v);
    8994            children.add(new PseudoCommand() {
    90                 @Override public JLabel getDescription() {
     95                @Override
     96                public JLabel getDescription() {
    9197                    return v.toLabel();
    9298                }
    93                 @Override public Collection<? extends OsmPrimitive> getParticipatingPrimitives() {
     99                @Override
     100                public Collection<? extends OsmPrimitive> getParticipatingPrimitives() {
    94101                    return Collections.singleton(osm);
    95102                }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java

    r3669 r3671  
    2828 * @author Teemu Koskinen
    2929 */
    30 public class Coastlines extends Test
    31 {
     30public class Coastlines extends Test {
     31
    3232    protected static int UNORDERED_COASTLINE = 901;
    3333    protected static int REVERSED_COASTLINE = 902;
     
    4141     * Constructor
    4242     */
    43     public Coastlines()
    44     {
     43    public Coastlines() {
    4544        super(tr("Coastlines."),
    4645              tr("This test checks that coastlines are correct."));
     
    4847
    4948    @Override
    50     public void startTest(ProgressMonitor monitor)
    51     {
     49    public void startTest(ProgressMonitor monitor) {
     50
    5251        super.startTest(monitor);
    5352
    5453        OsmDataLayer layer = Main.map.mapView.getEditLayer();
    5554
    56         if (layer != null)
     55        if (layer != null) {
    5756            downloadedArea = layer.data.getDataSourceArea();
     57        }
    5858
    5959        coastlines = new LinkedList<Way>();
     
    6161
    6262    @Override
    63     public void endTest()
    64     {
     63    public void endTest() {
    6564        for (Way c1 : coastlines) {
    6665            Node head = c1.firstNode();
    6766            Node tail = c1.lastNode();
    6867
    69             if (head.equals(tail))
     68            if (head.equals(tail)) {
    7069                continue;
     70            }
    7171
    7272            int headWays = 0;
     
    8080
    8181            for (Way c2 : coastlines) {
    82                 if (c1 == c2)
     82                if (c1 == c2) {
    8383                    continue;
     84                }
    8485
    8586                if (c2.containsNode(head)) {
     
    8788                    next = c2;
    8889
    89                     if (head.equals(c2.firstNode()))
     90                    if (head.equals(c2.firstNode())) {
    9091                        headReversed = true;
    91                     else if (!head.equals(c2.lastNode()))
     92                    } else if (!head.equals(c2.lastNode())) {
    9293                        headUnordered = true;
     94                    }
    9395                }
    9496
     
    9799                    prev = c2;
    98100
    99                     if (tail.equals(c2.lastNode()))
     101                    if (tail.equals(c2.lastNode())) {
    100102                        tailReversed = true;
    101                     else if (!tail.equals(c2.firstNode()))
     103                    } else if (!tail.equals(c2.firstNode())) {
    102104                        tailUnordered = true;
    103                 }
    104             }
    105 
     105                    }
     106                }
     107            }
    106108
    107109            List<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>();
     
    121123                }
    122124
    123                 if (highlight.size() > 0)
     125                if (highlight.size() > 0) {
    124126                    errors.add(new TestError(this, Severity.ERROR, tr("Unconnected coastline"),
    125127                                             UNCONNECTED_COASTLINE, primitives, highlight));
     128                }
    126129            }
    127130
     
    129132            boolean reversed = false;
    130133
    131             if (headWays == 1 && headReversed && tailWays == 1 && tailReversed)
     134            if (headWays == 1 && headReversed && tailWays == 1 && tailReversed) {
    132135                reversed = true;
    133 
    134             if (headWays > 1 || tailWays > 1)
     136            }
     137
     138            if (headWays > 1 || tailWays > 1) {
    135139                unordered = true;
    136             else if (headUnordered || tailUnordered)
     140            } else if (headUnordered || tailUnordered) {
    137141                unordered = true;
    138             else if (reversed && next == prev)
     142            } else if (reversed && next == prev) {
    139143                unordered = true;
     144            }
    140145
    141146            if (unordered) {
     
    168173
    169174    @Override
    170     public void visit(Way way)
    171     {
     175    public void visit(Way way) {
    172176        if (!way.isUsable())
    173177            return;
     
    192196            return new ChangeCommand(way, newWay);
    193197        }
    194 
    195198        return null;
    196199    }
     
    198201    @Override
    199202    public boolean isFixable(TestError testError) {
    200         if (testError.getTester() instanceof Coastlines) {
     203        if (testError.getTester() instanceof Coastlines)
    201204            return (testError.getCode() == REVERSED_COASTLINE);
    202         }
    203205
    204206        return false;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r3669 r3671  
    2828 * @author frsantos
    2929 */
    30 public class CrossingWays extends Test
    31 {
     30public class CrossingWays extends Test {
    3231    protected static int CROSSING_WAYS = 601;
    3332
     
    3938    Map<List<Way>, List<WaySegment>> ways_seen;
    4039
    41 
    4240    /**
    4341     * Constructor
    4442     */
    45     public CrossingWays()
    46     {
     43    public CrossingWays() {
    4744        super(tr("Crossing ways."),
    4845              tr("This test checks if two roads, railways, waterways or buildings crosses in the same layer, but are not connected by a node."));
    4946    }
    5047
    51 
    5248    @Override
    53     public void startTest(ProgressMonitor monitor)
    54     {
     49    public void startTest(ProgressMonitor monitor) {
    5550        super.startTest(monitor);
    5651        cellSegments = new HashMap<Point2D,List<ExtendedSegment>>(1000);
     
    6055
    6156    @Override
    62     public void endTest()
    63     {
     57    public void endTest() {
    6458        super.endTest();
    6559        cellSegments = null;
     
    6963
    7064    @Override
    71     public void visit(Way w)
    72     {
    73         if( !w.isUsable() )
     65    public void visit(Way w) {
     66        if(!w.isUsable())
    7467            return;
    7568
     
    8174        boolean isBuilding = (w.get("building") != null);
    8275
    83         if( w.get("highway") == null && w.get("waterway") == null && (railway1 == null || isSubway1 || isTram1)  && !isCoastline1 && !isBuilding)
     76        if (w.get("highway") == null && w.get("waterway") == null
     77                && (railway1 == null || isSubway1 || isTram1)
     78                && !isCoastline1 && !isBuilding)
    8479            return;
    8580
     
    9186            ExtendedSegment es1 = new ExtendedSegment(ws, layer1, railway1, coastline1);
    9287            List<List<ExtendedSegment>> cellSegments = getSegments(es1.n1, es1.n2);
    93             for( List<ExtendedSegment> segments : cellSegments)
    94             {
    95                 for( ExtendedSegment es2 : segments)
    96                 {
     88            for (List<ExtendedSegment> segments : cellSegments) {
     89                for (ExtendedSegment es2 : segments) {
    9790                    List<Way> prims;
    9891                    List<WaySegment> highlight;
     
    107100                        continue;
    108101
    109                     if( !es1.intersects(es2) ) continue;
    110                     if( isSubway1 && "subway".equals(railway2)) continue;
    111                     if( isTram1 && "tram".equals(railway2)) continue;
     102                    if (!es1.intersects(es2) ) continue;
     103                    if (isSubway1 && "subway".equals(railway2)) continue;
     104                    if (isTram1 && "tram".equals(railway2)) continue;
    112105
    113106                    boolean isCoastline2 = coastline2 != null && (coastline2.equals("water") || coastline2.equals("coastline"));
    114                     if( isCoastline1 != isCoastline2 ) continue;
    115 
    116                     if((es1.railway != null && es1.railway.equals("abandoned")) || (railway2 != null && railway2.equals("abandoned"))) continue;
     107                    if (isCoastline1 != isCoastline2) continue;
     108
     109                    if ((es1.railway != null && es1.railway.equals("abandoned"))
     110                            || (railway2 != null && railway2.equals("abandoned"))) continue;
    117111
    118112                    prims = Arrays.asList(es1.ws.way, es2.ws.way);
    119                     if ((highlight = ways_seen.get(prims)) == null)
    120                     {
     113                    if ((highlight = ways_seen.get(prims)) == null) {
    121114                        highlight = new ArrayList<WaySegment>();
    122115                        highlight.add(es1.ws);
     
    124117
    125118                        errors.add(new TestError(this, Severity.WARNING,
    126                         isBuilding ? tr("Crossing buildings") : tr("Crossing ways"), CROSSING_WAYS, prims, highlight));
     119                            isBuilding ? tr("Crossing buildings") : tr("Crossing ways"),
     120                            CROSSING_WAYS,
     121                            prims,
     122                            highlight));
    127123                        ways_seen.put(prims, highlight);
    128                     }
    129                     else
    130                     {
     124                    } else {
    131125                        highlight.add(es1.ws);
    132126                        highlight.add(es2.ws);
     
    146140    * @return A list with all the cells the segment crosses
    147141    */
    148     public List<List<ExtendedSegment>> getSegments(Node n1, Node n2)
    149     {
     142    public List<List<ExtendedSegment>> getSegments(Node n1, Node n2) {
     143
    150144        List<List<ExtendedSegment>> cells = new ArrayList<List<ExtendedSegment>>();
    151         for( Point2D cell : ValUtil.getSegmentCells(n1, n2, OsmValidator.griddetail) )
    152         {
    153             List<ExtendedSegment> segments = cellSegments.get( cell );
    154             if( segments == null )
    155             {
     145        for(Point2D cell : ValUtil.getSegmentCells(n1, n2, OsmValidator.griddetail)) {
     146            List<ExtendedSegment> segments = cellSegments.get(cell);
     147            if (segments == null) {
    156148                segments = new ArrayList<ExtendedSegment>();
    157149                cellSegments.put(cell, segments);
     
    159151            cells.add(segments);
    160152        }
    161 
    162153        return cells;
    163154    }
     
    167158     * @author frsantos
    168159     */
    169     private static class ExtendedSegment
    170     {
     160    public static class ExtendedSegment {
    171161        public Node n1, n2;
    172162
     
    187177         * @param layer The layer of the way this segment is in
    188178         * @param railway The railway type of the way this segment is in
    189          * @param coastline The coastlyne typo of the way the segment is in
     179         * @param coastline The coastline typo of the way the segment is in
    190180         */
    191         public ExtendedSegment(WaySegment ws, String layer, String railway, String coastline)
    192         {
     181        public ExtendedSegment(WaySegment ws, String layer, String railway, String coastline) {
    193182            this.ws = ws;
    194183            this.n1 = ws.way.getNodes().get(ws.lowerIndex);
     
    202191         * Checks whether this segment crosses other segment
    203192         * @param s2 The other segment
    204          * @return true if both segements crosses
     193         * @return true if both segments crosses
    205194         */
    206         public boolean intersects(ExtendedSegment s2)
    207         {
    208             if( n1.equals(s2.n1) || n2.equals(s2.n2) ||
    209                 n1.equals(s2.n2)   || n2.equals(s2.n1) )
    210             {
     195        public boolean intersects(ExtendedSegment s2) {
     196            if (n1.equals(s2.n1) || n2.equals(s2.n2) ||
     197                    n1.equals(s2.n2) || n2.equals(s2.n1))
    211198                return false;
    212             }
    213199
    214200            return Line2D.linesIntersect(
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java

    r3669 r3671  
    5858        private LatLon getLatLon(Object o) {
    5959            if (o instanceof Node) {
    60                 if (precision==0) {
     60                if (precision==0)
    6161                    return ((Node) o).getCoor().getRoundedToOsmPrecision();
    62                 } else {
    63                     return RoundCoord((Node) o);
    64                 }
     62                return RoundCoord((Node) o);
    6563            } else if (o instanceof List<?>) {
    66                 if (precision==0) {
     64                if (precision==0)
    6765                    return ((List<Node>) o).get(0).getCoor().getRoundedToOsmPrecision();
    68                 } else {
    69                     return RoundCoord(((List<Node>) o).get(0));
    70                 }
     66                return RoundCoord(((List<Node>) o).get(0));
    7167            } else {
    7268                throw new AssertionError();
     
    7470        }
    7571
     72        @Override
    7673        public boolean equals(Object k, Object t) {
    7774            return getLatLon(k).equals(getLatLon(t));
    7875        }
    7976
     77        @Override
    8078        public int getHashCode(Object k) {
    8179            return getLatLon(k).hashCode();
    8280        }
    83 
    8481    }
    8582
     
    107104     * Constructor
    108105     */
    109     public DuplicateNode()
    110     {
     106    public DuplicateNode() {
    111107        super(tr("Duplicated nodes")+".",
    112108                tr("This test checks that there are no nodes at the very same location."));
     
    132128            // multiple nodes at the same position -> report errors
    133129            //
    134             List<Node> nodes = (List<Node>)v;
     130            List<Node> nodes = (List<Node>) v;
    135131            errors.addAll(buildTestErrors(this, nodes));
    136132        }
     
    154150        // the same tag set
    155151        //
    156         for (Iterator<Map<String,String>> it = bag.keySet().iterator(); it.hasNext(); ) {
     152        for (Iterator<Map<String,String>> it = bag.keySet().iterator(); it.hasNext();) {
    157153            Map<String,String> tagSet = it.next();
    158154            if (bag.get(tagSet).size() > 1) {
     
    177173                                    }
    178174                                }
    179                                 if (!typed) typeMap.put("none", true);
     175                                if (!typed) {
     176                                    typeMap.put("none", true);
     177                                }
    180178                            }
    181179                        }
     
    186184                int nbType=0;
    187185                for (String type: typeMap.keySet()) {
    188                     if (typeMap.get(type)) nbType++;
     186                    if (typeMap.get(type)) {
     187                        nbType++;
     188                    }
    189189                }
    190190
     
    303303                it.remove();
    304304            }
    305 
    306305        }
    307306
     
    359358     */
    360359    @Override
    361     public Command fixError(TestError testError)
    362     {
     360    public Command fixError(TestError testError) {
    363361        Collection<OsmPrimitive> sel = new LinkedList<OsmPrimitive>(testError.getPrimitives());
    364362        LinkedHashSet<Node> nodes = new LinkedHashSet<Node>(OsmPrimitive.getFilteredList(sel, Node.class));
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java

    r3669 r3671  
    4040            keys=_keys;
    4141        }
     42
    4243        @Override
    4344        public int hashCode() {
    4445            return coor.hashCode()+keys.hashCode();
    4546        }
     47
    4648        @Override
    4749        public boolean equals(Object obj) {
    48             if (!(obj instanceof WayPair)) return false;
     50            if (!(obj instanceof WayPair))
     51                return false;
    4952            WayPair wp = (WayPair) obj;
    5053            return wp.coor.equals(coor) && wp.keys.equals(keys);
     
    6063     * Constructor
    6164     */
    62     public DuplicateWay()
    63     {
     65    public DuplicateWay() {
    6466        super(tr("Duplicated ways")+".",
    6567              tr("This test checks that there are no ways with same tags and same node coordinates."));
     
    6870
    6971    @Override
    70     public void startTest(ProgressMonitor monitor)
    71     {
     72    public void startTest(ProgressMonitor monitor) {
    7273        super.startTest(monitor);
    7374        ways = new Bag<WayPair, OsmPrimitive>(1000);
     
    7576
    7677    @Override
    77     public void endTest()
    78     {
     78    public void endTest() {
    7979        super.endTest();
    80         for(List<OsmPrimitive> duplicated : ways.values() )
    81         {
    82             if( duplicated.size() > 1)
    83             {
     80        for (List<OsmPrimitive> duplicated : ways.values()) {
     81            if (duplicated.size() > 1) {
    8482                TestError testError = new TestError(this, Severity.ERROR, tr("Duplicated ways"), DUPLICATE_WAY, duplicated);
    85                 errors.add( testError );
     83                errors.add(testError);
    8684            }
    8785        }
     
    9088
    9189    @Override
    92     public void visit(Way w)
    93     {
    94         if( !w.isUsable() )
     90    public void visit(Way w) {
     91        if (!w.isUsable())
    9592            return;
    9693        List<Node> wNodes=w.getNodes();
    9794        Vector<LatLon> wLat=new Vector<LatLon>(wNodes.size());
    98         for(int i=0;i<wNodes.size();i++) {
    99                  wLat.add(wNodes.get(i).getCoor());
     95        for (int i=0;i<wNodes.size();i++) {
     96             wLat.add(wNodes.get(i).getCoor());
    10097        }
    10198        Map<String, String> wkeys=w.getKeys();
     
    109106     */
    110107    @Override
    111     public Command fixError(TestError testError)
    112     {
     108    public Command fixError(TestError testError) {
    113109        Collection<? extends OsmPrimitive> sel = testError.getPrimitives();
    114110        HashSet<Way> ways = new HashSet<Way>();
    115111
    116         for (OsmPrimitive osm : sel)
    117             if (osm instanceof Way)
     112        for (OsmPrimitive osm : sel) {
     113            if (osm instanceof Way) {
    118114                ways.add((Way)osm);
     115            }
     116        }
    119117
    120         if( ways.size() < 2 )
     118        if (ways.size() < 2)
    121119            return null;
    122120
     
    171169
    172170    @Override
    173     public boolean isFixable(TestError testError)
    174     {
     171    public boolean isFixable(TestError testError) {
    175172        if (!(testError.getTester() instanceof DuplicateWay))
    176173            return false;
     
    180177        HashSet<Way> ways = new HashSet<Way>();
    181178
    182         for (OsmPrimitive osm : sel)
    183             if (osm instanceof Way)
     179        for (OsmPrimitive osm : sel) {
     180            if (osm instanceof Way) {
    184181                ways.add((Way)osm);
     182            }
     183        }
    185184
    186185        if (ways.size() < 2)
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicatedWayNodes.java

    r3669 r3671  
    2525    }
    2626
    27     @Override public void visit(Way w) {
     27    @Override
     28    public void visit(Way w) {
    2829        if (!w.isUsable()) return;
    2930
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r3669 r3671  
    5151
    5252    @Override
    53     public void initialize() throws Exception
    54     {
     53    public void initialize() throws Exception {
    5554        styles = MapPaintStyles.getStyles().getStyleSet();
    5655    }
     
    5958        List<List<Node>> result = new ArrayList<List<Node>>();
    6059        List<Way> waysToJoin = new ArrayList<Way>();
    61         for (Way way: ways) {
     60        for (Way way : ways) {
    6261            if (way.isClosed()) {
    6362                result.add(way.getNodes());
     
    6766        }
    6867
    69         for (JoinedWay jw: Multipolygon.joinWays(waysToJoin)) {
     68        for (JoinedWay jw : Multipolygon.joinWays(waysToJoin)) {
    7069            if (!jw.isClosed()) {
    7170                nonClosedWays.add(jw.getNodes());
     
    7978    private GeneralPath createPath(List<Node> nodes) {
    8079        GeneralPath result = new GeneralPath();
    81         result.moveTo((float)nodes.get(0).getCoor().lat(), (float)nodes.get(0).getCoor().lon());
     80        result.moveTo((float) nodes.get(0).getCoor().lat(), (float) nodes.get(0).getCoor().lon());
    8281        for (int i=1; i<nodes.size(); i++) {
    8382            Node n = nodes.get(i);
    84             result.lineTo((float)n.getCoor().lat(), (float)n.getCoor().lon());
     83            result.lineTo((float )n.getCoor().lat(), (float) n.getCoor().lon());
    8584        }
    8685        return result;
     
    8988    private List<GeneralPath> createPolygons(List<List<Node>> joinedWays) {
    9089        List<GeneralPath> result = new ArrayList<GeneralPath>();
    91         for (List<Node> way: joinedWays) {
     90        for (List<Node> way : joinedWays) {
    9291            result.add(createPath(way));
    9392        }
     
    9998        boolean outside = false;
    10099
    101         for (Node n: inner) {
     100        for (Node n : inner) {
    102101            boolean contains = outer.contains(n.getCoor().lat(), n.getCoor().lon());
    103102            inside = inside | contains;
     
    108107        }
    109108
    110         return inside?Intersection.INSIDE:Intersection.OUTSIDE;
     109        return inside ? Intersection.INSIDE : Intersection.OUTSIDE;
    111110    }
    112111
    113112    @Override
    114113    public void visit(Way w) {
    115         if (styles != null && !w.isClosed())
    116         {
     114        if (styles != null && !w.isClosed()) {
    117115            ElemStyle e = styles.getArea(w);
    118             if(e instanceof AreaElemStyle && !((AreaElemStyle)e).closed)
     116            if (e instanceof AreaElemStyle && !((AreaElemStyle)e).closed) {
    119117                errors.add( new TestError(this, Severity.WARNING, tr("Area style way is not closed"), NOT_CLOSED,  w));
     118            }
    120119        }
    121120    }
     
    134133            }
    135134
    136             for (RelationMember rm: r.getMembers()) {
    137                 if (!rm.getMember().isUsable()) {
     135            for (RelationMember rm : r.getMembers()) {
     136                if (!rm.getMember().isUsable())
    138137                    return; // Rest of checks is only for complete multipolygons
    139                 }
    140138            }
    141139
     
    143141            List<List<Node>> outerWays = joinWays(polygon.getOuterWays());
    144142
    145             if(styles != null) {
     143            if (styles != null) {
    146144                ElemStyle wayStyle = styles.get(r);
    147145
    148146                // If area style was not found for relation then use style of ways
    149                 if(!(wayStyle instanceof AreaElemStyle)) {
     147                if (!(wayStyle instanceof AreaElemStyle)) {
    150148                    errors.add( new TestError(this, Severity.OTHER, tr("No style in multipolygon relation"),
    151149                    NO_STYLE_POLYGON, r));
     
    159157
    160158                if (wayStyle instanceof AreaElemStyle) {
    161                     for (Way wInner : polygon.getInnerWays())
    162                     {
     159                    for (Way wInner : polygon.getInnerWays()) {
    163160                        ElemStyle innerStyle = styles.get(wInner);
    164                         if(wayStyle != null && wayStyle.equals(innerStyle)) {
     161                        if (wayStyle != null && wayStyle.equals(innerStyle)) {
    165162                            List<OsmPrimitive> l = new ArrayList<OsmPrimitive>();
    166163                            l.add(r);
     
    170167                        }
    171168                    }
    172                     for (Way wOuter : polygon.getOuterWays())
    173                     {
     169                    for (Way wOuter : polygon.getOuterWays()) {
    174170                        ElemStyle outerStyle = styles.get(wOuter);
    175                         if(outerStyle instanceof AreaElemStyle && !wayStyle.equals(outerStyle)) {
     171                        if (outerStyle instanceof AreaElemStyle && !wayStyle.equals(outerStyle)) {
    176172                            List<OsmPrimitive> l = new ArrayList<OsmPrimitive>();
    177173                            l.add(r);
    178174                            l.add(wOuter);
    179                             errors.add( new TestError(this, Severity.WARNING, tr("Style for outer way mismatches"),
     175                            errors.add(new TestError(this, Severity.WARNING, tr("Style for outer way mismatches"),
    180176                            OUTER_STYLE_MISMATCH, l, Collections.singletonList(wOuter)));
    181177                        }
    182178                    }
    183179                }
    184                 else
    185                     errors.add( new TestError(this, Severity.OTHER, tr("No style for multipolygon"),
    186                     NO_STYLE, r));
     180                else {
     181                    errors.add(new TestError(this, Severity.OTHER, tr("No style for multipolygon"), NO_STYLE, r));
     182                }
    187183            }
    188184
    189185            if (!nonClosedWays.isEmpty()) {
    190                 errors.add( new TestError(this, Severity.WARNING, tr("Multipolygon is not closed"), NON_CLOSED_WAY,  Collections.singletonList(r), nonClosedWays));
     186                errors.add(new TestError(this, Severity.WARNING, tr("Multipolygon is not closed"), NON_CLOSED_WAY,  Collections.singletonList(r), nonClosedWays));
    191187            }
    192188
    193189            // For painting is used Polygon class which works with ints only. For validation we need more precision
    194190            List<GeneralPath> outerPolygons = createPolygons(outerWays);
    195             for (List<Node> pdInner: innerWays) {
     191            for (List<Node> pdInner : innerWays) {
    196192                boolean outside = true;
    197193                boolean crossing = false;
     
    221217
    222218    private void checkMembersAndRoles(Relation r) {
    223         for (RelationMember rm: r.getMembers()) {
     219        for (RelationMember rm : r.getMembers()) {
    224220            if (rm.isWay()) {
    225221                if (!("inner".equals(rm.getRole()) || "outer".equals(rm.getRole()) || !rm.hasRole())) {
    226                     errors.add( new TestError(this, Severity.WARNING, tr("No useful role for multipolygon member"), WRONG_MEMBER_ROLE, rm.getMember()));
     222                    errors.add(new TestError(this, Severity.WARNING, tr("No useful role for multipolygon member"), WRONG_MEMBER_ROLE, rm.getMember()));
    227223                }
    228224            } else {
    229                 errors.add( new TestError(this, Severity.WARNING, tr("Non-Way in multipolygon"), WRONG_MEMBER_TYPE, rm.getMember()));
    230             }
    231         }
    232     }
    233 
    234 
     225                errors.add(new TestError(this, Severity.WARNING, tr("Non-Way in multipolygon"), WRONG_MEMBER_TYPE, rm.getMember()));
     226            }
     227        }
     228    }
    235229}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/NameMismatch.java

    r3669 r3671  
    7272        if (name == null) {
    7373            errors.add(new TestError(this, Severity.OTHER,
    74                 tr("A name is missing, even though name:* exists."),
    75                                      NAME_MISSING, p));
     74                    tr("A name is missing, even though name:* exists."),
     75                    NAME_MISSING, p));
    7676        return;
    7777    }
     
    105105    @Override public void visit(Collection<OsmPrimitive> selection) {
    106106        for (OsmPrimitive p : selection)
    107             if (!p.isDeleted() && !p.isIncomplete())
     107            if (!p.isDeleted() && !p.isIncomplete()) {
    108108                check(p);
     109            }
    109110    }
    110111}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/NodesWithSameName.java

    r3669 r3671  
    99import java.util.HashSet;
    1010import java.util.ArrayList;
    11 
    1211
    1312import org.openstreetmap.josm.data.osm.Node;
     
    3938        String highway = n.get("highway");
    4039        if (name == null
    41             || (sign != null && sign.equals("city_limit"))
    42             || (highway != null && highway.equals("bus_stop"))) {
     40                || (sign != null && sign.equals("city_limit"))
     41                || (highway != null && highway.equals("bus_stop")))
    4342            return;
    44         }
    4543
    4644        List<Node> nodes = namesToNodes.get(name);
    47         if (nodes == null)
     45        if (nodes == null) {
    4846            namesToNodes.put(name, nodes = new ArrayList<Node>());
     47        }
    4948
    5049        nodes.add(n);
     
    6160                    if (ref == null || !refs.add(ref)) {
    6261                        errors.add(new TestError(this, Severity.OTHER,
    63                             tr("Nodes with same name"), SAME_NAME, nodes));
     62                                tr("Nodes with same name"), SAME_NAME, nodes));
    6463                        break;
    6564                    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r3669 r3671  
    2626 * @author frsantos
    2727 */
    28 public class OverlappingWays extends Test
    29 {
     28public class OverlappingWays extends Test {
     29   
    3030    /** Bag of all way segments */
    3131    Bag<Pair<Node,Node>, WaySegment> nodePairs;
     
    4040
    4141    /** Constructor */
    42     public OverlappingWays()
    43     {
     42    public OverlappingWays() {
    4443        super(tr("Overlapping ways."),
    4544              tr("This test checks that a connection between two nodes "
    4645                + "is not used by more than one way."));
    47 
    4846    }
    4947
    50 
    5148    @Override
    52     public void startTest(ProgressMonitor monitor)
    53     {
     49    public void startTest(ProgressMonitor monitor)  {
    5450        super.startTest(monitor);
    5551        nodePairs = new Bag<Pair<Node,Node>, WaySegment>(1000);
     
    5753
    5854    @Override
    59     public void endTest()
    60     {
     55    public void endTest() {
    6156        Map<List<Way>, List<WaySegment>> ways_seen = new HashMap<List<Way>, List<WaySegment>>(500);
    6257
    63         for (List<WaySegment> duplicated : nodePairs.values())
    64         {
     58        for (List<WaySegment> duplicated : nodePairs.values()) {
    6559            int ways = duplicated.size();
    6660
    67             if (ways > 1)
    68             {
     61            if (ways > 1) {
    6962                List<OsmPrimitive> prims = new ArrayList<OsmPrimitive>();
    7063                List<Way> current_ways = new ArrayList<Way>();
     
    7467                int area = 0;
    7568
    76                 for (WaySegment ws : duplicated)
    77                 {
    78                     if (ws.way.get("highway") != null)
     69                for (WaySegment ws : duplicated) {
     70                    if (ws.way.get("highway") != null) {
    7971                        highway++;
    80                     else if (ws.way.get("railway") != null)
     72                    } else if (ws.way.get("railway") != null) {
    8173                        railway++;
     74                    }
    8275                    Boolean ar = OsmUtils.getOsmBoolean(ws.way.get("area"));
    83                     if (ar != null && ar)
     76                    if (ar != null && ar) {
    8477                        area++;
    85                     if (ws.way.get("landuse") != null || ws.way.get("natural") != null
    86                     || ws.way.get("amenity") != null || ws.way.get("leisure") != null
    87                     || ws.way.get("building") != null)
    88                     {
    89                         area++; ways--;
     78                    }
     79                    if (ws.way.get("landuse") != null
     80                            || ws.way.get("natural") != null
     81                            || ws.way.get("amenity") != null
     82                            || ws.way.get("leisure") != null
     83                            || ws.way.get("building") != null) {
     84                        area++;
     85                        ways--;
    9086                    }
    9187
     
    9793                 * highways or railways mark a separate error
    9894                 */
    99                 if ((highlight = ways_seen.get(current_ways)) == null)
    100                 {
     95                if ((highlight = ways_seen.get(current_ways)) == null) {
    10196                    String errortype;
    10297                    int type;
    10398
    104                     if(area > 0)
    105                     {
    106                         if (ways == 0 || duplicated.size() == area)
    107                         {
     99                    if (area > 0) {
     100                        if (ways == 0 || duplicated.size() == area) {
    108101                            errortype = tr("Overlapping areas");
    109102                            type = OVERLAPPING_AREA;
    110                         }
    111                         else if (highway == ways)
    112                         {
     103                        } else if (highway == ways) {
    113104                            errortype = tr("Overlapping highways (with area)");
    114105                            type = OVERLAPPING_HIGHWAY_AREA;
    115                         }
    116                         else if (railway == ways)
    117                         {
     106                        } else if (railway == ways) {
    118107                            errortype = tr("Overlapping railways (with area)");
    119108                            type = OVERLAPPING_RAILWAY_AREA;
    120                         }
    121                         else
    122                         {
     109                        } else {
    123110                            errortype = tr("Overlapping ways (with area)");
    124111                            type = OVERLAPPING_WAY_AREA;
    125112                        }
    126113                    }
    127                     else if (highway == ways)
    128                     {
     114                    else if (highway == ways) {
    129115                        errortype = tr("Overlapping highways");
    130116                        type = OVERLAPPING_HIGHWAY;
    131                     }
    132                     else if (railway == ways)
    133                     {
     117                    } else if (railway == ways) {
    134118                        errortype = tr("Overlapping railways");
    135119                        type = OVERLAPPING_RAILWAY;
    136                     }
    137                     else
    138                     {
     120                    } else {
    139121                        errortype = tr("Overlapping ways");
    140122                        type = OVERLAPPING_WAY;
    141123                    }
    142124
    143                     errors.add(new TestError(this, type < OVERLAPPING_HIGHWAY_AREA
    144                     ? Severity.WARNING : Severity.OTHER, tr(errortype), type, prims, duplicated));
     125                    errors.add(new TestError(this,
     126                            type < OVERLAPPING_HIGHWAY_AREA ? Severity.WARNING : Severity.OTHER,
     127                            tr(errortype), type, prims, duplicated));
    145128                    ways_seen.put(current_ways, duplicated);
    146                 }
    147                 else    /* way seen, mark highlight layer only */
    148                 {
    149                     for (WaySegment ws : duplicated)
     129                } else { /* way seen, mark highlight layer only */
     130                    for (WaySegment ws : duplicated) {
    150131                        highlight.add(ws);
     132                    }
    151133                }
    152134            }
     
    157139
    158140    @Override
    159     public void visit(Way w)
    160     {
     141    public void visit(Way w) {
    161142        Node lastN = null;
    162143        int i = -2;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java

    r3669 r3671  
    2323 *
    2424 */
    25 public class RelationChecker extends Test
    26 {
     25public class RelationChecker extends Test {
     26
    2727    protected static int ROLE_UNKNOWN      = 1701;
    2828    protected static int ROLE_EMPTY        = 1702;
     
    3737     * Constructor
    3838     */
    39     public RelationChecker()
    40     {
     39    public RelationChecker() {
    4140        super(tr("Relation checker :"),
    4241                tr("This plugin checks for errors in relations."));
     
    4443
    4544    @Override
    46     public void initialize() throws Exception
    47     {
     45    public void initialize() throws Exception {
    4846        initializePresets();
    4947    }
    5048
    5149    static Collection<TaggingPreset> relationpresets = new LinkedList<TaggingPreset>();
     50
    5251    /**
    5352     * Reads the presets data.
    5453     *
    5554     */
    56     public void initializePresets()
    57     {
     55    public void initializePresets() {
    5856        Collection<TaggingPreset> presets = TaggingPresetPreference.taggingPresets;
    59         if(presets != null)
    60         {
    61             for(TaggingPreset p : presets)
    62             {
    63                 for(TaggingPreset.Item i : p.data)
    64                 {
    65                     if(i instanceof TaggingPreset.Roles)
    66                     {
     57        if (presets != null) {
     58            for (TaggingPreset p : presets) {
     59                for (TaggingPreset.Item i : p.data) {
     60                    if (i instanceof TaggingPreset.Roles) {
    6761                        relationpresets.add(p);
    6862                        break;
     
    7367    }
    7468
    75     public class RoleInfo
    76     {
     69    public class RoleInfo {
    7770        int total = 0;
    7871        int nodes = 0;
     
    8477
    8578    @Override
    86     public void visit(Relation n)
    87     {
     79    public void visit(Relation n) {
    8880        LinkedList<TaggingPreset.Role> allroles = new LinkedList<TaggingPreset.Role>();
    89         for(TaggingPreset p : relationpresets)
    90         {
     81        for (TaggingPreset p : relationpresets) {
    9182            boolean matches = true;
    9283            TaggingPreset.Roles r = null;
    93             for(TaggingPreset.Item i : p.data)
    94             {
    95                 if(i instanceof TaggingPreset.Key)
    96                 {
    97                     TaggingPreset.Key k = (TaggingPreset.Key)i;
    98                     if(!k.value.equals(n.get(k.key)))
    99                     {
     84            for (TaggingPreset.Item i : p.data) {
     85                if (i instanceof TaggingPreset.Key) {
     86                    TaggingPreset.Key k = (TaggingPreset.Key) i;
     87                    if (!k.value.equals(n.get(k.key))) {
    10088                        matches = false;
    10189                        break;
    10290                    }
     91                } else if (i instanceof TaggingPreset.Roles) {
     92                    r = (TaggingPreset.Roles) i;
    10393                }
    104                 else if(i instanceof TaggingPreset.Roles)
    105                     r = (TaggingPreset.Roles) i;
    10694            }
    107             if(matches && r != null)
     95            if (matches && r != null) {
    10896                allroles.addAll(r.roles);
     97            }
    10998        }
    110         if(allroles.size() == 0)
    111         {
     99        if (allroles.size() == 0) {
    112100            errors.add( new TestError(this, Severity.WARNING, tr("Relation type is unknown"),
    113101                    RELATION_UNKNOWN, n) );
    114 
    115         }
    116         else
    117         {
     102        } else {
    118103            HashMap<String,RoleInfo> map = new HashMap<String, RoleInfo>();
    119             for(RelationMember m : n.getMembers()) {
     104            for (RelationMember m : n.getMembers()) {
    120105                String s = "";
    121                 if(m.hasRole())
     106                if (m.hasRole()) {
    122107                    s = m.getRole();
     108                }
    123109                RoleInfo ri = map.get(s);
    124                 if(ri == null)
     110                if (ri == null) {
    125111                    ri = new RoleInfo();
     112                }
    126113                ri.total++;
    127                 if(m.isRelation())
     114                if (m.isRelation()) {
    128115                    ri.relations++;
    129                 else if(m.isWay())
    130                 {
     116                } else if(m.isWay()) {
    131117                    ri.ways++;
    132                     if(m.getWay().isClosed())
     118                    if (m.getWay().isClosed()) {
    133119                        ri.closedways++;
    134                     else
     120                    } else {
    135121                        ri.openways++;
     122                    }
    136123                }
    137                 else if(m.isNode())
     124                else if (m.isNode()) {
    138125                    ri.nodes++;
     126                }
    139127                map.put(s, ri);
    140128            }
    141             if(map.size() == 0)
     129            if(map.isEmpty()) {
    142130                errors.add( new TestError(this, Severity.ERROR, tr("Relation is empty"),
    143131                        RELATION_EMPTY, n) );
    144             else
    145             {
     132            } else {
    146133                LinkedList<String> done = new LinkedList<String>();
    147                 for(TaggingPreset.Role r : allroles)
    148                 {
     134                for (TaggingPreset.Role r : allroles) {
    149135                    done.add(r.key);
    150136                    String keyname = r.key;
    151                     if(keyname == "")
     137                    if (keyname == "") { //FIXME
    152138                        keyname = tr("<empty>");
     139                    }
    153140                    RoleInfo ri = map.get(r.key);
    154141                    long count = (ri == null) ? 0 : ri.total;
    155142                    long vc = r.getValidCount(count);
    156                     if(count != vc)
    157                     {
    158                         if(count == 0)
    159                         {
     143                    if (count != vc) {
     144                        if (count == 0) {
    160145                            String s = marktr("Role {0} missing");
    161146                            errors.add( new TestError(this, Severity.WARNING, tr("Role verification problem"),
    162147                                    tr(s, keyname), MessageFormat.format(s, keyname), ROLE_MISSING, n) );
    163148                        }
    164                         else if(vc > count)
    165                         {
     149                        else if (vc > count) {
    166150                            String s = marktr("Number of {0} roles too low ({1})");
    167151                            errors.add( new TestError(this, Severity.WARNING, tr("Role verification problem"),
    168152                                    tr(s, keyname, count), MessageFormat.format(s, keyname, count), LOW_COUNT, n) );
    169                         }
    170                         else
    171                         {
     153                        } else {
    172154                            String s = marktr("Number of {0} roles too high ({1})");
    173155                            errors.add( new TestError(this, Severity.WARNING, tr("Role verification problem"),
     
    175157                        }
    176158                    }
    177                     if(ri != null && ((!r.types.contains(PresetType.WAY) && (r.types.contains(PresetType.CLOSEDWAY) ? ri.openways > 0 : ri.ways > 0))
     159                    if (ri != null && ((!r.types.contains(PresetType.WAY) && (r.types.contains(PresetType.CLOSEDWAY) ? ri.openways > 0 : ri.ways > 0))
    178160                            || (!r.types.contains(PresetType.NODE) && ri.nodes > 0) || (!r.types.contains(PresetType.RELATION) && ri.relations > 0)))
    179161                    {
     
    183165                    }
    184166                }
    185                 for(String key : map.keySet())
    186                 {
    187                     if(!done.contains(key))
    188                     {
    189                         if(key.length() > 0)
    190                         {
     167                for (String key : map.keySet()) {
     168                    if (!done.contains(key)) {
     169                        if (key.length() > 0) {
    191170                            String s = marktr("Role {0} unknown");
    192                             errors.add( new TestError(this, Severity.WARNING, tr("Role verification problem"),
    193                                     tr(s, key), MessageFormat.format(s, key), ROLE_UNKNOWN, n) );
    194                         }
    195                         else
    196                         {
     171                            errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"),
     172                                    tr(s, key), MessageFormat.format(s, key), ROLE_UNKNOWN, n));
     173                        } else {
    197174                            String s = marktr("Empty role found");
    198                             errors.add( new TestError(this, Severity.WARNING, tr("Role verification problem"),
    199                                     tr(s), s, ROLE_EMPTY, n) );
     175                            errors.add(new TestError(this, Severity.WARNING, tr("Role verification problem"),
     176                                    tr(s), s, ROLE_EMPTY, n));
    200177                        }
    201178                    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWay.java

    r3669 r3671  
    1717 */
    1818public class SelfIntersectingWay extends Test {
     19   
    1920    protected static int SELF_INTERSECT = 401;
    2021
  • trunk/src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java

    r3669 r3671  
    2525 * @author frsantos
    2626 */
    27 public class SimilarNamedWays extends Test
    28 {
     27public class SimilarNamedWays extends Test {
     28
    2929    protected static int SIMILAR_NAMED = 701;
    3030
     
    3737     * Constructor
    3838     */
    39     public SimilarNamedWays()
    40     {
     39    public SimilarNamedWays() {
    4140        super(tr("Similarly named ways")+".",
    4241              tr("This test checks for ways with similar names that may have been misspelled."));
     
    4443
    4544    @Override
    46     public void startTest(ProgressMonitor monitor)
    47     {
     45    public void startTest(ProgressMonitor monitor) {
    4846        super.startTest(monitor);
    4947        cellWays = new HashMap<Point2D,List<Way>>(1000);
     
    5250
    5351    @Override
    54     public void endTest()
    55     {
     52    public void endTest() {
    5653        cellWays = null;
    5754        errorWays = null;
     
    6057
    6158    @Override
    62     public void visit(Way w)
    63     {
    64         if( !w.isUsable() )
     59    public void visit(Way w) {
     60        if (!w.isUsable())
    6561            return;
    6662
    6763        String name = w.get("name");
    68         if( name == null || name.length() < 6 )
     64        if (name == null || name.length() < 6)
    6965            return;
    7066
    7167        List<List<Way>> theCellWays = ValUtil.getWaysInCell(w, cellWays);
    72         for( List<Way> ways : theCellWays)
    73         {
    74             for( Way w2 : ways)
    75             {
    76                 if( errorWays.contains(w, w2) || errorWays.contains(w2, w) )
     68        for (List<Way> ways : theCellWays) {
     69            for (Way w2 : ways) {
     70                if (errorWays.contains(w, w2) || errorWays.contains(w2, w)) {
    7771                    continue;
     72                }
    7873
    7974                String name2 = w2.get("name");
    80                 if( name2 == null || name2.length() < 6 )
     75                if (name2 == null || name2.length() < 6) {
    8176                    continue;
     77                }
    8278
    8379                int levenshteinDistance = getLevenshteinDistance(name, name2);
    84                 if( 0 < levenshteinDistance && levenshteinDistance <= 2 )
    85                 {
     80                if (0 < levenshteinDistance && levenshteinDistance <= 2) {
    8681                    List<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>();
    8782                    primitives.add(w);
    8883                    primitives.add(w2);
    89                     errors.add( new TestError(this, Severity.WARNING, tr("Similarly named ways"), SIMILAR_NAMED, primitives) );
     84                    errors.add(new TestError(this, Severity.WARNING, tr("Similarly named ways"), SIMILAR_NAMED, primitives));
    9085                    errorWays.add(w, w2);
    9186                }
     
    10297     * @return The distance between words
    10398     */
    104     public int getLevenshteinDistance(String s, String t)
    105     {
     99    public int getLevenshteinDistance(String s, String t) {
    106100        int d[][]; // matrix
    107101        int n; // length of s
     
    114108
    115109        // Step 1
    116 
    117110        n = s.length();
    118111        m = t.length();
    119         if (n == 0) return m;
    120         if (m == 0) return n;
     112        if (n == 0)
     113            return m;
     114        if (m == 0)
     115            return n;
    121116        d = new int[n + 1][m + 1];
    122117
    123118        // Step 2
    124         for (i = 0; i <= n; i++) d[i][0] = i;
    125         for (j = 0; j <= m; j++) d[0][j] = j;
     119        for (i = 0; i <= n; i++) {
     120            d[i][0] = i;
     121        }
     122        for (j = 0; j <= m; j++) {
     123            d[0][j] = j;
     124        }
    126125
    127126        // Step 3
    128         for (i = 1; i <= n; i++)
    129         {
     127        for (i = 1; i <= n; i++) {
     128
    130129            s_i = s.charAt(i - 1);
    131130
    132131            // Step 4
    133             for (j = 1; j <= m; j++)
    134             {
     132            for (j = 1; j <= m; j++) {
     133
    135134                t_j = t.charAt(j - 1);
    136135
    137136                // Step 5
    138                 if (s_i == t_j)
    139                 {
     137                if (s_i == t_j) {
    140138                    cost = 0;
    141                 }
    142                 else
    143                 {
     139                } else {
    144140                    cost = 1;
    145141                }
    146142
    147143                // Step 6
    148                 d[i][j] = Minimum(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
     144                d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
    149145            }
    150146        }
     
    154150    }
    155151
    156     /**
     152    /** // FIXME: move to utils
    157153     * Get minimum of three values
    158154     * @param a First value
    159155     * @param b Second value
    160156     * @param c Third value
    161      * @return The minimum of the tre values
     157     * @return The minimum of the three values
    162158     */
    163     private static int Minimum(int a, int b, int c)
    164     {
     159    private static int min(int a, int b, int c) {
    165160        int mi = a;
    166         if (b < mi)
    167         {
     161        if (b < mi) {
    168162            mi = b;
    169         }
    170         if (c < mi)
    171         {
     163        } if (c < mi) {
    172164            mi = c;
    173165        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r3669 r3671  
    141141
    142142    /** List of sources for spellcheck data */
    143     protected JList Sources;
    144 
     143    protected JList sourcesList;
    145144
    146145    protected static Entities entities = new Entities();
     146
    147147    /**
    148148     * Constructor
    149149     */
    150     public TagChecker()
    151     {
     150    public TagChecker() {
    152151        super(tr("Properties checker :"),
    153152                tr("This plugin checks for errors in property keys and values."));
     
    155154
    156155    @Override
    157     public void initialize() throws Exception
    158     {
     156    public void initialize() throws Exception {
    159157        initializeData();
    160158        initializePresets();
     
    170168     * @throws IOException
    171169     */
    172     private static void initializeData() throws IOException
    173     {
     170    private static void initializeData() throws IOException {
    174171        spellCheckKeyData = new HashMap<String, String>();
    175172        String sources = Main.pref.get( PREF_SOURCES, "");
    176         if(Main.pref.getBoolean(PREF_USE_DATA_FILE, true))
    177         {
    178             if( sources == null || sources.length() == 0)
     173        if (Main.pref.getBoolean(PREF_USE_DATA_FILE, true)) {
     174            if (sources == null || sources.length() == 0) {
    179175                sources = DATA_FILE;
    180             else
     176            } else {
    181177                sources = DATA_FILE + ";" + sources;
    182         }
    183         if(Main.pref.getBoolean(PREF_USE_IGNORE_FILE, true))
    184         {
    185             if( sources == null || sources.length() == 0)
     178            }
     179        }
     180        if (Main.pref.getBoolean(PREF_USE_IGNORE_FILE, true)) {
     181            if (sources == null || sources.length() == 0) {
    186182                sources = IGNORE_FILE;
    187             else
     183            } else {
    188184                sources = IGNORE_FILE + ";" + sources;
    189         }
    190         if(Main.pref.getBoolean(PREF_USE_SPELL_FILE, true))
    191         {
    192             if( sources == null || sources.length() == 0)
     185            }
     186        }
     187        if (Main.pref.getBoolean(PREF_USE_SPELL_FILE, true)) {
     188            if( sources == null || sources.length() == 0) {
    193189                sources = SPELL_FILE;
    194             else
     190            } else {
    195191                sources = SPELL_FILE + ";" + sources;
     192            }
    196193        }
    197194
    198195        String errorSources = "";
    199         if(sources.length() == 0)
     196        if (sources.length() == 0)
    200197            return;
    201         for(String source: sources.split(";"))
    202         {
    203             try
    204             {
     198        for (String source : sources.split(";")) {
     199            try {
    205200                MirroredInputStream s = new MirroredInputStream(source, ValUtil.getPluginDir(), -1);
    206201                InputStreamReader r;
    207                 try
    208                 {
     202                try {
    209203                    r = new InputStreamReader(s, "UTF-8");
    210                 }
    211                 catch (UnsupportedEncodingException e)
    212                 {
     204                } catch (UnsupportedEncodingException e) {
    213205                    r = new InputStreamReader(s);
    214206                }
     
    219211                boolean ignorefile = false;
    220212                String line;
    221                 while((line = reader.readLine()) != null && (tagcheckerfile || line.length() != 0))
    222                 {
    223                     if(line.startsWith("#"))
    224                     {
    225                         if(line.startsWith("# JOSM TagChecker"))
     213                while ((line = reader.readLine()) != null && (tagcheckerfile || line.length() != 0)) {
     214                    if (line.startsWith("#")) {
     215                        if (line.startsWith("# JOSM TagChecker")) {
    226216                            tagcheckerfile = true;
    227                         if(line.startsWith("# JOSM IgnoreTags"))
     217                        }
     218                        if (line.startsWith("# JOSM IgnoreTags")) {
    228219                            ignorefile = true;
     220                        }
    229221                        continue;
    230                     }
    231                     else if(ignorefile)
    232                     {
     222                    } else if (ignorefile) {
    233223                        line = line.trim();
    234                         if(line.length() < 4)
     224                        if (line.length() < 4) {
    235225                            continue;
     226                        }
    236227
    237228                        String key = line.substring(0, 2);
    238229                        line = line.substring(2);
    239230
    240                         if(key.equals("S:"))
    241                         {
     231                        if (key.equals("S:")) {
    242232                            ignoreDataStartsWith.add(line);
    243                         }
    244                         else if(key.equals("E:"))
    245                         {
     233                        } else if (key.equals("E:")) {
    246234                            ignoreDataEquals.add(line);
    247                         }
    248                         else if(key.equals("F:"))
    249                         {
     235                        } else if (key.equals("F:")) {
    250236                            ignoreDataEndsWith.add(line);
    251                         }
    252                         else if(key.equals("K:"))
    253                         {
     237                        } else if (key.equals("K:")) {
    254238                            IgnoreKeyPair tmp = new IgnoreKeyPair();
    255239                            int mid = line.indexOf("=");
     
    257241                            tmp.value = line.substring(mid+1);
    258242                            ignoreDataKeyPair.add(tmp);
    259                         }
    260                         else if(key.equals("T:"))
    261                         {
     243                        } else if (key.equals("T:")) {
    262244                            IgnoreTwoKeyPair tmp = new IgnoreTwoKeyPair();
    263245                            int mid = line.indexOf("=");
     
    272254                        }
    273255                        continue;
    274                     }
    275                     else if(tagcheckerfile)
    276                     {
    277                         if(line.length() > 0)
    278                         {
     256                    } else if (tagcheckerfile) {
     257                        if (line.length() > 0) {
    279258                            CheckerData d = new CheckerData();
    280259                            String err = d.getData(line);
    281260
    282                             if(err == null)
     261                            if (err == null) {
    283262                                checkerData.add(d);
    284                             else
     263                            } else {
    285264                                System.err.println(tr("Invalid tagchecker line - {0}: {1}", err, line));
    286                         }
    287                     }
    288                     else if(line.charAt(0) == '+')
    289                     {
     265                            }
     266                        }
     267                    } else if (line.charAt(0) == '+') {
    290268                        okValue = line.substring(1);
    291                     }
    292                     else if(line.charAt(0) == '-' && okValue != null)
    293                     {
     269                    } else if (line.charAt(0) == '-' && okValue != null) {
    294270                        spellCheckKeyData.put(line.substring(1), okValue);
    295                     }
    296                     else
    297                     {
     271                    } else {
    298272                        System.err.println(tr("Invalid spellcheck line: {0}", line));
    299273                    }
    300274                }
    301             }
    302             catch (IOException e)
    303             {
     275            } catch (IOException e) {
    304276                errorSources += source + "\n";
    305277            }
    306278        }
    307279
    308         if( errorSources.length() > 0 )
     280        if (errorSources.length() > 0)
    309281            throw new IOException( tr("Could not access data file(s):\n{0}", errorSources) );
    310282    }
     
    315287     * @throws Exception
    316288     */
    317     public static void initializePresets() throws Exception
    318     {
    319         if( !Main.pref.getBoolean(PREF_CHECK_VALUES, true) )
     289    public static void initializePresets() throws Exception {
     290
     291        if (!Main.pref.getBoolean(PREF_CHECK_VALUES, true))
    320292            return;
    321293
    322294        Collection<TaggingPreset> presets = TaggingPresetPreference.taggingPresets;
    323         if(presets != null)
    324         {
     295        if (presets != null) {
    325296            presetsValueData = new Bag<String, String>();
    326             for(String a : OsmPrimitive.getUninterestingKeys())
     297            for (String a : OsmPrimitive.getUninterestingKeys()) {
    327298                presetsValueData.add(a);
     299            }
    328300            // TODO directionKeys are no longer in OsmPrimitive (search pattern is used instead)
    329301            /*  for(String a : OsmPrimitive.getDirectionKeys())
    330302                presetsValueData.add(a);
    331303             */
    332             for(String a : Main.pref.getCollection(ValidatorPreference.PREFIX + ".knownkeys",
    333                     Arrays.asList(new String[]{"is_in", "int_ref", "fixme", "population"})))
     304            for (String a : Main.pref.getCollection(ValidatorPreference.PREFIX + ".knownkeys",
     305                    Arrays.asList(new String[]{"is_in", "int_ref", "fixme", "population"}))) {
    334306                presetsValueData.add(a);
    335             for(TaggingPreset p : presets)
    336             {
    337                 for(TaggingPreset.Item i : p.data)
    338                 {
    339                     if(i instanceof TaggingPreset.Combo)
    340                     {
     307            }
     308            for (TaggingPreset p : presets) {
     309                for(TaggingPreset.Item i : p.data) {
     310                    if (i instanceof TaggingPreset.Combo) {
    341311                        TaggingPreset.Combo combo = (TaggingPreset.Combo) i;
    342                         if(combo.values != null)
    343                         {
    344                             for(String value : combo.values.split(","))
     312                        if (combo.values != null) {
     313                            for(String value : combo.values.split(",")) {
    345314                                presetsValueData.add(combo.key, value);
    346                         }
    347                     }
    348                     else if(i instanceof TaggingPreset.Key)
    349                     {
     315                            }
     316                        }
     317                    } else if (i instanceof TaggingPreset.Key) {
    350318                        TaggingPreset.Key k = (TaggingPreset.Key) i;
    351319                        presetsValueData.add(k.key, k.value);
    352                     }
    353                     else if(i instanceof TaggingPreset.Text)
    354                     {
     320                    } else if (i instanceof TaggingPreset.Text) {
    355321                        TaggingPreset.Text k = (TaggingPreset.Text) i;
    356322                        presetsValueData.add(k.key);
    357                     }
    358                     else if(i instanceof TaggingPreset.Check)
    359                     {
     323                    } else if (i instanceof TaggingPreset.Check) {
    360324                        TaggingPreset.Check k = (TaggingPreset.Check) i;
    361325                        presetsValueData.add(k.key, "yes");
     
    368332
    369333    @Override
    370     public void visit(Node n)
    371     {
     334    public void visit(Node n) {
    372335        checkPrimitive(n);
    373336    }
    374337
    375 
    376338    @Override
    377     public void visit(Relation n)
    378     {
     339    public void visit(Relation n) {
    379340        checkPrimitive(n);
    380341    }
    381342
    382 
    383343    @Override
    384     public void visit(Way w)
    385     {
     344    public void visit(Way w) {
    386345        checkPrimitive(w);
    387346    }
     
    392351     */
    393352    private boolean containsLow(String s) {
    394         if (s==null) return false;
    395         for(int i=0;i<s.length();i++) {
    396             if (s.charAt(i)<0x20) return true;
     353        if (s == null)
     354            return false;
     355        for (int i = 0; i < s.length(); i++) {
     356            if (s.charAt(i) < 0x20)
     357                return true;
    397358        }
    398359        return false;
     
    403364     * @param p The primitive to check
    404365     */
    405     private void checkPrimitive(OsmPrimitive p)
    406     {
     366    private void checkPrimitive(OsmPrimitive p) {
    407367        // Just a collection to know if a primitive has been already marked with error
    408368        Bag<OsmPrimitive, String> withErrors = new Bag<OsmPrimitive, String>();
    409369
    410         if(checkComplex)
    411         {
     370        if (checkComplex) {
    412371            Map<String, String> props = (p.getKeys() == null) ? Collections.<String, String>emptyMap() : p.getKeys();
    413             for(Entry<String, String> prop: props.entrySet() )
    414             {
     372            for (Entry<String, String> prop : props.entrySet()) {
    415373                boolean ignore = true;
    416374                String key1 = prop.getKey();
    417375                String value1 = prop.getValue();
    418376
    419                 for(IgnoreTwoKeyPair a : ignoreDataTwoKeyPair)
    420                 {
    421                     if(key1.equals(a.key1) && value1.equals(a.value1))
    422                     {
     377                for (IgnoreTwoKeyPair a : ignoreDataTwoKeyPair) {
     378                    if (key1.equals(a.key1) && value1.equals(a.value1)) {
    423379                        ignore = false;
    424                         for(Entry<String, String> prop2: props.entrySet() )
    425                         {
     380                        for (Entry<String, String> prop2 : props.entrySet()) {
    426381                            String key2 = prop2.getKey();
    427382                            String value2 = prop2.getValue();
    428                             for(IgnoreTwoKeyPair b : ignoreDataTwoKeyPair)
    429                             {
    430                                 if(key2.equals(b.key2) && value2.equals(b.value2))
    431                                 {
     383                            for (IgnoreTwoKeyPair b : ignoreDataTwoKeyPair) {
     384                                if (key2.equals(b.key2) && value2.equals(b.value2)) {
    432385                                    ignore = true;
    433386                                    break;
    434387                                }
    435388                            }
    436                             if(ignore)
     389                            if (ignore) {
    437390                                break;
    438                         }
    439                     }
    440                     if(ignore)
     391                            }
     392                        }
     393                    }
     394                    if (ignore) {
    441395                        break;
    442                 }
    443 
    444                 if(!ignore)
    445                 {
     396                    }
     397                }
     398
     399                if (!ignore) {
    446400                    errors.add( new TestError(this, Severity.ERROR, tr("Illegal tag/value combinations"),
    447401                            tr("Illegal tag/value combinations"), tr("Illegal tag/value combinations"), 1272, p) );
     
    451405
    452406            Map<String, String> keys = p.getKeys();
    453             for(CheckerData d : checkerData)
    454             {
    455                 if(d.match(p, keys))
    456                 {
     407            for (CheckerData d : checkerData) {
     408                if (d.match(p, keys)) {
    457409                    errors.add( new TestError(this, d.getSeverity(), tr("Illegal tag/value combinations"),
    458410                            d.getDescription(), d.getDescriptionOrig(), d.getCode(), p) );
     
    463415
    464416        Map<String, String> props = (p.getKeys() == null) ? Collections.<String, String>emptyMap() : p.getKeys();
    465         for(Entry<String, String> prop: props.entrySet() )
    466         {
     417        for (Entry<String, String> prop : props.entrySet()) {
    467418            String s = marktr("Key ''{0}'' invalid.");
    468419            String key = prop.getKey();
    469420            String value = prop.getValue();
    470             if( checkValues && (containsLow(value)) && !withErrors.contains(p, "ICV"))
    471             {
     421            if (checkValues && (containsLow(value)) && !withErrors.contains(p, "ICV")) {
    472422                errors.add( new TestError(this, Severity.WARNING, tr("Tag value contains character with code less than 0x20"),
    473423                        tr(s, key), MessageFormat.format(s, key), LOW_CHAR_VALUE, p) );
    474424                withErrors.add(p, "ICV");
    475425            }
    476             if( checkKeys && (containsLow(key)) && !withErrors.contains(p, "ICK"))
    477             {
     426            if (checkKeys && (containsLow(key)) && !withErrors.contains(p, "ICK")) {
    478427                errors.add( new TestError(this, Severity.WARNING, tr("Tag key contains character with code less than 0x20"),
    479428                        tr(s, key), MessageFormat.format(s, key), LOW_CHAR_KEY, p) );
    480429                withErrors.add(p, "ICK");
    481430            }
    482             if( checkValues && (value!=null && value.length() > 255) && !withErrors.contains(p, "LV"))
    483             {
     431            if (checkValues && (value!=null && value.length() > 255) && !withErrors.contains(p, "LV")) {
    484432                errors.add( new TestError(this, Severity.ERROR, tr("Tag value longer than allowed"),
    485433                        tr(s, key), MessageFormat.format(s, key), LONG_VALUE, p) );
    486434                withErrors.add(p, "LV");
    487435            }
    488             if( checkKeys && (key!=null && key.length() > 255) && !withErrors.contains(p, "LK"))
    489             {
     436            if (checkKeys && (key!=null && key.length() > 255) && !withErrors.contains(p, "LK")) {
    490437                errors.add( new TestError(this, Severity.ERROR, tr("Tag key longer than allowed"),
    491438                        tr(s, key), MessageFormat.format(s, key), LONG_KEY, p) );
    492439                withErrors.add(p, "LK");
    493440            }
    494             if( checkValues && (value==null || value.trim().length() == 0) && !withErrors.contains(p, "EV"))
    495             {
     441            if (checkValues && (value==null || value.trim().length() == 0) && !withErrors.contains(p, "EV")) {
    496442                errors.add( new TestError(this, Severity.WARNING, tr("Tags with empty values"),
    497443                        tr(s, key), MessageFormat.format(s, key), EMPTY_VALUES, p) );
    498444                withErrors.add(p, "EV");
    499445            }
    500             if( checkKeys && spellCheckKeyData.containsKey(key) && !withErrors.contains(p, "IPK"))
    501             {
     446            if (checkKeys && spellCheckKeyData.containsKey(key) && !withErrors.contains(p, "IPK")) {
    502447                errors.add( new TestError(this, Severity.WARNING, tr("Invalid property key"),
    503448                        tr(s, key), MessageFormat.format(s, key), INVALID_KEY, p) );
    504449                withErrors.add(p, "IPK");
    505450            }
    506             if( checkKeys && key.indexOf(" ") >= 0 && !withErrors.contains(p, "IPK"))
    507             {
     451            if (checkKeys && key.indexOf(" ") >= 0 && !withErrors.contains(p, "IPK")) {
    508452                errors.add( new TestError(this, Severity.WARNING, tr("Invalid white space in property key"),
    509453                        tr(s, key), MessageFormat.format(s, key), INVALID_KEY_SPACE, p) );
    510454                withErrors.add(p, "IPK");
    511455            }
    512             if( checkValues && value != null && (value.startsWith(" ") || value.endsWith(" ")) && !withErrors.contains(p, "SPACE"))
    513             {
     456            if (checkValues && value != null && (value.startsWith(" ") || value.endsWith(" ")) && !withErrors.contains(p, "SPACE")) {
    514457                errors.add( new TestError(this, Severity.OTHER, tr("Property values start or end with white space"),
    515458                        tr(s, key), MessageFormat.format(s, key), INVALID_SPACE, p) );
    516459                withErrors.add(p, "SPACE");
    517460            }
    518             if( checkValues && value != null && !value.equals(entities.unescape(value)) && !withErrors.contains(p, "HTML"))
    519             {
     461            if (checkValues && value != null && !value.equals(entities.unescape(value)) && !withErrors.contains(p, "HTML")) {
    520462                errors.add( new TestError(this, Severity.OTHER, tr("Property values contain HTML entity"),
    521463                        tr(s, key), MessageFormat.format(s, key), INVALID_HTML, p) );
    522464                withErrors.add(p, "HTML");
    523465            }
    524             if( checkValues && value != null && value.length() > 0 && presetsValueData != null)
    525             {
     466            if (checkValues && value != null && value.length() > 0 && presetsValueData != null) {
    526467                List<String> values = presetsValueData.get(key);
    527                 if(values == null)
    528                 {
     468                if (values == null) {
    529469                    boolean ignore = false;
    530                     for(String a : ignoreDataStartsWith)
    531                     {
    532                         if(key.startsWith(a))
     470                    for (String a : ignoreDataStartsWith) {
     471                        if (key.startsWith(a)) {
    533472                            ignore = true;
    534                     }
    535                     for(String a : ignoreDataEquals)
    536                     {
    537                         if(key.equals(a))
     473                        }
     474                    }
     475                    for (String a : ignoreDataEquals) {
     476                        if(key.equals(a)) {
    538477                            ignore = true;
    539                     }
    540                     for(String a : ignoreDataEndsWith)
    541                     {
    542                         if(key.endsWith(a))
     478                        }
     479                    }
     480                    for (String a : ignoreDataEndsWith) {
     481                        if(key.endsWith(a)) {
    543482                            ignore = true;
    544                     }
    545                     if(!ignore)
    546                     {
     483                        }
     484                    }
     485                    if (!ignore) {
    547486                        String i = marktr("Key ''{0}'' not in presets.");
    548487                        errors.add( new TestError(this, Severity.OTHER, tr("Presets do not contain property key"),
     
    550489                        withErrors.add(p, "UPK");
    551490                    }
    552                 }
    553                 else if(values.size() > 0 && !values.contains(prop.getValue()))
    554                 {
     491                } else if (values.size() > 0 && !values.contains(prop.getValue())) {
    555492                    boolean ignore = false;
    556                     for(IgnoreKeyPair a : ignoreDataKeyPair)
    557                     {
    558                         if(key.equals(a.key) && value.equals(a.value))
     493                    for (IgnoreKeyPair a : ignoreDataKeyPair) {
     494                        if (key.equals(a.key) && value.equals(a.value)) {
    559495                            ignore = true;
    560                     }
    561 
    562                     for(IgnoreTwoKeyPair a : ignoreDataTwoKeyPair)
    563                     {
    564                         if(key.equals(a.key2) && value.equals(a.value2))
     496                        }
     497                    }
     498
     499                    for (IgnoreTwoKeyPair a : ignoreDataTwoKeyPair) {
     500                        if (key.equals(a.key2) && value.equals(a.value2)) {
    565501                            ignore = true;
    566                     }
    567 
    568                     if(!ignore)
    569                     {
     502                        }
     503                    }
     504
     505                    if (!ignore) {
    570506                        String i = marktr("Value ''{0}'' for key ''{1}'' not in presets.");
    571507                        errors.add( new TestError(this, Severity.OTHER, tr("Presets do not contain property value"),
     
    589525
    590526    @Override
    591     public void startTest(ProgressMonitor monitor)
    592     {
     527    public void startTest(ProgressMonitor monitor) {
    593528        super.startTest(monitor);
    594529        checkKeys = Main.pref.getBoolean(PREF_CHECK_KEYS, true);
    595         if( isBeforeUpload )
     530        if (isBeforeUpload) {
    596531            checkKeys = checkKeys && Main.pref.getBoolean(PREF_CHECK_KEYS_BEFORE_UPLOAD, true);
     532        }
    597533
    598534        checkValues = Main.pref.getBoolean(PREF_CHECK_VALUES, true);
    599         if( isBeforeUpload )
     535        if (isBeforeUpload) {
    600536            checkValues = checkValues && Main.pref.getBoolean(PREF_CHECK_VALUES_BEFORE_UPLOAD, true);
     537        }
    601538
    602539        checkComplex = Main.pref.getBoolean(PREF_CHECK_COMPLEX, true);
    603         if( isBeforeUpload )
     540        if (isBeforeUpload) {
    604541            checkComplex = checkValues && Main.pref.getBoolean(PREF_CHECK_COMPLEX_BEFORE_UPLOAD, true);
     542        }
    605543
    606544        checkFixmes = Main.pref.getBoolean(PREF_CHECK_FIXMES, true);
    607         if( isBeforeUpload )
     545        if (isBeforeUpload) {
    608546            checkFixmes = checkFixmes && Main.pref.getBoolean(PREF_CHECK_FIXMES_BEFORE_UPLOAD, true);
     547        }
    609548    }
    610549
    611550    @Override
    612     public void visit(Collection<OsmPrimitive> selection)
    613     {
    614         if( checkKeys || checkValues || checkComplex || checkFixmes)
     551    public void visit(Collection<OsmPrimitive> selection) {
     552        if (checkKeys || checkValues || checkComplex || checkFixmes) {
    615553            super.visit(selection);
     554        }
    616555    }
    617556
    618557    @Override
    619     public void addGui(JPanel testPanel)
    620     {
     558    public void addGui(JPanel testPanel) {
    621559        GBC a = GBC.eol();
    622560        a.anchor = GridBagConstraints.EAST;
    623561
    624         testPanel.add( new JLabel(name), GBC.eol().insets(3,0,0,0) );
     562        testPanel.add(new JLabel(name), GBC.eol().insets(3,0,0,0));
    625563
    626564        prefCheckKeys = new JCheckBox(tr("Check property keys."), Main.pref.getBoolean(PREF_CHECK_KEYS, true));
     
    640578        testPanel.add(prefCheckComplexBeforeUpload, a);
    641579
    642         Sources = new JList(new DefaultListModel());
     580        sourcesList = new JList(new DefaultListModel());
    643581
    644582        String sources = Main.pref.get( PREF_SOURCES );
    645         if(sources != null && sources.length() > 0)
    646         {
    647             for(String source : sources.split(";"))
    648                 ((DefaultListModel)Sources.getModel()).addElement(source);
     583        if (sources != null && sources.length() > 0) {
     584            for (String source : sources.split(";")) {
     585                ((DefaultListModel)sourcesList.getModel()).addElement(source);
     586            }
    649587        }
    650588
    651589        addSrcButton = new JButton(tr("Add"));
    652         addSrcButton.addActionListener(new ActionListener(){
     590        addSrcButton.addActionListener(new ActionListener() {
     591            @Override
    653592            public void actionPerformed(ActionEvent e) {
    654593                String source = JOptionPane.showInputDialog(
     
    656595                        tr("TagChecker source"),
    657596                        tr("TagChecker source"),
    658                         JOptionPane.QUESTION_MESSAGE
    659                 );
    660                 if (source != null)
    661                     ((DefaultListModel)Sources.getModel()).addElement(source);
    662                 Sources.clearSelection();
     597                        JOptionPane.QUESTION_MESSAGE);
     598                if (source != null) {
     599                    ((DefaultListModel)sourcesList.getModel()).addElement(source);
     600                }
     601                sourcesList.clearSelection();
    663602            }
    664603        });
    665604
    666605        editSrcButton = new JButton(tr("Edit"));
    667         editSrcButton.addActionListener(new ActionListener(){
     606        editSrcButton.addActionListener(new ActionListener() {
     607            @Override
    668608            public void actionPerformed(ActionEvent e) {
    669                 int row = Sources.getSelectedIndex();
    670                 if(row == -1 && Sources.getModel().getSize() == 1)
    671                 {
    672                     Sources.setSelectedIndex(0);
     609                int row = sourcesList.getSelectedIndex();
     610                if (row == -1 && sourcesList.getModel().getSize() == 1) {
     611                    sourcesList.setSelectedIndex(0);
    673612                    row = 0;
    674613                }
    675                 if (row == -1)
    676                 {
    677                     if(Sources.getModel().getSize() == 0)
    678                     {
     614                if (row == -1) {
     615                    if (sourcesList.getModel().getSize() == 0) {
    679616                        String source = JOptionPane.showInputDialog(Main.parent, tr("TagChecker source"), tr("TagChecker source"), JOptionPane.QUESTION_MESSAGE);
    680                         if (source != null)
    681                             ((DefaultListModel)Sources.getModel()).addElement(source);
    682                     }
    683                     else
    684                     {
     617                        if (source != null) {
     618                            ((DefaultListModel)sourcesList.getModel()).addElement(source);
     619                        }
     620                    } else {
    685621                        JOptionPane.showMessageDialog(
    686622                                Main.parent,
     
    690626                        );
    691627                    }
    692                 }
    693                 else {
     628                } else {
    694629                    String source = (String)JOptionPane.showInputDialog(Main.parent,
    695630                            tr("TagChecker source"),
    696631                            tr("TagChecker source"),
    697632                            JOptionPane.QUESTION_MESSAGE, null, null,
    698                             Sources.getSelectedValue());
    699                     if (source != null)
    700                         ((DefaultListModel)Sources.getModel()).setElementAt(source, row);
    701                 }
    702                 Sources.clearSelection();
     633                            sourcesList.getSelectedValue());
     634                    if (source != null) {
     635                        ((DefaultListModel)sourcesList.getModel()).setElementAt(source, row);
     636                    }
     637                }
     638                sourcesList.clearSelection();
    703639            }
    704640        });
    705641
    706642        deleteSrcButton = new JButton(tr("Delete"));
    707         deleteSrcButton.addActionListener(new ActionListener(){
     643        deleteSrcButton.addActionListener(new ActionListener() {
     644            @Override
    708645            public void actionPerformed(ActionEvent e) {
    709                 if (Sources.getSelectedIndex() == -1)
     646                if (sourcesList.getSelectedIndex() == -1) {
    710647                    JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete."), tr("Information"), JOptionPane.QUESTION_MESSAGE);
    711                 else {
    712                     ((DefaultListModel)Sources.getModel()).remove(Sources.getSelectedIndex());
     648                } else {
     649                    ((DefaultListModel)sourcesList.getModel()).remove(sourcesList.getSelectedIndex());
    713650                }
    714651            }
    715652        });
    716         Sources.setMinimumSize(new Dimension(300,50));
    717         Sources.setVisibleRowCount(3);
    718 
    719         Sources.setToolTipText(tr("The sources (URL or filename) of spell check (see http://wiki.openstreetmap.org/index.php/User:JLS/speller) or tag checking data files."));
     653        sourcesList.setMinimumSize(new Dimension(300,50));
     654        sourcesList.setVisibleRowCount(3);
     655
     656        sourcesList.setToolTipText(tr("The sources (URL or filename) of spell check (see http://wiki.openstreetmap.org/index.php/User:JLS/speller) or tag checking data files."));
    720657        addSrcButton.setToolTipText(tr("Add a new source to the list."));
    721658        editSrcButton.setToolTipText(tr("Edit the selected source."));
     
    723660
    724661        testPanel.add(new JLabel(tr("Data sources")), GBC.eol().insets(23,0,0,0));
    725         testPanel.add(new JScrollPane(Sources), GBC.eol().insets(23,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     662        testPanel.add(new JScrollPane(sourcesList), GBC.eol().insets(23,0,0,0).fill(GridBagConstraints.HORIZONTAL));
    726663        final JPanel buttonPanel = new JPanel(new GridBagLayout());
    727664        testPanel.add(buttonPanel, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
     
    730667        buttonPanel.add(deleteSrcButton, GBC.std().insets(0,5,0,0));
    731668
    732         ActionListener disableCheckActionListener = new ActionListener(){
     669        ActionListener disableCheckActionListener = new ActionListener() {
     670            @Override
    733671            public void actionPerformed(ActionEvent e) {
    734672                handlePrefEnable();
     
    771709    }
    772710
    773     public void handlePrefEnable()
    774     {
     711    public void handlePrefEnable() {
    775712        boolean selected = prefCheckKeys.isSelected() || prefCheckKeysBeforeUpload.isSelected()
    776         || prefCheckComplex.isSelected() || prefCheckComplexBeforeUpload.isSelected();
    777         Sources.setEnabled( selected );
     713                    || prefCheckComplex.isSelected() || prefCheckComplexBeforeUpload.isSelected();
     714        sourcesList.setEnabled( selected );
    778715        addSrcButton.setEnabled(selected);
    779716        editSrcButton.setEnabled(selected);
     
    786723        enabled = prefCheckKeys.isSelected() || prefCheckValues.isSelected() || prefCheckComplex.isSelected() || prefCheckFixmes.isSelected();
    787724        testBeforeUpload = prefCheckKeysBeforeUpload.isSelected() || prefCheckValuesBeforeUpload.isSelected()
    788         || prefCheckFixmesBeforeUpload.isSelected() || prefCheckComplexBeforeUpload.isSelected();
     725                || prefCheckFixmesBeforeUpload.isSelected() || prefCheckComplexBeforeUpload.isSelected();
    789726
    790727        Main.pref.put(PREF_CHECK_VALUES, prefCheckValues.isSelected());
     
    800737        Main.pref.put(PREF_USE_SPELL_FILE, prefUseSpellFile.isSelected());
    801738        String sources = "";
    802         if( Sources.getModel().getSize() > 0 )
    803         {
     739        if (sourcesList.getModel().getSize() > 0) {
    804740            String sb = "";
    805             for (int i = 0; i < Sources.getModel().getSize(); ++i)
    806                 sb += ";"+Sources.getModel().getElementAt(i);
     741            for (int i = 0; i < sourcesList.getModel().getSize(); ++i) {
     742                sb += ";"+sourcesList.getModel().getElementAt(i);
     743            }
    807744            sources = sb.substring(1);
    808745        }
    809         if(sources.length() == 0)
     746        if (sources.length() == 0) {
    810747            sources = null;
     748        }
    811749        return Main.pref.put(PREF_SOURCES, sources);
    812750    }
    813751
    814752    @Override
    815     public Command fixError(TestError testError)
    816     {
     753    public Command fixError(TestError testError) {
     754
    817755        List<Command> commands = new ArrayList<Command>(50);
    818756
    819757        int i = -1;
    820758        List<? extends OsmPrimitive> primitives = testError.getPrimitives();
    821         for(OsmPrimitive p : primitives )
    822         {
     759        for (OsmPrimitive p : primitives) {
    823760            i++;
    824761            Map<String, String> tags = p.getKeys();
    825             if( tags == null || tags.size() == 0 )
     762            if (tags == null || tags.isEmpty()) {
    826763                continue;
    827 
    828             for(Entry<String, String> prop: tags.entrySet() )
    829             {
     764            }
     765
     766            for (Entry<String, String> prop: tags.entrySet()) {
    830767                String key = prop.getKey();
    831768                String value = prop.getValue();
    832                 if( value == null || value.trim().length() == 0 )
    833                     commands.add( new ChangePropertyCommand(Collections.singleton(primitives.get(i)), key, null) );
    834                 else if(value.startsWith(" ") || value.endsWith(" "))
    835                     commands.add( new ChangePropertyCommand(Collections.singleton(primitives.get(i)), key, value.trim()) );
    836                 else if(key.startsWith(" ") || key.endsWith(" "))
    837                     commands.add( new ChangePropertyKeyCommand(Collections.singleton(primitives.get(i)), key, key.trim()) );
    838                 else
    839                 {
     769                if (value == null || value.trim().length() == 0) {
     770                    commands.add(new ChangePropertyCommand(Collections.singleton(primitives.get(i)), key, null));
     771                } else if (value.startsWith(" ") || value.endsWith(" ")) {
     772                    commands.add(new ChangePropertyCommand(Collections.singleton(primitives.get(i)), key, value.trim()));
     773                } else if (key.startsWith(" ") || key.endsWith(" ")) {
     774                    commands.add(new ChangePropertyKeyCommand(Collections.singleton(primitives.get(i)), key, key.trim()));
     775                } else {
    840776                    String evalue = entities.unescape(value);
    841                     if(!evalue.equals(value))
    842                         commands.add( new ChangePropertyCommand(Collections.singleton(primitives.get(i)), key, evalue) );
    843                     else
    844                     {
     777                    if (!evalue.equals(value)) {
     778                        commands.add(new ChangePropertyCommand(Collections.singleton(primitives.get(i)), key, evalue));
     779                    } else {
    845780                        String replacementKey = spellCheckKeyData.get(key);
    846                         if( replacementKey != null )
    847                         {
    848                             commands.add( new ChangePropertyKeyCommand(Collections.singleton(primitives.get(i)),
    849                                     key, replacementKey) );
    850                         }
    851                     }
    852                 }
    853             }
    854         }
    855 
    856         if( commands.size() == 0 )
     781                        if (replacementKey != null) {
     782                            commands.add(new ChangePropertyKeyCommand(Collections.singleton(primitives.get(i)),
     783                                    key, replacementKey));
     784                        }
     785                    }
     786                }
     787            }
     788        }
     789
     790        if (commands.isEmpty())
    857791            return null;
    858         else if( commands.size() == 1 )
     792        if (commands.size() == 1)
    859793            return commands.get(0);
    860         else
    861             return new SequenceCommand(tr("Fix properties"), commands);
     794       
     795        return new SequenceCommand(tr("Fix properties"), commands);
    862796    }
    863797
    864798    @Override
    865     public boolean isFixable(TestError testError)
    866     {
    867         if( testError.getTester() instanceof TagChecker)
    868         {
     799    public boolean isFixable(TestError testError) {
     800
     801        if (testError.getTester() instanceof TagChecker) {
    869802            int code = testError.getCode();
    870803            return code == INVALID_KEY || code == EMPTY_VALUES || code == INVALID_SPACE || code == INVALID_KEY_SPACE || code == INVALID_HTML;
     
    903836            public boolean valueAll = false;
    904837            public boolean valueBool = false;
    905             private Pattern getPattern(String str) throws IllegalStateException, PatternSyntaxException
    906             {
    907                 if(str.endsWith("/i"))
     838            private Pattern getPattern(String str) throws IllegalStateException, PatternSyntaxException {
     839                if (str.endsWith("/i"))
    908840                    return Pattern.compile(str.substring(1,str.length()-2), Pattern.CASE_INSENSITIVE);
    909                 else if(str.endsWith("/"))
     841                if (str.endsWith("/"))
    910842                    return Pattern.compile(str.substring(1,str.length()-1));
     843
    911844                throw new IllegalStateException();
    912845            }
    913             public CheckerElement(String exp) throws IllegalStateException, PatternSyntaxException
    914             {
     846            public CheckerElement(String exp) throws IllegalStateException, PatternSyntaxException {
    915847                Matcher m = Pattern.compile("(.+)([!=]=)(.+)").matcher(exp);
    916848                m.matches();
    917849
    918850                String n = m.group(1).trim();
     851
     852                // FIXME FIXME: indentation and { } pairs don't match, probably coding error
     853
    919854                if(n.equals("*"))
    920855                    tagAll = true;
     
    938873                        value = n.startsWith("/") ? getPattern(n) : n;
    939874            }
     875
    940876            public boolean match(OsmPrimitive osm, Map<String, String> keys) {
    941                 for(Entry<String, String> prop: keys.entrySet()) {
     877                for (Entry<String, String> prop: keys.entrySet()) {
    942878                    String key = prop.getKey();
    943879                    String val = valueBool ? OsmUtils.getNamedOsmBoolean(prop.getValue()) : prop.getValue();
    944                     if((tagAll || (tag instanceof Pattern ? ((Pattern)tag).matcher(key).matches() : key.equals(tag)))
    945                             && (valueAll || (value instanceof Pattern ? ((Pattern)value).matcher(val).matches() : val.equals(value))))
     880                    if ((tagAll || (tag instanceof Pattern ? ((Pattern) tag).matcher(key).matches() : key.equals(tag)))
     881                            && (valueAll || (value instanceof Pattern ? ((Pattern) value).matcher(val).matches() : val.equals(value))))
    946882                        return !noMatch;
    947883                }
     
    950886        };
    951887
    952         public String getData(String str)
    953         {
     888        public String getData(String str) {
    954889            Matcher m = Pattern.compile(" *# *([^#]+) *$").matcher(str);
    955890            str = m.replaceFirst("").trim();
    956             try
    957             {
     891            try {
    958892                description = m.group(1);
    959                 if(description != null && description.length() == 0)
     893                if (description != null && description.length() == 0) {
    960894                    description = null;
    961             }
    962             catch (IllegalStateException e)
    963             {
     895                }
     896            } catch (IllegalStateException e) {
    964897                description = null;
    965898            }
    966899            String[] n = str.split(" *: *", 3);
    967             if(n[0].equals("way"))
     900            if (n[0].equals("way")) {
    968901                type = OsmPrimitiveType.WAY;
    969             else if(n[0].equals("node"))
     902            } else if (n[0].equals("node")) {
    970903                type = OsmPrimitiveType.NODE;
    971             else if(n[0].equals("relation"))
     904            } else if (n[0].equals("relation")) {
    972905                type = OsmPrimitiveType.RELATION;
    973             else if(n[0].equals("*"))
     906            } else if (n[0].equals("*")) {
    974907                type = null;
    975             else
     908            } else
    976909                return tr("Could not find element type");
    977910            if (n.length != 3)
    978911                return tr("Incorrect number of parameters");
    979912
    980             if(n[1].equals("W"))
    981             {
     913            if (n[1].equals("W")) {
    982914                severity = Severity.WARNING;
    983915                code = TAG_CHECK_WARN;
    984             }
    985             else if(n[1].equals("E"))
    986             {
     916            } else if (n[1].equals("E")) {
    987917                severity = Severity.ERROR;
    988918                code = TAG_CHECK_ERROR;
    989             }
    990             else if(n[1].equals("I"))
    991             {
     919            } else if(n[1].equals("I")) {
    992920                severity = Severity.OTHER;
    993921                code = TAG_CHECK_INFO;
    994             }
    995             else
     922            } else
    996923                return tr("Could not find warning level");
    997             for(String exp: n[2].split(" *&& *"))
    998             {
    999                 try
    1000                 {
     924            for (String exp: n[2].split(" *&& *")) {
     925                try {
    1001926                    data.add(new CheckerElement(exp));
    1002                 }
    1003                 catch(IllegalStateException e)
    1004                 {
     927                } catch (IllegalStateException e) {
    1005928                    return tr("Illegal expression ''{0}''", exp);
    1006929                }
    1007                 catch(PatternSyntaxException e)
    1008                 {
     930                catch (PatternSyntaxException e) {
    1009931                    return tr("Illegal regular expression ''{0}''", exp);
    1010932                }
     
    1012934            return null;
    1013935        }
    1014         public boolean match(OsmPrimitive osm, Map<String, String> keys)
    1015         {
     936
     937        public boolean match(OsmPrimitive osm, Map<String, String> keys) {
    1016938            if (type != null && OsmPrimitiveType.from(osm) != type)
    1017939                return false;
    1018940
    1019             for(CheckerElement ce : data) {
    1020                 if(!ce.match(osm, keys))
     941            for (CheckerElement ce : data) {
     942                if (!ce.match(osm, keys))
    1021943                    return false;
    1022944            }
    1023945            return true;
    1024946        }
    1025         public String getDescription()
    1026         {
     947
     948        public String getDescription() {
    1027949            return tr(description);
    1028950        }
    1029         public String getDescriptionOrig()
    1030         {
     951
     952        public String getDescriptionOrig() {
    1031953            return description;
    1032954        }
    1033         public Severity getSeverity()
    1034         {
     955
     956        public Severity getSeverity() {
    1035957            return severity;
    1036958        }
    1037959
    1038960        public int getCode() {
    1039             if (type == null) {
     961            if (type == null)
    1040962                return code;
    1041             } else {
    1042                 return code + type.ordinal() + 1;
    1043             }
     963
     964            return code + type.ordinal() + 1;
    1044965        }
    1045966    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java

    r3669 r3671  
    3333
    3434    public TurnrestrictionTest() {
    35         super(tr("Turnrestriction"),
    36                 tr("This test checks if turnrestrictions are valid"));
     35        super(tr("Turnrestriction"), tr("This test checks if turnrestrictions are valid"));
    3736    }
    3837
     
    5150
    5251        /* find the "from", "via" and "to" elements */
    53         for (RelationMember m : r.getMembers())
    54         {
    55             if(m.getMember().isIncomplete())
     52        for (RelationMember m : r.getMembers()) {
     53            if (m.getMember().isIncomplete())
    5654                return;
    57             else
    58             {
    59                 ArrayList<OsmPrimitive> l = new ArrayList<OsmPrimitive>();
    60                 l.add(r);
    61                 l.add(m.getMember());
    62                 if(m.isWay())
    63                 {
    64                     Way w = m.getWay();
    65                     if(w.getNodesCount() < 2) {
    66                         continue;
     55
     56            ArrayList<OsmPrimitive> l = new ArrayList<OsmPrimitive>();
     57            l.add(r);
     58            l.add(m.getMember());
     59            if (m.isWay()) {
     60                Way w = m.getWay();
     61                if (w.getNodesCount() < 2) {
     62                    continue;
     63                }
     64
     65                if ("from".equals(m.getRole())) {
     66                    if (fromWay != null) {
     67                        morefrom = true;
     68                    } else {
     69                        fromWay = w;
    6770                    }
    68 
    69                     if("from".equals(m.getRole())) {
    70                         if(fromWay != null) {
    71                             morefrom = true;
    72                         } else {
    73                             fromWay = w;
    74                         }
    75                     } else if("to".equals(m.getRole())) {
    76                         if(toWay != null) {
    77                             moreto = true;
    78                         } else {
    79                             toWay = w;
    80                         }
    81                     } else if("via".equals(m.getRole())) {
    82                         if(via != null) {
    83                             morevia = true;
    84                         } else {
    85                             via = w;
    86                         }
     71                } else if ("to".equals(m.getRole())) {
     72                    if (toWay != null) {
     73                        moreto = true;
    8774                    } else {
    88                         errors.add(new TestError(this, Severity.WARNING, tr("Unknown role"), UNKNOWN_ROLE,
    89                         l, Collections.singletonList(m)));
     75                        toWay = w;
    9076                    }
    91                 }
    92                 else if(m.isNode())
    93                 {
    94                     Node n = m.getNode();
    95                     if("via".equals(m.getRole()))
    96                     {
    97                         if(via != null) {
    98                             morevia = true;
    99                         } else {
    100                             via = n;
    101                         }
     77                } else if ("via".equals(m.getRole())) {
     78                    if (via != null) {
     79                        morevia = true;
    10280                    } else {
    103                         errors.add(new TestError(this, Severity.WARNING, tr("Unknown role"), UNKNOWN_ROLE,
    104                         l, Collections.singletonList(m)));
     81                        via = w;
    10582                    }
    10683                } else {
    107                     errors.add(new TestError(this, Severity.WARNING, tr("Unknown member type"), UNKNOWN_TYPE,
    108                     l, Collections.singletonList(m)));
     84                    errors.add(new TestError(this, Severity.WARNING, tr("Unknown role"), UNKNOWN_ROLE,
     85                            l, Collections.singletonList(m)));
    10986                }
     87            } else if (m.isNode()) {
     88                Node n = m.getNode();
     89                if ("via".equals(m.getRole())) {
     90                    if (via != null) {
     91                        morevia = true;
     92                    } else {
     93                        via = n;
     94                    }
     95                } else {
     96                    errors.add(new TestError(this, Severity.WARNING, tr("Unknown role"), UNKNOWN_ROLE,
     97                            l, Collections.singletonList(m)));
     98                }
     99            } else {
     100                errors.add(new TestError(this, Severity.WARNING, tr("Unknown member type"), UNKNOWN_TYPE,
     101                        l, Collections.singletonList(m)));
    110102            }
    111103        }
    112         if(morefrom)
     104        if (morefrom) {
    113105            errors.add(new TestError(this, Severity.ERROR, tr("More than one \"from\" way found"), MORE_FROM, r));
    114         if(moreto)
     106        }
     107        if (moreto) {
    115108            errors.add(new TestError(this, Severity.ERROR, tr("More than one \"to\" way found"), MORE_TO, r));
    116         if(morevia)
     109        }
     110        if (morevia) {
    117111            errors.add(new TestError(this, Severity.ERROR, tr("More than one \"via\" way found"), MORE_VIA, r));
     112        }
    118113
    119114        if (fromWay == null) {
     
    131126
    132127        Node viaNode;
    133         if(via instanceof Node)
    134         {
     128        if (via instanceof Node) {
    135129            viaNode = (Node) via;
    136             if(!fromWay.isFirstLastNode(viaNode)) {
     130            if (!fromWay.isFirstLastNode(viaNode)) {
    137131                errors.add(new TestError(this, Severity.ERROR,
    138                 tr("The \"from\" way does not start or end at a \"via\" node"), FROM_VIA_NODE, r));
     132                        tr("The \"from\" way does not start or end at a \"via\" node"), FROM_VIA_NODE, r));
    139133                return;
    140134            }
    141             if(!toWay.isFirstLastNode(viaNode)) {
     135            if (!toWay.isFirstLastNode(viaNode)) {
    142136                errors.add(new TestError(this, Severity.ERROR,
    143                 tr("The \"to\" way does not start or end at a \"via\" node"), TO_VIA_NODE, r));
     137                        tr("The \"to\" way does not start or end at a \"via\" node"), TO_VIA_NODE, r));
     138                //FIXME: return; ?
    144139            }
    145         }
    146         else
    147         {
     140        } else {
    148141            Way viaWay = (Way) via;
    149142            Node firstNode = viaWay.firstNode();
     
    152145
    153146            String onewayviastr = viaWay.get("oneway");
    154             if(onewayviastr != null)
    155             {
    156                 if("-1".equals(onewayviastr)) {
     147            if (onewayviastr != null) {
     148                if ("-1".equals(onewayviastr)) {
    157149                    onewayvia = true;
    158150                    Node tmp = firstNode;
     
    167159            }
    168160
    169             if(fromWay.isFirstLastNode(firstNode))
     161            if (fromWay.isFirstLastNode(firstNode)) {
    170162                viaNode = firstNode;
    171             else if(!onewayvia && fromWay.isFirstLastNode(lastNode))
     163            } else if (!onewayvia && fromWay.isFirstLastNode(lastNode)) {
    172164                viaNode = lastNode;
    173             else
    174             {
     165            } else {
    175166                errors.add(new TestError(this, Severity.ERROR,
    176                 tr("The \"from\" way does not start or end at a \"via\" way."), FROM_VIA_WAY, r));
     167                        tr("The \"from\" way does not start or end at a \"via\" way."), FROM_VIA_WAY, r));
    177168                return;
    178169            }
    179             if(!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) {
     170            if (!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) {
    180171                errors.add(new TestError(this, Severity.ERROR,
    181                 tr("The \"to\" way does not start or end at a \"via\" way."), TO_VIA_WAY, r));
     172                        tr("The \"to\" way does not start or end at a \"via\" way."), TO_VIA_WAY, r));
    182173            }
    183174        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnclosedWays.java

    r3669 r3671  
    2727public class UnclosedWays extends Test {
    2828    /** The already detected errors */
    29     Bag<Way, Way> _errorWays;
     29    protected Bag<Way, Way> errorWays;
    3030
    3131    /**
     
    3939    public void startTest(ProgressMonitor monitor) {
    4040        super.startTest(monitor);
    41         _errorWays = new Bag<Way, Way>();
     41        errorWays = new Bag<Way, Way>();
    4242    }
    4343
    4444    @Override
    4545    public void endTest() {
    46         _errorWays = null;
     46        errorWays = null;
    4747        super.endTest();
    4848    }
     
    7474
    7575        test = w.get("natural");
    76         if (test != null && !"coastline".equals(test) && !"cliff".equals(test))
     76        if (test != null && !"coastline".equals(test) && !"cliff".equals(test)) {
    7777            set(1101, marktr("natural type {0}"), test);
     78        }
    7879        test = w.get("landuse");
    79         if (test != null)
     80        if (test != null) {
    8081            set(1102, marktr("landuse type {0}"), test);
     82        }
    8183        test = w.get("amenities");
    82         if (test != null)
     84        if (test != null) {
    8385            set(1103, marktr("amenities type {0}"), test);
     86        }
    8487        test = w.get("sport");
    85         if (test != null && !test.equals("water_slide"))
     88        if (test != null && !test.equals("water_slide")) {
    8689            set(1104, marktr("sport type {0}"), test);
     90        }
    8791        test = w.get("tourism");
    88         if (test != null)
     92        if (test != null) {
    8993            set(1105, marktr("tourism type {0}"), test);
     94        }
    9095        test = w.get("shop");
    91         if (test != null)
     96        if (test != null) {
    9297            set(1106, marktr("shop type {0}"), test);
     98        }
    9399        test = w.get("leisure");
    94         if (test != null)
     100        if (test != null) {
    95101            set(1107, marktr("leisure type {0}"), test);
     102        }
    96103        test = w.get("waterway");
    97         if (test != null && test.equals("riverbank"))
     104        if (test != null && test.equals("riverbank")) {
    98105            set(1108, marktr("waterway type {0}"), test);
     106        }
    99107        Boolean btest = OsmUtils.getOsmBoolean(w.get("building"));
    100         if (btest != null && btest)
     108        if (btest != null && btest) {
    101109            set(1120, marktr("building"));
     110        }
    102111        btest = OsmUtils.getOsmBoolean(w.get("area"));
    103         if (btest != null && btest)
     112        if (btest != null && btest) {
    104113            set(1130, marktr("area"));
     114        }
    105115
    106116        if (type != null && !w.isClosed()) {
     
    123133            errors.add(new TestError(this, Severity.WARNING, tr("Unclosed way"),
    124134                            type, etype, mode, primitives, highlight));
    125             _errorWays.add(w, w);
     135            errorWays.add(w, w);
    126136        }
    127137    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r3669 r3671  
    3737 * @author frsantos
    3838 */
    39 public class UnconnectedWays extends Test
    40 {
     39public class UnconnectedWays extends Test {
     40
    4141    protected static int UNCONNECTED_WAYS = 1301;
    4242    protected static final String PREFIX = ValidatorPreference.PREFIX + "." + UnconnectedWays.class.getSimpleName();
     
    5454    double mindist;
    5555    double minmiddledist;
     56
    5657    /**
    5758     * Constructor
    5859     */
    59     public UnconnectedWays()
    60     {
     60    public UnconnectedWays() {
    6161        super(tr("Unconnected ways."),
    6262              tr("This test checks if a way has an endpoint very near to another way."));
     
    6464
    6565    @Override
    66     public void startTest(ProgressMonitor monitor)
    67     {
     66    public void startTest(ProgressMonitor monitor) {
    6867        super.startTest(monitor);
    6968        ways = new HashSet<MyWaySegment>();
     
    7978
    8079    @Override
    81     public void endTest()
    82     {
     80    public void endTest() {
    8381        //Area a = Main.ds.getDataSourceArea();
    8482        Map<Node, Way> map = new HashMap<Node, Way>();
    85         long last = -1;
     83        //long last = -1;
    8684        for (int iter = 0; iter < 1; iter++) {
    87         last = System.currentTimeMillis();
    88         long last_print = -1;
    89         int nr = 0;
    90         Collection<MyWaySegment> tmp_ways = ways;
    91         for(MyWaySegment s : tmp_ways) {
    92             nr++;
    93             long now = System.currentTimeMillis();
    94             if (now - last_print > 200) {
    95                 //System.err.println("processing segment nr: " + nr + " of " + ways.size());
    96                 last_print = now;
    97             }
    98             for(Node en : s.nearbyNodes(mindist)) {
    99                 if (en == null)
    100                     continue;
    101                 if(!s.highway)
    102                     continue;
    103                 if (!endnodes_highway.contains(en))
    104                     continue;
    105                 if("turning_circle".equals(en.get("highway"))
    106                     || "bus_stop".equals(en.get("highway"))
    107                     || OsmUtils.isTrue(en.get("noexit"))
    108                     || en.hasKey("barrier"))
    109                     continue;
    110                 // There's a small false-positive here.  Imagine an intersection
    111                 // like a 't'.  If the top part of the 't' is short enough, it
    112                 // will trigger the node at the very top of the 't' to be unconnected
    113                 // to the way that "crosses" the 't'.  We should probably check that
    114                 // the ways to which 'en' belongs are not connected to 's.w'.
    115                 map.put(en, s.w);
    116             }
    117         }
    118         //System.out.println("p1 elapsed: " + (System.currentTimeMillis()-last));
    119         last = System.currentTimeMillis();
    120         }
    121         for(Map.Entry<Node, Way> error : map.entrySet())
    122         {
     85            //last = System.currentTimeMillis();
     86            long last_print = -1;
     87            int nr = 0;
     88            Collection<MyWaySegment> tmp_ways = ways;
     89            for (MyWaySegment s : tmp_ways) {
     90                nr++;
     91                long now = System.currentTimeMillis();
     92                if (now - last_print > 200) {
     93                    //System.err.println("processing segment nr: " + nr + " of " + ways.size());
     94                    last_print = now;
     95                }
     96                for (Node en : s.nearbyNodes(mindist)) {
     97                    if (en == null || !s.highway || !endnodes_highway.contains(en)) {
     98                        continue;
     99                    }
     100                    if ("turning_circle".equals(en.get("highway"))
     101                        || "bus_stop".equals(en.get("highway"))
     102                        || OsmUtils.isTrue(en.get("noexit"))
     103                        || en.hasKey("barrier")) {
     104                        continue;
     105                    }
     106                    // There's a small false-positive here.  Imagine an intersection
     107                    // like a 't'.  If the top part of the 't' is short enough, it
     108                    // will trigger the node at the very top of the 't' to be unconnected
     109                    // to the way that "crosses" the 't'.  We should probably check that
     110                    // the ways to which 'en' belongs are not connected to 's.w'.
     111                    map.put(en, s.w);
     112                }
     113            }
     114            //System.out.println("p1 elapsed: " + (System.currentTimeMillis()-last));
     115            //last = System.currentTimeMillis();
     116        }
     117        for (Map.Entry<Node, Way> error : map.entrySet()) {
    123118            errors.add(new TestError(this, Severity.WARNING,
    124             tr("Way end node near other highway"), UNCONNECTED_WAYS,
    125             Arrays.asList(error.getKey(), error.getValue())));
     119                    tr("Way end node near other highway"),
     120                    UNCONNECTED_WAYS,
     121                    Arrays.asList(error.getKey(), error.getValue())));
    126122        }
    127123        map.clear();
    128         for(MyWaySegment s : ways)
    129         {
    130             for(Node en : s.nearbyNodes(mindist))
    131             {
     124        for (MyWaySegment s : ways) {
     125            for (Node en : s.nearbyNodes(mindist)) {
    132126                if (endnodes_highway.contains(en) && !s.highway && !s.isArea()) {
    133127                    map.put(en, s.w);
     
    138132        }
    139133        //System.out.println("p2 elapsed: " + (System.currentTimeMillis()-last));
    140         last = System.currentTimeMillis();
    141         for(Map.Entry<Node, Way> error : map.entrySet())
    142         {
     134        //last = System.currentTimeMillis();
     135        for (Map.Entry<Node, Way> error : map.entrySet()) {
    143136            errors.add(new TestError(this, Severity.WARNING,
    144             tr("Way end node near other way"), UNCONNECTED_WAYS,
    145             Arrays.asList(error.getKey(), error.getValue())));
     137                    tr("Way end node near other way"),
     138                    UNCONNECTED_WAYS,
     139                    Arrays.asList(error.getKey(), error.getValue())));
    146140        }
    147141        /* the following two use a shorter distance */
    148         if(minmiddledist > 0.0)
    149         {
     142        if (minmiddledist > 0.0) {
    150143            map.clear();
    151             for(MyWaySegment s : ways)
    152             {
    153                 for(Node en : s.nearbyNodes(minmiddledist))
    154                 {
    155                     if (!middlenodes.contains(en))
     144            for (MyWaySegment s : ways) {
     145                for (Node en : s.nearbyNodes(minmiddledist)) {
     146                    if (!middlenodes.contains(en)) {
    156147                        continue;
     148                    }
    157149                    map.put(en, s.w);
    158150                }
    159151            }
    160152            //System.out.println("p3 elapsed: " + (System.currentTimeMillis()-last));
    161             last = System.currentTimeMillis();
    162             for(Map.Entry<Node, Way> error : map.entrySet())
    163             {
     153            //last = System.currentTimeMillis();
     154            for (Map.Entry<Node, Way> error : map.entrySet()) {
    164155                errors.add(new TestError(this, Severity.OTHER,
    165                 tr("Way node near other way"), UNCONNECTED_WAYS,
    166                 Arrays.asList(error.getKey(), error.getValue())));
     156                        tr("Way node near other way"),
     157                        UNCONNECTED_WAYS,
     158                        Arrays.asList(error.getKey(), error.getValue())));
    167159            }
    168160            map.clear();
    169             for(MyWaySegment s : ways)
    170             {
    171                 for(Node en : s.nearbyNodes(minmiddledist))
    172                 {
    173                     if (!othernodes.contains(en))
     161            for (MyWaySegment s : ways) {
     162                for (Node en : s.nearbyNodes(minmiddledist)) {
     163                    if (!othernodes.contains(en)) {
    174164                        continue;
     165                    }
    175166                    map.put(en, s.w);
    176167                }
    177168            }
    178169            //System.out.println("p4 elapsed: " + (System.currentTimeMillis()-last));
    179             last = System.currentTimeMillis();
    180             for(Map.Entry<Node, Way> error : map.entrySet())
    181             {
     170            //last = System.currentTimeMillis();
     171            for (Map.Entry<Node, Way> error : map.entrySet()) {
    182172                errors.add(new TestError(this, Severity.OTHER,
    183                 tr("Connected way end node near other way"), UNCONNECTED_WAYS,
    184                 Arrays.asList(error.getKey(), error.getValue())));
     173                        tr("Connected way end node near other way"),
     174                        UNCONNECTED_WAYS,
     175                        Arrays.asList(error.getKey(), error.getValue())));
    185176            }
    186177        }
     
    189180        super.endTest();
    190181        //System.out.println("p99 elapsed: " + (System.currentTimeMillis()-last));
    191         last = System.currentTimeMillis();
    192     }
    193 
    194     private class MyWaySegment
    195     {
     182        //last = System.currentTimeMillis();
     183    }
     184
     185    private class MyWaySegment {
    196186        private final Line2D line;
    197187        public final Way w;
     
    205195        final Node n2;
    206196
    207         public MyWaySegment(Way w, Node n1, Node n2)
    208         {
     197        public MyWaySegment(Way w, Node n1, Node n2) {
    209198            this.w = w;
    210199            String railway = w.get("railway");
     
    220209        }
    221210
    222         public boolean nearby(Node n, double dist)
    223         {
    224 //            return !w.containsNode(n)
    225 //            && line.ptSegDist(n.getEastNorth().east(), n.getEastNorth().north()) < dist;
     211        public boolean nearby(Node n, double dist) {
    226212            if (w == null) {
    227213                Main.debug("way null");
     
    240226            return line.ptSegDist(p) < dist;
    241227        }
    242         public List<LatLon> getBounds(double fudge)
    243         {
     228
     229        public List<LatLon> getBounds(double fudge) {
    244230            double x1 = n1.getCoor().lon();
    245231            double x2 = n2.getCoor().lon();
     
    264250        }
    265251
    266         public Collection<Node> nearbyNodes(double dist)
    267         {
     252        public Collection<Node> nearbyNodes(double dist) {
    268253            // If you're looking for nodes that are farther
    269254            // away that we looked for last time, the cached
     
    284269                    Set<Node> trimmed = new HashSet<Node>(nearbyNodeCache);
    285270                    for (Node n : new HashSet<Node>(nearbyNodeCache)) {
    286                         if (!nearby(n, dist))
     271                        if (!nearby(n, dist)) {
    287272                            trimmed.remove(n);
     273                        }
    288274                    }
    289275                    return trimmed;
     
    307293            for (Node n : found_nodes) {
    308294                if (!nearby(n, dist) ||
    309                      (ds_area != null && !ds_area.contains(n.getCoor())))
     295                     (ds_area != null && !ds_area.contains(n.getCoor()))) {
    310296                    continue;
     297                }
    311298                // It is actually very rare for us to find a node
    312299                // so defer as much of the work as possible, like
    313300                // allocating the hash set
    314                 if (nearbyNodeCache == null)
     301                if (nearbyNodeCache == null) {
    315302                    nearbyNodeCache = new HashSet<Node>();
     303                }
    316304                nearbyNodeCache.add(n);
    317305            }
    318306            nearbyNodeCacheDist = dist;
    319             if (nearbyNodeCache == null)
     307            if (nearbyNodeCache == null) {
    320308                nearbyNodeCache = Collections.emptySet();
     309            }
    321310            return nearbyNodeCache;
    322311        }
     
    330319    }
    331320
    332     List<MyWaySegment> getWaySegments(Way w)
    333     {
     321    List<MyWaySegment> getWaySegments(Way w) {
    334322        List<MyWaySegment> ret = new ArrayList<MyWaySegment>();
    335323        if (!w.isUsable()
     
    339327
    340328        int size = w.getNodesCount();
    341         if(size < 2)
     329        if (size < 2)
    342330            return ret;
    343         for(int i = 1; i < size; ++i)
    344         {
    345             if(i < size-1)
     331        for (int i = 1; i < size; ++i) {
     332            if(i < size-1) {
    346333                addNode(w.getNode(i), middlenodes);
     334            }
    347335            MyWaySegment ws = new MyWaySegment(w, w.getNode(i-1), w.getNode(i));
    348             if (ws.isBoundary || ws.isAbandoned)
     336            if (ws.isBoundary || ws.isAbandoned) {
    349337                continue;
     338            }
    350339            ret.add(ws);
    351340        }
     
    354343
    355344    @Override
    356     public void visit(Way w)
    357     {
     345    public void visit(Way w) {
    358346        ways.addAll(getWaySegments(w));
    359347        Set<Node> set = endnodes;
    360         if(w.hasKey("highway") || w.hasKey("railway"))
     348        if (w.hasKey("highway") || w.hasKey("railway")) {
    361349            set = endnodes_highway;
     350        }
    362351        addNode(w.firstNode(), set);
    363352        addNode(w.lastNode(), set);
    364353    }
     354
    365355    @Override
    366     public void visit(Node n)
    367     {
    368     }
    369     private void addNode(Node n, Set<Node> s)
    370     {
     356    public void visit(Node n) {
     357    }
     358
     359    private void addNode(Node n, Set<Node> s) {
    371360        boolean m = middlenodes.contains(n);
    372361        boolean e = endnodes.contains(n);
    373362        boolean eh = endnodes_highway.contains(n);
    374363        boolean o = othernodes.contains(n);
    375         if(!m && !e && !o && !eh)
     364        if (!m && !e && !o && !eh) {
    376365            s.add(n);
    377         else if(!o)
    378         {
     366        } else if (!o) {
    379367            othernodes.add(n);
    380             if(e)
     368            if (e) {
    381369                endnodes.remove(n);
    382             else if(eh)
     370            } else if (eh) {
    383371                endnodes_highway.remove(n);
    384             else
     372            } else {
    385373                middlenodes.remove(n);
     374            }
    386375        }
    387376    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java

    r3669 r3671  
    2323 * @author frsantos
    2424 */
    25 public class UntaggedNode extends Test
    26 {
     25public class UntaggedNode extends Test {
     26
    2727    protected static final int UNTAGGED_NODE_BLANK = 201;
    2828    protected static final int UNTAGGED_NODE_FIXME = 202;
     
    3636     * Constructor
    3737     */
    38     public UntaggedNode()
    39     {
     38    public UntaggedNode() {
    4039        super(tr("Untagged and unconnected nodes")+".",
    4140                tr("This test checks for untagged nodes that are not part of any way."));
     
    4342
    4443    @Override
    45     public void startTest(ProgressMonitor monitor)
    46     {
     44    public void startTest(ProgressMonitor monitor) {
    4745        super.startTest(monitor);
    4846    }
    4947
    5048    @Override
    51     public void visit(Collection<OsmPrimitive> selection)
    52     {
     49    public void visit(Collection<OsmPrimitive> selection) {
    5350        for (OsmPrimitive p : selection) {
    5451            if (p.isUsable() && p instanceof Node) {
     
    5956
    6057    @Override
    61     public void visit(Node n)
    62     {
     58    public void visit(Node n) {
    6359        if(n.isUsable() && !n.isTagged() && n.getReferrers().isEmpty()) {
    6460            if (!n.hasKeys()) {
     
    6965            for (Map.Entry<String, String> tag : n.getKeys().entrySet()) {
    7066                String key = tag.getKey();
    71                 String value = tag.getValue();
    7267                if (contains(tag, "fixme") || contains(tag, "FIXME")) {
    7368                    /* translation note: don't translate quoted words */
     
    114109
    115110    @Override
    116     public Command fixError(TestError testError)
    117     {
     111    public Command fixError(TestError testError) {
    118112        return DeleteCommand.delete(Main.map.mapView.getEditLayer(), testError.getPrimitives());
    119113    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java

    r3669 r3671  
    4444    /** Ways that must have a name */
    4545    public static final Set<String> NAMED_WAYS = new HashSet<String>();
    46     static
    47     {
     46    static {
    4847        NAMED_WAYS.add( "motorway" );
    4948        NAMED_WAYS.add( "trunk" );
     
    5857     * Constructor
    5958     */
    60     public UntaggedWay()
    61     {
     59    public UntaggedWay() {
    6260        super(tr("Untagged, empty and one node ways."),
    6361              tr("This test checks for untagged, empty and one node ways."));
     
    6563
    6664    @Override
    67     public void visit(Way w)
    68     {
    69         if (!w.isUsable()) return;
     65    public void visit(Way w) {
     66        if (!w.isUsable())
     67            return;
    7068
    7169        Map<String, String> tags = w.getKeys();
    72         if( tags.size() != 0 )
    73         {
     70        if (!tags.isEmpty()) {
    7471            String highway = tags.get("highway");
    75             if(highway != null && NAMED_WAYS.contains(highway))
    76             {
    77                 if( !tags.containsKey("name") && !tags.containsKey("ref") )
    78                 {
     72            if (highway != null && NAMED_WAYS.contains(highway)) {
     73                if (!tags.containsKey("name") && !tags.containsKey("ref")) {
    7974                    boolean isRoundabout = false;
    8075                    boolean hasName = false;
    81                     for( String key : w.keySet())
    82                     {
     76                    for (String key : w.keySet()) {
    8377                        hasName = key.startsWith("name:") || key.endsWith("_name") || key.endsWith("_ref");
    84                         if( hasName )
     78                        if (hasName) {
    8579                            break;
    86                         if(key.equals("junction"))
    87                         {
     80                        }
     81                        if (key.equals("junction")) {
    8882                            isRoundabout = w.get("junction").equals("roundabout");
    8983                            break;
     
    9185                    }
    9286
    93                     if( !hasName && !isRoundabout)
    94                         errors.add( new TestError(this, Severity.WARNING, tr("Unnamed ways"), UNNAMED_WAY, w) );
    95                     else if(isRoundabout)
    96                         errors.add( new TestError(this, Severity.WARNING, tr("Unnamed junction"), UNNAMED_JUNCTION, w) );
     87                    if (!hasName && !isRoundabout) {
     88                        errors.add(new TestError(this, Severity.WARNING, tr("Unnamed ways"), UNNAMED_WAY, w));
     89                    } else if (isRoundabout) {
     90                        errors.add(new TestError(this, Severity.WARNING, tr("Unnamed junction"), UNNAMED_JUNCTION, w));
     91                    }
    9792                }
    9893            }
    9994        }
    10095
    101         if(!w.isTagged() && !multipolygonways.contains(w))
    102         {
    103             if(w.hasKeys())
    104                 errors.add( new TestError(this, Severity.WARNING, tr("Untagged ways (commented)"), COMMENTED_WAY, w) );
    105             else
    106                 errors.add( new TestError(this, Severity.WARNING, tr("Untagged ways"), UNTAGGED_WAY, w) );
     96        if (!w.isTagged() && !multipolygonways.contains(w)) {
     97            if (w.hasKeys()) {
     98                errors.add(new TestError(this, Severity.WARNING, tr("Untagged ways (commented)"), COMMENTED_WAY, w));
     99            } else {
     100                errors.add(new TestError(this, Severity.WARNING, tr("Untagged ways"), UNTAGGED_WAY, w));
     101            }
    107102        }
    108103
    109         if( w.getNodesCount() == 0 )
    110         {
    111             errors.add( new TestError(this, Severity.ERROR, tr("Empty ways"), EMPTY_WAY, w) );
     104        if (w.getNodesCount() == 0) {
     105            errors.add(new TestError(this, Severity.ERROR, tr("Empty ways"), EMPTY_WAY, w));
     106        } else if (w.getNodesCount() == 1) {
     107            errors.add(new TestError(this, Severity.ERROR, tr("One node ways"), ONE_NODE_WAY, w));
    112108        }
    113         else if( w.getNodesCount() == 1 )
    114         {
    115             errors.add( new TestError(this, Severity.ERROR, tr("One node ways"), ONE_NODE_WAY, w) );
    116         }
    117 
    118109    }
    119110
    120111    @Override
    121     public void startTest(ProgressMonitor monitor)
    122     {
     112    public void startTest(ProgressMonitor monitor) {
    123113        super.startTest(monitor);
    124114        multipolygonways = new LinkedList<Way>();
    125         for (Relation r : Main.main.getCurrentDataSet().getRelations())
    126         {
    127             if(r.isUsable() && "multipolygon".equals(r.get("type")))
    128             {
    129                 for (RelationMember m : r.getMembers())
    130                 {
    131                     if(m.getMember() != null && m.getMember() instanceof Way &&
    132                     m.getMember().isUsable() && !m.getMember().isTagged())
     115        for (Relation r : Main.main.getCurrentDataSet().getRelations()) {
     116            if (r.isUsable() && "multipolygon".equals(r.get("type"))) {
     117                for (RelationMember m : r.getMembers()) {
     118                    if (m.getMember() != null && m.getMember() instanceof Way &&
     119                            m.getMember().isUsable() && !m.getMember().isTagged()) {
    133120                        multipolygonways.add((Way)m.getMember());
     121                    }
    134122                }
    135123            }
     
    138126
    139127    @Override
    140     public void endTest()
    141     {
     128    public void endTest() {
    142129        multipolygonways = null;
    143130        super.endTest();
     
    145132
    146133    @Override
    147     public boolean isFixable(TestError testError)
    148     {
    149         if( testError.getTester() instanceof UntaggedWay )
    150         {
     134    public boolean isFixable(TestError testError) {
     135        if (testError.getTester() instanceof UntaggedWay)
    151136            return testError.getCode() == EMPTY_WAY
    152137                || testError.getCode() == ONE_NODE_WAY;
    153         }
    154138
    155139        return false;
     
    157141
    158142    @Override
    159     public Command fixError(TestError testError)
    160     {
     143    public Command fixError(TestError testError) {
    161144        return DeleteCommand.delete(Main.map.mapView.getEditLayer(), testError.getPrimitives());
    162145    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/WronglyOrderedWays.java

    r3669 r3671  
    2020 * @author jrreid
    2121 */
    22 public class WronglyOrderedWays extends Test  {
     22public class WronglyOrderedWays extends Test {
     23
    2324    protected static int WRONGLY_ORDERED_COAST = 1001;
    2425    protected static int WRONGLY_ORDERED_WATER = 1002;
     
    2627
    2728    /** The already detected errors */
    28     Bag<Way, Way> _errorWays;
     29    protected Bag<Way, Way> errorWays;
    2930
    3031    /**
    3132     * Constructor
    3233     */
    33     public WronglyOrderedWays()
    34     {
     34    public WronglyOrderedWays() {
    3535        super(tr("Wrongly Ordered Ways."),
    3636              tr("This test checks the direction of water, land and coastline ways."));
     
    3838
    3939    @Override
    40     public void startTest(ProgressMonitor monitor)
    41     {
     40    public void startTest(ProgressMonitor monitor) {
    4241        super.startTest(monitor);
    43         _errorWays = new Bag<Way, Way>();
     42        errorWays = new Bag<Way, Way>();
    4443    }
    4544
    4645    @Override
    47     public void endTest()
    48     {
    49         _errorWays = null;
     46    public void endTest() {
     47        errorWays = null;
    5048        super.endTest();
    5149    }
    5250
    5351    @Override
    54     public void visit(Way w)
    55     {
     52    public void visit(Way w) {
    5653        String errortype = "";
    5754        int type;
    5855
    59         if( !w.isUsable() )
     56        if (!w.isUsable())
    6057            return;
    6158        if (w.getNodesCount() <= 0)
     
    6360
    6461        String natural = w.get("natural");
    65         if( natural == null)
     62        if (natural == null)
    6663            return;
    6764
    68         if( natural.equals("coastline") )
    69         {
     65        if (natural.equals("coastline")) {
    7066            errortype = tr("Reversed coastline: land not on left side");
    7167            type= WRONGLY_ORDERED_COAST;
    72         }
    73         else if(natural.equals("water") )
    74         {
     68        } else if (natural.equals("water")) {
    7569            errortype = tr("Reversed water: land not on left side");
    7670            type= WRONGLY_ORDERED_WATER;
    77         }
    78         else if( natural.equals("land") )
    79         {
     71        } else if (natural.equals("land")) {
    8072            errortype = tr("Reversed land: land not on left side");
    8173            type= WRONGLY_ORDERED_LAND;
    82         }
    83         else
     74        } else
    8475            return;
    85 
    8676
    8777        /**
     
    9383         *
    9484         */
    95 
    96         if(w.getNode(0) == w.getNode(w.getNodesCount()-1))
    97         {
     85        if(w.getNode(0) == w.getNode(w.getNodesCount()-1)) {
    9886            double area2 = 0;
    9987
    100             for (int node = 1; node < w.getNodesCount(); node++)
    101             {
     88            for (int node = 1; node < w.getNodesCount(); node++) {
    10289                area2 += (w.getNode(node-1).getCoor().lon() * w.getNode(node).getCoor().lat()
    10390                - w.getNode(node).getCoor().lon() * w.getNode(node-1).getCoor().lat());
    10491            }
    10592
    106             if(((natural.equals("coastline") || natural.equals("land")) && area2 < 0.)
    107             || (natural.equals("water") && area2 > 0.))
    108             {
     93            if (((natural.equals("coastline") || natural.equals("land")) && area2 < 0.)
     94                    || (natural.equals("water") && area2 > 0.)) {
    10995                List<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>();
    11096                primitives.add(w);
    11197                errors.add( new TestError(this, Severity.OTHER, errortype, type, primitives) );
    112                 _errorWays.add(w,w);
     98                errorWays.add(w,w);
    11399            }
    114100        }
  • trunk/src/org/openstreetmap/josm/data/validation/util/AgregatePrimitivesVisitor.java

    r3669 r3671  
    1919 * @author frsantos
    2020 */
    21 public class AgregatePrimitivesVisitor extends AbstractVisitor
    22 {
     21public class AgregatePrimitivesVisitor extends AbstractVisitor {
    2322    /** Aggregated data */
    2423    final Collection<OsmPrimitive> aggregatedData = new HashSet<OsmPrimitive>();
     
    2928     * @return The aggregated primitives
    3029     */
    31     public Collection<OsmPrimitive> visit(Collection<OsmPrimitive> data)
    32     {
    33         for (OsmPrimitive osm : data)
    34         {
     30    public Collection<OsmPrimitive> visit(Collection<OsmPrimitive> data) {
     31        for (OsmPrimitive osm : data) {
    3532            osm.visit(this);
    3633        }
     
    3936    }
    4037
    41     public void visit(Node n)
    42     {
    43         if(!aggregatedData.contains(n))
     38    @Override
     39    public void visit(Node n) {
     40        if (!aggregatedData.contains(n)) {
    4441            aggregatedData.add(n);
    45     }
    46 
    47     public void visit(Way w)
    48     {
    49         if(!aggregatedData.contains(w))
    50         {
    51             aggregatedData.add(w);
    52             for (Node n : w.getNodes())
    53                 visit(n);
    5442        }
    5543    }
    5644
     45    @Override
     46    public void visit(Way w) {
     47        if (!aggregatedData.contains(w)) {
     48            aggregatedData.add(w);
     49            for (Node n : w.getNodes()) {
     50                visit(n);
     51            }
     52        }
     53    }
     54
     55    @Override
    5756    public void visit(Relation r) {
    5857        if (!aggregatedData.contains(r)) {
  • trunk/src/org/openstreetmap/josm/data/validation/util/MultipleNameVisitor.java

    r3669 r3671  
    3131     * @param data The collection of primitives
    3232     */
    33     public void visit(Collection<? extends OsmPrimitive> data)
    34     {
     33    public void visit(Collection<? extends OsmPrimitive> data) {
    3534        String multipleName = null;
    3635        String multiplePluralClassname = null;
     
    4039
    4140        multipleClassname = null;
    42         for (OsmPrimitive osm : data)
    43         {
     41        for (OsmPrimitive osm : data) {
    4442            String name = osm.get("name");
    45             if(name == null) name = osm.get("ref");
    46             if(!initializedname)
    47             {
     43            if (name == null) {
     44                name = osm.get("ref");
     45            }
     46            if (!initializedname) {
    4847                multipleName = name; initializedname = true;
    49             }
    50             else if(multipleName != null && (name == null  || !name.equals(multipleName)))
    51             {
     48            } else if (multipleName != null && (name == null  || !name.equals(multipleName))) {
    5249                multipleName = null;
    5350            }
    5451
    55             if(firstName == null && name != null)
     52            if (firstName == null && name != null) {
    5653                firstName = name;
     54            }
    5755            osm.visit(this);
    58             if (multipleClassname == null)
    59             {
     56            if (multipleClassname == null) {
    6057                multipleClassname = className;
    6158                multiplePluralClassname = classNamePlural;
    62             }
    63             else if (!multipleClassname.equals(className))
    64             {
     59            } else if (!multipleClassname.equals(className)) {
    6560                multipleClassname = "object";
    6661                multiplePluralClassname = trn("object", "objects", 2);
     
    6863        }
    6964
    70         if( size == 1 )
     65        if (size == 1) {
    7166            displayName = name;
    72         else if(multipleName != null)
     67        } else if (multipleName != null) {
    7368            displayName = size + " " + trn(multipleClassname, multiplePluralClassname, size) + ": " + multipleName;
    74         else if(firstName != null)
     69        } else if (firstName != null) {
    7570            displayName = size + " " + trn(multipleClassname, multiplePluralClassname, size) + ": " + tr("{0}, ...", firstName);
    76         else
     71        } else {
    7772            displayName = size + " " + trn(multipleClassname, multiplePluralClassname, size);
     73        }
    7874    }
    7975
    8076    @Override
    81     public JLabel toLabel()
    82     {
     77    public JLabel toLabel() {
    8378        return new JLabel(getText(), getIcon(), JLabel.HORIZONTAL);
    8479    }
     
    8883     * @return the name of the items
    8984     */
    90     public String getText()
    91     {
     85    public String getText() {
    9286        return displayName;
    9387    }
     
    9791     * @return the icon of the items
    9892     */
    99     public Icon getIcon()
    100     {
    101         if( size == 1 )
     93    public Icon getIcon() {
     94        if (size == 1)
    10295            return icon;
    10396        else
  • trunk/src/org/openstreetmap/josm/data/validation/util/NameVisitor.java

    r3669 r3671  
    4343     * is displayed.
    4444     */
     45    @Override
    4546    public void visit(Node n) {
    4647        name = n.getDisplayName(DefaultNameFormatter.getInstance());
     
    5556     * is displayed with x being the number of nodes in the way.
    5657     */
     58    @Override
    5759    public void visit(Way w) {
    5860        name = w.getDisplayName(DefaultNameFormatter.getInstance());
     
    6567    /**
    6668     */
     69    @Override
    6770    public void visit(Relation e) {
    6871        name = e.getDisplayName(DefaultNameFormatter.getInstance());
     
    7780    }
    7881
    79 
    8082    private void addId(OsmPrimitive osm) {
    81         if (Main.pref.getBoolean("osm-primitives.showid"))
     83        if (Main.pref.getBoolean("osm-primitives.showid")) {
    8284            name += tr(" [id: {0}]", osm.getId());
     85        }
    8386    }
    8487}
  • trunk/src/org/openstreetmap/josm/data/validation/util/ValUtil.java

    r3670 r3671  
    3838     * @return A list with all the cells the way starts or ends
    3939     */
    40     public static List<List<Way>> getWaysInCell(Way w, Map<Point2D,List<Way>> cellWays)
    41     {
     40    public static List<List<Way>> getWaysInCell(Way w, Map<Point2D,List<Way>> cellWays) {
    4241        if (w.getNodesCount() == 0)
    4342            return Collections.emptyList();
     
    5958        cell = new Point2D.Double(x0, y0);
    6059        cellNodes.add(cell);
    61         List<Way> ways = cellWays.get( cell );
    62         if( ways == null )
    63         {
     60        List<Way> ways = cellWays.get(cell);
     61        if (ways == null) {
    6462            ways = new ArrayList<Way>();
    6563            cellWays.put(cell, ways);
     
    6967        // End of the way
    7068        cell = new Point2D.Double(x1, y1);
    71         if( !cellNodes.contains(cell) )
    72         {
     69        if (!cellNodes.contains(cell)) {
    7370            cellNodes.add(cell);
    7471            ways = cellWays.get( cell );
    75             if( ways == null )
    76             {
     72            if (ways == null) {
    7773                ways = new ArrayList<Way>();
    7874                cellWays.put(cell, ways);
     
    8278
    8379        // Then floor coordinates, in case the way is in the border of the cell.
    84         x0 = (long)Math.floor(n1.getEastNorth().east()  * OsmValidator.griddetail);
    85         y0 = (long)Math.floor(n1.getEastNorth().north() * OsmValidator.griddetail);
    86         x1 = (long)Math.floor(n2.getEastNorth().east()  * OsmValidator.griddetail);
    87         y1 = (long)Math.floor(n2.getEastNorth().north() * OsmValidator.griddetail);
     80        x0 = (long) Math.floor(n1.getEastNorth().east()  * OsmValidator.griddetail);
     81        y0 = (long) Math.floor(n1.getEastNorth().north() * OsmValidator.griddetail);
     82        x1 = (long) Math.floor(n2.getEastNorth().east()  * OsmValidator.griddetail);
     83        y1 = (long) Math.floor(n2.getEastNorth().north() * OsmValidator.griddetail);
    8884
    8985        // Start of the way
    9086        cell = new Point2D.Double(x0, y0);
    91         if( !cellNodes.contains(cell) )
    92         {
     87        if (!cellNodes.contains(cell)) {
    9388            cellNodes.add(cell);
    94             ways = cellWays.get( cell );
    95             if( ways == null )
    96             {
     89            ways = cellWays.get(cell);
     90            if (ways == null) {
    9791                ways = new ArrayList<Way>();
    9892                cellWays.put(cell, ways);
     
    10397        // End of the way
    10498        cell = new Point2D.Double(x1, y1);
    105         if( !cellNodes.contains(cell) )
    106         {
     99        if (!cellNodes.contains(cell)) {
    107100            cellNodes.add(cell);
    108             ways = cellWays.get( cell );
    109             if( ways == null )
    110             {
     101            ways = cellWays.get(cell);
     102            if (ways == null) {
    111103                ways = new ArrayList<Way>();
    112104                cellWays.put(cell, ways);
     
    114106            cells.add(ways);
    115107        }
    116 
    117108        return cells;
    118109    }
     
    128119     * @return A list with the coordinates of all cells
    129120     */
    130     public static List<Point2D> getSegmentCells(Node n1, Node n2, double gridDetail)
    131     {
     121    public static List<Point2D> getSegmentCells(Node n1, Node n2, double gridDetail) {
    132122        List<Point2D> cells = new ArrayList<Point2D>();
    133123        double x0 = n1.getEastNorth().east() * gridDetail;
     
    136126        double y1 = n2.getEastNorth().north() * gridDetail + 1;
    137127
    138         if( x0 > x1 )
    139         {
     128        if (x0 > x1) {
    140129            // Move to 1st-4th cuadrants
    141130            double aux;
     
    147136        double dy  = y1 - y0;
    148137        long stepY = y0 <= y1 ? 1 : -1;
    149         long gridX0 = (long)Math.floor(x0);
    150         long gridX1 = (long)Math.floor(x1);
    151         long gridY0 = (long)Math.floor(y0);
    152         long gridY1 = (long)Math.floor(y1);
     138        long gridX0 = (long) Math.floor(x0);
     139        long gridX1 = (long) Math.floor(x1);
     140        long gridY0 = (long) Math.floor(y0);
     141        long gridY1 = (long) Math.floor(y1);
    153142
    154143        long maxSteps = (gridX1 - gridX0) + Math.abs(gridY1 - gridY0) + 1;
    155         while( (gridX0 <= gridX1 && (gridY0 - gridY1)*stepY <= 0) && maxSteps-- > 0)
    156         {
    157             cells.add( new Point2D.Double(gridX0, gridY0) );
     144        while ((gridX0 <= gridX1 && (gridY0 - gridY1)*stepY <= 0) && maxSteps-- > 0) {
     145            cells.add( new Point2D.Double(gridX0, gridY0));
    158146
    159147            // Is the cross between the segment and next vertical line nearer than the cross with next horizontal line?
     
    166154            double distY = Math.pow(scanX - x0, 2) + Math.pow(gridY0 + stepY - y0, 2);
    167155
    168             if( distX < distY)
     156            if (distX < distY) {
    169157                gridX0 += 1;
    170             else
     158            } else {
    171159                gridY0 += stepY;
     160            }
    172161        }
    173 
    174162        return cells;
    175163    }
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r3669 r3671  
    11// License: GPL. See LICENSE file for details.
    2 
    32package org.openstreetmap.josm.gui;
    43
     
    7776import org.openstreetmap.josm.actions.ZoomOutAction;
    7877import org.openstreetmap.josm.actions.OrthogonalizeAction.Undo;
    79 import org.openstreetmap.josm.actions.ValidateAction;
    8078import org.openstreetmap.josm.actions.audio.AudioBackAction;
    8179import org.openstreetmap.josm.actions.audio.AudioFasterAction;
     
    8987import org.openstreetmap.josm.gui.tagging.TaggingPresetSearchAction;
    9088import org.openstreetmap.josm.tools.Shortcut;
     89
    9190/**
    9291 * This is the JOSM main menu bar. It is overwritten to initialize itself and provide all menu
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

    r3669 r3671  
    22package org.openstreetmap.josm.gui.dialogs;
    33
    4 import org.openstreetmap.josm.gui.layer.Layer;
    5 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    64import static org.openstreetmap.josm.tools.I18n.marktr;
    75import static org.openstreetmap.josm.tools.I18n.tr;
     
    4846import org.openstreetmap.josm.data.validation.ValidatorVisitor;
    4947import org.openstreetmap.josm.gui.MapView;
    50 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
    5148import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    5249import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    5350import org.openstreetmap.josm.gui.SideButton;
    5451import org.openstreetmap.josm.gui.dialogs.validator.ValidatorTreePanel;
     52import org.openstreetmap.josm.gui.layer.Layer;
     53import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    5554import org.openstreetmap.josm.gui.preferences.ValidatorPreference;
    5655import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    7372    public ValidatorTreePanel tree;
    7473
     74    /** The fix button */
    7575    private SideButton fixButton;
    76     /** The fix button */
     76    /** The ignore button */
    7777    private SideButton ignoreButton;
    78     /** The ignore button */
     78    /** The select button */
    7979    private SideButton selectButton;
    80     /** The select button */
    8180
    8281    private JPopupMenu popupMenu;
     
    9897        JMenuItem zoomTo = new JMenuItem(tr("Zoom to problem"));
    9998        zoomTo.addActionListener(new ActionListener() {
     99            @Override
    100100            public void actionPerformed(ActionEvent e) {
    101101                zoomToProblem();
     
    129129        }
    130130        add(buttonPanel, BorderLayout.SOUTH);
    131 
    132131    }
    133132
     
    154153    @Override
    155154    public void setVisible(boolean v) {
    156         if (tree != null)
     155        if (tree != null) {
    157156            tree.setVisible(v);
     157        }
    158158        super.setVisible(v);
    159159        Main.map.repaint();
     
    176176        for (TreePath path : selectionPaths) {
    177177            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    178             if (node == null)
     178            if (node == null) {
    179179                continue;
     180            }
    180181
    181182            Enumeration<DefaultMutableTreeNode> children = node.breadthFirstEnumeration();
    182183            while (children.hasMoreElements()) {
    183184                DefaultMutableTreeNode childNode = children.nextElement();
    184                 if (processedNodes.contains(childNode))
     185                if (processedNodes.contains(childNode)) {
    185186                    continue;
     187                }
    186188
    187189                processedNodes.add(childNode);
     
    215217        for (TreePath path : selectionPaths) {
    216218            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    217             if (node == null)
     219            if (node == null) {
    218220                continue;
     221            }
    219222
    220223            Object mainNodeInfo = node.getUserObject();
     
    232235                    while (children.hasMoreElements()) {
    233236                        DefaultMutableTreeNode childNode = children.nextElement();
    234                         if (processedNodes.contains(childNode))
     237                        if (processedNodes.contains(childNode)) {
    235238                            continue;
     239                        }
    236240
    237241                        processedNodes.add(childNode);
     
    248252                    }
    249253                    continue;
    250                 } else if (asked == JOptionPane.CANCEL_OPTION)
     254                } else if (asked == JOptionPane.CANCEL_OPTION) {
    251255                    continue;
     256                }
    252257            }
    253258
     
    255260            while (children.hasMoreElements()) {
    256261                DefaultMutableTreeNode childNode = children.nextElement();
    257                 if (processedNodes.contains(childNode))
     262                if (processedNodes.contains(childNode)) {
    258263                    continue;
     264                }
    259265
    260266                processedNodes.add(childNode);
     
    329335            }
    330336        }
    331 
    332337        Main.main.getCurrentDataSet().setSelected(sel);
    333338    }
    334339
     340    @Override
    335341    public void actionPerformed(ActionEvent e) {
    336342        String actionCommand = e.getActionCommand();
    337         if (actionCommand.equals("Select"))
     343        if (actionCommand.equals("Select")) {
    338344            setSelectedItems();
    339         else if (actionCommand.equals("Fix"))
     345        } else if (actionCommand.equals("Fix")) {
    340346            fixErrors(e);
    341         else if (actionCommand.equals("Ignore"))
     347        } else if (actionCommand.equals("Ignore")) {
    342348            ignoreErrors(e);
     349        }
    343350    }
    344351
     
    389396        }
    390397        selectButton.setEnabled(true);
    391         if (ignoreButton != null)
     398        if (ignoreButton != null) {
    392399            ignoreButton.setEnabled(true);
     400        }
    393401
    394402        return hasFixes;
     
    415423        public void mouseClicked(MouseEvent e) {
    416424            fixButton.setEnabled(false);
    417             if (ignoreButton != null)
     425            if (ignoreButton != null) {
    418426                ignoreButton.setEnabled(false);
     427            }
    419428            selectButton.setEnabled(false);
    420429
     
    428437            if (isDblClick) {
    429438                Main.main.getCurrentDataSet().setSelected(sel);
    430                 if(Main.pref.getBoolean("validator.autozoom", false))
     439                if(Main.pref.getBoolean("validator.autozoom", false)) {
    431440                    AutoScaleAction.zoomTo(sel);
     441                }
    432442            }
    433443        }
     
    449459     */
    450460    public class SelectionWatch implements TreeSelectionListener {
     461        @Override
    451462        public void valueChanged(TreeSelectionEvent e) {
    452463            fixButton.setEnabled(false);
    453             if (ignoreButton != null)
     464            if (ignoreButton != null) {
    454465                ignoreButton.setEnabled(false);
     466            }
    455467            selectButton.setEnabled(false);
    456468
     
    467479
    468480    public static class ValidatorBoundingXYVisitor extends BoundingXYVisitor implements ValidatorVisitor {
    469 
     481        @Override
    470482        public void visit(OsmPrimitive p) {
    471483            if (p.isUsable()) {
     
    474486        }
    475487
     488        @Override
    476489        public void visit(WaySegment ws) {
    477490            if (ws.lowerIndex < 0 || ws.lowerIndex + 1 >= ws.way.getNodesCount())
     
    481494        }
    482495
     496        @Override
    483497        public void visit(List<Node> nodes) {
    484498            for (Node n: nodes) {
     
    491505        if (!Main.pref.getBoolean(ValidatorPreference.PREF_FILTER_BY_SELECTION, false))
    492506            return;
    493         if (newSelection.isEmpty())
     507        if (newSelection.isEmpty()) {
    494508            tree.setFilter(null);
     509        }
    495510        HashSet<OsmPrimitive> filter = new HashSet<OsmPrimitive>(newSelection);
    496511        tree.setFilter(filter);
    497512    }
    498513
     514    @Override
    499515    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    500516        updateSelection(newSelection);
     
    539555                    final Command fixCommand = error.getFix();
    540556                    if (fixCommand != null) {
    541                         SwingUtilities.invokeAndWait(
    542                                 new Runnable() {
    543                                     public void run() {
    544                                         Main.main.undoRedo.addNoRedraw(fixCommand);
    545                                     }
    546                                 }
    547                         );
     557                        SwingUtilities.invokeAndWait(new Runnable() {
     558                            @Override
     559                            public void run() {
     560                                Main.main.undoRedo.addNoRedraw(fixCommand);
     561                            }
     562                        });
    548563                        error.setIgnored(true);
    549564                    }
     
    552567                monitor.subTask(tr("Updating map ..."));
    553568                SwingUtilities.invokeAndWait(new Runnable() {
     569                    @Override
    554570                    public void run() {
    555571                        Main.main.undoRedo.afterAdd();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java

    r3669 r3671  
    3333 * @author frsantos
    3434 */
    35 
    3635public class ValidatorTreePanel extends JTree {
    3736    /** Serializable ID */
     
    4140     * The validation data.
    4241     */
    43     protected DefaultTreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
     42    protected DefaultTreeModel valTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    4443
    4544    /** The list of errors shown in the tree */
     
    6059    public ValidatorTreePanel(List<TestError> errors) {
    6160        ToolTipManager.sharedInstance().registerComponent(this);
    62         this.setModel(treeModel);
     61        this.setModel(valTreeModel);
    6362        this.setRootVisible(false);
    6463        this.setShowsRootHandles(true);
     
    8786                    res += "<br>" + d;
    8887                res += "</html>";
    89             } else
     88            } else {
    9089                res = node.toString();
     90            }
    9191        }
    9292        return res;
     
    100100    @Override
    101101    public void setVisible(boolean v) {
    102         if (v)
     102        if (v) {
    103103            buildTree();
    104         else
    105             treeModel.setRoot(new DefaultMutableTreeNode());
     104        } else {
     105            valTreeModel.setRoot(new DefaultMutableTreeNode());
     106        }
    106107        super.setVisible(v);
    107108    }
     
    115116
    116117        if (errors == null || errors.isEmpty()) {
    117             treeModel.setRoot(rootNode);
     118            valTreeModel.setRoot(rootNode);
    118119            return;
    119120        }
     
    127128                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    128129                Object userObject = node.getUserObject();
    129                 if (userObject instanceof Severity)
     130                if (userObject instanceof Severity) {
    130131                    oldSelectedRows.add(userObject);
    131                 else if (userObject instanceof String) {
     132                } else if (userObject instanceof String) {
    132133                    String msg = (String) userObject;
    133134                    msg = msg.substring(0, msg.lastIndexOf(" ("));
     
    145146
    146147        for (TestError e : errors) {
    147             if (e.getIgnored())
     148            if (e.getIgnored()) {
    148149                continue;
     150            }
    149151            Severity s = e.getSeverity();
    150152            String d = e.getDescription();
     
    158160                    }
    159161                }
    160                 if (!found)
     162                if (!found) {
    161163                    continue;
     164                }
    162165            }
    163166            if (d != null) {
     
    168171                }
    169172                b.add(d, e);
    170             } else
     173            } else {
    171174                errorTree.get(s).add(m, e);
     175            }
    172176        }
    173177
     
    176180            Bag<String, TestError> severityErrors = errorTree.get(s);
    177181            Map<String, Bag<String, TestError>> severityErrorsDeep = errorTreeDeep.get(s);
    178             if (severityErrors.isEmpty() && severityErrorsDeep.isEmpty())
     182            if (severityErrors.isEmpty() && severityErrorsDeep.isEmpty()) {
    179183                continue;
     184            }
    180185
    181186            // Severity node
     
    183188            rootNode.add(severityNode);
    184189
    185             if (oldSelectedRows.contains(s))
     190            if (oldSelectedRows.contains(s)) {
    186191                expandedPaths.add(new TreePath(new Object[] { rootNode, severityNode }));
     192            }
    187193
    188194            for (Entry<String, List<TestError>> msgErrors : severityErrors.entrySet()) {
    189195                // Message node
    190                 List<TestError> errors = msgErrors.getValue();
    191                 String msg = msgErrors.getKey() + " (" + errors.size() + ")";
     196                List<TestError> errs = msgErrors.getValue();
     197                String msg = msgErrors.getKey() + " (" + errs.size() + ")";
    192198                DefaultMutableTreeNode messageNode = new DefaultMutableTreeNode(msg);
    193199                severityNode.add(messageNode);
     
    197203                }
    198204
    199                 for (TestError error : errors) {
     205                for (TestError error : errs) {
    200206                    // Error node
    201207                    DefaultMutableTreeNode errorNode = new DefaultMutableTreeNode(error);
     
    218224                for (Entry<String, List<TestError>> msgErrors : errorlist.entrySet()) {
    219225                    // Message node
    220                     List<TestError> errors = msgErrors.getValue();
     226                    List<TestError> errs = msgErrors.getValue();
    221227                    String msg;
    222                     if (groupNode != null)
    223                         msg = msgErrors.getKey() + " (" + errors.size() + ")";
    224                     else
    225                         msg = bag.getKey() + " - " + msgErrors.getKey() + " (" + errors.size() + ")";
     228                    if (groupNode != null) {
     229                        msg = msgErrors.getKey() + " (" + errs.size() + ")";
     230                    } else {
     231                        msg = bag.getKey() + " - " + msgErrors.getKey() + " (" + errs.size() + ")";
     232                    }
    226233                    DefaultMutableTreeNode messageNode = new DefaultMutableTreeNode(msg);
    227                     if (groupNode != null)
     234                    if (groupNode != null) {
    228235                        groupNode.add(messageNode);
    229                     else
     236                    } else {
    230237                        severityNode.add(messageNode);
     238                    }
    231239
    232240                    if (oldSelectedRows.contains(msgErrors.getKey())) {
     
    239247                    }
    240248
    241                     for (TestError error : errors) {
     249                    for (TestError error : errs) {
    242250                        // Error node
    243251                        DefaultMutableTreeNode errorNode = new DefaultMutableTreeNode(error);
     
    248256        }
    249257
    250         treeModel.setRoot(rootNode);
     258        valTreeModel.setRoot(rootNode);
    251259        for (TreePath path : expandedPaths) {
    252260            this.expandPath(path);
     
    260268    public void setErrorList(List<TestError> errors) {
    261269        this.errors = errors;
    262         if (isVisible())
     270        if (isVisible()) {
    263271            buildTree();
     272        }
    264273    }
    265274
     
    273282        errors.clear();
    274283        for (TestError error : newerrors) {
    275             if (!error.getIgnored())
     284            if (!error.getIgnored()) {
    276285                errors.add(error);
    277         }
    278         if (isVisible())
     286            }
     287        }
     288        if (isVisible()) {
    279289            buildTree();
     290        }
    280291    }
    281292
     
    293304
    294305    public void setFilter(Set<OsmPrimitive> filter) {
    295         if (filter != null && filter.size() == 0)
     306        if (filter != null && filter.isEmpty()) {
    296307            this.filter = null;
    297         else
     308        } else {
    298309            this.filter = filter;
    299         if (isVisible())
     310        }
     311        if (isVisible()) {
    300312            buildTree();
     313        }
    301314    }
    302315
     
    330343     */
    331344    public DefaultMutableTreeNode getRoot() {
    332         return (DefaultMutableTreeNode) treeModel.getRoot();
     345        return (DefaultMutableTreeNode) valTreeModel.getRoot();
    333346    }
    334347
  • trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreeRenderer.java

    r3669 r3671  
    2525    public Component getTreeCellRendererComponent(JTree tree, Object value,
    2626            boolean selected, boolean expanded, boolean leaf, int row,
    27             boolean hasFocus)
    28     {
     27            boolean hasFocus) {
    2928        super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    3029
    31         DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
     30        DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    3231        Object nodeInfo = node.getUserObject();
    3332
    34         if (nodeInfo instanceof Severity)
    35         {
    36             Severity s = (Severity)nodeInfo;
     33        if (nodeInfo instanceof Severity) {
     34            Severity s = (Severity) nodeInfo;
    3735            setIcon(ImageProvider.get("data", s.getIcon()));
    38         }
    39         else if (nodeInfo instanceof TestError)
    40         {
    41             TestError error = (TestError)nodeInfo;
     36        } else if (nodeInfo instanceof TestError) {
     37            TestError error = (TestError) nodeInfo;
    4238            MultipleNameVisitor v = new MultipleNameVisitor();
    4339            v.visit(error.getPrimitives());
     
    4541            setIcon(v.getIcon());
    4642        }
    47 
    4843        return this;
    4944    }
  • trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java

    r3669 r3671  
    3535    private int updateCount = -1;
    3636
    37 
    3837    public ValidatorLayer() {
    3938        super(tr("Validation errors"));
     
    6766            while (errorMessages.hasMoreElements()) {
    6867                Object tn = errorMessages.nextElement().getUserObject();
    69                 if (tn instanceof TestError)
     68                if (tn instanceof TestError) {
    7069                    ((TestError) tn).paint(g, mv);
     70                }
    7171            }
    7272
     
    8686        StringBuilder b = new StringBuilder();
    8787        for (Severity s : Severity.values()) {
    88             if (errorTree.containsKey(s))
     88            if (errorTree.containsKey(s)) {
    8989                b.append(tr(s.toString())).append(": ").append(errorTree.get(s).size()).append("<br>");
     90            }
    9091        }
    9192
     
    134135    }
    135136
     137    @Override
    136138    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    137139    }
    138140
     141    @Override
    139142    public void layerAdded(Layer newLayer) {
    140143    }
     
    143146     * If layer is the OSM Data layer, remove all errors
    144147     */
     148    @Override
    145149    public void layerRemoved(Layer oldLayer) {
    146150        if (oldLayer instanceof OsmDataLayer &&  Main.map.mapView.getEditLayer() == null) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/ValidatorPreference.java

    r3669 r3671  
    2323 * @author frsantos
    2424 */
    25 public class ValidatorPreference implements PreferenceSetting
    26 {
     25public class ValidatorPreference implements PreferenceSetting {
    2726
    2827    public static class Factory implements PreferenceSettingFactory {
     28        @Override
    2929        public PreferenceSetting createPreferenceSetting() {
    3030            return new ValidatorPreference();
     
    6666    private Collection<Test> allTests;
    6767
     68    @Override
    6869    public void addGui(PreferenceTabbedPane gui)
    6970    {
     
    8990
    9091        allTests = OsmValidator.getTests();
    91         for(Test test: allTests)
    92         {
     92        for (Test test: allTests) {
    9393            test.addGui(testPanel);
    9494        }
     
    103103    }
    104104
    105     public boolean ok()
    106     {
     105    @Override
     106    public boolean ok() {
    107107        StringBuilder tests = new StringBuilder();
    108108        StringBuilder testsBeforeUpload = new StringBuilder();
    109         Boolean res = false;
    110109
    111         for (Test test : allTests)
    112         {
    113             if(test.ok())
    114                 res = false;
     110        for (Test test : allTests) {
    115111            String name = test.getClass().getSimpleName();
    116             tests.append( ',' ).append( name ).append( '=' ).append( test.enabled );
    117             testsBeforeUpload.append( ',' ).append( name ).append( '=' ).append( test.testBeforeUpload );
     112            tests.append(',').append(name).append('=').append(test.enabled);
     113            testsBeforeUpload.append(',').append(name).append('=').append(test.testBeforeUpload);
    118114        }
    119115
    120         if (tests.length() > 0 ) tests = tests.deleteCharAt(0);
    121         if (testsBeforeUpload.length() > 0 ) testsBeforeUpload = testsBeforeUpload.deleteCharAt(0);
     116        if (tests.length() > 0) {
     117            tests = tests.deleteCharAt(0);
     118        }
     119        if (testsBeforeUpload.length() > 0) {
     120            testsBeforeUpload = testsBeforeUpload.deleteCharAt(0);
     121        }
    122122
    123         OsmValidator.initializeTests( allTests );
     123        OsmValidator.initializeTests(allTests);
    124124
    125         Main.pref.put( PREF_TESTS, tests.toString());
    126         Main.pref.put( PREF_TESTS_BEFORE_UPLOAD, testsBeforeUpload.toString());
    127         Main.pref.put( PREF_USE_IGNORE, prefUseIgnore.isSelected());
    128         Main.pref.put( PREF_OTHER_UPLOAD, prefOtherUpload.isSelected());
    129         Main.pref.put( PREF_LAYER, prefUseLayer.isSelected());
     125        Main.pref.put(PREF_TESTS, tests.toString());
     126        Main.pref.put(PREF_TESTS_BEFORE_UPLOAD, testsBeforeUpload.toString());
     127        Main.pref.put(PREF_USE_IGNORE, prefUseIgnore.isSelected());
     128        Main.pref.put(PREF_OTHER_UPLOAD, prefOtherUpload.isSelected());
     129        Main.pref.put(PREF_LAYER, prefUseLayer.isSelected());
    130130        return false;
    131131    }
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r3669 r3671  
    9292    public final static Collection<PluginProxy> pluginList = new LinkedList<PluginProxy>();
    9393
    94 
    9594    /**
    9695     * Removes deprecated plugins from a collection of plugins. Modifies the
Note: See TracChangeset for help on using the changeset viewer.