View Javadoc

1   package org.catacomb.interlish.content;
2   
3   import org.catacomb.report.E;
4   
5   
6   public class ColorValue extends PrimitiveValue {
7   
8   
9       private int cval;
10  
11  
12      public ColorValue() {
13          super();
14          cval = 0;
15      }
16  
17      public ColorValue(int ic) {
18          super();
19          cval = ic;
20      }
21  
22      public ColorValue(String s) {
23          super();
24          silentSetColor(s);
25      }
26  
27  
28      public void silentSetColor(String s) {
29          try {
30              cval = Integer.decode(s).intValue();
31  
32          } catch (NumberFormatException ex) {
33              E.error("cant decode color string " + s);
34          }
35      }
36  
37  
38      public void silentSetColor(int ic) {
39          cval = ic;
40          logChange();
41      }
42  
43      public int getIntColor() {
44          return cval;
45      }
46  
47  
48      public void clear() {
49          silentSetColor(0);
50      }
51  
52      public void reportableSetColor(int ic, Object src) {
53          silentSetColor(ic);
54          /*
55          E.info("color set to " + ((ic >>16) & 255) + " " + ((ic >> 8) & 255) + " " +
56                   ((ic & 255)));
57          */
58          reportValueChange(src);
59      }
60  
61      public void reportableSetColor(String s, Object src) {
62          silentSetColor(s);
63          reportValueChange(src);
64      }
65  
66      public void copyFrom(ColorValue src) {
67          silentSetColor(src.getIntColor());
68      }
69  
70      public String getAsString() {
71          String ret = "000000" + Integer.toHexString(cval);
72          ret = "0x" + ret.substring(ret.length()-6, ret.length());
73          return ret;
74      }
75  
76  }