1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint;
|
---|
3 |
|
---|
4 | import java.util.Locale;
|
---|
5 | import java.util.Objects;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * A MapCSS keyword.
|
---|
9 | *
|
---|
10 | * For example "<code>round</code>" is a keyword in
|
---|
11 | * <pre>linecap: round;</pre>
|
---|
12 | * Keywords are similar to a Java enum value. In accordance with the CSS
|
---|
13 | * specification, they are parsed case insensitive.
|
---|
14 | */
|
---|
15 | public class Keyword {
|
---|
16 | /**
|
---|
17 | * The string value for this keyword
|
---|
18 | */
|
---|
19 | public final String val;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Create a new Keyword
|
---|
23 | * @param val The string value that is written in the MapCSS file
|
---|
24 | */
|
---|
25 | public Keyword(String val) {
|
---|
26 | this.val = val.toLowerCase(Locale.ENGLISH);
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public String toString() {
|
---|
31 | return "Keyword{" + val + '}';
|
---|
32 | }
|
---|
33 |
|
---|
34 | @Override
|
---|
35 | public boolean equals(Object obj) {
|
---|
36 | if (this == obj) return true;
|
---|
37 | if (obj == null || getClass() != obj.getClass()) return false;
|
---|
38 | Keyword keyword = (Keyword) obj;
|
---|
39 | return Objects.equals(val, keyword.val);
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | public int hashCode() {
|
---|
44 | return Objects.hash(val);
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Automated text positioning
|
---|
49 | */
|
---|
50 | public static final Keyword AUTO = new Keyword("auto");
|
---|
51 | /**
|
---|
52 | * Align text at the bottom
|
---|
53 | */
|
---|
54 | public static final Keyword BOTTOM = new Keyword("bottom");
|
---|
55 | /**
|
---|
56 | * Align text at the center
|
---|
57 | */
|
---|
58 | public static final Keyword CENTER = new Keyword("center");
|
---|
59 | /**
|
---|
60 | * Use default line width
|
---|
61 | */
|
---|
62 | public static final Keyword DEFAULT = new Keyword("default");
|
---|
63 | /**
|
---|
64 | * Align to the right
|
---|
65 | */
|
---|
66 | public static final Keyword RIGHT = new Keyword("right");
|
---|
67 | /**
|
---|
68 | * Thinnest line width
|
---|
69 | */
|
---|
70 | public static final Keyword THINNEST = new Keyword("thinnest");
|
---|
71 | }
|
---|