visad
Class MouseHelper

java.lang.Object
  extended by visad.MouseHelper
All Implemented Interfaces:
RendererSourceListener

public class MouseHelper
extends Object
implements RendererSourceListener

MouseHelper is the VisAD helper class for MouseBehaviorJ3D and MouseBehaviorJ2D.

MouseHelper is preferred by cats everywhere.


Field Summary
protected  boolean[] actual_button
           
static int CENTER
           
static int CURSOR_ROTATE
           
static int CURSOR_TRANSLATE
           
static int CURSOR_ZOOM
           
static int DIRECT
           
protected  DataRenderer direct_renderer
          DataRenderer for direct manipulation
protected  boolean[] function
           
static int LEFT
           
protected  int mouseModifiers
          ((InputEvent) event).getModifiers() when mouse pressed
static int NONE
           
protected  boolean[] old_function
           
static int RIGHT
           
static int ROTATE
           
protected  int start_x
          screen location when mousePressed1 or mousePressed3
protected  int start_y
          screen location when mousePressed1 or mousePressed3
static int TRANSLATE
           
protected  double[] tstart
          matrix from ProjectionControl when mousePressed1 (left)
protected  int virtual_button
           
protected  double xmul
           
protected  double xymul
           
protected  double ymul
           
static int ZOOM
           
 
Constructor Summary
MouseHelper(DisplayRenderer r, MouseBehavior b)
           
 
Method Summary
protected  boolean enableFunctions(MouseEvent event)
          Enable the functions for this mouse helper
 DisplayImpl getDisplay()
          Get the Display for this Helper
 DisplayRenderer getDisplayRenderer()
          Get the DisplayRenderer for this Helper
 boolean getEnableCombos()
          Get whether the mouse button combos are enabled
 boolean getMode2D()
          Get whether we're in 2D mode
 MouseBehavior getMouseBehavior()
          Get the MouseBehavior for this Helper
 ProjectionControl getProjectionControl()
          Get the ProjectionControl for this Helper
protected  void handleMouseDragged(MouseEvent event, int remoteId)
           
 void print_matrix(String title, double[] m)
          Print out a readable form of a matrix.
 void processEvent(AWTEvent event)
          Process the given event treating it as a local event.
 void processEvent(AWTEvent event, int remoteId)
          Process the given event, treating it as coming from a remote source if remote flag is set.
 void rendererDeleted(DataRenderer renderer)
          Implementation for RendererSourceListener.
 void setEnableCombos(boolean e)
          Enable/disable the interpretation of any pair of mouse buttons as the third button.
 void setFunctionMap(int[][][] map)
          Set mapping from (button, ctrl, shift) to function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

direct_renderer

protected DataRenderer direct_renderer
DataRenderer for direct manipulation


tstart

protected double[] tstart
matrix from ProjectionControl when mousePressed1 (left)


start_x

protected int start_x
screen location when mousePressed1 or mousePressed3


start_y

protected int start_y
screen location when mousePressed1 or mousePressed3


xmul

protected double xmul

ymul

protected double ymul

xymul

protected double xymul

mouseModifiers

protected int mouseModifiers
((InputEvent) event).getModifiers() when mouse pressed


NONE

public static final int NONE
See Also:
Constant Field Values

ROTATE

public static final int ROTATE
See Also:
Constant Field Values

ZOOM

public static final int ZOOM
See Also:
Constant Field Values

TRANSLATE

public static final int TRANSLATE
See Also:
Constant Field Values

CURSOR_TRANSLATE

public static final int CURSOR_TRANSLATE
See Also:
Constant Field Values

CURSOR_ZOOM

public static final int CURSOR_ZOOM
See Also:
Constant Field Values

CURSOR_ROTATE

public static final int CURSOR_ROTATE
See Also:
Constant Field Values

DIRECT

public static final int DIRECT
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

CENTER

public static final int CENTER
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

actual_button

protected boolean[] actual_button

virtual_button

protected int virtual_button

function

protected boolean[] function

old_function

protected boolean[] old_function
Constructor Detail

MouseHelper

public MouseHelper(DisplayRenderer r,
                   MouseBehavior b)
Method Detail

getMouseBehavior

public MouseBehavior getMouseBehavior()
Get the MouseBehavior for this Helper

Returns:
MouseBehavior

getDisplay

public DisplayImpl getDisplay()
Get the Display for this Helper

Returns:
Display

getDisplayRenderer

public DisplayRenderer getDisplayRenderer()
Get the DisplayRenderer for this Helper

Returns:
DisplayRenderer

getProjectionControl

public ProjectionControl getProjectionControl()
Get the ProjectionControl for this Helper

Returns:
ProjectionControl

getMode2D

public boolean getMode2D()
Get whether we're in 2D mode

Returns:
true if 2D mode

processEvent

public void processEvent(AWTEvent event)
Process the given event treating it as a local event.

Parameters:
event - event to process.

processEvent

public void processEvent(AWTEvent event,
                         int remoteId)
Process the given event, treating it as coming from a remote source if remote flag is set.

Parameters:
event - event to process.
remoteId - id of remote source.

handleMouseDragged

protected void handleMouseDragged(MouseEvent event,
                                  int remoteId)

enableFunctions

protected boolean enableFunctions(MouseEvent event)
Enable the functions for this mouse helper

Parameters:
event - The MouseEvent

setEnableCombos

public void setEnableCombos(boolean e)
Enable/disable the interpretation of any pair of mouse buttons as the third button.

Parameters:
e - enable/disable. If true (default), interpret any pair of mouse buttons as the third button.

getEnableCombos

public boolean getEnableCombos()
Get whether the mouse button combos are enabled

Returns:
true if any pair of mouse buttons is interpreted as the third

setFunctionMap

public void setFunctionMap(int[][][] map)
                    throws VisADException
Set mapping from (button, ctrl, shift) to function.
  map[button][ctrl][shift] =
    MouseHelper.NONE               for no function
    MouseHelper.ROTATE             for box rotate
    MouseHelper.ZOOM               for box zoom
    MouseHelper.TRANSLATE          for box translate
    MouseHelper.CURSOR_TRANSLATE   for cursor translate
    MouseHelper.CURSOR_ZOOM        for cursor on Z axis (3-D only)
    MouseHelper.CURSOR_ROTATE      for box rotate with cursor
    MouseHelper.DIRECT             for direct manipulate
  where button = 0 (left), 1 (center), 2 (right)
  ctrl = 0 (CTRL key not pressed), 1 (CTRL key pressed)
  shift = 0 (SHIFT key not pressed), 1 (SHIFT key pressed)

  Note some direct manipulation DataRenderers test the status of
  CTRL and SHIFT keys, so it is advisable that the DIRECT function
  be invariant to the state of ctrl and shift in the map array.

  For example, to set the left mouse button for direct
  manipulation, and the center button for box rotation
  (only without shift or control):
  mouse_helper.setFunctionMap(new int[][][]
    {{{MouseHelper.DIRECT, MouseHelper.DIRECT},
      {MouseHelper.DIRECT, MouseHelper.DIRECT}},
     {{MouseHelper.ROTATE, MouseHelper.NONE},
      {MouseHelper.NONE, MouseHelper.NONE}},
     {{MouseHelper.NONE, MouseHelper.NONE},
      {MouseHelper.NONE, MouseHelper.NONE}}});
  

Parameters:
map - map of functions. map must be int[3][2][2]
Throws:
VisADException - bad map

print_matrix

public void print_matrix(String title,
                         double[] m)
Print out a readable form of a matrix. Useful for debugging.

Parameters:
title - title to prepend to output.
m - matrix to print.

rendererDeleted

public void rendererDeleted(DataRenderer renderer)
Implementation for RendererSourceListener. Notifies that the renderer has been deleted.

Specified by:
rendererDeleted in interface RendererSourceListener
Parameters:
renderer - DataRenderer that was deleted.