sun.text.CodePointIterator Java Examples

The following examples show how to use sun.text.CodePointIterator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TextLine.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #2
Source File: FontResolver.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #3
Source File: TextLine.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #4
Source File: FontResolver.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #5
Source File: TextLine.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #6
Source File: TextLine.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #7
Source File: FontResolver.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #8
Source File: TextLine.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #9
Source File: FontResolver.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #10
Source File: TextLine.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #11
Source File: FontResolver.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #12
Source File: TextLine.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #13
Source File: FontResolver.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #14
Source File: TextLine.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #15
Source File: FontResolver.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #16
Source File: TextLine.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #17
Source File: TextLine.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #18
Source File: FontResolver.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #19
Source File: TextLine.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #20
Source File: FontResolver.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #21
Source File: TextLine.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #22
Source File: TextLine.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #23
Source File: TextLine.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #24
Source File: FontResolver.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #25
Source File: FontResolver.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #26
Source File: TextLine.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #27
Source File: TextLine.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static Font getFontAtCurrentPos(AttributedCharacterIterator aci) {

        Object value = aci.getAttribute(TextAttribute.FONT);
        if (value != null) {
            return (Font) value;
        }
        if (aci.getAttribute(TextAttribute.FAMILY) != null) {
            return Font.getFont(aci.getAttributes());
        }

        int ch = CodePointIterator.create(aci).next();
        if (ch != CodePointIterator.DONE) {
            FontResolver resolver = FontResolver.getInstance();
            return resolver.getFont(resolver.getFontIndex(ch), aci.getAttributes());
        }
        return null;
    }
 
Example #28
Source File: FontResolver.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines the font index for the code point at the current position in the
 * iterator, then advances the iterator to the first code point that has
 * a different index or until the iterator is DONE, and returns the font index.
 * @param iter a code point iterator, this will be advanced past any code
 *             points that have the same font index
 * @return the font index for the initial code point found, or 1 if the iterator
 * was empty.
 */
public int nextFontRunIndex(CodePointIterator iter) {
    int cp = iter.next();
    int fontIndex = 1;
    if (cp != CodePointIterator.DONE) {
        fontIndex = getFontIndex(cp);

        while ((cp = iter.next()) != CodePointIterator.DONE) {
            if (getFontIndex(cp) != fontIndex) {
                iter.prev();
                break;
            }
        }
    }
    return fontIndex;
}
 
Example #29
Source File: StyledParagraph.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Resolve the given chars into Fonts using FontResolver, then add
 * font runs for each.
 */
private void addFonts(char[] chars, Map<? extends Attribute, ?> attributes,
                      int start, int limit) {

    FontResolver resolver = FontResolver.getInstance();
    CodePointIterator iter = CodePointIterator.create(chars, start, limit);
    for (int runStart = iter.charIndex(); runStart < limit; runStart = iter.charIndex()) {
        int fontIndex = resolver.nextFontRunIndex(iter);
        addFont(resolver.getFont(fontIndex, attributes), runStart);
    }
}
 
Example #30
Source File: StyledParagraph.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolve the given chars into Fonts using FontResolver, then add
 * font runs for each.
 */
private void addFonts(char[] chars, Map<? extends Attribute, ?> attributes,
                      int start, int limit) {

    FontResolver resolver = FontResolver.getInstance();
    CodePointIterator iter = CodePointIterator.create(chars, start, limit);
    for (int runStart = iter.charIndex(); runStart < limit; runStart = iter.charIndex()) {
        int fontIndex = resolver.nextFontRunIndex(iter);
        addFont(resolver.getFont(fontIndex, attributes), runStart);
    }
}