public static final String truncateIfNecessary(String text, int count, int truncationPolicy) {
		int tCount = text.length();

		count = tCount - count;
		if (count > 0) {
			count++; // Count is now the amount to remove from the string
			if (truncationPolicy == SwingConstants.LEFT) {
				return ELLIPSIS + text.substring(count);
			}
			if (truncationPolicy == SwingConstants.CENTER) {
				int remaining = tCount - count;
				int left = remaining / 2;
				int right = remaining - left;
				StringBuilder buffer = new StringBuilder(remaining + 1);

				if (left > 0) {
					buffer.append(text.substring(0, left));
				}
				buffer.append(ELLIPSIS);
				if (right > 0) {
					buffer.append(text.substring(tCount - right));
				}
				return buffer.toString();
			}
			return text.substring(0, tCount - count) + ELLIPSIS;
		}
		return text;
	}