Enum Class Orientation

java.lang.Object
java.lang.Enum<Orientation>
cloud.opencode.base.pdf.document.Orientation
All Implemented Interfaces:
Serializable, Comparable<Orientation>, Constable

public enum Orientation extends Enum<Orientation>
Page Orientation - Portrait or Landscape 页面方向 - 纵向或横向

Features | 主要功能:

  • Portrait and landscape orientation constants - 纵向和横向方向常量
  • Dimension adjustment based on orientation - 根据方向调整尺寸

Usage Examples | 使用示例:

Orientation orient = Orientation.LANDSCAPE;
float[] dims = orient.apply(595, 842); // swaps to [842, 595]

Security | 安全性:

  • Thread-safe: Yes — immutable enum - 线程安全: 是 — 不可变枚举
  • Null-safe: N/A — enum values are never null - 空值安全: 不适用 — 枚举值不会为空
Since:
JDK 25, opencode-base-pdf V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Enum Constant Details

    • PORTRAIT

      public static final Orientation PORTRAIT
      Portrait orientation (height > width) 纵向(高度 > 宽度)
    • LANDSCAPE

      public static final Orientation LANDSCAPE
      Landscape orientation (width > height) 横向(宽度 > 高度)
  • Method Details

    • values

      public static Orientation[] 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 Orientation 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
    • isPortrait

      public boolean isPortrait()
      Checks if this is portrait orientation 检查是否为纵向
      Returns:
      true if portrait | 如果纵向返回 true
    • isLandscape

      public boolean isLandscape()
      Checks if this is landscape orientation 检查是否为横向
      Returns:
      true if landscape | 如果横向返回 true
    • apply

      public float[] apply(float width, float height)
      Applies orientation to page dimensions 将方向应用于页面尺寸
      Parameters:
      width - original width | 原始宽度
      height - original height | 原始高度
      Returns:
      adjusted dimensions [width, height] | 调整后的尺寸 [宽, 高]