javax.swing.text.AttributeSet.getAttribute()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(33)

本文整理了Java中javax.swing.text.AttributeSet.getAttribute()方法的一些代码示例,展示了AttributeSet.getAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributeSet.getAttribute()方法的具体详情如下:
包路径:javax.swing.text.AttributeSet
类名称:AttributeSet
方法名:getAttribute

AttributeSet.getAttribute介绍

暂无

代码示例

代码示例来源:origin: skylot/jadx

Element child = line.getElement(i);
AttributeSet as = child.getAttributes();
String fontFamily = (String) as.getAttribute(StyleConstants.FontFamily);
Integer fontSize = (Integer) as.getAttribute(StyleConstants.FontSize);
String key = fontFamily + fontSize;
FontMetrics fm = fonts.computeIfAbsent(key, k -> {

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf

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());
}

代码示例来源:origin: SonarSource/sonarqube

Element child = line.getElement(i);
AttributeSet as = child.getAttributes();
String fontFamily = (String) as.getAttribute(StyleConstants.FontFamily);
Integer fontSize = (Integer) as.getAttribute(StyleConstants.FontSize);
String key = fontFamily + fontSize;

代码示例来源:origin: groovy/groovy-core

public int findTabLocation(int offset) {
    // find first {
    boolean cont = true;
    while (offset > -1 && cont) {
      Element el = doc.getCharacterElement(offset);
      Object color =
          el.getAttributes().getAttribute(StyleConstants.Foreground);
      if (!COMMENT_COLOR.equals(color)) {
        cont = segment.array[offset] != '{' &&
            segment.array[offset] != '}';
      }
      offset -= cont ? 1 : 0;
    }
    if (offset > -1 && segment.array[offset] == '{') {
      while (offset > -1 &&
          !Character.isWhitespace(segment.array[offset--])) {
      }
    }
    int index = offset < 0 || segment.array[offset] == '}' ? -4 : 0;
    if (offset > -1) {
      Element top = doc.getDefaultRootElement();
      offset = top.getElement(top.getElementIndex(offset)).getStartOffset();
      while (Character.isWhitespace(segment.array[offset++])) {
        index++;
      }
    }
    return index;
  }
}

代码示例来源:origin: stackoverflow.com

public class MyStyleContext extends javax.swing.text.StyleContext
{
  @Override public Font getFont(AttributeSet attr)
  {
    Font font = attr.getAttribute("MyFont");
    if (font != null)
      return font;
    else
      return super.getFont(attr);
  }
}

代码示例来源:origin: chatty/chatty

private static Color getColor(AttributeSet attr, Attribute key) {
  Object value = attr.getAttribute(key);
  if (value instanceof Color) {
    return (Color)value;
  }
  return null;
}

代码示例来源:origin: chatty/chatty

private static int getInteger(AttributeSet attr, Attribute key) {
  Object value = attr.getAttribute(key);
  if (value instanceof Integer) {
    return (Integer)value;
  }
  return -1;
}

代码示例来源:origin: chatty/chatty

private static boolean getBoolean(AttributeSet attr, Attribute key) {
    Object value = attr.getAttribute(key);
    if (value instanceof Boolean) {
      return (Boolean)value;
    }
    return false;
  }
}

代码示例来源:origin: stackoverflow.com

public void mouseClicked(MouseEvent e)
   {
     Element ele = doc.getCharacterElement(chatbox.viewToModel(e.getPoint()));
     AttributeSet as = ele.getAttributes();
     ChatLinkListener fla = (ChatLinkListener)as.getAttribute("linkact");
     if(fla != null)
     {
       fla.execute();
     }
   }

代码示例来源:origin: otros-systems/otroslogviewer

private Optional<String> getExceptionNameAndMsgUnderCursor(MouseEvent e) {
 AttributeSet styleUnderCursor = getStyleUnderCursor(e);
 final String exceptionMessage = (String) styleUnderCursor.getAttribute("exceptionMessage");
 return Optional.ofNullable(exceptionMessage);
}

代码示例来源:origin: chatty/chatty

private long getTimeAgo(Element element) {
  Long timestamp = (Long)element.getAttributes().getAttribute(Attribute.TIMESTAMP);
  if (timestamp != null) {
    return System.currentTimeMillis() - timestamp;
  }
  return Long.MAX_VALUE;
}

代码示例来源:origin: chatty/chatty

/**
 * Gets the id attached to the message.
 * 
 * @param element
 * @return The ID element, or null if none was found
 */
public static String getIdFromElement(Element element) {
  if (element != null) {
    return (String)element.getAttributes().getAttribute(Attribute.ID);
  }
  return null;
}

代码示例来源:origin: freeplane/freeplane

private boolean isEndtag(final Element elem) {
  final AttributeSet attributes = elem.getAttributes();
  final Object endTag = attributes.getAttribute(HTML.Attribute.ENDTAG);
  final boolean isEndtag = (endTag instanceof String) && ((String) endTag).equals("true");
  return isEndtag;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-rhtml

private static Color getColoring(FontColorSettings fcs, String tokenName) {
  AttributeSet as = fcs.getTokenFontColors(tokenName);
  if (as != null) {
    return (Color) as.getAttribute(StyleConstants.Background); //NOI18N
  }
  return null;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-mobility-svgcore

public static boolean isHiddenElement(DocumentElement de) {
  AttributeSet attrs = de.getAttributes();
  String visible = (String) attrs.getAttribute(SVGConstants.SVG_VISIBILITY_ATTRIBUTE);
  if (visible != null && visible.equals(SVGConstants.CSS_HIDDEN_VALUE)) {
    return true;
  }
  return false;
}

代码示例来源:origin: chatty/chatty

private boolean isUrlDeleted(Element e) {
  Boolean deleted = (Boolean) e.getAttributes().getAttribute(ChannelTextPane.Attribute.URL_DELETED);
  if (deleted == null) {
    return false;
  }
  return deleted;
}

代码示例来源:origin: chatty/chatty

public static void getImageIds(Element element, Set<Long> ids) {
  Long id = (Long)element.getAttributes().getAttribute(ChannelTextPane.Attribute.IMAGE_ID);
  if (id != null) {
    ids.add(id);
  }
  for (int i=0; i<element.getElementCount(); i++) {
    getImageIds(element.getElement(i), ids);
  }
}

代码示例来源:origin: protegeproject/protege

@Override
  public void mouseMoved(MouseEvent e) {
    int pos = previewText.viewToModel(e.getPoint());
    StyledDocument doc = previewText.getStyledDocument();
    Element element = doc.getCharacterElement(pos);
    AttributeSet addtributes = element.getAttributes();
    Style style = doc.getStyle((String) addtributes
        .getAttribute(StyleConstants.NameAttribute));
    previewText.setToolTipText(
        "Click to change the " + style.getName() + " color");
  }
});

代码示例来源:origin: protegeproject/protege

private static Style getStyleAtPoint(JTextPane text, Point point) {
  int pos = text.viewToModel(point);
  StyledDocument doc = text.getStyledDocument();
  Element element = doc.getCharacterElement(pos);
  AttributeSet addtributes = element.getAttributes();
  return doc.getStyle((String) addtributes
      .getAttribute(StyleConstants.NameAttribute));
}

代码示例来源:origin: chatty/chatty

private void clearImages(Element element) {
  Long imageId = (Long)element.getAttributes().getAttribute(Attribute.IMAGE_ID);
  if (imageId != null) {
    kit.clearImage(imageId);
  }
  if (!element.isLeaf()) {
    for (int i=0; i<element.getElementCount(); i++) {
      clearImages(element.getElement(i));
    }
  }
}

相关文章