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


Java TextHitInfo.trailing方法代码示例

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


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

示例1: x2RelOffset

import java.awt.font.TextHitInfo; //导入方法依赖的package包/类
static TextHitInfo x2RelOffset(TextLayout textLayout, float x) {
    TextHitInfo hit;
    x -= EXTRA_MARGIN_WIDTH;
    if (x >= textLayout.getAdvance()) {
        hit = TextHitInfo.trailing(textLayout.getCharacterCount());
    } else {
        hit = textLayout.hitTestChar(x, 0); // What about backward bias -> with higher offsets it may go back visually
    }
    return hit;

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:FoldView.java

示例2: init

import java.awt.font.TextHitInfo; //导入方法依赖的package包/类
public void init(TestEnvironment env, Result results) {
    super.init(env, results);

    ArrayList list = new ArrayList(text.length() * 2 + 2);
    TextHitInfo hit = TextHitInfo.trailing(-1);
    do {
        list.add(hit);
        hit = tl.getNextRightHit(hit);
    } while (hit != null);
    hits = (TextHitInfo[])list.toArray(new TextHitInfo[list.size()]);

    lb = tl.getBounds();
    lb.setRect(lb.getMinX() - 10, lb.getMinY(), lb.getWidth() + 20, lb.getHeight());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:TextMeasureTests.java

示例3: main

import java.awt.font.TextHitInfo; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    ThreadGroup stubTG = new ThreadGroup(getRootThreadGroup(), "Stub Thread Group");
    ThreadGroup swingTG = new ThreadGroup(getRootThreadGroup(), "SwingTG");
    try {
        Thread stubThread = new Thread(stubTG, SunToolkit::createNewAppContext);
        stubThread.start();
        stubThread.join();

        CountDownLatch startSwingLatch = new CountDownLatch(1);
        new Thread(swingTG, () -> {
            SunToolkit.createNewAppContext();
            SwingUtilities.invokeLater(() -> {
                frame = new JFrame();
                component = new JLabel("Test Text");
                frame.add(component);
                frame.setBounds(100, 100, 100, 100);
                frame.setVisible(true);
                startSwingLatch.countDown();
            });
        }).start();
        startSwingLatch.await();

        AtomicReference<Exception> caughtException = new AtomicReference<>();
        Thread checkThread = new Thread(getRootThreadGroup(), () -> {
            try {
                // If the bug is present this will throw exception
                new InputMethodEvent(component,
                        InputMethodEvent.CARET_POSITION_CHANGED,
                        TextHitInfo.leading(0),
                        TextHitInfo.trailing(0));
            } catch (Exception e) {
                caughtException.set(e);
            }
        });
        checkThread.start();
        checkThread.join();

        if (caughtException.get() != null) {
            throw new RuntimeException("Failed. Caught exception!", caughtException.get());
        }
    } finally {
        new Thread(swingTG, () -> SwingUtilities.invokeLater(() -> {
            if (frame != null) {
                frame.dispose();
            }
        })).start();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:49,代码来源:bug8041990.java


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