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


Java StyleSheet.getStyleNames方法代碼示例

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


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

示例1: writeStyles

import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
/**
 * Outputs the styles as a single element. Styles are not stored as
 * elements, but part of the document. For the time being styles are
 * written out as a comment, inside a style tag.
 */
void writeStyles(StyleSheet sheet) throws IOException {
    if (sheet != null) {
        Enumeration styles = sheet.getStyleNames();
        if (styles != null) {
            boolean outputStyle = false;
            while (styles.hasMoreElements()) {
                String name = (String) styles.nextElement();
                // Don't write out the default style.
                if (!StyleContext.DEFAULT_STYLE.equals(name)
                    && writeStyle(name, sheet.getStyle(name), outputStyle)) {
                    outputStyle = true;
                }
            }
            if (outputStyle) {
                writeStyleEndTag();
            }
        }
    }
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:25,代碼來源:AltHTMLWriter.java

示例2: writeStyles

import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
/**
 * Outputs the styles as a single element. Styles are not stored as
 * elements, but part of the document. For the time being styles are written
 * out as a comment, inside a style tag.
 */
void writeStyles(StyleSheet sheet) throws IOException {
	if (sheet != null) {
		Enumeration styles = sheet.getStyleNames();
		if (styles != null) {
			boolean outputStyle = false;
			while (styles.hasMoreElements()) {
				String name = (String) styles.nextElement();
				// Don't write out the default style.
				if (!StyleContext.DEFAULT_STYLE.equals(name)
						&& writeStyle(name, sheet.getStyle(name), outputStyle)) {
					outputStyle = true;
				}
			}
			if (outputStyle) {
				writeStyleEndTag();
			}
		}
	}
}
 
開發者ID:cst316,項目名稱:spring16project-Fortran,代碼行數:25,代碼來源:AltHTMLWriter.java

示例3: getAllFontFamiliesInStyleSheets

import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
public String[] getAllFontFamiliesInStyleSheets() {
	Vector families = new Vector();
	StyleSheet styles = getStyleSheet();
	Enumeration styleNames = styles.getStyleNames();
	while (styleNames.hasMoreElements()) {
		String name = (String) styleNames.nextElement();
		Style style = styles.getStyle(name);
		Enumeration attrNames = style.getAttributeNames();
		while (attrNames.hasMoreElements()) {
			Object n = attrNames.nextElement();
			if (n.toString().equals("resolver")) {
				Style nst = (Style) style.getAttribute(n);
				Enumeration nAttrNames = nst.getAttributeNames();
				while (nAttrNames.hasMoreElements()) {
					Object nAttrName = nAttrNames.nextElement();
					if (nAttrName.toString().toLowerCase().equals(
							"font-family")) {
						Object value = nst.getAttribute(nAttrName);
						String values[] = value.toString().toLowerCase()
								.split(",");
						for (int i = 0; i < values.length; i++) {
							String val = values[i].trim();
							if (!families.contains(val))
								families.add(val);
						}
					}
				}
			}
		}
	}
	String[] familiesArray = (String[]) families.toArray(new String[] {});
	Arrays.sort(familiesArray);
	return familiesArray;
}
 
開發者ID:LowResourceLanguages,項目名稱:InuktitutComputing,代碼行數:35,代碼來源:NRC_HTMLDocument.java

示例4: trouverProprieteCSS

import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
public Object trouverProprieteCSS(Attribute attr, Element element) {
	AttributeSet as;
	Object attrValue = null;
	Object style;
	StyleSheet styles;
	Style rule;
	NRC_HTMLTag tag = null;

	if (element == null)
		return null;

	String elementName = element.getName();

	if (elementName.equals("p-implied")) {
		Element parent = element.getParentElement();
		return trouverProprieteCSS(attr,parent);
	}
	as = element.getAttributes();

	// Vérifier si un attribut STYLE est spécifié avec la propriété 'attr'
	if (as.isDefined(HTML.Attribute.STYLE)) {
		style = as.getAttribute(HTML.Attribute.STYLE);
		StyleSheet ss = new StyleSheet();
		AttributeSet ssrule = ss.getDeclaration(style.toString());
		if (ssrule.isDefined(attr))
			attrValue = ssrule.getAttribute(attr).toString();
	}

	if (attrValue != null) {
		return attrValue;
	}

	// Si ce n'est pas le cas, vérifier si un style a été défini pour
	// cet élément dans une feuille de style (soit par l'élément STYLE
	// au début du fichier, soit par une feuille de style externe).

	styles = getStyleSheet();
	tag = new NRC_HTMLTag(elementName);
	rule = styles.getRule(tag, element);

	if (rule != null) {
		attrValue = rule.getAttribute(attr);
	}
	if (attrValue != null) {
		return attrValue;
	}

	// Si ce n'est pas le cas, vérifier si un style a été défini pour cet
	// élément avec un sélecteur contenant un ':'
	Vector attrValuesVector = new Vector();
	Pattern p = Pattern.compile("^[^:]+:");
	Enumeration rules = styles.getStyleNames();
	while (rules.hasMoreElements()) {
		String name = (String) rules.nextElement();
		Matcher mp = p.matcher(name);
		rule = styles.getStyle(name);
		if (mp.lookingAt()) {
			attrValue = rule.getAttribute(attr);
			if (attrValue != null
					&& !attrValuesVector.contains(attrValue.toString()))
				attrValuesVector.add(attrValue.toString());
		}
	}
	attrValue = null;
	if (attrValuesVector.size() != 0) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < attrValuesVector.size(); i++)
			sb.append(attrValuesVector.elementAt(i).toString()).append(" ");
		attrValue = sb.toString().trim();
	}
	return attrValue;
}
 
開發者ID:LowResourceLanguages,項目名稱:InuktitutComputing,代碼行數:73,代碼來源:NRC_HTMLDocument.java


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