Class Text
- java.lang.Object
-
- ch.andre601.fluxpoint4j.image.format.Text
-
- Direct Known Subclasses:
Text.MultiLine
,Text.SingleLine
public abstract class Text extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Text.MultiLine
Represents multiple lines to add.static class
Text.SingleLine
Represents a single text line to add.static class
Text.TextAlignment
Used to determine the text-alignment.
-
Constructor Summary
Constructors Constructor Description Text()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract Text
asBold(boolean bold)
Sets whether the text should be bold or not.abstract Text
asItalic(boolean italic)
Sets whether the text should be italic or not.abstract Text
asUnderline(boolean underline)
Sets whether the text should be underlined or not.abstract Text
withBackgroundColor(@NotNull ColorObject backgroundColor)
Sets the background color to use for the Text.abstract Text
withColor(@NotNull ColorObject color)
Sets the Text color to use.abstract Text
withFont(@NotNull java.lang.String font)
Sets the font to use for the text.abstract Text
withMaxHeight(int maxHeight)
Sets the maximum height the text should take.abstract Text
withMaxWidth(int maxWidth)
Sets the maximum width the text should take.abstract Text
withOutline(boolean outline)
Sets whether the text should have an outline or not.abstract Text
withOutlineBlur(int outlineBlur)
Sets the blur the outline should have.abstract Text
withOutlineColor(@NotNull ColorObject color)
Sets the outline color to use.abstract Text
withOutlineWidth(int outlineWidth)
Sets the width of the outline for the text.abstract Text
withPosX(int posX)
Sets the relative X (horizontal) position of the text, where 0 is the very left of the image.abstract Text
withPosY(int posY)
Sets the relative Y (vertical) position of the text, where 0 is the very top of the image.abstract Text
withSize(int size)
Sets the text size to use.abstract Text
withTextAlignment(@NotNull Text.TextAlignment textAlignment)
Sets the text-alignment this text has using the providedTextAlignment value
.abstract Text
withWeight(int weight)
Sets the font weight of this text.
-
-
-
Method Detail
-
withPosX
public abstract Text withPosX(int posX)
Sets the relative X (horizontal) position of the text, where 0 is the very left of the image.
The value can be between 0 andInteger.MAX_VALUE
(2147483647)An
IllegalArgumentException
may be thrown in the following case:- PosX is less than 0.
- Parameters:
posX
- The horizontal position of the text, relative to the image itself.- Returns:
- The Text instance. Useful for chaining.
-
withPosY
public abstract Text withPosY(int posY)
Sets the relative Y (vertical) position of the text, where 0 is the very top of the image.
The value can be between 0 andInteger.MAX_VALUE
(2147483647)An
IllegalArgumentException
may be thrown in the following case:- PosX is less than 0.
- Parameters:
posY
- The vertical position of the text, relative to the image itself.- Returns:
- The Text instance. Useful for chaining.
-
withTextAlignment
public abstract Text withTextAlignment(@NotNull @NotNull Text.TextAlignment textAlignment)
Sets the text-alignment this text has using the providedTextAlignment value
.
The text-alignment influences how the Text is positioned horizontally when usingwithPosX(int)
.- Parameters:
textAlignment
- The Text-alignment to use for this text.- Returns:
- The Text instance. Useful for chaining.
-
withSize
public abstract Text withSize(int size)
Sets the text size to use.An
IllegalArgumentException
may be thrown in the following case:- Size is 0 or less.
- Parameters:
size
- The size of the text.- Returns:
- The Text instance. Useful for chaining.
-
withFont
public abstract Text withFont(@NotNull @NotNull java.lang.String font)
Sets the font to use for the text.
Whether the provided font is valid and/or usable by the API depends on the Fluxpoint API itself and is nothing that can be checked in this library.An
IllegalArgumentException
may be thrown in the following case:- Font is an empty String.
- Parameters:
font
- The font to use.- Returns:
- The Text instance. Useful for chaining.
-
withColor
public abstract Text withColor(@NotNull @NotNull ColorObject color)
Sets the Text color to use.
Please see the documentation of theColorObject
for possible errors.- Parameters:
color
- The Color to use for the Text.- Returns:
- The Text instance. Useful for chaining.
-
withBackgroundColor
public abstract Text withBackgroundColor(@NotNull @NotNull ColorObject backgroundColor)
Sets the background color to use for the Text.
Please see the documentation of theColorObject
for possible errors.- Parameters:
backgroundColor
- The color to use for the text-background.- Returns:
- The Text instance. Useful for chaining.
-
asBold
public abstract Text asBold(boolean bold)
Sets whether the text should be bold or not.- Parameters:
bold
- Boolean to set if the text should be bold or not.- Returns:
- The Text instance. Useful for chaining.
-
asItalic
public abstract Text asItalic(boolean italic)
Sets whether the text should be italic or not.- Parameters:
italic
- Boolean to set if the text should be italic or not.- Returns:
- The Text instance. Useful for chaining.
-
asUnderline
public abstract Text asUnderline(boolean underline)
Sets whether the text should be underlined or not.- Parameters:
underline
- Boolean to set if the text should be underlined or not.- Returns:
- The Text instance. Useful for chaining.
-
withWeight
public abstract Text withWeight(int weight)
Sets the font weight of this text.
The value can be between 0 andInteger.MAX_VALUE
(2147483647) where 0 would essentially hide the text.An
IllegalArgumentException
may be thrown in the following case:- Weight is less than 0.
- Parameters:
weight
- The font weight to use.- Returns:
- The Text instance. Useful for chaining.
-
withMaxWidth
public abstract Text withMaxWidth(int maxWidth)
Sets the maximum width the text should take.
The value can be between 0 andInteger.MAX_VALUE
(2147483647) where 0 would essentially hide the text.An
IllegalArgumentException
may be thrown in the following case:- MaxWidth is less than 0.
- Parameters:
maxWidth
- The maximum width of the text.- Returns:
- The Text instance. Useful for chaining.
-
withMaxHeight
public abstract Text withMaxHeight(int maxHeight)
Sets the maximum height the text should take.
The value can be between 0 andInteger.MAX_VALUE
(2147483647) where 0 would essentially hide the text.An
IllegalArgumentException
may be thrown in the following case:- MaxHeight is less than 0.
- Parameters:
maxHeight
- The maximum height of the text.- Returns:
- The Text instance. Useful for chaining.
-
withOutline
public abstract Text withOutline(boolean outline)
Sets whether the text should have an outline or not.- Parameters:
outline
- Boolean to set if the text should have an outline.- Returns:
- The Text instance. Useful for chaining.
-
withOutlineWidth
public abstract Text withOutlineWidth(int outlineWidth)
Sets the width of the outline for the text.
This has no effect ifwithOutline(false)
(default value) is used.The value can be between 0 and
Integer.MAX_VALUE
(2147483647) where 0 would make the text have no outline.An
IllegalArgumentException
may be thrown in the following case:- OutlineWidth is less than 0.
- Parameters:
outlineWidth
- The width the outline should have.- Returns:
- The Text instance. Useful for chaining.
-
withOutlineColor
public abstract Text withOutlineColor(@NotNull @NotNull ColorObject color)
Sets the outline color to use.
This has no effect ifwithOutline(false)
(default value) is used.Please see the documentation of the
ColorObject
for possible errors.- Parameters:
color
- The color to use for the outline.- Returns:
- The Text instance. Useful for chaining.
-
withOutlineBlur
public abstract Text withOutlineBlur(int outlineBlur)
Sets the blur the outline should have.
This has no effect ifwithOutline(false)
(default value) is used.The value can be between 0 and
Integer.MAX_VALUE
(2147483647) where 0 would make the text have no outline blurring.An
IllegalArgumentException
may be thrown in the following case:- OutlineWidth is less than 0.
- Parameters:
outlineBlur
- The strength of the blurring for the outline.- Returns:
- The Text instance. Useful for chaining.
-
-