org.newdawn.slick.font.effects
Class ShadowEffect

java.lang.Object
  extended by org.newdawn.slick.font.effects.ShadowEffect
All Implemented Interfaces:
ConfigurableEffect, Effect

public class ShadowEffect
extends java.lang.Object
implements ConfigurableEffect

An effect to generate soft shadows beneath text

Author:
Nathan Sweet

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.newdawn.slick.font.effects.ConfigurableEffect
ConfigurableEffect.Value
 
Field Summary
static float[][] GAUSSIAN_BLUR_KERNELS
          The blur kernels applied across the effect
static int NUM_KERNELS
          The number of kernels to apply
 
Constructor Summary
ShadowEffect()
          Default constructor for injection
ShadowEffect(java.awt.Color color, int xDistance, int yDistance, float opacity)
          Create a new effect to apply a drop shadow to text
 
Method Summary
 void draw(java.awt.image.BufferedImage image, java.awt.Graphics2D g, UnicodeFont unicodeFont, Glyph glyph)
          Called to draw the effect.
 int getBlurKernelSize()
          Get the size of the kernel used to apply the blur
 int getBlurPasses()
          Get the number of passes to apply the kernel for blurring
 java.awt.Color getColor()
          Get the colour of the shadow generated
 float getOpacity()
          Get the opacity of the shadow, i.e.
 java.util.List getValues()
          Returns the list of ConfigurableEffect.Values for this effect.
 float getXDistance()
          Get the distance on the X axis from the text the shadow should be generated at
 float getYDistance()
          Get the distance on the Y axis from the text the shadow should be generated at
 void setBlurKernelSize(int blurKernelSize)
          Sets how many neighboring pixels are used to blur the shadow.
 void setBlurPasses(int blurPasses)
          Sets the number of times to apply a blur to the shadow.
 void setColor(java.awt.Color color)
          Set the colour of the shadow to be generated
 void setOpacity(float opacity)
          Set the opacity of the shadow, i.e.
 void setValues(java.util.List values)
          Sets the list of ConfigurableEffect.Values for this effect.
 void setXDistance(float distance)
          Sets the pixels to offset the shadow on the x axis.
 void setYDistance(float distance)
          Sets the pixels to offset the shadow on the y axis.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUM_KERNELS

public static final int NUM_KERNELS
The number of kernels to apply

See Also:
Constant Field Values

GAUSSIAN_BLUR_KERNELS

public static final float[][] GAUSSIAN_BLUR_KERNELS
The blur kernels applied across the effect

Constructor Detail

ShadowEffect

public ShadowEffect()
Default constructor for injection


ShadowEffect

public ShadowEffect(java.awt.Color color,
                    int xDistance,
                    int yDistance,
                    float opacity)
Create a new effect to apply a drop shadow to text

Parameters:
color - The colour of the shadow to generate
xDistance - The distance from the text on the x axis the shadow should be rendered
yDistance - The distance from the text on the y axis the shadow should be rendered
opacity - The transparency factor of the shadow
Method Detail

draw

public void draw(java.awt.image.BufferedImage image,
                 java.awt.Graphics2D g,
                 UnicodeFont unicodeFont,
                 Glyph glyph)
Description copied from interface: Effect
Called to draw the effect.

Specified by:
draw in interface Effect
Parameters:
image - The image to draw into
g - The graphics context to use for applying the effect
unicodeFont - The font being rendered
glyph - The particular glyph being rendered
See Also:
Effect.draw(java.awt.image.BufferedImage, java.awt.Graphics2D, org.newdawn.slick.UnicodeFont, org.newdawn.slick.font.Glyph)

getColor

public java.awt.Color getColor()
Get the colour of the shadow generated

Returns:
The colour of the shadow generated

setColor

public void setColor(java.awt.Color color)
Set the colour of the shadow to be generated

Parameters:
color - The colour ofthe shadow to be generated

getXDistance

public float getXDistance()
Get the distance on the X axis from the text the shadow should be generated at

Returns:
The distance on the X axis the shadow will be from the text

setXDistance

public void setXDistance(float distance)
Sets the pixels to offset the shadow on the x axis. The glyphs will need padding so the shadow doesn't get clipped.

Parameters:
distance - The offset on the x axis

getYDistance

public float getYDistance()
Get the distance on the Y axis from the text the shadow should be generated at

Returns:
The distance on the Y axis the shadow will be from the text

setYDistance

public void setYDistance(float distance)
Sets the pixels to offset the shadow on the y axis. The glyphs will need padding so the shadow doesn't get clipped.

Parameters:
distance - The offset on the y axis

getBlurKernelSize

public int getBlurKernelSize()
Get the size of the kernel used to apply the blur

Returns:
The blur kernel size

setBlurKernelSize

public void setBlurKernelSize(int blurKernelSize)
Sets how many neighboring pixels are used to blur the shadow. Set to 0 for no blur.

Parameters:
blurKernelSize - The size of the kernel to apply the blur with

getBlurPasses

public int getBlurPasses()
Get the number of passes to apply the kernel for blurring

Returns:
The number of passes

setBlurPasses

public void setBlurPasses(int blurPasses)
Sets the number of times to apply a blur to the shadow. Set to 0 for no blur.

Parameters:
blurPasses - The number of passes to apply when blurring

getOpacity

public float getOpacity()
Get the opacity of the shadow, i.e. how transparent it is

Returns:
The opacity of the shadow

setOpacity

public void setOpacity(float opacity)
Set the opacity of the shadow, i.e. how transparent it is

Parameters:
opacity - The opacity of the shadow

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getValues

public java.util.List getValues()
Description copied from interface: ConfigurableEffect
Returns the list of ConfigurableEffect.Values for this effect. This list is not typically backed by the effect, so changes to the values will not take affect until ConfigurableEffect.setValues(List) is called.

Specified by:
getValues in interface ConfigurableEffect
See Also:
ConfigurableEffect.getValues()

setValues

public void setValues(java.util.List values)
Description copied from interface: ConfigurableEffect
Sets the list of ConfigurableEffect.Values for this effect.

Specified by:
setValues in interface ConfigurableEffect
See Also:
ConfigurableEffect.setValues(java.util.List)


Copyright © 2006 New Dawn Software. All Rights Reserved.