blob: 6af813ae4077abadfc6c8f158c2833792c258f0d (
plain)
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
57
58
59
60
61
62
63
64
|
package org.singinst.uf.presenter;
import java.awt.Color;
import org.singinst.uf.model.SimpleColor;
public class HtmlUtil {
public static String green(Object value) {
return color("green", value);
}
/**
* Takes a Color and an object, and wraps it around a span html element, and adds the color to it.
*
* @param c
* Color to display value in
* @param value
* Value to display in color c
* @return
* HTML code.
*/
public static String htmlcolorFromColor(Color c, Object value){
return color("#" + Integer.toHexString((c.getRGB() & 0xffffff) | 0x1000000).substring(1) , value);
}
private static String color(String color, Object value) {
return "<html><span color=" + color + ">" + value + "</span>";
}
public static String red(Object value) {
return color("red", value);
}
public static String style(SimpleStyle style, String string) {
return color(htmlColor(style), string);
}
private static String htmlColor(SimpleStyle style) {
return new SimpleColor.Visitor<String>() {
@Override
public String visit_BLACK() {
return "black";
}
@Override
public String visit_GREEN() {
return "green";
}
@Override
public String visit_LIGHT_GRAY() {
return "light gray";
}
@Override
public String visit_RED() {
return "red";
}
}.visit(style.getColor());
}
}
|