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


Java Font.hasLayoutAttributes方法代码示例

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


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

示例1: TextLayout

import java.awt.Font; //导入方法依赖的package包/类
/**
 * Constructs a <code>TextLayout</code> from a <code>String</code>
 * and a {@link Font}.  All the text is styled using the specified
 * <code>Font</code>.
 * <p>
 * The <code>String</code> must specify a single paragraph of text,
 * because an entire paragraph is required for the bidirectional
 * algorithm.
 * @param string the text to display
 * @param font a <code>Font</code> used to style the text
 * @param frc contains information about a graphics device which is needed
 *       to measure the text correctly.
 *       Text measurements can vary slightly depending on the
 *       device resolution, and attributes such as antialiasing.  This
 *       parameter does not specify a translation between the
 *       <code>TextLayout</code> and user space.
 */
public TextLayout(String string, Font font, FontRenderContext frc) {

    if (font == null) {
        throw new IllegalArgumentException("Null font passed to TextLayout constructor.");
    }

    if (string == null) {
        throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
    }

    if (string.length() == 0) {
        throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
    }

    Map<? extends Attribute, ?> attributes = null;
    if (font.hasLayoutAttributes()) {
        attributes = font.getAttributes();
    }

    char[] text = string.toCharArray();
    if (sameBaselineUpTo(font, text, 0, text.length) == text.length) {
        fastInit(text, font, attributes, frc);
    } else {
        AttributedString as = attributes == null
            ? new AttributedString(string)
            : new AttributedString(string, attributes);
        as.addAttribute(TextAttribute.FONT, font);
        standardInit(as.getIterator(), text, frc);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:TextLayout.java

示例2: getTracking

import java.awt.Font; //导入方法依赖的package包/类
private float getTracking(Font font) {
    if (font.hasLayoutAttributes()) {
        AttributeValues values = ((AttributeMap)font.getAttributes()).getValues();
        return values.getTracking();
    }
    return 0;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:StandardGlyphVector.java

示例3: getBaselineTransform

import java.awt.Font; //导入方法依赖的package包/类
public AffineTransform getBaselineTransform() {
    Font font = source.getFont();
    if (font.hasLayoutAttributes()) {
        return AttributeValues.getBaselineTransform(font.getAttributes());
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:TextSourceLabel.java

示例4: isSimpleString

import java.awt.Font; //导入方法依赖的package包/类
/**
    * If the text is a simple text and we can use FontDesignMetrics without a stackoverflow.
    * @see FontDesignMetrics#stringWidth(String)
    * @return true, if a simple text. false it is a complex text.
    */
public static boolean isSimpleString(Font font, String str) {
	if (font.hasLayoutAttributes()) {
		return false;
	}
	for (int i = 0; i < str.length(); ++i) {
		if (FontUtilities.isNonSimpleChar(str.charAt(i))) {
			return false;
		}
	}
	return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:StandardGlyphVector.java

示例5: TextLayout

import java.awt.Font; //导入方法依赖的package包/类
/**
 * Constructs a {@code TextLayout} from a {@code String}
 * and a {@link Font}.  All the text is styled using the specified
 * {@code Font}.
 * <p>
 * The {@code String} must specify a single paragraph of text,
 * because an entire paragraph is required for the bidirectional
 * algorithm.
 * @param string the text to display
 * @param font a {@code Font} used to style the text
 * @param frc contains information about a graphics device which is needed
 *       to measure the text correctly.
 *       Text measurements can vary slightly depending on the
 *       device resolution, and attributes such as antialiasing.  This
 *       parameter does not specify a translation between the
 *       {@code TextLayout} and user space.
 */
public TextLayout(String string, Font font, FontRenderContext frc) {

    if (font == null) {
        throw new IllegalArgumentException("Null font passed to TextLayout constructor.");
    }

    if (string == null) {
        throw new IllegalArgumentException("Null string passed to TextLayout constructor.");
    }

    if (string.length() == 0) {
        throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
    }

    Map<? extends Attribute, ?> attributes = null;
    if (font.hasLayoutAttributes()) {
        attributes = font.getAttributes();
    }

    char[] text = string.toCharArray();
    if (sameBaselineUpTo(font, text, 0, text.length) == text.length) {
        fastInit(text, font, attributes, frc);
    } else {
        AttributedString as = attributes == null
            ? new AttributedString(string)
            : new AttributedString(string, attributes);
        as.addAttribute(TextAttribute.FONT, font);
        standardInit(as.getIterator(), text, frc);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:48,代码来源:TextLayout.java


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