2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
14 package org.openhab.binding.nanoleaf.internal.layout;
16 import org.eclipse.jdt.annotation.NonNullByDefault;
19 * Information about the different Nanoleaf shapes.
21 * @author Jørgen Austvik - Initial contribution
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);
44 private final String name;
46 private final double sideLength;
47 private final int numSides;
48 private final DrawingAlgorithm drawingAlgorithm;
50 ShapeType(String name, int id, double sideLenght, int numSides, DrawingAlgorithm drawingAlgorithm) {
53 this.sideLength = sideLenght;
54 this.numSides = numSides;
55 this.drawingAlgorithm = drawingAlgorithm;
58 public String getName() {
66 public double getSideLength() {
70 public int getNumSides() {
74 public DrawingAlgorithm getDrawingAlgorithm() {
75 return drawingAlgorithm;
78 public static ShapeType valueOf(int id) {
79 for (ShapeType shapeType : values()) {
80 if (shapeType.getId() == id) {
85 return ShapeType.UNKNOWN;