Package edu.wisc.ssec.mcidasv.util
Class FocusTraveller
java.lang.Object
java.awt.FocusTraversalPolicy
edu.wisc.ssec.mcidasv.util.FocusTraveller
Abstraction of
FocusTraversalPolicy that allows for easy creation of
the traversal policy.
Note that the "delta" parameter of both
cycle(Component, int) and indexCycle(int, int) can be any
positive or negative integer. Both methods compute indices using the wonders
of modular arithmetic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Component[]Components to traverse, stored in the desired traversal order. -
Constructor Summary
ConstructorsConstructorDescriptionFocusTraveller(Component... componentsToTraverse) Creates theFocusTraversalPolicy.FocusTraveller(Collection<Component> componentsToTraverse) Creates theFocusTraversalPolicyfor the given components. -
Method Summary
Modifier and TypeMethodDescriptionprivate ComponentCycles through components.getComponentAfter(Container container, Component component) Gets the next component aftercomponent.getComponentBefore(Container container, Component component) Gets the component beforecomponent.getDefaultComponent(Container container) Not used.getFirstComponent(Container container) Gets the first component.getLastComponent(Container container) Gets the last component.private intindexCycle(int index, int delta) Cycles through valid index values.Methods inherited from class java.awt.FocusTraversalPolicy
getInitialComponent
-
Field Details
-
components
Components to traverse, stored in the desired traversal order.
-
-
Constructor Details
-
FocusTraveller
Creates theFocusTraversalPolicy.- Parameters:
componentsToTraverse- Components to traverse, in the desired order. Cannot benull.
-
FocusTraveller
Creates theFocusTraversalPolicyfor the given components.- Parameters:
componentsToTraverse- Components to traverse. Cannot benull.
-
-
Method Details
-
indexCycle
Cycles through valid index values.- Parameters:
index- Current index.delta- Index of next component, relative toindex.- Returns:
- Next index value.
-
cycle
Cycles through components.- Parameters:
currentComponent- Cannot benull.delta- Index of next component, relative tocurrentComponent.- Returns:
- The "next" component in the traversal order.
-
getComponentAfter
Gets the next component aftercomponent.- Specified by:
getComponentAfterin classFocusTraversalPolicy- Parameters:
container- Ignored.component- Cannot benull.- Returns:
- Next component after
component.
-
getComponentBefore
Gets the component beforecomponent.- Specified by:
getComponentBeforein classFocusTraversalPolicy- Parameters:
container- Ignored.component- Cannot benull.- Returns:
- The
Componentbeforecomponentin traversal order.
-
getFirstComponent
Gets the first component.- Specified by:
getFirstComponentin classFocusTraversalPolicy- Parameters:
container- Ignored.- Returns:
- The first
Componentin traversal order.
-
getLastComponent
Gets the last component.- Specified by:
getLastComponentin classFocusTraversalPolicy- Parameters:
container- Ignored.- Returns:
- The last
Componentin traversal order.
-
getDefaultComponent
Not used. SeegetFirstComponent(Container).- Specified by:
getDefaultComponentin classFocusTraversalPolicy- Parameters:
container- Ignored.- Returns:
- The first
Componentin traversal order.
-