Changeset 11726 in josm


Ignore:
Timestamp:
2017-03-13T18:54:20+01:00 (6 months ago)
Author:
michael2402
Message:

Don't use null to indicate a rotation of 0 degrees, simply set the rotation to 0.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/.classpath

    r11571 r11726  
    2121        <classpathentry kind="lib" path="test/lib/system-rules-1.16.1.jar"/>
    2222        <classpathentry kind="lib" path="test/lib/unitils-core/unitils-core-3.4.6.jar"/>
     23        <classpathentry kind="lib" path="pja.jar"/>
    2324        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    2425        <classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r11553 r11726  
    15321532        settingsMap.keySet().stream()
    15331533                .filter(key -> key.startsWith("color."))
    1534                 .flatMap(key -> {
     1534                .map(key -> {
    15351535                    final String newKey = ColorProperty.getColorKey(key.substring("color.".length()));
    1536                     return key.equals(newKey) || settingsMap.containsKey(newKey)
    1537                             ? Stream.empty()
    1538                             : Stream.of(new AbstractMap.SimpleImmutableEntry<>(key, newKey));
     1536                    return new AbstractMap.SimpleImmutableEntry<>(key, newKey);
     1537                })
     1538                .filter(entry -> {
     1539                    return !entry.getKey().equals(entry.getValue()) && !settingsMap.containsKey(entry.getValue());
    15391540                })
    15401541                .collect(Collectors.toList()) // to avoid ConcurrentModificationException
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/RenderBenchmarkCollector.java

    r10697 r11726  
    3737    /**
    3838     * Notified when the renderer method starts drawing
    39      * @param allStyleElems All the elements that are painted.
     39     * @param allStyleElems All the elements that are painted. Unsorted
    4040     * @return <code>true</code> if the renderer should continue to render
    4141     */
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaElement.java

    r11722 r11726  
    1515import org.openstreetmap.josm.gui.mappaint.Environment;
    1616import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
    17 import org.openstreetmap.josm.gui.util.RotationAngle;
    1817import org.openstreetmap.josm.tools.CheckParameterUtil;
    1918import org.openstreetmap.josm.tools.Utils;
     
    6362    public Float extentThreshold;
    6463
    65     /**
    66      * The icon that is displayed on the center of the area.
    67      */
    68     private final MapImage iconImage;
    69 
    70     /**
    71      * The rotation of the {@link #iconImageAngle}
    72      */
    73     private final RotationAngle iconImageAngle;
    74 
    75     protected AreaElement(Cascade c, Color color, MapImage fillImage, Float extent,
    76             Float extentThreshold, TextLabel text, MapImage iconImage, RotationAngle iconImageAngle) {
     64    protected AreaElement(Cascade c, Color color, MapImage fillImage, Float extent, Float extentThreshold, TextLabel text) {
    7765        super(c, 1f);
    7866        CheckParameterUtil.ensureParameterNotNull(color);
     
    8270        this.extentThreshold = extentThreshold;
    8371        this.text = text;
    84         this.iconImage = iconImage;
    85         this.iconImageAngle = iconImageAngle;
    8672    }
    8773
     
    119105
    120106        TextLabel text = null; // <- text is handled by TextElement
    121         MapImage iconImage = NodeElement.createIcon(env);
    122         RotationAngle rotationAngle = NodeElement.createRotationAngle(env);
    123 
    124         if (iconImage != null) {
    125             // fake a transparent color.
    126             color = new Color(0, 0, 0, 0);
    127         }
    128107
    129108        if (color != null) {
     
    131110            Float extentThreshold = c.get(FILL_EXTENT_THRESHOLD, null, float.class);
    132111
    133             return new AreaElement(c, color, fillImage, extent, extentThreshold, text, iconImage, rotationAngle);
     112            return new AreaElement(c, color, fillImage, extent, extentThreshold, text);
    134113        } else {
    135114            return null;
     
    156135            painter.drawArea((Relation) osm, myColor, fillImage, extent, extentThreshold, painter.isInactiveMode() || osm.isDisabled(), text);
    157136        }
    158 
    159         if (iconImage != null && painter.isShowIcons()) {
    160             painter.drawAreaIcon(osm, iconImage, painter.isInactiveMode() || osm.isDisabled(), selected, member,
    161                     iconImageAngle == null ? 0.0 : iconImageAngle.getRotationAngle(osm));
    162         }
    163137    }
    164138
     
    173147                Objects.equals(text, that.text) &&
    174148                Objects.equals(extent, that.extent) &&
    175                 Objects.equals(extentThreshold, that.extentThreshold) &&
    176                 Objects.equals(iconImage, that.iconImage) &&
    177                 Objects.equals(iconImageAngle, that.iconImageAngle);
     149                Objects.equals(extentThreshold, that.extentThreshold);
    178150    }
    179151
    180152    @Override
    181153    public int hashCode() {
    182         return Objects.hash(super.hashCode(), color, fillImage, text, extent, extentThreshold, iconImage, iconImageAngle);
     154        return Objects.hash(super.hashCode(), color, fillImage, text, extent, extentThreshold);
    183155    }
    184156
     
    186158    public String toString() {
    187159        return "AreaElemStyle{" + super.toString() + "color=" + Utils.toString(color) +
    188                 " fillImage=[" + fillImage + "] iconImage=[" + iconImage + "] iconImageAngle=[" + iconImageAngle + "]}";
     160                " fillImage=[" + fillImage + "]}";
    189161    }
    190162}
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java

    r11702 r11726  
    6666        this.mapImage = mapImage;
    6767        this.symbol = symbol;
    68         this.mapImageAngle = rotationAngle;
     68        this.mapImageAngle = Objects.requireNonNull(rotationAngle, "rotationAngle");
    6969    }
    7070
     
    106106        Cascade c = env.mc.getCascade(env.layer);
    107107
    108         RotationAngle rotationAngle = null;
     108        RotationAngle rotationAngle = RotationAngle.NO_ROTATION;
    109109        final Float angle = c.get(ICON_ROTATION, null, Float.class, true);
    110110        if (angle != null) {
  • trunk/src/org/openstreetmap/josm/gui/util/RotationAngle.java

    r11725 r11726  
    116116        }
    117117    }
     118
     119    /**
     120     * A no-rotation angle that always returns 0.
     121     * @since 11726
     122     */
     123    static RotationAngle NO_ROTATION = new StaticRotationAngle(0);
    118124
    119125    /**
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java

    r11714 r11726  
    9898                new TestConfig("area-fill-image", AREA_DEFAULT),
    9999
     100                /** Tests area label drawing/placement */
     101                new TestConfig("area-text", AREA_DEFAULT),
     102
    100103                /** Tests if all styles are sorted correctly. Tests {@link StyleRecord#compareTo(StyleRecord)} */
    101104                new TestConfig("order", AREA_DEFAULT)
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

    r10945 r11726  
    4848            Layer layer = new OsmDataLayer(ds, null, null);
    4949            Main.getLayerManager().addLayer(layer);
    50             // FIXME enable this test after we fix the bug. Test disabled for now
    51             // try {
    52             //     new JoinAreasAction().join(ds.getWays());
    53             // } finally {
    54             // Ensure we clean the place before leaving, even if test fails.
    55             Main.getLayerManager().removeLayer(layer);
    56             // }
     50            try {
     51                new JoinAreasAction().join(ds.getWays());
     52            } finally {
     53                // Ensure we clean the place before leaving, even if test fails.
     54                Main.getLayerManager().removeLayer(layer);
     55            }
    5756        }
    5857    }
     
    7776                Main.main.menu.joinAreas.join(Utils.filteredCollection(found, Way.class));
    7877
    79                 Collection<OsmPrimitive> found2 = SearchAction.searchAndReturn("type:way ref="+ref, SearchAction.SearchMode.replace);
     78                Collection<OsmPrimitive> found2 = SearchAction.searchAndReturn("type:relation ref="+ref, SearchAction.SearchMode.replace);
    8079                assertEquals(1, found2.size());
    8180                System.out.println(" ==> OK");
Note: See TracChangeset for help on using the changeset viewer.