org.xhtmlrenderer.swing
Class MouseTracker

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by javax.swing.event.MouseInputAdapter
          extended by 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 the FSMouseListener instances associated with a BasicPanel. The tracker will start receiving events as soon as the first listener is added (via addListener(FSMouseListener) and will stop receiving events as soon as the last listener is removed via removeListener(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 located the Box on which the mouse is acting.


Constructor Summary
MouseTracker(BasicPanel panel)
          Instantiates a MouseTracker to listen to mouse events for the given panel.
 
Method Summary
 void addListener(FSMouseListener l)
          Adds a listener to receive callbacks on mouse events.
 List getListeners()
          Returns a (new) list of all listeners currently tracked for receiving events.
 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 removeListener(FSMouseListener l)
          Removes the given listener, after which it will no longer receive callbacks on mouse events.
 void reset()
          Utility method; calls FSMouseListener.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 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:
mouseEntered in interface MouseListener
Overrides:
mouseEntered in class MouseAdapter

mouseExited

public void mouseExited(MouseEvent e)

Specified by:
mouseExited in interface MouseListener
Overrides:
mouseExited in class MouseAdapter

mouseMoved

public void mouseMoved(MouseEvent e)

Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class MouseAdapter

mouseReleased

public void mouseReleased(MouseEvent e)

Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseAdapter

mousePressed

public void mousePressed(MouseEvent e)

Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseAdapter

mouseDragged

public void mouseDragged(MouseEvent e)

Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class MouseAdapter

reset

public void reset()
Utility method; calls FSMouseListener.reset() for all listeners currently being tracked.



Copyright © 2013. All Rights Reserved.