org.apache.poi.xslf.usermodel
Class XSLFTextShape

java.lang.Object
  extended by org.apache.poi.xslf.usermodel.XSLFShape
      extended by org.apache.poi.xslf.usermodel.XSLFSimpleShape
          extended by org.apache.poi.xslf.usermodel.XSLFTextShape
All Implemented Interfaces:
java.lang.Iterable<XSLFTextParagraph>, IAdjustableShape, PlaceableShape<XSLFShape,XSLFTextParagraph>, Shape<XSLFShape,XSLFTextParagraph>, SimpleShape<XSLFShape,XSLFTextParagraph>, TextShape<XSLFShape,XSLFTextParagraph>
Direct Known Subclasses:
XSLFAutoShape, XSLFTableCell

@Beta
public abstract class XSLFTextShape
extends XSLFSimpleShape
implements TextShape<XSLFShape,XSLFTextParagraph>

Represents a shape that can hold text.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.TextShape
TextShape.TextAutofit, TextShape.TextDirection, TextShape.TextPlaceholder
 
Field Summary
 
Fields inherited from class org.apache.poi.xslf.usermodel.XSLFShape
PML_NS
 
Method Summary
 XSLFTextParagraph addNewTextParagraph()
          add a new paragraph run to this shape
 XSLFTextRun appendText(java.lang.String text, boolean newParagraph)
           
 void clearText()
          unset text from this shape
 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.
 Insets2D getInsets()
           
 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.
 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.
 java.lang.String getText()
           
 TextShape.TextAutofit getTextAutofit()
           
protected abstract  org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody getTextBody(boolean create)
           
protected  org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties getTextBodyPr()
           
protected  org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties getTextBodyPr(boolean create)
           
 TextShape.TextDirection getTextDirection()
           
 double getTextHeight()
           
 double getTextHeight(java.awt.Graphics2D graphics)
           
 java.util.List<XSLFTextParagraph> getTextParagraphs()
           
 TextShape.TextPlaceholder getTextPlaceholder()
           
 java.lang.Double getTextRotation()
           
 Placeholder getTextType()
           
 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.
 VerticalAlignment getVerticalAlignment()
           
 boolean getWordWrap()
           
 boolean isHorizontalCentered()
           
 java.util.Iterator<XSLFTextParagraph> iterator()
           
protected  XSLFTextParagraph newTextParagraph(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph p)
          Helper method to allow subclasses to provide their own text paragraph
 java.awt.geom.Rectangle2D resizeToFitText()
           
 java.awt.geom.Rectangle2D resizeToFitText(java.awt.Graphics2D graphics)
           
 void setBottomInset(double margin)
          Sets the bottom margin.
 void setHorizontalCentered(java.lang.Boolean isCentered)
           
 void setInsets(Insets2D insets)
           
 void setLeftInset(double margin)
          Sets the left margin.
 void setPlaceholder(Placeholder placeholder)
          Specifies that the corresponding shape should be represented by the generating application as a placeholder.
 void setRightInset(double margin)
          Sets the right margin.
 XSLFTextRun setText(java.lang.String text)
           
 void setTextAutofit(TextShape.TextAutofit value)
          Specifies that a shape should be auto-fit to fully contain the text described within it.
 void setTextDirection(TextShape.TextDirection orientation)
           
 void setTextPlaceholder(TextShape.TextPlaceholder placeholder)
           
 void setTextRotation(java.lang.Double rotation)
           
 void setTopInset(double margin)
          Sets the top margin.
 void setVerticalAlignment(VerticalAlignment anchor)
           
 void setWordWrap(boolean wrap)
           
 
Methods inherited from class org.apache.poi.xslf.usermodel.XSLFSimpleShape
createHyperlink, getAdjustValue, getAnchor, getFillColor, getFillStyle, getFlipHorizontal, getFlipVertical, getGeometry, getHyperlink, getLineCap, getLineColor, getLineCompound, getLineDash, getLineDecoration, getLineHeadDecoration, getLineHeadLength, getLineHeadWidth, getLinePaint, getLineTailDecoration, getLineTailLength, getLineTailWidth, getLineWidth, getRotation, getShadow, getShapeType, getStrokeStyle, getXfrm, isPlaceholder, setAnchor, setFillColor, setFlipHorizontal, setFlipVertical, setLineCap, setLineColor, setLineCompound, setLineDash, setLineHeadDecoration, setLineHeadLength, setLineHeadWidth, setLineTailDecoration, setLineTailLength, setLineTailWidth, setLineWidth, setRotation, setShapeType, setStrokeStyle
 
Methods inherited from class org.apache.poi.xslf.usermodel.XSLFShape
draw, fetchShapeProperty, getBgPr, getBgRef, getChild, getCNvPr, getCTPlaceholder, getFillPaint, getGrpSpPr, getParent, getPlaceholder, getShapeId, getShapeName, getShapeProperties, getSheet, getSpStyle, getXmlObject, selectPaint, selectPaint, selectPaint, selectPaint, selectPaint, selectProperty, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.poi.sl.usermodel.SimpleShape
createHyperlink, getFillColor, getFillStyle, getGeometry, getHyperlink, getLineDecoration, getPlaceholder, getShadow, getShapeType, getStrokeStyle, setFillColor, 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
 

Method Detail

iterator

public java.util.Iterator<XSLFTextParagraph> iterator()
Specified by:
iterator in interface java.lang.Iterable<XSLFTextParagraph>

getText

public java.lang.String getText()
Specified by:
getText in interface TextShape<XSLFShape,XSLFTextParagraph>

clearText

public void clearText()
unset text from this shape


setText

public XSLFTextRun setText(java.lang.String text)
Specified by:
setText in interface TextShape<XSLFShape,XSLFTextParagraph>

appendText

public XSLFTextRun appendText(java.lang.String text,
                              boolean newParagraph)
Specified by:
appendText in interface TextShape<XSLFShape,XSLFTextParagraph>

getTextParagraphs

public java.util.List<XSLFTextParagraph> getTextParagraphs()
Specified by:
getTextParagraphs in interface TextShape<XSLFShape,XSLFTextParagraph>

addNewTextParagraph

public XSLFTextParagraph addNewTextParagraph()
add a new paragraph run to this shape

Returns:
created paragraph run

setVerticalAlignment

public void setVerticalAlignment(VerticalAlignment anchor)
Specified by:
setVerticalAlignment in interface TextShape<XSLFShape,XSLFTextParagraph>

getVerticalAlignment

public VerticalAlignment getVerticalAlignment()
Specified by:
getVerticalAlignment in interface TextShape<XSLFShape,XSLFTextParagraph>

setHorizontalCentered

public void setHorizontalCentered(java.lang.Boolean isCentered)
Specified by:
setHorizontalCentered in interface TextShape<XSLFShape,XSLFTextParagraph>

isHorizontalCentered

public boolean isHorizontalCentered()
Specified by:
isHorizontalCentered in interface TextShape<XSLFShape,XSLFTextParagraph>

setTextDirection

public void setTextDirection(TextShape.TextDirection orientation)
Specified by:
setTextDirection in interface TextShape<XSLFShape,XSLFTextParagraph>

getTextDirection

public TextShape.TextDirection getTextDirection()
Specified by:
getTextDirection in interface TextShape<XSLFShape,XSLFTextParagraph>

getTextRotation

public java.lang.Double getTextRotation()
Specified by:
getTextRotation in interface TextShape<XSLFShape,XSLFTextParagraph>

setTextRotation

public void setTextRotation(java.lang.Double rotation)
Specified by:
setTextRotation in interface TextShape<XSLFShape,XSLFTextParagraph>

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 bottom 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()

getInsets

public Insets2D getInsets()
Specified by:
getInsets in interface TextShape<XSLFShape,XSLFTextParagraph>

setInsets

public void setInsets(Insets2D insets)
Specified by:
setInsets in interface TextShape<XSLFShape,XSLFTextParagraph>

getWordWrap

public boolean getWordWrap()
Specified by:
getWordWrap in interface TextShape<XSLFShape,XSLFTextParagraph>

setWordWrap

public void setWordWrap(boolean wrap)
Specified by:
setWordWrap in interface TextShape<XSLFShape,XSLFTextParagraph>

setTextAutofit

public void setTextAutofit(TextShape.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 TextShape.TextAutofit getTextAutofit()
Returns:
type of autofit

getTextBodyPr

protected org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties getTextBodyPr()

getTextBodyPr

protected org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties getTextBodyPr(boolean create)

getTextBody

protected abstract org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody getTextBody(boolean create)

setPlaceholder

public void setPlaceholder(Placeholder placeholder)
Description copied from class: XSLFShape
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

Specified by:
setPlaceholder in interface SimpleShape<XSLFShape,XSLFTextParagraph>
Overrides:
setPlaceholder in class XSLFSimpleShape
Parameters:
placeholder - The shape to use as placeholder or null if no placeholder should be set.

getTextType

public Placeholder getTextType()

getTextHeight

public double getTextHeight()
Specified by:
getTextHeight in interface TextShape<XSLFShape,XSLFTextParagraph>

getTextHeight

public double getTextHeight(java.awt.Graphics2D graphics)
Specified by:
getTextHeight in interface TextShape<XSLFShape,XSLFTextParagraph>

resizeToFitText

public java.awt.geom.Rectangle2D resizeToFitText()
Specified by:
resizeToFitText in interface TextShape<XSLFShape,XSLFTextParagraph>

resizeToFitText

public java.awt.geom.Rectangle2D resizeToFitText(java.awt.Graphics2D graphics)
Specified by:
resizeToFitText in interface TextShape<XSLFShape,XSLFTextParagraph>

setTextPlaceholder

public void setTextPlaceholder(TextShape.TextPlaceholder placeholder)
Specified by:
setTextPlaceholder in interface TextShape<XSLFShape,XSLFTextParagraph>

getTextPlaceholder

public TextShape.TextPlaceholder getTextPlaceholder()
Specified by:
getTextPlaceholder in interface TextShape<XSLFShape,XSLFTextParagraph>

newTextParagraph

protected XSLFTextParagraph newTextParagraph(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph p)
Helper method to allow subclasses to provide their own text paragraph

Parameters:
p - the xml reference
Returns:
a new text paragraph
Since:
POI 3.15-beta2