fr.inria.zvtm.widgets
Class Menu

java.lang.Object
  extended by fr.inria.zvtm.widgets.Menu

public class Menu
extends Object

Implementation of a linear menu.

Author:
R.Primet, INRIA, E.Pietriga, INRIA Chile

Field Summary
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 Summary
Menu(VirtualSpace space)
           
Menu(VirtualSpace space, Color bgColor, Color hColor, Color lColor, short labelAnchor)
           
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

width

protected double width

DEFAULT_ITEM_HEIGHT

protected static final double DEFAULT_ITEM_HEIGHT
See Also:
Constant Field Values

DEFAULT_MENU_BGCOLOR

protected static final Color DEFAULT_MENU_BGCOLOR

DEFAULT_MENU_HCOLOR

protected static final Color DEFAULT_MENU_HCOLOR

DEFAULT_MENU_LBCOLOR

protected static final Color DEFAULT_MENU_LBCOLOR

MENU_BGCOLOR

protected Color MENU_BGCOLOR

MENU_HCOLOR

protected Color MENU_HCOLOR

MENU_LBCOLOR

protected Color MENU_LBCOLOR

LABEL_ANCHOR

protected short LABEL_ANCHOR

MENU_BOX_TYPE

protected static final String MENU_BOX_TYPE
See Also:
Constant Field Values

space

protected final VirtualSpace space

elems

protected final List<Glyph> elems
Constructor Detail

Menu

public Menu(VirtualSpace space)

Menu

public Menu(VirtualSpace space,
            Color bgColor,
            Color hColor,
            Color lColor,
            short labelAnchor)
Parameters:
space - VirtualSpace in which to instantiate the menu
bgColor - background color of menu item boxes
highlight - color of menu item boxes (when cursor inside)
lColor - menu item label color
label - alignment (one of VText.TEXT_ANCHOR_*)
Method Detail

show

public void show()
Shows the menu


hide

public void hide()
Hides the menu


clear

public void clear()
Clears the menu


getWidth

public double getWidth()
Returns the width of the menu, in virtual space units.


setWidth

public void setWidth(double width)
Sets the width of the menu.

Parameters:
width - new width of the menu, in virtualspace units
Throws:
IllegalArgumentException - if width is less than or equal to 0.

makeLabel

protected VText makeLabel(MenuItem item,
                          double xpos,
                          double ypos)
Override this method if you need to customize menu labels (e.g. set color...)


populate

public void populate(List<MenuItem> items,
                     Point2D.Double coords)
Builds a menu from the given items.

Parameters:
coords - coordinates of the topmost menu item, in virtual space units.

getItemForGlyph

public MenuItem getItemForGlyph(Glyph glyph)
Returns the MenuItem associated to a given Glyph, if there is such an item.

Returns:
the MenuItem associated to the given Glyph, or null if there is no such item.

onEnterGlyph

public void onEnterGlyph(Glyph g)
Should be called from outside to highlight the menu items if needed.


onExitGlyph

public void onExitGlyph(Glyph g)
Should be called from outside to highlight the menu items if needed.



Copyright © 2000-2002 Xerox Corporation. All Rights Reserved
Copyright © 2003 World Wide Web Consortium. All Rights Reserved
Copyright © 2004-2011 INRIA. All Rights Reserved
Licensed under the GNU LGPL. For full terms see the file COPYING.