KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > suberic > pooka > gui > MultiValueIcon


1 package net.suberic.pooka.gui;
2 import java.awt.Component JavaDoc;
3
4 public class MultiValueIcon extends BooleanIcon {
5     boolean seen, recent;
6     String JavaDoc recentAndUnseenFile, justUnseenFile;
7
8     public MultiValueIcon(boolean isSeen, boolean isRecent, String JavaDoc recentAndUnseen, String JavaDoc justUnseen ) {
9     super (isSeen, recentAndUnseen, "MultiValue");
10     seen = isSeen;
11     recent = isRecent;
12     recentAndUnseenFile = recentAndUnseen;
13     justUnseenFile = justUnseen;
14     }
15     
16     public Component JavaDoc getIcon() {
17     if (seen) {
18         return BooleanIcon.blankImage;
19     } else if (recent) {
20         return getIcon(recentAndUnseenFile);
21     } else {
22         return getIcon(justUnseenFile);
23     }
24     }
25
26     private int getIntValue() {
27     if (seen)
28         return 0;
29     else if (!recent)
30         return 1;
31     else
32         return 2;
33     }
34
35     public int compareTo(Object JavaDoc o) {
36     if (o instanceof MultiValueIcon) {
37         int otherValue= ((MultiValueIcon) o).getIntValue();
38         if ( getIntValue() < otherValue)
39         return -1;
40         else if (getIntValue() == otherValue)
41         return 0;
42         else
43         return 1;
44     }
45
46     throw new ClassCastException JavaDoc("object is not a MultiValueIcon.");
47     }
48
49     public String JavaDoc toString() {
50     return "";
51     }
52 }
53
Popular Tags