vmm.core
Class TwoPointInput

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

public abstract class TwoPointInput
extends MouseTask

Meant for use as a "one-shot" mouse task that lets the user specify two points by clicking and dragging. The first point is where the mouse is pressed, the second is where the mouse is released.


Field Summary
static int DRAW_CIRCLE_FROM_DIAMETER
           
static int DRAW_CIRCLE_FROM_RADIUS
           
static int DRAW_LINE
           
static int DRAW_NOTHING
           
static int DRAW_RECT
           
 
Constructor Summary
TwoPointInput()
           
 
Method Summary
 boolean doMouseDown(java.awt.event.MouseEvent evt, Display display, View view, int width, int height)
          Called when the user presses the mouse in the Display in which this MouseTask is installed.
 void doMouseDrag(java.awt.event.MouseEvent evt, Display display, View view, int width, int height)
          Continue processing a mouse gesture for which doMouseDown returned a value of true.
 void doMouseUp(java.awt.event.MouseEvent evt, Display display, View view, int width, int height)
          Finish processing a mouse gesture for which doMouseDown returned a value of true.
 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.
 boolean getAllowOutOfBoundsDrag()
           
 java.awt.Cursor getCursor(Display display, View view)
          Return a cursor to be used in the display when this MouseTask is installed and waiting for a mouse-down event.
 java.awt.Color getDrawColor()
           
 int getFigureToDraw()
           
 int getMaximumDrag()
           
 int getMinimumDrag()
           
protected abstract  void gotPoints(Display display, View view, int startX, int startY, int endX, int endY)
           
 void setAllowOutOfBoundsDrag(boolean allowOutOfBoundsDrag)
           
 void setDrawColor(java.awt.Color drawColor)
           
 void setFigureToDraw(int figureToDraw)
           
 void setMaximumDrag(int maximumDrag)
           
 void setMinimumDrag(int minimumDrag)
           
 
Methods inherited from class vmm.core.MouseTask
finish, getCursorForDragging, getStatusText, start, wantsMoreClicks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DRAW_NOTHING

public static final int DRAW_NOTHING
See Also:
Constant Field Values

DRAW_LINE

public static final int DRAW_LINE
See Also:
Constant Field Values

DRAW_CIRCLE_FROM_RADIUS

public static final int DRAW_CIRCLE_FROM_RADIUS
See Also:
Constant Field Values

DRAW_CIRCLE_FROM_DIAMETER

public static final int DRAW_CIRCLE_FROM_DIAMETER
See Also:
Constant Field Values

DRAW_RECT

public static final int DRAW_RECT
See Also:
Constant Field Values
Constructor Detail

TwoPointInput

public TwoPointInput()
Method Detail

gotPoints

protected abstract void gotPoints(Display display,
                                  View view,
                                  int startX,
                                  int startY,
                                  int endX,
                                  int endY)

getAllowOutOfBoundsDrag

public boolean getAllowOutOfBoundsDrag()

setAllowOutOfBoundsDrag

public void setAllowOutOfBoundsDrag(boolean allowOutOfBoundsDrag)

getDrawColor

public java.awt.Color getDrawColor()

setDrawColor

public void setDrawColor(java.awt.Color drawColor)

getFigureToDraw

public int getFigureToDraw()

setFigureToDraw

public void setFigureToDraw(int figureToDraw)

getMaximumDrag

public int getMaximumDrag()

setMaximumDrag

public void setMaximumDrag(int maximumDrag)

getMinimumDrag

public int getMinimumDrag()

setMinimumDrag

public void setMinimumDrag(int minimumDrag)

doMouseDown

public boolean doMouseDown(java.awt.event.MouseEvent evt,
                           Display display,
                           View view,
                           int width,
                           int height)
Description copied from class: MouseTask
Called when the user presses the mouse in the Display in which this MouseTask is installed. The return value indicates whether or not the MouseTask wants to recieve the mouse drag and mouse up events that follow the mouse down event. If the return value is false, then the Display will not call the other two methods. This is an abstract method that must be redefined in a subclass. It should not be necessary to call this method 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).

doMouseDrag

public void doMouseDrag(java.awt.event.MouseEvent evt,
                        Display display,
                        View view,
                        int width,
                        int height)
Description copied from class: MouseTask
Continue processing a mouse gesture for which doMouseDown returned a value of true. If not redefined in a subclass, this method does nothing.

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)
Description copied from class: MouseTask
Finish processing a mouse gesture for which doMouseDown returned a value of true. If not redefined in a subclass, does nothing.

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).

drawWhileDragging

public void drawWhileDragging(java.awt.Graphics2D g,
                              Display display,
                              View view,
                              int width,
                              int height)
Description copied from class: MouseTask
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. The graphics context is a newly created one, which has been translated and clipped, if necessary, to account for any border that has been applied to the Display. The width and height parameters give the width and height of the drawing area, in pixels.

Overrides:
drawWhileDragging in class MouseTask

getCursor

public java.awt.Cursor getCursor(Display display,
                                 View view)
Description copied from class: MouseTask
Return a cursor to be used in the display when this MouseTask is installed and waiting for a mouse-down event. If the return value is null, the default cursor will be used. If not redefined in a subclass, returns null.

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