Example usage for java.text AttributedString AttributedString

List of usage examples for java.text AttributedString AttributedString

Introduction

In this page you can find the example usage for java.text AttributedString AttributedString.

Prototype

public AttributedString(AttributedCharacterIterator text, int beginIndex, int endIndex) 

Source Link

Document

Constructs an AttributedString instance with the subrange of the given attributed text represented by AttributedCharacterIterator.

Usage

From source file:net.sf.jasperreports.engine.util.JRStyledTextParser.java

/**
 * Outputs the String representation of a styled text chunk.
 * //ww  w . j a  v a 2  s.c o m
 * @param styledText the styled text
 * @param startIndex the start index
 * @param endIndex the end index
 * @return the String styled text representation of the chunk delimited by
 * the start index and the end index
 * @see #write(Map, AttributedCharacterIterator, String)
 */
public String write(JRStyledText styledText, int startIndex, int endIndex) {
    AttributedCharacterIterator subIterator = new AttributedString(
            styledText.getAttributedString().getIterator(), startIndex, endIndex).getIterator();
    String subText = styledText.getText().substring(startIndex, endIndex);
    return write(styledText.getGlobalAttributes(), subIterator, subText);
}