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

Method shortenToWidth

Minecraft-Utils/1.8.9/src/Variables.java:174–190  ·  view source on GitHub ↗
(String string, int width)

Source from the content-addressed store, hash-verified

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