gov.noaa.pmel.sgt.swing
Class UserIcon

java.lang.Object
  extended by javax.swing.ImageIcon
      extended by gov.noaa.pmel.sgt.swing.UserIcon
All Implemented Interfaces:
LayerChild, Selectable, Draggable, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Icon

public class UserIcon
extends javax.swing.ImageIcon
implements LayerChild, Draggable

UserIcon extends ImageIcon to create a icon than can be dragged on a sgt plot displaying a user defined text string along with the image.

Since:
2.0
Version:
$Revision$, $Date$
Author:
Donald Denbo
See Also:
ValueIcon, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.ImageIcon
javax.swing.ImageIcon.AccessibleImageIcon
 
Field Summary
protected  java.awt.Rectangle bounds_
           
protected  java.beans.PropertyChangeSupport changes_
           
protected  Layer layer_
           
protected  Point2D.Double loc_
           
protected  boolean moved_
           
protected  SoTPoint uLoc_
           
protected  java.beans.VetoableChangeSupport vetos_
           
 
Fields inherited from class javax.swing.ImageIcon
component, tracker
 
Constructor Summary
UserIcon(java.awt.Image image, java.lang.String description)
          Construct a UserIcon using an Image.
UserIcon(java.lang.String filename, java.lang.String description)
          Construct a UserIcon using an image from a specified file.
UserIcon(java.net.URL location, java.lang.String description)
          Construct a UserIcon using an image from a specified URL.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void addVetoableChangeListener(java.beans.VetoableChangeListener l)
           
 LayerChild copy()
          Create a copy of the LayerChild.
 void draw(java.awt.Graphics g)
          Draw the LayerChild.
 java.awt.Rectangle getBounds()
          Gets the bounding rectangle in device coordinates.
 java.awt.Font getFont()
          Get the value label font
 int getIconHeight()
          Get the total heigth.
 int getIconWidth()
          Get the total width, icon + label.
 java.lang.String getId()
          Get the identifier.
 Layer getLayer()
          Get the associated Layer.
 Point2D.Double getLocationP()
          Get the icon location in physical units.
 SoTPoint getLocationU()
          Get the icon location in user units.
 AbstractPane getPane()
          Get AbstractPane of the LayerChild.
 boolean isSelectable()
          Returns true if the current state is selectable.
 boolean isSelected()
          Returns true if the object's selected property is set.
 boolean isVisible()
          Check if LayerChild is visible.
 void modified(java.lang.String mess)
          Used by sgt internally.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Paint the icon at the specified location.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void removeVetoableChangeListener(java.beans.VetoableChangeListener l)
           
 void setBounds(int x, int y, int width, int height)
          Set icon bounds.
protected  void setBounds(int x, int y, int width, int height, boolean fireEvent)
           
 void setBounds(java.awt.Rectangle bounds)
          Set icon bounds.
 void setFont(java.awt.Font font)
          Set the font for the value label.
 void setId(java.lang.String id)
          Set the identifier.
 void setLayer(Layer l)
          Associate a Layer with the LayerChild.
 void setLocation(java.awt.Point loc)
          Set icon location in device units
 void setLocation(java.awt.Point loc, boolean fireEvent)
          Set icon location in device units and optionally fire a PropertyChangeEvent.
 void setLocationNoVeto(int x, int y)
          Set icon location in device coordinates.
 void setLocationP(Point2D.Double loc)
          Set the icon location in physical units.
 void setLocationU(SoTPoint loc)
          Set the icon location in user units.
 void setLocationUNoVeto(SoTPoint loc)
          Set the icon location in user units.
 void setSelectable(boolean select)
          Set the Selectable property.
 void setSelected(boolean sel)
          Sets the selected property.
 void setVisible(boolean vis)
          Set visibility for a LayerChild.
 java.lang.String toString()
          Return a string that represents the LayerChild.
 
Methods inherited from class javax.swing.ImageIcon
getAccessibleContext, getDescription, getImage, getImageLoadStatus, getImageObserver, loadImage, setDescription, setImage, setImageObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

moved_

protected boolean moved_

layer_

protected Layer layer_

bounds_

protected java.awt.Rectangle bounds_

loc_

protected Point2D.Double loc_

uLoc_

protected SoTPoint uLoc_

changes_

protected java.beans.PropertyChangeSupport changes_

vetos_

protected java.beans.VetoableChangeSupport vetos_
Constructor Detail

UserIcon

public UserIcon(java.lang.String filename,
                java.lang.String description)
Construct a UserIcon using an image from a specified file.

Parameters:
filename - name of image file
description - brief textual description of the image

UserIcon

public UserIcon(java.net.URL location,
                java.lang.String description)
Construct a UserIcon using an image from a specified URL.

Parameters:
location - URL of image file
description - brief textual description of the image

UserIcon

public UserIcon(java.awt.Image image,
                java.lang.String description)
Construct a UserIcon using an Image.

Parameters:
image - the image
description - brief textual description of the image
Method Detail

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Paint the icon at the specified location.

Specified by:
paintIcon in interface javax.swing.Icon
Overrides:
paintIcon in class javax.swing.ImageIcon

setFont

public void setFont(java.awt.Font font)
Set the font for the value label.

Parameters:
font - the font

getFont

public java.awt.Font getFont()
Get the value label font


getIconWidth

public int getIconWidth()
Get the total width, icon + label.

Specified by:
getIconWidth in interface javax.swing.Icon
Overrides:
getIconWidth in class javax.swing.ImageIcon

getIconHeight

public int getIconHeight()
Get the total heigth.

Specified by:
getIconHeight in interface javax.swing.Icon
Overrides:
getIconHeight in class javax.swing.ImageIcon

copy

public LayerChild copy()
Description copied from interface: LayerChild
Create a copy of the LayerChild.

Specified by:
copy in interface LayerChild
Returns:
A copy of the LayerChild.

setVisible

public void setVisible(boolean vis)
Description copied from interface: LayerChild
Set visibility for a LayerChild.

Specified by:
setVisible in interface LayerChild
Parameters:
vis - visible if true

isVisible

public boolean isVisible()
Description copied from interface: LayerChild
Check if LayerChild is visible.

Specified by:
isVisible in interface LayerChild
Returns:
true if visible

draw

public void draw(java.awt.Graphics g)
Description copied from interface: LayerChild
Draw the LayerChild.

Specified by:
draw in interface LayerChild
Parameters:
g - Graphics context

getId

public java.lang.String getId()
Description copied from interface: LayerChild
Get the identifier.

Specified by:
getId in interface LayerChild
Returns:
LayerChild identification.

getLayer

public Layer getLayer()
Description copied from interface: LayerChild
Get the associated Layer.

Specified by:
getLayer in interface LayerChild
Returns:
Associated layer

getPane

public AbstractPane getPane()
Description copied from interface: LayerChild
Get AbstractPane of the LayerChild.

Specified by:
getPane in interface LayerChild

modified

public void modified(java.lang.String mess)
Description copied from interface: LayerChild
Used by sgt internally.

Specified by:
modified in interface LayerChild

setId

public void setId(java.lang.String id)
Description copied from interface: LayerChild
Set the identifier.

Specified by:
setId in interface LayerChild
Parameters:
id - LayerChild identification.

setLayer

public void setLayer(Layer l)
Description copied from interface: LayerChild
Associate a Layer with the LayerChild.

Specified by:
setLayer in interface LayerChild
Parameters:
l - Parent layer.

toString

public java.lang.String toString()
Description copied from interface: LayerChild
Return a string that represents the LayerChild.

Specified by:
toString in interface LayerChild
Overrides:
toString in class javax.swing.ImageIcon
Returns:
Stringified LayerChild representation.

getBounds

public java.awt.Rectangle getBounds()
Description copied from interface: Selectable
Gets the bounding rectangle in device coordinates.

Specified by:
getBounds in interface Selectable
Returns:
bounding rectangle

isSelected

public boolean isSelected()
Description copied from interface: Selectable
Returns true if the object's selected property is set.

Specified by:
isSelected in interface Selectable
Returns:
true if selected, false if not.

setSelected

public void setSelected(boolean sel)
Description copied from interface: Selectable
Sets the selected property.

Specified by:
setSelected in interface Selectable
Parameters:
sel - true if selected, false if not.

isSelectable

public boolean isSelectable()
Description copied from interface: Selectable
Returns true if the current state is selectable.

Specified by:
isSelectable in interface Selectable
Returns:
true if selectable

setSelectable

public void setSelectable(boolean select)
Description copied from interface: Selectable
Set the Selectable property.

Specified by:
setSelectable in interface Selectable
Parameters:
select - if true object is selectable

getLocationP

public Point2D.Double getLocationP()
Get the icon location in physical units.


setLocationP

public void setLocationP(Point2D.Double loc)
Set the icon location in physical units.
Property Change: location.


getLocationU

public SoTPoint getLocationU()
Get the icon location in user units.

Since:
3.0

setLocationUNoVeto

public void setLocationUNoVeto(SoTPoint loc)
Set the icon location in user units. Location change can't be vetoed.

Since:
3.0

setLocationU

public void setLocationU(SoTPoint loc)
                  throws java.beans.PropertyVetoException
Set the icon location in user units. Location change can be vetoed.
Property Change: location.

Throws:
java.beans.PropertyVetoException
Since:
3.0

setLocationNoVeto

public void setLocationNoVeto(int x,
                              int y)
Set icon location in device coordinates. Locatoin change can't be vetoed.

Specified by:
setLocationNoVeto in interface Draggable

setLocation

public void setLocation(java.awt.Point loc)
Set icon location in device units

Specified by:
setLocation in interface Draggable

setLocation

public void setLocation(java.awt.Point loc,
                        boolean fireEvent)
Set icon location in device units and optionally fire a PropertyChangeEvent.

Specified by:
setLocation in interface Draggable

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Set icon bounds.
Property Change: location.


setBounds

protected void setBounds(int x,
                         int y,
                         int width,
                         int height,
                         boolean fireEvent)

setBounds

public void setBounds(java.awt.Rectangle bounds)
Set icon bounds.


addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener l)

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener l)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)