KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > usertasks > renderers > UserTaskIconProvider


1 package org.netbeans.modules.tasklist.usertasks.renderers;
2
3 import java.awt.Image JavaDoc;
4 import org.netbeans.modules.tasklist.usertasks.model.UserTask;
5 import org.openide.util.Utilities;
6
7 /**
8  * Returns an icon for a given UT.
9  *
10  * @author tl
11  */

12 public class UserTaskIconProvider {
13     private static final Image JavaDoc LIST_IMAGE =
14         Utilities.loadImage(
15             "org/netbeans/modules/tasklist/usertasks/tasklistfile.gif"); // NOI18N
16
private static final Image JavaDoc IMAGE =
17         Utilities.loadImage(
18             "org/netbeans/modules/tasklist/core/task.gif"); // NOI18N
19
private static final Image JavaDoc DONE =
20         Utilities.loadImage(
21             "org/netbeans/modules/tasklist/core/doneItem.gif"); // NOI18N
22
private static final Image JavaDoc UNMATCHED =
23         Utilities.loadImage(
24             "org/netbeans/modules/tasklist/core/unmatched.gif"); // NOI18N
25

26     private static final Image JavaDoc STARTED_BADGE =
27         Utilities.loadImage(
28             "org/netbeans/modules/tasklist/usertasks/startedBadge.gif"); // NOI18N
29

30     private static final Image JavaDoc IMAGE_STARTED =
31         Utilities.mergeImages(IMAGE, STARTED_BADGE, 8, 8);
32     private static final Image JavaDoc DONE_STARTED =
33         Utilities.mergeImages(DONE, STARTED_BADGE, 8, 8);
34     private static final Image JavaDoc UNMATCHED_STARTED =
35         Utilities.mergeImages(UNMATCHED, STARTED_BADGE, 8, 8);
36     
37     /**
38      * Returns the icon for a task list.
39      *
40      * @return the icon
41      */

42     public static Image JavaDoc getUserTaskListImage() {
43         return LIST_IMAGE;
44     }
45     
46     /**
47      * Returns a 16x16 icon.
48      *
49      * @param ut a task
50      * @param unmatched true for tasks that do not pass through the filter
51      * but have children that do
52      * @return icon
53      */

54     public static Image JavaDoc getUserTaskImage(UserTask ut, boolean unmatched) {
55         if (ut.isStarted()) {
56             if (unmatched)
57                 return UNMATCHED_STARTED;
58             else if (ut.isDone())
59                 return DONE_STARTED;
60             else
61                 return IMAGE_STARTED;
62         } else {
63             if (unmatched)
64                 return UNMATCHED;
65             else if (ut.isDone())
66                 return DONE;
67             else
68                 return IMAGE;
69         }
70     }
71     
72     /**
73      * Creates a new instance of UserTaskIconProvider
74      */

75     private UserTaskIconProvider() {
76     }
77 }
78
Popular Tags