Top Inners Methods
org.apache.poi.sl.usermodel

public Interface TextShape<S extends Shape<S, P>, P extends TextParagraph<S, P, ? extends TextRun>>

extends SimpleShape<S extends Shape<S, P>, P extends TextParagraph<S, P, ? extends TextRun>>, Iterable<P extends TextParagraph<S, P, ? extends TextRun>>
Known Direct Subinterfaces
org.apache.poi.sl.usermodel.AutoShape, org.apache.poi.sl.usermodel.TableCell
Imports
java.awt.Graphics2D, java.awt.geom.Rectangle2D, java.util.List

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
TextShape.TextAutofit

Specifies alist of auto-fit types.

public static enum
TextShape.TextDirection

Vertical Text Types

public static enum
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

Modifier and TypeMethod and Description
public TextRun
appendText(String
the text string to be appended.
text
,
boolean
if true, a new paragraph will be added, which will contain the added text
newParagraph
)

Adds the supplied text onto the end of the TextParagraphs, creating a new RichTextRun for it to sit in.

public Insets2D

Returns:

text shape margin
getInsets
()

public String

Returns:

the text string for this textbox.
getText
()

Returns the text contained in this text frame, which has been made safe for printing and other use.

public TextShape.TextDirection

Returns:

vertical orientation of the text
getTextDirection
()

public double

Returns:

the cumulative height occupied by the text
getTextHeight
()

Compute the cumulative height occupied by the text

public double

Returns:

the cumulative height occupied by the text
getTextHeight
(Graphics2D
a customized graphics context, e.g. which contains font mappings
graphics
)

Compute the cumulative height occupied by the text

public List<P>

Returns:

the TextParagraphs for this text box
getTextParagraphs
()

public TextShape.TextPlaceholder

Returns:

the text placeholder
getTextPlaceholder
()

public Double

Returns:

text rotation in degrees, returns null if no rotation is given
getTextRotation
()

The text rotation can be independent specified from the shape rotation.

public VerticalAlignment

Returns:

the type of vertical alignment
getVerticalAlignment
()

Returns the type of vertical alignment for the text.

public boolean

Returns:

whether to wrap words within the bounding rectangle
getWordWrap
()

public boolean

Returns:

true, if the text anchor is horizontal centered
isHorizontalCentered
()

Returns if the text is centered.

public Rectangle2D

Returns:

a Rectangle2D that is the bounds of this shape.
resizeToFitText
()

Adjust the size of the shape so it encompasses the text inside it.

public Rectangle2D

Returns:

a Rectangle2D that is the bounds of this shape.
resizeToFitText
(Graphics2D
a customized graphics context, e.g. which contains font mappings
graphics
)

Adjust the size of the shape so it encompasses the text inside it.

public void
setHorizontalCentered(Boolean
true, if the paragraphs are horizontal centered A null values unsets this property.
isCentered
)

Sets if the paragraphs are horizontal centered

public void
setInsets(Insets2D
the new shape margins
insets
)

Sets the shape margins

public TextRun

Returns:

the last text run of the - potential split - text
setText
(String
the text string used by this object.
text
)

Sets (overwrites) the current text.

public void
setTextDirection(TextShape.TextDirection
vertical orientation of the text
orientation
)

sets the vertical orientation

public void
setTextPlaceholder(TextShape.TextPlaceholder placeholder)

Sets the text placeholder

public void
setTextRotation(Double
the text rotation, or null to unset the rotation
rotation
)

Sets the text rotation.

public void
setVerticalAlignment(VerticalAlignment
- the type of alignment. A null values unsets this property.
vAlign
)

Sets the type of vertical alignment for the text.

public void
setWordWrap(boolean
whether to wrap words within the bounding rectangle
wrap
)

Inherited from java.lang.Iterable:
forEachiteratorspliterator
Inherited from org.apache.poi.sl.usermodel.SimpleShape:
createHyperlinkgetFillColorgetFillStylegetGeometrygetHyperlinkgetLineDecorationgetPlaceholdergetPlaceholderDetailsgetShadowgetShapeTypegetStrokeStyleisPlaceholdersetFillColorsetPlaceholdersetShapeTypesetStrokeStyle

Method Detail

appendTextback to summary
public TextRun appendText(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:String

the text string to be appended.

newParagraph:boolean

if true, a new paragraph will be added, which will contain the added text

Since
POI 3.14-Beta1
getInsetsback to summary
public Insets2D getInsets()
Returns:Insets2D

text shape margin

getTextback to summary
public String getText()

Returns the text contained in this text frame, which has been made safe for printing and other use.

Returns:String

the text string for this textbox.

Since
POI 3.14-Beta2
getTextDirectionback to summary
public TextShape.TextDirection getTextDirection()
Returns:TextShape.TextDirection

vertical orientation of the text

getTextHeightback to summary
public double getTextHeight()

Compute the cumulative height occupied by the text

Returns:double

the cumulative height occupied by the text

getTextHeightback to summary
public double getTextHeight(Graphics2D graphics)

Compute the cumulative height occupied by the text

Parameters
graphics:Graphics2D

a customized graphics context, e.g. which contains font mappings

Returns:double

the cumulative height occupied by the text

Since
POI 3.17-beta2
getTextParagraphsback to summary
public List<P> getTextParagraphs()
Returns:List<P>

the TextParagraphs for this text box

getTextPlaceholderback to summary
public TextShape.TextPlaceholder getTextPlaceholder()
Returns:TextShape.TextPlaceholder

the text placeholder

getTextRotationback to summary
public 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:Double

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

getVerticalAlignmentback to summary
public VerticalAlignment getVerticalAlignment()

Returns the type of vertical alignment for the text.

Returns:VerticalAlignment

the type of vertical alignment

getWordWrapback to summary
public boolean getWordWrap()
Returns:boolean

whether to wrap words within the bounding rectangle

isHorizontalCenteredback to summary
public 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:boolean

true, if the text anchor is horizontal centered

resizeToFitTextback to summary
public Rectangle2D resizeToFitText()

Adjust the size of the shape so it encompasses the text inside it.

Returns:Rectangle2D

a Rectangle2D that is the bounds of this shape.

Since
POI 3.17-beta2
resizeToFitTextback to summary
public Rectangle2D resizeToFitText(Graphics2D graphics)

Adjust the size of the shape so it encompasses the text inside it.

Parameters
graphics:Graphics2D

a customized graphics context, e.g. which contains font mappings

Returns:Rectangle2D

a Rectangle2D that is the bounds of this shape.

Since
POI 3.17-beta2
setHorizontalCenteredback to summary
public void setHorizontalCentered(Boolean isCentered)

Sets if the paragraphs are horizontal centered

Parameters
isCentered:Boolean

true, if the paragraphs are horizontal centered A null values unsets this property.

setInsetsback to summary
public void setInsets(Insets2D insets)

Sets the shape margins

Parameters
insets:Insets2D

the new shape margins

setTextback to summary
public TextRun setText(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:String

the text string used by this object.

Returns:TextRun

the last text run of the - potential split - text

setTextDirectionback to summary
public void setTextDirection(TextShape.TextDirection orientation)

sets the vertical orientation

Parameters
orientation:TextShape.TextDirection

vertical orientation of the text

setTextPlaceholderback to summary
public void setTextPlaceholder(TextShape.TextPlaceholder placeholder)

Sets the text placeholder

setTextRotationback to summary
public void setTextRotation(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:Double

the text rotation, or null to unset the rotation

setVerticalAlignmentback to summary
public void setVerticalAlignment(VerticalAlignment vAlign)

Sets the type of vertical alignment for the text.

Parameters
vAlign:VerticalAlignment

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

setWordWrapback to summary
public void setWordWrap(boolean wrap)
Parameters
wrap:boolean

whether to wrap words within the bounding rectangle

org.apache.poi.sl.usermodel back to summary

public final Enum TextShape.TextAutofit

extends Enum<TextShape.TextAutofit>
Class Inheritance

Specifies alist of auto-fit types.

Autofit specofies 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

Field Summary

Modifier and TypeField and Description
public static final TextShape.TextAutofit
NONE

Specifies that text within the text body should not be auto-fit to the bounding box.

public static final TextShape.TextAutofit
NORMAL

Specifies that text within the text body should be normally auto-fit to the bounding box.

public static final TextShape.TextAutofit
SHAPE

Specifies that a shape should be auto-fit to fully contain the text described within it.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static TextShape.TextAutofit
public static TextShape.TextAutofit[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NONEback to summary
public static final TextShape.TextAutofit NONE

Specifies that text within the text body should not be auto-fit to the bounding box. Auto-fitting is when text within a text box is scaled in order to remain inside the text box.

NORMALback to summary
public static final TextShape.TextAutofit NORMAL

Specifies that text within the text body should be normally auto-fit to the bounding box. Autofitting is when text within a text box is scaled in order to remain inside the text box.

Example: Consider the situation where a user is building a diagram and needs to have the text for each shape that they are using stay within the bounds of the shape. An easy way this might be done is by using NORMAL autofit

SHAPEback to summary
public static final TextShape.TextAutofit SHAPE

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.

Example: Consider the situation where a user is building a diagram and needs to have the text for each shape that they are using stay within the bounds of the shape. An easy way this might be done is by using SHAPE autofit

Constructor Detail

TextAutofitback to summary
private TextAutofit()

Method Detail

valueOfback to summary
public static TextShape.TextAutofit valueOf(String name)
valuesback to summary
public static TextShape.TextAutofit[] values()
org.apache.poi.sl.usermodel back to summary

public final Enum TextShape.TextDirection

extends Enum<TextShape.TextDirection>
Class Inheritance

Vertical Text Types

Field Summary

Modifier and TypeField and Description
public static final TextShape.TextDirection
HORIZONTAL

Horizontal text.

public static final TextShape.TextDirection
STACKED

Determines if all of the text is vertical ("one letter on top of another").

public static final TextShape.TextDirection
VERTICAL

Vertical orientation.

public static final TextShape.TextDirection
VERTICAL_270

Vertical orientation.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static TextShape.TextDirection
public static TextShape.TextDirection[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

HORIZONTALback to summary
public static final TextShape.TextDirection HORIZONTAL

Horizontal text. This should be default.

STACKEDback to summary
public static final TextShape.TextDirection STACKED

Determines if all of the text is vertical ("one letter on top of another"). For HSLF: not supported

VERTICALback to summary
public static final TextShape.TextDirection VERTICAL

Vertical orientation. (each line is 90 degrees rotated clockwise, so it goes from top to bottom; each next line is to the left from the previous one).

VERTICAL_270back to summary
public static final TextShape.TextDirection VERTICAL_270

Vertical orientation. (each line is 270 degrees rotated clockwise, so it goes from bottom to top; each next line is to the right from the previous one). For HSLF: always interpreted by Powerpoint as HORIZONTAL.

Constructor Detail

TextDirectionback to summary
private TextDirection()

Method Detail

valueOfback to summary
public static TextShape.TextDirection valueOf(String name)
valuesback to summary
public static TextShape.TextDirection[] values()
org.apache.poi.sl.usermodel back to summary

public final Enum TextShape.TextPlaceholder

extends Enum<TextShape.TextPlaceholder>
Class Inheritance

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). 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. This enum and the handling around it may change significantly in future releases

Field Summary

Modifier and TypeField and Description
public static final TextShape.TextPlaceholder
BODY

Body placeholder shape text

public static final TextShape.TextPlaceholder
CENTER_BODY

Center body placeholder shape text

public static final TextShape.TextPlaceholder
CENTER_TITLE

Center title placeholder shape text

public static final TextShape.TextPlaceholder
HALF_BODY

Half-sized body placeholder shape text

public final int
public static final TextShape.TextPlaceholder
NOTES

Notes placeholder shape text

public static final TextShape.TextPlaceholder
OTHER

Any other text

public static final TextShape.TextPlaceholder
QUARTER_BODY

Quarter-sized body placeholder shape text

public static final TextShape.TextPlaceholder
TITLE

Title placeholder shape text

Constructor Summary

AccessConstructor and Description
private
TextPlaceholder(int nativeId)

Method Summary

Modifier and TypeMethod and Description
public static TextShape.TextPlaceholder
fromNativeId(int nativeId)

public static boolean
isTitle(int nativeId)

public static TextShape.TextPlaceholder
public static TextShape.TextPlaceholder[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BODYback to summary
public static final TextShape.TextPlaceholder BODY

Body placeholder shape text

CENTER_BODYback to summary
public static final TextShape.TextPlaceholder CENTER_BODY

Center body placeholder shape text

CENTER_TITLEback to summary
public static final TextShape.TextPlaceholder CENTER_TITLE

Center title placeholder shape text

HALF_BODYback to summary
public static final TextShape.TextPlaceholder HALF_BODY

Half-sized body placeholder shape text

nativeIdback to summary
public final int nativeId
NOTESback to summary
public static final TextShape.TextPlaceholder NOTES

Notes placeholder shape text

OTHERback to summary
public static final TextShape.TextPlaceholder OTHER

Any other text

QUARTER_BODYback to summary
public static final TextShape.TextPlaceholder QUARTER_BODY

Quarter-sized body placeholder shape text

TITLEback to summary
public static final TextShape.TextPlaceholder TITLE

Title placeholder shape text

Constructor Detail

TextPlaceholderback to summary
private TextPlaceholder(int nativeId)

Method Detail

fromNativeIdback to summary
public static TextShape.TextPlaceholder fromNativeId(int nativeId)
isTitleback to summary
public static boolean isTitle(int nativeId)
valueOfback to summary
public static TextShape.TextPlaceholder valueOf(String name)
valuesback to summary
public static TextShape.TextPlaceholder[] values()