Package org.jfree.chart.util
Class DefaultShadowGenerator
java.lang.Object
org.jfree.chart.util.DefaultShadowGenerator
- All Implemented Interfaces:
Serializable,ShadowGenerator
public class DefaultShadowGenerator extends Object implements ShadowGenerator, Serializable
A default implementation of the
ShadowGenerator interface, based on
code in a
blog
post by Romain Guy.- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description DefaultShadowGenerator()Creates a new instance with default attributes.DefaultShadowGenerator(int size, Color color, float opacity, int distance, double angle)Creates a new instance with the specified attributes. -
Method Summary
Modifier and Type Method Description protected voidapplyShadow(BufferedImage image)Applies a shadow to the image.intcalculateOffsetX()Calculates the x-offset for drawing the shadow image relative to the source.intcalculateOffsetY()Calculates the y-offset for drawing the shadow image relative to the source.BufferedImagecreateDropShadow(BufferedImage source)Creates and returns an image containing the drop shadow for the specified source image.booleanequals(Object obj)Tests this object for equality with an arbitrary object.doublegetAngle()Returns the shadow offset angle (in radians).intgetDistance()Returns the shadow offset distance.ColorgetShadowColor()Returns the shadow color.floatgetShadowOpacity()Returns the shadow opacity.intgetShadowSize()Returns the shadow size.inthashCode()Returns a hash code for this instance.
-
Constructor Details
-
DefaultShadowGenerator
public DefaultShadowGenerator()Creates a new instance with default attributes. -
DefaultShadowGenerator
Creates a new instance with the specified attributes.- Parameters:
size- the shadow size.color- the shadow color.opacity- the shadow opacity.distance- the shadow offset distance.angle- the shadow offset angle (in radians).
-
-
Method Details
-
getShadowSize
Returns the shadow size.- Returns:
- The shadow size.
-
getShadowColor
Returns the shadow color.- Returns:
- The shadow color (never
null).
-
getShadowOpacity
Returns the shadow opacity.- Returns:
- The shadow opacity.
-
getDistance
Returns the shadow offset distance.- Returns:
- The shadow offset distance (in Java2D units).
-
getAngle
Returns the shadow offset angle (in radians).- Returns:
- The angle (in radians).
-
calculateOffsetX
Calculates the x-offset for drawing the shadow image relative to the source.- Specified by:
calculateOffsetXin interfaceShadowGenerator- Returns:
- The x-offset.
-
calculateOffsetY
Calculates the y-offset for drawing the shadow image relative to the source.- Specified by:
calculateOffsetYin interfaceShadowGenerator- Returns:
- The y-offset.
-
createDropShadow
Creates and returns an image containing the drop shadow for the specified source image.- Specified by:
createDropShadowin interfaceShadowGenerator- Parameters:
source- the source image.- Returns:
- A new image containing the shadow.
-
applyShadow
Applies a shadow to the image.- Parameters:
image- the image.
-
equals
Tests this object for equality with an arbitrary object. -
hashCode
Returns a hash code for this instance.
-