Ignore:
Timestamp:
2013-12-29T12:03:21+01:00 (12 years ago)
Author:
simon04
Message:

see #9485 - MapCSS: add support for set class_name instruction and .class_name condition (which is specified in the MapCSS specification)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java

    r6554 r6560  
    2222    abstract public boolean applies(Environment e);
    2323
    24     public static Condition create(String k, String v, Op op, Context context, boolean considerValAsKey) {
     24    public static Condition createKeyValueCondition(String k, String v, Op op, Context context, boolean considerValAsKey) {
    2525        switch (context) {
    2626        case PRIMITIVE:
     
    4141    }
    4242
    43     public static Condition create(String k, boolean not, KeyMatchType matchType, Context context) {
     43    public static Condition createKeyCondition(String k, boolean not, KeyMatchType matchType, Context context) {
    4444        switch (context) {
    4545        case PRIMITIVE:
     
    5757    }
    5858
    59     public static Condition create(String id, boolean not, Context context) {
     59    public static Condition createPseudoClassCondition(String id, boolean not, Context context) {
    6060        return new PseudoClassCondition(id, not);
    6161    }
    6262
    63     public static Condition create(Expression e, Context context) {
     63    public static Condition createClassCondition(String id, boolean not, Context context) {
     64        return new ClassCondition(id, not);
     65    }
     66
     67    public static Condition createExpressionCondition(Expression e, Context context) {
    6468        return new ExpressionCondition(e);
    6569    }
     
    275279    }
    276280
     281    public static class ClassCondition extends Condition {
     282
     283        public final String id;
     284        public final boolean not;
     285
     286        public ClassCondition(String id, boolean not) {
     287            this.id = id;
     288            this.not = not;
     289        }
     290
     291        @Override
     292        public boolean applies(Environment env) {
     293            return not ^ env.mc.getCascade(env.layer).containsKey(id);
     294        }
     295
     296        @Override
     297        public String toString() {
     298            return (not ? "!" : "") + "." + id;
     299        }
     300    }
     301
    277302    public static class PseudoClassCondition extends Condition {
    278303
Note: See TracChangeset for help on using the changeset viewer.