]> git.basschouten.com Git - openhab-addons.git/blob
d09a0291ac73e093a5e8e67efb3ffacb887dd748
[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.hdpowerview.internal.dto;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.library.types.HSBType;
17
18 /**
19  * Color and brightness information for HD PowerView repeater
20  *
21  * @author Jacob Laursen - Initial contribution
22  */
23 @NonNullByDefault
24 public class Color {
25     public int brightness;
26     public int red;
27     public int green;
28     public int blue;
29
30     public Color(int brightness, HSBType hsbType) {
31         this.brightness = brightness;
32         int rgb = hsbType.getRGB();
33         java.awt.Color color = new java.awt.Color(rgb);
34         red = color.getRed();
35         green = color.getGreen();
36         blue = color.getBlue();
37     }
38
39     public Color(int brightness, java.awt.Color color) {
40         this.brightness = brightness;
41         red = color.getRed();
42         green = color.getGreen();
43         blue = color.getBlue();
44     }
45
46     public Color(int brightness, int red, int green, int blue) {
47         this.brightness = brightness;
48         this.red = red;
49         this.green = green;
50         this.blue = blue;
51     }
52
53     @Override
54     public String toString() {
55         return String.format("%d.%d.%d/%d%%", red, green, blue, brightness);
56     }
57 }