Visual Color Imbalance Detector: Reconstructed project directories and files
[VistaCID.git] / org / tjworld / components / LocalityIconTitledURLItem.java
1 /*\r
2         * LocalityIconTitledURLItem.java\r
3  *\r
4         * Created on 15 November 2001, 14:25\r
5  * $Header: /VisTA/CID/Components/LocalityIconTitledURLItem.java 1     15/11/01 15:36 Tj $\r
6         *\r
7         * $History: LocalityIconTitledURLItem.java $\r
8  * \r
9  * *****************  Version 1  *****************\r
10  * User: Tj           Date: 15/11/01   Time: 15:36\r
11  * Created in $/VisTA/CID/Components\r
12  * State-enabled Iconified TitledURLItem\r
13  */\r
14 \r
15 package org.tjworld.components;\r
16 \r
17 import java.net.URL;\r
18 import javax.swing.Icon;\r
19 import javax.swing.ImageIcon;\r
20 \r
21 /** Provides local and online icons that indicate where the URL is located\r
22  * @see LocalityIconTitledURLItem\r
23  * @see IconTitledURLItem\r
24         * @see TitledURLItem\r
25         * @author  TJ\r
26  * @version 1.0 15 Nov, 2001\r
27  */\r
28 public class LocalityIconTitledURLItem extends IconTitledURLItem {\r
29  protected static Icon classLocalIcon = null;\r
30  protected static Icon classOnlineIcon = null;\r
31  protected Icon localIcon = null;\r
32         protected Icon onlineIcon = null;\r
33         protected boolean local = false;\r
34         \r
35         /** Creates new LocalityIconTitledURLItem which defaults to being a 'local' resource */\r
36  public LocalityIconTitledURLItem() {\r
37                 this((Icon)null, (Icon)null,(Icon)null,(Icon)null, (String)null, (URL)null, true);\r
38         }\r
39 \r
40         /** Creates new LocalityIconTitledURLItem\r
41                 * @param url the URL\r
42                 * @param title the associated Title\r
43                 * @param local true to use the 'local' indicator icon, false to use the 'online' version\r
44                 * @see #isLocal\r
45                 */\r
46         public LocalityIconTitledURLItem(String title, URL url, boolean local) {\r
47                 this((Icon)null, (Icon)null,(Icon)null,(Icon)null, title, url, local);\r
48         }\r
49                 \r
50         /** Creates new LocalityIconTitledURLItem with instance-only Icons\r
51                 * @param localIcon the local Icon\r
52                 * @param onlineIcon the local Icon\r
53                 * @param url the URL\r
54                 * @param title the associated Title\r
55                 * @param local true to use the 'local' indicator icon, false to use the 'online' version\r
56                 * @see #isLocal\r
57                 */\r
58         public LocalityIconTitledURLItem(Icon localIcon, Icon onlineIcon, String title, URL url, boolean local) {\r
59                 this((Icon)null, (Icon)null, localIcon, onlineIcon, title, url, local);\r
60         }\r
61 \r
62         /** Creates new LocalityIconTitledURLItem with class-wide and instance-only Icons\r
63                 * @param classLocalIcon the class-wide local Icon\r
64                 * @param classOnlineIcon the class-wide online Icon\r
65                 * @param localIcon the local Icon\r
66                 * @param onlineIcon the local Icon\r
67                 * @param url the URL\r
68                 * @param title the associated Title\r
69                 * @param local true to use the 'local' indicator icon, false to use the 'online' version\r
70                 * @see #isLocal\r
71                 */\r
72         public LocalityIconTitledURLItem(Icon classLocalIcon, Icon classOnlineIcon, Icon localIcon, Icon onlineIcon, String title, URL url, boolean local) {\r
73          super(title, url, null);\r
74                 this.local = local;\r
75                 this.classLocalIcon = classLocalIcon;\r
76                 this.classOnlineIcon = classOnlineIcon;\r
77                 this.localIcon = localIcon;\r
78                 this.onlineIcon = onlineIcon;\r
79                 setIcon(local ? (localIcon != null ? localIcon : classLocalIcon) : (onlineIcon != null ? onlineIcon : classOnlineIcon));\r
80         }\r
81         \r
82         /** Tests if the URL represents a local or online resource.\r
83                 * The definition of what is local is arbitary, and is up to the User to decide. No URL\r
84                 * testing is done to determine it's locality.\r
85                 * @return true if this URL represents a local resource\r
86                 */\r
87  public boolean isLocal() {\r
88                 return local;\r
89         }\r
90         \r
91         /** Sets the locality indicator\r
92                 * @param local true if the URL represents a 'local' resource, false if the resource is 'online'\r
93                 * @see #isLocal\r
94                 */\r
95         public void setLocal(boolean local) {\r
96                 if(this.local != local) { // change the icon\r
97                         setIcon();\r
98                  this.local = local; // update state\r
99                 }\r
100         }\r
101         \r
102         protected void setIcon() {\r
103                 // prefer to use per-object Icon, but if there isn't one use the class Icon\r
104                 setIcon(local ? (localIcon != null ? localIcon : classLocalIcon) : (onlineIcon != null ? onlineIcon : classOnlineIcon));\r
105         }\r
106         \r
107         /** Gets the Icon representing 'local' resources \r
108                 * @return the local Icon\r
109                 */\r
110  public Icon getLocalIcon() {\r
111                 return localIcon;\r
112         }\r
113         \r
114         public void setLocalIcon(Icon localIcon) {\r
115                 this.localIcon = localIcon;\r
116                 setIcon();\r
117         }\r
118         \r
119         /** Gets the Icon representing 'online' resources \r
120                 * @return the online Icon\r
121                 */\r
122         public Icon getOnlineIcon() {\r
123                 return onlineIcon;\r
124         }\r
125         \r
126         /** Sets the Icon representing 'online' resources\r
127                 * @param onlineIcon\r
128                 */\r
129  public void setOnlineIcon(Icon onlineIcon) {\r
130                 this.onlineIcon = onlineIcon;\r
131                 setIcon();\r
132         }\r
133         \r
134         /* Gets the class-wide Icon representing 'local' resources\r
135                 * @return the class-wide local Icon\r
136                 */\r
137         public Icon getClassLocalIcon() {\r
138                 return classLocalIcon;\r
139         }\r
140         \r
141         /** Sets the class-wide Icon representing 'local' resources\r
142                 * @param classLocalIcon the class-wide local Icon\r
143                 */\r
144         public void setClassLocalIcon(Icon classLocalIcon) {\r
145                 this.classLocalIcon = classLocalIcon;\r
146                 setIcon();\r
147         }\r
148         \r
149         /* Gets the class-wide Icon representing 'online' resources\r
150                 * @return the class-wide online Icon\r
151                 */\r
152  public Icon getClassOnlineIcon() {\r
153                 return classOnlineIcon;\r
154         }\r
155         \r
156         /** Sets the class-wide Icon representing 'online' resources\r
157                 * @param classOnlineIcon the class-wide online Icon\r
158                 */\r
159         public void setClassOnlineIcon(Icon classOnlineIcon) {\r
160                 this.classOnlineIcon = classOnlineIcon;\r
161                 setIcon();\r
162         }\r
163 }