]> git.basschouten.com Git - openhab-addons.git/blob
f90262e0e7ecef2972771305f2ac6c7570bc48ac
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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, DrawingAlgorithm.NONE),
27     TRIANGLE("Triangle", 0, 150, 3, DrawingAlgorithm.TRIANGLE),
28     RHYTHM("Rhythm", 1, 0, 1, DrawingAlgorithm.NONE),
29     SQUARE("Square", 2, 100, 0, DrawingAlgorithm.SQUARE),
30     CONTROL_SQUARE_MASTER("Control Square Master", 3, 100, 0, DrawingAlgorithm.SQUARE),
31     CONTROL_SQUARE_PASSIVE("Control Square Passive", 4, 100, 0, DrawingAlgorithm.SQUARE),
32     SHAPES_HEXAGON("Hexagon (Shapes)", 7, 67, 6, DrawingAlgorithm.HEXAGON),
33     SHAPES_TRIANGLE("Triangle (Shapes)", 8, 134, 3, DrawingAlgorithm.TRIANGLE),
34     SHAPES_MINI_TRIANGLE("Mini Triangle (Shapes)", 9, 67, 3, DrawingAlgorithm.TRIANGLE),
35     SHAPES_CONTROLLER("Controller (Shapes)", 12, 0, 0, DrawingAlgorithm.NONE),
36     ELEMENTS_HEXAGON("Elements Hexagon", 14, 134, 6, DrawingAlgorithm.HEXAGON),
37     ELEMENTS_HEXAGON_CORNER("Elements Hexagon - Corner", 15, 33.5 / 58, 6, DrawingAlgorithm.CORNER),
38     LINES_CONNECTOR("Lines Connector", 16, 11, 1, DrawingAlgorithm.LINE),
39     LIGHT_LINES("Light Lines", 17, 154, 1, DrawingAlgorithm.LINE),
40     LINES_LINES_SINGLE("Light Lines - Single Sone", 18, 77, 1, DrawingAlgorithm.LINE),
41     CONTROLLER_CAP("Controller Cap", 19, 11, 0, DrawingAlgorithm.NONE),
42     POWER_CONNECTOR("Power Connector", 20, 11, 0, DrawingAlgorithm.NONE);
43
44     private final String name;
45     private final int id;
46     private final double sideLength;
47     private final int numSides;
48     private final DrawingAlgorithm drawingAlgorithm;
49
50     ShapeType(String name, int id, double sideLenght, int numSides, DrawingAlgorithm drawingAlgorithm) {
51         this.name = name;
52         this.id = id;
53         this.sideLength = sideLenght;
54         this.numSides = numSides;
55         this.drawingAlgorithm = drawingAlgorithm;
56     }
57
58     public String getName() {
59         return name;
60     }
61
62     public int getId() {
63         return id;
64     }
65
66     public double getSideLength() {
67         return sideLength;
68     }
69
70     public int getNumSides() {
71         return numSides;
72     }
73
74     public DrawingAlgorithm getDrawingAlgorithm() {
75         return drawingAlgorithm;
76     }
77
78     public static ShapeType valueOf(int id) {
79         for (ShapeType shapeType : values()) {
80             if (shapeType.getId() == id) {
81                 return shapeType;
82             }
83         }
84
85         return ShapeType.UNKNOWN;
86     }
87 }