Package com.openhtmltopdf.render
Class InlineBox
- java.lang.Object
-
- com.openhtmltopdf.render.InlineBox
-
- All Implemented Interfaces:
Styleable
public class InlineBox extends java.lang.Object implements Styleable
A class which represents a portion of an inline element. If an inline element does not contain any nested elements, then a singleInlineBoxobject will contain the content for the entire element. Otherwise multipleInlineBoxobjects will be created corresponding to each discrete chunk of text appearing in the element. It is not rendered directly (and hence does not extend fromBox), but does play an important role in layout (for example, when calculating min/max widths). Note that it does not contain children. Inline content is stored as a flat list in the layout tree. However,InlineBoxdoes contain enough information to reconstruct the original element nesting and this is, in fact, done during inline layout.- See Also:
InlineLayoutBox
-
-
Field Summary
Fields Modifier and Type Field Description private ContentFunction_contentFunctionprivate org.w3c.dom.Element_elementprivate boolean_endsHereSeeisEndsHere()private int_firstLineWidthprivate BlockBox_footnoteBodyprivate FSFunction_functionprivate int_maxWidthprivate boolean_minMaxCalculatedprivate int_minWidthprivate java.lang.String_originalTextprivate java.lang.String_pseudoElementOrClassprivate boolean_removableWhitespaceprivate boolean_startsHereSeeisStartsHere()private CalculatedStyle_styleprivate java.lang.String_textprivate byte_textDirection
-
Constructor Summary
Constructors Constructor Description InlineBox(java.lang.String text)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendPositioningInfo(java.lang.StringBuilder result)voidapplyTextTransform()private voidcalcMaxWidthFromLineLength(LayoutContext c, int cbWidth, boolean trim)voidcalcMinMaxWidth(LayoutContext c, int cbWidth, boolean trimLeadingSpace)private intcalcMinWidthFromWordLength(LayoutContext c, int cbWidth, boolean trimLeadingSpace, boolean includeWS)ContentFunctiongetContentFunction()org.w3c.dom.ElementgetElement()intgetFirstLineWidth()BlockBoxgetFootnoteBody()FSFunctiongetFunction()private intgetInlineMBP(LayoutContext c, int cbWidth)private intgetMaxCharWidth(LayoutContext c, java.lang.String s)intgetMaxWidth()intgetMinWidth()java.lang.StringgetPseudoElementOrClass()intgetSpaceWidth(LayoutContext c)CalculatedStylegetStyle()java.lang.StringgetText()private java.lang.StringgetText(boolean trimLeadingSpace)bytegetTextDirection()private intgetTextWidth(LayoutContext c, java.lang.String s)intgetTrailingSpaceWidth(LayoutContext c)booleanhasFootnote()booleanisDynamicFunction()booleanisEndsHere()The opposite ofisStartsHere()booleanisRemovableWhitespace()booleanisStartsHere()Whether this is the first InlineBox for a box.voidsetContentFunction(ContentFunction contentFunction)voidsetElement(org.w3c.dom.Element element)voidsetEndsHere(boolean endsHere)SeeisEndsHere()voidsetFootnote(BlockBox footnoteBody)voidsetFunction(FSFunction function)voidsetPseudoElementOrClass(java.lang.String pseudoElementOrClass)voidsetRemovableWhitespace(boolean removeableWhitespace)voidsetStartsHere(boolean startsHere)SeeisStartsHere()voidsetStyle(CalculatedStyle style)voidsetText(java.lang.String text)voidsetTextDirection(byte direction)private java.lang.StringshortText()java.lang.StringtoString()voidtruncateText()
-
-
-
Field Detail
-
_element
private org.w3c.dom.Element _element
-
_originalText
private java.lang.String _originalText
-
_text
private java.lang.String _text
-
_removableWhitespace
private boolean _removableWhitespace
-
_startsHere
private boolean _startsHere
SeeisStartsHere()
-
_endsHere
private boolean _endsHere
SeeisEndsHere()
-
_style
private CalculatedStyle _style
-
_contentFunction
private ContentFunction _contentFunction
-
_function
private FSFunction _function
-
_minMaxCalculated
private boolean _minMaxCalculated
-
_maxWidth
private int _maxWidth
-
_minWidth
private int _minWidth
-
_firstLineWidth
private int _firstLineWidth
-
_pseudoElementOrClass
private java.lang.String _pseudoElementOrClass
-
_textDirection
private byte _textDirection
-
_footnoteBody
private BlockBox _footnoteBody
-
-
Method Detail
-
setTextDirection
public void setTextDirection(byte direction)
- Parameters:
direction- either LTR or RTL fromBidiSplitterinterface.
-
getTextDirection
public byte getTextDirection()
- Returns:
- either LTR or RTL from
BidiSplitterinterface.
-
getText
public java.lang.String getText()
-
setText
public void setText(java.lang.String text)
-
applyTextTransform
public void applyTextTransform()
-
isRemovableWhitespace
public boolean isRemovableWhitespace()
-
setRemovableWhitespace
public void setRemovableWhitespace(boolean removeableWhitespace)
-
isEndsHere
public boolean isEndsHere()
The opposite ofisStartsHere()
-
setEndsHere
public void setEndsHere(boolean endsHere)
SeeisEndsHere()
-
isStartsHere
public boolean isStartsHere()
Whether this is the first InlineBox for a box. For example:[b]one[i]two[/i]three[/b]will create three InlineBox objects and one and two will return true for isStartsHere. This is used for example to decide whether left margin needs to be applied.
-
setStartsHere
public void setStartsHere(boolean startsHere)
SeeisStartsHere()
-
getStyle
public CalculatedStyle getStyle()
-
setStyle
public void setStyle(CalculatedStyle style)
-
getElement
public org.w3c.dom.Element getElement()
- Specified by:
getElementin interfaceStyleable
-
setElement
public void setElement(org.w3c.dom.Element element)
- Specified by:
setElementin interfaceStyleable
-
getContentFunction
public ContentFunction getContentFunction()
-
setContentFunction
public void setContentFunction(ContentFunction contentFunction)
-
isDynamicFunction
public boolean isDynamicFunction()
-
getTextWidth
private int getTextWidth(LayoutContext c, java.lang.String s)
-
getMaxCharWidth
private int getMaxCharWidth(LayoutContext c, java.lang.String s)
-
calcMaxWidthFromLineLength
private void calcMaxWidthFromLineLength(LayoutContext c, int cbWidth, boolean trim)
-
getSpaceWidth
public int getSpaceWidth(LayoutContext c)
-
getTrailingSpaceWidth
public int getTrailingSpaceWidth(LayoutContext c)
-
calcMinWidthFromWordLength
private int calcMinWidthFromWordLength(LayoutContext c, int cbWidth, boolean trimLeadingSpace, boolean includeWS)
-
getText
private java.lang.String getText(boolean trimLeadingSpace)
-
getInlineMBP
private int getInlineMBP(LayoutContext c, int cbWidth)
-
calcMinMaxWidth
public void calcMinMaxWidth(LayoutContext c, int cbWidth, boolean trimLeadingSpace)
-
getMaxWidth
public int getMaxWidth()
-
getMinWidth
public int getMinWidth()
-
getFirstLineWidth
public int getFirstLineWidth()
-
getPseudoElementOrClass
public java.lang.String getPseudoElementOrClass()
- Specified by:
getPseudoElementOrClassin interfaceStyleable
-
setPseudoElementOrClass
public void setPseudoElementOrClass(java.lang.String pseudoElementOrClass)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
appendPositioningInfo
protected void appendPositioningInfo(java.lang.StringBuilder result)
-
shortText
private java.lang.String shortText()
-
getFunction
public FSFunction getFunction()
-
setFunction
public void setFunction(FSFunction function)
-
truncateText
public void truncateText()
-
setFootnote
public void setFootnote(BlockBox footnoteBody)
-
hasFootnote
public boolean hasFootnote()
-
getFootnoteBody
public BlockBox getFootnoteBody()
-
-