PingDebugChart.java

net.minecraft.client.gui.components.debugchart.PingDebugChart

信息

  • 全限定名:net.minecraft.client.gui.components.debugchart.PingDebugChart
  • 类型:public class
  • 包:net.minecraft.client.gui.components.debugchart
  • 源码路径:src/main/java/net/minecraft/client/gui/components/debugchart/PingDebugChart.java
  • 起始行号:L11
  • 继承:AbstractDebugChart
  • 职责:

    TODO

字段/常量

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

      TODO

内部类/嵌套类型

构造器

public PingDebugChart(Font font, SampleStorage sampleStorage) @ L14

  • 构造器名:PingDebugChart
  • 源码定位:L14
  • 修饰符:public

参数:

  • font: Font
  • sampleStorage: SampleStorage

说明:

TODO

方法

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

protected void extractAdditionalLinesAndLabels(GuiGraphicsExtractor graphics, int left, int width, int bottom) @ L18

  • 方法名:extractAdditionalLinesAndLabels
  • 源码定位:L18
  • 返回类型:void
  • 修饰符:protected

参数:

  • graphics: GuiGraphicsExtractor
  • left: int
  • width: int
  • bottom: int

说明:

TODO

protected String toDisplayString(double millis) @ L23

  • 方法名:toDisplayString
  • 源码定位:L23
  • 返回类型:String
  • 修饰符:protected

参数:

  • millis: double

说明:

TODO

protected int getSampleHeight(double millis) @ L28

  • 方法名:getSampleHeight
  • 源码定位:L28
  • 返回类型:int
  • 修饰符:protected

参数:

  • millis: double

说明:

TODO

protected int getSampleColor(long millis) @ L33

  • 方法名:getSampleColor
  • 源码定位:L33
  • 返回类型:int
  • 修饰符:protected

参数:

  • millis: long

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class PingDebugChart extends AbstractDebugChart {
    private static final int CHART_TOP_VALUE = 500;
 
    public PingDebugChart(Font font, SampleStorage sampleStorage) {
        super(font, sampleStorage);
    }
 
    @Override
    protected void extractAdditionalLinesAndLabels(GuiGraphicsExtractor graphics, int left, int width, int bottom) {
        this.extractStringWithShade(graphics, "500 ms", left + 1, bottom - 60 + 1);
    }
 
    @Override
    protected String toDisplayString(double millis) {
        return String.format(Locale.ROOT, "%d ms", (int)Math.round(millis));
    }
 
    @Override
    protected int getSampleHeight(double millis) {
        return (int)Math.round(millis * 60.0 / 500.0);
    }
 
    @Override
    protected int getSampleColor(long millis) {
        return this.getSampleColor(millis, 0.0, -16711936, 250.0, -256, 500.0, -65536);
    }
}

引用的其他类