本文整理了Java中javax.swing.text.SimpleAttributeSet.getAttribute()
方法的一些代码示例,展示了SimpleAttributeSet.getAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SimpleAttributeSet.getAttribute()
方法的具体详情如下:
包路径:javax.swing.text.SimpleAttributeSet
类名称:SimpleAttributeSet
方法名:getAttribute
暂无
代码示例来源:origin: stackoverflow.com
if (att_.toString().equalsIgnoreCase("title")) {
return attSet_.getAttribute(att_).toString();
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
sourceKeys[i] = (String) temp.toString();
sourceValues[i] = new String();
sourceValues[i] = (String) sourceAS.getAttribute(temp).toString();
i++;
removeValues[j] = (String) removeAS.getAttribute(removeKeys[j]).toString();
j++;
代码示例来源:origin: stackoverflow.com
JEditorPane editorPane = new JEditorPane() {
@Override
public String getToolTipText(MouseEvent evt) {
String text = null;
int pos = viewToModel(evt.getPoint());
if (pos >= 0) {
HTMLDocument hdoc = (HTMLDocument) getDocument();
javax.swing.text.Element e = hdoc.getCharacterElement(pos);
AttributeSet a = e.getAttributes();
SimpleAttributeSet value = (SimpleAttributeSet) a.getAttribute(HTML.Tag.A);
if (value != null) {
String href = (String) value.getAttribute(HTML.Attribute.HREF);
if (href != null) {
text = href;
}
}
}
return text;
}
};
代码示例来源:origin: stackoverflow.com
EditorKit kit = new HTMLEditorKit();
HTMLDocument doc = (HTMLDocument)kit.createDefaultDocument();
doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
kit.read(reader, doc, 0);
HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A);
while (it.isValid())
{
SimpleAttributeSet s = (SimpleAttributeSet)it.getAttributes();
String href = (String)s.getAttribute(HTML.Attribute.HREF);
System.out.println( href );
it.next();
}
代码示例来源:origin: net.sf.mmax2/mmax2
relationColors.add((Color)attributes.getAttribute(tempElem));
relationStyles.add((Integer)attributes.getAttribute(tempElem));
代码示例来源:origin: stackoverflow.com
public class ExtendedHTMLEditorKit extends HTMLEditorKit{
//.... other code here
public class MyHTMLFactory extends HTMLFactory{
//other code here
@Override
public View create(Element elem) {
if (isLayered(elem)){ //it means, it has position attribute
return new PositionedView(elem);
}
else
return super.create(elem);
}
boolean isLayered(Element elem){
SimpleAttributeSet sas = new SimpleAttributeSet(elem);
StyleSheet styles = (HTMLDocument elem.getDocument).getStyleSheet();
Tag tag = element.getAttributes().getAttribute(AttributeSet.NameAttribute);
sas.addAttributes(styleSheet.getRule(tag, element));
return sas.isDefined("position")
&& !sas.getAttribute("position").toString().equalsIgnorecase("static");
}
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
Object entryValue = sasText.getAttribute(entryKey);
if(entryKey.toString().equals(HTML.Tag.A.toString()))
if(subKey.toString().toLowerCase().equals("href"))
currentAnchor = ((SimpleAttributeSet)entryValue).getAttribute(subKey).toString();
break;
Object entryValue = baseAttrs.getAttribute(entryKey);
insertAttribute(sasAttr, entryKey, entryValue);
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages
private static void addColor(
String tokenType,
SimpleAttributeSet sas,
Map<String,AttributeSet> colorsMap,
Map<String,AttributeSet> defaultsMap
) {
if (sas == null)
sas = new SimpleAttributeSet();
else
sas = new SimpleAttributeSet(sas);
String colorName = (String) sas.getAttribute(StyleConstants.NameAttribute);
if (colorName == null)
colorName = tokenType;
sas.addAttribute(StyleConstants.NameAttribute, colorName);
sas.addAttribute(EditorStyleConstants.DisplayName, colorName);
if (!sas.isDefined(EditorStyleConstants.Default)) {
String def = colorName;
int i = def.lastIndexOf('_');
if (i > 0) def = def.substring(i + 1);
if (defaultsMap.containsKey(def))
sas.addAttribute(EditorStyleConstants.Default, def);
}
colorsMap.put(colorName, sas);
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
parentTextPane.setParagraphAttributes(sasPara, true);
} else if (textLength < 0) {
if (sasPara.getAttribute(StyleConstants.NameAttribute) == Tag.IMPLIED) sasPara.addAttribute(
StyleConstants.NameAttribute, Tag.P);
sasPara.addAttribute(HTML.Attribute.ALIGN, a_);
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
insertAttr(attrs, "face", attrs.getAttribute("face"));
insertAttr(attrs, "font-family", attrs.getAttribute("face"));
代码示例来源:origin: ru.sbtqa/monte-media
@Override
public void mouseClicked(MouseEvent e) {
Point point = e.getPoint();
AccessibleText at = (AccessibleText) label.getAccessibleContext();
int pos = at.getIndexAtPoint(point);
AttributeSet as = at.getCharacterAttribute(pos);
if (label.isEnabled() && as.getAttribute(A) != null) {
label.setCursor(getPredefinedCursor(HAND_CURSOR));
SimpleAttributeSet attr = (SimpleAttributeSet) as.getAttribute(A);
String href = (String) attr.getAttribute(HREF);
fireActionPerformed(new ActionEvent(label, ACTION_PERFORMED, href));
} else {
label.setCursor(getDefaultCursor());
}
}
代码示例来源:origin: com.github.stephenc.monte/monte-screen-recorder
@Override
public void mouseClicked(MouseEvent e) {
Point point = e.getPoint();
AccessibleText at = (AccessibleText) label.getAccessibleContext();
int pos = at.getIndexAtPoint(point);
AttributeSet as = at.getCharacterAttribute(pos);
if (label.isEnabled() && as.getAttribute(HTML.Tag.A) != null) {
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
SimpleAttributeSet attr=(SimpleAttributeSet)as.getAttribute(HTML.Tag.A);
String href=(String)attr.getAttribute(HTML.Attribute.HREF);
fireActionPerformed(
new ActionEvent(label,ActionEvent.ACTION_PERFORMED,href));
} else {
label.setCursor(Cursor.getDefaultCursor());
}
}
代码示例来源:origin: raydac/netbeans-mmd-plugin
private void cacheLinkElements() {
this.linkCache = new ArrayList<>();
final View view = (View) this.getClientProperty("html"); //NOI18N
if (view != null) {
final HTMLDocument doc = (HTMLDocument) view.getDocument();
final HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A);
while (it.isValid()) {
final SimpleAttributeSet s = (SimpleAttributeSet) it.getAttributes();
final String link = (String) s.getAttribute(HTML.Attribute.HREF);
if (link != null) {
this.linkCache.add(new HtmlLinkAddress(link, it.getStartOffset(), it.getEndOffset()));
}
it.next();
}
}
}
代码示例来源:origin: javax.help/javahelp
/**
* Creates a link button. This is just a JButton with default settings.
*/
private void createLinkButton() {
LookAndFeel.installBorder(this, buttonPropertyPrefix + "border");
setBorderPainted(true);
setFocusPainted(true);
setAlignmentY(Container.CENTER_ALIGNMENT);
setContentAreaFilled(true);
setBackground(UIManager.getColor(buttonPropertyPrefix + "background"));
if (textAttribs != null &&
textAttribs.isDefined(StyleConstants.Foreground)) {
setForeground((Color)textAttribs.getAttribute(StyleConstants.Foreground));
} else {
setForeground(UIManager.getColor(buttonPropertyPrefix + "foreground"));
}
invalidate();
}
代码示例来源:origin: cpesch/RouteConverter
private void createLinkLabel() {
setBorder(new EmptyBorder(1, 1, 1, 1));
setBorderPainted(false);
setFocusPainted(false);
setAlignmentY(getPreferredAlignmentY());
setContentAreaFilled(false);
setHorizontalAlignment(LEFT);
setBackground(UIManager.getColor("EditorPane.background"));
if (textAttribs != null && textAttribs.isDefined(Foreground)) {
setForeground((Color) textAttribs.getAttribute(Foreground));
} else {
setForeground(blue);
}
invalidate();
}
代码示例来源:origin: javax.help/javahelp
/**
* Creates a link label. A link label is a form of a JButton but without a
* button like appearance.
*/
private void createLinkLabel() {
setBorder(new EmptyBorder(1,1,1,1));
setBorderPainted(false);
setFocusPainted(false);
setAlignmentY(getPreferredLabelAlignment());
setContentAreaFilled(false);
setBackground(UIManager.getColor(editorPropertyPrefix + "background"));
if (textAttribs != null &&
textAttribs.isDefined(StyleConstants.Foreground)) {
setForeground((Color)textAttribs.getAttribute(StyleConstants.Foreground));
} else {
setForeground(Color.blue);
}
invalidate();
}
代码示例来源:origin: net.sf.mmax2/mmax2
resultSet.addAttribute("handles", inferiorSet.getAttribute("handles"));
代码示例来源:origin: net.sf.mmax2/mmax2
StyleConstants.setForeground(handleStyle, (Color) markableAttributes.getAttribute("handles"));
内容来源于网络,如有侵权,请联系作者删除!