Package org.xhtmlrenderer.swing
Class MouseTracker
- java.lang.Object
-
- java.awt.event.MouseAdapter
-
- javax.swing.event.MouseInputAdapter
-
- org.xhtmlrenderer.swing.MouseTracker
-
- All Implemented Interfaces:
MouseListener,MouseMotionListener,MouseWheelListener,EventListener,MouseInputListener
public class MouseTracker extends MouseInputAdapter
A MouseTracker is used to delegate mouse events to theFSMouseListenerinstances associated with aBasicPanel. The tracker will start receiving events as soon as the first listener is added (viaaddListener(FSMouseListener)) and will stop receiving events as soon as the last listener is removed viaremoveListener(FSMouseListener). This binding is handled automatically via the add and remove methods and the tracker will remain active as long as the tracker has at least one listener. The MouseTracker is also responsible for using MouseEvent coordinates to locate the Box on which the mouse is acting.
-
-
Constructor Summary
Constructors Constructor Description MouseTracker(BasicPanel panel)Instantiates a MouseTracker to listen to mouse events for the given panel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(FSMouseListener l)Adds a listener to receive callbacks on mouse events.List<FSMouseListener>getListeners()Returns a (new) list of all listeners currently tracked for receiving events.voidmouseDragged(MouseEvent e)voidmouseEntered(MouseEvent e)voidmouseExited(MouseEvent e)voidmouseMoved(MouseEvent e)voidmousePressed(MouseEvent e)voidmouseReleased(MouseEvent e)voidremoveListener(FSMouseListener l)Removes the given listener, after which it will no longer receive callbacks on mouse events.voidreset()Utility method; callsFSMouseListener.reset()for all listeners currently being tracked.-
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseWheelMoved
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.awt.event.MouseListener
mouseClicked
-
-
-
-
Constructor Detail
-
MouseTracker
public MouseTracker(BasicPanel panel)
Instantiates a MouseTracker to listen to mouse events for the given panel.- Parameters:
panel- the panel for which mouse events should be delegated.
-
-
Method Detail
-
addListener
public void addListener(FSMouseListener l)
Adds a listener to receive callbacks on mouse events.- Parameters:
l- the listener
-
removeListener
public void removeListener(FSMouseListener l)
Removes the given listener, after which it will no longer receive callbacks on mouse events.- Parameters:
l- the listener to remove
-
getListeners
public List<FSMouseListener> getListeners()
Returns a (new) list of all listeners currently tracked for receiving events.- Returns:
- a (new) list of all listeners currently tracked for receiving events.
-
mouseEntered
public void mouseEntered(MouseEvent e)
- Specified by:
mouseEnteredin interfaceMouseListener- Overrides:
mouseEnteredin classMouseAdapter
-
mouseExited
public void mouseExited(MouseEvent e)
- Specified by:
mouseExitedin interfaceMouseListener- Overrides:
mouseExitedin classMouseAdapter
-
mouseMoved
public void mouseMoved(MouseEvent e)
- Specified by:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classMouseAdapter
-
mouseReleased
public void mouseReleased(MouseEvent e)
- Specified by:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classMouseAdapter
-
mousePressed
public void mousePressed(MouseEvent e)
- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classMouseAdapter
-
mouseDragged
public void mouseDragged(MouseEvent e)
- Specified by:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin classMouseAdapter
-
reset
public void reset()
Utility method; callsFSMouseListener.reset()for all listeners currently being tracked.
-
-