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
13 package org.openhab.binding.nanoleaf.internal.layout.shape;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.nanoleaf.internal.layout.Point2D;
17 import org.openhab.binding.nanoleaf.internal.layout.ShapeType;
18 import org.openhab.binding.nanoleaf.internal.model.PositionDatum;
21 * Create the correct chape for a given shape type.
23 * @author Jørgen Austvik - Initial contribution
26 public class ShapeFactory {
28 public static Shape CreateShape(ShapeType shapeType, PositionDatum positionDatum) {
29 Point2D pos = new Point2D(positionDatum.getPosX(), positionDatum.getPosY());
30 switch (shapeType.getDrawingAlgorithm()) {
32 return new Square(shapeType, positionDatum.getPanelId(), pos, positionDatum.getOrientation());
35 return new Triangle(shapeType, positionDatum.getPanelId(), pos, positionDatum.getOrientation());
38 return new Hexagon(shapeType, positionDatum.getPanelId(), pos, positionDatum.getOrientation());
41 return new Point(shapeType, positionDatum.getPanelId(), pos, positionDatum.getOrientation());