Package org.jfree.chart.util
Class DefaultShadowGenerator
- java.lang.Object
-
- org.jfree.chart.util.DefaultShadowGenerator
-
- All Implemented Interfaces:
java.io.Serializable,ShadowGenerator
public class DefaultShadowGenerator extends java.lang.Object implements ShadowGenerator, java.io.Serializable
A default implementation of theShadowGeneratorinterface, based on code in a blog post by Romain Guy.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private doubleangleThe shadow offset angle (in radians).private intdistanceThe shadow offset distance (in Java2D units).private static longserialVersionUIDprivate java.awt.ColorshadowColorThe shadow color.private floatshadowOpacityThe shadow opacity.private intshadowSizeThe shadow size.
-
Constructor Summary
Constructors Constructor Description DefaultShadowGenerator()Creates a new instance with default attributes.DefaultShadowGenerator(int size, java.awt.Color color, float opacity, int distance, double angle)Creates a new instance with the specified attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyShadow(java.awt.image.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.java.awt.image.BufferedImagecreateDropShadow(java.awt.image.BufferedImage source)Creates and returns an image containing the drop shadow for the specified source image.booleanequals(java.lang.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.java.awt.ColorgetShadowColor()Returns the shadow color.floatgetShadowOpacity()Returns the shadow opacity.intgetShadowSize()Returns the shadow size.inthashCode()Returns a hash code for this instance.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
shadowSize
private int shadowSize
The shadow size.
-
shadowColor
private java.awt.Color shadowColor
The shadow color.
-
shadowOpacity
private float shadowOpacity
The shadow opacity.
-
angle
private double angle
The shadow offset angle (in radians).
-
distance
private int distance
The shadow offset distance (in Java2D units).
-
-
Constructor Detail
-
DefaultShadowGenerator
public DefaultShadowGenerator()
Creates a new instance with default attributes.
-
DefaultShadowGenerator
public DefaultShadowGenerator(int size, java.awt.Color color, float opacity, int distance, double angle)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 Detail
-
getShadowSize
public int getShadowSize()
Returns the shadow size.- Returns:
- The shadow size.
-
getShadowColor
public java.awt.Color getShadowColor()
Returns the shadow color.- Returns:
- The shadow color (never
null).
-
getShadowOpacity
public float getShadowOpacity()
Returns the shadow opacity.- Returns:
- The shadow opacity.
-
getDistance
public int getDistance()
Returns the shadow offset distance.- Returns:
- The shadow offset distance (in Java2D units).
-
getAngle
public double getAngle()
Returns the shadow offset angle (in radians).- Returns:
- The angle (in radians).
-
calculateOffsetX
public int calculateOffsetX()
Calculates the x-offset for drawing the shadow image relative to the source.- Specified by:
calculateOffsetXin interfaceShadowGenerator- Returns:
- The x-offset.
-
calculateOffsetY
public int calculateOffsetY()
Calculates the y-offset for drawing the shadow image relative to the source.- Specified by:
calculateOffsetYin interfaceShadowGenerator- Returns:
- The y-offset.
-
createDropShadow
public java.awt.image.BufferedImage createDropShadow(java.awt.image.BufferedImage source)
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
protected void applyShadow(java.awt.image.BufferedImage image)
Applies a shadow to the image.- Parameters:
image- the image.
-
equals
public boolean equals(java.lang.Object obj)
Tests this object for equality with an arbitrary object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object (nullpermitted).- Returns:
- The object.
-
hashCode
public int hashCode()
Returns a hash code for this instance.- Overrides:
hashCodein classjava.lang.Object- Returns:
- The hash code.
-
-