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

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

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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    /**
Note: See TracChangeset for help on using the changeset viewer.