private FieldElementResult addSideBorder(FieldElement element, int row, boolean center) {

		boolean isClipped = false;
		int ellipsisWidth = 0;
		String ellipsisText = EMPTY_STRING;

		int spaceWidth = getMetrics().charWidth(' ');
		int starWidth = getMetrics().charWidth('*');
		int fullStarWidth = stars.length() * starWidth;
		int sideStarWidth = 2 * starWidth;
		int sideSpaceWidth = 2 * spaceWidth;
		int availableWidth = fullStarWidth - sideStarWidth - sideSpaceWidth;
		if (availableWidth < element.getStringWidth()) {
			// not enough room; clip the text and add ellipses
			isClipped = true;
			ellipsisText = ELLIPSIS;
			ellipsisWidth = getMetrics().charWidth('.') * ELLIPSIS.length();
			availableWidth -= ellipsisWidth;
			int charsThatFit = element.getMaxCharactersForWidth(availableWidth);
			element = element.substring(0, charsThatFit); // clip
		}

		int paddingWidth = sideStarWidth + sideSpaceWidth;
		int currentTextWidth = paddingWidth + element.getStringWidth() + ellipsisWidth;
		int biggestCharWidth = Math.max(starWidth, spaceWidth);
		int paddingCharsNeeded = (width - currentTextWidth) / biggestCharWidth;
		int prePaddingCharCount = center ? paddingCharsNeeded / 2 : 0;
		int postPaddingCharCount = center ? (paddingCharsNeeded + 1) / 2 : paddingCharsNeeded;

		StringBuilder buffy = new StringBuilder();
		buffy.append('*').append(' ');
		addPaddingSpaces(buffy, prePaddingCharCount);

		FieldElement prefix = new TextFieldElement(
			new AttributedString(buffy.toString(), CommentColors.PLATE, getMetrics()), row, 0);

		FieldElement ellipsis = new TextFieldElement(
			new AttributedString(ellipsisText, CommentColors.PLATE, getMetrics()), row,
			prefix.length() + element.length());

		buffy.setLength(0);
		addPaddingSpaces(buffy, postPaddingCharCount);
		buffy.append(' ').append('*');

		FieldElement suffix = new TextFieldElement(
			new AttributedString(buffy.toString(), CommentColors.PLATE, getMetrics()), row,
			prefix.length() + element.length() + ellipsis.length());

		return new FieldElementResult(
			new CompositeFieldElement(new FieldElement[] { prefix, element, ellipsis, suffix }),
			isClipped);
	}
Constructor
@param model the model that the field belongs to.
@param hlProvider the HightLightStringProvider.
@param displayOptions the Options for display properties.
@param fieldOptions the Options for field specific properties.
Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PlateFieldFactory.java