com.alee.managers.style.skin.web
Class WebPopupMenuPainter<E extends javax.swing.JPopupMenu>

java.lang.Object
  extended by com.alee.extended.painter.AbstractPainter<E>
      extended by com.alee.managers.style.skin.web.WebPopupPainter<E>
          extended by com.alee.managers.style.skin.web.WebPopupMenuPainter<E>
All Implemented Interfaces:
Painter<E>, SpecificPainter, PopupMenuPainter<E>, PainterShapeProvider<E>, javax.swing.SwingConstants

public class WebPopupMenuPainter<E extends javax.swing.JPopupMenu>
extends WebPopupPainter<E>
implements PopupMenuPainter<E>

Base painter for JPopupMenu component. It is used as WebPopupMenuUI default styling.

Author:
Mikle Garin

Field Summary
protected  boolean fixLocation
           
protected  int menuSpacing
          Style settings.
protected  PopupMenuType popupMenuType
           
protected  PopupMenuWay popupMenuWay
          Runtime variables.
 
Fields inherited from class com.alee.managers.style.skin.web.WebPopupPainter
borderColor, cornerAlignment, cornerSide, cornerWidth, DROPDOWN_BORDER_SHAPE, DROPDOWN_FILL_SHAPE, popupStyle, relativeCorner, round, shadeTransparency, shadeWidth, SIMPLE_BORDER_SHAPE, SIMPLE_FILL_SHAPE, transparency, transparent
 
Fields inherited from class com.alee.extended.painter.AbstractPainter
listeners, margin, opaque, preferredSize
 
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
WebPopupMenuPainter()
           
 
Method Summary
 java.awt.Insets getMargin(E c)
          Returns margin required for visual data provided by this painter.
 int getMenuSpacing()
          Returns spacing between popup menus.
 boolean isFixLocation()
          Returns whether should fix initial popup menu location or not.
protected  void paintDropdownCornerFill(java.awt.Graphics2D g2d, E popupMenu, java.awt.Dimension menuSize)
          Paints dropdown-styled popup menu corner fill if menu item near it is selected.
protected  void paintTransparentPopup(java.awt.Graphics2D g2d, E popupMenu)
          Paints transparent popup version.
 java.awt.Point preparePopupMenu(E popupMenu, java.awt.Component invoker, int x, int y)
          Prepares popup menu to be displayed.
 void setFixLocation(boolean fix)
          Sets whether should fix initial popup menu location or not.
 void setMenuSpacing(int spacing)
          Sets spacing between popup menus.
 void setPopupMenuType(PopupMenuType type)
          Sets popup menu type.
 void setPopupMenuWay(PopupMenuWay way)
          Sets preferred popup menu display way.
 
Methods inherited from class com.alee.managers.style.skin.web.WebPopupPainter
createDropdownCornerShape, createDropdownShape, createSimpleShape, getBackgroundColor, getBorderColor, getBorderShape, getCachedShapeSettings, getComponentBackground, getCornerAlignment, getCornerSide, getCornerWidth, getCurrentShadeTransparency, getDropdownCornerShape, getPopupStyle, getRelativeCorner, getRound, getShadeBounds, getShadeTransparency, getShadeWidth, getSideWidth, getTransparency, isOpaque, isTransparent, paint, paintBackground, paintBorder, paintShade, paintSimplePopup, provideShape, setBorderColor, setCornerAlignment, setCornerSide, setCornerWidth, setPopupStyle, setRelativeCorner, setRound, setShadeTransparency, setShadeWidth, setTransparency, setTransparent
 
Methods inherited from class com.alee.extended.painter.AbstractPainter
addPainterListener, getPreferredSize, install, p, removePainterListener, repaint, repaint, repaint, revalidate, setMargin, setMargin, setMargin, setOpaque, setPreferredSize, uninstall, updateAll, updateOpacity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.alee.laf.menu.PopupMenuPainter
setTransparent
 
Methods inherited from interface com.alee.extended.painter.Painter
addPainterListener, getPreferredSize, install, isOpaque, paint, removePainterListener, uninstall
 

Field Detail

menuSpacing

protected int menuSpacing
Style settings.


fixLocation

protected boolean fixLocation

popupMenuWay

protected PopupMenuWay popupMenuWay
Runtime variables.


popupMenuType

protected PopupMenuType popupMenuType
Constructor Detail

WebPopupMenuPainter

public WebPopupMenuPainter()
Method Detail

getMenuSpacing

public int getMenuSpacing()
Returns spacing between popup menus.

Returns:
spacing between popup menus

setMenuSpacing

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

Specified by:
setMenuSpacing in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
spacing - spacing between popup menus

isFixLocation

public boolean isFixLocation()
Returns whether should fix initial popup menu location or not.

Returns:
true if should fix initial popup menu location, false otherwise

setFixLocation

public void setFixLocation(boolean fix)
Sets whether should fix initial popup menu location or not. If set to true popup menu will try to use best possible location to show up.

This is set to true by default to place menubar and menu popups correctly. You might want to set this to false for some specific popup menu, but not all of them at once.

Specified by:
setFixLocation in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
fix - whether should fix initial popup menu location or not

setPopupMenuWay

public void setPopupMenuWay(PopupMenuWay way)
Sets preferred popup menu display way. This value is updated right before preparePopupMenu method call.

Specified by:
setPopupMenuWay in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
way - preferred popup menu display way

setPopupMenuType

public void setPopupMenuType(PopupMenuType type)
Sets popup menu type. This value is updated right before popup menu window becomes visible. You can use it to draw different popup menu decoration for each popup menu type.

Specified by:
setPopupMenuType in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
type - popup menu type

getMargin

public java.awt.Insets getMargin(E c)
Returns margin required for visual data provided by this painter. This margin is usually added to component's margin when the final component border is calculated. You may pass null instead of zero margin - it will simply be ignored in that case.

Specified by:
getMargin in interface Painter<E extends javax.swing.JPopupMenu>
Overrides:
getMargin in class WebPopupPainter<E extends javax.swing.JPopupMenu>
Parameters:
c - component to process
Returns:
margin required for visual data provided by this painter or null for zero margin

paintTransparentPopup

protected void paintTransparentPopup(java.awt.Graphics2D g2d,
                                     E popupMenu)
Paints transparent popup version. This one is used when popup component can be transparent, otherwise a simple popup version is painted.

Overrides:
paintTransparentPopup in class WebPopupPainter<E extends javax.swing.JPopupMenu>
Parameters:
g2d - graphics context
popupMenu - popup component

paintDropdownCornerFill

protected void paintDropdownCornerFill(java.awt.Graphics2D g2d,
                                       E popupMenu,
                                       java.awt.Dimension menuSize)
Paints dropdown-styled popup menu corner fill if menu item near it is selected.

Parameters:
g2d - graphics context
popupMenu - popup menu
menuSize - menu size

preparePopupMenu

public java.awt.Point preparePopupMenu(E popupMenu,
                                       java.awt.Component invoker,
                                       int x,
                                       int y)
Prepares popup menu to be displayed.

Specified by:
preparePopupMenu in interface PopupMenuPainter<E extends javax.swing.JPopupMenu>
Parameters:
popupMenu - JPopupMenu to prepare for display
x - screen x location actual popup is to be shown at
y - screen y location actual popup is to be shown at
Returns:
modified popup display location