dog.gui
Class DItem

java.lang.Object
  |
  +--dog.gui.DItem
All Implemented Interfaces:
java.awt.image.ImageObserver, Referential
Direct Known Subclasses:
DMenu.Separator

public class DItem
extends java.lang.Object
implements Referential, java.awt.image.ImageObserver

Class to encapsulate the notion of an item.
This might be a list or (popup)menu item, or a node in a tree.
It can contain multiple fields, an icon, and an object reference.


Field Summary
protected  java.util.Hashtable fields
          The fields contained in the item.
protected  java.awt.Image icon
          The icon image.
protected  java.lang.String label
          The default text to display in the item.
protected  java.util.Vector listeners
           
protected  java.lang.Object reference
          The object reference associated with the item.
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DItem()
          Constructs an item with the label "New item", and no icon.
DItem(java.lang.String label)
          Constructs an item with the specified label.
DItem(java.lang.String label, java.awt.Image icon)
          Constructs an item with the specified label and icon.
DItem(java.lang.String label, java.awt.Image icon, java.lang.Object reference)
          Constructs an item with the specified label, icon and reference.
DItem(java.lang.String label, java.lang.String icon)
          Constructs an item with the specified label and icon.
DItem(java.lang.String label, java.lang.String icon, java.lang.Object reference)
          Constructs an item with the specified label, icon and reference.
DItem(java.lang.String label, java.net.URL icon)
          Constructs an item with the specified label and icon.
DItem(java.lang.String label, java.net.URL icon, java.lang.Object reference)
          Constructs an item with the specified label, icon and reference.
 
Method Summary
 void addField(java.lang.String name, java.lang.Object value)
          Adds a field identified by the specified name.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds the specified property change listener to receive property change events from this item.
 boolean equals(java.lang.Object other)
          Determines if this item is equal to another.
 java.lang.Object getField(java.lang.String name)
          Returns the field identified by the specified name.
 java.lang.String[] getFieldNames()
          Returns an array of the field names in the item.
 java.awt.Image getIcon()
          Returns the icon.
 java.lang.String getLabel()
          Returns the label.
 java.lang.Object getReference()
          Returns the object reference.
 java.lang.String getText()
          This is an alias for getLabel().
 int hashCode()
          Returns a hashcode value for storing this item in a hashtable.
 boolean imageUpdate(java.awt.Image image, int flags, int x, int y, int w, int h)
          The item's icon has arrived...
protected  java.lang.String paramString()
          Returns a parameter string for this object.
protected  void processPropertyChangeEvent(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
          Processes property changes on this item.
 void removeField(java.lang.String name)
          Removes the field identified by the specified name.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the specified property change listener so it no longer receives property change events from this item.
 void setIcon(java.awt.Image icon)
          Sets the icon.
 void setIcon(java.lang.String file)
          Sets the icon from a file.
 void setIcon(java.net.URL url)
          Sets the icon from a URL.
 void setLabel(java.lang.String label)
          Sets the label.
 void setReference(java.lang.Object reference)
          Sets the object reference.
 void setText(java.lang.String text)
          This is an alias for setLabel().
 java.lang.String toString()
          Returns a string description of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

label

protected java.lang.String label
The default text to display in the item.

icon

protected java.awt.Image icon
The icon image.

reference

protected java.lang.Object reference
The object reference associated with the item.

fields

protected java.util.Hashtable fields
The fields contained in the item.

listeners

protected java.util.Vector listeners
Constructor Detail

DItem

public DItem()
Constructs an item with the label "New item", and no icon.

DItem

public DItem(java.lang.String label)
Constructs an item with the specified label.

DItem

public DItem(java.lang.String label,
             java.awt.Image icon)
Constructs an item with the specified label and icon.

DItem

public DItem(java.lang.String label,
             java.awt.Image icon,
             java.lang.Object reference)
Constructs an item with the specified label, icon and reference.

DItem

public DItem(java.lang.String label,
             java.lang.String icon)
Constructs an item with the specified label and icon.

DItem

public DItem(java.lang.String label,
             java.lang.String icon,
             java.lang.Object reference)
Constructs an item with the specified label, icon and reference.

DItem

public DItem(java.lang.String label,
             java.net.URL icon)
Constructs an item with the specified label and icon.

DItem

public DItem(java.lang.String label,
             java.net.URL icon,
             java.lang.Object reference)
Constructs an item with the specified label, icon and reference.
Method Detail

getText

public java.lang.String getText()
This is an alias for getLabel().
See Also:
getLabel()

setText

public void setText(java.lang.String text)
This is an alias for setLabel().
See Also:
setLabel(java.lang.String)

getLabel

public java.lang.String getLabel()
Returns the label.
See Also:
setLabel(java.lang.String)

setLabel

public void setLabel(java.lang.String label)
Sets the label.
Parameters:
label - the label text.
See Also:
getLabel()

getIcon

public java.awt.Image getIcon()
Returns the icon.

setIcon

public void setIcon(java.awt.Image icon)
Sets the icon.
Parameters:
icon - the icon image.

setIcon

public void setIcon(java.lang.String file)
Sets the icon from a file.
Parameters:
file - the image file.

setIcon

public void setIcon(java.net.URL url)
Sets the icon from a URL.
Parameters:
url - the image URL.

imageUpdate

public boolean imageUpdate(java.awt.Image image,
                           int flags,
                           int x,
                           int y,
                           int w,
                           int h)
The item's icon has arrived...
Specified by:
imageUpdate in interface java.awt.image.ImageObserver

getReference

public java.lang.Object getReference()
Returns the object reference.
Specified by:
getReference in interface Referential

setReference

public void setReference(java.lang.Object reference)
Sets the object reference.
Specified by:
setReference in interface Referential
Parameters:
reference - the object reference to store.

getFieldNames

public java.lang.String[] getFieldNames()
Returns an array of the field names in the item.
See Also:
getField(java.lang.String), addField(java.lang.String, java.lang.Object), removeField(java.lang.String)

getField

public java.lang.Object getField(java.lang.String name)
Returns the field identified by the specified name.
See Also:
getFieldNames(), addField(java.lang.String, java.lang.Object), removeField(java.lang.String)

addField

public void addField(java.lang.String name,
                     java.lang.Object value)
Adds a field identified by the specified name.
See Also:
getFieldNames(), getField(java.lang.String), removeField(java.lang.String)

removeField

public void removeField(java.lang.String name)
Removes the field identified by the specified name.
See Also:
getFieldNames(), getField(java.lang.String), addField(java.lang.String, java.lang.Object)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the specified property change listener to receive property change events from this item.
Parameters:
listener - the property change listener

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the specified property change listener so it no longer receives property change events from this item.
Parameters:
listener - the property change listener

processPropertyChangeEvent

protected void processPropertyChangeEvent(java.lang.String name,
                                          java.lang.Object oldValue,
                                          java.lang.Object newValue)
Processes property changes on this item.

hashCode

public int hashCode()
Returns a hashcode value for storing this item in a hashtable.
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Determines if this item is equal to another.
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns a string description of this object.
Overrides:
toString in class java.lang.Object

paramString

protected java.lang.String paramString()
Returns a parameter string for this object.