E - component typeD - decoration typeI - shadow typepublic class WebShadow<E extends javax.swing.JComponent,D extends WebDecoration<E,D>,I extends WebShadow<E,D,I>> extends AbstractShadow<E,D,I>
ShadowFilter and saved into BufferedImage.
Generated image with the shadow is usually kept in cache to optimize UI performance.
One generated shadow sometimes might be reused by multiple components of different size.
That happens only when IShape implementation this shadow is based on provides stretch areas.
In that case NinePatchIcon is created based on the shadow image to stretch the shadow.| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
separator
Cache key data separator.
|
protected NinePatchIcon |
shadowIcon
Reference keeping shadow icon in memory.
|
protected static java.util.Map<java.lang.String,java.lang.ref.WeakReference<NinePatchIcon>> |
shadowIconsCache
Shadow icons cache.
|
protected java.awt.image.BufferedImage |
shadowImage
Reference keeping shadow image in memory.
|
protected static java.util.Map<java.lang.String,java.lang.ref.WeakReference<java.awt.image.BufferedImage>> |
shadowImagesCache
Shadow images cache.
|
color, opacity, type, width| Constructor and Description |
|---|
WebShadow() |
| Modifier and Type | Method and Description |
|---|---|
static NinePatchIcon |
createInnerShadeIcon(StretchInfo stretchInfo,
java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape)
Returns inner shadow nine-patch icon.
|
static java.awt.image.BufferedImage |
createInnerShadeImage(java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape)
Returns inner shadow image based on provided shape.
|
static NinePatchIcon |
createShadeIcon(StretchInfo stretchInfo,
java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape)
Returns shadow nine-patch icon.
|
static java.awt.image.BufferedImage |
createShadeImage(java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape)
Returns shadow image based on provided shape.
|
protected NinePatchIcon |
getInnerShadeIcon(StretchInfo stretchInfo,
java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape,
java.lang.Object... settings)
Returns cached inner shadow icon based on provided shape.
|
static java.awt.image.BufferedImage |
getInnerShadeImage(java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape,
java.lang.Object... settings)
Returns cached inner shadow image based on provided shape.
|
protected java.awt.Rectangle |
getShadeBounds(ShadowType type,
java.awt.Shape shape,
int width)
Returns bounds used for shadow image generation.
|
protected NinePatchIcon |
getShadeIcon(StretchInfo stretchInfo,
java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape,
java.lang.Object... settings)
Returns cached shadow icon based on provided shape.
|
static java.awt.image.BufferedImage |
getShadeImage(java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape,
java.lang.Object... settings)
Returns cached shadow image based on provided shape.
|
void |
paint(java.awt.Graphics2D g2d,
java.awt.Rectangle bounds,
E c,
D d,
java.awt.Shape shape)
Paints shadow for the specified shape.
|
clone, getColor, getId, getOpacity, getType, getWidth, mergeprotected static final transient java.util.Map<java.lang.String,java.lang.ref.WeakReference<NinePatchIcon>> shadowIconsCache
protected static final transient java.util.Map<java.lang.String,java.lang.ref.WeakReference<java.awt.image.BufferedImage>> shadowImagesCache
protected static final java.lang.String separator
protected transient NinePatchIcon shadowIcon
protected transient java.awt.image.BufferedImage shadowImage
public void paint(java.awt.Graphics2D g2d,
java.awt.Rectangle bounds,
E c,
D d,
java.awt.Shape shape)
IShadowg2d - graphics contextbounds - painting boundsc - painted componentd - painted decoration stateshape - background shapeprotected java.awt.Rectangle getShadeBounds(ShadowType type, java.awt.Shape shape, int width)
type - shadow typeshape - shadow shapewidth - shadow widthprotected NinePatchIcon getShadeIcon(StretchInfo stretchInfo, java.awt.Rectangle bounds, int width, float opacity, java.awt.Color color, java.awt.Shape shape, java.lang.Object... settings)
stretchInfo - shape stretch informationbounds - shadow boundswidth - shadow widthopacity - shadow opacitycolor - shadow colorshape - shadow shapesettings - shape settingspublic static NinePatchIcon createShadeIcon(StretchInfo stretchInfo, java.awt.Rectangle bounds, int width, float opacity, java.awt.Color color, java.awt.Shape shape)
stretchInfo - shape stretch informationbounds - shadow boundswidth - shadow widthopacity - shadow opacitycolor - shadow colorshape - shadow shapepublic static java.awt.image.BufferedImage getShadeImage(java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape,
java.lang.Object... settings)
bounds - shadow boundswidth - shadow widthopacity - shadow opacitycolor - shadow colorshape - shadow shapesettings - shape settingspublic static java.awt.image.BufferedImage createShadeImage(java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape)
bounds - shadow boundswidth - shadow widthopacity - shadow opacitycolor - shadow colorshape - shadow shapeprotected NinePatchIcon getInnerShadeIcon(StretchInfo stretchInfo, java.awt.Rectangle bounds, int width, float opacity, java.awt.Color color, java.awt.Shape shape, java.lang.Object... settings)
stretchInfo - shape stretch informationbounds - shadow boundswidth - shadow widthopacity - shadow opacitycolor - shadow colorshape - shadow shapesettings - shape settingspublic static NinePatchIcon createInnerShadeIcon(StretchInfo stretchInfo, java.awt.Rectangle bounds, int width, float opacity, java.awt.Color color, java.awt.Shape shape)
stretchInfo - shape stretch informationbounds - shadow boundswidth - shadow widthopacity - shadow opacitycolor - shadow colorshape - shadow shapepublic static java.awt.image.BufferedImage getInnerShadeImage(java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape,
java.lang.Object... settings)
bounds - shadow boundswidth - shadow widthopacity - shadow opacitycolor - shadow colorshape - shadow shapesettings - shape settingspublic static java.awt.image.BufferedImage createInnerShadeImage(java.awt.Rectangle bounds,
int width,
float opacity,
java.awt.Color color,
java.awt.Shape shape)
bounds - shadow boundswidth - shadow widthopacity - shadow opacitycolor - shadow colorshape - shadow shape