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

Partial revert of [11726]: Committed to much.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.