com.java4less.rmenu
Class RMenu
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--java.awt.Panel
|
+--com.java4less.rmenu.RMenu
- All Implemented Interfaces:
- javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable
- public class RMenu
- extends java.awt.Panel
- implements java.lang.Runnable
Warning: This documentation is only for java programmers. If you are just using the Applet in a HTML page, please read Class RMenuApplet.
The RMenu is a subclass of Panel. Therefore you can add it to any container in your java application. In order to create a menu you must follow these steps:
1. Create menu and add it to a container.
2. Create nodes and add them to the menu You can:
2.1 add a node to the first level with the method addFirstLevelNode().
2.2 or add the node to another node.
3. You can also read the definition of the menu from a file like this: menu.createTreeFromFile(tree.Root,). See documention of the applet for details Class RMenuApplet about the parameters in the file.
4. Start the menu. The menuimplements the Runnable interface in other to be able to run the initial animation, for this reason you must start it like this: new Thread(menu).start();
- See Also:
- Serialized Form
Field Summary |
static int |
ALIGN_CENTER
|
static int |
ALIGN_LEFT
|
static int |
ALIGN_RIGHT
|
java.awt.Color |
backColor
background color of the menu. |
java.awt.Color |
backColor2
|
java.awt.Image |
backImage
background image |
boolean |
changeCursor
|
boolean |
collapse_on_exit
|
java.lang.String |
defaultTarget
Target frame where URL should be openned after double-clicking a node. |
static int |
EXPAND_ON_CLICK
expand nodes when the user clicks on them. |
static int |
EXPAND_ON_ENTER
expand nodes when the mouse enters them. |
int |
expandOn
specifies how the nodes are going to be expanded. |
java.awt.Image |
hSeparator
separator of items in a horizontal menu. |
int |
iconsWidth
Width of the icons. |
int |
itemHeight
Height of the items in the menu. |
int |
itemWidth
Width of the items in the menu. |
java.lang.String |
JSOnDblClick
name of javascript function to call on events "double click" |
java.lang.String |
JSOnEnter
name of javascript function to call on events "enter" |
java.lang.String |
JSOnExit
name of javascript function to call on events "exit" |
java.lang.String |
JSOnExpand
name of javascript function to call on events "expand" |
java.lang.String |
JSOnLoad
name of javascript function to call on events "load" |
java.lang.String |
JSOnLoadEnd
name of javascript function to call on events "load end" |
java.lang.String |
JSOnSelect
name of javascript function to call on events "select" |
int |
leftMargin
left margin of the menu. |
int |
levelTab
|
java.awt.Font |
loadingFont
font of the text displayed to the user while definition files or applet parameters are read. |
java.awt.Image |
loadingImage
Image to be displayed while definition files or applet parameters are read. |
java.lang.String |
loadingText
this text will be shown to the user while definition files or applet parameters are read. |
static int |
MENU_DEFINED
|
static int |
MENU_HORIZONTAL
|
static int |
MENU_VERTICAL
|
int |
menuAlignment
how items are going to be aligned on a horizontal menu. |
int |
menuInternalMargin
space between the border of the menu and the items. |
int |
menuType
Type of menu: MENU_VERTICAL, MENU_HORIZONTAL (see menuAligment ) and MENU_DEFINED (see userDefinedX and userDefinedY). |
java.lang.String |
openingURLText
Text to be displyed while openning an URL. |
java.applet.Applet |
parentApplet
Applet (if any) in which the menu is placed. |
RNode |
Root
root of the menu. |
java.awt.Cursor |
selCursor
cursor for selected node |
boolean |
showRoot
show root of tree |
boolean |
showTip
If false, no tips will be displayed. |
java.awt.Image |
subMenuIcon
|
java.awt.Color |
tipBack
background of the box used to displayed tips. |
java.awt.Color |
tipBorder
color of the border of the box used to displayed tips. |
java.awt.Color |
tipColor
color of the font. |
int |
tipDelay
specifies the number of milliseconds the tree will wait before showing a tip for the current node. |
java.awt.Font |
tipFont
Font used to display tips. |
int |
topMargin
top margin of the menu. |
int[] |
userDefinedX
x coordinates of the items for a menu of type DEFINED. |
int[] |
userDefinedY
y coordinates of the items for a menu of type DEFINED. |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary |
RMenu()
|
Method Summary |
void |
addFirstLevelNode(RNode n)
adds the node to the root. |
void |
clear(RNode n)
deletes the children of the node. |
java.awt.Color |
convertColor(java.lang.String c)
converts a color parameter (as string) to a color class. |
java.awt.Font |
convertFont(java.lang.String f)
converts a font parameter (as string) to a Font class. |
int |
countNodesToDraw(RNode n)
number of visible nodes |
void |
createTreeFromFile(RNode startNode,
java.lang.String sFile)
processes the file sfile. |
void |
createTreeFromParameters(java.applet.Applet pApplet)
create the menu using the parameters of the applet. |
void |
drawNode(java.awt.Graphics g,
RNode n,
int level,
boolean redrawChildren)
|
void |
expandNode(java.lang.String Name,
boolean expand)
Expands or collapses a node. |
RNode |
findNode(RNode n,
java.lang.String Name)
find a node by name |
java.awt.Image |
loadImageUrl(java.lang.String urlAdd)
load an image resource |
void |
paint(java.awt.Graphics g)
|
void |
paintMenu(java.awt.Graphics g,
RNode n,
int nx,
int ny)
|
void |
processParameter(RNode currentNode,
java.lang.String ParamName,
java.lang.String ParamValue)
process a parameter. |
void |
refresh()
repaints the menu. |
void |
run()
thread's entry point |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
backImage
public java.awt.Image backImage
- background image
EXPAND_ON_CLICK
public static final int EXPAND_ON_CLICK
- expand nodes when the user clicks on them.
EXPAND_ON_ENTER
public static final int EXPAND_ON_ENTER
- expand nodes when the mouse enters them.
expandOn
public int expandOn
- specifies how the nodes are going to be expanded. Valid values are EXPAND_ON_CLICK or EXPAND_ON_ENTER.
MENU_VERTICAL
public static final int MENU_VERTICAL
MENU_HORIZONTAL
public static final int MENU_HORIZONTAL
MENU_DEFINED
public static final int MENU_DEFINED
collapse_on_exit
public boolean collapse_on_exit
menuType
public int menuType
- Type of menu: MENU_VERTICAL, MENU_HORIZONTAL (see menuAligment ) and MENU_DEFINED (see userDefinedX and userDefinedY). In MENU_DEFINED the user must specify the location of the items in the applet.
userDefinedX
public int[] userDefinedX
- x coordinates of the items for a menu of type DEFINED.
userDefinedY
public int[] userDefinedY
- y coordinates of the items for a menu of type DEFINED.
hSeparator
public java.awt.Image hSeparator
- separator of items in a horizontal menu.
menuInternalMargin
public int menuInternalMargin
- space between the border of the menu and the items. The default value is 1 pixel.
ALIGN_LEFT
public static final int ALIGN_LEFT
ALIGN_RIGHT
public static final int ALIGN_RIGHT
ALIGN_CENTER
public static final int ALIGN_CENTER
menuAlignment
public int menuAlignment
- how items are going to be aligned on a horizontal menu. (ALIGN_LEFT, ALIGN_RIGHT or ALIGN_CENTER).
tipDelay
public int tipDelay
- specifies the number of milliseconds the tree will wait before showing a tip for the current node.
loadingText
public java.lang.String loadingText
- this text will be shown to the user while definition files or applet parameters are read.
openingURLText
public java.lang.String openingURLText
- Text to be displyed while openning an URL.
backColor
public java.awt.Color backColor
- background color of the menu.
backColor2
public java.awt.Color backColor2
iconsWidth
public int iconsWidth
- Width of the icons. The default value is 16.
loadingImage
public java.awt.Image loadingImage
- Image to be displayed while definition files or applet parameters are read.
loadingFont
public java.awt.Font loadingFont
- font of the text displayed to the user while definition files or applet parameters are read.
subMenuIcon
public java.awt.Image subMenuIcon
changeCursor
public boolean changeCursor
selCursor
public java.awt.Cursor selCursor
- cursor for selected node
showTip
public boolean showTip
- If false, no tips will be displayed.
tipFont
public java.awt.Font tipFont
- Font used to display tips.
tipColor
public java.awt.Color tipColor
- color of the font.
tipBorder
public java.awt.Color tipBorder
- color of the border of the box used to displayed tips.
tipBack
public java.awt.Color tipBack
- background of the box used to displayed tips.
Root
public RNode Root
- root of the menu. Menus always have a root but it is hidden.
showRoot
public boolean showRoot
- show root of tree
levelTab
public int levelTab
leftMargin
public int leftMargin
- left margin of the menu.
topMargin
public int topMargin
- top margin of the menu.
parentApplet
public java.applet.Applet parentApplet
- Applet (if any) in which the menu is placed. This is used to read the applet's parameters.
defaultTarget
public java.lang.String defaultTarget
- Target frame where URL should be openned after double-clicking a node. Valid values are:
"_self" show in the current frame
"_parent" show in the parent frame
"_top" show in the topmost frame
"_blank" show in a new unnamed top-level window
name show in a new top-level window named name
itemHeight
public int itemHeight
- Height of the items in the menu. The default is 20.
itemWidth
public int itemWidth
- Width of the items in the menu. The default is 100.
JSOnEnter
public java.lang.String JSOnEnter
- name of javascript function to call on events "enter"
JSOnExit
public java.lang.String JSOnExit
- name of javascript function to call on events "exit"
JSOnLoad
public java.lang.String JSOnLoad
- name of javascript function to call on events "load"
JSOnLoadEnd
public java.lang.String JSOnLoadEnd
- name of javascript function to call on events "load end"
JSOnExpand
public java.lang.String JSOnExpand
- name of javascript function to call on events "expand"
JSOnSelect
public java.lang.String JSOnSelect
- name of javascript function to call on events "select"
JSOnDblClick
public java.lang.String JSOnDblClick
- name of javascript function to call on events "double click"
RMenu
public RMenu()
addFirstLevelNode
public void addFirstLevelNode(RNode n)
- adds the node to the root.
paintMenu
public void paintMenu(java.awt.Graphics g,
RNode n,
int nx,
int ny)
run
public void run()
- thread's entry point
- Specified by:
run
in interface java.lang.Runnable
paint
public void paint(java.awt.Graphics g)
- Overrides:
paint
in class java.awt.Container
countNodesToDraw
public int countNodesToDraw(RNode n)
- number of visible nodes
expandNode
public void expandNode(java.lang.String Name,
boolean expand)
- Expands or collapses a node.
refresh
public void refresh()
- repaints the menu.
clear
public void clear(RNode n)
- deletes the children of the node.
findNode
public RNode findNode(RNode n,
java.lang.String Name)
- find a node by name
loadImageUrl
public java.awt.Image loadImageUrl(java.lang.String urlAdd)
- load an image resource
convertColor
public java.awt.Color convertColor(java.lang.String c)
- converts a color parameter (as string) to a color class.
convertFont
public java.awt.Font convertFont(java.lang.String f)
- converts a font parameter (as string) to a Font class.
createTreeFromFile
public void createTreeFromFile(RNode startNode,
java.lang.String sFile)
- processes the file sfile. The nodes will be added as children of startNode.
createTreeFromParameters
public void createTreeFromParameters(java.applet.Applet pApplet)
- create the menu using the parameters of the applet.
processParameter
public void processParameter(RNode currentNode,
java.lang.String ParamName,
java.lang.String ParamValue)
- process a parameter. This method ís used to provide access to paramters from javascript.
drawNode
public void drawNode(java.awt.Graphics g,
RNode n,
int level,
boolean redrawChildren)