BandwidthDebugChart.java
net.minecraft.client.gui.components.debugchart.BandwidthDebugChart
信息
- 全限定名:net.minecraft.client.gui.components.debugchart.BandwidthDebugChart
- 类型:public class
- 包:net.minecraft.client.gui.components.debugchart
- 源码路径:src/main/java/net/minecraft/client/gui/components/debugchart/BandwidthDebugChart.java
- 起始行号:L12
- 继承:AbstractDebugChart
- 职责:
TODO
字段/常量
-
MIN_COLOR- 类型:
int - 修饰符:
private static final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
MID_COLOR- 类型:
int - 修饰符:
private static final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
MAX_COLOR- 类型:
int - 修饰符:
private static final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
KILOBYTE- 类型:
int - 修饰符:
private static final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
MEGABYTE- 类型:
int - 修饰符:
private static final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
CHART_TOP_VALUE- 类型:
int - 修饰符:
private static final - 源码定位:
L18 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public BandwidthDebugChart(Font font, SampleStorage sampleStorage) @ L20
- 构造器名:BandwidthDebugChart
- 源码定位:L20
- 修饰符:public
参数:
- font: Font
- sampleStorage: SampleStorage
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected void extractAdditionalLinesAndLabels(GuiGraphicsExtractor graphics, int left, int width, int bottom) @ L24
- 方法名:extractAdditionalLinesAndLabels
- 源码定位:L24
- 返回类型:void
- 修饰符:protected
参数:
- graphics: GuiGraphicsExtractor
- left: int
- width: int
- bottom: int
说明:
TODO
private void extractLabeledLineAtValue(GuiGraphicsExtractor graphics, int left, int width, int bottom, int bytesPerSecond) @ L32
- 方法名:extractLabeledLineAtValue
- 源码定位:L32
- 返回类型:void
- 修饰符:private
参数:
- graphics: GuiGraphicsExtractor
- left: int
- width: int
- bottom: int
- bytesPerSecond: int
说明:
TODO
private void extractLineWithLabel(GuiGraphicsExtractor graphics, int x, int width, int y, String label) @ L36
- 方法名:extractLineWithLabel
- 源码定位:L36
- 返回类型:void
- 修饰符:private
参数:
- graphics: GuiGraphicsExtractor
- x: int
- width: int
- y: int
- label: String
说明:
TODO
protected String toDisplayString(double bytesPerTick) @ L41
- 方法名:toDisplayString
- 源码定位:L41
- 返回类型:String
- 修饰符:protected
参数:
- bytesPerTick: double
说明:
TODO
private static String toDisplayStringInternal(double bytesPerSecond) @ L46
- 方法名:toDisplayStringInternal
- 源码定位:L46
- 返回类型:String
- 修饰符:private static
参数:
- bytesPerSecond: double
说明:
TODO
protected int getSampleHeight(double bytesPerTick) @ L56
- 方法名:getSampleHeight
- 源码定位:L56
- 返回类型:int
- 修饰符:protected
参数:
- bytesPerTick: double
说明:
TODO
private static int getSampleHeightInternal(double bytesPerSecond) @ L61
- 方法名:getSampleHeightInternal
- 源码定位:L61
- 返回类型:int
- 修饰符:private static
参数:
- bytesPerSecond: double
说明:
TODO
protected int getSampleColor(long bytesPerTick) @ L65
- 方法名:getSampleColor
- 源码定位:L65
- 返回类型:int
- 修饰符:protected
参数:
- bytesPerTick: long
说明:
TODO
private static double toBytesPerSecond(double bytesPerTick) @ L70
- 方法名:toBytesPerSecond
- 源码定位:L70
- 返回类型:double
- 修饰符:private static
参数:
- bytesPerTick: double
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class BandwidthDebugChart extends AbstractDebugChart {
private static final int MIN_COLOR = -16711681;
private static final int MID_COLOR = -6250241;
private static final int MAX_COLOR = -65536;
private static final int KILOBYTE = 1024;
private static final int MEGABYTE = 1048576;
private static final int CHART_TOP_VALUE = 1048576;
public BandwidthDebugChart(Font font, SampleStorage sampleStorage) {
super(font, sampleStorage);
}
@Override
protected void extractAdditionalLinesAndLabels(GuiGraphicsExtractor graphics, int left, int width, int bottom) {
this.extractLabeledLineAtValue(graphics, left, width, bottom, 64);
this.extractLabeledLineAtValue(graphics, left, width, bottom, 1024);
this.extractLabeledLineAtValue(graphics, left, width, bottom, 16384);
this.extractStringWithShade(graphics, toDisplayStringInternal(1048576.0), left + 1, bottom - getSampleHeightInternal(1048576.0) + 1);
}
private void extractLabeledLineAtValue(GuiGraphicsExtractor graphics, int left, int width, int bottom, int bytesPerSecond) {
this.extractLineWithLabel(graphics, left, width, bottom - getSampleHeightInternal(bytesPerSecond), toDisplayStringInternal(bytesPerSecond));
}
private void extractLineWithLabel(GuiGraphicsExtractor graphics, int x, int width, int y, String label) {
this.extractStringWithShade(graphics, label, x + 1, y + 1);
graphics.horizontalLine(x, x + width - 1, y, -1);
}
@Override
protected String toDisplayString(double bytesPerTick) {
return toDisplayStringInternal(toBytesPerSecond(bytesPerTick));
}
private static String toDisplayStringInternal(double bytesPerSecond) {
if (bytesPerSecond >= 1048576.0) {
return String.format(Locale.ROOT, "%.1f MiB/s", bytesPerSecond / 1048576.0);
} else {
return bytesPerSecond >= 1024.0
? String.format(Locale.ROOT, "%.1f KiB/s", bytesPerSecond / 1024.0)
: String.format(Locale.ROOT, "%d B/s", Mth.floor(bytesPerSecond));
}
}
@Override
protected int getSampleHeight(double bytesPerTick) {
return getSampleHeightInternal(toBytesPerSecond(bytesPerTick));
}
private static int getSampleHeightInternal(double bytesPerSecond) {
return (int)Math.round(Math.log(bytesPerSecond + 1.0) * 60.0 / Math.log(1048576.0));
}
@Override
protected int getSampleColor(long bytesPerTick) {
return this.getSampleColor(toBytesPerSecond(bytesPerTick), 0.0, -16711681, 8192.0, -6250241, 1.048576E7, -65536);
}
private static double toBytesPerSecond(double bytesPerTick) {
return bytesPerTick * 20.0;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.floor()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: