com.alee.extended.menu
Class WebDynamicMenu

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.alee.laf.panel.WebPanel
                      extended by com.alee.utils.swing.WebHeavyWeightPopup
                          extended by com.alee.extended.menu.WebDynamicMenu
All Implemented Interfaces:
PartialDecoration, LanguageContainerMethods, ToolTipMethods, ShapeProvider, Styleable, EventMethods, SizeMethods<WebPanel>, SwingMethods, WindowMethods<javax.swing.JWindow>, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class WebDynamicMenu
extends WebHeavyWeightPopup

Custom dynamic menu with pretty display/hide animations.

Author:
Mikle Garin
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  double angleRange
          Angle which is available for menu elements.
protected  boolean clockwise
          Menu animation direction.
protected  GlobalFocusListener focusListener
          Custom global focus listener that closes menu.
protected  WindowFollowAdapter followAdapter
          Invoker window follow adapter.
protected  DynamicMenuType hideType
          Menu hide animation type.
protected  int hidingCause
          Index of menu item that caused menu to close.
protected  java.util.List<WebDynamicMenuItem> items
          Menu items list.
protected  java.awt.event.AWTEventListener mouseListener
          Custom global mouse listener that closes menu.
protected  int radius
          Radius of the menu background in px.
protected  double startingAngle
          First element position angle in degrees.
protected  DynamicMenuType type
          Menu animation type.
 
Fields inherited from class com.alee.utils.swing.WebHeavyWeightPopup
alwaysOnTop, animate, closeOnOuterAction, displaying, displayProgress, followInvoker, hideAnimator, hiding, invoker, invokerWindow, listeners, lsync, onFullDisplay, onFullHide, opacity, opaque, popup, showAnimator, stepProgress, sync, window
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
WebDynamicMenu()
          Constructs new dynamic menu.
 
Method Summary
 WebDynamicMenuItem addItem(javax.swing.ImageIcon icon)
           
 WebDynamicMenuItem addItem(javax.swing.ImageIcon icon, java.awt.event.ActionListener action)
           
 WebDynamicMenuItem addItem(WebDynamicMenuItem menuItem)
           
 DynamicMenuLayout getActualLayout()
          Returns actual menu layout manager.
 double getAngleRange()
           
 DynamicMenuType getHideType()
           
 int getHidingCause()
          Returns index of menu item that caused menu to close.
 double getItemAngle(java.awt.Component item)
          Returns menu item angle relative to vertical axis.
 double getItemAngle(int index)
          Returns menu item angle relative to vertical axis.
 java.util.List<WebDynamicMenuItem> getItems()
           
 int getRadius()
           
 double getStartingAngle()
           
 DynamicMenuType getType()
           
static void hideAllDynamicMenus()
          Hides all visible dynamic menus.
protected  void hideAnimationStepPerformed()
          Called with each hide animation step performed.
 void hideMenu()
          Hides dynamic menu.
 void hideMenu(int index)
          Hides dynamic menu.
 WebHeavyWeightPopup hidePopup()
          Hides popup window.
static boolean isAnyDynamicMenuDisplayed()
          Returns whether any dynamic menu is currently displayed or not.
 boolean isClockwise()
           
 void setAngleRange(double angleRange)
           
 void setClockwise(boolean clockwise)
           
 void setHideType(DynamicMenuType hideType)
           
 void setRadius(int radius)
           
 void setStartingAngle(double startingAngle)
           
 void setType(DynamicMenuType type)
           
protected  void showAnimationStepPerformed()
          Called with each show animation step performed.
 void showMenu(java.awt.Component invoker, int x, int y)
          Displays dynamic menu for the specified invoker location.
 void showMenu(java.awt.Component invoker, java.awt.Point location)
          Displays dynamic menu for the specified invoker location.
 WebDynamicMenu showPopup(java.awt.Component invoker, int x, int y)
          Shows popup window.
 
Methods inherited from class com.alee.utils.swing.WebHeavyWeightPopup
addPopupListener, center, center, center, center, completePopupHide, firePopupClosed, firePopupOpened, firePopupWillBeClosed, firePopupWillBeOpened, fullyDisplayed, fullyHidden, getDisplayProgress, getInvoker, getInvokerWindow, getPopup, getStepProgress, getWindow, getWindowOpacity, hidePopupImpl, installFollowAdapter, isAlwaysOnTop, isAnimate, isCloseOnOuterAction, isDisplaying, isFollowInvoker, isHiding, isWindowOpaque, onFullDisplay, onFullHide, packAndCenter, packAndCenter, packToHeight, packToWidth, removePopupListener, setAlwaysOnTop, setAnimate, setCloseOnOuterAction, setFollowInvoker, setStepProgress, setWindowOpacity, setWindowOpaque, showPopup, showPopupImpl, uninstallFollowAdapter, updateOpacity, updateOpaque
 
Methods inherited from class com.alee.laf.panel.WebPanel
add, add, add, add, add, add, addToolTip, addToolTip, addToolTip, addToolTip, addToolTip, addToolTip, addToolTip, addToolTip, addToolTip, addToolTip, contains, getBorderColor, getBorderStroke, getDisabledBorderColor, getFirstComponent, getLanguageContainerKey, getLastComponent, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getPainter, getPreferredHeight, getPreferredSize, getPreferredWidth, getRound, getShadeTransparency, getShadeWidth, getStyleId, getWebUI, isPaintBackground, isPaintBottom, isPaintBottomLine, isPaintFocus, isPaintLeft, isPaintLeftLine, isPaintRight, isPaintRightLine, isPaintTop, isPaintTopLine, isUndecorated, isWebColoredBackground, onDoubleClick, onFocusGain, onFocusLoss, onKeyPress, onKeyPress, onKeyRelease, onKeyRelease, onKeyType, onKeyType, onMenuTrigger, onMouseClick, onMouseClick, onMouseDrag, onMouseDrag, onMouseEnter, onMouseExit, onMousePress, onMousePress, provideShape, remove, remove, removeAll, removeLanguageContainerKey, removeToolTip, removeToolTips, removeToolTips, removeToolTips, setBorderColor, setBorderStroke, setDisabledBorderColor, setLanguageContainerKey, setMargin, setMargin, setMargin, setMaximumHeight, setMaximumWidth, setMinimumHeight, setMinimumWidth, setPaintBackground, setPaintBottom, setPaintBottomLine, setPainter, setPaintFocus, setPaintLeft, setPaintLeftLine, setPaintRight, setPaintRightLine, setPaintSideLines, setPaintSides, setPaintTop, setPaintTopLine, setPreferredHeight, setPreferredSize, setPreferredWidth, setRound, setShadeTransparency, setShadeWidth, setStyleId, setToolTip, setToolTip, setToolTip, setToolTip, setToolTip, setToolTip, setToolTip, setToolTip, setToolTip, setToolTip, setUndecorated, setWebColoredBackground, updateUI
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

radius

protected int radius
Radius of the menu background in px.


startingAngle

protected double startingAngle
First element position angle in degrees. Counted from the circle top-most point.


angleRange

protected double angleRange
Angle which is available for menu elements. It is 360 degress by default (whole circle available).


type

protected DynamicMenuType type
Menu animation type.


hideType

protected DynamicMenuType hideType
Menu hide animation type.


clockwise

protected boolean clockwise
Menu animation direction.


items

protected java.util.List<WebDynamicMenuItem> items
Menu items list.


followAdapter

protected WindowFollowAdapter followAdapter
Invoker window follow adapter.


hidingCause

protected int hidingCause
Index of menu item that caused menu to close. This might affect the hiding animation.


mouseListener

protected java.awt.event.AWTEventListener mouseListener
Custom global mouse listener that closes menu.


focusListener

protected GlobalFocusListener focusListener
Custom global focus listener that closes menu.

Constructor Detail

WebDynamicMenu

public WebDynamicMenu()
Constructs new dynamic menu.

Method Detail

getRadius

public int getRadius()

setRadius

public void setRadius(int radius)

getStartingAngle

public double getStartingAngle()

setStartingAngle

public void setStartingAngle(double startingAngle)

getAngleRange

public double getAngleRange()

setAngleRange

public void setAngleRange(double angleRange)

getType

public DynamicMenuType getType()

setType

public void setType(DynamicMenuType type)

getHideType

public DynamicMenuType getHideType()

setHideType

public void setHideType(DynamicMenuType hideType)

isClockwise

public boolean isClockwise()

setClockwise

public void setClockwise(boolean clockwise)

getItems

public java.util.List<WebDynamicMenuItem> getItems()

addItem

public WebDynamicMenuItem addItem(javax.swing.ImageIcon icon)

addItem

public WebDynamicMenuItem addItem(javax.swing.ImageIcon icon,
                                  java.awt.event.ActionListener action)

addItem

public WebDynamicMenuItem addItem(WebDynamicMenuItem menuItem)

getHidingCause

public int getHidingCause()
Returns index of menu item that caused menu to close.

Returns:
index of menu item that caused menu to close

showPopup

public WebDynamicMenu showPopup(java.awt.Component invoker,
                                int x,
                                int y)
Shows popup window. Depending on settings it might take a while to animate the show action.

Overrides:
showPopup in class WebHeavyWeightPopup
Parameters:
invoker - invoker component
x - popup X coordinate relative to invoker
y - popup Y coordinate relative to invoker
Returns:
this popup

showMenu

public void showMenu(java.awt.Component invoker,
                     java.awt.Point location)
Displays dynamic menu for the specified invoker location.

Parameters:
invoker - menu invoker
location - menu location

showMenu

public void showMenu(java.awt.Component invoker,
                     int x,
                     int y)
Displays dynamic menu for the specified invoker location.

Parameters:
invoker - menu invoker
x - menu location X coordinate
y - menu location Y coordinate

showAnimationStepPerformed

protected void showAnimationStepPerformed()
Called with each show animation step performed. This method is a placeholder for overriding classes.

Overrides:
showAnimationStepPerformed in class WebHeavyWeightPopup

hidePopup

public WebHeavyWeightPopup hidePopup()
Hides popup window. Depending on settings it might take a while to animate the hide action.

Overrides:
hidePopup in class WebHeavyWeightPopup
Returns:
this popup

hideMenu

public void hideMenu()
Hides dynamic menu.


hideMenu

public void hideMenu(int index)
Hides dynamic menu.

Parameters:
index - menu item that forced menu to hide

hideAnimationStepPerformed

protected void hideAnimationStepPerformed()
Called with each hide animation step performed. This method is a placeholder for overriding classes.

Overrides:
hideAnimationStepPerformed in class WebHeavyWeightPopup

getItemAngle

public double getItemAngle(java.awt.Component item)
Returns menu item angle relative to vertical axis.

Parameters:
item - menu item
Returns:
menu item center point angle

getItemAngle

public double getItemAngle(int index)
Returns menu item angle relative to vertical axis.

Parameters:
index - menu item index
Returns:
menu item center point angle

getActualLayout

public DynamicMenuLayout getActualLayout()
Returns actual menu layout manager.

Returns:
actual menu layout manager

isAnyDynamicMenuDisplayed

public static boolean isAnyDynamicMenuDisplayed()
Returns whether any dynamic menu is currently displayed or not.

Returns:
true if any dynamic menu is currently displayed, false otherwise

hideAllDynamicMenus

public static void hideAllDynamicMenus()
Hides all visible dynamic menus.