private void clip(int availableWidth) {
		originalElement = textElement;
		int w = textElement.getStringWidth();

		if (w <= availableWidth) {
			textStartX = startX + availableWidth - w;
			return;
		}

		isClipped = true;
		// get the index of the start character that will fit
		startingCharIndex =
			textElement.getMaxCharactersForWidth(w - (availableWidth - DOT_DOT_DOT_WIDTH)) + 1;
		startingCharIndex = Math.min(startingCharIndex, textElement.length());
		textElement = textElement.substring(startingCharIndex);
		int margin = availableWidth - DOT_DOT_DOT_WIDTH - textElement.getStringWidth();
		margin = Math.max(margin, 0);
		dotdotdotStartX = startX + margin;
		textStartX = startX + DOT_DOT_DOT_WIDTH + margin;
	}
Checks if any of the textElements need to be clipped. If so, it creates a
new textElement for the element that needs to be clipped that will fit in
the available space. Any textElements past the clipped element will be
ignored.
Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/ReverseClippingTextField.java