public class FrameFocusTransferManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
FrameFocusTransferManager.Target
The container for the target component and cursor position.
|
Modifier and Type | Field and Description |
---|---|
private Frame |
owner
Owner frame.
|
private static java.util.Comparator<Widget> |
reverseSortHelper
Reverse sorting routine.
|
private static java.util.Comparator<Widget> |
sortHelper
Sorts widgets based on a left to right and top to bottom ordering.
|
Constructor and Description |
---|
FrameFocusTransferManager(Frame owner)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private FrameFocusTransferManager.Target |
getTarget(Widget source,
int coff,
boolean direction)
Locate component suitable for focus transfer using cursor movement keys.
|
boolean |
isLeftMostWidget(Widget wdgt)
Check if the specified widget is the left-most component in the current
screen row (not the same as the current record which may wrap).
|
boolean |
isRightMostWidget(Widget wdgt)
Check if the specified widget is the right-most component in the current
screen row (not the same as the current record which may wrap).
|
void |
moveAboveWidget(Widget wdgt,
int coff)
Move the cursor to the component in the nearest row above this widget.
|
void |
moveBelowWidget(Widget wdgt,
int coff)
Move the cursor to the component in the nearest row below this widget.
|
(package private) void |
moveToTarget(Widget source,
FrameFocusTransferManager.Target tgt)
Move to a target widget if needed.
|
private Widget[] |
widgetList(java.util.Comparator<Widget> helper)
Obtain a list of widgets in this frame which is guaranteed
to enforce an ordering in which the each element is left and/or above
(positionally) the next array element.
|
private final Frame owner
private static java.util.Comparator<Widget> sortHelper
private static java.util.Comparator<Widget> reverseSortHelper
public FrameFocusTransferManager(Frame owner)
owner
- Owner frame.public void moveAboveWidget(Widget wdgt, int coff)
The algorithm is dependent upon the array of components returned by the container. In particular, the order of the widgets in the array MUST be from left to right and top to bottom.
The search order (from highest to lowest precedence) is as follows:
The cursor (and focus) will be moved into the component above this one as long as such a component exists. Otherwise this method has no affect.
wdgt
- widget to checkcoff
- cursor offset within the widgetpublic void moveBelowWidget(Widget wdgt, int coff)
The algorithm is dependent upon the array of components returned by the container. In particular, the order of the widgets in the array MUST be from left to right and top to bottom.
The search order (from highest to lowest precedence) is as follows:
The cursor (and focus) will be moved into the component below this one as long as such a component exists. Otherwise this method has no affect.
wdgt
- widget to checkcoff
- cursor offset within the widgetpublic boolean isLeftMostWidget(Widget wdgt)
The algorithm is dependent upon the array of components returned by the container. In particular, the order of the widgets in the array MUST be from left to right and top to bottom.
wdgt
- widget to checktrue
if this component is the left-most component
in the row.public boolean isRightMostWidget(Widget wdgt)
The algorithm is dependent upon the array of components returned by the container. In particular, the order of the widgets in the array MUST be from left to right and top to bottom.
wdgt
- widget to checktrue
if this component is the right-most component
in the row.void moveToTarget(Widget source, FrameFocusTransferManager.Target tgt)
null
, this will change focus to that target widget and
set the cursor position accordingly.source
- Source widget.tgt
- The target to which to move. May be null
in
which case nothing is changed.private FrameFocusTransferManager.Target getTarget(Widget source, int coff, boolean direction)
First of all algorithm locates source component which contains focus now. Then it locates first component which is placed on the closest row below (or above, depending on direction) source component. Then all components which are placed on that row checked and one target component is then returned as a part of result. In most cases algorithm tries to find component which may accept cursor without changing cursors global (in screen coordinates) column. There are exceptions though.
Rules which determine the component are following:
source
- widget to checkcoff
- cursor offset within the widgetdirection
- Direction in which widgets are searched.private Widget[] widgetList(java.util.Comparator<Widget> helper)
helper
- Comparator implementation which determines final order of
widgets.