private String getVisibleText(String text) {
        if (metrics.stringWidth(text) < width - 8) {
            return text;
        }
        else {
            String toReturn = "";
            for (char ch : text.toCharArray()) {
                if (metrics.stringWidth(toReturn + ch) < width - (14)) {
                    toReturn += ch;
                }
                else if (metrics.stringWidth(toReturn.substring(1) + ch) < width - (14)) {
                    toReturn = toReturn.substring(1) + ch;
                }
                else if (metrics.stringWidth(toReturn.substring(2) + ch) < width - (14)) {
                    toReturn = toReturn.substring(2) + ch;
                }
                else if (metrics.stringWidth(toReturn.substring(3) + ch) < width - (14)) {
                    toReturn = toReturn.substring(3) + ch;
                }
            }
            return toReturn;
        }
    }