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

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(162)

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

StyledDocument.setCharacterAttributes介绍

暂无

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

  1. /**
  2. * Highlights specified text region by changing the character attributes
  3. */
  4. private void highlightText(int start, int end, SimpleAttributeSet style) {
  5. if (start < end) {
  6. textPane.getStyledDocument().setCharacterAttributes(start, end - start + 1, style, false);
  7. }
  8. }

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

  1. int lenght = pairIntList.get(++i) - start + 1;
  2. doc.setCharacterAttributes(start, lenght, alertStyle, false);

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

  1. StyleConstants.setUnderline(set, random.nextBoolean());
  2. doc.setCharacterAttributes(i, 1, set, true);

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

  1. doc.setCharacterAttributes(0, doc.getLength(), defaultStyle, false);

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

  1. private void fadeOntologyURI(StyledDocument doc, int tokenStartIndex, int tokenLength, boolean enclosedByBracket) {
  2. // if surrounded by brackets, also render them in grey
  3. int start = tokenStartIndex;
  4. int length = tokenLength;
  5. if (enclosedByBracket) {
  6. start--;
  7. length = length + 2;
  8. }
  9. doc.setCharacterAttributes(start, length, ontologyURIStyle, true);
  10. }

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

  1. private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex,
  2. int tokenLength) {
  3. if (crossedOutEntities.contains(entity) || strikeThrough) {
  4. doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false);
  5. }
  6. }

代码示例来源:origin: org.protege/protege-editor-owl

  1. private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex,
  2. int tokenLength) {
  3. if(crossedOutEntities.contains(entity)) {
  4. doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false);
  5. }
  6. }

代码示例来源:origin: edu.stanford.protege/protege-editor-owl

  1. private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex,
  2. int tokenLength) {
  3. if(crossedOutEntities.contains(entity) || strikeThrough) {
  4. doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false);
  5. }
  6. }

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

  1. private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex,
  2. int tokenLength) {
  3. if(crossedOutEntities.contains(entity) || strikeThrough) {
  4. doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false);
  5. }
  6. }

代码示例来源:origin: org.netbeans.api/org-openide-text

  1. /** Remove guarded mark on a block of a document.
  2. * @param doc styled document
  3. * @param offset offset to start at
  4. * @param len length of text to mark as unguarded
  5. * @exception NullPointerException If the <code>doc</code> parameter
  6. * is <code>null</code>.
  7. */
  8. public static void unmarkGuarded(StyledDocument doc, int offset, int len) {
  9. checkDocParameter(doc);
  10. doc.setCharacterAttributes(offset, len, ATTR_REMOVE, false);
  11. }

代码示例来源:origin: org.netbeans.api/org-openide-text

  1. /** Mark part of a document as guarded (immutable to the user).
  2. * @param doc styled document
  3. * @param offset offset to start at
  4. * @param len length of text to mark as guarded
  5. * @exception NullPointerException If the <code>doc</code> parameter
  6. * is <code>null</code>.
  7. */
  8. public static void markGuarded(StyledDocument doc, int offset, int len) {
  9. checkDocParameter(doc);
  10. doc.setCharacterAttributes(offset, len, ATTR_ADD, false);
  11. }

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

  1. Simple AttributeSet changed = new SimpleAttributeSet();
  2. StyleConstants.setForeground(changed, Color.RED);
  3. StyleConstants.setBackground(changed, Color.YELLOW);
  4. // Change attributes on some text
  5. StyledDocument doc = textPane.getStyledDocument();
  6. doc.setCharacterAttributes(20, 4, changed, false);

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

  1. // Define a keyword attribute
  2. SimpleAttributeSet keyWord = new SimpleAttributeSet();
  3. StyleConstants.setForeground(keyWord, Color.RED);
  4. StyleConstants.setBackground(keyWord, Color.YELLOW);
  5. StyleConstants.setUnderline(keyWord, Boolean.TRUE );
  6. StyleConstants.setBold(keyWord, true);
  7. // Change attributes on some text
  8. StyledDocument doc = textPane.getStyledDocument();
  9. doc.setCharacterAttributes(start, end - start, keyWord, false);

代码示例来源:origin: edu.stanford.nlp/stanford-parser

  1. /**
  2. * Highlights specified text region by changing the character attributes
  3. */
  4. private void highlightText(int start, int end, SimpleAttributeSet style) {
  5. if (start < end) {
  6. textPane.getStyledDocument().setCharacterAttributes(start, end - start + 1, style, false);
  7. }
  8. }

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

  1. /** Mark part of a document as guarded (immutable to the user).
  2. * @param doc styled document
  3. * @param offset offset to start at
  4. * @param len length of text to mark as guarded
  5. * @exception NullPointerException If the <code>doc</code> parameter
  6. * is <code>null</code>.
  7. */
  8. public static void markGuarded (StyledDocument doc, int offset, int len) {
  9. checkDocParameter(doc);
  10. doc.setCharacterAttributes (offset, len, ATTR_ADD, false);
  11. }

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

  1. JTextPane textPane = new JTextPane();
  2. textPane.setText( "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight" );
  3. StyledDocument doc = textPane.getStyledDocument();
  4. // Define a keyword attribute
  5. SimpleAttributeSet keyWord = new SimpleAttributeSet();
  6. StyleConstants.setForeground(keyWord, Color.RED);
  7. StyleConstants.setBackground(keyWord, Color.YELLOW);
  8. // Change attributes on some text
  9. doc.setCharacterAttributes(0, 5, keyWord, false);

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

  1. public static void increaseJTextPaneFont(JTextPane jtp) {
  2. MutableAttributeSet attrs = jtp.getInputAttributes();
  3. //first get the current size of the font
  4. int size = StyleConstants.getFontSize(attrs);
  5. //now increase by 2 (or whatever factor you like)
  6. StyleConstants.setFontSize(attrs, size * 2);
  7. StyledDocument doc = jtp.getStyledDocument();
  8. doc.setCharacterAttributes(0, doc.getLength() + 1, attrs, false);
  9. }

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

  1. public void run() {
  2. OWLObjectProperty prop = (OWLObjectProperty) entity;
  3. OWLReasoner reasoner = getOWLModelManager().getReasoner();
  4. boolean consistent = reasoner.isConsistent();
  5. if(!consistent || reasoner.getBottomObjectPropertyNode().contains(prop)) {
  6. doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true);
  7. }
  8. }
  9. });

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

  1. public void run() {
  2. OWLReasoner reasoner = getOWLModelManager().getReasoner();
  3. boolean consistent = reasoner.isConsistent();
  4. if (!consistent || !getOWLModelManager().getReasoner().isSatisfiable((OWLClass) curEntity)) {
  5. // Paint red because of inconsistency
  6. doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true);
  7. }
  8. }
  9. });

代码示例来源:origin: com.davidbracewell/hermes-core

  1. public void removeRow(int index) {
  2. int start = getStart(index);
  3. int end = getEnd(index);
  4. annotations.removeAll(annotations.overlapping(new Span(start, end)));
  5. rows.remove(index);
  6. editorPane.getStyledDocument()
  7. .setCharacterAttributes(start, end - start, DEFAULT, true);
  8. fireTableDataChanged();
  9. }

相关文章