Changeset 11728 in josm


Ignore:
Timestamp:
2017-03-13T19:10:48+01:00 (10 days ago)
Author:
michael2402
Message:

Partial revert of [11726]: Committed to much.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/.classpath

    r11726 r11728  
    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"/>
    2423        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    2524        <classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

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

    r11726 r11728  
    1515import org.openstreetmap.josm.gui.mappaint.Environment;
    1616import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
     17import org.openstreetmap.josm.gui.util.RotationAngle;
    1718import org.openstreetmap.josm.tools.CheckParameterUtil;
    1819import org.openstreetmap.josm.tools.Utils;
     
    6263    public Float extentThreshold;
    6364
    64     protected AreaElement(Cascade c, Color color, MapImage fillImage, Float extent, Float extentThreshold, TextLabel text) {
     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) {
    6577        super(c, 1f);
    6678        CheckParameterUtil.ensureParameterNotNull(color);
     
    7082        this.extentThreshold = extentThreshold;
    7183        this.text = text;
     84        this.iconImage = iconImage;
     85        this.iconImageAngle = iconImageAngle;
    7286    }
    7387
     
    105119
    106120        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        }
    107128
    108129        if (color != null) {
     
    110131            Float extentThreshold = c.get(FILL_EXTENT_THRESHOLD, null, float.class);
    111132
    112             return new AreaElement(c, color, fillImage, extent, extentThreshold, text);
     133            return new AreaElement(c, color, fillImage, extent, extentThreshold, text, iconImage, rotationAngle);
    113134        } else {
    114135            return null;
     
    135156            painter.drawArea((Relation) osm, myColor, fillImage, extent, extentThreshold, painter.isInactiveMode() || osm.isDisabled(), text);
    136157        }
     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        }
    137163    }
    138164
     
    147173                Objects.equals(text, that.text) &&
    148174                Objects.equals(extent, that.extent) &&
    149                 Objects.equals(extentThreshold, that.extentThreshold);
     175                Objects.equals(extentThreshold, that.extentThreshold) &&
     176                Objects.equals(iconImage, that.iconImage) &&
     177                Objects.equals(iconImageAngle, that.iconImageAngle);
    150178    }
    151179
    152180    @Override
    153181    public int hashCode() {
    154         return Objects.hash(super.hashCode(), color, fillImage, text, extent, extentThreshold);
     182        return Objects.hash(super.hashCode(), color, fillImage, text, extent, extentThreshold, iconImage, iconImageAngle);
    155183    }
    156184
     
    158186    public String toString() {
    159187        return "AreaElemStyle{" + super.toString() + "color=" + Utils.toString(color) +
    160                 " fillImage=[" + fillImage + "]}";
     188                " fillImage=[" + fillImage + "] iconImage=[" + iconImage + "] iconImageAngle=[" + iconImageAngle + "]}";
    161189    }
    162190}
Note: See TracChangeset for help on using the changeset viewer.