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


Java Component.getFontMetrics方法代码示例

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


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

示例1: getBorderInsets

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Reinitialize the insets parameter with this Border's current Insets.
 * @param c the component for which this border insets value applies
 * @param insets the object to be reinitialized
 */
public Insets getBorderInsets(Component c, Insets insets) {
    if (!(c instanceof JPopupMenu)) {
        return insets;
    }
    FontMetrics fm;
    int         descent = 0;
    int         ascent = 16;

    String title = ((JPopupMenu)c).getLabel();
    if (title == null) {
        insets.left = insets.top = insets.right = insets.bottom = 0;
        return insets;
    }

    fm = c.getFontMetrics(font);

    if(fm != null) {
        descent = fm.getDescent();
        ascent = fm.getAscent();
    }

    insets.top += ascent + descent + TEXT_SPACING + GROOVE_HEIGHT;
    return insets;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:MotifBorders.java

示例2: getFontMetrics

import java.awt.Component; //导入方法依赖的package包/类
/** Get the font-metrics for the given font.
* @param font font for which the metrics is being retrieved.
* @param c component that is used to retrieve the metrics in case it's
*   not yet in the cache.
*/
public static synchronized FontMetrics getFontMetrics(Font f, Component c) {
    Object fm = font2FM.get(f);
    if (fm == null) {
        fm = c.getFontMetrics(f);
        font2FM.put(f, fm);
    }
    return (FontMetrics)fm;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:FontMetricsCache.java

示例3: isFixedWidth

import java.awt.Component; //导入方法依赖的package包/类
/**
    * Return true if this font is fixed width.
    * Only the first 256 characters are considered.
    * @param font
    * @return true if this font is fixed width.
    */
   private static boolean isFixedWidth(Component context, Font font) {
FontMetrics metrics = context.getFontMetrics(font);
int[] widths = metrics.getWidths();
int Swidth = widths[0];
for (int cx = 1; cx < widths.length; cx++) {
    int width = widths[cx];
    if (width == 0) {
	continue;
    } else if (Swidth != width) {
	return false;
    }
}
return true;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FontPanel.java

示例4: updateMetrics

import java.awt.Component; //导入方法依赖的package包/类
final void updateMetrics() {
	Component host = getContainer();
	Font f = host.getFont();
	metrics = host.getFontMetrics(f); // Metrics for the default font.
	tabSize = getTabSize() * metrics.charWidth('m');
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:7,代码来源:WrappedSyntaxView.java


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