visad
Class MouseHelper

java.lang.Object
  extended byvisad.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
(package private)  boolean[] actual_button
           
(package private)  MouseBehavior behavior
           
static int CENTER
           
static int CURSOR_ROTATE
           
static int CURSOR_TRANSLATE
           
static int CURSOR_ZOOM
           
static int DIRECT
           
(package private)  DataRenderer direct_renderer
           
(package private)  DisplayImpl display
           
(package private)  DisplayRenderer display_renderer
          DisplayRenderer for Display
(package private)  boolean enable_combos
           
(package private)  boolean[] function
           
(package private)  int[][][] function_map
           
static int LEFT
           
static int NFUNCTIONS
           
static int NONE
           
(package private)  boolean[] old_function
           
static int RIGHT
           
static int ROTATE
           
static int TRANSLATE
           
(package private)  int virtual_button
           
static int ZOOM
           
 
Constructor Summary
MouseHelper(DisplayRenderer r, MouseBehavior b)
           
 
Method Summary
 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

behavior

MouseBehavior behavior

display_renderer

DisplayRenderer display_renderer
DisplayRenderer for Display


display

DisplayImpl display

direct_renderer

DataRenderer direct_renderer

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

NFUNCTIONS

public static final int NFUNCTIONS
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

boolean[] actual_button

virtual_button

int virtual_button

function

boolean[] function

old_function

boolean[] old_function

enable_combos

boolean enable_combos

function_map

int[][][] function_map
Constructor Detail

MouseHelper

public MouseHelper(DisplayRenderer r,
                   MouseBehavior b)
Method Detail

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.

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.

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.