com.openhtmltopdf.bidi.SimpleBidiSplitter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openhtmltopdf-core Show documentation
Show all versions of openhtmltopdf-core Show documentation
Open HTML to PDF is a CSS 2.1 renderer written in Java. This artifact contains the core rendering and layout code.
The newest version!
package com.openhtmltopdf.bidi;
import java.util.Collections;
import java.util.List;
public class SimpleBidiSplitter implements BidiSplitter {
private List runs;
@Override
public void setParagraph(String paragraph, byte defaultDirection) {
// Commented out test code for testing only!
// int idx = paragraph.indexOf("Flying Saucer");
//
// if (idx >= 0)
// {
// runs = new ArrayList(2);
//
// runs.add(new BidiTextRun(0, idx, BidiSplitter.LTR));
// runs.add(new BidiTextRun(idx, paragraph.length() - idx, BidiSplitter.RTL));
// return;
// }
// Actual code starts here.
runs = Collections.singletonList(new BidiTextRun(0, paragraph.length(), defaultDirection));
}
@Override
public int countTextRuns() {
return runs.size();
}
@Override
public BidiTextRun getVisualRun(int runIndex) {
return runs.get(runIndex);
}
@Override
public byte getBaseDirection(String paragraph) {
return BidiSplitter.LTR;
}
}