|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.tapestry.contrib.services.impl.ShadowRenderer
public class ShadowRenderer
Constructor Summary | |
---|---|
ShadowRenderer(int size,
float opacity,
Color color)
A shadow renderer needs three properties to generate shadows. |
Method Summary | |
---|---|
BufferedImage |
createShadow(BufferedImage image)
Generates the shadow for a given picture and the current properties of the renderer. |
Color |
getColor()
Gets the color used by the renderer to generate shadows. |
float |
getOpacity()
Gets the opacity used by the renderer to generate shadows. |
static int[] |
getPixels(BufferedImage img,
int x,
int y,
int w,
int h,
int[] pixels)
Returns an array of pixels, stored as integers, from a BufferedImage . |
int |
getSize()
Gets the size in pixel used by the renderer to generate shadows. |
void |
setColor(Color shadowColor)
Sets the color used by the renderer to generate shadows. |
void |
setOpacity(float shadowOpacity)
Sets the opacity used by the renderer to generate shadows. |
static void |
setPixels(BufferedImage img,
int x,
int y,
int w,
int h,
int[] pixels)
Writes a rectangular area of pixels in the destination BufferedImage . |
void |
setSize(int shadowSize)
Sets the size, in pixels, used by the renderer to generate shadows. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ShadowRenderer(int size, float opacity, Color color)
A shadow renderer needs three properties to generate shadows. These properties are:
size
- the size of the shadow in pixels. Defines the fuzziness.opacity
- the opacity of the shadow.color
- the color of the shadow.Method Detail |
---|
public Color getColor()
Gets the color used by the renderer to generate shadows.
public void setColor(Color shadowColor)
Sets the color used by the renderer to generate shadows.
Consecutive calls to createShadow(java.awt.image.BufferedImage)
will all use this color
until it is set again.
If the color provided is null, the previous color will be retained.
shadowColor
- the generated shadows colorpublic float getOpacity()
Gets the opacity used by the renderer to generate shadows.
The opacity is comprised between 0.0f and 1.0f; 0.0f being fully transparent and 1.0f fully opaque.
public void setOpacity(float shadowOpacity)
Sets the opacity used by the renderer to generate shadows.
Consecutive calls to createShadow(java.awt.image.BufferedImage)
will all use this opacity
until it is set again.
The opacity is comprised between 0.0f and 1.0f; 0.0f being fully transparent and 1.0f fully opaque. If you provide a value out of these boundaries, it will be restrained to the closest boundary.
shadowOpacity
- the generated shadows opacitypublic int getSize()
Gets the size in pixel used by the renderer to generate shadows.
public void setSize(int shadowSize)
Sets the size, in pixels, used by the renderer to generate shadows.
The size defines the blur radius applied to the shadow to create the fuzziness.
There is virtually no limit to the size. The size cannot be negative. If you provide a negative value, the size will be 0 instead.
shadowSize
- the generated shadows size in pixels (fuzziness)public BufferedImage createShadow(BufferedImage image)
Generates the shadow for a given picture and the current properties of the renderer.
The generated image dimensions are computed as following:
width = imageWidth + 2 * shadowSize height = imageHeight + 2 * shadowSize
image
- the picture from which the shadow must be cast
image
public static int[] getPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels)
Returns an array of pixels, stored as integers, from a
BufferedImage
. The pixels are grabbed from a rectangular
area defined by a location and two dimensions. Calling this method on
an image of type different from BufferedImage.TYPE_INT_ARGB
and BufferedImage.TYPE_INT_RGB
will unmanage the image.
img
- the source imagex
- the x location at which to start grabbing pixelsy
- the y location at which to start grabbing pixelsw
- the width of the rectangle of pixels to grabh
- the height of the rectangle of pixels to grabpixels
- a pre-allocated array of pixels of size w*h; can be null
pixels
if non-null, a new array of integers
otherwise
IllegalArgumentException
- is pixels
is non-null and
of length < w*hpublic static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels)
Writes a rectangular area of pixels in the destination
BufferedImage
. Calling this method on
an image of type different from BufferedImage.TYPE_INT_ARGB
and BufferedImage.TYPE_INT_RGB
will unmanage the image.
img
- the destination imagex
- the x location at which to start storing pixelsy
- the y location at which to start storing pixelsw
- the width of the rectangle of pixels to storeh
- the height of the rectangle of pixels to storepixels
- an array of pixels, stored as integers
IllegalArgumentException
- is pixels
is non-null and
of length < w*h
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |