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.

Author:
Yegor Kozlov

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.poi.sl.usermodel.TextRun
TextRun.TextCap
 
Method Summary
 XSLFHyperlink createHyperlink()
           
 double getCharacterSpacing()
           
 PaintStyle getFontColor()
          Returns the font color.
 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()
           
 TextRun.TextCap getTextCap()
           
 org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun getXmlObject()
           
 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)
          Specifies whether this run of text will be formatted as bold text
 void setCharacterSpacing(double spc)
          Set the spacing between characters within a text run.
 void setFontColor(java.awt.Color color)
          Sets the (solid) font color - convenience function
 void setFontColor(PaintStyle color)
          Sets the font color
 void setFontFamily(java.lang.String typeface)
          Specifies the typeface, or name of the font that is to be used for this text run.
 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)
          Specifies whether a run of text will be formatted as strikethrough text.
 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 setUnderline(boolean underline)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun getXmlObject()

setFontColor

public void setFontColor(java.awt.Color color)
Description copied from interface: TextRun
Sets the (solid) font color - convenience function

Specified by:
setFontColor in interface TextRun
Parameters:
color - the color

setFontColor

public void setFontColor(PaintStyle color)
Description copied from interface: TextRun
Sets the font color

Specified by:
setFontColor in interface TextRun
Parameters:
color - the color
See Also:
DrawPaint.createSolidPaint(Color)

getFontColor

public PaintStyle getFontColor()
Description copied from interface: TextRun
Returns the font color. This usually returns a PaintStyle.SolidPaint, but but also other classes are possible

Specified by:
getFontColor in interface TextRun
Returns:
the font color/paint
See Also:
DrawPaint.getPaint(java.awt.Graphics2D, PaintStyle), PaintStyle.SolidPaint.getSolidColor(), DrawPaint.applyColorTransform(ColorStyle)

setFontSize

public void setFontSize(java.lang.Double fontSize)
Specified by:
setFontSize in interface TextRun
Parameters:
fontSize - font size in points, if null the underlying fontsize will be unset

getFontSize

public java.lang.Double getFontSize()
Specified by:
getFontSize in interface TextRun
Returns:
font size in points or null if font size is not set.

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)
Specifies the typeface, or name of the font that is to be used for this text run.

Parameters:
typeface - the font to apply to this text run. The value of null unsets the Typeface attrubute from the underlying xml.

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
Returns:
font family or null if not set

getPitchAndFamily

public byte getPitchAndFamily()
Specified by:
getPitchAndFamily in interface TextRun
Returns:
the pitch and family id or -1 if not applicable

setStrikethrough

public void setStrikethrough(boolean strike)
Specifies whether a run of text will be formatted as strikethrough text.

Parameters:
strike - whether a run of text will be formatted as strikethrough text.

isStrikethrough

public boolean isStrikethrough()
Specified by:
isStrikethrough in interface TextRun
Returns:
whether a run of text will be formatted as strikethrough text. Default is false.

isSuperscript

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

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
Returns:
whether a run of text will be formatted as a superscript text. Default is false.

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)
Specifies whether this run of text will be formatted as bold text

Parameters:
bold - whether this run of text will be formatted as bold text

isBold

public boolean isBold()
Specified by:
isBold in interface TextRun
Returns:
whether this run of text is formatted as bold text

setItalic

public void setItalic(boolean italic)
Parameters:
italic - whether this run of text is formatted as italic text

isItalic

public boolean isItalic()
Specified by:
isItalic in interface TextRun
Returns:
whether this run of text is formatted as italic text

setUnderline

public void setUnderline(boolean underline)
Parameters:
underline - whether this run of text is formatted as underlined text

isUnderlined

public boolean isUnderlined()
Specified by:
isUnderlined in interface TextRun
Returns:
whether this run of text is formatted as underlined text

getRPr

protected org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties getRPr()

toString

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

createHyperlink

public XSLFHyperlink createHyperlink()

getHyperlink

public XSLFHyperlink getHyperlink()


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