]> git.basschouten.com Git - openhab-addons.git/blob
0c0f3fa1b1c0d4aa2934682f2cbdc4d86ebb4bcd
[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
14 package org.openhab.binding.nanoleaf.internal.layout;
15
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17
18 /**
19  * Information about the different Nanoleaf shapes.
20  *
21  * @author Jørgen Austvik - Initial contribution
22  */
23 @NonNullByDefault
24 public enum ShapeType {
25     // side lengths are taken from https://forum.nanoleaf.me/docs chapter 3.3
26     UNKNOWN("Unknown", -1, 0, 0, 1, DrawingAlgorithm.NONE),
27     TRIANGLE("Triangle", 0, 150, 3, 1, DrawingAlgorithm.TRIANGLE),
28     RHYTHM("Rhythm", 1, 0, 1, 1, DrawingAlgorithm.NONE),
29     SQUARE("Square", 2, 100, 0, 1, DrawingAlgorithm.SQUARE),
30     CONTROL_SQUARE_MASTER("Control Square Master", 3, 100, 0, 1, DrawingAlgorithm.SQUARE),
31     CONTROL_SQUARE_PASSIVE("Control Square Passive", 4, 100, 0, 1, DrawingAlgorithm.SQUARE),
32     SHAPES_HEXAGON("Hexagon (Shapes)", 7, 67, 6, 1, DrawingAlgorithm.HEXAGON),
33     SHAPES_TRIANGLE("Triangle (Shapes)", 8, 134, 3, 1, DrawingAlgorithm.TRIANGLE),
34     SHAPES_MINI_TRIANGLE("Mini Triangle (Shapes)", 9, 67, 3, 1, DrawingAlgorithm.TRIANGLE),
35     SHAPES_CONTROLLER("Controller (Shapes)", 12, 0, 0, 1, DrawingAlgorithm.NONE),
36     ELEMENTS_HEXAGON("Elements Hexagon", 14, 134, 6, 1, DrawingAlgorithm.HEXAGON),
37     ELEMENTS_HEXAGON_CORNER("Elements Hexagon - Corner", 15, 58, 6, 6, DrawingAlgorithm.CORNER),
38     LINES_CONNECTOR("Lines Connector", 16, 11, 1, 1, DrawingAlgorithm.NONE),
39     LIGHT_LINES("Light Lines", 17, 154, 1, 1, DrawingAlgorithm.LINE),
40     LINES_LINES_SINGLE("Light Lines - Single Sone", 18, 77, 2, 2, DrawingAlgorithm.LINE),
41     CONTROLLER_CAP("Controller Cap", 19, 11, 0, 1, DrawingAlgorithm.NONE),
42     POWER_CONNECTOR("Power Connector", 20, 11, 0, 1, DrawingAlgorithm.NONE);
43
44     private final String name;
45     private final int id;
46     private final int sideLength;
47     private final int numSides;
48     private final int numLights;
49     private final DrawingAlgorithm drawingAlgorithm;
50
51     ShapeType(String name, int id, int sideLenght, int numSides, int numLights, DrawingAlgorithm drawingAlgorithm) {
52         this.name = name;
53         this.id = id;
54         this.sideLength = sideLenght;
55         this.numSides = numSides;
56         this.numLights = numLights;
57         this.drawingAlgorithm = drawingAlgorithm;
58     }
59
60     public String getName() {
61         return name;
62     }
63
64     public int getId() {
65         return id;
66     }
67
68     public int getSideLength() {
69         return sideLength;
70     }
71
72     public int getNumSides() {
73         return numSides;
74     }
75
76     public int getNumLightsPerShape() {
77         return numLights;
78     }
79
80     public DrawingAlgorithm getDrawingAlgorithm() {
81         return drawingAlgorithm;
82     }
83
84     public static ShapeType valueOf(int id) {
85         for (ShapeType shapeType : values()) {
86             if (shapeType.getId() == id) {
87                 return shapeType;
88             }
89         }
90
91         return ShapeType.UNKNOWN;
92     }
93 }