|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.livescribe.penlet.PenletPlugin
com.livescribe.penlet.AbstractPenletPlugin
com.livescribe.ext.plugins.AcquireHWPlugin
public class AcquireHWPlugin
A penlet plugin that performs common functions.
This is designed to work well with applications that use a single line of handwriting and some terminating event (including double-tap) to perform a function.
Note that this plugin does not save and restore the screen.
| Nested Class Summary | |
|---|---|
static interface |
AcquireHWPlugin.DisplayFilter
An interface that defines how to display the results on the screen when displaying the results
is enabled. |
| Field Summary | |
|---|---|
protected Rectangle |
currBB
The current bounding box of any received strokes. |
protected PageInstance |
currPage
The current page, set when a pen-down event occurs. |
static int |
DEFAULT_HWR_INACTIVITY_TIME
The default HWR inactivity time. |
static int |
RESULT_HWR_ERROR
Indicates that an HWR error occurred. |
static int |
RESULT_OK
The result is "OK". |
static int |
RESULT_OVERLAPPED
An overlap was detected and overlapping was set to not allowed. |
static int |
RESULT_PAGE_CHANGED
The page was changed in the middle of the recognition and page changing was set to not allowed. |
static int |
RESULT_UNDEFINED
The plugin has not been used to generate a result or it has been deactivated early. |
| Fields inherited from class com.livescribe.penlet.AbstractPenletPlugin |
|---|
active, listeners |
| Constructor Summary | |
|---|---|
AcquireHWPlugin(Penlet penlet)
Creates a new HWR plugin. |
|
| Method Summary | |
|---|---|
void |
activate()
Activates the plugin. |
void |
addAKSystemResource(String res)
Adds an Alphabet Knowledge system ICR resource. |
void |
addAppResource(String res)
Adds an application-specific ICR resource. |
void |
addLKSystemResource(String res)
Adds a Lexical Knowledge system ICR resource. |
void |
addSKSystemResource(String res)
Adds a Subset Knowledge system ICR resource. |
void |
clearResources()
Clears all the ICR resources. |
void |
deactivate()
Deactivates the plugin. |
String |
getHWRErrorString()
Returns the HWR error string if getResultStatus() returns
RESULT_HWR_ERROR. |
String |
getResult()
Returns the last HWR result. |
Rectangle |
getResultBounds()
Gets the bounds of the last result. |
int |
getResultStatus()
Gets the status of the result, for example if the result is null because of an error. |
boolean |
onPenTipEvent(PenTipEvent ev)
Processes a pen tip event. |
boolean |
onStrokeEvent(StrokeEvent ev)
A new stroke was created by the user. |
protected void |
restart(boolean resetState)
Restarts the handwriting recognition process. |
void |
setAllowOverlap(boolean flag)
Sets whether strokes are allowed on regions that are not open paper. |
void |
setAllowPageChange(boolean flag)
Sets whether to allow handwriting recognition over multiple pages. |
void |
setDisplayOnResult(boolean flag,
AcquireHWPlugin.DisplayFilter displayFilter)
Sets whether to display the results as the are received. |
void |
setDoubleTapTerminates(boolean flag)
Sets whether the plugin should terminate when a user timeout occurs or if it should terminate after a double tap. |
void |
setHWRInactivityTime(int time)
Sets the HWR timeout, in milliseconds. |
void |
setUserPauseTerminates(boolean flag)
Sets whether a user pause can terminate the plugin. |
String |
toString()
Returns a string representation of this object. |
| Methods inherited from class com.livescribe.penlet.AbstractPenletPlugin |
|---|
addPluginListener, fireActivated, fireDeactivated, isActive, onCoordinateEvent, onDocumentEvent, onMenuEvent, onRegionEvent, removePluginListener, scheduleDeactivation, setConsumeAllEvents |
| Methods inherited from class com.livescribe.penlet.PenletPlugin |
|---|
getDisplay, getPenlet, restoreDisplay, saveDisplay |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_HWR_INACTIVITY_TIME
public static final int RESULT_UNDEFINED
public static final int RESULT_OK
public static final int RESULT_OVERLAPPED
setAllowOverlap(boolean),
Constant Field Valuespublic static final int RESULT_PAGE_CHANGED
setAllowPageChange(boolean),
Constant Field Valuespublic static final int RESULT_HWR_ERROR
protected Rectangle currBB
protected PageInstance currPage
| Constructor Detail |
|---|
public AcquireHWPlugin(Penlet penlet)
consumeAllEvents set to false.
penlet - the associated penletAbstractPenletPlugin.AbstractPenletPlugin(Penlet, boolean)| Method Detail |
|---|
public void activate()
throws PenletStateChangeException
If the HWR engine could not be initialized or if the ICR resources have
not been set then this will throw a PenletStateChangeException.
The plugin will start processing events when it sees the next pen-down event. It will ignore all other pen tip and stroke events—and pass them along to the application—until then.
activate in class AbstractPenletPluginPenletStateChangeException - if there was an error initializing
HWR engine or if the ICR resources were not set.setHWRInactivityTime(int),
addAKSystemResource(String),
addSKSystemResource(String),
addLKSystemResource(String),
addAppResource(String)protected void restart(boolean resetState)
deactivate() implementation if actual
deactivation is not yet required.
There are two ways to restart the process. The first way is to
completely reset the state so that new handwriting will not continue
from where the recognition left off. If this is the desired behavior,
pass true for the resetState parameter.
The other way is to continue the recognition from where it left off.
If this is desired then pass false for the parameter.
resetState - indicates whether to reset the statepublic void deactivate()
This can be overridden and used as a way to detect when this plugin is
finished recognition. The HWR process can be restarted via
restart(boolean). In this case, don't call
super.deactivate() because that would actually deactivate
the plugin.
deactivate in class AbstractPenletPluginAbstractPenletPlugin.active,
AbstractPenletPlugin.fireDeactivated()public void setHWRInactivityTime(int time)
The default is 2000 ms.
time - the new HWR timeout, in msDEFAULT_HWR_INACTIVITY_TIMEpublic void addAKSystemResource(String res)
res - add this AK system resourceICRContext.createAKSystemResource(String),
clearResources()public void addSKSystemResource(String res)
res - add this SK system resourceICRContext.createSKSystemResource(String),
clearResources()public void addLKSystemResource(String res)
res - add this LK system resourceICRContext.createLKSystemResource(String),
clearResources()public void addAppResource(String res)
res - add this application resourceICRContext.createAppResource(String),
clearResources()public void clearResources()
addAKSystemResource(String),
addSKSystemResource(String),
addLKSystemResource(String),
addAppResource(String)public void setAllowOverlap(boolean flag)
The default is to disallow overlap, or false.
flag - the new statepublic void setAllowPageChange(boolean flag)
false.
flag - the new state
public void setDisplayOnResult(boolean flag,
AcquireHWPlugin.DisplayFilter displayFilter)
false.
This also sets the display filter to use when displaying received
results. If this is set to null then the result will be
used as-is. The default is no display filter, or null.
flag - the new statedisplayFilter - the new display filter, may be nullAcquireHWPlugin.DisplayFilterpublic void setDoubleTapTerminates(boolean flag)
true, the plugin will terminate after a double tap. If
set to false, the plugin will terminate after it receives
its first timeout.
The default is false.
If this is set to true then double taps are not consumed
by this plugin and are passed along to the application. This is to
allow the application to, for example, alert the user. Note that there
is no guarantee as to the ordering of this event with respect to plugin
deactivation.
flag - the new statesetUserPauseTerminates(boolean)public void setUserPauseTerminates(boolean flag)
setDoubleTapTerminates(boolean) set to false),
then this setting is ignored and it will be as if it is set to
true. In other words, the only time a user pause does not
terminate the plugin is when this setting is set to false
and setDoubleTapTerminates(boolean) is set to
true.
The default is false.
flag - the new statesetDoubleTapTerminates(boolean)public String getResult()
null if the
plugin has never been activated before, or if the current result was
not recognized.
getResultBounds(),
getResultStatus()public Rectangle getResultBounds()
getResult()public int getResultStatus()
null because of an error.
Please see the RESULT_XXX constants.
If this returns RESULT_HWR_ERROR then
getHWRErrorString() can be used to retrieve any associated
error string.
RESULT_UNDEFINED,
RESULT_OK,
RESULT_OVERLAPPED,
RESULT_PAGE_CHANGED,
RESULT_HWR_ERRORpublic String getHWRErrorString()
getResultStatus() returns
RESULT_HWR_ERROR.
HWRListener.hwrError(long, String)public boolean onStrokeEvent(StrokeEvent ev)
This performs the following tasks:
recordNextStroke to true and returns
immediately if it was set to false.currBB.
onStrokeEvent in class AbstractPenletPluginev - the stroke event
AbstractPenletPlugin.setConsumeAllEvents(boolean)public boolean onPenTipEvent(PenTipEvent ev)
This does not consume double taps if double tap termination is enabled
via setDoubleTapTerminates(boolean). The purpose of passing
along double taps is to allow the application to perform some action in
case it wishes to alert the user.
onPenTipEvent in class AbstractPenletPluginev - the pen tip event
AbstractPenletPlugin.setConsumeAllEvents(boolean)public String toString()
toString in class Object
|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||