1 package org.catacomb.druid.swing;
2
3 import java.awt.Color;
4
5 import org.catacomb.interlish.structure.Colored;
6 import org.catacomb.interlish.structure.Named;
7
8
9
10 public class ToggleItem implements Colored {
11
12
13 boolean b;
14
15 Object ref;
16
17 public ToggleItem(Object obj) {
18 ref = obj;
19 }
20
21
22 public String toString() {
23 String ret = null;
24 if (ref instanceof Named) {
25 ret = ((Named)ref).getName();
26
27 } else {
28 ret = ref.toString();
29 }
30 return ret;
31
32 }
33
34
35 public boolean isOn() {
36 return b;
37 }
38
39 public Object getRef() {
40 return ref;
41 }
42
43 public void toggle() {
44 b = !b;
45 }
46
47 public void setOff() {
48 b = false;
49 }
50
51 public void setOn() {
52 b = true;
53 }
54
55
56 public Color getColor() {
57 Color ret = null;
58 if (ref instanceof Colored) {
59 ret = ((Colored)ref).getColor();
60 }
61 return ret;
62 }
63 }