MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / shortenToWidth

Method shortenToWidth

Minecraft-Utils/1.12.2/src/Variables.java:173–189  ·  view source on GitHub ↗
(String string, int width)

Source from the content-addressed store, hash-verified

171 }
172
173 @Override
174 public String shortenToWidth(String string, int width) {
175 if (StringUtils.isEmpty(string))
176 return string;
177 Validate.isTrue(width > 0);
178
179 boolean changed = false;
180 if (getStringWidth(string) > width) {
181 while (getStringWidth(string + "...") > width && !string.isEmpty()) {
182 string = string.substring(0, string.length() - 1);
183 changed = true;
184 }
185 }
186 if (changed)
187 string += "...";
188 return string;
189 }
190
191 @Override
192 public IButton createButton(int id, int x, int y, String label) {

Callers

nothing calls this directly

Calls 3

getStringWidthMethod · 0.95
isEmptyMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected