## org.apache.poi.hslf.model
Class TextShape

    java.lang.Object
      org.apache.poi.hslf.model.Shape
          org.apache.poi.hslf.model.SimpleShape
              org.apache.poi.hslf.model.TextShape

Direct Known Subclasses:
  AutoShape, TextBox

    public abstract class TextShape

extends SimpleShape

A common superclass of all shapes that can hold text.

Author:
  Yegor Kozlov

Field Summary
`protected static java.awt.font.FontRenderContext` `_frc` Used to calculate text bounds
`protected EscherTextboxWrapper` `_txtbox` Escher container which holds text attributes such as TextHeaderAtom, TextBytesAtom ot TextCharsAtom, StyleTextPropAtom etc.
`protected TextRun` `_txtrun` TextRun object which holds actual text and format data
`static int` `AlignCenter`
`static int` `AlignJustify`
`static int` `AlignLeft` How to align the text
`static int` `AlignRight`
`static int` `AnchorBottom`
`static int` `AnchorBottomBaseline`
`static int` `AnchorBottomCentered`
`static int` `AnchorBottomCenteredBaseline`
`static int` `AnchorMiddle`
`static int` `AnchorMiddleCentered`
`static int` `AnchorTop` How to anchor the text
`static int` `AnchorTopBaseline`
`static int` `AnchorTopCentered`
`static int` `AnchorTopCenteredBaseline`
`static int` `WrapByPoints`
`static int` `WrapNone`
`static int` `WrapSquare` How to wrap the text
`static int` `WrapThrough`
`static int` `WrapTopBottom`

Fields inherited from class org.apache.poi.hslf.model.SimpleShape
`_clientData, _clientRecords, DEFAULT_LINE_WIDTH`

Fields inherited from class org.apache.poi.hslf.model.Shape
`_escherContainer, _fill, _parent, _sheet, EMU_PER_CENTIMETER, EMU_PER_INCH, EMU_PER_POINT, logger, MASTER_DPI, PIXEL_DPI, POINT_DPI`

Constructor Summary
`` `TextShape()` Create a new TextBox.
`protected` `TextShape(EscherContainerRecord escherRecord, Shape parent)` Create a TextBox object and initialize it from the supplied Record container.
`` `TextShape(Shape parent)` Create a new TextBox.

Method Summary
`protected void` `afterInsert(Sheet sh)` When a textbox is added to a sheet we need to tell upper-level `PPDrawing` about it.
`TextRun` `createTextRun()`
`void` `draw(java.awt.Graphics2D graphics)`
`protected EscherTextboxWrapper` `getEscherTextboxWrapper()`
`int` `getHorizontalAlignment()` Gets the type of horizontal alignment for the text.
`float` `getMarginBottom()` 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.
`float` `getMarginLeft()` 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.
`float` `getMarginRight()` 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.
`float` `getMarginTop()` 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.
`OEPlaceholderAtom` `getPlaceholderAtom()` Return `OEPlaceholderAtom`, the atom that describes a placeholder.
`java.lang.String` `getText()` Returns the text contained in this text frame.
`int` `getTextId()`
`TextRun` `getTextRun()`
`int` `getVerticalAlignment()` Returns the type of vertical alignment for the text.
`int` `getWordWrap()` Returns the value indicating word wrap.
`protected void` `initTextRun()`
`java.awt.geom.Rectangle2D` `resizeToFitText()` Adjust the size of the TextShape so it encompasses the text inside it.
`protected void` `setDefaultTextProperties(TextRun _txtrun)` Set default properties for the TextRun.
`void` `setHorizontalAlignment(int align)` Sets the type of horizontal alignment for the text.
`void` `setHyperlink(int linkId, int beginIndex, int endIndex)` Assigns a hyperlink to this text shape
`void` `setMarginBottom(float margin)` Sets the botom margin.
`void` `setMarginLeft(float margin)` Sets the left margin.
`void` `setMarginRight(float margin)` Sets the right margin.
`void` `setMarginTop(float margin)` Sets the top margin.
`void` `setSheet(Sheet sheet)` Assign the `SlideShow` this shape belongs to
`void` `setText(java.lang.String text)` Sets the text contained in this text frame.
`void` `setTextId(int id)` Sets text ID
`void` `setVerticalAlignment(int align)` Sets the type of vertical alignment for the text.
`void` `setWordWrap(int wrap)` Specifies how the text should be wrapped

Methods inherited from class org.apache.poi.hslf.model.SimpleShape
`createSpContainer, getClientDataRecord, getClientRecords, getFillColor, getFlipHorizontal, getFlipVertical, getLineColor, getLineDashing, getLineStyle, getLineWidth, getLogicalAnchor2D, getRotation, setFillColor, setHyperlink, setLineColor, setLineDashing, setLineStyle, setLineWidth, setRotation, updateClientData`

Methods inherited from class org.apache.poi.hslf.model.Shape
`getAnchor, getAnchor2D, getEscherChild, getEscherProperty, getEscherProperty, getEscherProperty, getFill, getHyperlink, getOutline, getParent, getShapeId, getShapeName, getShapeType, getSheet, getSpContainer, moveTo, setAnchor, setEscherProperty, setEscherProperty, setShapeId, setShapeType`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### AnchorTop

    public static final int AnchorTop

  How to anchor the text

  See Also:
    Constant Field Values

### AnchorMiddle

    public static final int AnchorMiddle

See Also:
  Constant Field Values

### AnchorBottom

    public static final int AnchorBottom

See Also:
  Constant Field Values

### AnchorTopCentered

    public static final int AnchorTopCentered

See Also:
  Constant Field Values

### AnchorMiddleCentered

    public static final int AnchorMiddleCentered

See Also:
  Constant Field Values

### AnchorBottomCentered

    public static final int AnchorBottomCentered

See Also:
  Constant Field Values

### AnchorTopBaseline

    public static final int AnchorTopBaseline

See Also:
  Constant Field Values

### AnchorBottomBaseline

    public static final int AnchorBottomBaseline

See Also:
  Constant Field Values

### AnchorTopCenteredBaseline

    public static final int AnchorTopCenteredBaseline

See Also:
  Constant Field Values

### AnchorBottomCenteredBaseline

    public static final int AnchorBottomCenteredBaseline

See Also:
  Constant Field Values

### WrapSquare

    public static final int WrapSquare

  How to wrap the text

  See Also:
    Constant Field Values

### WrapByPoints

    public static final int WrapByPoints

See Also:
  Constant Field Values

### WrapNone

    public static final int WrapNone

See Also:
  Constant Field Values

### WrapTopBottom

    public static final int WrapTopBottom

See Also:
  Constant Field Values

### WrapThrough

    public static final int WrapThrough

See Also:
  Constant Field Values

### AlignLeft

    public static final int AlignLeft

  How to align the text

  See Also:
    Constant Field Values

### AlignCenter

    public static final int AlignCenter

See Also:
  Constant Field Values

### AlignRight

    public static final int AlignRight

See Also:
  Constant Field Values

### AlignJustify

    public static final int AlignJustify

See Also:
  Constant Field Values

### _txtrun

    protected TextRun _txtrun

  TextRun object which holds actual text and format data

### _txtbox

    protected EscherTextboxWrapper _txtbox

  Escher container which holds text attributes such as TextHeaderAtom, TextBytesAtom ot TextCharsAtom, StyleTextPropAtom etc.

### _frc

    protected static final java.awt.font.FontRenderContext _frc

  Used to calculate text bounds

Constructor Detail

### TextShape

    protected TextShape(EscherContainerRecord escherRecord,
                        Shape parent)

  Create a TextBox object and initialize it from the supplied Record container.

  Parameters:
    `escherRecord` - `EscherSpContainer` container which holds information about this shape
    `parent` - the parent of the shape

### TextShape

    public TextShape(Shape parent)

  Create a new TextBox. This constructor is used when a new shape is created.

  Parameters:
    `parent` - the parent of this Shape. For example, if this text box is a cell in a table then the parent is Table.

### TextShape

    public TextShape()

  Create a new TextBox. This constructor is used when a new shape is created.

Method Detail

### createTextRun

    public TextRun createTextRun()

### setDefaultTextProperties

    protected void setDefaultTextProperties(TextRun _txtrun)

  Set default properties for the TextRun. Depending on the text and shape type the defaults are different: TextBox: align=left, valign=top AutoShape: align=center, valign=middle

### getText

    public java.lang.String getText()

  Returns the text contained in this text frame.

  Returns:
    the text string for this textbox.

### setText

    public void setText(java.lang.String text)

  Sets the text contained in this text frame.

  Parameters:
    `text` - the text string used by this object.

### afterInsert

    protected void afterInsert(Sheet sh)

  When a textbox is added to a sheet we need to tell upper-level `PPDrawing` about it.

  Overrides:
    `afterInsert` in class `Shape`
  Parameters:
    `sh` - the sheet we are adding to

### getEscherTextboxWrapper

    protected EscherTextboxWrapper getEscherTextboxWrapper()

### resizeToFitText

    public java.awt.geom.Rectangle2D resizeToFitText()

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

  Returns:
    a `Rectangle2D` that is the bounds of this `TextShape`.

### getVerticalAlignment

    public int getVerticalAlignment()

  Returns the type of vertical alignment for the text. One of the `Anchor*` constants defined in this class.

  Returns:
    the type of alignment

### setVerticalAlignment

    public void setVerticalAlignment(int align)

  Sets the type of vertical alignment for the text. One of the `Anchor*` constants defined in this class.

  Parameters:
    `align` - - the type of alignment

### setHorizontalAlignment

    public void setHorizontalAlignment(int align)

  Sets the type of horizontal alignment for the text. One of the `Align*` constants defined in this class.

  Parameters:
    `align` - - the type of horizontal alignment

### getHorizontalAlignment

    public int getHorizontalAlignment()

  Gets the type of horizontal alignment for the text. One of the `Align*` constants defined in this class.

  Returns:
    align - the type of horizontal alignment

### getMarginBottom

    public float getMarginBottom()

  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. Default value is 1/20 inch.

  Returns:
    the botom margin

### setMarginBottom

    public void setMarginBottom(float margin)

  Sets the botom margin.

  Parameters:
    `margin` - the bottom margin
  See Also:
    `getMarginBottom()`

### getMarginLeft

    public float getMarginLeft()

  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. Default value is 1/10 inch.

  Returns:
    the left margin

### setMarginLeft

    public void setMarginLeft(float margin)

  Sets the left margin.

  Parameters:
    `margin` - the left margin
  See Also:
    `getMarginLeft()`

### getMarginRight

    public float getMarginRight()

  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. Default value is 1/10 inch.

  Returns:
    the right margin

### setMarginRight

    public void setMarginRight(float margin)

  Sets the right margin.

  Parameters:
    `margin` - the right margin
  See Also:
    `getMarginRight()`

### getMarginTop

    public float getMarginTop()

  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. Default value is 1/20 inch.

  Returns:
    the top margin

### setMarginTop

    public void setMarginTop(float margin)

  Sets the top margin.

  Parameters:
    `margin` - the top margin
  See Also:
    `getMarginTop()`

### getWordWrap

    public int getWordWrap()

  Returns the value indicating word wrap.

  Returns:
    the value indicating word wrap. Must be one of the `Wrap*` constants defined in this class.

### setWordWrap

    public void setWordWrap(int wrap)

  Specifies how the text should be wrapped

  Parameters:
    `wrap` - the value indicating how the text should be wrapped. Must be one of the `Wrap*` constants defined in this class.

### getTextId

    public int getTextId()

  Returns:
    id for the text.

### setTextId

    public void setTextId(int id)

  Sets text ID

  Parameters:
    `id` - of the text

### getTextRun

    public TextRun getTextRun()

  Returns:
    the TextRun object for this text box

### setSheet

    public void setSheet(Sheet sheet)

  Description copied from class: `Shape`
  Assign the `SlideShow` this shape belongs to

  Overrides:
    `setSheet` in class `Shape`
  Parameters:
    `sheet` - owner of this shape

### initTextRun

    protected void initTextRun()

### draw

    public void draw(java.awt.Graphics2D graphics)

  Overrides:
    `draw` in class `SimpleShape`

### getPlaceholderAtom

    public OEPlaceholderAtom getPlaceholderAtom()

  Return `OEPlaceholderAtom`, the atom that describes a placeholder.

  Returns:
    `OEPlaceholderAtom` or `null` if not found

### setHyperlink

    public void setHyperlink(int linkId,
                             int beginIndex,
                             int endIndex)

  Assigns a hyperlink to this text shape

  Parameters:
    `linkId` - id of the hyperlink, @see org.apache.poi.hslf.usermodel.SlideShow#addHyperlink(Hyperlink)
    `beginIndex` - the beginning index, inclusive.
    `endIndex` - the ending index, exclusive.
  See Also:
    `SlideShow.addHyperlink(Hyperlink)`

Copyright 2012 The Apache Software Foundation or its licensors, as applicable.