Example usage for java.text AttributedCharacterIterator current

List of usage examples for java.text AttributedCharacterIterator current

Introduction

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

Prototype

public char current();

Source Link

Document

Gets the character at the current position (as returned by getIndex()).

Usage

From source file:org.apache.fop.svg.ACIUtils.java

/**
 * Dumps the contents of an ACI to System.out. Used for debugging only.
 * @param aci the ACI to dump//from  w  ww.  j  av  a2  s. co m
 */
public static void dumpAttrs(AttributedCharacterIterator aci) {
    aci.first();
    Set<Entry<Attribute, Object>> entries = aci.getAttributes().entrySet();
    for (Map.Entry<Attribute, Object> entry : entries) {
        if (entry.getValue() != null) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }
    }
    int start = aci.getBeginIndex();
    System.out.print("AttrRuns: ");
    while (aci.current() != CharacterIterator.DONE) {
        int end = aci.getRunLimit();
        System.out.print("" + (end - start) + ", ");
        aci.setIndex(end);
        if (start == end) {
            break;
        }
        start = end;
    }
    System.out.println("");
}

From source file:org.apache.fop.svg.NativeTextPainter.java

/**
 * Collects all characters from an {@link AttributedCharacterIterator}.
 * @param runaci the character iterator/*from   w w  w.j  a v a2  s.  co  m*/
 * @return the characters
 */
protected CharSequence collectCharacters(AttributedCharacterIterator runaci) {
    StringBuffer chars = new StringBuffer();
    for (runaci.first(); runaci.getIndex() < runaci.getEndIndex();) {
        chars.append(runaci.current());
        runaci.next();
    }
    return chars;
}