org.apache.poi.xslf.usermodel
Class XSLFTextRun

java.lang.Object
  extended by org.apache.poi.xslf.usermodel.XSLFTextRun
All Implemented Interfaces:
TextRun

@Beta
public class XSLFTextRun
extends java.lang.Object
implements TextRun

Represents a run of text within the containing text body. The run element is the lowest level text separation mechanism within a text body.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.TextRun
TextRun.FieldType, TextRun.TextCap
 
Constructor Summary
protected XSLFTextRun(org.apache.xmlbeans.XmlObject r, XSLFTextParagraph p)
           
 
Method Summary
 XSLFHyperlink createHyperlink()
           
 double getCharacterSpacing()
           
 TextRun.FieldType getFieldType()
           
 PaintStyle getFontColor()
           
 java.lang.String getFontFamily()
           
 java.lang.Double getFontSize()
           
 XSLFHyperlink getHyperlink()
           
 byte getPitchAndFamily()
           
 java.lang.String getRawText()
           
protected  org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties getRPr(boolean create)
          Return the character properties
 TextRun.TextCap getTextCap()
           
 org.apache.xmlbeans.XmlObject getXmlObject()
          Return the text run xmlbeans object.
 boolean isBold()
           
 boolean isItalic()
           
 boolean isStrikethrough()
           
 boolean isSubscript()
           
 boolean isSuperscript()
           
 boolean isUnderlined()
           
 void setBaselineOffset(double baselineOffset)
          Set the baseline for both the superscript and subscript fonts.
 void setBold(boolean bold)
           
 void setCharacterSpacing(double spc)
          Set the spacing between characters within a text run.
 void setFontColor(java.awt.Color color)
           
 void setFontColor(PaintStyle color)
           
 void setFontFamily(java.lang.String typeface)
           
 void setFontFamily(java.lang.String typeface, byte charset, byte pictAndFamily, boolean isSymbol)
           
 void setFontSize(java.lang.Double fontSize)
           
 void setItalic(boolean italic)
           
 void setStrikethrough(boolean strike)
           
 void setSubscript(boolean flag)
          Set whether the text in this run is formatted as subscript.
 void setSuperscript(boolean flag)
          Set whether the text in this run is formatted as superscript.
 void setText(java.lang.String text)
           
 void setUnderlined(boolean underline)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XSLFTextRun

protected XSLFTextRun(org.apache.xmlbeans.XmlObject r,
                      XSLFTextParagraph p)
Method Detail

getRawText

public java.lang.String getRawText()
Specified by:
getRawText in interface TextRun

setText

public void setText(java.lang.String text)
Specified by:
setText in interface TextRun

getXmlObject

public org.apache.xmlbeans.XmlObject getXmlObject()
Return the text run xmlbeans object. Depending on the type of text run, this can be CTTextField, CTTextLineBreak or usually a CTRegularTextRun

Returns:
the xmlbeans object

setFontColor

public void setFontColor(java.awt.Color color)
Specified by:
setFontColor in interface TextRun

setFontColor

public void setFontColor(PaintStyle color)
Specified by:
setFontColor in interface TextRun

getFontColor

public PaintStyle getFontColor()
Specified by:
getFontColor in interface TextRun

setFontSize

public void setFontSize(java.lang.Double fontSize)
Specified by:
setFontSize in interface TextRun

getFontSize

public java.lang.Double getFontSize()
Specified by:
getFontSize in interface TextRun

getCharacterSpacing

public double getCharacterSpacing()
Returns:
the spacing between characters within a text run, If this attribute is omitted than a value of 0 or no adjustment is assumed.

setCharacterSpacing

public void setCharacterSpacing(double spc)
Set the spacing between characters within a text run.

The spacing is specified in points. Positive values will cause the text to expand, negative values to condense.

Parameters:
spc - character spacing in points.

setFontFamily

public void setFontFamily(java.lang.String typeface)
Specified by:
setFontFamily in interface TextRun

setFontFamily

public void setFontFamily(java.lang.String typeface,
                          byte charset,
                          byte pictAndFamily,
                          boolean isSymbol)

getFontFamily

public java.lang.String getFontFamily()
Specified by:
getFontFamily in interface TextRun

getPitchAndFamily

public byte getPitchAndFamily()
Specified by:
getPitchAndFamily in interface TextRun

setStrikethrough

public void setStrikethrough(boolean strike)
Specified by:
setStrikethrough in interface TextRun

isStrikethrough

public boolean isStrikethrough()
Specified by:
isStrikethrough in interface TextRun

isSuperscript

public boolean isSuperscript()
Specified by:
isSuperscript in interface TextRun

setBaselineOffset

public void setBaselineOffset(double baselineOffset)
Set the baseline for both the superscript and subscript fonts.

The size is specified using a percentage. Positive values indicate superscript, negative values indicate subscript.

Parameters:
baselineOffset -

setSuperscript

public void setSuperscript(boolean flag)
Set whether the text in this run is formatted as superscript. Default base line offset is 30%

See Also:
setBaselineOffset(double)

setSubscript

public void setSubscript(boolean flag)
Set whether the text in this run is formatted as subscript. Default base line offset is -25%.

See Also:
setBaselineOffset(double)

isSubscript

public boolean isSubscript()
Specified by:
isSubscript in interface TextRun

getTextCap

public TextRun.TextCap getTextCap()
Specified by:
getTextCap in interface TextRun
Returns:
whether a run of text will be formatted as a superscript text. Default is false.

setBold

public void setBold(boolean bold)
Specified by:
setBold in interface TextRun

isBold

public boolean isBold()
Specified by:
isBold in interface TextRun

setItalic

public void setItalic(boolean italic)
Specified by:
setItalic in interface TextRun

isItalic

public boolean isItalic()
Specified by:
isItalic in interface TextRun

setUnderlined

public void setUnderlined(boolean underline)
Specified by:
setUnderlined in interface TextRun

isUnderlined

public boolean isUnderlined()
Specified by:
isUnderlined in interface TextRun

getRPr

protected org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties getRPr(boolean create)
Return the character properties

Parameters:
create - if true, create an empty character properties object if it doesn't exist
Returns:
the character properties or null if create was false and the properties haven't exist

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

createHyperlink

public XSLFHyperlink createHyperlink()
Specified by:
createHyperlink in interface TextRun

getHyperlink

public XSLFHyperlink getHyperlink()
Specified by:
getHyperlink in interface TextRun

getFieldType

public TextRun.FieldType getFieldType()
Specified by:
getFieldType in interface TextRun