Changeset 7621 in josm


Ignore:
Timestamp:
2014-10-14T21:11:26+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #10615 - Inner ways of multipolygon not correctly displayed (regression from r7555)

Location:
trunk/src/org/openstreetmap/josm
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r7330 r7621  
    590590    }
    591591
     592    /**
     593     * Determines if this primitive is a member of a selected relation.
     594     * @return {@code true} if this primitive is a member of a selected relation, {@code false} otherwise
     595     */
    592596    public boolean isMemberOfSelected() {
    593597        if (referrers == null)
     
    598602            if (ref instanceof Relation && ref.isSelected())
    599603                return true;
     604        }
     605        return false;
     606    }
     607
     608    /**
     609     * Determines if this primitive is an outer member of a selected multipolygon relation.
     610     * @return {@code true} if this primitive is an outer member of a selected multipolygon relation, {@code false} otherwise
     611     * @since 7621
     612     */
     613    public boolean isOuterMemberOfSelected() {
     614        if (referrers == null)
     615            return false;
     616        if (referrers instanceof OsmPrimitive) {
     617            return isOuterMemberOfMultipolygon((OsmPrimitive) referrers);
     618        }
     619        for (OsmPrimitive ref : (OsmPrimitive[]) referrers) {
     620            if (isOuterMemberOfMultipolygon(ref))
     621                return true;
     622        }
     623        return false;
     624    }
     625
     626    private boolean isOuterMemberOfMultipolygon(OsmPrimitive ref) {
     627        if (ref instanceof Relation && ref.isSelected() && ((Relation)ref).isMultipolygon()) {
     628            for (RelationMember rm : ((Relation)ref).getMembersFor(Collections.singleton(this))) {
     629                if ("outer".equals(rm.getRole())) {
     630                    return true;
     631                }
     632            }
    600633        }
    601634        return false;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r7555 r7621  
    291291    private static final int FLAG_MEMBER_OF_SELECTED = 2;
    292292    private static final int FLAG_SELECTED = 4;
     293    private static final int FLAG_OUTERMEMBER_OF_SELECTED = 8;
    293294
    294295    private static final double PHI = Math.toRadians(20);
     
    15141515            } else if (w.isSelected()) {
    15151516                add(w, FLAG_SELECTED);
     1517            } else if (w.isOuterMemberOfSelected()) {
     1518                add(w, FLAG_OUTERMEMBER_OF_SELECTED);
    15161519            } else if (w.isMemberOfSelected()) {
    15171520                add(w, FLAG_MEMBER_OF_SELECTED);
     
    15271530            } else if (r.isSelected()) {
    15281531                add(r, FLAG_SELECTED);
     1532            } else if (r.isOuterMemberOfSelected()) {
     1533                add(r, FLAG_OUTERMEMBER_OF_SELECTED);
    15291534            } else if (r.isMemberOfSelected()) {
    15301535                add(r, FLAG_MEMBER_OF_SELECTED);
     
    16541659                        StyledMapRenderer.this,
    16551660                        (r.flags & FLAG_SELECTED) != 0,
     1661                        (r.flags & FLAG_OUTERMEMBER_OF_SELECTED) != 0,
    16561662                        (r.flags & FLAG_MEMBER_OF_SELECTED) != 0
    16571663                );
  • trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java

    r7555 r7621  
    8686
    8787    @Override
    88     public void paintPrimitive(OsmPrimitive osm, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean member) {
     88    public void paintPrimitive(OsmPrimitive osm, MapPaintSettings paintSettings, StyledMapRenderer painter,
     89            boolean selected, boolean outermember, boolean member) {
    8990        Color myColor = color;
    9091        if (osm instanceof Way) {
     
    9293                if (selected) {
    9394                    myColor = paintSettings.getSelectedColor(color.getAlpha());
    94                 } else if (member) {
     95                } else if (outermember) {
    9596                    myColor = paintSettings.getRelationSelectedColor(color.getAlpha());
    9697                }
     
    9899            painter.drawArea((Way) osm, myColor, fillImage, text);
    99100        } else if (osm instanceof Relation) {
    100             if (color != null && (selected || (member && ((Relation) osm).isMultipolygon()))) {
     101            if (color != null && (selected || outermember)) {
    101102                myColor = paintSettings.getRelationSelectedColor(color.getAlpha());
    102103            }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/BoxTextElemStyle.java

    r7383 r7621  
    179179
    180180    @Override
    181     public void paintPrimitive(OsmPrimitive osm, MapPaintSettings settings, StyledMapRenderer painter, boolean selected, boolean member) {
     181    public void paintPrimitive(OsmPrimitive osm, MapPaintSettings settings, StyledMapRenderer painter,
     182            boolean selected, boolean outermember, boolean member) {
    182183        if (osm instanceof Node) {
    183184            painter.drawBoxText((Node) osm, this);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java

    r7383 r7621  
    4343     * @param painter
    4444     * @param selected true, if primitive is selected
     45     * @param outermember true, if primitive is not selected and outer member of a selected multipolygon relation
    4546     * @param member true, if primitive is not selected and member of a selected relation
    4647     */
    47     public abstract void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean member);
     48    public abstract void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
     49            boolean selected, boolean outermember, boolean member);
    4850
    4951    public boolean isProperLineStyle() {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java

    r7136 r7621  
    264264
    265265    @Override
    266     public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean member) {
     266    public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
     267            boolean selected, boolean outermember, boolean member) {
    267268        Way w = (Way)primitive;
    268269        /* show direction arrows, if draw.segment.relevant_directions_only is not set,
     
    297298        if (selected) {
    298299            myColor = paintSettings.getSelectedColor(color.getAlpha());
    299         } else if (member) {
     300        } else if (member || outermember) {
    300301            myColor = paintSettings.getRelationSelectedColor(color.getAlpha());
    301302        } else if(w.isDisabled()) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/LineTextElemStyle.java

    r7383 r7621  
    3232
    3333    @Override
    34     public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean member) {
     34    public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
     35            boolean selected, boolean outermember, boolean member) {
    3536        Way w = (Way)primitive;
    3637        painter.drawTextOnPath(w, text);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java

    r7136 r7621  
    241241
    242242    @Override
    243     public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings settings, StyledMapRenderer painter, boolean selected, boolean member) {
     243    public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings settings, StyledMapRenderer painter,
     244            boolean selected, boolean outermember, boolean member) {
    244245        if (primitive instanceof Node) {
    245246            Node n = (Node) primitive;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/RepeatImageElemStyle.java

    r7083 r7621  
    5050
    5151    @Override
    52     public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean member) {
     52    public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
     53            boolean selected, boolean outermember, boolean member) {
    5354        Way w = (Way) primitive;
    5455        painter.drawRepeatImage(w, pattern.getImage(), offset, spacing, phase, align);
Note: See TracChangeset for help on using the changeset viewer.