Enum Class ObjectFit

java.lang.Object
java.lang.Enum<ObjectFit>
com.oorian.css.ObjectFit
All Implemented Interfaces:
Serializable, Comparable<ObjectFit>, Constable

public enum ObjectFit extends Enum<ObjectFit>
CSS object-fit property values for replaced element sizing.

The object-fit property specifies how the contents of a replaced element (like img or video) should be fitted to the box established by its width and height.

Fit Values:

  • fill: Stretches to fill box, may distort aspect ratio
  • contain: Scales to fit box, maintains aspect ratio
  • cover: Scales to cover box, maintains aspect ratio, may crop
  • none: No resizing, may overflow or underflow
  • scale-down: Behaves as none or contain, whichever is smaller

Usage:


 image.setObjectFit(ObjectFit.COVER);
 video.setObjectFit(ObjectFit.CONTAIN);
 
Since:
2024
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Scales content to fit inside the box, maintains aspect ratio.
    Scales content to cover the box, maintains aspect ratio, may crop.
    Stretches content to fill the box, may distort aspect ratio (default).
    Inherits from parent element.
    Sets to default value.
    Content is not resized.
    Rolls back to the value defined by a previous cascade origin.
    Rolls back to the value defined in the previous cascade layer.
    Behaves as none or contain, whichever results in smaller concrete object size.
    Resets the property to its inherited value or initial value.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the CSS value string.
    Returns the CSS value string.
    static ObjectFit
    Returns the enum constant of this class with the specified name.
    static ObjectFit[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • FILL

      public static final ObjectFit FILL
      Stretches content to fill the box, may distort aspect ratio (default).
    • CONTAIN

      public static final ObjectFit CONTAIN
      Scales content to fit inside the box, maintains aspect ratio.
    • COVER

      public static final ObjectFit COVER
      Scales content to cover the box, maintains aspect ratio, may crop.
    • NONE

      public static final ObjectFit NONE
      Content is not resized.
    • SCALE_DOWN

      public static final ObjectFit SCALE_DOWN
      Behaves as none or contain, whichever results in smaller concrete object size.
    • INITIAL

      public static final ObjectFit INITIAL
      Sets to default value.
    • INHERIT

      public static final ObjectFit INHERIT
      Inherits from parent element.
    • UNSET

      public static final ObjectFit UNSET
      Resets the property to its inherited value or initial value.
    • REVERT

      public static final ObjectFit REVERT
      Rolls back to the value defined by a previous cascade origin.
    • REVERT_LAYER

      public static final ObjectFit REVERT_LAYER
      Rolls back to the value defined in the previous cascade layer.
  • Method Details

    • values

      public static ObjectFit[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ObjectFit valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getValue

      public String getValue()
      Returns the CSS value string.
      Returns:
      the CSS value
    • toString

      public String toString()
      Returns the CSS value string.
      Overrides:
      toString in class Enum<ObjectFit>
      Returns:
      the CSS value