Package io.imagekit.models
Class Overlay
-
- All Implemented Interfaces:
public final class OverlaySpecifies an overlay to be applied on the parent image or video. ImageKit supports overlays including images, text, videos, subtitles, and solid colors. See Overlay using layers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceOverlay.VisitorAn interface that defines how to map each variant of Overlay to a value of type T.
-
Method Summary
-
-
Method Detail
-
text
final Optional<TextOverlay> text()
-
image
final Optional<ImageOverlay> image()
-
video
final Optional<VideoOverlay> video()
-
subtitle
final Optional<SubtitleOverlay> subtitle()
-
solidColor
final Optional<SolidColorOverlay> solidColor()
-
isSubtitle
final Boolean isSubtitle()
-
isSolidColor
final Boolean isSolidColor()
-
asText
final TextOverlay asText()
-
asImage
final ImageOverlay asImage()
-
asVideo
final VideoOverlay asVideo()
-
asSubtitle
final SubtitleOverlay asSubtitle()
-
asSolidColor
final SolidColorOverlay asSolidColor()
-
accept
final <T extends Any> T accept(Overlay.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import io.imagekit.core.JsonValue; import java.util.Optional; Optional<String> result = overlay.accept(new Overlay.Visitor<Optional<String>>() { @Override public Optional<String> visitText(TextOverlay text) { return Optional.of(text.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final Overlay validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofText
final static Overlay ofText(TextOverlay text)
-
ofImage
final static Overlay ofImage(ImageOverlay image)
-
ofVideo
final static Overlay ofVideo(VideoOverlay video)
-
ofSubtitle
final static Overlay ofSubtitle(SubtitleOverlay subtitle)
-
ofSolidColor
final static Overlay ofSolidColor(SolidColorOverlay solidColor)
-
-
-
-