Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package viewer;
import javafx.scene.paint.Color;
/**
* A subpixel contributes to the color of one pixel. Pixels are usually
* composed of several subpixels, whose colors are averaged.
*/
class SubPixel {
private Color color = Color.BLACK;
/**
* Each subpixel has a value that will be used to color them.
*/
final double value;
/**
* Creates a subpixel.
*
* @param value divergence for the corresponding pixel. This will be mapped to a color.
*/
SubPixel(double value) {
this.value = value;
}
/**
* Attributes a color to a subpixel.
*
* @param color the color to give to the subpixel
*/
void setColor(Color color) {
this.color = color;
}
/**
* @return the color of the subpixel. Default is black.
*/
Color getColor() {
return color;
}
/**
* Comparison of two subpixels by their values.
*
* @param pix1 first subpixel to compare
* @param pix2 second subpixel to compare
* @return an integer representing the result of the comparison, with the usual convention.
*/
static int compare(SubPixel pix1, SubPixel pix2) {
return Double.compare(pix1.value, pix2.value);
}
}