01: package prefuse.controls;
02:
03: import java.awt.event.MouseEvent;
04:
05: import prefuse.visual.VisualItem;
06:
07: /**
08: * Control that executes an action when the mouse passes over an item.
09: *
10: * @author <a href="http://jheer.org">jeffrey heer</a>
11: */
12: public class HoverActionControl extends ControlAdapter {
13:
14: private String m_action;
15:
16: /**
17: * Create a new HoverActionControl.
18: * @param action the action to run upon mouse-over. The action is run
19: * both upon entering and upon exiting the item.
20: */
21: public HoverActionControl(String action) {
22: m_action = action;
23: }
24:
25: /**
26: * @see prefuse.controls.Control#itemEntered(prefuse.visual.VisualItem, java.awt.event.MouseEvent)
27: */
28: public void itemEntered(VisualItem item, MouseEvent e) {
29: item.getVisualization().run(m_action);
30: }
31:
32: /**
33: * @see prefuse.controls.Control#itemExited(prefuse.visual.VisualItem, java.awt.event.MouseEvent)
34: */
35: public void itemExited(VisualItem item, MouseEvent e) {
36: item.getVisualization().run(m_action);
37: }
38:
39: } // end of class HoverActionControl
|