public class AutoDirectionHandler extends Object implements KeyUpHandler, HasDirectionEstimator
Modifier and Type | Class and Description |
---|---|
static interface |
AutoDirectionHandler.Target
The interface an object must implement in order to add an
AutoDirectionHandler to it.
|
Modifier and Type | Method and Description |
---|---|
static AutoDirectionHandler |
addTo(AutoDirectionHandler.Target target)
Operates like
addTo(Target, DirectionEstimator) , but always uses
a default DirectionEstimator, WordCountDirectionEstimator . |
static AutoDirectionHandler |
addTo(AutoDirectionHandler.Target target,
boolean enabled)
Operates like
addTo(Target, DirectionEstimator) , but uses a
default DirectionEstimator, WordCountDirectionEstimator if enabled ,
or else a null DirectionEstimator, which means disabling direction
estimation. |
static AutoDirectionHandler |
addTo(AutoDirectionHandler.Target target,
DirectionEstimator directionEstimator)
Adds auto-direction adjustment to a given object:
- Creates an AutoDirectionHandler.
|
DirectionEstimator |
getDirectionEstimator()
Returns the DirectionEstimator object.
|
void |
onKeyUp(KeyUpEvent event)
Automatically adjusts hasDirection's direction on KeyUpEvent events.
|
void |
refreshDirection()
Adjusts target's direction according to the estimated direction of the text
it supplies.
|
void |
setDirectionEstimator(boolean enabled)
Toggles direction estimation on (using a default estimator) and off.
|
void |
setDirectionEstimator(DirectionEstimator directionEstimator)
Sets the DirectionEstimator object.
|
public static AutoDirectionHandler addTo(AutoDirectionHandler.Target target)
addTo(Target, DirectionEstimator)
, but always uses
a default DirectionEstimator, WordCountDirectionEstimator
.target
- Object whose direction should be automatically adjusted on
relevant events.public static AutoDirectionHandler addTo(AutoDirectionHandler.Target target, boolean enabled)
addTo(Target, DirectionEstimator)
, but uses a
default DirectionEstimator, WordCountDirectionEstimator
if enabled
,
or else a null DirectionEstimator, which means disabling direction
estimation.target
- Object whose direction should be automatically adjusted on
relevant events.enabled
- Whether the handler is enabled upon creation.public static AutoDirectionHandler addTo(AutoDirectionHandler.Target target, DirectionEstimator directionEstimator)
target
- Object whose direction should be automatically adjusted on
relevant events.directionEstimator
- A DirectionEstimator object used for direction
estimation (use null to disable direction estimation).public DirectionEstimator getDirectionEstimator()
getDirectionEstimator
in interface HasDirectionEstimator
public void onKeyUp(KeyUpEvent event)
onKeyUp
in interface KeyUpHandler
event
- the KeyUpEvent
that was firedpublic void refreshDirection()
public void setDirectionEstimator(boolean enabled)
setDirectionEstimator
in interface HasDirectionEstimator
enabled
- Whether to enable direction estimation. If true
,
sets the DirectionEstimator
object to a default
DirectionEstimator
.public void setDirectionEstimator(DirectionEstimator directionEstimator)
setDirectionEstimator
in interface HasDirectionEstimator
directionEstimator
- The DirectionEstimator
to be set. null
means turning off direction estimation.Copyright © 2018. All rights reserved.