java.lang.Object
org.refcodes.textual.TextBorderBuilder
- All Implemented Interfaces:
org.refcodes.graphical.BoxBorderModeAccessor
,org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>
,org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeMutator
,org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty
,Text<TextBorderBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<TextBorderBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
,TextBoxGridAccessor
,TextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
,TextBoxGridAccessor.TextBoxGridMutator
,TextBoxGridAccessor.TextBoxGridProperty
public class TextBorderBuilder
extends Object
implements org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>, TextBoxGridAccessor.TextBoxGridProperty, TextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
"Draws" a border around a text. The text border can be provided by adjusting
properties such as the
TableStyle
or the BoxBorderMode
. When
providing a TableStyle
, then the TableStyle.getBody()
characters are used to draw the border.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.graphical.BoxBorderModeAccessor
org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<B extends org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<B>>, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeMutator, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty
Nested classes/interfaces inherited from interface org.refcodes.textual.TextAccessor
TextAccessor.TextBuilder<B extends TextAccessor.TextBuilder<B>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider
Nested classes/interfaces inherited from interface org.refcodes.textual.TextBoxGridAccessor
TextBoxGridAccessor.TextBoxGridBuilder<B extends TextBoxGridAccessor.TextBoxGridBuilder<?>>, TextBoxGridAccessor.TextBoxGridMutator, TextBoxGridAccessor.TextBoxGridProperty
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionchar
Retrieves the border char from the border char property.int
Retrieves the border width from the border width property.org.refcodes.graphical.BoxBorderMode
String[]
getText()
Retrieves the text from the text property.Gets the currently setTextBoxGrid
being used.void
setBorderChar
(char aBorderChar) Sets the border char for the border char property.void
setBorderWidth
(int aBorderWidth) Sets the border width for the border width property.void
setBoxBorderMode
(org.refcodes.graphical.BoxBorderMode aBoxBorderMode) void
Sets the text for the text property.void
setTextBoxGrid
(TextBoxGrid aTextBoxGrid) Sets theTextBoxGrid
to be used.void
setTextBoxStyle
(TextBoxStyle aTextBoxStyle) protected static String[]
toAsciiBorder
(String[] aText) Adds a predefined "single-line" border to the provided text.protected static String[]
toBorder
(String[] aText, char aTopLeftBorderChar, char aTopRightBorderChar, char aBottomLeftBorderChar, char aBottomRightBorderChar, char aTopBorderChar, char aRightBorderChar, char aBottomBorderChar, char aLeftBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode) Adds a predefined border according border to the provided text.static String[]
toBorder
(String[] aText, int aBorderWidth, char aBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode) Adds the according border with the given char and the provided width to the provided text.protected static String[]
toBottomBorder
(String[] aText, int aBorderWidth, char aBorderChar) Adds the according border with the given char and the provided width to the provided text.protected static String[]
toDoubleBorder
(String[] aText) Adds a predefined "double-line" border to the provided text.protected static String[]
toLeftBorder
(String[] aText, int aBorderWidth, char aBorderChar) Adds the according border with the given char and the provided witdh to the provided text.protected static String
toLine
(int aLength, char aFillChar) Returns aString
with the given length and containing only the provided fill character.protected static String[]
toRightBorder
(String[] aText, int aBorderWidth, char aBorderChar) Adds the according border with the given char and the provided width to the provided text.protected static String[]
toSingleBorder
(String[] aText) Adds a predefined "single-line" border to the provided text.toString()
TheString
being build by the builder upon the settings of the attributes.Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
.String[]
TheString
s being build by the builder upon the settings of the attributes.String[]
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
.protected static String[]
toTopBorder
(String[] aText, int aBorderWidth, char aBorderChar) Adds the according border with the given char and the provided width to the provided text.withBorderChar
(char aBorderChar) Sets the border char for the border char property.withBorderWidth
(int aBorderWidth) Sets the border width for the border width property.withBoxBorderMode
(org.refcodes.graphical.BoxBorderMode aBoxBorderMode) With text.withText
(Collection<String> aText) With text.withTextBoxGrid
(TextBoxGrid aTextBoxGrid) Sets the rowsTextBoxGrid
to use returns this builder as of the Builder-Pattern.withTextBoxGrid
(TextBoxStyle aTextBoxStyle) Sets the rowsTextBoxGrid
to use returns this builder as of the Builder-Pattern.withTextBoxStyle
(TextBoxStyle aTextBoxStyle) Convenience method forwithTextBoxGrid(TextBoxGrid)
to set theTextBoxGrid
from aTextBoxStyle
valueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty
letBoxBorderMode
Methods inherited from interface org.refcodes.textual.TextAccessor.TextMutator
setText
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProperty
letText, letText
Methods inherited from interface org.refcodes.textual.TextBoxGridAccessor.TextBoxGridMutator
setTextBoxGrid
Methods inherited from interface org.refcodes.textual.TextBoxGridAccessor.TextBoxGridProperty
letTextBoxGrid, letTextBoxGrid
-
Constructor Details
-
TextBorderBuilder
public TextBorderBuilder()
-
-
Method Details
-
setTextBoxStyle
- Parameters:
aTextBoxStyle
- TheTextBoxStyle
which'sTextBoxGrid
is to be set.
-
withTextBoxStyle
Convenience method forwithTextBoxGrid(TextBoxGrid)
to set theTextBoxGrid
from aTextBoxStyle
value- Parameters:
aTextBoxStyle
- TheTextBoxStyle
which'sTextBoxGrid
is to be set.- Returns:
- This instance as of the builder pattern,
-
withBorderChar
Sets the border char for the border char property.- Parameters:
aBorderChar
- The border char to be stored by the text align mode property.- Returns:
- The builder for applying multiple build operations.
-
withBorderWidth
Sets the border width for the border width property.- Parameters:
aBorderWidth
- The border width to be stored by the text align mode property.- Returns:
- The builder for applying multiple build operations.
-
getBoxBorderMode
public org.refcodes.graphical.BoxBorderMode getBoxBorderMode()- Specified by:
getBoxBorderMode
in interfaceorg.refcodes.graphical.BoxBorderModeAccessor
-
setBoxBorderMode
public void setBoxBorderMode(org.refcodes.graphical.BoxBorderMode aBoxBorderMode) - Specified by:
setBoxBorderMode
in interfaceorg.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeMutator
-
withBoxBorderMode
- Specified by:
withBoxBorderMode
in interfaceorg.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>
-
getTextBoxGrid
Gets the currently setTextBoxGrid
being used.- Specified by:
getTextBoxGrid
in interfaceTextBoxGridAccessor
- Returns:
- The currently configured
TextBoxGrid
s.
-
setTextBoxGrid
Sets theTextBoxGrid
to be used.- Specified by:
setTextBoxGrid
in interfaceTextBoxGridAccessor.TextBoxGridMutator
- Parameters:
aTextBoxGrid
- TheTextBoxGrid
to be stored by theTextBoxGrid
property.
-
withTextBoxGrid
Sets the rowsTextBoxGrid
to use returns this builder as of the Builder-Pattern.- Specified by:
withTextBoxGrid
in interfaceTextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
- Parameters:
aTextBoxGrid
- TheTextBoxGrid
to be used.- Returns:
- This
TextBoxGridAccessor.TextBoxGridBuilder
instance to continue configuration.
-
withTextBoxGrid
Sets the rowsTextBoxGrid
to use returns this builder as of the Builder-Pattern.- Specified by:
withTextBoxGrid
in interfaceTextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
- Parameters:
aTextBoxStyle
- TheTextBoxStyle
to be used.- Returns:
- This
TextBoxGridAccessor.TextBoxGridBuilder
instance to continue configuration.
-
getBorderChar
public char getBorderChar()Retrieves the border char from the border char property.- Returns:
- The border char stored by the border char property.
-
setBorderChar
public void setBorderChar(char aBorderChar) Sets the border char for the border char property.- Parameters:
aBorderChar
- The border char to be stored by the text align mode property.
-
getBorderWidth
public int getBorderWidth()Retrieves the border width from the border width property.- Returns:
- The border width stored by the border width property.
-
setBorderWidth
public void setBorderWidth(int aBorderWidth) Sets the border width for the border width property.- Parameters:
aBorderWidth
- The border width to be stored by the text align mode property.
-
toStrings
TheString
s being build by the builder upon the settings of the attributes.- Specified by:
toStrings
in interfaceTextAccessor.TextProvider
- Returns:
- The according resulting
String
array
-
toStrings
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
. Implementation requirements: This method must not(!) be implemented by callingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
(do not change the text property) as this would not be thread safe!- Specified by:
toStrings
in interfaceText<TextBorderBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
toLeftBorder
Adds the according border with the given char and the provided witdh to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.- Returns:
- The text with the according border being applied.
-
toRightBorder
Adds the according border with the given char and the provided width to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.- Returns:
- The text with the according border being applied.
-
toTopBorder
Adds the according border with the given char and the provided width to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.- Returns:
- The text with the according border being applied.
-
toBottomBorder
Adds the according border with the given char and the provided width to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.- Returns:
- The text with the according border being applied.
-
toBorder
public static String[] toBorder(String[] aText, int aBorderWidth, char aBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode) Adds the according border with the given char and the provided width to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.aBoxBorderMode
- the box border mode- Returns:
- The text with the according border being applied.
-
toBorder
protected static String[] toBorder(String[] aText, char aTopLeftBorderChar, char aTopRightBorderChar, char aBottomLeftBorderChar, char aBottomRightBorderChar, char aTopBorderChar, char aRightBorderChar, char aBottomBorderChar, char aLeftBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode) Adds a predefined border according border to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aTopLeftBorderChar
- The top left border's character.aTopRightBorderChar
- The top right border's character.aBottomLeftBorderChar
- The bottom left border's character.aBottomRightBorderChar
- The bottom right border's character.aTopBorderChar
- the top border charaRightBorderChar
- the right border charaBottomBorderChar
- the bottom border charaLeftBorderChar
- the left border charaBoxBorderMode
- the box border mode- Returns:
- The text with the according border being applied.
-
toSingleBorder
Adds a predefined "single-line" border to the provided text.- Parameters:
aText
- The text to which the border is to be applied.- Returns:
- The text with the according border being applied.
-
toDoubleBorder
Adds a predefined "double-line" border to the provided text.- Parameters:
aText
- The text to which the border is to be applied.- Returns:
- The text with the according border being applied.
-
toAsciiBorder
Adds a predefined "single-line" border to the provided text.- Parameters:
aText
- The text to which the border is to be applied.- Returns:
- The text with the according border being applied.
-
toLine
Returns aString
with the given length and containing only the provided fill character.- Parameters:
aLength
- The length to be reached.aFillChar
- The char to be used for filling up- Returns:
- The
String
filled with the fill character till the provided length.
-
getText
Retrieves the text from the text property.- Specified by:
getText
in interfaceTextAccessor
- Returns:
- The text stored by the text property.
-
setText
Sets the text for the text property.- Specified by:
setText
in interfaceTextAccessor.TextMutator
- Parameters:
aText
- The text to be stored by the text property.
-
withText
With text. -
withText
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
toString
TheString
being build by the builder upon the settings of the attributes. In case more then one line has been set as input and the functionality of the builder is applied to each line in separate, then this method returns all of them lines concatenated with a line break between each of them (implementation depended).- Specified by:
toString
in interfaceTextAccessor.TextProvider
- Overrides:
toString
in classObject
- Returns:
- The according resulting
String
-
toString
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
. Implementation requirements: This method must not(!) be implemented by callingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
(do not change the text property) as this would not be thread safe!
-