本文整理匯總了Java中org.eclipse.swt.graphics.FontMetrics.getDescent方法的典型用法代碼示例。如果您正苦於以下問題:Java FontMetrics.getDescent方法的具體用法?Java FontMetrics.getDescent怎麽用?Java FontMetrics.getDescent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.graphics.FontMetrics
的用法示例。
在下文中一共展示了FontMetrics.getDescent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例2: getAscent
import org.eclipse.swt.graphics.FontMetrics; //導入方法依賴的package包/類
/**
* Gets the font's ascent.
*
* @param font
* @return the font's ascent
*/
public int getAscent(Font font) {
FontMetrics fm = FigureUtilities.getFontMetrics(font);
return fm.getHeight() - fm.getDescent();
}