PenProfile 2.x

com.livescribe.buttons
Class DrawnButtonController

java.lang.Object
  extended by com.livescribe.penlet.PenletPlugin
      extended by com.livescribe.penlet.AbstractPenletPlugin
          extended by com.livescribe.buttons.DrawnButtonController

public class DrawnButtonController
extends AbstractPenletPlugin

A plugin that manages the display, presentation, and processing of new prompt and believe buttons.

Events passed to the application and not processed by this plugin:

All other events are consumed, but nothing is actually done with them until this receives a pen-down or menu event.

Since:
2.3

Field Summary
static long DEFAULT_INPUT_TIMEOUT
          The default input timeout, the timeout once a user starts drawing.
protected  MediaPlayer mediaPlayer
           
 
Fields inherited from class com.livescribe.penlet.AbstractPenletPlugin
active, listeners
 
Constructor Summary
DrawnButtonController(Penlet penlet)
          Creates a new setup button plugin.
 
Method Summary
 void activate()
          Activates the plugin.
protected  void allButtonsDone()
          This is called when all the buttons have been set up.
protected  void buttonDone(Bookmarkable button)
          Called when a button was setup successfully.
protected  Region createRegionFor(Bookmarkable b)
          Subclasses can override this to change how regions are created for a bookmarkable item.
 void deactivate()
          Deactivates the plugin.
 boolean onDocumentEvent(DocumentEvent ev)
          Processes a document event.
 boolean onMenuEvent(MenuEvent ev)
          Processes a menu event.
 boolean onPenTipEvent(PenTipEvent ev)
          Processes a pen tip event.
 boolean onStrokeEvent(StrokeEvent ev)
          Processes a stroke event.
 void setButton(Bookmarkable button)
          Sets the button to set up.
 void setButtons(Bookmarkable[] buttons)
          Sets the buttons to set up.
 void setInputTimeout(long time)
          Sets the input timeout.
 
Methods inherited from class com.livescribe.penlet.AbstractPenletPlugin
addPluginListener, fireActivated, fireDeactivated, isActive, onCoordinateEvent, 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, toString, wait, wait, wait
 

Field Detail

DEFAULT_INPUT_TIMEOUT

public static final long DEFAULT_INPUT_TIMEOUT
The default input timeout, the timeout once a user starts drawing.

See Also:
setInputTimeout(long), Constant Field Values

mediaPlayer

protected MediaPlayer mediaPlayer
Constructor Detail

DrawnButtonController

public DrawnButtonController(Penlet penlet)
Creates a new setup button plugin.

Parameters:
penlet - the penlet
Method Detail

onStrokeEvent

public boolean onStrokeEvent(StrokeEvent ev)
Processes a stroke event.

Overrides:
onStrokeEvent in class AbstractPenletPlugin
Parameters:
ev - the stroke event
Returns:
true, indicating the event is handled here.
See Also:
AbstractPenletPlugin.setConsumeAllEvents(boolean)

createRegionFor

protected Region createRegionFor(Bookmarkable b)
Subclasses can override this to change how regions are created for a bookmarkable item. For example, an application may want final control over the occlusive or store strokes setting.

This creates a new region with the bookmarkable's area ID and Z-order, and with the occlusive bit set.

Parameters:
b - the bookmarkable item
Returns:
a new region.
Since:
2.5

onPenTipEvent

public boolean onPenTipEvent(PenTipEvent ev)
Processes a pen tip event.

Overrides:
onPenTipEvent in class AbstractPenletPlugin
Parameters:
ev - the pen tip event
Returns:
true, indicating the event is handled here.
See Also:
AbstractPenletPlugin.setConsumeAllEvents(boolean)

onMenuEvent

public boolean onMenuEvent(MenuEvent ev)
Processes a menu event. Unless the plugin is waiting to be deactivated, all menu events are passed to the application.

Overrides:
onMenuEvent in class AbstractPenletPlugin
Parameters:
ev - the menu event
Returns:
whether the event was handled here.
See Also:
AbstractPenletPlugin.setConsumeAllEvents(boolean)

onDocumentEvent

public boolean onDocumentEvent(DocumentEvent ev)
Processes a document event. Unless the plugin is waiting to be deactivated all document events are passed to the application.

Overrides:
onDocumentEvent in class AbstractPenletPlugin
Parameters:
ev - the document event
Returns:
whether the event was handled here.
See Also:
AbstractPenletPlugin.setConsumeAllEvents(boolean)

activate

public void activate()
              throws PenletStateChangeException
Activates the plugin. This ignores the activation request if the setup button parameters have not been set. It is suggested that the display transition be set before a call to this method.

The plugin is automatically deactivated when it is finished.

Overrides:
activate in class AbstractPenletPlugin
Throws:
PenletStateChangeException - if the buttons were not set.
See Also:
setButton(Bookmarkable), setButtons(Bookmarkable[]), Display.setTransition(Transition)

deactivate

public void deactivate()
Deactivates the plugin. This restores the display.

Overrides:
deactivate in class AbstractPenletPlugin
See Also:
AbstractPenletPlugin.active, AbstractPenletPlugin.fireDeactivated()

setButton

public final void setButton(Bookmarkable button)
Sets the button to set up. If the plugin is currently active then this will throw an IllegalStateException.

If the parameter is null then the plugin will not be activatable.

If the button's displayable user prompt returns null then then a default one will be used. Additionally, if the display name is null then the localized version of the word "BUTTON" wlil be used.

Parameters:
button - the parameters for a single button
Throws:
java.lang.IllegalStateException - if the plugin is currently active.
See Also:
setButtons(Bookmarkable[])

setButtons

public final void setButtons(Bookmarkable[] buttons)
Sets the buttons to set up. If the plugin is currently active then this will throw an IllegalStateException.

Each button will be set up, one after the other. Note that the array is used as-is internally and is not copied.

If the buttons parameter is null or of zero length then the plugin will not be activatable.

If any button's displayable user prompt returns null then then a default one will be used. Additionally, if the display name is null then the localized version of the word "BUTTON" wlil be used.

Parameters:
buttons - the list of Bookmarkable button parameters
Throws:
IllegalArgumentException - if the arrays are not the same length.
java.lang.IllegalStateException - if the plugin is currently active.

buttonDone

protected void buttonDone(Bookmarkable button)
Called when a button was setup successfully. This is called for each button and before the plugin is deactivated.

This implementation just plays the acknowledge sound.

Parameters:
button - the button that was just completed

allButtonsDone

protected void allButtonsDone()
This is called when all the buttons have been set up. The plugin should be deactivated here. For example, a subclass may wish to schedule deactivation at a later time if it is displaying a message on the screen.

This implementation simply calls deactivate().


setInputTimeout

public final void setInputTimeout(long time)
Sets the input timeout. This is the amount of time the controller will wait before automatically considering the button to be finished if the user does not double tap.

The timeout is disabled if the time is ≤ zero. The default is for the timeout is one second.

Parameters:
time - the input timeout, in milliseconds
See Also:
DEFAULT_INPUT_TIMEOUT

PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.