當前位置: 首頁>>代碼示例>>Java>>正文


Java FontMetrics.getLeading方法代碼示例

本文整理匯總了Java中org.eclipse.swt.graphics.FontMetrics.getLeading方法的典型用法代碼示例。如果您正苦於以下問題:Java FontMetrics.getLeading方法的具體用法?Java FontMetrics.getLeading怎麽用?Java FontMetrics.getLeading使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.graphics.FontMetrics的用法示例。


在下文中一共展示了FontMetrics.getLeading方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: calculateTextBounds

import org.eclipse.swt.graphics.FontMetrics; //導入方法依賴的package包/類
/**
 * Calculates the bounds of the text in the box as measured by the given
 * graphics context and font metrics.
 * 
 * @param gc graphics context from which the measurements are done
 * @return point representing the dimensions of the text's bounds
 */
private Point calculateTextBounds(final GC gc) {
    final SWTGraphics2D g2 = new SWTGraphics2D(gc, Display.getDefault());
    g2.setFont(font);
    final FontMetrics fm = g2.getSWTFontMetrics();
    final Point textBounds = new Point(0, 0);

    boolean firstLine = true;

    final Iterator lineIterator = lines.iterator();
    while (lineIterator.hasNext()) {
        String line = (String) lineIterator.next();
        Point lineBounds = gc.stringExtent(line);
        if (firstLine) {
            textBounds.x = lineBounds.x;
            textBounds.y += fm.getAscent() + fm.getDescent() + fm.getLeading();
            firstLine = false;
        }
        else {
            textBounds.x = Math.max(lineBounds.x, textBounds.x);
            textBounds.y += fm.getHeight();
        }
    }

    return textBounds;
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:33,代碼來源:PSWTText.java

示例2: getBaselineBias

import org.eclipse.swt.graphics.FontMetrics; //導入方法依賴的package包/類
/**
 * Returns the difference between the baseline of the widget and the
 * baseline as specified by the font for <code>gc</code>. When drawing
 * line numbers, the returned bias should be added to obtain text lined up
 * on the correct base line of the text widget.
 *
 * @param gc the <code>GC</code> to get the font metrics from
 * @param widgetLine the widget line
 * @return the baseline bias to use when drawing text that is lined up with
 *         <code>fCachedTextWidget</code>
 * @since 3.2
 */
private int getBaselineBias(GC gc, int widgetLine) {
	/*
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=62951
	 * widget line height may be more than the font height used for the
	 * line numbers, since font styles (bold, italics...) can have larger
	 * font metrics than the simple font used for the numbers.
	 */
	int offset= fCachedTextWidget.getOffsetAtLine(widgetLine);
	int widgetBaseline= fCachedTextWidget.getBaseline(offset);

	FontMetrics fm= gc.getFontMetrics();
	int fontBaseline= fm.getAscent() + fm.getLeading();
	int baselineBias= widgetBaseline - fontBaseline;
	return Math.max(0, baselineBias);
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:28,代碼來源:CommonLineNumberRulerColumn.java

示例3: draw

import org.eclipse.swt.graphics.FontMetrics; //導入方法依賴的package包/類
/**
 * Draw string at widget offset.
 * 
 * @param gc
 * @param offset
 *            the widget offset
 * @param s
 *            the string to be drawn
 * @param fg
 *            the foreground color
 */
private void draw(GC gc, int offset, String s, Color fg)
{
	// Compute baseline delta (see
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165640)
	int baseline = fTextWidget.getBaseline(offset);
	FontMetrics fontMetrics = gc.getFontMetrics();
	int fontBaseline = fontMetrics.getAscent() + fontMetrics.getLeading();
	int baslineDelta = baseline - fontBaseline;

	Point pos = fTextWidget.getLocationAtOffset(offset);
	gc.setForeground(fg);
	gc.drawString(s, pos.x, pos.y + baslineDelta, true);
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:25,代碼來源:WhitespaceCharacterPainter.java

示例4: getFMAscent

import org.eclipse.swt.graphics.FontMetrics; //導入方法依賴的package包/類
public float getFMAscent(){
	this.setAdvanced(false);
	
	FontMetrics fm = this.gc.getFontMetrics();
	return (fm.getAscent() + fm.getLeading());
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:7,代碼來源:TGPainterImpl.java

示例5: getBaselineBias

import org.eclipse.swt.graphics.FontMetrics; //導入方法依賴的package包/類
/**
 * Returns the difference between the baseline of the widget and the baseline as specified by
 * the font for <code>gc</code>. When drawing line numbers, the returned bias should be added to
 * obtain text lined up on the correct base line of the text widget.
 * 
 * @param gc
 *            the {@code GC} to get the font metrics from
 * @param widgetLine
 *            the widget line
 * @return the baseline bias to use when drawing text that is lined up with the text widget.
 */
private int getBaselineBias(GC gc, int widgetLine) {
    ITextViewer textViewer = getParentRuler().getTextViewer();
    int offset = textViewer.getTextWidget().getOffsetAtLine(widgetLine);
    int widgetBaseline = textViewer.getTextWidget().getBaseline(offset);

    FontMetrics fm = gc.getFontMetrics();
    int fontBaseline = fm.getAscent() + fm.getLeading();
    int baselineBias = widgetBaseline - fontBaseline;
    return Math.max(0, baselineBias);
}
 
開發者ID:kopl,項目名稱:SPLevo,代碼行數:22,代碼來源:UnifiedDiffRulerColumn.java


注:本文中的org.eclipse.swt.graphics.FontMetrics.getLeading方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。