private int buildAttributedByteValues(FieldElement[] elements, int pos, byte[] bytes, int size,
			int residual, Color color, boolean addDelimiter) {
		StringBuilder buffer = new StringBuilder();
		int groupSize = byteGroupSize - residual;
		int tempGroupSize = 0;
		for (int i = 0; i < size; ++i) {
			if (bytes[i] >= 0x00 && bytes[i] <= 0x0F) {
				buffer.append("0");
			}
			String bStr = Integer.toHexString(bytes[i] & 0x000000FF);
			if (bStr.length() > 2) {
				bStr = bStr.substring(bStr.length() - 2);
			}
			if (displayUpperCase) {
				bStr = bStr.toUpperCase();
			}
			buffer.append(bStr);
			++tempGroupSize;
			if (tempGroupSize == groupSize) {
				tempGroupSize = 0;
				groupSize = byteGroupSize;
				if (i < size - 1 || addDelimiter) {
					buffer.append(delim);
				}
				AttributedString as = new AttributedString(buffer.toString(), color, getMetrics());
				elements[pos] = new TextFieldElement(as, pos, 0);
				pos++;
				buffer = new StringBuilder();
			}
		}

		// append incomplete byte group...
		if (tempGroupSize > 0) {
			AttributedString as = new AttributedString(buffer.toString(), color, getMetrics());
			elements[pos] = new TextFieldElement(as, pos, 0);
		}
		return tempGroupSize;
	}
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/BytesFieldFactory.java