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


Java TextLayout.getVisualHighlightShape方法代码示例

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


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

示例1: getRealAlloc

import java.awt.font.TextLayout; //导入方法依赖的package包/类
/**
     * Get real allocation (possibly not rectangular) of a part of layout.
     * <br>
     * It's used when rendering the text layout for filling background highlights of the view.
     *
     * @param length Total number of characters for which the allocation is computed.
     * @param alloc Allocation given by a parent view.
     * @return
     */
    public static Shape getRealAlloc(TextLayout textLayout, Rectangle2D textLayoutRect,
            TextHitInfo startHit, TextHitInfo endHit)
    {
        // Quick-fix to eliminate missing line in rendering italic "d" - more elaborate fix is needed
        textLayoutRect = new Rectangle2D.Double(textLayoutRect.getX(), textLayoutRect.getY(),
                textLayoutRect.getWidth() + 2, textLayoutRect.getHeight());
        Rectangle2D.Double zeroBasedRect = ViewUtils.shape2Bounds(textLayoutRect);
        zeroBasedRect.x = 0;
        zeroBasedRect.y = 0;
        Shape ret = textLayout.getVisualHighlightShape(startHit, endHit, zeroBasedRect);
        AffineTransform transform = AffineTransform.getTranslateInstance(
                textLayoutRect.getX(),
                textLayoutRect.getY()
        );
        ret = transform.createTransformedShape(ret);
        // The following gives bad result for some reason (works for layout but not for caret modelToView())
//        Shape ret2 = textLayout.getVisualHighlightShape(startHit.getCharIndex(), endHit.getCharIndex(), textLayoutRect);
        return ret;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:TextLayoutUtils.java

示例2: runTest

import java.awt.font.TextLayout; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    Rectangle2D lb = tlctx.lb;
    Shape s;
    if (hits.length < 3) {
        do {
            s = tl.getVisualHighlightShape(hits[0], hits[hits.length - 1], lb);
        } while (--numReps >= 0);
    } else {
        do {
            for (int i = 3; i < hits.length; ++i) {
                s = tl.getVisualHighlightShape(hits[i-3], hits[i], lb);
            }
        } while (--numReps >= 0);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:TextMeasureTests.java


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