本文整理汇总了Java中javax.swing.text.AttributeSet.getAttributeNames方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet.getAttributeNames方法的具体用法?Java AttributeSet.getAttributeNames怎么用?Java AttributeSet.getAttributeNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.AttributeSet
的用法示例。
在下文中一共展示了AttributeSet.getAttributeNames方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeEmbeddedTags
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
/**
* Searches for embedded tags in the AttributeSet
* and writes them out. It also stores these tags in a vector
* so that when appropriate the corresponding end tags can be
* written out.
*
* @exception IOException on any I/O error
*/
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {
// translate css attributes to html
attr = convertToHTML(attr, oConvAttr);
Enumeration names = attr.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
if (name instanceof HTML.Tag) {
HTML.Tag tag = (HTML.Tag) name;
if (tag == HTML.Tag.FORM || tags.contains(tag)) {
continue;
}
write('<');
write(tag.toString());
Object o = attr.getAttribute(tag);
if (o != null && o instanceof AttributeSet) {
writeAttributes((AttributeSet) o);
}
write('>');
tags.addElement(tag);
tagValues.addElement(o);
}
}
}
示例2: convertToHTML40
import javax.swing.text.AttributeSet; //导入方法依赖的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);
}
}
示例3: dumpAttributes
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
private String dumpAttributes(StringBuilder sb, AttributeSet attribs) {
if (sb == null) {
sb = new StringBuilder();
}
if (attribs == null) {
sb.append(" ");
} else {
Enumeration en = attribs.getAttributeNames();
while (en.hasMoreElements()) {
Object attrName = en.nextElement();
Object attrValue = attribs.getAttribute(attrName);
sb.append("'");
sb.append(attrName.toString());
sb.append("' = '");
sb.append(attrValue == null ? "null" : attrValue.toString());
sb.append("'");
if (en.hasMoreElements()) {
sb.append(", ");
}
}
}
return sb.toString();
}
示例4: immutize
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
/**
* Creates unmodifiable copy of the original map converting <code>AttributeSet</code>s
* to their immutable versions.
*/
public static Map<String, AttributeSet> immutize(Map<String, ? extends AttributeSet> map, Object... filterOutKeys) {
Map<String, AttributeSet> immutizedMap = new HashMap<String, AttributeSet>();
for(String name : map.keySet()) {
AttributeSet attribs = map.get(name);
if (filterOutKeys.length == 0) {
immutizedMap.put(name, AttributesUtilities.createImmutable(attribs));
} else {
List<Object> pairs = new ArrayList<Object>();
// filter out attributes specified by filterOutKeys
first:
for(Enumeration<? extends Object> keys = attribs.getAttributeNames(); keys.hasMoreElements(); ) {
Object key = keys.nextElement();
for(Object filterOutKey : filterOutKeys) {
if (Utilities.compareObjects(key, filterOutKey)) {
continue first;
}
}
pairs.add(key);
pairs.add(attribs.getAttribute(key));
}
immutizedMap.put(name, AttributesUtilities.createImmutable(pairs.toArray()));
}
}
return Collections.unmodifiableMap(immutizedMap);
}
示例5: toAttrSetBuilder
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
static AttrSetBuilder toAttrSetBuilder(AttributeSet attrs) {
AttrSetBuilder builder = new AttrSetBuilder(attrs.getAttributeCount() << 1);
Enumeration<?> en = attrs.getAttributeNames();
while (en.hasMoreElements()) {
Object key = en.nextElement();
Object value = attrs.getAttribute(key);
builder.add(key, value);
}
return builder;
}
示例6: getAllKeys
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
private Collection<?> getAllKeys() {
HashSet<Object> allKeys = new HashSet<Object>();
for(AttributeSet delegate : delegates) {
for(Enumeration<?> keys = delegate.getAttributeNames(); keys.hasMoreElements(); ) {
Object key = keys.nextElement();
allKeys.add(key);
}
}
return allKeys;
}
示例7: dumpAttribs
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
private void dumpAttribs(AttributeSet attribs, String name, boolean tokenColoring) {
// if (!allFcsi[0].getMimePath().getPath().equals("text/x-java")) { //NOI18N
// return;
// }
StringBuilder sb = new StringBuilder();
sb.append("Attribs for base mime path '"); //NOI18N
sb.append(allFcsi[0].getMimePath().getPath());
sb.append("' and "); //NOI18N
if (tokenColoring) {
sb.append("token '"); //NOI18N
} else {
sb.append("highlight '"); //NOI18N
}
sb.append(name);
sb.append("' = {"); //NOI18N
Enumeration<?> keys = attribs.getAttributeNames();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = attribs.getAttribute(key);
sb.append("'").append(key).append("' = '").append(value).append("'"); //NOI18N
if (keys.hasMoreElements()) {
sb.append(", "); //NOI18N
}
}
sb.append("} CompoundFCS.this = "); //NOI18N
sb.append(this.toString());
System.out.println(sb.toString());
}
示例8: translate
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public static Map<Attribute,Object> translate(AttributeSet attrs) {
int attrCount = attrs.getAttributeCount();
Map<Attribute,Object> ret = new HashMap<Attribute, Object>(attrCount);
for (Enumeration<?> attrNames = attrs.getAttributeNames(); attrNames.hasMoreElements();) {
Object attrName = attrNames.nextElement();
AttributeTranslateHandler handler = attr2Handler.get(attrName);
if (handler != null) {
Object textAttrValue = handler.getTextAttrValue(attrs.getAttribute(attrName));
if (textAttrValue != null) {
ret.put(handler.getTextAttr(), textAttrValue);
}
} // Unknown attributes are ignored
}
return ret;
}
示例9: addAttributes
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public void addAttributes(AttributeSet attr)
{
Enumeration as = attr.getAttributeNames();
while(as.hasMoreElements()) {
Object el = as.nextElement();
backing.put(el, attr.getAttribute(el));
}
}
示例10: containsAttributes
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public boolean containsAttributes(AttributeSet attributes) {
Enumeration e = attributes.getAttributeNames();
while(e.hasMoreElements()) {
Object key = e.nextElement();
Object value = attributes.getAttribute(key);
if(!containsAttribute(key, value)) return false;
}
return true;
}
示例11: attrValue
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
private static String attrValue(AttributeSet attr, String attrName) {
for (Enumeration en = attr.getAttributeNames(); en.hasMoreElements(); ) {
Object name = en.nextElement();
if (attrName.equalsIgnoreCase(name.toString())) {
return attrValue(attr, name);
}
}
return null;
}
示例12: adjustAttributes
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
private static AttributeSet adjustAttributes(AttributeSet as) {
Collection<Object> attrs = new LinkedList<Object>();
for (Enumeration<?> e = as.getAttributeNames(); e.hasMoreElements(); ) {
Object key = e.nextElement();
Object value = as.getAttribute(key);
if (value != Boolean.FALSE) {
attrs.add(key);
attrs.add(value);
}
}
return AttributesUtilities.createImmutable(attrs.toArray());
}
示例13: convertToHTML32
import javax.swing.text.AttributeSet; //导入方法依赖的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 convertToHTML32(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) {
if ((key == CSS.Attribute.FONT_FAMILY)
|| (key == CSS.Attribute.FONT_SIZE)
|| (key == CSS.Attribute.COLOR)) {
createFontAttribute((CSS.Attribute) key, from, to);
}
else if (key == CSS.Attribute.FONT_WEIGHT) {
// add a bold tag is weight is bold
//CSS.FontWeight weightValue = (CSS.FontWeight) from.getAttribute(CSS.Attribute.FONT_WEIGHT);
String weightValue = from.getAttribute(CSS.Attribute.FONT_WEIGHT).toString();
if (weightValue != null) {
int fweight;
try {
fweight = new Integer(weightValue).intValue();
}
catch (Exception ex) {
fweight = -1;
}
if ((weightValue.toLowerCase().equals("bold")) || (fweight > 400))
to.addAttribute(HTML.Tag.B, SimpleAttributeSet.EMPTY);
}
}
else if (key == CSS.Attribute.FONT_STYLE) {
String s = from.getAttribute(key).toString();
if (s.indexOf("italic") >= 0) {
to.addAttribute(HTML.Tag.I, SimpleAttributeSet.EMPTY);
}
}
else if (key == CSS.Attribute.TEXT_DECORATION) {
String decor = from.getAttribute(key).toString();
if (decor.indexOf("underline") >= 0) {
to.addAttribute(HTML.Tag.U, SimpleAttributeSet.EMPTY);
}
if (decor.indexOf("line-through") >= 0) {
to.addAttribute(HTML.Tag.STRIKE, SimpleAttributeSet.EMPTY);
}
}
else if (key == CSS.Attribute.VERTICAL_ALIGN) {
String vAlign = from.getAttribute(key).toString();
if (vAlign.indexOf("sup") >= 0) {
to.addAttribute(HTML.Tag.SUP, SimpleAttributeSet.EMPTY);
}
if (vAlign.indexOf("sub") >= 0) {
to.addAttribute(HTML.Tag.SUB, SimpleAttributeSet.EMPTY);
}
}
else if (key == CSS.Attribute.TEXT_ALIGN) {
to.addAttribute(HTML.Attribute.ALIGN, from.getAttribute(key).toString());
}
else {
// 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);
}
}