Class Caption
- java.lang.Object
-
- net.coobird.thumbnailator.filters.Caption
-
- All Implemented Interfaces:
ImageFilter
public class Caption extends java.lang.Object implements ImageFilter
AnImageFilterwhich will overlay a text caption to an image.
-
-
Field Summary
Fields Modifier and Type Field Description private floatalphaThe opacity level of the text to add.private java.awt.ColorcThe color of the text to add.private java.lang.StringcaptionThe text of the caption.private java.awt.FontfontThe font of text to add.private intinsetsThe insets for the text to draw.private PositionpositionThe position at which the text should be drawn.
-
Constructor Summary
Constructors Constructor Description Caption(java.lang.String caption, java.awt.Font font, java.awt.Color c, float alpha, Position position, int insets)Instantiates a filter which adds a text caption to an image.Caption(java.lang.String caption, java.awt.Font font, java.awt.Color c, Position position, int insets)Instantiates a filter which adds a text caption to an image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImageapply(java.awt.image.BufferedImage img)Applies a image filtering operation on an image.
-
-
-
Field Detail
-
caption
private final java.lang.String caption
The text of the caption.
-
font
private final java.awt.Font font
The font of text to add.
-
c
private final java.awt.Color c
The color of the text to add.
-
alpha
private final float alpha
The opacity level of the text to add.The value should be between
0.0fto1.0f, where0.0fis completely transparent, and1.0fis completely opaque.
-
position
private final Position position
The position at which the text should be drawn.
-
insets
private final int insets
The insets for the text to draw.
-
-
Constructor Detail
-
Caption
public Caption(java.lang.String caption, java.awt.Font font, java.awt.Color c, float alpha, Position position, int insets)Instantiates a filter which adds a text caption to an image.- Parameters:
caption- The text of the caption.font- The font of the caption.c- The color of the caption.alpha- The opacity level of caption.The value should be between
0.0fand1.0f, where0.0fis completely transparent, and1.0fis completely opaque.position- The position of the caption.insets- The inset size around the caption. Cannot be negative.
-
Caption
public Caption(java.lang.String caption, java.awt.Font font, java.awt.Color c, Position position, int insets)Instantiates a filter which adds a text caption to an image.The opacity of the caption will be 100% opaque.
- Parameters:
caption- The text of the caption.font- The font of the caption.c- The color of the caption.position- The position of the caption.insets- The inset size around the caption. Cannot be negative.
-
-
Method Detail
-
apply
public java.awt.image.BufferedImage apply(java.awt.image.BufferedImage img)
Description copied from interface:ImageFilterApplies a image filtering operation on an image.- Specified by:
applyin interfaceImageFilter- Parameters:
img- The image to apply the filtering on.- Returns:
- The resulting image after applying this filter.
-
-