]> git.basschouten.com Git - openhab-addons.git/blob
631cfb6ba75406b9544423f7cad1bfc1c0cac773
[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, int red, int green, int blue) {
38         this.brightness = brightness;
39         this.red = red;
40         this.green = green;
41         this.blue = blue;
42     }
43
44     @Override
45     public String toString() {
46         return String.format("%d.%d.%d/%d%%", red, green, blue, brightness);
47     }
48 }