public class Menu extends Object
Modifier and Type | Field and Description |
---|---|
protected static double |
DEFAULT_ITEM_HEIGHT |
protected static Color |
DEFAULT_MENU_BGCOLOR |
protected static Color |
DEFAULT_MENU_HCOLOR |
protected static Color |
DEFAULT_MENU_LBCOLOR |
protected List<Glyph> |
elems |
protected short |
LABEL_ANCHOR |
protected Color |
MENU_BGCOLOR |
protected static String |
MENU_BOX_TYPE |
protected Color |
MENU_HCOLOR |
protected Color |
MENU_LBCOLOR |
protected VirtualSpace |
space |
protected double |
width |
Constructor and Description |
---|
Menu(VirtualSpace space) |
Menu(VirtualSpace space,
Color bgColor,
Color hColor,
Color lColor,
short labelAnchor) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the menu
|
MenuItem |
getItemForGlyph(Glyph glyph)
Returns the MenuItem associated to a given Glyph, if
there is such an item.
|
double |
getWidth()
Returns the width of the menu, in virtual space units.
|
void |
hide()
Hides the menu
|
protected VText |
makeLabel(MenuItem item,
double xpos,
double ypos)
Override this method if you need to customize menu labels
(e.g.
|
void |
onEnterGlyph(Glyph g)
Should be called from outside to highlight the menu items
if needed.
|
void |
onExitGlyph(Glyph g)
Should be called from outside to highlight the menu items
if needed.
|
void |
populate(List<MenuItem> items,
Point2D.Double coords)
Builds a menu from the given items.
|
void |
setWidth(double width)
Sets the width of the menu.
|
void |
show()
Shows the menu
|
protected double width
protected static final double DEFAULT_ITEM_HEIGHT
protected static final Color DEFAULT_MENU_BGCOLOR
protected static final Color DEFAULT_MENU_HCOLOR
protected static final Color DEFAULT_MENU_LBCOLOR
protected Color MENU_BGCOLOR
protected Color MENU_HCOLOR
protected Color MENU_LBCOLOR
protected short LABEL_ANCHOR
protected static final String MENU_BOX_TYPE
protected final VirtualSpace space
public Menu(VirtualSpace space)
public Menu(VirtualSpace space, Color bgColor, Color hColor, Color lColor, short labelAnchor)
space
- VirtualSpace in which to instantiate the menubgColor
- background color of menu item boxeshColor
- color of menu item boxes (when cursor inside)lColor
- menu item label colorlabelAnchor
- alignment (one of VText.TEXT_ANCHOR_*)public void show()
public void hide()
public void clear()
public double getWidth()
public void setWidth(double width)
width
- new width of the menu, in virtualspace unitsIllegalArgumentException
- if width
is less than or equal to 0.protected VText makeLabel(MenuItem item, double xpos, double ypos)
public void populate(List<MenuItem> items, Point2D.Double coords)
coords
- coordinates of the topmost menu item, in virtual space units.public MenuItem getItemForGlyph(Glyph glyph)
public void onEnterGlyph(Glyph g)
public void onExitGlyph(Glyph g)
Copyright © 2000-2002 Xerox Corporation. All Rights Reserved
Copyright © 2003 World Wide Web Consortium. All Rights Reserved
Copyright © 2004-2015 INRIA. All Rights Reserved
Licensed under the GNU LGPL. For full terms see the file COPYING.