]> git.basschouten.com Git - openhab-addons.git/blob
acf985f3bf04b11af02b5d69419df5cefc844c7b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.wlanthermo.internal.api.mini;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.wlanthermo.internal.WlanThermoUtil;
20
21 /**
22  * The {@link WlanThermoMiniUtil} class provides conversion functions for the WlanThermo Mini
23  *
24  * @author Christian Schlipp - Initial contribution
25  */
26 @NonNullByDefault
27 public class WlanThermoMiniUtil extends WlanThermoUtil {
28     private static final Map<String, String> COLOR_MAPPINGS = createColorMap();
29     private static final String DEFAULT_HEX = "#ffffff";
30
31     private WlanThermoMiniUtil() {
32         // hidden
33     }
34
35     private static Map<String, String> createColorMap() {
36         HashMap<String, String> map = new HashMap<>();
37         map.put("green", "#008000");
38         map.put("red", "#FF0000");
39         map.put("blue", "#0000FF");
40         map.put("olive", "#808000");
41         map.put("magenta", "#FF00FF");
42         map.put("yellow", "#FFFF00");
43         map.put("violet", "#EE82EE");
44         map.put("orange", "#FFA500");
45         map.put("mediumpurple3", "#9370DB");
46         map.put("aquamarine", "#7FFFD4");
47         map.put("brown", "#A52A2A");
48         map.put("plum", "#DDA0DD");
49         map.put("skyblue", "#87CEEB");
50         map.put("orange-red", "#FF4500");
51         map.put("salmon", "#FA8072");
52         map.put("black", "#000000");
53         map.put("dark-grey", "#A9A9A9");
54         map.put("purple", "800080");
55         map.put("turquoise", "#40E0D0");
56         map.put("khaki", "#F0E68C");
57         map.put("dark-violet", "#9400D3");
58         map.put("seagreen", "#2E8B57");
59         map.put("web-blue", "#0080ff");
60         map.put("steelblue", "#4682B4");
61         map.put("gold", "#FFD700");
62         map.put("dark-green", "#006400");
63         map.put("midnight-blue", "#191970");
64         map.put("dark-khaki", "#BDB76B");
65         map.put("dark-olivegreen", "#556B2F");
66         map.put("pink", "#FFC0CB");
67         map.put("chartreuse", "#7FFF00");
68         map.put("gray", "#808080");
69         map.put("slategrey", "#708090");
70         return map;
71     }
72
73     /**
74      * Convert WlanThermo Color Name to Hex
75      * 
76      * @param colorName the WlanThermo color name
77      * @return The color as Hex String
78      */
79     public static String toHex(String colorName) {
80         return COLOR_MAPPINGS.getOrDefault(colorName, DEFAULT_HEX);
81     }
82 }