org.apache.poi.sl.usermodel
Interface TextShape<S extends Shape<S,P>,P extends TextParagraph<S,P,?>>

All Superinterfaces:
IAdjustableShape, java.lang.Iterable<P>, PlaceableShape<S,P>, Shape<S,P>, SimpleShape<S,P>
All Known Subinterfaces:
AutoShape<S,P>, FreeformShape<S,P>, Line<S,P>, TableCell<S,P>, TextBox<S,P>

public interface TextShape<S extends Shape<S,P>,P extends TextParagraph<S,P,?>>
extends SimpleShape<S,P>, java.lang.Iterable<P>


Nested Class Summary
static class TextShape.TextAutofit
          Specifies alist of auto-fit types.
static class TextShape.TextDirection
          Vertical Text Types
static class TextShape.TextPlaceholder
          This enum represents a compromise for the handling of HSLF run types (see org.apache.poi.hslf.record.TextHeaderAtom) and XSLF placeholders (see org.apache.poi.xslf.usermodel.Placeholder).
 
Method Summary
 TextRun appendText(java.lang.String text, boolean newParagraph)
          Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.
 Insets2D getInsets()
           
 java.lang.String getText()
          Returns the text contained in this text frame, which has been made safe for printing and other use.
 TextShape.TextDirection getTextDirection()
           
 double getTextHeight()
          Compute the cumulative height occupied by the text
 double getTextHeight(java.awt.Graphics2D graphics)
          Compute the cumulative height occupied by the text
 java.util.List<? extends TextParagraph<S,P,?>> getTextParagraphs()
           
 TextShape.TextPlaceholder getTextPlaceholder()
           
 java.lang.Double getTextRotation()
          The text rotation can be independent specified from the shape rotation.
 VerticalAlignment getVerticalAlignment()
          Returns the type of vertical alignment for the text.
 boolean getWordWrap()
           
 boolean isHorizontalCentered()
          Returns if the text is centered.
 java.awt.geom.Rectangle2D resizeToFitText()
          Adjust the size of the shape so it encompasses the text inside it.
 java.awt.geom.Rectangle2D resizeToFitText(java.awt.Graphics2D graphics)
          Adjust the size of the shape so it encompasses the text inside it.
 void setHorizontalCentered(java.lang.Boolean isCentered)
          Sets if the paragraphs are horizontal centered
 void setInsets(Insets2D insets)
          Sets the shape margins
 TextRun setText(java.lang.String text)
          Sets (overwrites) the current text.
 void setTextDirection(TextShape.TextDirection orientation)
          sets the vertical orientation
 void setTextPlaceholder(TextShape.TextPlaceholder placeholder)
          Sets the text placeholder
 void setTextRotation(java.lang.Double rotation)
          Sets the text rotation.
 void setVerticalAlignment(VerticalAlignment vAlign)
          Sets the type of vertical alignment for the text.
 void setWordWrap(boolean wrap)
           
 
Methods inherited from interface org.apache.poi.sl.usermodel.SimpleShape
createHyperlink, getFillColor, getFillStyle, getGeometry, getHyperlink, getLineDecoration, getPlaceholder, getShadow, getShapeType, getStrokeStyle, setFillColor, setPlaceholder, setShapeType, setStrokeStyle
 
Methods inherited from interface org.apache.poi.sl.usermodel.Shape
draw, getAnchor, getParent, getSheet
 
Methods inherited from interface org.apache.poi.sl.draw.geom.IAdjustableShape
getAdjustValue
 
Methods inherited from interface org.apache.poi.sl.usermodel.PlaceableShape
getAnchor, getFlipHorizontal, getFlipVertical, getParent, getRotation, getSheet, setAnchor, setFlipHorizontal, setFlipVertical, setRotation
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

getText

java.lang.String getText()
Returns the text contained in this text frame, which has been made safe for printing and other use.

Returns:
the text string for this textbox.
Since:
POI 3.14-Beta2

setText

TextRun setText(java.lang.String text)
Sets (overwrites) the current text. Uses the properties of the first paragraph / textrun. Text paragraphs are split by \\r or \\n. New lines within text run are split by \\u000b

Parameters:
text - the text string used by this object.
Returns:
the last text run of the - potential split - text

appendText

TextRun appendText(java.lang.String text,
                   boolean newParagraph)
Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.

Parameters:
text - the text string to be appended.
newParagraph - if true, a new paragraph will be added, which will contain the added text
Since:
POI 3.14-Beta1

getTextParagraphs

java.util.List<? extends TextParagraph<S,P,?>> getTextParagraphs()
Returns:
the TextParagraphs for this text box

getInsets

Insets2D getInsets()
Returns:
text shape margin

setInsets

void setInsets(Insets2D insets)
Sets the shape margins

Parameters:
insets - the new shape margins

getTextHeight

double getTextHeight()
Compute the cumulative height occupied by the text

Returns:
the cumulative height occupied by the text

getTextHeight

double getTextHeight(java.awt.Graphics2D graphics)
Compute the cumulative height occupied by the text

Parameters:
graphics - a customized graphics context, e.g. which contains font mappings
Returns:
the cumulative height occupied by the text
Since:
POI 3.17-beta2

getVerticalAlignment

VerticalAlignment getVerticalAlignment()
Returns the type of vertical alignment for the text.

Returns:
the type of vertical alignment

setVerticalAlignment

void setVerticalAlignment(VerticalAlignment vAlign)
Sets the type of vertical alignment for the text.

Parameters:
vAlign - - the type of alignment. A null values unsets this property.

isHorizontalCentered

boolean isHorizontalCentered()
Returns if the text is centered. If true and if the individual paragraph settings allow it, the whole text block will be displayed centered, i.e. its left and right margin will be maximized while still keeping the alignment of the paragraphs

Returns:
true, if the text anchor is horizontal centered

setHorizontalCentered

void setHorizontalCentered(java.lang.Boolean isCentered)
Sets if the paragraphs are horizontal centered

Parameters:
isCentered - true, if the paragraphs are horizontal centered A null values unsets this property.

getWordWrap

boolean getWordWrap()
Returns:
whether to wrap words within the bounding rectangle

setWordWrap

void setWordWrap(boolean wrap)
Parameters:
wrap - whether to wrap words within the bounding rectangle

getTextDirection

TextShape.TextDirection getTextDirection()
Returns:
vertical orientation of the text

setTextDirection

void setTextDirection(TextShape.TextDirection orientation)
sets the vertical orientation

Parameters:
orientation - vertical orientation of the text

getTextRotation

java.lang.Double getTextRotation()
The text rotation can be independent specified from the shape rotation. For XSLF this can be an arbitrary degree, for HSLF the degree is given in steps of 90 degrees

Returns:
text rotation in degrees, returns null if no rotation is given

setTextRotation

void setTextRotation(java.lang.Double rotation)
Sets the text rotation. For XSLF this can ben an arbitrary degree, for HSLF the rotation is rounded to next 90 degree step

Parameters:
rotation - the text rotation, or null to unset the rotation

setTextPlaceholder

void setTextPlaceholder(TextShape.TextPlaceholder placeholder)
Sets the text placeholder


getTextPlaceholder

TextShape.TextPlaceholder getTextPlaceholder()
Returns:
the text placeholder

resizeToFitText

java.awt.geom.Rectangle2D resizeToFitText()
Adjust the size of the shape so it encompasses the text inside it.

Returns:
a Rectangle2D that is the bounds of this shape.
Since:
POI 3.17-beta2

resizeToFitText

java.awt.geom.Rectangle2D resizeToFitText(java.awt.Graphics2D graphics)
Adjust the size of the shape so it encompasses the text inside it.

Parameters:
graphics - a customized graphics context, e.g. which contains font mappings
Returns:
a Rectangle2D that is the bounds of this shape.
Since:
POI 3.17-beta2