Package com.castlabs.android.subtitles
Class SubtitlesStyle
- java.lang.Object
-
- com.castlabs.android.subtitles.SubtitlesStyle
-
- All Implemented Interfaces:
Parcelable
public class SubtitlesStyle extends Object implements Parcelable
This is the model class that contains all the styling information used by the subtitles plugins to render subtitles and closed captions. You can use the following static properties of this class to overwrite the defaults:DEFAULT_FOREGROUND_COLOR
-- The default foreground color as ARGBDEFAULT_BACKGROUND_COLOR
-- The default background color as ARGBDEFAULT_WINDOW_COLOR
-- The default window color as ARGBDEFAULT_EDGE_COLOR
-- The default edge color as ARGBDEFAULT_EDGE_TYPE
-- The default edge typeDEFAULT_FONT_SCALE
-- The default font scaleDEFAULT_TYPEFACE
-- The default typeface
SubtitlesStyle.Builder
and itsSubtitlesStyle.Builder.create(Context, boolean)
method. When you use the Builder, you have the option to select of certain values overwrite the default or not. This is used if subtitles support their own styling, i.e. TTML with styles. If the overwrite flag is not set, the setting will be applied to un-styled subtitles, but styled subtitles are still rendered accordingly. Of theoverwrite
flag is set totrue
, the style will always be enforced and content based styles will not be applied, i.e. TTML styles will be ignored.- Since:
- 3.1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SubtitlesStyle.Builder
static interface
SubtitlesStyle.EdgeType
static interface
SubtitlesStyle.ImageScalingMode
-
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T extends Object>, Parcelable.Creator<T extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description int
backgroundColor
The text background color as ARGB.int
bottomMargin
The margin in pixels applied to the subtitles located below the horizontal middle of the video viewstatic Parcelable.Creator<SubtitlesStyle>
CREATOR
static int
DEFAULT_BACKGROUND_COLOR
The default background colorstatic int
DEFAULT_BOTTOM_MARGIN
The default bottom margin in pixelsstatic boolean
DEFAULT_DRAW_BEYOND_VIDEO_AREA
The default draw beyond video area flagstatic int
DEFAULT_EDGE_BLUR_RADIUS
The default edge blur radius in pixelsstatic int
DEFAULT_EDGE_COLOR
The default edge colorstatic int
DEFAULT_EDGE_THICKNESS
The default edge thickness in pixelsstatic int
DEFAULT_EDGE_TYPE
The default edge typestatic float
DEFAULT_FONT_SCALE
The default font scalestatic int
DEFAULT_FOREGROUND_COLOR
The default foreground colorstatic int
DEFAULT_IMAGE_SCALING_MODE
Default value for image scaling modestatic int
DEFAULT_LEFT_MARGIN
The default left margin in pixelsstatic int
DEFAULT_REGION_COLOR
The default region colorstatic int
DEFAULT_RIGHT_MARGIN
The default right margin in pixelsstatic int
DEFAULT_TOP_MARGIN
The default top margin in pixelsstatic Typeface
DEFAULT_TYPEFACE
The default typeface.static int
DEFAULT_WINDOW_COLOR
The default window colorboolean
drawBeyondVideoArea
Enable drawing beyond the video area therefore in case of video area and canvas area (video container) aspect mismatch, the text will go beyond the video areastatic int
EDGE_TYPE_DEPRESSED
Edge type value specifying depressed bevel character edges.static int
EDGE_TYPE_DROP_SHADOW
Edge type value specifying drop-shadowed character edges.static int
EDGE_TYPE_NONE
Edge type value specifying no character edges.static int
EDGE_TYPE_OUTLINE
Edge type value specifying uniformly outlined character edges.static int
EDGE_TYPE_RAISED
Edge type value specifying raised bevel character edges.int
edgeBlurRadius
The edge blur radius in pixels.int
edgeColor
The edge color as ARGB.int
edgeThickness
The edge thickness in pixels.int
edgeType
The Edge Type as one ofEDGE_TYPE_NONE
,EDGE_TYPE_OUTLINE
,EDGE_TYPE_DROP_SHADOW
,EDGE_TYPE_RAISED
, orEDGE_TYPE_DEPRESSED
float
fontScale
The font size scaling factorint
fontSize
The font size in pixels.int
foregroundColor
The text foreground color as ARGB.boolean
hasBackgroundColor
True if thebackgroundColor
was customized by the user and the setting should overwrite any content styles.boolean
hasEdgeBlurRadius
True if theedgeBlurRadius
was customized by the user and the setting should overwrite any content styles.boolean
hasEdgeColor
True if theedgeColor
was customized by the user and the setting should overwrite any content styles.boolean
hasEdgeThickness
True if theedgeThickness
was customized by the user and the setting should overwrite any content styles.boolean
hasEdgeType
True if theedgeType
was customized by the user and the setting should overwrite any content styles.boolean
hasFontSize
True if thefontSize
was customized by the user and the setting should overwrite any content styles.boolean
hasForegroundColor
True if theforegroundColor
was customized by the user and the setting should overwrite any content styles.boolean
hasRegionColor
True if theregionColor
was customized by the user and the setting should overwrite any content styles.boolean
hasTypeface
True if thetypeface
was customized by the user and the setting should overwrite any content styles.boolean
hasWindowColor
True if thewindowColor
was customized by the user and the setting should overwrite any content styles.static int
IMAGE_SCALE_FILL
Image scale mode specifying image will fill the container without taking aspect ratio into consideration.static int
IMAGE_SCALE_FIT
Image scale mode specifying image will be scaled as big as possible inside the container but keeping aspect ratio.static int
IMAGE_SCALE_WIDTH_BOTTOM
Image scale mode specifying image will be scaled to fill width of container and its height will be scaled keeping the aspect ratio, even if it results higher than the container.static int
IMAGE_SCALE_WIDTH_TOP
Image scale mode specifying image will be scaled to fill width of container and its height will be scaled keeping the aspect ratio, even if it results higher than the container.int
imageScalingMode
The image scaling mode for pre rendered subtitle images as one ofIMAGE_SCALE_FILL
,IMAGE_SCALE_WIDTH_BOTTOM
,IMAGE_SCALE_WIDTH_TOP
orIMAGE_SCALE_FIT
int
leftMargin
The margin in pixels applied to the subtitles located to the left of the vertical middle of the video viewint
regionColor
The region color as ARGB.int
rightMargin
The margin in pixels applied to the subtitles located to the right of the vertical middle of the video viewint
topMargin
The margin in pixels applied to the subtitles located above the horizontal middle of the video viewTypeface
typeface
int
windowColor
The window color as ARGB.-
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
describeContents()
boolean
equals(Object o)
int
hashCode()
void
writeToParcel(Parcel dest, int flags)
-
-
-
Field Detail
-
IMAGE_SCALE_FILL
public static final int IMAGE_SCALE_FILL
Image scale mode specifying image will fill the container without taking aspect ratio into consideration. This is the default behaviour.- See Also:
- Constant Field Values
-
IMAGE_SCALE_WIDTH_BOTTOM
public static final int IMAGE_SCALE_WIDTH_BOTTOM
Image scale mode specifying image will be scaled to fill width of container and its height will be scaled keeping the aspect ratio, even if it results higher than the container. Image will be aligned at the bottom of the container.- See Also:
- Constant Field Values
-
IMAGE_SCALE_WIDTH_TOP
public static final int IMAGE_SCALE_WIDTH_TOP
Image scale mode specifying image will be scaled to fill width of container and its height will be scaled keeping the aspect ratio, even if it results higher than the container. Image will be aligned at the top of the container.- See Also:
- Constant Field Values
-
IMAGE_SCALE_FIT
public static final int IMAGE_SCALE_FIT
Image scale mode specifying image will be scaled as big as possible inside the container but keeping aspect ratio.- See Also:
- Constant Field Values
-
EDGE_TYPE_NONE
public static final int EDGE_TYPE_NONE
Edge type value specifying no character edges.- See Also:
- Constant Field Values
-
EDGE_TYPE_OUTLINE
public static final int EDGE_TYPE_OUTLINE
Edge type value specifying uniformly outlined character edges.- See Also:
- Constant Field Values
-
EDGE_TYPE_DROP_SHADOW
public static final int EDGE_TYPE_DROP_SHADOW
Edge type value specifying drop-shadowed character edges.- See Also:
- Constant Field Values
-
EDGE_TYPE_RAISED
public static final int EDGE_TYPE_RAISED
Edge type value specifying raised bevel character edges.- See Also:
- Constant Field Values
-
EDGE_TYPE_DEPRESSED
public static final int EDGE_TYPE_DEPRESSED
Edge type value specifying depressed bevel character edges.- See Also:
- Constant Field Values
-
DEFAULT_FOREGROUND_COLOR
public static int DEFAULT_FOREGROUND_COLOR
The default foreground color
-
DEFAULT_BACKGROUND_COLOR
public static int DEFAULT_BACKGROUND_COLOR
The default background color
-
DEFAULT_WINDOW_COLOR
public static int DEFAULT_WINDOW_COLOR
The default window color
-
DEFAULT_EDGE_COLOR
public static int DEFAULT_EDGE_COLOR
The default edge color
-
DEFAULT_REGION_COLOR
public static int DEFAULT_REGION_COLOR
The default region color
-
DEFAULT_EDGE_THICKNESS
public static int DEFAULT_EDGE_THICKNESS
The default edge thickness in pixels
-
DEFAULT_EDGE_BLUR_RADIUS
public static int DEFAULT_EDGE_BLUR_RADIUS
The default edge blur radius in pixels
-
DEFAULT_EDGE_TYPE
public static int DEFAULT_EDGE_TYPE
The default edge type
-
DEFAULT_FONT_SCALE
public static float DEFAULT_FONT_SCALE
The default font scale
-
DEFAULT_BOTTOM_MARGIN
public static int DEFAULT_BOTTOM_MARGIN
The default bottom margin in pixels
-
DEFAULT_TOP_MARGIN
public static int DEFAULT_TOP_MARGIN
The default top margin in pixels
-
DEFAULT_LEFT_MARGIN
public static int DEFAULT_LEFT_MARGIN
The default left margin in pixels
-
DEFAULT_RIGHT_MARGIN
public static int DEFAULT_RIGHT_MARGIN
The default right margin in pixels
-
DEFAULT_DRAW_BEYOND_VIDEO_AREA
public static boolean DEFAULT_DRAW_BEYOND_VIDEO_AREA
The default draw beyond video area flag
-
DEFAULT_TYPEFACE
@NonNull public static Typeface DEFAULT_TYPEFACE
The default typeface. NULL us not permitted.
-
DEFAULT_IMAGE_SCALING_MODE
public static final int DEFAULT_IMAGE_SCALING_MODE
Default value for image scaling mode- See Also:
- Constant Field Values
-
foregroundColor
public final int foregroundColor
The text foreground color as ARGB. This also contains the alpha/opacity component of the color.
-
backgroundColor
public final int backgroundColor
The text background color as ARGB. This also contains the alpha/opacity component of the color.
-
windowColor
public final int windowColor
The window color as ARGB. This also contains the alpha/opacity component of the color.
-
edgeColor
public final int edgeColor
The edge color as ARGB. This also contains the alpha/opacity component of the color.
-
regionColor
public final int regionColor
The region color as ARGB. This also contains the alpha/opacity component of the color. This color can be used to overwrite any TTML span or region background colors.
-
edgeType
public final int edgeType
The Edge Type as one ofEDGE_TYPE_NONE
,EDGE_TYPE_OUTLINE
,EDGE_TYPE_DROP_SHADOW
,EDGE_TYPE_RAISED
, orEDGE_TYPE_DEPRESSED
-
edgeThickness
public final int edgeThickness
The edge thickness in pixels.
-
edgeBlurRadius
public final int edgeBlurRadius
The edge blur radius in pixels.
-
typeface
@NonNull public final Typeface typeface
-
fontScale
public final float fontScale
The font size scaling factor
-
fontSize
public final int fontSize
The font size in pixels. Note that thefontScale
will still be applied to the font size
-
hasFontSize
public final boolean hasFontSize
True if thefontSize
was customized by the user and the setting should overwrite any content styles.
-
hasForegroundColor
public final boolean hasForegroundColor
True if theforegroundColor
was customized by the user and the setting should overwrite any content styles.
-
hasBackgroundColor
public final boolean hasBackgroundColor
True if thebackgroundColor
was customized by the user and the setting should overwrite any content styles.
-
hasWindowColor
public final boolean hasWindowColor
True if thewindowColor
was customized by the user and the setting should overwrite any content styles.
-
hasEdgeColor
public final boolean hasEdgeColor
True if theedgeColor
was customized by the user and the setting should overwrite any content styles.
-
hasEdgeType
public final boolean hasEdgeType
True if theedgeType
was customized by the user and the setting should overwrite any content styles.
-
hasEdgeThickness
public final boolean hasEdgeThickness
True if theedgeThickness
was customized by the user and the setting should overwrite any content styles.
-
hasEdgeBlurRadius
public final boolean hasEdgeBlurRadius
True if theedgeBlurRadius
was customized by the user and the setting should overwrite any content styles.
-
hasTypeface
public final boolean hasTypeface
True if thetypeface
was customized by the user and the setting should overwrite any content styles.
-
hasRegionColor
public final boolean hasRegionColor
True if theregionColor
was customized by the user and the setting should overwrite any content styles.
-
bottomMargin
public final int bottomMargin
The margin in pixels applied to the subtitles located below the horizontal middle of the video view
-
topMargin
public final int topMargin
The margin in pixels applied to the subtitles located above the horizontal middle of the video view
-
leftMargin
public final int leftMargin
The margin in pixels applied to the subtitles located to the left of the vertical middle of the video view
-
rightMargin
public final int rightMargin
The margin in pixels applied to the subtitles located to the right of the vertical middle of the video view
-
imageScalingMode
public final int imageScalingMode
The image scaling mode for pre rendered subtitle images as one ofIMAGE_SCALE_FILL
,IMAGE_SCALE_WIDTH_BOTTOM
,IMAGE_SCALE_WIDTH_TOP
orIMAGE_SCALE_FIT
-
drawBeyondVideoArea
public final boolean drawBeyondVideoArea
Enable drawing beyond the video area therefore in case of video area and canvas area (video container) aspect mismatch, the text will go beyond the video area
-
CREATOR
public static final Parcelable.Creator<SubtitlesStyle> CREATOR
-
-
Method Detail
-
describeContents
public int describeContents()
- Specified by:
describeContents
in interfaceParcelable
-
writeToParcel
public void writeToParcel(Parcel dest, int flags)
- Specified by:
writeToParcel
in interfaceParcelable
-
-