com.alee.laf.menu
Class WebPopupMenuUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.PopupMenuUI
          extended by javax.swing.plaf.basic.BasicPopupMenuUI
              extended by com.alee.laf.menu.WebPopupMenuUI
All Implemented Interfaces:
ShapeProvider, Styleable, BorderMethods, SwingMethods, javax.swing.SwingConstants

public class WebPopupMenuUI
extends javax.swing.plaf.basic.BasicPopupMenuUI
implements javax.swing.SwingConstants, Styleable, ShapeProvider, BorderMethods

Custom UI for JPopupMenu component.

Author:
Mikle Garin

Field Summary
protected  boolean fixLocation
           
protected  java.beans.PropertyChangeListener jdkSevenFixListener
           
protected  java.awt.Insets margin
          UI style settings.
protected  int menuSpacing
           
protected  java.beans.PropertyChangeListener orientationChangeListener
           
protected  PopupMenuPainter painter
          Component painter.
protected  java.beans.PropertyChangeListener popupMenuTypeUpdater
          Menu listeners.
protected  PopupMenuWay popupMenuWay
           
protected  java.lang.String styleId
          Runtime variables.
protected  boolean transparent
           
protected  java.beans.PropertyChangeListener visibilityChangeListener
           
 
Fields inherited from class javax.swing.plaf.basic.BasicPopupMenuUI
popupMenu
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
WebPopupMenuUI()
           
 
Method Summary
protected  void applyPainterSettings(PopupMenuPainter painter)
          Applies UI settings to this specific painter.
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
          Returns an instance of the WebPopupMenuUI for the specified component.
 java.awt.Color getBorderColor()
          Returns popup border color.
 int getCornerAlignment()
          Returns dropdown corner alignment.
 int getCornerWidth()
          Returns popup dropdown style corner width.
 java.awt.Insets getMargin()
          Returns popup menu content margin.
 int getMenuSpacing()
          Returns spacing between menubar popup menus.
 Painter getPainter()
          Returns popup menu painter.
 javax.swing.Popup getPopup(javax.swing.JPopupMenu popup, int x, int y)
          Returns the Popup that will be responsible for displaying the JPopupMenu.
 PopupStyle getPopupStyle()
          Returns popup style.
 int getRound()
          Returns decoration corners rounding.
 float getShadeTransparency()
          Returns popup shade transparency.
 int getShadeWidth()
          Returns decoration shade width.
 java.lang.String getStyleId()
          Returns component style ID.
 float getTransparency()
          Returns popup background transparency.
 void installUI(javax.swing.JComponent c)
          Installs UI in the specified component.
 boolean isFixLocation()
          Returns whether popup menu should try to fix its initial location when displayed or not.
 void paint(java.awt.Graphics g, javax.swing.JComponent c)
          Paints popup menu decorations.
 java.awt.Shape provideShape()
          Returns component shape.
 void setBorderColor(java.awt.Color color)
          Sets popup border color.
 void setCornerAlignment(int cornerAlignment)
          Sets dropdown corner alignment.
 void setCornerWidth(int width)
          Sets popup dropdown style corner width.
 void setFixLocation(boolean fix)
          Sets whether popup menu should try to fix its initial location when displayed or not.
 void setMargin(java.awt.Insets margin)
          Sets popup menu content margin.
 void setMenuSpacing(int spacing)
          Sets spacing between menubar popup menus.
 void setPainter(Painter painter)
          Sets popup menu painter.
 void setPopupMenuWay(PopupMenuWay way)
          Assists popup menu to allow it choose the best position relative to invoker.
 void setPopupStyle(PopupStyle style)
          Sets popup style.
 void setRound(int round)
          Sets decoration corners rounding.
 void setShadeTransparency(float opacity)
          Sets popup shade transparency.
 void setShadeWidth(int shadeWidth)
          Sets decoration shade width.
 void setStyleId(java.lang.String id)
          Sets custom component style ID.
 void setTransparency(float transparency)
          Sets popup background transparency.
 void uninstallUI(javax.swing.JComponent c)
          Uninstalls UI from the specified component.
 void updateBorder()
          Updates custom WebLaF border.
 
Methods inherited from class javax.swing.plaf.basic.BasicPopupMenuUI
installDefaults, installKeyboardActions, installListeners, isPopupTrigger, uninstallDefaults, uninstallKeyboardActions, uninstallListeners
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

margin

protected java.awt.Insets margin
UI style settings.


menuSpacing

protected int menuSpacing

fixLocation

protected boolean fixLocation

painter

protected PopupMenuPainter painter
Component painter.


popupMenuTypeUpdater

protected java.beans.PropertyChangeListener popupMenuTypeUpdater
Menu listeners.


orientationChangeListener

protected java.beans.PropertyChangeListener orientationChangeListener

visibilityChangeListener

protected java.beans.PropertyChangeListener visibilityChangeListener

jdkSevenFixListener

protected java.beans.PropertyChangeListener jdkSevenFixListener

styleId

protected java.lang.String styleId
Runtime variables.


transparent

protected boolean transparent

popupMenuWay

protected PopupMenuWay popupMenuWay
Constructor Detail

WebPopupMenuUI

public WebPopupMenuUI()
Method Detail

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
Returns an instance of the WebPopupMenuUI for the specified component. This tricky method is used by UIManager to create component UIs when needed.

Parameters:
c - component that will use UI instance
Returns:
instance of the WebPopupMenuUI

installUI

public void installUI(javax.swing.JComponent c)
Installs UI in the specified component.

Overrides:
installUI in class javax.swing.plaf.basic.BasicPopupMenuUI
Parameters:
c - component for this UI

uninstallUI

public void uninstallUI(javax.swing.JComponent c)
Uninstalls UI from the specified component.

Overrides:
uninstallUI in class javax.swing.plaf.basic.BasicPopupMenuUI
Parameters:
c - component with this UI

getStyleId

public java.lang.String getStyleId()
Returns component style ID. Custom ID can be specified to override default component style using "setStyleId" method. If style for such custom ID is not found in skin descriptor then default style for that component is used.

Specified by:
getStyleId in interface Styleable
Returns:
component style ID

setStyleId

public void setStyleId(java.lang.String id)
Sets custom component style ID. If style for such custom ID is not found in skin descriptor default style will be used for that component. This method forces component to instantly use component style with the specified ID.

Specified by:
setStyleId in interface Styleable
Parameters:
id - custom component style ID

provideShape

public java.awt.Shape provideShape()
Returns component shape.

Specified by:
provideShape in interface ShapeProvider
Returns:
component shape

updateBorder

public void updateBorder()
Updates custom WebLaF border.

Specified by:
updateBorder in interface BorderMethods

getMargin

public java.awt.Insets getMargin()
Returns popup menu content margin.

Returns:
popup menu content margin

setMargin

public void setMargin(java.awt.Insets margin)
Sets popup menu content margin.

Parameters:
margin - new popup menu content margin

getMenuSpacing

public int getMenuSpacing()
Returns spacing between menubar popup menus.

Returns:
spacing between menubar popup menus

setMenuSpacing

public void setMenuSpacing(int spacing)
Sets spacing between menubar popup menus.

Parameters:
spacing - new spacing between menubar popup menus

isFixLocation

public boolean isFixLocation()
Returns whether popup menu should try to fix its initial location when displayed or not.

Returns:
true if popup menu should try to fix its initial location when displayed, false otherwise

setFixLocation

public void setFixLocation(boolean fix)
Sets whether popup menu should try to fix its initial location when displayed or not.

Parameters:
fix - whether popup menu should try to fix its initial location when displayed or not

setPopupMenuWay

public void setPopupMenuWay(PopupMenuWay way)
Assists popup menu to allow it choose the best position relative to invoker. Its value nullified right after first usage to avoid popup menu display issues in future.

Parameters:
way - approximate popup menu display way

getPopupStyle

public PopupStyle getPopupStyle()
Returns popup style.

Returns:
popup style

setPopupStyle

public void setPopupStyle(PopupStyle style)
Sets popup style.

Parameters:
style - new popup style

getBorderColor

public java.awt.Color getBorderColor()
Returns popup border color.

Returns:
popup border color

setBorderColor

public void setBorderColor(java.awt.Color color)
Sets popup border color.

Parameters:
color - new popup border color

getRound

public int getRound()
Returns decoration corners rounding.

Returns:
decoration corners rounding

setRound

public void setRound(int round)
Sets decoration corners rounding.

Parameters:
round - decoration corners rounding

getShadeWidth

public int getShadeWidth()
Returns decoration shade width.

Returns:
decoration shade width

setShadeWidth

public void setShadeWidth(int shadeWidth)
Sets decoration shade width.

Parameters:
shadeWidth - decoration shade width

getShadeTransparency

public float getShadeTransparency()
Returns popup shade transparency.

Returns:
popup shade transparency

setShadeTransparency

public void setShadeTransparency(float opacity)
Sets popup shade transparency.

Parameters:
opacity - new popup shade transparency

getCornerWidth

public int getCornerWidth()
Returns popup dropdown style corner width.

Returns:
popup dropdown style corner width

setCornerWidth

public void setCornerWidth(int width)
Sets popup dropdown style corner width.

Parameters:
width - popup dropdown style corner width

getCornerAlignment

public int getCornerAlignment()
Returns dropdown corner alignment.

Returns:
dropdown corner alignment

setCornerAlignment

public void setCornerAlignment(int cornerAlignment)
Sets dropdown corner alignment.

Parameters:
cornerAlignment - dropdown corner alignment

getTransparency

public float getTransparency()
Returns popup background transparency.

Returns:
popup background transparency

setTransparency

public void setTransparency(float transparency)
Sets popup background transparency.

Parameters:
transparency - popup background transparency

getPainter

public Painter getPainter()
Returns popup menu painter.

Returns:
popup menu painter

setPainter

public void setPainter(Painter painter)
Sets popup menu painter. Pass null to remove popup menu painter.

Parameters:
painter - new popup menu painter

applyPainterSettings

protected void applyPainterSettings(PopupMenuPainter painter)
Applies UI settings to this specific painter.

Parameters:
painter - popup menu painter

getPopup

public javax.swing.Popup getPopup(javax.swing.JPopupMenu popup,
                                  int x,
                                  int y)
Returns the Popup that will be responsible for displaying the JPopupMenu. Also does necessary modifications to popup coordinates in case they are actually required.

Overrides:
getPopup in class javax.swing.plaf.PopupMenuUI
Parameters:
popup - JPopupMenu requesting Popup
x - screen x location Popup is to be shown at
y - screen y location Popup is to be shown at
Returns:
Popup that will show the JPopupMenu

paint

public void paint(java.awt.Graphics g,
                  javax.swing.JComponent c)
Paints popup menu decorations. The whole painting process is delegated to installed painter class.

Overrides:
paint in class javax.swing.plaf.ComponentUI
Parameters:
g - graphics context
c - popup menu component