Package com.castlabs.subtitles.presentation

# Class SubtitlesStyle

java.lang.Object
com.castlabs.subtitles.presentation.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 ARGB
- `DEFAULT_BACKGROUND_COLOR` -- The default background color as ARGB
- `DEFAULT_WINDOW_COLOR` -- The default window color as ARGB
- `DEFAULT_EDGE_COLOR` -- The default edge color as ARGB
- `DEFAULT_EDGE_TYPE` -- The default edge type
- `DEFAULT_FONT_SCALE` -- The default font scale
- `DEFAULT_TYPEFACE` -- The default typeface

Instances of this class can be created using the `SubtitlesStyle.Builder` and its `SubtitlesStyle.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 the `overwrite` flag is set to `true`, 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.DisplayAlign`
  `static @interface`
  `SubtitlesStyle.EdgeType`
  `static @interface`
  `SubtitlesStyle.ImageScalingMode`
  `static @interface`
  `SubtitlesStyle.TextAlign`

  ## Nested classes/interfaces inherited from interface android.os.Parcelable

  `Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final int`
  `backgroundColor`
  The text background color as ARGB.
  `final int`
  `bottomMargin`
  The margin in pixels applied to the subtitles located below the horizontal middle of the video view
  `static final Parcelable.Creator<SubtitlesStyle>`
  `CREATOR`
  `static int`
  `DEFAULT_BACKGROUND_COLOR`
  The default background color
  `static int`
  `DEFAULT_BOTTOM_MARGIN`
  The default bottom margin in pixels
  `static final int`
  `DEFAULT_DISPLAY_ALIGN`
  Text align value specifying vertical default alignment
  `static boolean`
  `DEFAULT_DRAW_BEYOND_VIDEO_AREA`
  The default draw beyond video area flag
  `static int`
  `DEFAULT_EDGE_BLUR_RADIUS`
  The default edge blur radius in pixels
  `static int`
  `DEFAULT_EDGE_COLOR`
  The default edge color
  `static int`
  `DEFAULT_EDGE_THICKNESS`
  The default edge thickness in pixels
  `static int`
  `DEFAULT_EDGE_TYPE`
  The default edge type
  `static float`
  `DEFAULT_FONT_SCALE`
  The default font scale
  `static int`
  `DEFAULT_FOREGROUND_COLOR`
  The default foreground color
  `static final int`
  `DEFAULT_IMAGE_SCALING_MODE`
  Default value for image scaling mode
  `static int`
  `DEFAULT_LEFT_MARGIN`
  The default left margin in pixels
  `static int`
  `DEFAULT_REGION_COLOR`
  The default region color
  `static int`
  `DEFAULT_RIGHT_MARGIN`
  The default right margin in pixels
  `static final int`
  `DEFAULT_TEXT_ALIGN`
  Text align value specifying horizontal default alignment
  `static int`
  `DEFAULT_TOP_MARGIN`
  The default top margin in pixels
  `static Typeface`
  `DEFAULT_TYPEFACE`
  The default typeface.
  `static int`
  `DEFAULT_WINDOW_COLOR`
  The default window color
  `final boolean`
  `disableAutoFlowText`
  If set to true the auto-flow text behaviour will be disabled regardless of the font-size and the font-scale.
  `static final int`
  `DISPLAY_ALIGN_AFTER`
  Text align value specifying vertical alignment to the bottom
  `static final int`
  `DISPLAY_ALIGN_BEFORE`
  Text align value specifying vertical alignment to the top
  `static final int`
  `DISPLAY_ALIGN_CENTER`
  Text align value specifying vertical alignment to the center
  `final int`
  `displayAlign`
  The display alignment
  `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
  `static final int`
  `EDGE_TYPE_DEPRESSED`
  Edge type value specifying depressed bevel character edges.
  `static final int`
  `EDGE_TYPE_DROP_SHADOW`
  Edge type value specifying drop-shadowed character edges.
  `static final int`
  `EDGE_TYPE_NONE`
  Edge type value specifying no character edges.
  `static final int`
  `EDGE_TYPE_OUTLINE`
  Edge type value specifying uniformly outlined character edges.
  `static final int`
  `EDGE_TYPE_RAISED`
  Edge type value specifying raised bevel character edges.
  `final int`
  `edgeBlurRadius`
  The edge blur radius in pixels.
  `final int`
  `edgeColor`
  The edge color as ARGB.
  `final int`
  `edgeThickness`
  The edge thickness in pixels.
  `final int`
  `edgeType`
  The Edge Type as one of `EDGE_TYPE_NONE`, `EDGE_TYPE_OUTLINE`, `EDGE_TYPE_DROP_SHADOW`, `EDGE_TYPE_RAISED`, or `EDGE_TYPE_DEPRESSED`
  `final float`
  `fontScale`
  The font size scaling factor
  `final int`
  `fontSize`
  The font size in pixels.
  `final int`
  `foregroundColor`
  The text foreground color as ARGB.
  `final boolean`
  `hasBackgroundColor`
  True if the `backgroundColor` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasEdgeBlurRadius`
  True if the `edgeBlurRadius` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasEdgeColor`
  True if the `edgeColor` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasEdgeThickness`
  True if the `edgeThickness` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasEdgeType`
  True if the `edgeType` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasFontSize`
  True if the `fontSize` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasForegroundColor`
  True if the `foregroundColor` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasRegionAutoSizedToFit`
  True if the `regionAutoSizedToFit` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasRegionColor`
  True if the `regionColor` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasTypeface`
  True if the `typeface` was customized by the user and the setting should overwrite any content styles.
  `final boolean`
  `hasWindowColor`
  True if the `windowColor` was customized by the user and the setting should overwrite any content styles.
  `static final int`
  `IMAGE_SCALE_FILL`
  Image scale mode specifying image will fill the container without taking aspect ratio into consideration.
  `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.
  `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.
  `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.
  `final int`
  `imageScalingMode`
  The image scaling mode for pre rendered subtitle images as one of `IMAGE_SCALE_FILL`, `IMAGE_SCALE_WIDTH_BOTTOM`, `IMAGE_SCALE_WIDTH_TOP` or `IMAGE_SCALE_FIT`
  `final int`
  `leftMargin`
  The margin in pixels applied to the subtitles located to the left of the vertical middle of the video view
  `final boolean`
  `regionAutoSizedToFit`
  Whether the region will be automatically sized to fit
  `final int`
  `regionColor`
  The region color as ARGB.
  `final int`
  `rightMargin`
  The margin in pixels applied to the subtitles located to the right of the vertical middle of the video view
  `static final int`
  `TEXT_ALIGN_CENTER`
  Text align value specifying horizontal alignment to the center
  `static final int`
  `TEXT_ALIGN_END`
  Text align value specifying horizontal alignment to the end
  `static final int`
  `TEXT_ALIGN_LEFT`
  Text align value specifying horizontal alignment to the left
  `static final int`
  `TEXT_ALIGN_RIGHT`
  Text align value specifying horizontal alignment to the right
  `static final int`
  `TEXT_ALIGN_START`
  Text align value specifying horizontal alignment to the start
  `final int`
  `textAlign`
  The text alignment
  `final int`
  `topMargin`
  The margin in pixels applied to the subtitles located above the horizontal middle of the video view
  `final Typeface`
  `typeface`
  `final int`
  `windowColor`
  The window color as ARGB.

  ### Fields inherited from interface android.os.Parcelable

  `CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `SubtitlesStyle(Parcel in)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `describeContents()`
  `boolean`
  `equals(Object o)`
  `int`
  `hashCode()`
  `void`
  `writeToParcel(Parcel dest, int flags)`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### 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_TEXT_ALIGN

    public static final int DEFAULT_TEXT_ALIGN
    Text align value specifying horizontal default alignment
    See Also:
      - Constant Field Values

  - ### TEXT_ALIGN_LEFT

    public static final int TEXT_ALIGN_LEFT
    Text align value specifying horizontal alignment to the left
    See Also:
      - Constant Field Values

  - ### TEXT_ALIGN_CENTER

    public static final int TEXT_ALIGN_CENTER
    Text align value specifying horizontal alignment to the center
    See Also:
      - Constant Field Values

  - ### TEXT_ALIGN_RIGHT

    public static final int TEXT_ALIGN_RIGHT
    Text align value specifying horizontal alignment to the right
    See Also:
      - Constant Field Values

  - ### TEXT_ALIGN_START

    public static final int TEXT_ALIGN_START
    Text align value specifying horizontal alignment to the start
    See Also:
      - Constant Field Values

  - ### TEXT_ALIGN_END

    public static final int TEXT_ALIGN_END
    Text align value specifying horizontal alignment to the end
    See Also:
      - Constant Field Values

  - ### DEFAULT_DISPLAY_ALIGN

    public static final int DEFAULT_DISPLAY_ALIGN
    Text align value specifying vertical default alignment
    See Also:
      - Constant Field Values

  - ### DISPLAY_ALIGN_BEFORE

    public static final int DISPLAY_ALIGN_BEFORE
    Text align value specifying vertical alignment to the top
    See Also:
      - Constant Field Values

  - ### DISPLAY_ALIGN_CENTER

    public static final int DISPLAY_ALIGN_CENTER
    Text align value specifying vertical alignment to the center
    See Also:
      - Constant Field Values

  - ### DISPLAY_ALIGN_AFTER

    public static final int DISPLAY_ALIGN_AFTER
    Text align value specifying vertical alignment to the bottom
    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 of `EDGE_TYPE_NONE`, `EDGE_TYPE_OUTLINE`, `EDGE_TYPE_DROP_SHADOW`, `EDGE_TYPE_RAISED`, or `EDGE_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 the `fontScale` will still be applied to the font size

  - ### hasFontSize

    public final boolean hasFontSize
    True if the `fontSize` was customized by the user and the setting should overwrite any content styles.

  - ### disableAutoFlowText

    public final boolean disableAutoFlowText
    If set to true the auto-flow text behaviour will be disabled regardless of the font-size and the font-scale.

  - ### regionAutoSizedToFit

    public final boolean regionAutoSizedToFit
    Whether the region will be automatically sized to fit

  - ### hasRegionAutoSizedToFit

    public final boolean hasRegionAutoSizedToFit
    True if the `regionAutoSizedToFit` was customized by the user and the setting should overwrite any content styles.

  - ### textAlign

    public final int textAlign
    The text alignment

  - ### displayAlign

    public final int displayAlign
    The display alignment

  - ### hasForegroundColor

    public final boolean hasForegroundColor
    True if the `foregroundColor` was customized by the user and the setting should overwrite any content styles.

  - ### hasBackgroundColor

    public final boolean hasBackgroundColor
    True if the `backgroundColor` was customized by the user and the setting should overwrite any content styles.

  - ### hasWindowColor

    public final boolean hasWindowColor
    True if the `windowColor` was customized by the user and the setting should overwrite any content styles.

  - ### hasEdgeColor

    public final boolean hasEdgeColor
    True if the `edgeColor` was customized by the user and the setting should overwrite any content styles.

  - ### hasEdgeType

    public final boolean hasEdgeType
    True if the `edgeType` was customized by the user and the setting should overwrite any content styles.

  - ### hasEdgeThickness

    public final boolean hasEdgeThickness
    True if the `edgeThickness` was customized by the user and the setting should overwrite any content styles.

  - ### hasEdgeBlurRadius

    public final boolean hasEdgeBlurRadius
    True if the `edgeBlurRadius` was customized by the user and the setting should overwrite any content styles.

  - ### hasTypeface

    public final boolean hasTypeface
    True if the `typeface` was customized by the user and the setting should overwrite any content styles.

  - ### hasRegionColor

    public final boolean hasRegionColor
    True if the `regionColor` 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 of `IMAGE_SCALE_FILL`, `IMAGE_SCALE_WIDTH_BOTTOM`, `IMAGE_SCALE_WIDTH_TOP` or `IMAGE_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

- ## Constructor Details

  - ### SubtitlesStyle

    protected SubtitlesStyle(Parcel in)

- ## Method Details

  - ### describeContents

    public int describeContents()
    Specified by:
      `describeContents` in interface `Parcelable`

  - ### writeToParcel

    public void writeToParcel(Parcel dest, int flags)
    Specified by:
      `writeToParcel` in interface `Parcelable`

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`