Package org.apache.poi.sl.usermodel
Interface TextShape<S extends Shape<S,P>,P extends TextParagraph<S,P,? extends TextRun>>
- All Superinterfaces:
IAdjustableShape
,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>
- All Known Implementing Classes:
HSLFAutoShape
,HSLFFreeformShape
,HSLFLine
,HSLFPlaceholder
,HSLFTableCell
,HSLFTextBox
,HSLFTextShape
,Polygon
,XSLFAutoShape
,XSLFFreeformShape
,XSLFTableCell
,XSLFTextBox
,XSLFTextShape
public interface TextShape<S extends Shape<S,P>,P extends TextParagraph<S,P,? extends TextRun>>
extends SimpleShape<S,P>, Iterable<P>
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Specifies alist of auto-fit types.static enum
Vertical Text Typesstatic enum
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
Modifier and TypeMethodDescriptionappendText
(String text, boolean newParagraph) Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.getText()
Returns the text contained in this text frame, which has been made safe for printing and other use.double
Compute the cumulative height occupied by the textdouble
getTextHeight
(Graphics2D graphics) Compute the cumulative height occupied by the textThe text rotation can be independent specified from the shape rotation.Returns the type of vertical alignment for the text.boolean
boolean
Returns if the text is centered.Adjust the size of the shape so it encompasses the text inside it.resizeToFitText
(Graphics2D graphics) Adjust the size of the shape so it encompasses the text inside it.void
setHorizontalCentered
(Boolean isCentered) Sets if the paragraphs are horizontal centeredvoid
Sets the shape marginsSets (overwrites) the current text.void
setTextDirection
(TextShape.TextDirection orientation) sets the vertical orientationvoid
setTextPlaceholder
(TextShape.TextPlaceholder placeholder) Sets the text placeholdervoid
setTextRotation
(Double rotation) Sets the text rotation.void
Sets the type of vertical alignment for the text.void
setWordWrap
(boolean wrap) Methods inherited from interface org.apache.poi.sl.draw.geom.IAdjustableShape
getAdjustValue
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.apache.poi.sl.usermodel.PlaceableShape
getAnchor, getFlipHorizontal, getFlipVertical, getParent, getRotation, getSheet, setAnchor, setFlipHorizontal, setFlipVertical, setRotation
Methods inherited from interface org.apache.poi.sl.usermodel.Shape
draw, getAnchor, getParent, getShapeId, getShapeName, getSheet
Methods inherited from interface org.apache.poi.sl.usermodel.SimpleShape
createHyperlink, getFillColor, getFillStyle, getGeometry, getHyperlink, getLineDecoration, getPlaceholder, getPlaceholderDetails, getShadow, getShapeType, getStrokeStyle, isPlaceholder, setFillColor, setPlaceholder, setShapeType, setStrokeStyle
-
Method Details
-
getText
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
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
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
- Returns:
- the TextParagraphs for this text box
-
getInsets
Insets2D getInsets()- Returns:
- text shape margin
-
setInsets
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
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
Sets the type of vertical alignment for the text.- Parameters:
vAlign
- - the type of alignment. Anull
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
Sets if the paragraphs are horizontal centered- Parameters:
isCentered
- true, if the paragraphs are horizontal centered Anull
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
sets the vertical orientation- Parameters:
orientation
- vertical orientation of the text
-
getTextRotation
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
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
Sets the text placeholder -
getTextPlaceholder
TextShape.TextPlaceholder getTextPlaceholder()- Returns:
- the text placeholder
-
resizeToFitText
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
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
-