1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.imaging.color;
18
19
20
21
22
23
24
25
26
27
28
29
30 public final class ColorCieLch {
31
32
33
34
35
36
37
38
39
40
41 public static final ColorCieLch BLACK = new ColorCieLch(0, 0, 0);
42
43
44
45
46
47
48
49
50
51
52 public static final ColorCieLch WHITE = new ColorCieLch(100, 0, 297);
53
54
55
56
57
58
59
60
61
62
63 public static final ColorCieLch RED = new ColorCieLch(53, 80, 67);
64
65
66
67
68
69
70
71
72
73
74 public static final ColorCieLch GREEN = new ColorCieLch(88, -86, 83);
75
76
77
78
79
80
81
82
83
84
85 public static final ColorCieLch BLUE = new ColorCieLch(32, 79, -108);
86
87 public final double l;
88 public final double c;
89 public final double h;
90
91 public ColorCieLch(final double l, final double c, final double h) {
92 this.l = l;
93 this.c = c;
94 this.h = h;
95 }
96
97 @Override
98 public boolean equals(final Object o) {
99 if (this == o) {
100 return true;
101 }
102 if (o == null || getClass() != o.getClass()) {
103 return false;
104 }
105
106 final ColorCieLch that = (ColorCieLch) o;
107 if (Double.compare(that.c, c) != 0) {
108 return false;
109 }
110 if (Double.compare(that.h, h) != 0) {
111 return false;
112 }
113 if (Double.compare(that.l, l) != 0) {
114 return false;
115 }
116
117 return true;
118 }
119
120 @Override
121 public int hashCode() {
122 int result;
123 long temp;
124 temp = Double.doubleToLongBits(l);
125 result = (int) (temp ^ temp >>> 32);
126 temp = Double.doubleToLongBits(c);
127 result = 31 * result + (int) (temp ^ temp >>> 32);
128 temp = Double.doubleToLongBits(h);
129 return 31 * result + (int) (temp ^ temp >>> 32);
130 }
131
132 @Override
133 public String toString() {
134 return "{L: " + l + ", C: " + c + ", h: " + h + "}";
135 }
136 }