[josm] 07/14: Imported Upstream version 0.0.svn8969+dfsg

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri Oct 30 14:40:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository josm.

commit b2e053eb191497ed175fb2c04655ccb92d3ceed0
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Oct 30 12:02:49 2015 +0100

    Imported Upstream version 0.0.svn8969+dfsg
---
 REVISION                                           |   8 +-
 .../openstreetmap/josm/actions/SplitWayAction.java |  16 ++-
 .../data/osm/visitor/paint/MapPaintSettings.java   | 135 ++++++++++++++++++++-
 .../josm/data/validation/tests/TagChecker.java     |   2 +-
 .../josm/gui/widgets/JosmImageView.java            |   4 +-
 .../io/remotecontrol/RemoteControlHttpServer.java  |   8 +-
 .../josm/actions/SplitWayActionTest.java           |  86 +++++++++++++
 7 files changed, 243 insertions(+), 16 deletions(-)

diff --git a/REVISION b/REVISION
index 903a5ff..ba85c09 100644
--- a/REVISION
+++ b/REVISION
@@ -2,7 +2,7 @@
 <info>
 <entry
    path="trunk"
-   revision="8964"
+   revision="8969"
    kind="dir">
 <url>https://josm.openstreetmap.de/svn/trunk</url>
 <relative-url>^/trunk</relative-url>
@@ -11,9 +11,9 @@
 <uuid>0c6e7542-c601-0410-84e7-c038aed88b3b</uuid>
 </repository>
 <commit
-   revision="8964">
-<author>simon04</author>
-<date>2015-10-27T22:40:20.350192Z</date>
+   revision="8969">
+<author>Don-vip</author>
+<date>2015-10-29T21:15:23.556649Z</date>
 </commit>
 </entry>
 </info>
diff --git a/src/org/openstreetmap/josm/actions/SplitWayAction.java b/src/org/openstreetmap/josm/actions/SplitWayAction.java
index fd6cb67..8dafc19 100644
--- a/src/org/openstreetmap/josm/actions/SplitWayAction.java
+++ b/src/org/openstreetmap/josm/actions/SplitWayAction.java
@@ -566,6 +566,7 @@ public class SplitWayAction extends JosmAction {
         if (!newSelection.contains(way)) {
             newSelection.add(way);
         }
+        final int indexOfWayToKeep = newWays.indexOf(wayToKeep);
         newWays.remove(wayToKeep);
 
         for (Way wayToAdd : newWays) {
@@ -676,10 +677,21 @@ public class SplitWayAction extends JosmAction {
                         }
 
                         int j = i_c;
-                        for (Way wayToAdd : newWays) {
+                        final List<Way> waysToAddBefore = newWays.subList(0, indexOfWayToKeep);
+                        for (Way wayToAdd : waysToAddBefore) {
                             RelationMember em = new RelationMember(rm.getRole(), wayToAdd);
                             j++;
-                            if ((backwards != null) && backwards) {
+                            if (Boolean.TRUE.equals(backwards)) {
+                                c.addMember(i_c + 1, em);
+                            } else {
+                                c.addMember(j - 1, em);
+                            }
+                        }
+                        final List<Way> waysToAddAfter = newWays.subList(indexOfWayToKeep, newWays.size());
+                        for (Way wayToAdd : waysToAddAfter) {
+                            RelationMember em = new RelationMember(rm.getRole(), wayToAdd);
+                            j++;
+                            if (Boolean.TRUE.equals(backwards)) {
                                 c.addMember(i_c, em);
                             } else {
                                 c.addMember(j, em);
diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java
index f6bf8d4..a32d5e9 100644
--- a/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java
+++ b/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java
@@ -7,8 +7,13 @@ import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
 
+/**
+ * Global mappaint settings.
+ * @since 2675
+ */
 public final class MapPaintSettings implements PreferenceChangedListener {
 
+    /** The unique instance **/
     public static final MapPaintSettings INSTANCE = new MapPaintSettings();
 
     private boolean useRealWidth;
@@ -16,6 +21,7 @@ public final class MapPaintSettings implements PreferenceChangedListener {
     private boolean showDirectionArrow;
     /** Preference: should arrows for oneways be displayed */
     private boolean showOnewayArrow;
+    /** Preference: default width for ways segments */
     private int defaultSegmentWidth;
     /** Preference: should the segment numbers of ways be displayed */
     private boolean showOrderNumber;
@@ -40,6 +46,7 @@ public final class MapPaintSettings implements PreferenceChangedListener {
     private boolean fillTaggedNode;
     /** Preference: should multiply connected nodes be filled */
     private boolean fillConnectionNode;
+    /** Preference: should only the data area outline be drawn */
     private boolean outlineOnly;
     /** Color Preference for selected objects */
     private Color selectedColor;
@@ -81,7 +88,6 @@ public final class MapPaintSettings implements PreferenceChangedListener {
             taggedConnectionColor = connectionColor;
         }
 
-
         showOrderNumber = Main.pref.getBoolean("draw.segment.order_number", false);
         showHeadArrowOnly = Main.pref.getBoolean("draw.segment.head_only", false);
 
@@ -99,7 +105,6 @@ public final class MapPaintSettings implements PreferenceChangedListener {
         fillConnectionNode = Main.pref.getBoolean("mappaint.node.fill-connection", false);
 
         outlineOnly = Main.pref.getBoolean("draw.data.area_outline_only", false);
-
     }
 
     @Override
@@ -107,118 +112,236 @@ public final class MapPaintSettings implements PreferenceChangedListener {
         load();
     }
 
+    /**
+     * Determines if the real width of ways should be used
+     * @return {@code true} if the real width of ways should be used
+     */
     public boolean isUseRealWidth() {
         return useRealWidth;
     }
 
+    /**
+     * Determines if directional arrows should be displayed
+     * @return {@code true} if directional arrows should be displayed
+     */
     public boolean isShowDirectionArrow() {
         return showDirectionArrow;
     }
 
+    /**
+     * Determines if arrows for oneways should be displayed
+     * @return {@code true} if arrows for oneways should be displayed
+     */
     public boolean isShowOnewayArrow() {
         return showOnewayArrow;
     }
 
+    /**
+     * Returns color for selected objects (nodes and ways)
+     * @return color for selected objects
+     */
     public Color getSelectedColor() {
         return selectedColor;
     }
 
-    public int getDefaultSegmentWidth() {
-        return defaultSegmentWidth;
-    }
-
+    /**
+     * Returns color for selected objects (nodes and ways) with a given alpha
+     * @param alpha alpha component in the range 0-255
+     * @return color for selected objects
+     */
     public Color getSelectedColor(int alpha) {
         return new Color(selectedColor.getRGB() & 0x00ffffff | (alpha << 24), true);
     }
 
+    /**
+     * Returns default width for ways segments
+     * @return default width for ways segments
+     */
+    public int getDefaultSegmentWidth() {
+        return defaultSegmentWidth;
+    }
+
+    /**
+     * Returns color for selected relations
+     * @return color for selected relations
+     */
     public Color getRelationSelectedColor() {
         return relationSelectedColor;
     }
 
+    /**
+     * Returns color for selected relations with a given alpha
+     * @param alpha alpha component in the range 0-255
+     * @return color for selected relations
+     */
     public Color getRelationSelectedColor(int alpha) {
         return new Color(relationSelectedColor.getRGB() & 0x00ffffff | (alpha << 24), true);
     }
 
+    /**
+     * Returns color for hightlighted objects
+     * @return color for hightlighted objects
+     */
     public Color getHighlightColor() {
         return highlightColor;
     }
 
+    /**
+     * Returns color for inactive objects
+     * @return color for inactive objects
+     */
     public Color getInactiveColor() {
         return inactiveColor;
     }
 
+    /**
+     * Returns color for nodes
+     * @return color for nodes
+     */
     public Color getNodeColor() {
         return nodeColor;
     }
 
+    /**
+     * Returns color for tagged nodes
+     * @return color for tagged nodes
+     */
     public Color getTaggedColor() {
         return taggedColor;
     }
 
+    /**
+     * Returns color for multiply connected nodes
+     * @return color for multiply connected nodes
+     */
     public Color getConnectionColor() {
         return connectionColor;
     }
 
+    /**
+     * Returns color for tagged and multiply connected nodes
+     * @return color for tagged and multiply connected nodes
+     */
     public Color getTaggedConnectionColor() {
         return taggedConnectionColor;
     }
 
+    /**
+     * Determines if the segment numbers of ways should be displayed
+     * @return {@code true} if the segment numbers of ways should be displayed
+     */
     public boolean isShowOrderNumber() {
         return showOrderNumber;
     }
 
+    /**
+     * Specifies if only the last arrow of a way should be displayed
+     * @param showHeadArrowOnly {@code true} if only the last arrow of a way should be displayed
+     */
     public void setShowHeadArrowOnly(boolean showHeadArrowOnly) {
         this.showHeadArrowOnly = showHeadArrowOnly;
     }
 
+    /**
+     * Determines if only the last arrow of a way should be displayed
+     * @return {@code true} if only the last arrow of a way should be displayed
+     */
     public boolean isShowHeadArrowOnly() {
         return showHeadArrowOnly;
     }
 
+    /**
+     * Returns the distance at which names should be drawn
+     * @return the distance at which names should be drawn
+     */
     public int getShowNamesDistance() {
         return showNamesDistance;
     }
 
+    /**
+     * Returns the distance at which strokes should be used
+     * @return the distance at which strokes should be used
+     */
     public int getUseStrokesDistance() {
         return useStrokesDistance;
     }
 
+    /**
+     * Returns the distance at which icons should be drawn
+     * @return the distance at which icons should be drawn
+     */
     public int getShowIconsDistance() {
         return showIconsDistance;
     }
 
+    /**
+     * Returns the size of selected nodes
+     * @return the size of selected nodes
+     */
     public int getSelectedNodeSize() {
         return selectedNodeSize;
     }
 
+    /**
+     * Returns the size of multiply connected nodes
+     * @return the size of multiply connected nodes
+     */
     public int getConnectionNodeSize() {
         return connectionNodeSize;
     }
 
+    /**
+     * Returns the size of unselected nodes
+     * @return the size of unselected nodes
+     */
     public int getUnselectedNodeSize() {
         return unselectedNodeSize;
     }
 
+    /**
+     * Returns the size of tagged nodes
+     * @return the size of tagged nodes
+     */
     public int getTaggedNodeSize() {
         return taggedNodeSize;
     }
 
+    /**
+     * Determines if selected nodes should be filled
+     * @return {@code true} if selected nodes should be filled
+     */
     public boolean isFillSelectedNode() {
         return fillSelectedNode;
     }
 
+    /**
+     * Determines if unselected nodes should be filled
+     * @return {@code true} if unselected nodes should be filled
+     */
     public boolean isFillUnselectedNode() {
         return fillUnselectedNode;
     }
 
+    /**
+     * Determines if multiply connected nodes should be filled
+     * @return {@code true} if multiply connected nodes should be filled
+     */
     public boolean isFillConnectionNode() {
         return fillConnectionNode;
     }
 
+    /**
+     * Determines if tagged nodes should be filled
+     * @return {@code true} if tagged nodes should be filled
+     */
     public boolean isFillTaggedNode() {
         return fillTaggedNode;
     }
 
+    /**
+     * Determines if only the data area outline should be drawn
+     * @return {@code true} if only the data area outline should be drawn
+     */
     public boolean isOutlineOnly() {
         return outlineOnly;
     }
diff --git a/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java b/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
index 4d989c7..98deef5 100644
--- a/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
+++ b/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
@@ -405,7 +405,7 @@ public class TagChecker extends TagTest {
                     if (!keyInPresets) {
                         String prettifiedKey = harmonizeKey(key);
                         String fixedKey = harmonizedKeys.get(prettifiedKey);
-                        if (fixedKey != null && !"".equals(fixedKey)) {
+                        if (fixedKey != null && !"".equals(fixedKey) && !fixedKey.equals(key)) {
                             // misspelled preset key
                             String i = marktr("Key ''{0}'' looks like ''{1}''.");
                             errors.add(new FixableTestError(this, Severity.WARNING, tr("Misspelled property key"),
diff --git a/src/org/openstreetmap/josm/gui/widgets/JosmImageView.java b/src/org/openstreetmap/josm/gui/widgets/JosmImageView.java
index 9cbec89..4ba4ee3 100644
--- a/src/org/openstreetmap/josm/gui/widgets/JosmImageView.java
+++ b/src/org/openstreetmap/josm/gui/widgets/JosmImageView.java
@@ -9,6 +9,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URL;
 
+import javax.swing.ImageIcon;
 import javax.swing.text.AttributeSet;
 import javax.swing.text.Element;
 import javax.swing.text.html.ImageView;
@@ -126,7 +127,8 @@ public class JosmImageView extends ImageView {
         if (src != null) {
             String urlStr = src.toExternalForm();
             if (urlStr.endsWith(".svg") || urlStr.endsWith(".svg?format=raw")) {
-                imageField.set(this, new ImageProvider(urlStr).get().getImage());
+                ImageIcon imgIcon = new ImageProvider(urlStr).setOptional(true).get();
+                imageField.set(this, imgIcon != null ? imgIcon.getImage() : null);
             } else {
                 Method loadImage = ImageView.class.getDeclaredMethod("loadImage");
                 loadImage.setAccessible(true);
diff --git a/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpServer.java b/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpServer.java
index 847b28c..a7e4dbb 100644
--- a/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpServer.java
+++ b/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpServer.java
@@ -100,9 +100,13 @@ public class RemoteControlHttpServer extends Thread {
                 @SuppressWarnings("resource")
                 Socket request = server.accept();
                 RequestProcessor.processRequest(request);
-            } catch (SocketException se) {
-                if (!server.isClosed())
+            } catch (SocketException se) {  
+                if (!server.isClosed()) {
                     Main.error(se);
+                } else {
+                    // stop the thread automatically if server is stopped
+                    return;
+                }
             } catch (IOException ioe) {
                 Main.error(ioe);
             }
diff --git a/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
index 4472ba0..fc6158d 100644
--- a/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
+++ b/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
@@ -1,18 +1,25 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.actions;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Iterator;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.openstreetmap.josm.JOSMFixture;
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.coor.EastNorth;
+import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.RelationMember;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
@@ -93,4 +100,83 @@ public final class SplitWayActionTest {
                        w1.getNode(i), w1NodesArray[i]);
         }
     }
+
+    @Test
+    public void testRouteRelation() {
+        doTestRouteRelation(false, 0);
+        doTestRouteRelation(false, 1);
+        doTestRouteRelation(false, 2);
+        doTestRouteRelation(false, 3);
+        doTestRouteRelation(true, 0);
+        doTestRouteRelation(true, 1);
+        doTestRouteRelation(true, 2);
+        doTestRouteRelation(true, 3);
+    }
+
+    void doTestRouteRelation(final boolean wayIsReversed, final int indexOfWayToKeep) {
+        final DataSet dataSet = new DataSet();
+        final OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
+        final Node n1 = new Node(new LatLon(1, 0));
+        final Node n2 = new Node(new LatLon(2, 0));
+        final Node n3 = new Node(new LatLon(3, 0));
+        final Node n4 = new Node(new LatLon(4, 0));
+        final Node n5 = new Node(new LatLon(5, 0));
+        final Node n6 = new Node(new LatLon(6, 0));
+        final Node n7 = new Node(new LatLon(7, 0));
+        final Way w1 = new Way();
+        final Way w2 = new Way();
+        final Way w3 = new Way();
+        final Relation route = new Relation();
+        for (OsmPrimitive p : Arrays.asList(n1, n2, n3, n4, n5, n6, n7, w1, w2, w3, route)) {
+            dataSet.addPrimitive(p);
+        }
+        w1.setNodes(Arrays.asList(n1, n2));
+        w2.setNodes(wayIsReversed
+                ? Arrays.asList(n6, n5, n4, n3, n2)
+                : Arrays.asList(n2, n3, n4, n5, n6)
+        );
+        w3.setNodes(Arrays.asList(n6, n7));
+        route.put("type", "route");
+        route.addMember(new RelationMember("", w1));
+        route.addMember(new RelationMember("", w2));
+        route.addMember(new RelationMember("", w3));
+        dataSet.setSelected(Arrays.asList(w2, n3, n4, n5));
+
+
+        final SplitWayAction.Strategy strategy = new SplitWayAction.Strategy() {
+
+            @Override
+            public Way determineWayToKeep(Iterable<Way> wayChunks) {
+                final Iterator<Way> it = wayChunks.iterator();
+                for (int i = 0; i < indexOfWayToKeep; i++) {
+                    it.next();
+                }
+                return it.next();
+            }
+        };
+        final SplitWayAction.SplitWayResult result = SplitWayAction.splitWay(
+                layer, w2, SplitWayAction.buildSplitChunks(w2, Arrays.asList(n3, n4, n5)), new ArrayList<OsmPrimitive>(), strategy);
+        Main.main.undoRedo.add(result.getCommand());
+
+        assertEquals(6, route.getMembersCount());
+        assertEquals(w1, route.getMemberPrimitivesList().get(0));
+        assertEquals(w3, route.getMemberPrimitivesList().get(5));
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(0)), n1);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(0)), n2);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(1)), n2);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(1)), n3);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(2)), n3);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(2)), n4);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(3)), n4);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(3)), n5);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(4)), n5);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(4)), n6);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(5)), n6);
+        assertFirstLastNodeIs(((Way) route.getMemberPrimitivesList().get(5)), n7);
+
+    }
+
+    static void assertFirstLastNodeIs(Way way, Node node) {
+        assertTrue("First/last node of " + way + " should be " + node, node.equals(way.firstNode()) || node.equals(way.lastNode()));
+    }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/josm.git



More information about the Pkg-grass-devel mailing list