本文整理汇总了Java中javax.swing.text.AttributeSet.isDefined方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet.isDefined方法的具体用法?Java AttributeSet.isDefined怎么用?Java AttributeSet.isDefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.AttributeSet
的用法示例。
在下文中一共展示了AttributeSet.isDefined方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttribute
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public Object getAttribute(Object key) {
if (key instanceof String && key.equals(ATTR_DISMANTLED_STRUCTURE)) {
return dismantle(this);
}
for(AttributeSet delegate : delegates) {
AttributeSet current = delegate;
while (current != null) {
if (current.isDefined(key)) {
return current.getAttribute(key);
}
current = current.getResolveParent();
}
}
return null;
}
示例2: noMatchForTagInAttributes
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
/**
* Searches the attribute set for a tag, both of which
* are passed in as a parameter. Returns true if no match is found
* and false otherwise.
*/
private boolean noMatchForTagInAttributes(AttributeSet attr, HTML.Tag t, Object tagValue) {
if (attr != null && attr.isDefined(t)) {
Object newValue = attr.getAttribute(t);
if ((tagValue == null) ? (newValue == null) : (newValue != null && tagValue.equals(newValue))) {
return false;
}
}
return true;
}
示例3: isDefined
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public boolean isDefined(Object key) {
for(AttributeSet delegate : delegates) {
if (delegate.isDefined(key)) {
return true;
}
}
return false;
}
示例4: assertAttribNotContains
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
private void assertAttribNotContains(String msg, AttributeSet as, String... keys) {
// System.out.print("assertAttribNotContains: attributes: ");
// for(Enumeration<?> attribKeys = as.getAttributeNames(); attribKeys.hasMoreElements(); ) {
// Object key = attribKeys.nextElement();
// Object value = as.getAttribute(key);
// System.out.print("'" + key + "' = '" + value + "', ");
// }
// System.out.println();
for (String key : keys) {
if (null != as.getAttribute(key) || as.isDefined(key)) {
fail(msg + " attribute key: " + key);
}
}
}
示例5: setFontProperties
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
String setFontProperties(Element el, String text) {
FontDialog dlg = new FontDialog(null);
//dlg.setLocation(editor.getLocationOnScreen());
Dimension dlgSize = dlg.getSize();
Dimension frmSize = this.getSize();
Point loc = this.getLocationOnScreen();
dlg.setLocation(
(frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.setModal(true);
AttributeSet ea = el.getAttributes();
/*
* if (ea.isDefined(HTML.Tag.FONT)) { String[] param =
* ea.getAttribute(HTML.Tag.FONT).toString().split(" "); for (int i = 0;
* i < param.length; i++) if (param[i].startsWith("face="))
* dlg.fontFamilyCB.setSelectedItem(param[i].split("=")[1]); else if
* (param[i].startsWith("size="))
* dlg.fontSizeCB.setSelectedItem(param[i].split("=")[1]); else if
* (param[i].startsWith("color=")) {
* dlg.colorField.setText(param[i].split("=")[1]);
* Util.setColorField(dlg.colorField); }
*/
if (ea.isDefined(StyleConstants.FontFamily))
dlg.fontFamilyCB.setSelectedItem(
ea.getAttribute(StyleConstants.FontFamily).toString());
if (ea.isDefined(HTML.Tag.FONT)) {
String s = ea.getAttribute(HTML.Tag.FONT).toString();
String size =
s.substring(s.indexOf("size=") + 5, s.indexOf("size=") + 6);
dlg.fontSizeCB.setSelectedItem(size);
}
if (ea.isDefined(StyleConstants.Foreground)) {
dlg.colorField.setText(
Util.encodeColor(
(Color) ea.getAttribute(StyleConstants.Foreground)));
Util.setColorField(dlg.colorField);
dlg.sample.setForeground(
(Color) ea.getAttribute(StyleConstants.Foreground));
}
if (text != null)
dlg.sample.setText(text);
dlg.setVisible(true);
if (dlg.CANCELLED)
return null;
String attrs = "";
if (dlg.fontSizeCB.getSelectedIndex() > 0)
attrs += "size=\"" + dlg.fontSizeCB.getSelectedItem() + "\"";
if (dlg.fontFamilyCB.getSelectedIndex() > 0)
attrs += "face=\"" + dlg.fontFamilyCB.getSelectedItem() + "\"";
if (dlg.colorField.getText().length() > 0)
attrs += "color=\"" + dlg.colorField.getText() + "\"";
if (attrs.length() > 0)
return " " + attrs;
else
return null;
}
示例6: getValue
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
private Object getValue (String language, AttributeSet category, Object key) {
if (category.isDefined (key))
return category.getAttribute (key);
return getDefault (language, category, key);
}
示例7: setAnnotations
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public void setAnnotations (
String profile,
Collection<AttributeSet> annotations
) {
if (annotations == null) {
EditorSettings.getDefault().setAnnotations(profile, null);
return;
}
Collection<AttributeSet> annos = new ArrayList<AttributeSet>();
for(AttributeSet category : annotations) {
AnnotationType annotationType = (AnnotationType)
category.getAttribute ("annotationType");
SimpleAttributeSet c = new SimpleAttributeSet();
c.addAttribute(StyleConstants.NameAttribute, category.getAttribute(StyleConstants.NameAttribute));
if (category.isDefined (StyleConstants.Background)) {
annotationType.setUseHighlightColor (true);
if (annotationType.getHighlight() == null || !annotationType.getHighlight().equals((Color) category.getAttribute (StyleConstants.Background))) {
annotationType.setHighlight (
(Color) category.getAttribute (StyleConstants.Background)
);
}
c.addAttribute(StyleConstants.Background, category.getAttribute(StyleConstants.Background));
} else
annotationType.setUseHighlightColor (false);
if (category.isDefined (StyleConstants.Foreground)) {
annotationType.setInheritForegroundColor (false);
if (annotationType.getForegroundColor() == null || !annotationType.getForegroundColor().equals( (Color) category.getAttribute (StyleConstants.Foreground))) {
annotationType.setForegroundColor (
(Color) category.getAttribute (StyleConstants.Foreground)
);
}
c.addAttribute(StyleConstants.Foreground, category.getAttribute(StyleConstants.Foreground));
} else
annotationType.setInheritForegroundColor (true);
if (category.isDefined (EditorStyleConstants.WaveUnderlineColor)) {
annotationType.setUseWaveUnderlineColor (true);
if(category.getAttribute (EditorStyleConstants.WaveUnderlineColor) == null || !category.getAttribute (EditorStyleConstants.WaveUnderlineColor).equals(annotationType.getWaveUnderlineColor())) {
annotationType.setWaveUnderlineColor (
(Color) category.getAttribute (EditorStyleConstants.WaveUnderlineColor)
);
}
c.addAttribute((EditorStyleConstants.WaveUnderlineColor), category.getAttribute (EditorStyleConstants.WaveUnderlineColor));
} else
annotationType.setUseWaveUnderlineColor (false);
//S ystem.out.println(" " + category.getDisplayName () + " : " + annotationType + " : " + annotationType.getHighlight() + " : " + annotationType.isUseHighlightColor());
annos.add(c);
}
EditorSettings.getDefault().setAnnotations(profile, toMap(annos));
}
示例8: setFontProperties
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
String setFontProperties(Element el, String text) {
FontDialog dlg = new FontDialog(null);
//dlg.setLocation(editor.getLocationOnScreen());
Dimension dlgSize = dlg.getSize();
Dimension frmSize = this.getSize();
Point loc = this.getLocationOnScreen();
dlg.setLocation(
(frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.setModal(true);
AttributeSet ea = el.getAttributes();
/*
* if (ea.isDefined(HTML.Tag.FONT)) { String[] param =
* ea.getAttribute(HTML.Tag.FONT).toString().split(" "); for (int i = 0;
* i < param.length; i++) if (param[i].startsWith("face="))
* dlg.fontFamilyCB.setSelectedItem(param[i].split("=")[1]); else if
* (param[i].startsWith("size="))
* dlg.fontSizeCB.setSelectedItem(param[i].split("=")[1]); else if
* (param[i].startsWith("color=")) {
* dlg.colorField.setText(param[i].split("=")[1]);
* HtmlUtil.setColorField(dlg.colorField); }
*/
if (ea.isDefined(StyleConstants.FontFamily))
dlg.fontFamilyCB.setSelectedItem(
ea.getAttribute(StyleConstants.FontFamily).toString());
if (ea.isDefined(HTML.Tag.FONT)) {
String s = ea.getAttribute(HTML.Tag.FONT).toString();
String size =
s.substring(s.indexOf("size=") + 5, s.indexOf("size=") + 6);
dlg.fontSizeCB.setSelectedItem(size);
}
if (ea.isDefined(StyleConstants.Foreground)) {
dlg.colorField.setText(
HtmlUtil.encodeColor(
(Color) ea.getAttribute(StyleConstants.Foreground)));
HtmlUtil.setColorField(dlg.colorField);
dlg.sample.setForeground(
(Color) ea.getAttribute(StyleConstants.Foreground));
}
if (text != null)
dlg.sample.setText(text);
dlg.setVisible(true);
if (dlg.CANCELLED)
return null;
String attrs = "";
if (dlg.fontSizeCB.getSelectedIndex() > 0)
attrs += "size=\"" + dlg.fontSizeCB.getSelectedItem() + "\"";
if (dlg.fontFamilyCB.getSelectedIndex() > 0)
attrs += "face=\"" + dlg.fontFamilyCB.getSelectedItem() + "\"";
if (dlg.colorField.getText().length() > 0)
attrs += "color=\"" + dlg.colorField.getText() + "\"";
if (attrs.length() > 0)
return " " + attrs;
else
return null;
}