GlyphGutter.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:incubator-netbeans 作者:
protected int getLineNumberWidth() {
    int newWidth = 0;
    EditorUI eui = editorUI;
    if (eui != null) {
        /*
        Insets insets = eui.getLineNumberMargin();
        if (insets != null) {
            newWidth += insets.left + insets.right;
        }
         */
        JTextComponent tc = eui.getComponent();
        if (font != null && tc != null) {
            Graphics g;
            FontRenderContext frc;
            FontMetrics fm;
            if ((g = tc.getGraphics()) != null && (g instanceof Graphics2D) &&
                (frc = ((Graphics2D)g).getFontRenderContext()) != null)
            {
                newWidth += new TextLayout(String.valueOf(highestLineNumber), font, frc).getAdvance();
            } else if ((fm = getFontMetrics(font)) != null) {
                // Use FontMetrics.stringWidth() as best approximation
                newWidth += fm.stringWidth(String.valueOf(highestLineNumber));
            }
        }
    }

    return newWidth;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号