Changeset 15983 in josm


Ignore:
Timestamp:
2020-03-01T23:35:55+01:00 (5 years ago)
Author:
simon04
Message:

see #18802 - Extract org.openstreetmap.josm.gui.mappaint.mapcss.Declaration

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r15982 r15983  
    4747import org.openstreetmap.josm.gui.mappaint.MultiCascade;
    4848import org.openstreetmap.josm.gui.mappaint.mapcss.Condition;
     49import org.openstreetmap.josm.gui.mappaint.mapcss.Declaration;
    4950import org.openstreetmap.josm.gui.mappaint.mapcss.Expression;
    5051import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction;
    5152import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule;
    52 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule.Declaration;
    5353import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    5454import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource.MapCSSRuleIndex;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java

    r15902 r15983  
    1616 * For example a simple assignment like <code>width: 3;</code>, but may also
    1717 * be a set instruction (<code>set highway;</code>).
    18  * A MapCSS {@link MapCSSRule.Declaration} is a list of instructions.
     18 * A MapCSS {@link Declaration} is a list of instructions.
    1919 */
    2020@FunctionalInterface
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r15935 r15983  
    2626import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.KeyMatchType;
    2727import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.Op;
     28import org.openstreetmap.josm.gui.mappaint.mapcss.Declaration;
    2829import org.openstreetmap.josm.gui.mappaint.mapcss.Expression;
    2930import org.openstreetmap.josm.gui.mappaint.mapcss.ExpressionFactory;
     
    3334import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSException;
    3435import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule;
    35 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule.Declaration;
    3636import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    3737import org.openstreetmap.josm.gui.mappaint.mapcss.Selector;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSRule.java

    r15909 r15983  
    22package org.openstreetmap.josm.gui.mappaint.mapcss;
    33
    4 import java.util.List;
    5 import java.util.Objects;
    64import java.util.stream.Collectors;
    75
    86import org.openstreetmap.josm.gui.mappaint.Environment;
    9 import org.openstreetmap.josm.gui.mappaint.StyleSource;
    10 import org.openstreetmap.josm.tools.Utils;
    117
    128/**
     
    2723     */
    2824    public final Declaration declaration;
    29 
    30     /**
    31      * A declaration is a set of {@link Instruction}s
    32      */
    33     public static class Declaration {
    34         /**
    35          * The instructions in this declaration
    36          */
    37         public final List<Instruction> instructions;
    38         /**
    39          * The index of this declaration
    40          * <p>
    41          * declarations in the StyleSource are numbered consecutively
    42          */
    43         public final int idx;
    44 
    45         /**
    46          * Create a new {@link Declaration}
    47          * @param instructions The instructions for this dectlaration
    48          * @param idx The index in the {@link StyleSource}
    49          */
    50         public Declaration(List<Instruction> instructions, int idx) {
    51             this.instructions = Utils.toUnmodifiableList(instructions);
    52             this.idx = idx;
    53         }
    54 
    55         /**
    56          * <p>Executes the instructions against the environment {@code env}</p>
    57          *
    58          * @param env the environment
    59          */
    60         public void execute(Environment env) {
    61             for (Instruction i : instructions) {
    62                 i.execute(env);
    63             }
    64         }
    65 
    66         @Override
    67         public int hashCode() {
    68             return Objects.hash(instructions, idx);
    69         }
    70 
    71         @Override
    72         public boolean equals(Object obj) {
    73             if (this == obj) return true;
    74             if (obj == null || getClass() != obj.getClass()) return false;
    75             Declaration that = (Declaration) obj;
    76             return idx == that.idx &&
    77                     Objects.equals(instructions, that.instructions);
    78         }
    79 
    80         @Override
    81         public String toString() {
    82             return "Declaration [instructions=" + instructions + ", idx=" + idx + ']';
    83         }
    84     }
    8525
    8626    /**
Note: See TracChangeset for help on using the changeset viewer.