com.alee.managers.style.skin.web
Class WebPopupPainter<E extends javax.swing.JComponent>

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

public class WebPopupPainter<E extends javax.swing.JComponent>
extends AbstractPainter<E>
implements PainterShapeProvider<E>, javax.swing.SwingConstants

Web-styled popup painter for any type of components. It is generally used for WebPopupMenuUI default styling but might also be used in other cases. Be aware that you will have to manually setup this painter if used outside of the WebPopupMenuUI.

Author:
Mikle Garin

Field Summary
protected  java.awt.Color borderColor
           
protected  int cornerAlignment
           
protected  int cornerSide
           
protected  int cornerWidth
           
protected static java.lang.String DROPDOWN_BORDER_SHAPE
           
protected static java.lang.String DROPDOWN_FILL_SHAPE
           
protected  PopupStyle popupStyle
          Style settings.
protected  int relativeCorner
           
protected  int round
           
protected  float shadeTransparency
           
protected  int shadeWidth
           
protected static java.lang.String SIMPLE_BORDER_SHAPE
           
protected static java.lang.String SIMPLE_FILL_SHAPE
          Shape cache keys.
protected  float transparency
           
protected  boolean transparent
          Runtime variables.
 
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
WebPopupPainter()
           
 
Method Summary
protected  java.awt.geom.GeneralPath createDropdownCornerShape(E popupMenu, java.awt.Dimension menuSize, boolean fill)
          Creates and returns dropdown style corner shape.
protected  java.awt.geom.GeneralPath createDropdownShape(E popup, java.awt.Dimension popupSize, boolean fill)
          Creates and returns dropdown style shape.
protected  java.awt.geom.GeneralPath createSimpleShape(E popup, java.awt.Dimension popupSize, boolean fill)
          Creates and returns simple popup shape.
protected  java.awt.Color getBackgroundColor(E popup)
          Returns popup background color.
 java.awt.Color getBorderColor()
          Returns popup border color.
protected  java.awt.Shape getBorderShape(E popup, java.awt.Dimension popupSize, boolean fill)
          Returns popup border shape.
protected  java.lang.Object[] getCachedShapeSettings(E popup)
          Returns an array of shape settings cached along with the shape.
protected  java.awt.Color getComponentBackground(E popup)
          Returns popup background color.
 int getCornerAlignment()
          Returns dropdown corner alignment.
 int getCornerSide()
          Returns dropdown style corner side.
 int getCornerWidth()
          Returns popup dropdown style corner width.
protected  float getCurrentShadeTransparency()
          Returns current shade transparency.
protected  java.awt.Shape getDropdownCornerShape(E popupMenu, java.awt.Dimension menuSize, boolean fill)
          Returns dropdown style corner shape.
 java.awt.Insets getMargin(E c)
          Returns margin required for visual data provided by this painter.
 PopupStyle getPopupStyle()
          Returns popup style.
 int getRelativeCorner()
          Returns relative dropdown corner position.
 int getRound()
          Returns popup border corners rounding.
protected  java.awt.Rectangle getShadeBounds(java.awt.Dimension popupSize)
          Returns popup shade bounds.
 float getShadeTransparency()
          Returns popup shade transparency.
 int getShadeWidth()
          Returns popup shade width.
protected  int getSideWidth()
          Returns popup side space width.
 float getTransparency()
          Returns popup background transparency.
 java.lang.Boolean isOpaque(E c)
          Returns whether visual data provided by this painter is opaque or not.
 boolean isTransparent()
          Returns whether popup is transparent or not.
 void paint(java.awt.Graphics2D g2d, java.awt.Rectangle bounds, E popup)
          Paints visual data onto the component graphics.
protected  void paintBackground(java.awt.Graphics2D g2d, E popup, java.awt.Dimension popupSize)
          Paints popup background fill.
protected  void paintBorder(java.awt.Graphics2D g2d, E popup, java.awt.Dimension popupSize)
          Paints popup border.
protected  void paintShade(java.awt.Graphics2D g2d, E popup, java.awt.Dimension popupSize)
          Paints popup shade.
protected  void paintSimplePopup(java.awt.Graphics2D g2d, E popup)
          Paints simple popup version.
protected  void paintTransparentPopup(java.awt.Graphics2D g2d, E popup)
          Paints transparent popup version.
 java.awt.Shape provideShape(E component, java.awt.Rectangle bounds)
          Returns painted component shape.
 void setBorderColor(java.awt.Color color)
          Sets popup border color.
 void setCornerAlignment(int cornerAlignment)
          Sets dropdown corner alignment.
 void setCornerSide(int cornerSide)
          Sets dropdown style corner side.
 void setCornerWidth(int width)
          Sets popup dropdown style corner width.
 void setPopupStyle(PopupStyle style)
          Sets popup style.
 void setRelativeCorner(int relativeCorner)
          Sets relative dropdown corner position.
 void setRound(int round)
          Sets popup border corners rounding.
 void setShadeTransparency(float transparency)
          Sets popup shade transparency.
 void setShadeWidth(int width)
          Sets popup shade width.
 void setTransparency(float transparency)
          Sets popup background transparency.
 void setTransparent(boolean transparent)
          Sets whether popup is transparent or not.
 
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
 

Field Detail

SIMPLE_FILL_SHAPE

protected static final java.lang.String SIMPLE_FILL_SHAPE
Shape cache keys.

See Also:
Constant Field Values

SIMPLE_BORDER_SHAPE

protected static final java.lang.String SIMPLE_BORDER_SHAPE
See Also:
Constant Field Values

DROPDOWN_FILL_SHAPE

protected static final java.lang.String DROPDOWN_FILL_SHAPE
See Also:
Constant Field Values

DROPDOWN_BORDER_SHAPE

protected static final java.lang.String DROPDOWN_BORDER_SHAPE
See Also:
Constant Field Values

popupStyle

protected PopupStyle popupStyle
Style settings.


borderColor

protected java.awt.Color borderColor

round

protected int round

shadeWidth

protected int shadeWidth

shadeTransparency

protected float shadeTransparency

cornerWidth

protected int cornerWidth

transparency

protected float transparency

transparent

protected boolean transparent
Runtime variables.


cornerSide

protected int cornerSide

relativeCorner

protected int relativeCorner

cornerAlignment

protected int cornerAlignment
Constructor Detail

WebPopupPainter

public WebPopupPainter()
Method Detail

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 popup border corners rounding.

Returns:
popup border corners rounding

setRound

public void setRound(int round)
Sets popup border corners rounding.

Parameters:
round - new popup border corners rounding

getShadeWidth

public int getShadeWidth()
Returns popup shade width.

Returns:
popup shade width

setShadeWidth

public void setShadeWidth(int width)
Sets popup shade width.

Parameters:
width - new popup shade width

getShadeTransparency

public float getShadeTransparency()
Returns popup shade transparency.

Returns:
popup shade transparency

setShadeTransparency

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

Parameters:
transparency - 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

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

isTransparent

public boolean isTransparent()
Returns whether popup is transparent or not.

Returns:
true if popup is transparent, false otherwise

setTransparent

public void setTransparent(boolean transparent)
Sets whether popup is transparent or not.

Parameters:
transparent - whether popup is transparent or not

getCornerSide

public int getCornerSide()
Returns dropdown style corner side.

Returns:
dropdown style corner side

setCornerSide

public void setCornerSide(int cornerSide)
Sets dropdown style corner side.

Parameters:
cornerSide - dropdown style corner side

getRelativeCorner

public int getRelativeCorner()
Returns relative dropdown corner position.

Returns:
relative dropdown corner position

setRelativeCorner

public void setRelativeCorner(int relativeCorner)
Sets relative dropdown corner position.

Parameters:
relativeCorner - relative dropdown corner position

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

provideShape

public java.awt.Shape provideShape(E component,
                                   java.awt.Rectangle bounds)
Returns painted component shape.

Specified by:
provideShape in interface PainterShapeProvider<E extends javax.swing.JComponent>
Parameters:
component - component to process
bounds - bounds for painter visual data
Returns:
painted component shape

isOpaque

public java.lang.Boolean isOpaque(E c)
Returns whether visual data provided by this painter is opaque or not. Returned value might affect component opacity depending on painter support inside that component UI. Simply return null if you don't want to change default component opacity.

Specified by:
isOpaque in interface Painter<E extends javax.swing.JComponent>
Overrides:
isOpaque in class AbstractPainter<E extends javax.swing.JComponent>
Parameters:
c - component to process
Returns:
true if visual data provided by this painter is opaque, false otherwise

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.JComponent>
Overrides:
getMargin in class AbstractPainter<E extends javax.swing.JComponent>
Parameters:
c - component to process
Returns:
margin required for visual data provided by this painter or null for zero margin

paint

public void paint(java.awt.Graphics2D g2d,
                  java.awt.Rectangle bounds,
                  E popup)
Paints visual data onto the component graphics. Provided graphics and component are taken directly from component UI paint method. Provided bounds are usually fake (zero location, component size) but in some cases it might be specified by componentUI.

Specified by:
paint in interface Painter<E extends javax.swing.JComponent>
Parameters:
g2d - component graphics
bounds - bounds for painter visual data
popup - component to process

paintTransparentPopup

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

Parameters:
g2d - graphics context
popup - popup component

paintSimplePopup

protected void paintSimplePopup(java.awt.Graphics2D g2d,
                                E popup)
Paints simple popup version. This one is used when popup component is opaque.

Parameters:
g2d - graphics context
popup - popup component

paintShade

protected void paintShade(java.awt.Graphics2D g2d,
                          E popup,
                          java.awt.Dimension popupSize)
Paints popup shade.

Parameters:
g2d - graphics context
popup - popup component
popupSize - popup size

getCurrentShadeTransparency

protected float getCurrentShadeTransparency()
Returns current shade transparency. This part moved to a separate method to make it simple to override without touchin the actual transparency value.

Returns:
current shade transparency

paintBackground

protected void paintBackground(java.awt.Graphics2D g2d,
                               E popup,
                               java.awt.Dimension popupSize)
Paints popup background fill.

Parameters:
g2d - graphics context
popup - popup component
popupSize - popup size

paintBorder

protected void paintBorder(java.awt.Graphics2D g2d,
                           E popup,
                           java.awt.Dimension popupSize)
Paints popup border.

Parameters:
g2d - graphics context
popup - popup component
popupSize - popup size

getBackgroundColor

protected java.awt.Color getBackgroundColor(E popup)
Returns popup background color.

Parameters:
popup - popup component
Returns:
popup background color

getComponentBackground

protected java.awt.Color getComponentBackground(E popup)
Returns popup background color. This call moved into a separate method so you can override it to provide different background color.

Parameters:
popup - popup component
Returns:
popup background color

getShadeBounds

protected java.awt.Rectangle getShadeBounds(java.awt.Dimension popupSize)
Returns popup shade bounds.

Parameters:
popupSize - popup size
Returns:
popup shade bounds

getBorderShape

protected java.awt.Shape getBorderShape(E popup,
                                        java.awt.Dimension popupSize,
                                        boolean fill)
Returns popup border shape.

Parameters:
popup - popup component
popupSize - popup size
fill - whether it is a fill shape or not
Returns:
popup border shape

getCachedShapeSettings

protected java.lang.Object[] getCachedShapeSettings(E popup)
Returns an array of shape settings cached along with the shape.

Parameters:
popup - popup component
Returns:
an array of shape settings cached along with the shape

createSimpleShape

protected java.awt.geom.GeneralPath createSimpleShape(E popup,
                                                      java.awt.Dimension popupSize,
                                                      boolean fill)
Creates and returns simple popup shape.

Parameters:
popup - popup component
popupSize - popup size
fill - whether it is a fill shape or not
Returns:
simple popup shape

createDropdownShape

protected java.awt.geom.GeneralPath createDropdownShape(E popup,
                                                        java.awt.Dimension popupSize,
                                                        boolean fill)
Creates and returns dropdown style shape.

Parameters:
popup - popup component
popupSize - popup size
fill - whether it is a fill shape or not
Returns:
dropdown style shape

getDropdownCornerShape

protected java.awt.Shape getDropdownCornerShape(E popupMenu,
                                                java.awt.Dimension menuSize,
                                                boolean fill)
Returns dropdown style corner shape. It is used to paint corner fill when menu item at the same as corner side of popup menu is selected.

Parameters:
popupMenu - popup menu
menuSize - menu size
fill - whether it is a fill shape or not
Returns:
dropdown style corner shape

createDropdownCornerShape

protected java.awt.geom.GeneralPath createDropdownCornerShape(E popupMenu,
                                                              java.awt.Dimension menuSize,
                                                              boolean fill)
Creates and returns dropdown style corner shape. It is used to paint corner fill when menu item at the same as corner side of popup menu is selected.

Parameters:
popupMenu - popup menu
menuSize - menu size
fill - whether it is a fill shape or not
Returns:
dropdown style corner shape

getSideWidth

protected int getSideWidth()
Returns popup side space width. This is the space taken by popup shade and corner.

Returns:
popup side space width