]> git.basschouten.com Git - openhab-addons.git/blob
3d6c33ca92965cacb2db3b3e4240dd656e31ed0d
[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
17 /**
18  * Color and brightness information for HD PowerView repeater
19  *
20  * @author Jacob Laursen - Initial contribution
21  */
22 @NonNullByDefault
23 public class Color {
24     public int brightness;
25     public int red;
26     public int green;
27     public int blue;
28
29     public Color(int brightness, int srgb) {
30         this(brightness, new java.awt.Color(srgb));
31     }
32
33     public Color(int brightness, java.awt.Color color) {
34         this(brightness, color.getRed(), color.getGreen(), color.getBlue());
35     }
36
37     public Color(int brightness, Color color) {
38         this(brightness, color.red, color.green, color.blue);
39     }
40
41     public Color(int brightness, int red, int green, int blue) {
42         this.brightness = brightness;
43         this.red = red;
44         this.green = green;
45         this.blue = blue;
46     }
47
48     public boolean isBlack() {
49         return red == 0 && green == 0 && blue == 0;
50     }
51
52     @Override
53     public String toString() {
54         return String.format("%d.%d.%d/%d%%", red, green, blue, brightness);
55     }
56 }