JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table
Class MouseInputHandler

java.lang.Object
  |
  +--com.klg.jclass.table.InputHandler
        |
        +--com.klg.jclass.table.MouseInputHandler
All Implemented Interfaces:
ActionListener, EventListener, MouseListener, MouseMotionListener, Serializable

public class MouseInputHandler
extends InputHandler
implements Serializable, ActionListener, MouseListener, MouseMotionListener

MouseInputHandler processes all mouse events for table. It handles traversal, selection, resize, editor start and stop, and dragging.

See Also:
Serialized Form

Field Summary
protected static int AUTO_SCROLL_AMOUNT
           
protected static int AUTO_SCROLL_DEC
           
protected  int auto_scroll_horiz
           
protected static int AUTO_SCROLL_INC
           
protected  com.klg.jclass.table.JCCellPosition auto_scroll_initial_cell
           
protected static int AUTO_SCROLL_NONE
           
protected  Timer auto_scroll_timer
           
protected  int auto_scroll_vert
           
protected  int auto_scroll_x
           
protected  int auto_scroll_y
           
protected  boolean AUTOSCROLLING
           
protected static int CORNER_CURSOR
           
protected static int CORNER_RESIZE
           
protected static int DEFAULT_CURSOR
           
protected  boolean DRAGGING
           
protected static int HORIZ_CURSOR
           
protected static int HORIZ_RESIZE
           
protected  com.klg.jclass.table.JCCellPosition initial_cell
           
protected static int MOVE_CURSOR
           
protected  boolean multi_cell_drag
           
protected  boolean needs_resize_begin_event
           
protected static int NO_RESIZE
           
protected static int NONTRAV_CURSOR
           
protected  com.klg.jclass.table.JCCellPosition position
           
protected  com.klg.jclass.table.JCResizeCellEvent resize_motion_event
           
protected  int resizeColumn
           
protected  com.klg.jclass.table.CellSize resizeColumnCellSize
           
protected  int resizeHeight
           
protected  Point resizePoint
           
protected  int resizeRow
           
protected  com.klg.jclass.table.CellSize resizeRowCellSize
           
protected  int resizeWidth
           
protected  boolean RESIZING
           
protected  boolean SORTING
           
protected static int TRAV_CURSOR
           
protected static int VERT_CURSOR
           
protected static int VERT_RESIZE
           
protected static int WAIT_CURSOR
           
 
Fields inherited from class com.klg.jclass.table.InputHandler
SELECTING, table
 
Constructor Summary
MouseInputHandler(com.klg.jclass.table.JCTable table)
           
 
Method Summary
 void actionPerformed(ActionEvent event)
          ActionPerformed is called by the AutoScroll timer in order to make new rows/columns visible when the mouse is dragged out of the cell/label area of table during selection or dragging.
protected  void cancelDrag()
          Cancels the drag process if mouse release if over a frozen cell.
protected  void cancelResize()
          Resets the resize variables.
protected  void endDrag(com.klg.jclass.table.JCCellPosition final_cell)
          Completes the drag process by actually performing the manipulation.
protected  int getResizeDirection(int x, int y, int row, int column)
          Determines whether a resize is available at the current position.
protected  boolean isAutoScrollColumn()
          Returns true if column auto scroll is enabled.
protected  boolean isAutoScrollRow()
          Returns true if row auto scroll is enabled.
 boolean isLeftButton(int modifiers)
          Returns true if the mouse press is with the left mouse button.
 boolean isMiddleButton(int modifiers)
          Returns true if the mouse press is with the middle mouse button.
protected  boolean isResizing()
          Returns true if resize is under way.
 boolean isRightButton(int modifiers)
          Returns true if the mouse press is with the right mouse button.
protected  boolean isTraversable(int row, int column)
          Returns true if the cell is potentially traversable.
protected  boolean isValidCellPosition(com.klg.jclass.table.JCCellPosition cell)
          Returns true if the cell position is potentially valid.
protected  boolean isValidDragPosition(com.klg.jclass.table.JCCellPosition cp)
          Returns true if the given position is valid for dragging.
 void mouseClicked(MouseEvent e)
          Process mouse click.
 void mouseDragged(MouseEvent e)
          Process mouse drag.
 void mouseEntered(MouseEvent e)
          Process mouse enter.
 void mouseExited(MouseEvent e)
          Process mouse exit.
 void mouseMoved(MouseEvent e)
          Process mouse move.
 void mousePressed(MouseEvent e)
          Process mouse press.
 void mouseReleased(MouseEvent e)
          Process mouse release.
protected  void performDrag(com.klg.jclass.table.JCCellPosition current_cell)
          Drags the invoking row or column to the new position.
protected  void resizeBegin(int x, int y)
          Initiates a resize action.
protected  void resizeDrag(int x, int y)
          Handles a drag event during a resize action.
protected  void resizeEnd(int x, int y)
          Completes a resize action.
protected  int trackResizeCursor(int x, int y)
          Returns the cursor type given a mouse position.
protected  boolean traverse(MouseEvent event, com.klg.jclass.table.JCCellPosition position, boolean isPress)
          Traverse the current cell from one location to another, scrolling to make it visible if necessary.
 
Methods inherited from class com.klg.jclass.table.InputHandler
getCellPosition, isAlt, isCell, isControl, isCopyAction, isLabel, isMeta, isPasteAction, isShift, loadPasteData, performCopyAction, performPasteAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CURSOR

protected static final int DEFAULT_CURSOR
See Also:
Constant Field Values

TRAV_CURSOR

protected static final int TRAV_CURSOR
See Also:
Constant Field Values

NONTRAV_CURSOR

protected static final int NONTRAV_CURSOR
See Also:
Constant Field Values

CORNER_CURSOR

protected static final int CORNER_CURSOR
See Also:
Constant Field Values

HORIZ_CURSOR

protected static final int HORIZ_CURSOR
See Also:
Constant Field Values

VERT_CURSOR

protected static final int VERT_CURSOR
See Also:
Constant Field Values

MOVE_CURSOR

protected static final int MOVE_CURSOR
See Also:
Constant Field Values

WAIT_CURSOR

protected static final int WAIT_CURSOR
See Also:
Constant Field Values

NO_RESIZE

protected static final int NO_RESIZE
See Also:
Constant Field Values

HORIZ_RESIZE

protected static final int HORIZ_RESIZE
See Also:
Constant Field Values

VERT_RESIZE

protected static final int VERT_RESIZE
See Also:
Constant Field Values

CORNER_RESIZE

protected static final int CORNER_RESIZE
See Also:
Constant Field Values

initial_cell

protected com.klg.jclass.table.JCCellPosition initial_cell

position

protected com.klg.jclass.table.JCCellPosition position

multi_cell_drag

protected boolean multi_cell_drag

resizeRow

protected int resizeRow

resizeColumn

protected int resizeColumn

resizeHeight

protected int resizeHeight

resizeWidth

protected int resizeWidth

resizeRowCellSize

protected com.klg.jclass.table.CellSize resizeRowCellSize

resizeColumnCellSize

protected com.klg.jclass.table.CellSize resizeColumnCellSize

resizePoint

protected Point resizePoint

needs_resize_begin_event

protected boolean needs_resize_begin_event

resize_motion_event

protected com.klg.jclass.table.JCResizeCellEvent resize_motion_event

AUTO_SCROLL_DEC

protected static final int AUTO_SCROLL_DEC
See Also:
Constant Field Values

AUTO_SCROLL_NONE

protected static final int AUTO_SCROLL_NONE
See Also:
Constant Field Values

AUTO_SCROLL_INC

protected static final int AUTO_SCROLL_INC
See Also:
Constant Field Values

AUTO_SCROLL_AMOUNT

protected static final int AUTO_SCROLL_AMOUNT
See Also:
Constant Field Values

auto_scroll_horiz

protected int auto_scroll_horiz

auto_scroll_vert

protected int auto_scroll_vert

auto_scroll_timer

protected transient Timer auto_scroll_timer

auto_scroll_initial_cell

protected com.klg.jclass.table.JCCellPosition auto_scroll_initial_cell

auto_scroll_x

protected int auto_scroll_x

auto_scroll_y

protected int auto_scroll_y

AUTOSCROLLING

protected boolean AUTOSCROLLING

DRAGGING

protected boolean DRAGGING

RESIZING

protected boolean RESIZING

SORTING

protected boolean SORTING
Constructor Detail

MouseInputHandler

public MouseInputHandler(com.klg.jclass.table.JCTable table)
Method Detail

isLeftButton

public final boolean isLeftButton(int modifiers)
Returns true if the mouse press is with the left mouse button.

Parameters:
modifiers - The mouse event modifiers
Returns:
Was the left button pressed?

isMiddleButton

public final boolean isMiddleButton(int modifiers)
Returns true if the mouse press is with the middle mouse button.

Parameters:
modifiers - The mouse event modifiers
Returns:
Was the middle button pressed?

isRightButton

public final boolean isRightButton(int modifiers)
Returns true if the mouse press is with the right mouse button.

Parameters:
modifiers - The mouse event modifiers
Returns:
Was the right button pressed?

mousePressed

public void mousePressed(MouseEvent e)
Process mouse press.

Specified by:
mousePressed in interface MouseListener
Parameters:
e - The event generated by the mouse press

isValidDragPosition

protected boolean isValidDragPosition(com.klg.jclass.table.JCCellPosition cp)
Returns true if the given position is valid for dragging. The drag process is restricted to non-frozen cells.

Parameters:
cp - The cell position (i.e. row/column)
Returns:
Can you drag from the cell referenced by the given cell position

mouseDragged

public void mouseDragged(MouseEvent e)
Process mouse drag.

Specified by:
mouseDragged in interface MouseMotionListener
Parameters:
e - The event generated by the mouse drag

mouseReleased

public void mouseReleased(MouseEvent e)
Process mouse release.

Specified by:
mouseReleased in interface MouseListener
Parameters:
e - The event generated by the mouse release

mouseEntered

public void mouseEntered(MouseEvent e)
Process mouse enter.

Specified by:
mouseEntered in interface MouseListener
Parameters:
e - The event generated by the mouse enter

mouseMoved

public void mouseMoved(MouseEvent e)
Process mouse move.

Specified by:
mouseMoved in interface MouseMotionListener
Parameters:
e - The event generated by the mouse move

mouseExited

public void mouseExited(MouseEvent e)
Process mouse exit.

Specified by:
mouseExited in interface MouseListener
Parameters:
e - The event generated by the mouse exit

mouseClicked

public void mouseClicked(MouseEvent e)
Process mouse click.

Specified by:
mouseClicked in interface MouseListener
Parameters:
e - The event generated by the mouse click

trackResizeCursor

protected int trackResizeCursor(int x,
                                int y)
Returns the cursor type given a mouse position.

Parameters:
x - The x coordinate of the mouse
y - The y coordinate of the mouse
Returns:
The cursor type based on the mouse being at (x, y)

getResizeDirection

protected int getResizeDirection(int x,
                                 int y,
                                 int row,
                                 int column)
Determines whether a resize is available at the current position.

Parameters:
x - The x coordinate of the current position
y - The y coordinate of the current position
row - The row in which the current position is in
column - The column in which the current position is in
Returns:
The resize type available. Valid return values are NO_RESIZE, HORIZ_RESIZE, VERT_RESIZE and BORDER_RESIZE.

resizeBegin

protected void resizeBegin(int x,
                           int y)
Initiates a resize action.

Parameters:
x - The x position of the resize begin
y - The y position of the resize begin

resizeDrag

protected void resizeDrag(int x,
                          int y)
Handles a drag event during a resize action.

Parameters:
x - The x position of the resize drag
y - The y position of the resize drag

resizeEnd

protected void resizeEnd(int x,
                         int y)
Completes a resize action.

Parameters:
x - The x position of the resize end
y - The y position of the resize end

cancelResize

protected void cancelResize()
Resets the resize variables.


isAutoScrollRow

protected final boolean isAutoScrollRow()
Returns true if row auto scroll is enabled.

Returns:
Whether row auto scroll is enabled.

isAutoScrollColumn

protected final boolean isAutoScrollColumn()
Returns true if column auto scroll is enabled.

Returns:
Whether column auto scroll is enabled.

isResizing

protected final boolean isResizing()
Returns true if resize is under way.

Returns:
Is a resize currently happening?

isTraversable

protected final boolean isTraversable(int row,
                                      int column)
Returns true if the cell is potentially traversable.

Parameters:
row - The row index of the cell
column - The column index of the cell
Returns:
Whether a cell is a candidate for traversal

isValidCellPosition

protected final boolean isValidCellPosition(com.klg.jclass.table.JCCellPosition cell)
Returns true if the cell position is potentially valid. This check do not validate against the number of rows or columns in the datasource.

Parameters:
cell - The cell position
Returns:
Is the cell position potentially valid?

traverse

protected boolean traverse(MouseEvent event,
                           com.klg.jclass.table.JCCellPosition position,
                           boolean isPress)
Traverse the current cell from one location to another, scrolling to make it visible if necessary.

Parameters:
event - The mouse event that caused traverse to be called
position - The cell position of the mouse event
isPress - Is this a button press
Returns:
true if the traverse succeeded

performDrag

protected void performDrag(com.klg.jclass.table.JCCellPosition current_cell)
Drags the invoking row or column to the new position. The invoking row or column is determined at the time of the initial mouse press.

Parameters:
current_cell - The current cell to which to drag

cancelDrag

protected void cancelDrag()
Cancels the drag process if mouse release if over a frozen cell.


endDrag

protected void endDrag(com.klg.jclass.table.JCCellPosition final_cell)
Completes the drag process by actually performing the manipulation. Before endDrag is called, all drag actions are simulated by CellAreaHandler.

Parameters:
final_cell - The final cell to which to drag

actionPerformed

public void actionPerformed(ActionEvent event)
ActionPerformed is called by the AutoScroll timer in order to make new rows/columns visible when the mouse is dragged out of the cell/label area of table during selection or dragging.

Specified by:
actionPerformed in interface ActionListener
Parameters:
event - The action event generated by the action

Copyright © 2004 Quest Software Inc..
All rights reserved.