Package org.eclipse.graphiti.util
Class TextBuilder
java.lang.Object
org.eclipse.graphiti.util.TextBuilder
Class to construct
TextStyleRegions while adding text.- Since:
- 0.12
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInner class for storing the partial region styles. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd text to the builder.voidfinishRegion(String name) Finish a region.voidforgetRegion(String name) Drop a region that was created but not yet finished.intGet current length of the collected text.Get a previously created and not yet finished region.Get the regions created and finished for the text.booleanisEmpty()Is any text added yet?startRegion(String name) Start a new region in the text.toString()Get the collected text.
-
Constructor Details
-
TextBuilder
public TextBuilder()
-
-
Method Details
-
add
Add text to the builder.- Parameters:
text- Text to append.
-
getLength
public int getLength()Get current length of the collected text.- Returns:
- Length of the text collected so far (number of code points).
-
isEmpty
public boolean isEmpty()Is any text added yet?- Returns:
trueif no text added yet, elsefalse.
-
toString
Get the collected text.- Overrides:
toStringin classObject- Returns:
- The concatenated strings previously given through
add(java.lang.String).
-
getRegions
Get the regions created and finished for the text.- Returns:
- Regions of the text.
-
startRegion
Start a new region in the text. Returns the created region for setting the style of the new region.- Parameters:
name- Name of the region.- Returns:
- The created region.
-
getRegion
Get a previously created and not yet finished region.- Parameters:
name- Name of the region to retrieve.- Returns:
- The queried region if it exists, else
null.
-
finishRegion
Finish a region.- Parameters:
name- Name of the region to finish.
-
forgetRegion
Drop a region that was created but not yet finished.- Parameters:
name- Name of the region to forget.
-