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

x33g5p2x  于2022-01-19 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(135)

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

Element.getAttributes介绍

暂无

代码示例

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

public void focusGained(FocusEvent fe) {
    textComponent = (JTextComponent) fe.getSource();
    attributeSet =
        textComponent.getDocument().getDefaultRootElement().getAttributes();
  }
};

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

for (int i = 0; i < line.getElementCount(); i++) {
  Element child = line.getElement(i);
  AttributeSet as = child.getAttributes();
  String fontFamily = (String) as.getAttribute(StyleConstants.FontFamily);
  Integer fontSize = (Integer) as.getAttribute(StyleConstants.FontSize);

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

public void actionPerformed(ActionEvent ae) {
  JTextComponent tComp = (JTextComponent) ae.getSource();
  if (tComp.getDocument() instanceof StyledDocument) {
    doc = (StyledDocument) tComp.getDocument();
    try {
      doc.getText(0, doc.getLength(), segment);
    }
    catch (Exception e) {
      // should NEVER reach here
      e.printStackTrace();
    }
    int offset = tComp.getCaretPosition();
    int index = findTabLocation(offset);
    buffer.delete(0, buffer.length());
    buffer.append('\n');
    if (index > -1) {
      for (int i = 0; i < index + 4; i++) {
        buffer.append(' ');
      }
    }
    try {
      doc.insertString(offset, buffer.toString(),
          doc.getDefaultRootElement().getAttributes());
    }
    catch (BadLocationException ble) {
      ble.printStackTrace();
    }
  }
}

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

AttributeSet as = child.getAttributes();
String fontFamily = (String) as.getAttribute(StyleConstants.FontFamily);
Integer fontSize = (Integer) as.getAttribute(StyleConstants.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: 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: chatty/chatty

/**
 * Checks if the given line contains an attribute indicating that the line
 * is already deleted.
 * 
 * @param line The element representing this line
 * @return 
 */
private boolean isLineDeleted(Element line) {
  return line.getAttributes().containsAttribute(Attribute.DELETED_LINE, true);
}

代码示例来源: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: 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: org.codehaus.groovy/groovy-console

public void focusGained(FocusEvent fe) {
    textComponent = (JTextComponent) fe.getSource();
    attributeSet =
        textComponent.getDocument().getDefaultRootElement().getAttributes();
  }
};

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

public void focusGained(FocusEvent fe) {
    textComponent = (JTextComponent) fe.getSource();
    attributeSet =
        textComponent.getDocument().getDefaultRootElement().getAttributes();
  }
};

代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal

public void focusGained(FocusEvent fe) {
    textComponent = (JTextComponent)fe.getSource();
    attributeSet =
      textComponent.getDocument().getDefaultRootElement().getAttributes();
  }
};

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

/** Method tests whether the image within a link
 */
boolean isLink()
{
  AttributeSet anchorAttr = (AttributeSet)fElement.getAttributes().getAttribute(HTML.Tag.A);
  if(anchorAttr != null)
  {
    return anchorAttr.isDefined(HTML.Attribute.HREF);
  }
  return false;
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
protected void startTag(Element elem) throws IOException, BadLocationException {
  if (bodyStarted) {
    super.startTag(elem);
  }
  if (HTML.Tag.BODY == elem.getAttributes().getAttribute(StyleConstants.NameAttribute)) {
    bodyStarted = true;
  }
}

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

private AttributeSet getStyleUnderCursor(MouseEvent e) {
  int i = textPane.viewToModel(e.getPoint());
  return textPane.getStyledDocument().getCharacterElement(i).getAttributes();
 }
}

代码示例来源: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

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

相关文章