All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.openhtmltopdf.bidi.SimpleBidiSplitter Maven / Gradle / Ivy

Go to download

Open HTML to PDF is a CSS 2.1 renderer written in Java. This artifact contains the core rendering and layout code.

There is a newer version: 1.0.10
Show 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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy