當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。