2 * LocalityIconTitledURLItem.java
\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
7 * $History: LocalityIconTitledURLItem.java $
\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
15 package org.tjworld.components;
\r
17 import java.net.URL;
\r
18 import javax.swing.Icon;
\r
19 import javax.swing.ImageIcon;
\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
26 * @version 1.0 15 Nov, 2001
\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
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
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
46 public LocalityIconTitledURLItem(String title, URL url, boolean local) {
\r
47 this((Icon)null, (Icon)null,(Icon)null,(Icon)null, title, url, local);
\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
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
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
72 public LocalityIconTitledURLItem(Icon classLocalIcon, Icon classOnlineIcon, Icon localIcon, Icon onlineIcon, String title, URL url, boolean local) {
\r
73 super(title, url, null);
\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
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
87 public boolean isLocal() {
\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
95 public void setLocal(boolean local) {
\r
96 if(this.local != local) { // change the icon
\r
98 this.local = local; // update state
\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
107 /** Gets the Icon representing 'local' resources
\r
108 * @return the local Icon
\r
110 public Icon getLocalIcon() {
\r
114 public void setLocalIcon(Icon localIcon) {
\r
115 this.localIcon = localIcon;
\r
119 /** Gets the Icon representing 'online' resources
\r
120 * @return the online Icon
\r
122 public Icon getOnlineIcon() {
\r
126 /** Sets the Icon representing 'online' resources
\r
127 * @param onlineIcon
\r
129 public void setOnlineIcon(Icon onlineIcon) {
\r
130 this.onlineIcon = onlineIcon;
\r
134 /* Gets the class-wide Icon representing 'local' resources
\r
135 * @return the class-wide local Icon
\r
137 public Icon getClassLocalIcon() {
\r
138 return classLocalIcon;
\r
141 /** Sets the class-wide Icon representing 'local' resources
\r
142 * @param classLocalIcon the class-wide local Icon
\r
144 public void setClassLocalIcon(Icon classLocalIcon) {
\r
145 this.classLocalIcon = classLocalIcon;
\r
149 /* Gets the class-wide Icon representing 'online' resources
\r
150 * @return the class-wide online Icon
\r
152 public Icon getClassOnlineIcon() {
\r
153 return classOnlineIcon;
\r
156 /** Sets the class-wide Icon representing 'online' resources
\r
157 * @param classOnlineIcon the class-wide online Icon
\r
159 public void setClassOnlineIcon(Icon classOnlineIcon) {
\r
160 this.classOnlineIcon = classOnlineIcon;
\r