Enum Class ScreenOrientation

java.lang.Object
java.lang.Enum<ScreenOrientation>
com.vaadin.flow.component.page.ScreenOrientation
All Implemented Interfaces:
Serializable, Comparable<ScreenOrientation>, Constable

public enum ScreenOrientation extends Enum<ScreenOrientation>
Represents the orientation of the browser screen.

Mirrors the values reported by the browser's Screen Orientation API, plus an UNKNOWN sentinel used before the first value has arrived from the client and an UNSUPPORTED sentinel for browsers that do not implement the API.

See Also:
  • Enum Constant Details

    • UNKNOWN

      public static final ScreenOrientation UNKNOWN
      No value has been reported by the browser yet. Used as the initial value of the signal before the first client handshake delivers a real one. In normal request handling the signal is seeded before any user code runs, so this value is essentially never observed in practice; once a real value has arrived, the signal never returns to UNKNOWN.
    • UNSUPPORTED

      public static final ScreenOrientation UNSUPPORTED
      The browser does not implement the Screen Orientation API. Distinct from UNKNOWN so callers can tell "no data yet" apart from "the platform will never produce data."
    • PORTRAIT_PRIMARY

      public static final ScreenOrientation PORTRAIT_PRIMARY
      The screen is in primary portrait orientation (the device is held upright in its natural portrait position).
    • PORTRAIT_SECONDARY

      public static final ScreenOrientation PORTRAIT_SECONDARY
      The screen is in secondary portrait orientation (the device is rotated 180° from PORTRAIT_PRIMARY).
    • LANDSCAPE_PRIMARY

      public static final ScreenOrientation LANDSCAPE_PRIMARY
      The screen is in primary landscape orientation (the device is rotated 90° clockwise from its natural portrait position).
    • LANDSCAPE_SECONDARY

      public static final ScreenOrientation LANDSCAPE_SECONDARY
      The screen is in secondary landscape orientation (the device is rotated 90° counter-clockwise from its natural portrait position).
  • Method Details

    • values

      public static ScreenOrientation[] 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 ScreenOrientation 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
    • getClientValue

      public String getClientValue()
      Returns the value as used by the browser's Screen Orientation API.
      Returns:
      the client-side orientation type string
    • isLandscape

      public boolean isLandscape()
      Returns true for the two landscape orientations (LANDSCAPE_PRIMARY, LANDSCAPE_SECONDARY). UNKNOWN and UNSUPPORTED return false.
      Returns:
      whether this is a landscape orientation
    • isPortrait

      public boolean isPortrait()
      Returns true for the two portrait orientations (PORTRAIT_PRIMARY, PORTRAIT_SECONDARY). UNKNOWN and UNSUPPORTED return false.
      Returns:
      whether this is a portrait orientation
    • fromClientValue

      public static ScreenOrientation fromClientValue(String clientValue)
      Returns the enum constant matching the given client-side orientation type string.
      Parameters:
      clientValue - the orientation type string from the browser
      Returns:
      the corresponding enum value
      Throws:
      IllegalArgumentException - if the value does not match any known orientation type