Package org.boxutil.units.standard.misc
Class TextFieldObject
java.lang.Object
org.boxutil.units.standard.misc.TextFieldObject
Easy way for rendering text anywhere.
The compatibility simple rendering object in lower version, a substitute for TextFieldEntity.
Vanilla supported.
One of the ways for how to change the text content in existed TextData:
TextFieldObject text;
final var data = text.getTextDataList().get(0); // if the text content was in the index 0
data.setText("another text");
// and then call submit
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final byteprotected List<TextFieldEntity.TextData>protected List<org.lwjgl.util.vector.Vector3f>protected TextSubmitFeedbackAPIprotected final SpinLockprotected TextFieldEntity.Alignmentprotected ByteBufferprotected FontMapDataprotected booleanprotected final float[]protected final int[]protected final float[]protected FloatBufferprotected FloatBuffer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TextFieldEntity.TextDatacreateTextData(String text, float padding, Color color, boolean italic) intfloatfloatAfter calledsubmitText().floatAfter calledsubmitText().floatfloatintfloatfloatintvoidglDraw(boolean useVertexColor) booleanbooleanbooleanbytemallocTextData(int charNum) Optional.protected voidreallocateBuffer(int num) voidrender(org.lwjgl.util.vector.Vector2f location, float facing, boolean isAdditiveBlend, Color globalColor) General rendering method.replaceTextAtParagraph(String text, float padding, int paragraphIndex) replaceTextAtParagraph(String text, float padding, Color color, boolean italic, int paragraphIndex) replaceTextAtParagraph(String text, int paragraphIndex) voidreset()voidvoidsetAlignment(TextFieldEntity.Alignment alignment) voidvoidsetFieldHeight(float height) voidsetFieldSize(float width, float height) voidsetFieldWidth(float width) voidsetFontHeightSpace(float space) voidsetFontMap(String fontPath) voidsetFontMap(FontMapData map) voidsetFontSpace(float width, float height) voidsetFontWidthSpace(float space) voidsetItalicFactor(float angle) voidsetItalicFactorDirect(float value) voidsetRefreshRenderingLengthWhenSubmit(boolean refresh) voidsetShouldRenderingCharCount(int charNum) voidvoidvoidsetTextDataRefreshIndex(int index) voidsetTextDataRefreshSize(int size) byteIf insufficient space exists on allocated buffer space, will lose data what the text data is not include in current submit.
-
Field Details
-
_DEFAULT_PAD
protected static final byte _DEFAULT_PAD- See Also:
-
fontMap
-
textDataRefreshState
protected final int[] textDataRefreshState -
textStateAfterSubmit
protected final float[] textStateAfterSubmit -
state
protected final float[] state -
_sync_lock
-
isRefreshRenderingLengthWhenSubmit
protected boolean isRefreshRenderingLengthWhenSubmit -
vertexBuffer
-
uvBuffer
-
colorBuffer
-
_lastTextDataList
-
_lastTextDataState
-
_submitFeedback
-
alignment
-
-
Constructor Details
-
TextFieldObject
public TextFieldObject() -
TextFieldObject
-
TextFieldObject
-
-
Method Details
-
getFontMap
-
setFontMap
-
setFontMap
-
reset
public void reset() -
resetText
public void resetText() -
render
public void render(org.lwjgl.util.vector.Vector2f location, float facing, boolean isAdditiveBlend, @Nullable Color globalColor) General rendering method.Anchor at top-left.
-
glDraw
public void glDraw(boolean useVertexColor) -
createTextData
protected TextFieldEntity.TextData createTextData(String text, float padding, Color color, boolean italic) -
addText
-
addText
-
addText
-
addText
-
addText
-
addText
-
replaceTextAtParagraph
public TextFieldEntity.TextData replaceTextAtParagraph(@NotNull String text, float padding, Color color, boolean italic, int paragraphIndex) - Parameters:
padding- offset when line feed.- Returns:
- the text data previously at the specified position.
-
replaceTextAtParagraph
public TextFieldEntity.TextData replaceTextAtParagraph(@NotNull String text, float padding, int paragraphIndex) - Parameters:
padding- offset when line feed.- Returns:
- the text data previously at the specified position.
-
replaceTextAtParagraph
- Returns:
- the text data previously at the specified position.
-
reallocateBuffer
protected void reallocateBuffer(int num) -
submitText
public byte submitText()If insufficient space exists on allocated buffer space, will lose data what the text data is not include in current submit.- Returns:
- return
BoxEnum.STATE_SUCCESSwhen success.return
BoxEnum.STATE_FAILEDwhen an empty text data list or refresh count is zero.return
BoxEnum.STATE_FAILED_OTHERwhen happened another error.
-
mallocTextData
public byte mallocTextData(int charNum) Optional.Just
malloc()without any submit call.- Parameters:
charNum- must be positive integer.- Returns:
- return
BoxEnum.STATE_SUCCESSwhen success.return
BoxEnum.STATE_FAILEDwhen parameter error.return
BoxEnum.STATE_FAILED_OTHERwhen happened another error.
-
getSubmitFeedback
-
setSubmitFeedback
-
isRefreshRenderingLengthWhenSubmit
public boolean isRefreshRenderingLengthWhenSubmit() -
setRefreshRenderingLengthWhenSubmit
public void setRefreshRenderingLengthWhenSubmit(boolean refresh) -
getTextDataRefreshIndex
public int getTextDataRefreshIndex() -
setTextDataRefreshIndex
public void setTextDataRefreshIndex(int index) - Parameters:
index- Will refresh text data start from the index.
-
setTextDataRefreshSize
public void setTextDataRefreshSize(int size) - Parameters:
size- Will refresh text data count.
-
setTextDataRefreshAllFromCurrentIndex
public void setTextDataRefreshAllFromCurrentIndex() -
getTextDataList
-
getAllocatedValidCharLength
public int getAllocatedValidCharLength() -
haveAllocatedValidCharLength
public boolean haveAllocatedValidCharLength() -
getValidCharLength
public int getValidCharLength() -
isValidRenderingTextField
public boolean isValidRenderingTextField() -
setShouldRenderingCharCount
public void setShouldRenderingCharCount(int charNum) -
getAlignment
-
setAlignment
-
getFontWidthSpace
public float getFontWidthSpace() -
getFontHeightSpace
public float getFontHeightSpace() -
getTextFieldWidth
public float getTextFieldWidth() -
getTextFieldHeight
public float getTextFieldHeight() -
setFontWidthSpace
public void setFontWidthSpace(float space) - Parameters:
space- interval to previous font.
-
setFontHeightSpace
public void setFontHeightSpace(float space) - Parameters:
space- line interval to previous line of same(only) text data.
-
setFontSpace
public void setFontSpace(float width, float height) -
setFieldWidth
public void setFieldWidth(float width) -
setFieldHeight
public void setFieldHeight(float height) -
setFieldSize
public void setFieldSize(float width, float height) -
getCurrentVisualWidth
public float getCurrentVisualWidth()After calledsubmitText().But only counts for last submit call, not for the entity.
-
getCurrentVisualHeight
public float getCurrentVisualHeight()After calledsubmitText(). -
getCurrentItalicFactor
public float getCurrentItalicFactor() -
setItalicFactor
public void setItalicFactor(float angle) - Parameters:
angle- range at [-90, 90].
-
setItalicFactorDirect
public void setItalicFactorDirect(float value) - Parameters:
value- value of sin, and angle range at [-90, 90].
-
setDefaultItalicFactor
public void setDefaultItalicFactor()
-