VideoMode.java

com.mojang.blaze3d.platform.VideoMode

信息

  • 全限定名:com.mojang.blaze3d.platform.VideoMode
  • 类型:public final class
  • 包:com.mojang.blaze3d.platform
  • 源码路径:src/main/java/com/mojang/blaze3d/platform/VideoMode.java
  • 起始行号:L15
  • 职责:

    TODO

字段/常量

  • width

    • 类型: int
    • 修饰符: private final
    • 源码定位: L16
    • 说明:

      TODO

  • height

    • 类型: int
    • 修饰符: private final
    • 源码定位: L17
    • 说明:

      TODO

  • redBits

    • 类型: int
    • 修饰符: private final
    • 源码定位: L18
    • 说明:

      TODO

  • greenBits

    • 类型: int
    • 修饰符: private final
    • 源码定位: L19
    • 说明:

      TODO

  • blueBits

    • 类型: int
    • 修饰符: private final
    • 源码定位: L20
    • 说明:

      TODO

  • refreshRate

    • 类型: int
    • 修饰符: private final
    • 源码定位: L21
    • 说明:

      TODO

  • PATTERN

    • 类型: Pattern
    • 修饰符: private static final
    • 源码定位: L22
    • 说明:

      TODO

内部类/嵌套类型

构造器

public VideoMode(int width, int height, int redBits, int greenBits, int blueBits, int refreshRate) @ L24

  • 构造器名:VideoMode
  • 源码定位:L24
  • 修饰符:public

参数:

  • width: int
  • height: int
  • redBits: int
  • greenBits: int
  • blueBits: int
  • refreshRate: int

说明:

TODO

public VideoMode(Buffer buffer) @ L33

  • 构造器名:VideoMode
  • 源码定位:L33
  • 修饰符:public

参数:

  • buffer: Buffer

说明:

TODO

public VideoMode(GLFWVidMode mode) @ L42

  • 构造器名:VideoMode
  • 源码定位:L42
  • 修饰符:public

参数:

  • mode: GLFWVidMode

说明:

TODO

方法

下面的方法块按源码顺序生成。

public int getWidth() @ L51

  • 方法名:getWidth
  • 源码定位:L51
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getHeight() @ L55

  • 方法名:getHeight
  • 源码定位:L55
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getRedBits() @ L59

  • 方法名:getRedBits
  • 源码定位:L59
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getGreenBits() @ L63

  • 方法名:getGreenBits
  • 源码定位:L63
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getBlueBits() @ L67

  • 方法名:getBlueBits
  • 源码定位:L67
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getRefreshRate() @ L71

  • 方法名:getRefreshRate
  • 源码定位:L71
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public boolean equals(Object o) @ L75

  • 方法名:equals
  • 源码定位:L75
  • 返回类型:boolean
  • 修饰符:public

参数:

  • o: Object

说明:

TODO

public int hashCode() @ L92

  • 方法名:hashCode
  • 源码定位:L92
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public String toString() @ L97

  • 方法名:toString
  • 源码定位:L97
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

public static Optional<VideoMode> read(String s) @ L102

  • 方法名:read
  • 源码定位:L102
  • 返回类型:Optional
  • 修饰符:public static

参数:

  • s: String

说明:

TODO

public String write() @ L137

  • 方法名:write
  • 源码定位:L137
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public final class VideoMode {
    private final int width;
    private final int height;
    private final int redBits;
    private final int greenBits;
    private final int blueBits;
    private final int refreshRate;
    private static final Pattern PATTERN = Pattern.compile("(\\d+)x(\\d+)(?:@(\\d+)(?::(\\d+))?)?");
 
    public VideoMode(int width, int height, int redBits, int greenBits, int blueBits, int refreshRate) {
        this.width = width;
        this.height = height;
        this.redBits = redBits;
        this.greenBits = greenBits;
        this.blueBits = blueBits;
        this.refreshRate = refreshRate;
    }
 
    public VideoMode(Buffer buffer) {
        this.width = buffer.width();
        this.height = buffer.height();
        this.redBits = buffer.redBits();
        this.greenBits = buffer.greenBits();
        this.blueBits = buffer.blueBits();
        this.refreshRate = buffer.refreshRate();
    }
 
    public VideoMode(GLFWVidMode mode) {
        this.width = mode.width();
        this.height = mode.height();
        this.redBits = mode.redBits();
        this.greenBits = mode.greenBits();
        this.blueBits = mode.blueBits();
        this.refreshRate = mode.refreshRate();
    }
 
    public int getWidth() {
        return this.width;
    }
 
    public int getHeight() {
        return this.height;
    }
 
    public int getRedBits() {
        return this.redBits;
    }
 
    public int getGreenBits() {
        return this.greenBits;
    }
 
    public int getBlueBits() {
        return this.blueBits;
    }
 
    public int getRefreshRate() {
        return this.refreshRate;
    }
 
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (o != null && this.getClass() == o.getClass()) {
            VideoMode videoMode = (VideoMode)o;
            return this.width == videoMode.width
                && this.height == videoMode.height
                && this.redBits == videoMode.redBits
                && this.greenBits == videoMode.greenBits
                && this.blueBits == videoMode.blueBits
                && this.refreshRate == videoMode.refreshRate;
        } else {
            return false;
        }
    }
 
    @Override
    public int hashCode() {
        return Objects.hash(this.width, this.height, this.redBits, this.greenBits, this.blueBits, this.refreshRate);
    }
 
    @Override
    public String toString() {
        return String.format(Locale.ROOT, "%sx%s@%s (%sbit)", this.width, this.height, this.refreshRate, this.redBits + this.greenBits + this.blueBits);
    }
 
    public static Optional<VideoMode> read(@Nullable String s) {
        if (s == null) {
            return Optional.empty();
        } else {
            try {
                Matcher m = PATTERN.matcher(s);
                if (m.matches()) {
                    int width = Integer.parseInt(m.group(1));
                    int height = Integer.parseInt(m.group(2));
                    String rateString = m.group(3);
                    int rate;
                    if (rateString == null) {
                        rate = 60;
                    } else {
                        rate = Integer.parseInt(rateString);
                    }
 
                    String bitString = m.group(4);
                    int bits;
                    if (bitString == null) {
                        bits = 24;
                    } else {
                        bits = Integer.parseInt(bitString);
                    }
 
                    int componentBits = bits / 3;
                    return Optional.of(new VideoMode(width, height, componentBits, componentBits, componentBits, rate));
                }
            } catch (Exception var9) {
            }
 
            return Optional.empty();
        }
    }
 
    public String write() {
        return String.format(Locale.ROOT, "%sx%s@%s:%s", this.width, this.height, this.refreshRate, this.redBits + this.greenBits + this.blueBits);
    }
}

引用的其他类

  • TropicalFish
    • 引用位置: 字段/方法调用
    • 关联成员: Pattern.compile()