org.apache.poi.xslf.usermodel
Class XSLFTextShape
- java.lang.Object
-
- org.apache.poi.xslf.usermodel.XSLFShape
-
- org.apache.poi.xslf.usermodel.XSLFSimpleShape
-
- org.apache.poi.xslf.usermodel.XSLFTextShape
-
- All Implemented Interfaces:
- java.lang.Iterable<XSLFTextParagraph>
- Direct Known Subclasses:
- XSLFAutoShape, XSLFTableCell
@Beta public abstract class XSLFTextShape extends XSLFSimpleShape implements java.lang.Iterable<XSLFTextParagraph>
Represents a shape that can hold text.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description XSLFTextParagraphaddNewTextParagraph()add a new paragraph run to this shapevoidclearText()unset text from this shapevoiddrawContent(java.awt.Graphics2D graphics)draw any content within this shape (image, text, etc.).doublegetBottomInset()Returns the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.doublegetLeftInset()Returns the distance (in points) between the left edge of the text frame and the left edge of the inscribed rectangle of the shape that contains the text.doublegetRightInset()Returns the distance (in points) between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.java.lang.StringgetText()TextAutofitgetTextAutofit()TextDirectiongetTextDirection()doublegetTextHeight()Compute the cumulative height occupied by the textjava.util.List<XSLFTextParagraph>getTextParagraphs()PlaceholdergetTextType()doublegetTopInset()Returns the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.VerticalAlignmentgetVerticalAlignment()Returns the type of vertical alignment for the text.booleangetWordWrap()java.util.Iterator<XSLFTextParagraph>iterator()java.awt.geom.Rectangle2DresizeToFitText()Adjust the size of the shape so it encompasses the text inside it.voidsetBottomInset(double margin)Sets the botom margin.voidsetLeftInset(double margin)Sets the left margin.voidsetPlaceholder(Placeholder placeholder)Specifies that the corresponding shape should be represented by the generating application as a placeholder.voidsetRightInset(double margin)Sets the right margin.voidsetText(java.lang.String text)voidsetTextAutofit(TextAutofit value)Specifies that a shape should be auto-fit to fully contain the text described within it.voidsetTextDirection(TextDirection orientation)voidsetTopInset(double margin)Sets the top margin.voidsetVerticalAlignment(VerticalAlignment anchor)Sets the type of vertical alignment for the text.voidsetWordWrap(boolean wrap)-
Methods inherited from class org.apache.poi.xslf.usermodel.XSLFSimpleShape
draw, getAnchor, getFillColor, getFlipHorizontal, getFlipVertical, getLineCap, getLineColor, getLineDash, getLineHeadDecoration, getLineHeadLength, getLineHeadWidth, getLineTailDecoration, getLineTailLength, getLineTailWidth, getLineWidth, getRotation, getShadow, getShapeId, getShapeName, getShapeType, getSheet, getXmlObject, setAnchor, setFillColor, setFlipHorizontal, setFlipVertical, setLineCap, setLineColor, setLineDash, setLineHeadDecoration, setLineHeadLength, setLineHeadWidth, setLineTailDecoration, setLineTailLength, setLineTailWidth, setLineWidth, setRotation, setShapeType
-
-
-
-
Method Detail
-
iterator
public java.util.Iterator<XSLFTextParagraph> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<XSLFTextParagraph>
-
getText
public java.lang.String getText()
- Returns:
- text contained within this shape or empty string
-
clearText
public void clearText()
unset text from this shape
-
setText
public void setText(java.lang.String text)
-
getTextParagraphs
public java.util.List<XSLFTextParagraph> getTextParagraphs()
- Returns:
- text paragraphs in this shape
-
addNewTextParagraph
public XSLFTextParagraph addNewTextParagraph()
add a new paragraph run to this shape- Returns:
- created paragraph run
-
setVerticalAlignment
public void setVerticalAlignment(VerticalAlignment anchor)
Sets the type of vertical alignment for the text.- Parameters:
anchor- - the type of alignment. Anullvalues unsets this property.
-
getVerticalAlignment
public VerticalAlignment getVerticalAlignment()
Returns the type of vertical alignment for the text.- Returns:
- the type of vertical alignment
-
setTextDirection
public void setTextDirection(TextDirection orientation)
- Parameters:
orientation- vertical orientation of the text
-
getTextDirection
public TextDirection getTextDirection()
- Returns:
- vertical orientation of the text
-
getBottomInset
public double getBottomInset()
Returns the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.- Returns:
- the bottom inset in points
-
getLeftInset
public double getLeftInset()
Returns the distance (in points) between the left edge of the text frame and the left edge of the inscribed rectangle of the shape that contains the text.- Returns:
- the left inset in points
-
getRightInset
public double getRightInset()
Returns the distance (in points) between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.- Returns:
- the right inset in points
-
getTopInset
public double getTopInset()
Returns the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.- Returns:
- the top inset in points
-
setBottomInset
public void setBottomInset(double margin)
Sets the botom margin.- Parameters:
margin- the bottom margin- See Also:
getBottomInset()
-
setLeftInset
public void setLeftInset(double margin)
Sets the left margin.- Parameters:
margin- the left margin- See Also:
getLeftInset()
-
setRightInset
public void setRightInset(double margin)
Sets the right margin.- Parameters:
margin- the right margin- See Also:
getRightInset()
-
setTopInset
public void setTopInset(double margin)
Sets the top margin.- Parameters:
margin- the top margin- See Also:
getTopInset()
-
getWordWrap
public boolean getWordWrap()
- Returns:
- whether to wrap words within the bounding rectangle
-
setWordWrap
public void setWordWrap(boolean wrap)
- Parameters:
wrap- whether to wrap words within the bounding rectangle
-
setTextAutofit
public void setTextAutofit(TextAutofit value)
Specifies that a shape should be auto-fit to fully contain the text described within it. Auto-fitting is when text within a shape is scaled in order to contain all the text inside- Parameters:
value- type of autofit
-
getTextAutofit
public TextAutofit getTextAutofit()
- Returns:
- type of autofit
-
getTextType
public Placeholder getTextType()
-
setPlaceholder
public void setPlaceholder(Placeholder placeholder)
Specifies that the corresponding shape should be represented by the generating application as a placeholder. When a shape is considered a placeholder by the generating application it can have special properties to alert the user that they may enter content into the shape. Different types of placeholders are allowed and can be specified by using the placeholder type attribute for this element- Parameters:
placeholder-
-
getTextHeight
public double getTextHeight()
Compute the cumulative height occupied by the text
-
resizeToFitText
public java.awt.geom.Rectangle2D resizeToFitText()
Adjust the size of the shape so it encompasses the text inside it.- Returns:
- a
Rectangle2Dthat is the bounds of this shape.
-
drawContent
public void drawContent(java.awt.Graphics2D graphics)
Description copied from class:XSLFSimpleShapedraw any content within this shape (image, text, etc.).- Overrides:
drawContentin classXSLFSimpleShape- Parameters:
graphics- the graphics to draw into
-
-
DataMelt 3.0 © DataMelt by jWork.ORG