|
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
public abstract class PenletPlugin
A base class for all penlet plugins. A plugin has the ability to temporarily replace the display contents and to intercept penlet events.
An example of where this is useful is a subsystem that tells the user to draw a Prompt and Believe button. Having all the logic in a plugin removes the need for doing more work to support a specific feature from inside a penlet. Otherwise, the penlet would need to manage more states and data.
Another example is a logger that intercepts pen events.
Plugins can consume events by returning false from any of its
event handling methods. Consumed events will not be passed on to the
application.
Don't forget that plugins may choose not to handle events. This means that if an application uses plugins then they should check whether any relevant plugins are active. For example, a plugin may choose to assign meaning to only the NavPlus right arrow. It may handle this but will pass all other menu events to the application. Thus, the application needs to check the active state of that plugin before deciding what to do with all the other non-right arrow menu events.
A note on receiving events after the plugin is activated: Let's say a plugin is activated on a pen-down or region-enter event in a penlet. The plugin will now intercept everything after it has been activated, which means it will receive the region-exit, pen-up, and any taps that come later. Be careful when handling the pen tip, region, and stroke events in both the penlet and plugin processing logic.
Some ways to handle this include:
Plugins can share information via context properties.
A note on receiving menu events: A penlet must implement
MenuEventListener in order for any installed and active plugins to
receive any menu events. This is a current limitation in the system.
isActive(),
com.livescribe.event,
PenletContext.installPlugin(PenletPlugin),
PenletContext.uninstallPlugin(PenletPlugin),
PenletContext.setProperty(String, Object)| Constructor Summary | |
|---|---|
protected |
PenletPlugin(Penlet penlet)
Creates a new penlet plugin and uses the context of the specified Penlet. |
| Method Summary | |
|---|---|
abstract void |
activate()
Activates the plugin. |
abstract void |
addPluginListener(PluginListener l)
Adds a listener that's notified when the plugin changes state. |
abstract void |
deactivate()
Deactivates the plugin. |
protected Display |
getDisplay()
Gets the current Display. |
Penlet |
getPenlet()
Gets the penlet to which this plugin is attached. |
abstract boolean |
isActive()
Returns whether the plugin is currently active. |
boolean |
onCoordinateEvent(CoordinateEvent ev)
Handles a coordinate event. |
boolean |
onDocumentEvent(DocumentEvent ev)
Handles a document event. |
boolean |
onMenuEvent(MenuEvent ev)
Handles a menu event. |
boolean |
onPenTipEvent(PenTipEvent ev)
Handles a pen tip event. |
boolean |
onRegionEvent(RegionEvent ev)
Handles a region event. |
boolean |
onStrokeEvent(StrokeEvent ev)
Handles a stroke event. |
abstract void |
removePluginListener(PluginListener l)
Removes a listener that's notified when the plugin changes state. |
protected void |
restoreDisplay()
Restores the screen stored with saveDisplay(). |
protected void |
saveDisplay()
Stores the current screen contents so that it may be replaced and then restored at a later time. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected PenletPlugin(Penlet penlet)
penlet - the penlet| Method Detail |
|---|
public Penlet getPenlet()
protected void saveDisplay()
restoreDisplay()protected void restoreDisplay()
saveDisplay().
saveDisplay()protected Display getDisplay()
Display.
Displaypublic abstract void addPluginListener(PluginListener l)
null.
Note that this does not specify what happens if a listener is added more than once.
l - the listener to addpublic abstract void removePluginListener(PluginListener l)
null or is
not in the listener list.
l - the listener to removepublic abstract boolean isActive()
activate(),
deactivate()
public abstract void activate()
throws PenletStateChangeException
Any necessary plugin setup is done here. Additionally, any registered plugin listeners are notified when the plugin has finished activating.
This may throw a PenletStateChangeException if the plugin was
not activated. A plugin may decide that certain conditions are not met
and decide not to activate. One example is if an attempt is made to
activate the plugin more than once and the plugin disallows this. A
useful method is PenletStateChangeException.getCause() for
determining the underlying cause for an unsuccessful activation
request.
PenletStateChangeException - if the plugin could not be
activated.deactivate(),
isActive(),
PluginListener,
PenletStateChangeException.getCause()public abstract void deactivate()
Any necessary plugin cleanup is done here. Additionally, any registered plugin listeners are notified when the plugin has finished deactivating.
activate(),
isActive(),
PluginListenerpublic boolean onCoordinateEvent(CoordinateEvent ev)
false by
default, indicating that the event is consumed.
Note that the event can also be marked as consumed
to prevent the penlet from receiving the event, even if this returns
false.
ev - the coordinate event
false.Event.consume(),
CoordinateListenerpublic boolean onMenuEvent(MenuEvent ev)
false by default,
indicating that the event is consumed.
Note that the event can also be marked as consumed
to prevent the penlet from receiving the event, even if this returns
false.
ev - the menu event
false.Event.consume(),
MenuEventListenerpublic boolean onPenTipEvent(PenTipEvent ev)
false by default,
indicating that the event is consumed.
Note that the event can also be marked as consumed
to prevent the penlet from receiving the event, even if this returns
false.
ev - the pen tip event
false.Event.consume(),
PenTipListenerpublic boolean onStrokeEvent(StrokeEvent ev)
false by default,
indicating that the event is consumed.
Note that the event can also be marked as consumed
to prevent the penlet from receiving the event, even if this returns
false.
ev - the stroke event
false.Event.consume(),
StrokeListenerpublic boolean onRegionEvent(RegionEvent ev)
false by default,
indicating that the event is consumed.
Note that the event can also be marked as consumed
to prevent the penlet from receiving the event, even if this returns
false.
ev - the region event
false.Event.consume(),
RegionEnterExitListenerpublic boolean onDocumentEvent(DocumentEvent ev)
false by default,
indicating that the event is consumed.
Note that the event can also be marked as consumed
to prevent the penlet from receiving the event, even if this returns
false.
ev - the document event
false.Event.consume(),
PaperListener
|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||