public class MouseHelper extends Object implements RendererSourceListener
MouseHelper is preferred by cats everywhere.
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
MouseHelper(DisplayRenderer r,
MouseBehavior b) |
Modifier and Type | Method and Description |
---|---|
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.
|
void |
setTranslationFactor(int start_x,
int start_y) |
protected DataRenderer direct_renderer
protected double[] tstart
protected int start_x
protected int start_y
protected double xmul
protected double ymul
protected double xymul
protected int mouseModifiers
public static final int NONE
public static final int ROTATE
public static final int ZOOM
public static final int TRANSLATE
public static final int CURSOR_TRANSLATE
public static final int CURSOR_ZOOM
public static final int CURSOR_ROTATE
public static final int DIRECT
public static final int LEFT
public static final int CENTER
public static final int RIGHT
protected boolean[] actual_button
protected int virtual_button
protected boolean[] function
protected boolean[] old_function
public MouseHelper(DisplayRenderer r, MouseBehavior b)
public MouseBehavior getMouseBehavior()
public DisplayImpl getDisplay()
public DisplayRenderer getDisplayRenderer()
public ProjectionControl getProjectionControl()
public boolean getMode2D()
public void processEvent(AWTEvent event)
event
- event to process.public void processEvent(AWTEvent event, int remoteId)
event
- event to process.remoteId
- id of remote source.protected void handleMouseDragged(MouseEvent event, int remoteId)
protected boolean enableFunctions(MouseEvent event)
event
- The MouseEventpublic void setEnableCombos(boolean e)
e
- enable/disable. If true (default), interpret any pair
of mouse buttons as the third button.public boolean getEnableCombos()
public void setFunctionMap(int[][][] map) throws VisADException
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}}});
map
- map of functions. map must be int[3][2][2]VisADException
- bad mappublic void setTranslationFactor(int start_x, int start_y)
public void print_matrix(String title, double[] m)
title
- title to prepend to output.m
- matrix to print.public void rendererDeleted(DataRenderer renderer)
rendererDeleted
in interface RendererSourceListener
renderer
- DataRenderer that was deleted.Copyright © 1996–2023 The SSEC Visualization Project. All rights reserved.