Top Description Inners Fields Constructors Methods
com.openhtmltopdf.bidi

public Class ParagraphSplitter

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collections, .HashMap, .List, .Map, .TreeMap, org.w3c.dom.Document, .Element, .Node, .Text, com.openhtmltopdf.css.constants.IdentValue, com.openhtmltopdf.css.style.CalculatedStyle, com.openhtmltopdf.extend.ReplacedElementFactory, com.openhtmltopdf.layout.LayoutContext

This class aims to split text into paragraphs where they can be passed to the BidiSplitter. Each text node in the document is attached to the closest block-like element which we assume paragraphs do not cross.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ParagraphSplitter.FakeParagraph

A fake paragraqph only supports manual BIDI classification.

public static class
ParagraphSplitter.Paragraph

A paragraph object collects the text of one paragraph.

Field Summary

Modifier and TypeField and Description
private List<ParagraphSplitter.Paragraph>
private Map<Element, ParagraphSplitter.Paragraph>
private Map<Text, ParagraphSplitter.Paragraph>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static byte
public ParagraphSplitter.Paragraph
public ParagraphSplitter.Paragraph
lookupParagraph(Text node)

Get the paragraph object that a Text node is associated with.

public void
runBidiOnParagraphs(LayoutContext c)

Run bidi splitting on the document's paragraphs.

private void
splitParagraphs(LayoutContext c, Node parent, ParagraphSplitter.Paragraph nearestBlock)

Here we recursively split everything into paragraphs.

public void
splitRoot(LayoutContext c, Document doc)

This starts everything by recursively dividing the document into paragraphs.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allParagraphsback to summary
private List<ParagraphSplitter.Paragraph> allParagraphs
blocksback to summary
private Map<Element, ParagraphSplitter.Paragraph> blocks
paragraphsback to summary
private Map<Text, ParagraphSplitter.Paragraph> paragraphs

Constructor Detail

ParagraphSplitterback to summary
public ParagraphSplitter()

Method Detail

convertDirectionIdentback to summary
public static byte convertDirectionIdent(IdentValue ident)
lookupBlockElementback to summary
public ParagraphSplitter.Paragraph lookupBlockElement(Element elem)
lookupParagraphback to summary
public ParagraphSplitter.Paragraph lookupParagraph(Text node)

Get the paragraph object that a Text node is associated with. Should never return null.

runBidiOnParagraphsback to summary
public void runBidiOnParagraphs(LayoutContext c)

Run bidi splitting on the document's paragraphs.

splitParagraphsback to summary
private void splitParagraphs(LayoutContext c, Node parent, ParagraphSplitter.Paragraph nearestBlock)

Here we recursively split everything into paragraphs.

splitRootback to summary
public void splitRoot(LayoutContext c, Document doc)

This starts everything by recursively dividing the document into paragraphs.

com.openhtmltopdf.bidi back to summary

public Class ParagraphSplitter.FakeParagraph

extends Paragraph
Class Inheritance

A fake paragraqph only supports manual BIDI classification.

Field Summary

Inherited from com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph:
cssDirectiontextRuns

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected void
add(String text, Text textNode)

Overrides com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.add.

Here we add a textnode and its postion to a list.

public byte
public BidiTextRun
public BidiTextRun
protected void
runBidiSplitter(BidiSplitter splitter, LayoutContext c)

Overrides com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.runBidiSplitter.

Here we call out to the actual BIDI algorithm.

Inherited from com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph:
getCSSDirectiongetFirstCharIndexInParagraph

Constructor Detail

FakeParagraphback to summary
private FakeParagraph(IdentValue direction)

Method Detail

addback to summary
protected void add(String text, Text textNode)

Overrides com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.add.

Doc from com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.add.

Here we add a textnode and its postion to a list. We also build the paragraph string.

Annotations
@Override
getActualDirectionback to summary
public byte getActualDirection()

Overrides com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.getActualDirection.

Annotations
@Override
nextSplitback to summary
public BidiTextRun nextSplit(int startIndexInParagraph)

Overrides com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.nextSplit.

Returns:BidiTextRun

Doc from com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.nextSplit.

the BidiTextRun that starts at or above startIndexInPararagraph.

Annotations
@Override
prevSplitback to summary
public BidiTextRun prevSplit(int startIndexInParagraph)

Overrides com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.prevSplit.

Returns:BidiTextRun

Doc from com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.prevSplit.

the BidiTextRun that starts at or before startIndexInParagraph.

Annotations
@Override
runBidiSplitterback to summary
protected void runBidiSplitter(BidiSplitter splitter, LayoutContext c)

Overrides com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.runBidiSplitter.

Doc from com.openhtmltopdf.bidi.ParagraphSplitter.Paragraph.runBidiSplitter.

Here we call out to the actual BIDI algorithm.

Annotations
@Override
com.openhtmltopdf.bidi back to summary

public Class ParagraphSplitter.Paragraph

extends Object
Class Inheritance
Known Direct Subclasses
com.openhtmltopdf.bidi.ParagraphSplitter.FakeParagraph

A paragraph object collects the text of one paragraph. That is the text in a block element wiht possible holes from BIDI isolation tags. This text is then used to run the Unicode BIDI algorithm splitting text up into runs of LTR and RTL text.

Field Summary

Modifier and TypeField and Description
private byte
private final StringBuilder
protected final IdentValue
private final TreeMap<Integer, BidiTextRun>
protected final Map<Text, Integer>

Constructor Summary

AccessConstructor and Description
private
Paragraph(IdentValue direction)

private
Paragraph(IdentValue direction, boolean isLiveImplementation)

Method Summary

Modifier and TypeMethod and Description
protected void
add(String text, Text textNode)

Here we add a textnode and its postion to a list.

private void
copySplitPointsFromBidiSplitter(BidiSplitter splitter)

Here we copy the split points from the BIDI processor to our tree map for easy access.

public byte
public IdentValue
public int

Returns:

the first char index into this paragraph from a Text node or -1 if not available.
getFirstCharIndexInParagraph
(Text text)

public BidiTextRun

Returns:

the BidiTextRun that starts at or above startIndexInPararagraph.
nextSplit
(int startIndexInParagraph)

public BidiTextRun

Returns:

the BidiTextRun that starts at or before startIndexInParagraph.
prevSplit
(int startIndexInParagraph)

protected void
runBidiSplitter(BidiSplitter splitter, LayoutContext c)

Here we call out to the actual BIDI algorithm.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actualDirectionback to summary
private byte actualDirection
builderback to summary
private final StringBuilder builder
cssDirectionback to summary
protected final IdentValue cssDirection
splitPointsback to summary
private final TreeMap<Integer, BidiTextRun> splitPoints
textRunsback to summary
protected final Map<Text, Integer> textRuns

Constructor Detail

Paragraphback to summary
private Paragraph(IdentValue direction)
Paragraphback to summary
private Paragraph(IdentValue direction, boolean isLiveImplementation)

Method Detail

addback to summary
protected void add(String text, Text textNode)

Here we add a textnode and its postion to a list. We also build the paragraph string.

copySplitPointsFromBidiSplitterback to summary
private void copySplitPointsFromBidiSplitter(BidiSplitter splitter)

Here we copy the split points from the BIDI processor to our tree map for easy access.

getActualDirectionback to summary
public byte getActualDirection()
getCSSDirectionback to summary
public IdentValue getCSSDirection()
getFirstCharIndexInParagraphback to summary
public int getFirstCharIndexInParagraph(Text text)
Returns:int

the first char index into this paragraph from a Text node or -1 if not available.

nextSplitback to summary
public BidiTextRun nextSplit(int startIndexInParagraph)
Returns:BidiTextRun

the BidiTextRun that starts at or above startIndexInPararagraph.

prevSplitback to summary
public BidiTextRun prevSplit(int startIndexInParagraph)
Returns:BidiTextRun

the BidiTextRun that starts at or before startIndexInParagraph.

runBidiSplitterback to summary
protected void runBidiSplitter(BidiSplitter splitter, LayoutContext c)

Here we call out to the actual BIDI algorithm.