vmm.core
Class BasicMouseTask2D

java.lang.Object
  extended by vmm.core.MouseTask
      extended by vmm.core.BasicMouseTask2D

public class BasicMouseTask2D
extends MouseTask

A BasicMouseTask2D is a MouseTask that allows the user to drag and zoom the 2D window that is used to draw the Exhibit in a display. Dragging is done with the left mouse button. Zooming is done by dragging up/down with the middle mouse button (or holding down a shift or alt or option key). When draggin with the left mouse button, the user can switch between dragging the exhibit and zooming it by pressing and releasing the shift key.

The user can also use the right mouse key (or hold down the control or command key) to draw a rectangle; the rectangle can be moved while dragging by holding down the shift key. The View is then zoomed into that rectangle. The shape of the rectangle is contrained to have the same aspect ration as the display.

All the methods in this class are called by a Display in response to user actions. None of them are meant to be called directly.


Constructor Summary
BasicMouseTask2D()
           
 
Method Summary
 boolean doMouseDown(java.awt.event.MouseEvent evt, Display display, View view, int width, int height)
          Decides what type of operation to perform in response to a user's mouse click, and initiates that operation.
 void doMouseDrag(java.awt.event.MouseEvent evt, Display display, View view, int width, int height)
          Continue processing a drag operation.
 void doMouseUp(java.awt.event.MouseEvent evt, Display display, View view, int width, int height)
          Finish processing a drag operation.
 void drawWhileDragging(java.awt.Graphics2D g, Display display, View view, int width, int height)
          When the Display is repainted during a drag operation, this method will be called after the Exhibit is drawn, to give the MouseTask a chance to draw some extra stuff on top of the Exhibit.
 java.awt.Cursor getCursorForDragging(java.awt.event.MouseEvent mouseDownEvent, Display display, View view)
          Returns the cursor that the Display should use during a drag operation.
 
Methods inherited from class vmm.core.MouseTask
finish, getCursor, getStatusText, start, wantsMoreClicks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicMouseTask2D

public BasicMouseTask2D()
Method Detail

doMouseDown

public boolean doMouseDown(java.awt.event.MouseEvent evt,
                           Display display,
                           View view,
                           int width,
                           int height)
Decides what type of operation to perform in response to a user's mouse click, and initiates that operation. This method is called by a Display when the user clicks on the Display; it is not meant to be called directly.

Specified by:
doMouseDown in class MouseTask
Parameters:
evt - The mouse-down event, except that the x and y coordinates have been translated so that the top left corner of the View is at coordinates (0,0).
width - The width the drawing area (not including any insets).
height - The height the drawing area (not including any insets).
Returns:
returns true to tell the Display that the drag operation should continue, unless there is no Exhibit currently installed in the display.

doMouseDrag

public void doMouseDrag(java.awt.event.MouseEvent evt,
                        Display display,
                        View view,
                        int width,
                        int height)
Continue processing a drag operation.

Overrides:
doMouseDrag in class MouseTask
Parameters:
evt - The mouse-dragged event, except that the x and y coordinates have been translated by display.getInsets().left and display.getInsets().top to account for any border that has been applied to the display.
width - The width the drawing area (not including any insets).
height - The height the drawing area (not including any insets).

doMouseUp

public void doMouseUp(java.awt.event.MouseEvent evt,
                      Display display,
                      View view,
                      int width,
                      int height)
Finish processing a drag operation.

Overrides:
doMouseUp in class MouseTask
Parameters:
evt - The mouse-up event, except that the x and y coordinates have been translated by display.getInsets().left and display.getInsets().top to account for any border that has been applied to the display.
width - The width the drawing area (not including any insets).
height - The height the drawing area (not including any insets).

getCursorForDragging

public java.awt.Cursor getCursorForDragging(java.awt.event.MouseEvent mouseDownEvent,
                                            Display display,
                                            View view)
Returns the cursor that the Display should use during a drag operation. The cursor that is returned depends on which operation is being performed with the mouse.

Overrides:
getCursorForDragging in class MouseTask
See Also:
MouseTask.doMouseDown(MouseEvent, Display, View, int, int), MouseTask.getCursor(Display, View)

drawWhileDragging

public void drawWhileDragging(java.awt.Graphics2D g,
                              Display display,
                              View view,
                              int width,
                              int height)
When the Display is repainted during a drag operation, this method will be called after the Exhibit is drawn, to give the MouseTask a chance to draw some extra stuff on top of the Exhibit. In this class, it draws nothing unless the operation that is being performed is to draw a rectangle for zooming; if that is the operation, then the rectangle is drawn in red.

Overrides:
drawWhileDragging in class MouseTask