org.apache.poi.hslf.model
Class TextBox

java.lang.Object
  extended by org.apache.poi.hslf.model.Shape
      extended by org.apache.poi.hslf.model.SimpleShape
          extended by org.apache.poi.hslf.model.TextBox
Direct Known Subclasses:
Placeholder, TableCell

public class TextBox
extends SimpleShape

Represents a TextFrame shape in PowerPoint.

Contains the text in a text frame as well as the properties and methods that control alignment and anchoring of the text.

Author:
Yegor Kozlov

Field Summary
protected  EscherTextboxWrapper _txtbox
          Escher container which holds text attributes such as TextHeaderAtom, TextBytesAtom ot TextCharsAtom, StyleTextPropAtom etc.
protected  TextRun _txtrun
          Low-level 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.Shape
_escherContainer, _parent, _sheet, EMU_PER_CENTIMETER, EMU_PER_INCH, EMU_PER_POINT, logger, MASTER_DPI, PIXEL_DPI, POINT_DPI
 
Constructor Summary
  TextBox()
          Create a new TextBox.
protected TextBox(EscherContainerRecord escherRecord, Shape parent)
          Create a TextBox object and initialize it from the supplied Record container.
  TextBox(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.
protected  EscherContainerRecord createSpContainer(boolean isChild)
          Create a new textBox and initialize internal structures
 int getHorizontalAlignment()
           
 int 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.
 int getMarginLeft()
          Returns the distance (in EMUs) between the left edge of the text frame and the left edge of the inscribed rectangle of the shape that contains the text.
 int getMarginRight()
          Returns the distance (in EMUs) between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.
 int getMarginTop()
          Returns the distance (in EMUs) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.
 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.
 void resizeToFitText()
          Adjust the size of the TextBox so it encompasses the text inside it.
 void setBackgroundColor(java.awt.Color color)
          The color used to fill this shape.
 void setHorizontalAlignment(int align)
           
 void setMarginBottom(int margin)
          Sets the botom margin.
 void setMarginLeft(int margin)
          Sets the left margin.
 void setMarginRight(int margin)
          Sets the right margin.
 void setMarginTop(int 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
getFillColor, getLineColor, getLineDashing, getLineStyle, getLineWidth, setFillColor, setLineColor, setLineDashing, setLineStyle, setLineWidth
 
Methods inherited from class org.apache.poi.hslf.model.Shape
getAnchor, getColor, getEscherChild, getEscherProperty, getFill, getHyperlink, getParent, getShapeName, getShapeType, getSheet, getSpContainer, moveTo, setAnchor, setEscherProperty, 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
Low-level 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.

Constructor Detail

TextBox

protected TextBox(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

TextBox

public TextBox(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.

TextBox

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

Method Detail

createSpContainer

protected EscherContainerRecord createSpContainer(boolean isChild)
Create a new textBox and initialize internal structures

Overrides:
createSpContainer in class SimpleShape
Parameters:
isChild - true if the Line is inside a group, false otherwise
Returns:
the created EscherContainerRecord which holds shape data

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

resizeToFitText

public void resizeToFitText()
Adjust the size of the TextBox so it encompasses the text inside it.


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)

getHorizontalAlignment

public int getHorizontalAlignment()

getMarginBottom

public int 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(int margin)
Sets the botom margin.

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

getMarginLeft

public int getMarginLeft()
Returns the distance (in EMUs) 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(int margin)
Sets the left margin.

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

getMarginRight

public int getMarginRight()
Returns the distance (in EMUs) 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(int margin)
Sets the right margin.

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

getMarginTop

public int getMarginTop()
Returns the distance (in EMUs) 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(int margin)
Sets the top margin.

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

getWordWrap

public int getWordWrap()
Returns the value indicating word wrap. One of the Wrap* constants defined in this class.

Returns:
the value indicating word wrap

setWordWrap

public void setWordWrap(int wrap)
Specifies how the text should be wrapped

Parameters:
wrap - the value indicating how the text should be wrapped

getTextId

public int getTextId()
Returns:
id for the text.

setTextId

public void setTextId(int id)
Sets text ID

Parameters:
id - of the text

setBackgroundColor

public void setBackgroundColor(java.awt.Color color)
The color used to fill this shape.

Parameters:
color - the background color

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


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