Java Code Examples for sun.font.TextLabelFactory#getFontRenderContext()

The following examples show how to use sun.font.TextLabelFactory#getFontRenderContext() . 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 jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 2
Source File: TextLine.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 3
Source File: TextLine.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 4
Source File: TextLine.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 5
Source File: TextLine.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 6
Source File: TextLine.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 7
Source File: TextLine.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 8
Source File: TextLine.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 9
Source File: TextLine.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 10
Source File: TextLine.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 11
Source File: TextLine.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 12
Source File: TextLine.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 13
Source File: TextLine.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
/**
 * Create a TextLine from the Font and character data over the
 * range.  The range is relative to both the StyledParagraph and the
 * character array.
 */
public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets) {

    factory.setLineContext(0, chars.length);

    Bidi lineBidi = factory.getLineBidi();
    int[] charsLtoV = null;
    byte[] levels = null;

    if (lineBidi != null) {
        levels = BidiUtils.getLevels(lineBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
    }

    TextLineComponent[] components =
        getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory);

    return new TextLine(factory.getFontRenderContext(), components, baselineOffsets,
                        chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
 
Example 14
Source File: TextLine.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Returns an array (in logical order) of the TextLineComponents representing
 * the text.  The components are both logically and visually contiguous.
 */
public static TextLineComponent[] getComponents(StyledParagraph styledParagraph,
                                                char[] chars,
                                                int textStart,
                                                int textLimit,
                                                int[] charsLtoV,
                                                byte[] levels,
                                                TextLabelFactory factory) {

    FontRenderContext frc = factory.getFontRenderContext();

    int numComponents = 0;
    TextLineComponent[] tempComponents = new TextLineComponent[1];

    int pos = textStart;
    do {
        int runLimit = Math.min(styledParagraph.getRunLimit(pos), textLimit);

        Decoration decorator = styledParagraph.getDecorationAt(pos);

        Object graphicOrFont = styledParagraph.getFontOrGraphicAt(pos);

        if (graphicOrFont instanceof GraphicAttribute) {
            // AffineTransform baseRot = styledParagraph.getBaselineRotationAt(pos);
            // !!! For now, let's assign runs of text with both fonts and graphic attributes
            // a null rotation (e.g. the baseline rotation goes away when a graphic
            // is applied.
            AffineTransform baseRot = null;
            GraphicAttribute graphicAttribute = (GraphicAttribute) graphicOrFont;
            do {
                int chunkLimit = firstVisualChunk(charsLtoV, levels,
                                pos, runLimit);

                GraphicComponent nextGraphic =
                    new GraphicComponent(graphicAttribute, decorator, charsLtoV, levels, pos, chunkLimit, baseRot);
                pos = chunkLimit;

                ++numComponents;
                if (numComponents >= tempComponents.length) {
                    tempComponents = expandArray(tempComponents);
                }

                tempComponents[numComponents-1] = nextGraphic;

            } while(pos < runLimit);
        }
        else {
            Font font = (Font) graphicOrFont;

            tempComponents = createComponentsOnRun(pos, runLimit,
                                                    chars,
                                                    charsLtoV, levels,
                                                    factory, font, null,
                                                    frc,
                                                    decorator,
                                                    tempComponents,
                                                    numComponents);
            pos = runLimit;
            numComponents = tempComponents.length;
            while (tempComponents[numComponents-1] == null) {
                numComponents -= 1;
            }
        }

    } while (pos < textLimit);

    TextLineComponent[] components;
    if (tempComponents.length == numComponents) {
        components = tempComponents;
    }
    else {
        components = new TextLineComponent[numComponents];
        System.arraycopy(tempComponents, 0, components, 0, numComponents);
    }

    return components;
}
 
Example 15
Source File: TextLine.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an array (in logical order) of the TextLineComponents representing
 * the text.  The components are both logically and visually contiguous.
 */
public static TextLineComponent[] getComponents(StyledParagraph styledParagraph,
                                                char[] chars,
                                                int textStart,
                                                int textLimit,
                                                int[] charsLtoV,
                                                byte[] levels,
                                                TextLabelFactory factory) {

    FontRenderContext frc = factory.getFontRenderContext();

    int numComponents = 0;
    TextLineComponent[] tempComponents = new TextLineComponent[1];

    int pos = textStart;
    do {
        int runLimit = Math.min(styledParagraph.getRunLimit(pos), textLimit);

        Decoration decorator = styledParagraph.getDecorationAt(pos);

        Object graphicOrFont = styledParagraph.getFontOrGraphicAt(pos);

        if (graphicOrFont instanceof GraphicAttribute) {
            // AffineTransform baseRot = styledParagraph.getBaselineRotationAt(pos);
            // !!! For now, let's assign runs of text with both fonts and graphic attributes
            // a null rotation (e.g. the baseline rotation goes away when a graphic
            // is applied.
            AffineTransform baseRot = null;
            GraphicAttribute graphicAttribute = (GraphicAttribute) graphicOrFont;
            do {
                int chunkLimit = firstVisualChunk(charsLtoV, levels,
                                pos, runLimit);

                GraphicComponent nextGraphic =
                    new GraphicComponent(graphicAttribute, decorator, charsLtoV, levels, pos, chunkLimit, baseRot);
                pos = chunkLimit;

                ++numComponents;
                if (numComponents >= tempComponents.length) {
                    tempComponents = expandArray(tempComponents);
                }

                tempComponents[numComponents-1] = nextGraphic;

            } while(pos < runLimit);
        }
        else {
            Font font = (Font) graphicOrFont;

            tempComponents = createComponentsOnRun(pos, runLimit,
                                                    chars,
                                                    charsLtoV, levels,
                                                    factory, font, null,
                                                    frc,
                                                    decorator,
                                                    tempComponents,
                                                    numComponents);
            pos = runLimit;
            numComponents = tempComponents.length;
            while (tempComponents[numComponents-1] == null) {
                numComponents -= 1;
            }
        }

    } while (pos < textLimit);

    TextLineComponent[] components;
    if (tempComponents.length == numComponents) {
        components = tempComponents;
    }
    else {
        components = new TextLineComponent[numComponents];
        System.arraycopy(tempComponents, 0, components, 0, numComponents);
    }

    return components;
}
 
Example 16
Source File: TextLine.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an array (in logical order) of the TextLineComponents representing
 * the text.  The components are both logically and visually contiguous.
 */
public static TextLineComponent[] getComponents(StyledParagraph styledParagraph,
                                                char[] chars,
                                                int textStart,
                                                int textLimit,
                                                int[] charsLtoV,
                                                byte[] levels,
                                                TextLabelFactory factory) {

    FontRenderContext frc = factory.getFontRenderContext();

    int numComponents = 0;
    TextLineComponent[] tempComponents = new TextLineComponent[1];

    int pos = textStart;
    do {
        int runLimit = Math.min(styledParagraph.getRunLimit(pos), textLimit);

        Decoration decorator = styledParagraph.getDecorationAt(pos);

        Object graphicOrFont = styledParagraph.getFontOrGraphicAt(pos);

        if (graphicOrFont instanceof GraphicAttribute) {
            // AffineTransform baseRot = styledParagraph.getBaselineRotationAt(pos);
            // !!! For now, let's assign runs of text with both fonts and graphic attributes
            // a null rotation (e.g. the baseline rotation goes away when a graphic
            // is applied.
            AffineTransform baseRot = null;
            GraphicAttribute graphicAttribute = (GraphicAttribute) graphicOrFont;
            do {
                int chunkLimit = firstVisualChunk(charsLtoV, levels,
                                pos, runLimit);

                GraphicComponent nextGraphic =
                    new GraphicComponent(graphicAttribute, decorator, charsLtoV, levels, pos, chunkLimit, baseRot);
                pos = chunkLimit;

                ++numComponents;
                if (numComponents >= tempComponents.length) {
                    tempComponents = expandArray(tempComponents);
                }

                tempComponents[numComponents-1] = nextGraphic;

            } while(pos < runLimit);
        }
        else {
            Font font = (Font) graphicOrFont;

            tempComponents = createComponentsOnRun(pos, runLimit,
                                                    chars,
                                                    charsLtoV, levels,
                                                    factory, font, null,
                                                    frc,
                                                    decorator,
                                                    tempComponents,
                                                    numComponents);
            pos = runLimit;
            numComponents = tempComponents.length;
            while (tempComponents[numComponents-1] == null) {
                numComponents -= 1;
            }
        }

    } while (pos < textLimit);

    TextLineComponent[] components;
    if (tempComponents.length == numComponents) {
        components = tempComponents;
    }
    else {
        components = new TextLineComponent[numComponents];
        System.arraycopy(tempComponents, 0, components, 0, numComponents);
    }

    return components;
}
 
Example 17
Source File: TextLine.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an array (in logical order) of the TextLineComponents representing
 * the text.  The components are both logically and visually contiguous.
 */
public static TextLineComponent[] getComponents(StyledParagraph styledParagraph,
                                                char[] chars,
                                                int textStart,
                                                int textLimit,
                                                int[] charsLtoV,
                                                byte[] levels,
                                                TextLabelFactory factory) {

    FontRenderContext frc = factory.getFontRenderContext();

    int numComponents = 0;
    TextLineComponent[] tempComponents = new TextLineComponent[1];

    int pos = textStart;
    do {
        int runLimit = Math.min(styledParagraph.getRunLimit(pos), textLimit);

        Decoration decorator = styledParagraph.getDecorationAt(pos);

        Object graphicOrFont = styledParagraph.getFontOrGraphicAt(pos);

        if (graphicOrFont instanceof GraphicAttribute) {
            // AffineTransform baseRot = styledParagraph.getBaselineRotationAt(pos);
            // !!! For now, let's assign runs of text with both fonts and graphic attributes
            // a null rotation (e.g. the baseline rotation goes away when a graphic
            // is applied.
            AffineTransform baseRot = null;
            GraphicAttribute graphicAttribute = (GraphicAttribute) graphicOrFont;
            do {
                int chunkLimit = firstVisualChunk(charsLtoV, levels,
                                pos, runLimit);

                GraphicComponent nextGraphic =
                    new GraphicComponent(graphicAttribute, decorator, charsLtoV, levels, pos, chunkLimit, baseRot);
                pos = chunkLimit;

                ++numComponents;
                if (numComponents >= tempComponents.length) {
                    tempComponents = expandArray(tempComponents);
                }

                tempComponents[numComponents-1] = nextGraphic;

            } while(pos < runLimit);
        }
        else {
            Font font = (Font) graphicOrFont;

            tempComponents = createComponentsOnRun(pos, runLimit,
                                                    chars,
                                                    charsLtoV, levels,
                                                    factory, font, null,
                                                    frc,
                                                    decorator,
                                                    tempComponents,
                                                    numComponents);
            pos = runLimit;
            numComponents = tempComponents.length;
            while (tempComponents[numComponents-1] == null) {
                numComponents -= 1;
            }
        }

    } while (pos < textLimit);

    TextLineComponent[] components;
    if (tempComponents.length == numComponents) {
        components = tempComponents;
    }
    else {
        components = new TextLineComponent[numComponents];
        System.arraycopy(tempComponents, 0, components, 0, numComponents);
    }

    return components;
}
 
Example 18
Source File: TextLine.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an array (in logical order) of the TextLineComponents representing
 * the text.  The components are both logically and visually contiguous.
 */
public static TextLineComponent[] getComponents(StyledParagraph styledParagraph,
                                                char[] chars,
                                                int textStart,
                                                int textLimit,
                                                int[] charsLtoV,
                                                byte[] levels,
                                                TextLabelFactory factory) {

    FontRenderContext frc = factory.getFontRenderContext();

    int numComponents = 0;
    TextLineComponent[] tempComponents = new TextLineComponent[1];

    int pos = textStart;
    do {
        int runLimit = Math.min(styledParagraph.getRunLimit(pos), textLimit);

        Decoration decorator = styledParagraph.getDecorationAt(pos);

        Object graphicOrFont = styledParagraph.getFontOrGraphicAt(pos);

        if (graphicOrFont instanceof GraphicAttribute) {
            // AffineTransform baseRot = styledParagraph.getBaselineRotationAt(pos);
            // !!! For now, let's assign runs of text with both fonts and graphic attributes
            // a null rotation (e.g. the baseline rotation goes away when a graphic
            // is applied.
            AffineTransform baseRot = null;
            GraphicAttribute graphicAttribute = (GraphicAttribute) graphicOrFont;
            do {
                int chunkLimit = firstVisualChunk(charsLtoV, levels,
                                pos, runLimit);

                GraphicComponent nextGraphic =
                    new GraphicComponent(graphicAttribute, decorator, charsLtoV, levels, pos, chunkLimit, baseRot);
                pos = chunkLimit;

                ++numComponents;
                if (numComponents >= tempComponents.length) {
                    tempComponents = expandArray(tempComponents);
                }

                tempComponents[numComponents-1] = nextGraphic;

            } while(pos < runLimit);
        }
        else {
            Font font = (Font) graphicOrFont;

            tempComponents = createComponentsOnRun(pos, runLimit,
                                                    chars,
                                                    charsLtoV, levels,
                                                    factory, font, null,
                                                    frc,
                                                    decorator,
                                                    tempComponents,
                                                    numComponents);
            pos = runLimit;
            numComponents = tempComponents.length;
            while (tempComponents[numComponents-1] == null) {
                numComponents -= 1;
            }
        }

    } while (pos < textLimit);

    TextLineComponent[] components;
    if (tempComponents.length == numComponents) {
        components = tempComponents;
    }
    else {
        components = new TextLineComponent[numComponents];
        System.arraycopy(tempComponents, 0, components, 0, numComponents);
    }

    return components;
}
 
Example 19
Source File: TextLine.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an array (in logical order) of the TextLineComponents representing
 * the text.  The components are both logically and visually contiguous.
 */
public static TextLineComponent[] getComponents(StyledParagraph styledParagraph,
                                                char[] chars,
                                                int textStart,
                                                int textLimit,
                                                int[] charsLtoV,
                                                byte[] levels,
                                                TextLabelFactory factory) {

    FontRenderContext frc = factory.getFontRenderContext();

    int numComponents = 0;
    TextLineComponent[] tempComponents = new TextLineComponent[1];

    int pos = textStart;
    do {
        int runLimit = Math.min(styledParagraph.getRunLimit(pos), textLimit);

        Decoration decorator = styledParagraph.getDecorationAt(pos);

        Object graphicOrFont = styledParagraph.getFontOrGraphicAt(pos);

        if (graphicOrFont instanceof GraphicAttribute) {
            // AffineTransform baseRot = styledParagraph.getBaselineRotationAt(pos);
            // !!! For now, let's assign runs of text with both fonts and graphic attributes
            // a null rotation (e.g. the baseline rotation goes away when a graphic
            // is applied.
            AffineTransform baseRot = null;
            GraphicAttribute graphicAttribute = (GraphicAttribute) graphicOrFont;
            do {
                int chunkLimit = firstVisualChunk(charsLtoV, levels,
                                pos, runLimit);

                GraphicComponent nextGraphic =
                    new GraphicComponent(graphicAttribute, decorator, charsLtoV, levels, pos, chunkLimit, baseRot);
                pos = chunkLimit;

                ++numComponents;
                if (numComponents >= tempComponents.length) {
                    tempComponents = expandArray(tempComponents);
                }

                tempComponents[numComponents-1] = nextGraphic;

            } while(pos < runLimit);
        }
        else {
            Font font = (Font) graphicOrFont;

            tempComponents = createComponentsOnRun(pos, runLimit,
                                                    chars,
                                                    charsLtoV, levels,
                                                    factory, font, null,
                                                    frc,
                                                    decorator,
                                                    tempComponents,
                                                    numComponents);
            pos = runLimit;
            numComponents = tempComponents.length;
            while (tempComponents[numComponents-1] == null) {
                numComponents -= 1;
            }
        }

    } while (pos < textLimit);

    TextLineComponent[] components;
    if (tempComponents.length == numComponents) {
        components = tempComponents;
    }
    else {
        components = new TextLineComponent[numComponents];
        System.arraycopy(tempComponents, 0, components, 0, numComponents);
    }

    return components;
}
 
Example 20
Source File: TextLine.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an array (in logical order) of the TextLineComponents representing
 * the text.  The components are both logically and visually contiguous.
 */
public static TextLineComponent[] getComponents(StyledParagraph styledParagraph,
                                                char[] chars,
                                                int textStart,
                                                int textLimit,
                                                int[] charsLtoV,
                                                byte[] levels,
                                                TextLabelFactory factory) {

    FontRenderContext frc = factory.getFontRenderContext();

    int numComponents = 0;
    TextLineComponent[] tempComponents = new TextLineComponent[1];

    int pos = textStart;
    do {
        int runLimit = Math.min(styledParagraph.getRunLimit(pos), textLimit);

        Decoration decorator = styledParagraph.getDecorationAt(pos);

        Object graphicOrFont = styledParagraph.getFontOrGraphicAt(pos);

        if (graphicOrFont instanceof GraphicAttribute) {
            // AffineTransform baseRot = styledParagraph.getBaselineRotationAt(pos);
            // !!! For now, let's assign runs of text with both fonts and graphic attributes
            // a null rotation (e.g. the baseline rotation goes away when a graphic
            // is applied.
            AffineTransform baseRot = null;
            GraphicAttribute graphicAttribute = (GraphicAttribute) graphicOrFont;
            do {
                int chunkLimit = firstVisualChunk(charsLtoV, levels,
                                pos, runLimit);

                GraphicComponent nextGraphic =
                    new GraphicComponent(graphicAttribute, decorator, charsLtoV, levels, pos, chunkLimit, baseRot);
                pos = chunkLimit;

                ++numComponents;
                if (numComponents >= tempComponents.length) {
                    tempComponents = expandArray(tempComponents);
                }

                tempComponents[numComponents-1] = nextGraphic;

            } while(pos < runLimit);
        }
        else {
            Font font = (Font) graphicOrFont;

            tempComponents = createComponentsOnRun(pos, runLimit,
                                                    chars,
                                                    charsLtoV, levels,
                                                    factory, font, null,
                                                    frc,
                                                    decorator,
                                                    tempComponents,
                                                    numComponents);
            pos = runLimit;
            numComponents = tempComponents.length;
            while (tempComponents[numComponents-1] == null) {
                numComponents -= 1;
            }
        }

    } while (pos < textLimit);

    TextLineComponent[] components;
    if (tempComponents.length == numComponents) {
        components = tempComponents;
    }
    else {
        components = new TextLineComponent[numComponents];
        System.arraycopy(tempComponents, 0, components, 0, numComponents);
    }

    return components;
}