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


Java CSS类代码示例

本文整理汇总了Java中javax.swing.text.html.CSS的典型用法代码示例。如果您正苦于以下问题:Java CSS类的具体用法?Java CSS怎么用?Java CSS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: convertToHTML40

import javax.swing.text.html.CSS; //导入依赖的package包/类
/**
 * Copies the given AttributeSet to a new set, converting
 * any CSS attributes found to arguments of an HTML style
 * attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            value = value + " " + key + "=" + from.getAttribute(key) + ";";
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:22,代码来源:AltHTMLWriter.java

示例2: createFontAttribute

import javax.swing.text.html.CSS; //导入依赖的package包/类
/**
 * Create/update an HTML <font> tag attribute.  The
 * value of the attribute should be a MutableAttributeSet so
 * that the attributes can be updated as they are discovered.
 */
private static void createFontAttribute(CSS.Attribute a, AttributeSet from, MutableAttributeSet to) {
    MutableAttributeSet fontAttr = (MutableAttributeSet) to.getAttribute(HTML.Tag.FONT);
    if (fontAttr == null) {
        fontAttr = new SimpleAttributeSet();
        to.addAttribute(HTML.Tag.FONT, fontAttr);
    }
    // edit the parameters to the font tag
    String htmlValue = from.getAttribute(a).toString();
    if (a == CSS.Attribute.FONT_FAMILY) {
        fontAttr.addAttribute(HTML.Attribute.FACE, htmlValue);
    }
    else if (a == CSS.Attribute.FONT_SIZE) {
        fontAttr.addAttribute(HTML.Attribute.SIZE, htmlValue);
    }
    else if (a == CSS.Attribute.COLOR) {
        fontAttr.addAttribute(HTML.Attribute.COLOR, htmlValue);
    }
}
 
开发者ID:cst316,项目名称:spring16project-Modula-2,代码行数:24,代码来源:AltHTMLWriter.java

示例3: createFontAttribute

import javax.swing.text.html.CSS; //导入依赖的package包/类
/**
 * Create/update an HTML <font> tag attribute. The value of the
 * attribute should be a MutableAttributeSet so that the attributes can be
 * updated as they are discovered.
 */
private static void createFontAttribute(CSS.Attribute a, AttributeSet from, MutableAttributeSet to) {
	MutableAttributeSet fontAttr = (MutableAttributeSet) to.getAttribute(HTML.Tag.FONT);
	if (fontAttr == null) {
		fontAttr = new SimpleAttributeSet();
		to.addAttribute(HTML.Tag.FONT, fontAttr);
	}
	// edit the parameters to the font tag
	String htmlValue = from.getAttribute(a).toString();
	if (a == CSS.Attribute.FONT_FAMILY) {
		fontAttr.addAttribute(HTML.Attribute.FACE, htmlValue);
	} else if (a == CSS.Attribute.FONT_SIZE) {
		fontAttr.addAttribute(HTML.Attribute.SIZE, htmlValue);
	} else if (a == CSS.Attribute.COLOR) {
		fontAttr.addAttribute(HTML.Attribute.COLOR, htmlValue);
	}
}
 
开发者ID:cst316,项目名称:spring16project-Fortran,代码行数:22,代码来源:AltHTMLWriter.java

示例4: convertToHTML40

import javax.swing.text.html.CSS; //导入依赖的package包/类
/**
 * Copies the given AttributeSet to a new set, converting any CSS attributes
 * found to arguments of an HTML style attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
	Enumeration keys = from.getAttributeNames();
	String value = "";
	while (keys.hasMoreElements()) {
		Object key = keys.nextElement();
		if (key instanceof CSS.Attribute) {
			value = value + " " + key + "=" + from.getAttribute(key) + ";";
		} else {
			to.addAttribute(key, from.getAttribute(key));
		}
	}
	if (value.length() > 0) {
		to.addAttribute(HTML.Attribute.STYLE, value);
	}
}
 
开发者ID:cst316,项目名称:spring16project-Fortran,代码行数:20,代码来源:AltHTMLWriter.java

示例5: getFontScaleFactor

import javax.swing.text.html.CSS; //导入依赖的package包/类
private float getFontScaleFactor(AttributeSet a) {
	final Object attribute = a.getAttribute(CSS.Attribute.FONT_SIZE);
	if(attribute == null)
		return ScaledEditorKit.getFontScaleFactor();
	final String fontSize = attribute.toString();
	final int fsLength = fontSize.length();
	if(fsLength <= 1
			|| Character.isDigit(fontSize.charAt(fsLength-1))
			|| fontSize.endsWith("pt"))
		return ScaledEditorKit.getFontScaleFactor();
	if(fontSize.endsWith("px"))
		return 1/1.3f;
	if(fontSize.endsWith("%") || fontSize.endsWith("em") || fontSize.endsWith("ex")
			|| fontSize.endsWith("er"))
		return getFontScaleFactor(a);
	return ScaledEditorKit.getFontScaleFactor();
}
 
开发者ID:Actelion,项目名称:openchemlib,代码行数:18,代码来源:ScaledStyleSheet.java

示例6: createFontAttribute

import javax.swing.text.html.CSS; //导入依赖的package包/类
/**
 * Create/update an HTML &lt;font&gt; tag attribute.  The
 * value of the attribute should be a MutableAttributeSet so
 * that the attributes can be updated as they are discovered.
 */
private static void createFontAttribute(CSS.Attribute a, AttributeSet from,
                                MutableAttributeSet to) {
    MutableAttributeSet fontAttr = (MutableAttributeSet)
        to.getAttribute(HTML.Tag.FONT);
    if (fontAttr == null) {
        fontAttr = new SimpleAttributeSet();
        to.addAttribute(HTML.Tag.FONT, fontAttr);
    }
    // edit the parameters to the font tag
    String htmlValue = from.getAttribute(a).toString();
    if (a == CSS.Attribute.FONT_FAMILY) {
        fontAttr.addAttribute(HTML.Attribute.FACE, htmlValue);
    } else if (a == CSS.Attribute.FONT_SIZE) {
        fontAttr.addAttribute(HTML.Attribute.SIZE, htmlValue);
    } else if (a == CSS.Attribute.COLOR) {
        fontAttr.addAttribute(HTML.Attribute.COLOR, htmlValue);
    }
}
 
开发者ID:Sharcoux,项目名称:MathEOS,代码行数:24,代码来源:HTMLPerfectWriter.java

示例7: convertToHTML

import javax.swing.text.html.CSS; //导入依赖的package包/类
/**
 * Create an older style of HTML attributes. This will convert character
 * level attributes that have a StyleConstants mapping over to an HTML
 * tag/attribute. Other CSS attributes will be placed in an HTML style
 * attribute.
 */
private static void convertToHTML(AttributeSet from, MutableAttributeSet to) {
	if (from == null) {
		return;
	}
	Enumeration keys = from.getAttributeNames();
	String value = "";
	while (keys.hasMoreElements()) {
		Object key = keys.nextElement();
		if (key instanceof CSS.Attribute) {
			// default is to store in a HTML style attribute
			if (value.length() > 0) {
				value = value + "; ";
			}
			value = value + key + ": " + from.getAttribute(key);
		} else {
			to.addAttribute(key, from.getAttribute(key));
		}
	}
	if (value.length() > 0) {
		to.addAttribute(HTML.Attribute.STYLE, value);
	}
}
 
开发者ID:iwabuchiken,项目名称:freemind_1.0.0_20140624_214725,代码行数:29,代码来源:FixedHTMLWriter.java

示例8: getFontFamily

import javax.swing.text.html.CSS; //导入依赖的package包/类
/**
 * Gets the font family name at the {@link JEditorPane}'s current caret position
 * 
 * @param editor
 * @return The font family name, or null if no font is set
 */
public static String getFontFamily(JEditorPane editor)
{        
    AttributeSet attr = getCharacterAttributes(editor);
    if(attr != null)
    {        
        Object val = attr.getAttribute(StyleConstants.FontFamily);
        if(val != null)
            return val.toString();
        val = attr.getAttribute(CSS.Attribute.FONT_FAMILY);
        if(val != null)
            return val.toString();
        val = attr.getAttribute(HTML.Tag.FONT);
        if(val != null && val instanceof AttributeSet)
        {
            AttributeSet set = (AttributeSet)val;
            val = set.getAttribute(HTML.Attribute.FACE);
            if(val != null)
                return val.toString();
        }
    }
    
    return null; //no font family was defined        
}
 
开发者ID:OpenIndex,项目名称:OpenIndex-SHEF,代码行数:30,代码来源:HTMLUtils.java

示例9: corrigePImplied

import javax.swing.text.html.CSS; //导入依赖的package包/类
public static void corrigePImplied(ExtendedHTMLDocument doc) {
	List<Element> tds = findElementByTag(doc, Tag.TD);
	for(Element td: tds) {
		if(td.getElementCount() > 0) {
			Element p = td.getElement(0);
			AttributeSet attrs = p.getAttributes();
			if(attrs.containsAttribute(StyleConstants.NameAttribute, Tag.IMPLIED) &&
					attrs.isDefined(CSS.Attribute.TEXT_ALIGN)) {
				SimpleAttributeSet s = new SimpleAttributeSet();
				s.addAttribute(StyleConstants.NameAttribute, Tag.P);
				doc.setParagraphAttributes(p.getStartOffset(), p.getEndOffset(), 
						s, false);
			}
		}
	}
}
 
开发者ID:lexml,项目名称:lexml-swing-editorhtml,代码行数:17,代码来源:DocumentUtil.java

示例10: writeStyle

import javax.swing.text.html.CSS; //导入依赖的package包/类
/**
 * Outputs the named style. <code>outputStyle</code> indicates
 * whether or not a style has been output yet. This will return
 * true if a style is written.
 */
boolean writeStyle(String name, Style style, boolean outputStyle) throws IOException {
    boolean didOutputStyle = false;
    Enumeration attributes = style.getAttributeNames();
    if (attributes != null) {
        while (attributes.hasMoreElements()) {
            Object attribute = attributes.nextElement();
            if (attribute instanceof CSS.Attribute) {
                String value = style.getAttribute(attribute).toString();
                if (value != null) {
                    if (!outputStyle) {
                        writeStyleStartTag();
                        outputStyle = true;
                    }
                    if (!didOutputStyle) {
                        didOutputStyle = true;
                        indent();
                        write(name);
                        write(" {");
                    }
                    else {
                        write(";");
                    }
                    write(' ');
                    write(attribute.toString());
                    write(": ");
                    write(value);
                }
            }
        }
    }
    if (didOutputStyle) {
        write(" }");
        writeLineSeparator();
    }
    return didOutputStyle;
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:42,代码来源:AltHTMLWriter.java

示例11: writeStyle

import javax.swing.text.html.CSS; //导入依赖的package包/类
/**
 * Outputs the named style. <code>outputStyle</code> indicates whether or
 * not a style has been output yet. This will return true if a style is
 * written.
 */
boolean writeStyle(String name, Style style, boolean outputStyle) throws IOException {
	boolean didOutputStyle = false;
	Enumeration attributes = style.getAttributeNames();
	if (attributes != null) {
		while (attributes.hasMoreElements()) {
			Object attribute = attributes.nextElement();
			if (attribute instanceof CSS.Attribute) {
				String value = style.getAttribute(attribute).toString();
				if (value != null) {
					if (!outputStyle) {
						writeStyleStartTag();
						outputStyle = true;
					}
					if (!didOutputStyle) {
						didOutputStyle = true;
						indent();
						write(name);
						write(" {");
					} else {
						write(";");
					}
					write(' ');
					write(attribute.toString());
					write(": ");
					write(value);
				}
			}
		}
	}
	if (didOutputStyle) {
		write(" }");
		writeLineSeparator();
	}
	return didOutputStyle;
}
 
开发者ID:cst316,项目名称:spring16project-Fortran,代码行数:41,代码来源:AltHTMLWriter.java

示例12: decouperTexteEnLignes_String

import javax.swing.text.html.CSS; //导入依赖的package包/类
private void decouperTexteEnLignes_String(Element element) {
	if (!element.isLeaf()) {
		Object display = trouverProprieteCSSHeritage(CSS.Attribute.DISPLAY,
				element);
		if (display != null)
			display = display.toString().toLowerCase();
		else {
			HTML.Tag tag = HTML.getTag(element.getName());
			if (tag == null)
				display = "";
			else if (tag.isBlock())
				display = "block";
			else
				display = "inline";
		}
		if (display.equals("block")) {
			decoupe += "<<" + element.getName() + ">>";
		}

		int elementCount = element.getElementCount();
		for (int i = 0; i < elementCount; i++) {
			Element elem = element.getElement(i);
			decouperTexteEnLignes_String(elem);
		}

		if (display.equals("block")) {
			decoupe += "<<" + element.getName() + ">>";
		}
	} else {
		int beg = element.getStartOffset();
		int end = element.getEndOffset();
		String text = null;
		try {
			text = getText(beg, end - beg);
			text = text.replaceAll("\\s+", " ");
			decoupe += text;
		} catch (BadLocationException e) {
		}
	}
}
 
开发者ID:LowResourceLanguages,项目名称:InuktitutComputing,代码行数:41,代码来源:NRC_HTMLDocument.java

示例13: trouverFontFamily

import javax.swing.text.html.CSS; //导入依赖的package包/类
public String[] trouverFontFamily(Element element) {
	AttributeSet as;
	String family = null;
	as = element.getAttributes();

	// Vérifier si l'élément de texte contient directement un
	// attribut "font-family". NOTE: Normalement, il ne devrait pas
	// le contenir car notre lecteur HTML a été modifié par rapport
	// au HTMLDocument.HTMLReader original qui, lui, convertit certains
	// éléments HTML affectant le texte en attributs qu'il ajoute à
	// l'élément de texte (par exemple, <FONT face=verdana> devient
	// un attribut font-family=verdana ajouté au texte qui suit.)
	// if (as.isDefined(CSS.Attribute.FONT_FAMILY))

	// Essayer l'attribut css font-family
	Object familyObject = as.getAttribute(CSS.Attribute.FONT_FAMILY);
	if (familyObject == null)
		family = null;
	else
		family = familyObject.toString();

	// Sinon, essay l'attribut css font
	// if (family == null) {
	// String font = (String)as.getAttribute(CSS.Attribute.FONT);
	// family = parseFontForFamily(font);
	// }
	if (family == null) {
		Element parent = element.getParentElement();
		// fontFamily =
		// transInuk.trouverFontFamilyHerit(parent,doc);
		if (parent != null) {
			String[] families = trouverFontFamilyHerit(parent);
			return families;
		} else
			return null;
	} else {
		return (String[]) new String[] { family };
	}
}
 
开发者ID:LowResourceLanguages,项目名称:InuktitutComputing,代码行数:40,代码来源:NRC_HTMLDocument.java

示例14: caretUpdate

import javax.swing.text.html.CSS; //导入依赖的package包/类
@Override
public void caretUpdate(CaretEvent e) {
    int referentCharacter = e.getDot();
    try {
        if(referentCharacter>0 && !editeur.getText(referentCharacter-1, 1).equals("\n")) {referentCharacter--;}
    } catch (BadLocationException ex) {
        Logger.getLogger(JMathTextPane.class.getName()).log(Level.SEVERE, null, ex);
    }
    AttributeSet ast = editeur.getHTMLdoc().getCharacterElement(referentCharacter).getAttributes();
    Object textDecorationValue = ast.getAttribute(CSS.Attribute.TEXT_DECORATION);
    editeur.getEditeurKit().getBoutonStrike().setSelected(textDecorationValue!=null && textDecorationValue.toString().equals("line-through"));
}
 
开发者ID:Sharcoux,项目名称:MathEOS,代码行数:13,代码来源:OngletTexte.java


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