|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.livescribe.ext.ui.Menu
public class Menu
A class to make it easier to build browse list-based menus. This represents a list of items, some of which may be selectable submenus.
Internally, this maps browse list items to sub-menus.
| Nested Class Summary | |
|---|---|
static interface |
Menu.MenuAction
This interface provides a way for menu selection to trigger an action. |
protected class |
Menu.MenuBrowseList
A special BrowseList implementation that allows the menu to
access some protected methods and override others. |
protected static class |
Menu.MenuItem
An implementation of a browse list item. |
static interface |
Menu.MenuListener
This interface listens to menu changes or events. |
| Constructor Summary | |
|---|---|
Menu()
Creates a new menu with no title. |
|
Menu(Object title)
Creates a new menu having the specified title. |
|
| Method Summary | |
|---|---|
void |
add(Object text)
Adds a non-selectable item to the menu. |
void |
add(Object text,
Image icon,
String audio,
Menu.MenuAction action,
Menu submenu)
Adds a new item to the menu. |
void |
add(Object text,
Menu.MenuAction action)
Adds a non-selectable item to the menu. |
void |
add(Object text,
Menu submenu)
Adds a selectable item to the menu. |
void |
addAction(int index,
Menu.MenuAction action)
Adds an action for the item at the specified index. |
void |
addMenuListener(Menu.MenuListener listener)
Adds a menu listener to this menu. |
protected Menu.MenuBrowseList |
createBrowseList(Vector items,
BrowseList.Title title)
This gives subclasses the opportunity to use their own Menu.MenuBrowseList implementation, for example to paint icons
differently. |
Menu |
doSelect(int index,
Display display,
MediaPlayer player)
Selects an item as if it was chosen with a tap on the NavPlus right arrow. |
protected void |
fireItemChanged(int oldIndex,
int newIndex,
boolean activated)
Notifies the listener that an item was changed. |
protected void |
fireItemSelected(int index)
Notifies the listener that an item was selected. |
protected void |
fireMenuShown()
Notifies the listener that the menu was shown on the display. |
protected BrowseList |
getBrowseList()
Gets the browse list display object. |
int |
getFocusIndex()
Gets the index of the item that currently has the focus. |
int |
getItemCount()
Gets the item count. |
Object |
getMetadata()
Returns the metadata associated with this menu. |
Object |
getMetadata(int index)
Gets the metadata associated with the specified menu item. |
Menu |
getParent()
Returns the parent menu, or null if this menu has no
parent. |
Menu |
getSubmenu(int index)
Gets the submenu for the item at the specified index. |
Menu |
handleMenuEvent(MenuEvent event,
Display display,
MediaPlayer player)
Handles a menu event by properly displaying the information. |
boolean |
isSelectable(int index)
Returns whether the item at the specified index is selectable. |
void |
remove(int index)
Removes the menu item at the specified index. |
void |
removeMenuListener(Menu.MenuListener listener)
Removes a menu listener. |
void |
setAudio(int index,
String audio)
Sets the audio to be played when the specified menu item has the focus. |
void |
setBackAPM(String clip)
Sets the sound to play when the user navigates to a parent menu. |
void |
setBookmarkable(int index,
Bookmarkable b)
Sets the specified menu as bookmarkable. |
static void |
setDefaultBackAPM(String clip)
Sets the default sound to play when the user navigates to a parent menu. |
static void |
setDefaultForwardAPM(String clip)
Sets the default sound to play when the user navigates to a submenu. |
static void |
setDefaultSelectAPM(String clip)
Sets the default sound to play when the user selects a menu item having no submenu. |
void |
setFocusIndex(int index)
Sets the item index that should have the focus. |
void |
setForwardAPM(String clip)
Sets the sound to play when the user navigates to a submenu. |
void |
setIcon(int index,
Image icon)
Sets the icon for the item at the specified index. |
void |
setLastItemBookmarkable(Bookmarkable b)
A convenience method that sets the last menu item's bookmark info. |
void |
setMetadata(int index,
Object data)
Attaches some arbitrary metadata to a specific menu item. |
void |
setMetadata(Object data)
Attaches some arbitrary metadata to this menu. |
void |
setOneWayParent(Menu parent)
Sets the parent for this menu to be the specified menu but does not add this menu to the parent. |
void |
setPlayBackAPM(boolean flag)
Sets whether to play the back sound. |
void |
setPlayForwardAPM(boolean flag)
Sets whether to play the back sound. |
void |
setPlaySelectAPM(boolean flag)
Sets whether to play the back sound. |
void |
setSelectable(int index,
boolean flag)
Sets the item at the specified index as selectable or not selectable, depending on the flag. |
void |
setSelectAPM(String clip)
Sets the sound to play when the user selects a menu item having no submenu. |
void |
setSubmenu(int index,
Menu submenu)
Sets the submenu at the specified index. |
void |
setText(int index,
Object text)
Sets the text for the specified menu item. |
void |
show(Display display,
Transition t)
Shows the menu on the specified display using the specified transition. |
String |
toString()
Returns a string representation of this menu. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Menu()
public Menu(Object title)
AttributedText object or a plain string; it may also be
null.
title - the menu title, may be null
IllegalArgumentException - if the title is not valid text.| Method Detail |
|---|
public void addMenuListener(Menu.MenuListener listener)
null.
listener - the new menu listenerpublic void removeMenuListener(Menu.MenuListener listener)
null or if it has not already been added.
listener - the listener to removepublic void add(Object text)
AttributedText object or a plain string.
text - the menu text
IllegalArgumentException - if the text is not a valid type.add(Object, Image, String, MenuAction, Menu)
public void add(Object text,
Menu submenu)
AttributedText object or a plain string.
text - the menu textsubmenu - the submenu
IllegalArgumentException - if the text is not a valid type.add(Object, Image, String, MenuAction, Menu)
public void add(Object text,
Menu.MenuAction action)
text - the menu textaction - this is executed when the specified menu is selected
IllegalArgumentException - if the text is not a valid type.add(Object, Image, String, MenuAction, Menu)
public void add(Object text,
Image icon,
String audio,
Menu.MenuAction action,
Menu submenu)
null
then the item will be selectable. The text may be an
AttributedText object or a plain string.
If the submenu already has a parent, then it will be replaced with this menu.
When the menu is selected via forward, the specified action is
executed. It may be null if no action is to be executed.
text - the menu texticon - the menu icon, may be nullaudio - the item's audioaction - this is executed when the specified menu is selected, may
be nullsubmenu - the submenu, may be null
NullPointerException - if the text is null.
IllegalArgumentException - if the text is not a valid type.getParent()public void remove(int index)
index - index at which to remove the item
IndexOutOfBoundsException - if the index is out of range.getItemCount()public int getItemCount()
public void setBookmarkable(int index,
Bookmarkable b)
b is null then the item will no longer be
bookmarkable. If the item is already bookmarkable then the information
will be replaced by the given Bookmarkable parameter.
index - the item indexb - the bookmarking information, null to unset
IndexOutOfBoundsException - if the index is out of range.Bookmarkable,
BookmarkInfo,
getItemCount()public void setLastItemBookmarkable(Bookmarkable b)
b - the new bookmark informationsetBookmarkable(int, Bookmarkable),
getItemCount()
public void setAudio(int index,
String audio)
index - set the audio for the item at this indexaudio - the new audio, may be null
IndexOutOfBoundsException - if the index is out of range.getItemCount()
public void setText(int index,
Object text)
AttributedText object or a plain string.
index - set the text of the item at this indextext - the new menu text
IllegalArgumentException - if the text is not a valid type.
IndexOutOfBoundsException - if the index is out of range.getItemCount()
public void setSelectable(int index,
boolean flag)
true the item will
be set as selectable regardless if there is a submenu at that location.
On a Menu.MenuBrowseList, selectable items will be painted with a right
arrow.
index - set the selectable state of the item at this indexflag - whether the item is selectable
IndexOutOfBoundsException - if the index is out of range.getItemCount()public boolean isSelectable(int index)
setSelectable.
index - the item index
IndexOutOfBoundsException - if the index is out of range.getItemCount()
public void setIcon(int index,
Image icon)
index - set the icon for the item at this indexicon - the new icon, may be null
IndexOutOfBoundsException - if the index is out of range.getItemCount()public static void setDefaultBackAPM(String clip)
itemChanged
handler is called. However, the sound is not played if there is no
parent menu. This is set to null by default.
clip - the new default back sound clip, null
to unsetpublic static void setDefaultForwardAPM(String clip)
itemSelected and
execute handlers are called.
However, the sound is not played if there is no submenu. This is set
to null by default.
clip - the new default forward sound clip,
null to unsetpublic static void setDefaultSelectAPM(String clip)
itemSelected and
execute handlers are called.
This is set to null by default.
clip - the new default select sound clip,
null to unsetpublic void setBackAPM(String clip)
default sound. If
this is set to null then the default sound will be used.
This is set to null by default.
clip - the new back sound clip, null to unsetsetDefaultBackAPM(String)public void setForwardAPM(String clip)
default sound. If
this is set to null then the default sound will be used.
This is set to null by default.
clip - the new forward sound clip, null to
unsetsetDefaultForwardAPM(String)public void setSelectAPM(String clip)
default sound.
If this is set to null then the default sound will be
used. This is set to null by default.
clip - the new select sound clip, null to
unsetsetDefaultSelectAPM(String)public void setPlayBackAPM(boolean flag)
false then the sound
will never play. The default is true.
flag - whether to play any back soundpublic void setPlayForwardAPM(boolean flag)
false then the sound
will never play. The default is true.
flag - whether to play any back soundpublic void setPlaySelectAPM(boolean flag)
false then the sound
will never play. The default is true.
flag - whether to play any select sound
public void addAction(int index,
Menu.MenuAction action)
index - set the action for the item at this indexaction - the new action, may be null
IndexOutOfBoundsException - if the index is out of range.getItemCount()public void setOneWayParent(Menu parent)
null.
This method is useful when it is necessary to back out of a menu, say from a transient result, and not be able to navigate back.
parent - the new parent for this menupublic void setMetadata(Object data)
This can be useful, for example, when a listener object common to several menus needs to quickly determine the identity of the menu it was handed.
data - the new metadata, may be nullgetMetadata()public Object getMetadata()
null.setMetadata(Object)
public void setMetadata(int index,
Object data)
index - the item indexdata - the new metadata, may be null
IndexOutOfBoundsException - if the index is out of range.getItemCount()public Object getMetadata(int index)
index - the item index
null.
IndexOutOfBoundsException - if the index is out of range.getItemCount()public Menu getParent()
null if this menu has no
parent. A menu can have only one parent.
null if this menu has no
parent.add(Object, Image, String, MenuAction, Menu)public Menu getSubmenu(int index)
null.
index - get the submenu for the item at this index
null
if the item does not have a submenu.
IndexOutOfBoundsException - if the index is out of range.getItemCount()
public void setSubmenu(int index,
Menu submenu)
null.
index - sets the submenu at this indexsubmenu - the new submenu, may be null to remove
IndexOutOfBoundsException - if the index is out of range.getItemCount()
protected Menu.MenuBrowseList createBrowseList(Vector items,
BrowseList.Title title)
Menu.MenuBrowseList implementation, for example to paint icons
differently.
This is used by getBrowseList().
items - the itemstitle - the title
Menu.MenuBrowseList.protected BrowseList getBrowseList()
This uses createBrowseList(Vector, BrowseList.Title) to create
the browse list.
The browse list returned by this method should not be used to show the
menu, as some internal state may not get updated properly and listeners
may not get properly notified. Instead, use the
show(Display, Transition) method.
createBrowseList(Vector, BrowseList.Title),
show(Display, Transition)
protected void fireItemChanged(int oldIndex,
int newIndex,
boolean activated)
oldIndex - the old indexnewIndex - the new indexactivated - whether the menu was activatedMenu.MenuListener.itemChanged(Menu, int, int, boolean)protected void fireItemSelected(int index)
index - the item indexMenu.MenuListener.itemSelected(Menu, int)protected void fireMenuShown()
Menu.MenuListener.menuShown(Menu)public void setFocusIndex(int index)
The menu listener will be notified with an item-changed event
and with its activated parameter set to false.
index - the new index
IndexOutOfBoundsException - if the index is out of range.getItemCount(),
Menu.MenuListener.itemChanged(Menu, int, int, boolean)public int getFocusIndex()
public void show(Display display,
Transition t)
The menu listener will be notified with an item-changed event
and with its activated parameter set to true.
The notification will happen just before it is made active on the
display.
After the menu is shown on the display, a menu-shown event is sent.
display - the displayt - the transitionTransition,
Menu.MenuListener.itemChanged(Menu, int, int, boolean),
Menu.MenuListener.menuShown(Menu)
public Menu doSelect(int index,
Display display,
MediaPlayer player)
this otherwise.
index - select this menu itemdisplay - use this displayplayer - an optional media player
this if there is
no submenu.
IndexOutOfBoundsException - if the index is out of range.getItemCount(),
setForwardAPM(String)
public Menu handleMenuEvent(MenuEvent event,
Display display,
MediaPlayer player)
display and player arguments are the visual
and audio UI objects used to indicate any menu effects and changes.
This will return itself if we have not changed to a parent menu or submenu.
event - the menu eventdisplay - the display object for setting the browse listsplayer - an optional media player
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 | |||||||||