001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.mappaint; 003 004import java.util.Locale; 005import java.util.Objects; 006 007/** 008 * A MapCSS keyword. 009 * 010 * For example "<code>round</code>" is a keyword in 011 * <pre>linecap: round;</pre> 012 * Keywords are similar to a Java enum value. In accordance with the CSS 013 * specification, they are parsed case insensitive. 014 */ 015public class Keyword { 016 /** 017 * The string value for this keyword 018 */ 019 public final String val; 020 021 /** 022 * Create a new Keyword 023 * @param val The string value that is written in the MapCSS file 024 */ 025 public Keyword(String val) { 026 this.val = val.toLowerCase(Locale.ENGLISH); 027 } 028 029 @Override 030 public String toString() { 031 return "Keyword{" + val + '}'; 032 } 033 034 @Override 035 public boolean equals(Object obj) { 036 if (this == obj) return true; 037 if (obj == null || getClass() != obj.getClass()) return false; 038 Keyword keyword = (Keyword) obj; 039 return Objects.equals(val, keyword.val); 040 } 041 042 @Override 043 public int hashCode() { 044 return Objects.hash(val); 045 } 046 047 /** 048 * Automated text positioning 049 */ 050 public static final Keyword AUTO = new Keyword("auto"); 051 /** 052 * Align text at the bottom 053 */ 054 public static final Keyword BOTTOM = new Keyword("bottom"); 055 /** 056 * Align text at the center 057 */ 058 public static final Keyword CENTER = new Keyword("center"); 059 /** 060 * Use default line width 061 */ 062 public static final Keyword DEFAULT = new Keyword("default"); 063 /** 064 * Align to the right 065 */ 066 public static final Keyword RIGHT = new Keyword("right"); 067 /** 068 * Thinnest line width 069 */ 070 public static final Keyword THINNEST = new Keyword("thinnest"); 071}