Ignore:
Timestamp:
2016-01-07T18:13:44+01:00 (8 years ago)
Author:
bastiK
Message:

mapcss: basic support for :selected pseudoclass (see #9891)

Location:
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaElement.java

    r9323 r9341  
    138138    @Override
    139139    public int hashCode() {
    140         int hash = 3;
     140        int hash = super.hashCode();
    141141        hash = 61 * hash + color.hashCode();
    142142        hash = 61 * hash + (extent != null ? Float.floatToIntBits(extent) : 0);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java

    r9278 r9341  
    3232            c.put(Z_INDEX, -3f);
    3333        }
    34         return createLine(new Environment(null, mc, "default", null));
     34        Way w = new Way();
     35        return createLine(new Environment(w, mc, "default", null));
    3536    }
    3637
     
    4243    public float offset;
    4344    public float realWidth; // the real width of this line in meter
     45    public boolean wayDirectionArrows;
    4446
    4547    private BasicStroke dashesLine;
     
    6163
    6264    protected LineElement(Cascade c, float default_major_z_index, BasicStroke line, Color color, BasicStroke dashesLine,
    63             Color dashesBackground, float offset, float realWidth) {
     65            Color dashesBackground, float offset, float realWidth, boolean wayDirectionArrows) {
    6466        super(c, default_major_z_index);
    6567        this.line = line;
     
    6971        this.offset = offset;
    7072        this.realWidth = realWidth;
     73        this.wayDirectionArrows = wayDirectionArrows;
    7174    }
    7275
     
    264267        }
    265268
    266         return new LineElement(c, type.defaultMajorZIndex, line, color, dashesLine, dashesBackground, offset, realWidth);
     269        boolean wayDirectionArrows = c.get(type.prefix + WAY_DIRECTION_ARROWS, env.osm.isSelected(), Boolean.class);
     270
     271        return new LineElement(c, type.defaultMajorZIndex, line, color, dashesLine, dashesBackground,
     272                offset, realWidth, wayDirectionArrows);
    267273    }
    268274
     
    274280        the way is tagged with a direction key
    275281        (even if the tag is negated as in oneway=false) or the way is selected */
    276         boolean showOrientation = !isModifier && (selected || paintSettings.isShowDirectionArrow()) && !paintSettings.isUseRealWidth();
     282        boolean showOrientation;
     283        if (defaultSelectedHandling) {
     284            showOrientation = !isModifier && (selected || paintSettings.isShowDirectionArrow()) && !paintSettings.isUseRealWidth();
     285        } else {
     286            showOrientation = wayDirectionArrows;
     287        }
    277288        boolean showOneway = !isModifier && !selected &&
    278289                !paintSettings.isUseRealWidth() &&
     
    300311
    301312        Color myColor = color;
    302         if (selected) {
     313        if (defaultSelectedHandling && selected) {
    303314            myColor = paintSettings.getSelectedColor(color.getAlpha());
    304315        } else if (member || outermember) {
     
    342353            Objects.equals(dashesBackground, other.dashesBackground) &&
    343354            offset == other.offset &&
    344             realWidth == other.realWidth;
     355            realWidth == other.realWidth &&
     356            wayDirectionArrows == other.wayDirectionArrows;
    345357    }
    346358
     
    354366        hash = 29 * hash + Float.floatToIntBits(offset);
    355367        hash = 29 * hash + Float.floatToIntBits(realWidth);
     368        hash = 29 * hash + (this.wayDirectionArrows ? 1 : 0);
    356369        return hash;
    357370    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineTextElement.java

    r9278 r9341  
    5454    @Override
    5555    public int hashCode() {
    56         return text.hashCode();
     56        int hash = super.hashCode();
     57        hash = 43 * hash + text.hashCode();
     58        return hash;
    5759    }
    5860
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java

    r9284 r9341  
    285285                    if (painter.isInactiveMode() || n.isDisabled()) {
    286286                        fillColor = settings.getInactiveColor();
    287                     } else if (selected) {
     287                    } else if (defaultSelectedHandling && selected) {
    288288                        fillColor = settings.getSelectedColor(fillColor.getAlpha());
    289289                    } else if (member) {
     
    295295                    if (painter.isInactiveMode() || n.isDisabled()) {
    296296                        strokeColor = settings.getInactiveColor();
    297                     } else if (selected) {
     297                    } else if (defaultSelectedHandling && selected) {
    298298                        strokeColor = settings.getSelectedColor(strokeColor.getAlpha());
    299299                    } else if (member) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/RepeatImageElement.java

    r9278 r9341  
    8181    @Override
    8282    public int hashCode() {
    83         int hash = 7;
     83        int hash = super.hashCode();
    8484        hash = 83 * hash + this.pattern.hashCode();
    8585        hash = 83 * hash + Float.floatToIntBits(this.offset);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/StyleElement.java

    r9278 r9341  
    3232    public boolean isModifier;  // false, if style can serve as main style for the
    3333    // primitive; true, if it is a highlight or modifier
    34 
    35     public StyleElement(float major_z_index, float z_index, float object_z_index, boolean isModifier) {
     34    public boolean defaultSelectedHandling;
     35
     36    public StyleElement(float major_z_index, float z_index, float object_z_index, boolean isModifier, boolean defaultSelectedHandling) {
    3637        this.majorZIndex = major_z_index;
    3738        this.zIndex = z_index;
    3839        this.objectZIndex = object_z_index;
    3940        this.isModifier = isModifier;
     41        this.defaultSelectedHandling = defaultSelectedHandling;
    4042    }
    4143
     
    4547        objectZIndex = c.get(OBJECT_Z_INDEX, 0f, Float.class);
    4648        isModifier = c.get(MODIFIER, Boolean.FALSE, Boolean.class);
     49        defaultSelectedHandling = c.isDefaultSelectedHandling();
    4750    }
    4851
Note: See TracChangeset for help on using the changeset viewer.