edu.washington.biostr.sig.brainj3d.shwing.swing
Class ActionIcon

java.lang.Object
  extended by edu.washington.biostr.sig.brainj3d.icons.LazyIcon
      extended by edu.washington.biostr.sig.brainj3d.shwing.swing.ActionIcon
All Implemented Interfaces:
MouseListener, MouseMotionListener, Serializable, EventListener, Icon

public class ActionIcon
extends LazyIcon
implements Icon, MouseListener, MouseMotionListener

This adds a clickable icon to a component. Because of how it is set up, it is only appropriate to use for a single component. It only fires events when a mouse event happens on a non transparent pixel. Transparent pixel clicks are entirely ignored.
To create something with multiple ActionIcons, use a CompositeIcon.
In the case of a composite icon, any event that occurs on non-transparent pixels that correspond to 2 events will generate an event on both ActionIcon's.

Version:
1.0
Author:
not attributable
See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.washington.biostr.sig.brainj3d.icons.LazyIcon
img
 
Constructor Summary
ActionIcon(String location)
           
ActionIcon(String command, String location)
           
ActionIcon(String command, String location, Icon selected)
          Optionally we can display a different icon when selected
 
Method Summary
 void addActionListener(ActionListener list)
           
static boolean checkIntersection(Point2D p, BufferedImage img, int x, int y, int right, int down)
           
 void disable()
           
 boolean equals(Object obj)
          2 action icons are equal if their most recent components are equal and their LazyIcon's are equal.
protected  void fireActionEvent(ActionEvent evt)
           
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void paintIcon(Component parent, Graphics g, int x, int y)
           
 void removeActionListener(ActionListener list)
           
 void setHover(boolean hover)
          Set hover if you want to show the selected icon when we hover.
 void setSelected(boolean selected)
          Tell this to display the selected icon
 
Methods inherited from class edu.washington.biostr.sig.brainj3d.icons.LazyIcon
getIconHeight, getIconWidth, getSource, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.Icon
getIconHeight, getIconWidth
 

Constructor Detail

ActionIcon

public ActionIcon(String location)

ActionIcon

public ActionIcon(String command,
                  String location)

ActionIcon

public ActionIcon(String command,
                  String location,
                  Icon selected)
Optionally we can display a different icon when selected

Parameters:
command -
location -
selected -
Method Detail

setHover

public void setHover(boolean hover)
Set hover if you want to show the selected icon when we hover.

Parameters:
hover -

paintIcon

public void paintIcon(Component parent,
                      Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface Icon
Overrides:
paintIcon in class LazyIcon

fireActionEvent

protected void fireActionEvent(ActionEvent evt)

addActionListener

public void addActionListener(ActionListener list)

removeActionListener

public void removeActionListener(ActionListener list)

checkIntersection

public static boolean checkIntersection(Point2D p,
                                        BufferedImage img,
                                        int x,
                                        int y,
                                        int right,
                                        int down)

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

setSelected

public void setSelected(boolean selected)
Tell this to display the selected icon

Parameters:
selected -

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

disable

public void disable()

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

equals

public boolean equals(Object obj)
2 action icons are equal if their most recent components are equal and their LazyIcon's are equal. If the addedToComp is null, then the ActionIcon cannot be equal to anything but itself.

Overrides:
equals in class LazyIcon


Copyright © 2006 University of Washington. All Rights Reserved.