quicktime.app.event
Class QTMouseController

java.lang.Object
  |
  +--quicktime.app.event.QTMouseController
All Implemented Interfaces:
Controller, Listener, ListenerController
Direct Known Subclasses:
QTMouseTargetController

public class QTMouseController
extends java.lang.Object
implements ListenerController

A QTMouseController is attached to a Space. When the space is added to its container (for instance a QTCanvas in the case of QTDisplaySpaces) it will create an event dispatcher that will translate these container events to the QTMouseEvents that this controller distributes to its registered listeners.

Once created and attached to a space the program registers listeners with the controller based on the type of mouse events a particular task requires. The type of the registered listeners will determine the type of mouse events that the controller will handle.

See Also:
for mouse events that target a member of the source space.

Field Summary
protected  Space space
          The space which the controller is attached too.
 
Constructor Summary
QTMouseController()
          Creates a mouse controller.
 
Method Summary
 void addedTo(java.lang.Object interest)
          This method is called by the specified object when the instance of the class that implements this interface is added to the object that is the source of the interest.
 void addedToSpace(Space s)
          This method is called by the space when a Controller is being addedTo the Space s.
protected  void addHandler()
          This method is called when a controller is added to its space and the controller needs to create its event handler
 void addQTMouseListener(QTMouseListener l)
          Add a QTMouseListener for this controller.
protected  void doMouseClicked(QTMouseEvent e)
          This method dispatches the event to the appropriate listeners.
protected  void doMouseDragged(QTMouseEvent e)
          This method dispatches the event to the appropriate listeners.
protected  void doMouseEntered(QTMouseEvent e)
          This method dispatches the event to the appropriate listeners.
protected  void doMouseExited(QTMouseEvent e)
          This method dispatches the event to the appropriate listeners.
protected  void doMouseMoved(QTMouseEvent e, boolean isWithinItsSpace)
          This method dispatches the event to the appropriate listeners.
protected  void doMousePressed(QTMouseEvent e)
          This method dispatches the event to the appropriate listeners.
protected  void doMouseReleased(QTMouseEvent e)
          This method dispatches the event to the appropriate listeners.
 Space getSpace()
          This method returns the Space which the MouseController has been attached to.
 void mouseClicked(QTMouseEvent e)
          If the QTMouseController has a MouseButtonListener(s) it will dispatch click events that occur within its Space's area to those listeners.
 void mouseDragged(QTMouseEvent e)
          If the QTMouseController has a MouseMoveListener(s) it will dispatch drag events that occur within its Space's area to those listeners.
 void mouseEntered(QTMouseEvent e)
          If the QTMouseController has a MouseEnterExitListener(s) it will dispatch a mouseEntered event when the mouse moves or is dragged into the space.
 void mouseExited(QTMouseEvent e)
          If the QTMouseController has a MouseEnterExitListener(s) it will dispatch a mouseExited event when the mouse moves or is dragged out of the space.
 void mouseMoved(QTMouseEvent e)
          If the QTMouseController has a MouseMoveListener(s) it will dispatch move events that occur within its Space's area to those listeners.
 void mousePressed(QTMouseEvent e)
          If the QTMouseController has a MouseButtonListener(s) it will dispatch press events that occur within its Space's area to those listeners.
 void mouseReleased(QTMouseEvent e)
          If the QTMouseController has a MouseButtonListener(s) it will dispatch release events that occur within its Space's area to those listeners.
protected  void removeActiveHandler()
          This method is called when a controller is removed from its space and it had an active event handler
 void removedFrom(java.lang.Object interest)
          This method is called by the specified object when the instance of the class that implements this interface is removed from the object that is the source of the interest.
 void removedFromSpace()
          Called by the Space when a Controller is being removed from a Space.
 void removeQTMouseListener(QTMouseListener l)
          Remove a QTMouseListener for this controller.
protected  boolean translateAndIsWithin(QTMouseEvent e)
          This method returns true if the location of the QTMouseEvent is within the Space's area, or false if it isn't.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

space

protected Space space
The space which the controller is attached too. If the controller is not attached to a space this variable will be null. It is set in the addedToSpace method.
Constructor Detail

QTMouseController

public QTMouseController()
Creates a mouse controller.
Method Detail

getSpace

public Space getSpace()
This method returns the Space which the MouseController has been attached to.
Returns:
the current space.

addedToSpace

public void addedToSpace(Space s)
This method is called by the space when a Controller is being addedTo the Space s. If the Controller is not an appropriate controller for that kind of Space this method can throw an exception and the controller won't be added to the Space.
Specified by:
addedToSpace in interface Controller
Parameters:
s - the Space being added to
See Also:
setTargetSpace()

removedFromSpace

public void removedFromSpace()
Called by the Space when a Controller is being removed from a Space. This is only called by the Space on controllers that have previously been added, thus the space they are being removed from is the space they were added to. Sets the targetSpace to null.
Specified by:
removedFromSpace in interface Controller

addedTo

public void addedTo(java.lang.Object interest)
This method is called by the specified object when the instance of the class that implements this interface is added to the object that is the source of the interest. When this method is called the source of interest will determine the event handling mechanism that must be installed. The event dispatch to the QTMouseController is handled by an EventDispatcher that is created for the QTMouseController.
Specified by:
addedTo in interface Listener
Parameters:
interest - the object that is to be the source of interest for the the object that implements this interface.

removedFrom

public void removedFrom(java.lang.Object interest)
This method is called by the specified object when the instance of the class that implements this interface is removed from the object that is the source of the interest.
Specified by:
removedFrom in interface Listener
Parameters:
interest - the object that was the source of interest for the the object that implements this interface.

addHandler

protected void addHandler()
This method is called when a controller is added to its space and the controller needs to create its event handler

removeActiveHandler

protected void removeActiveHandler()
This method is called when a controller is removed from its space and it had an active event handler

translateAndIsWithin

protected boolean translateAndIsWithin(QTMouseEvent e)
This method returns true if the location of the QTMouseEvent is within the Space's area, or false if it isn't. This test assumes that the space is some kind of QTDisplaySpace, and can be overriden for a custom Space.

If the event is located within the space the coordinates of the event will be translated into the local coordinates of the space, with the top, left point of the space being 0,0. Returning true will also indicate that this translation has been done on the event coordinates.

Parameters:
e - the mouse event
Returns:
a boolean

addQTMouseListener

public void addQTMouseListener(QTMouseListener l)
Add a QTMouseListener for this controller. The controller will take the appropriate action based on the known mouse listeners in the quicktime.app.event package.
Parameters:
l - a new QTMouseListener

removeQTMouseListener

public void removeQTMouseListener(QTMouseListener l)
Remove a QTMouseListener for this controller.
Parameters:
l - a new QTMouseListener

mouseClicked

public void mouseClicked(QTMouseEvent e)
If the QTMouseController has a MouseButtonListener(s) it will dispatch click events that occur within its Space's area to those listeners.
Parameters:
e - the QTMouseEvent of this type.

doMouseClicked

protected void doMouseClicked(QTMouseEvent e)
This method dispatches the event to the appropriate listeners. Subclasses can overide this method to do any particular processing that is required for this type of mouse event.
Parameters:
e - the mouse event

mousePressed

public void mousePressed(QTMouseEvent e)
If the QTMouseController has a MouseButtonListener(s) it will dispatch press events that occur within its Space's area to those listeners.
Parameters:
e - the QTMouseEvent of this type.

doMousePressed

protected void doMousePressed(QTMouseEvent e)
This method dispatches the event to the appropriate listeners. Subclasses can overide this method to do any particular processing that is required for this type of mouse event.
Parameters:
e - the translated mouse event

mouseReleased

public void mouseReleased(QTMouseEvent e)
If the QTMouseController has a MouseButtonListener(s) it will dispatch release events that occur within its Space's area to those listeners.
Parameters:
e - the QTMouseEvent of this type.

doMouseReleased

protected void doMouseReleased(QTMouseEvent e)
This method dispatches the event to the appropriate listeners. Subclasses can overide this method to do any particular processing that is required for this type of mouse event.
Parameters:
e - the translated mouse event

mouseDragged

public void mouseDragged(QTMouseEvent e)
If the QTMouseController has a MouseMoveListener(s) it will dispatch drag events that occur within its Space's area to those listeners. Mouse drag events will continue to be delivered to the controller and its listeners where the press occured and until the mouse button is released (regardless of whether the mouse is within the space or not).
Parameters:
e - the QTMouseEvent of this type.

doMouseDragged

protected void doMouseDragged(QTMouseEvent e)
This method dispatches the event to the appropriate listeners. Subclasses can overide this method to do any particular processing that is required for this type of mouse event.
Parameters:
e - the translated mouse event

mouseMoved

public void mouseMoved(QTMouseEvent e)
If the QTMouseController has a MouseMoveListener(s) it will dispatch move events that occur within its Space's area to those listeners.
Parameters:
e - the QTMouseEvent of this type.

doMouseMoved

protected void doMouseMoved(QTMouseEvent e,
                            boolean isWithinItsSpace)
This method dispatches the event to the appropriate listeners. Subclasses can overide this method to do any particular processing that is required for this type of mouse event.
Parameters:
e - the translated mouse event
isWithinItsSpace - if true the mouse moved event is within the enclosing space. If false it isn't.

mouseEntered

public void mouseEntered(QTMouseEvent e)
If the QTMouseController has a MouseEnterExitListener(s) it will dispatch a mouseEntered event when the mouse moves or is dragged into the space.
Parameters:
e - the QTMouseEvent of this type.

doMouseEntered

protected void doMouseEntered(QTMouseEvent e)
This method dispatches the event to the appropriate listeners. Subclasses can overide this method to do any particular processing that is required for this type of mouse event.
Parameters:
e - the translated mouse event

mouseExited

public void mouseExited(QTMouseEvent e)
If the QTMouseController has a MouseEnterExitListener(s) it will dispatch a mouseExited event when the mouse moves or is dragged out of the space.
Parameters:
e - the QTMouseEvent of this type.

doMouseExited

protected void doMouseExited(QTMouseEvent e)
This method dispatches the event to the appropriate listeners. Subclasses can overide this method to do any particular processing that is required for this type of mouse event.
Parameters:
e - the translated mouse event