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

Method shortenToWidth

Minecraft-Utils/1.8/src/Variables.java:167–183  ·  view source on GitHub ↗
(String string, int width)

Source from the content-addressed store, hash-verified

165 }
166
167 @Override
168 public String shortenToWidth(String string, int width) {
169 if (StringUtils.isEmpty(string))
170 return string;
171 Validate.isTrue(width > 0);
172
173 boolean changed = false;
174 if (getStringWidth(string) > width) {
175 while (getStringWidth(string + "...") > width && !string.isEmpty()) {
176 string = string.substring(0, string.length() - 1);
177 changed = true;
178 }
179 }
180 if (changed)
181 string += "...";
182 return string;
183 }
184
185 @Override
186 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