当前位置: 首页>>代码示例>>Java>>正文


Java BidiUtils.getLevels方法代码示例

本文整理汇总了Java中sun.font.BidiUtils.getLevels方法的典型用法代码示例。如果您正苦于以下问题:Java BidiUtils.getLevels方法的具体用法?Java BidiUtils.getLevels怎么用?Java BidiUtils.getLevels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.font.BidiUtils的用法示例。


在下文中一共展示了BidiUtils.getLevels方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeTextLineOnRange

import sun.font.BidiUtils; //导入方法依赖的package包/类
private TextLine makeTextLineOnRange(int startPos, int limitPos) {

        int[] charsLtoV = null;
        byte[] charLevels = null;

        if (fBidi != null) {
            Bidi lineBidi = fBidi.createLineBidi(startPos, limitPos);
            charLevels = BidiUtils.getLevels(lineBidi);
            int[] charsVtoL = BidiUtils.createVisualToLogicalMap(charLevels);
            charsLtoV = BidiUtils.createInverseMap(charsVtoL);
        }

        TextLineComponent[] components = makeComponentsOnRange(startPos, limitPos);

        return new TextLine(fFrc,
                            components,
                            fBaselineOffsets,
                            fChars,
                            startPos,
                            limitPos,
                            charsLtoV,
                            charLevels,
                            fIsDirectionLTR);

    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:TextMeasurer.java

示例2: createLineFromText

import sun.font.BidiUtils; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:TextLine.java

示例3: makeTextLineOnRange

import sun.font.BidiUtils; //导入方法依赖的package包/类
private TextLine makeTextLineOnRange(int startPos, int limitPos) {

        int[] charsLtoV = null;
        byte[] charLevels = null;

        if (fBidi != null) {
            Bidi lineBidi = fBidi.createLineBidi(startPos, limitPos);
            charLevels = BidiUtils.getLevels(lineBidi);
            int[] charsVtoL = BidiUtils.createVisualToLogicalMap(charLevels);
            charsLtoV = BidiUtils.createInverseMap(charsVtoL);
        }

        TextLineComponent[] components = makeComponentsOnRange(startPos, limitPos);

        return new TextLine(fFrc, 
                            components, 
                            fBaselineOffsets,
                            fChars,
                            startPos,
                            limitPos,
                            charsLtoV,
                            charLevels,
                            fIsDirectionLTR);

    }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:26,代码来源:TextMeasurer.java

示例4: generateComponents

import sun.font.BidiUtils; //导入方法依赖的package包/类
/**
 * Generate components for the paragraph.  fChars, fBidi should have been
 * initialized already.
 */
private void generateComponents(int startingAt, int endingAt) {

    if (collectStats) {
        formattedChars += (endingAt-startingAt);
    }
    int layoutFlags = 0; // no extra info yet, bidi determines run and line direction
    TextLabelFactory factory = new TextLabelFactory(fFrc, fChars, fBidi, layoutFlags);

    int[] charsLtoV = null;

    if (fBidi != null) {
        fLevels = BidiUtils.getLevels(fBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(fLevels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
        fIsDirectionLTR = fBidi.baseIsLeftToRight();
    }
    else {
        fLevels = null;
        fIsDirectionLTR = true;
    }

    try {
        fComponents = TextLine.getComponents(
            fParagraph, fChars, startingAt, endingAt, charsLtoV, fLevels, factory);
    }
    catch(IllegalArgumentException e) {
        System.out.println("startingAt="+startingAt+"; endingAt="+endingAt);
        System.out.println("fComponentLimit="+fComponentLimit);
        throw e;
    }

    fComponentStart = startingAt;
    fComponentLimit = endingAt;
    //debugFormatCount += (endingAt-startingAt);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:TextMeasurer.java

示例5: generateComponents

import sun.font.BidiUtils; //导入方法依赖的package包/类
/**
 * Generate components for the paragraph.  fChars, fBidi should have been 
 * initialized already.
 */
private void generateComponents(int startingAt, int endingAt) {
    
    if (collectStats) {
        formattedChars += (endingAt-startingAt);
    }
    int layoutFlags = 0; // no extra info yet, bidi determines run and line direction
    TextLabelFactory factory = new TextLabelFactory(fFrc, fChars, fBidi, layoutFlags);

    int[] charsLtoV = null;
    
    if (fBidi != null) {
        fLevels = BidiUtils.getLevels(fBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(fLevels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
        fIsDirectionLTR = fBidi.baseIsLeftToRight();
    }
    else {
        fLevels = null;
        fIsDirectionLTR = true;
    }
    
    try {
        fComponents = TextLine.getComponents(
            fParagraph, fChars, startingAt, endingAt, charsLtoV, fLevels, factory);
    }
    catch(IllegalArgumentException e) {
        System.out.println("startingAt="+startingAt+"; endingAt="+endingAt);
        System.out.println("fComponentLimit="+fComponentLimit);
        throw e;
    }
    
    fComponentStart = startingAt;
    fComponentLimit = endingAt;
    //debugFormatCount += (endingAt-startingAt);
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:40,代码来源:TextMeasurer.java

示例6: calculateBidiLevels

import sun.font.BidiUtils; //导入方法依赖的package包/类
/**
 * Calculate the levels array for a range of paragraphs.
 */
private byte[] calculateBidiLevels( int firstPStart, int lastPEnd ) {

    byte levels[] = new byte[ lastPEnd - firstPStart ];
    int  levelsEnd = 0;
    Boolean defaultDirection = null;
    Object d = getProperty(TextAttribute.RUN_DIRECTION);
    if (d instanceof Boolean) {
        defaultDirection = (Boolean) d;
    }

    // For each paragraph in the given range of paragraphs, get its
    // levels array and add it to the levels array for the entire span.
    for(int o=firstPStart; o<lastPEnd; ) {
        Element p = getParagraphElement( o );
        int pStart = p.getStartOffset();
        int pEnd = p.getEndOffset();

        // default run direction for the paragraph.  This will be
        // null if there is no direction override specified (i.e.
        // the direction will be determined from the content).
        Boolean direction = defaultDirection;
        d = p.getAttributes().getAttribute(TextAttribute.RUN_DIRECTION);
        if (d instanceof Boolean) {
            direction = (Boolean) d;
        }

        //System.out.println("updateBidi: paragraph start = " + pStart + " paragraph end = " + pEnd);

        // Create a Bidi over this paragraph then get the level
        // array.
        Segment seg = SegmentCache.getSharedSegment();
        try {
            getText(pStart, pEnd-pStart, seg);
        } catch (BadLocationException e ) {
            throw new Error("Internal error: " + e.toString());
        }
        // REMIND(bcb) we should really be using a Segment here.
        Bidi bidiAnalyzer;
        int bidiflag = Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT;
        if (direction != null) {
            if (TextAttribute.RUN_DIRECTION_LTR.equals(direction)) {
                bidiflag = Bidi.DIRECTION_LEFT_TO_RIGHT;
            } else {
                bidiflag = Bidi.DIRECTION_RIGHT_TO_LEFT;
            }
        }
        bidiAnalyzer = new Bidi(seg.array, seg.offset, null, 0, seg.count,
                bidiflag);
        BidiUtils.getLevels(bidiAnalyzer, levels, levelsEnd);
        levelsEnd += bidiAnalyzer.getLength();

        o =  p.getEndOffset();
        SegmentCache.releaseSharedSegment(seg);
    }

    // REMIND(bcb) remove this code when debugging is done.
    if( levelsEnd != levels.length )
        throw new Error("levelsEnd assertion failed.");

    return levels;
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:65,代码来源:AbstractDocument.java


注:本文中的sun.font.BidiUtils.getLevels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。