本文整理了Java中javax.swing.text.StyledDocument.setCharacterAttributes()
方法的一些代码示例,展示了StyledDocument.setCharacterAttributes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StyledDocument.setCharacterAttributes()
方法的具体详情如下:
包路径:javax.swing.text.StyledDocument
类名称:StyledDocument
方法名:setCharacterAttributes
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Highlights specified text region by changing the character attributes
*/
private void highlightText(int start, int end, SimpleAttributeSet style) {
if (start < end) {
textPane.getStyledDocument().setCharacterAttributes(start, end - start + 1, style, false);
}
}
代码示例来源:origin: marytts/marytts
int lenght = pairIntList.get(++i) - start + 1;
doc.setCharacterAttributes(start, lenght, alertStyle, false);
代码示例来源:origin: stackoverflow.com
StyleConstants.setUnderline(set, random.nextBoolean());
doc.setCharacterAttributes(i, 1, set, true);
代码示例来源:origin: stackoverflow.com
doc.setCharacterAttributes(0, doc.getLength(), defaultStyle, false);
代码示例来源:origin: protegeproject/protege
private void fadeOntologyURI(StyledDocument doc, int tokenStartIndex, int tokenLength, boolean enclosedByBracket) {
// if surrounded by brackets, also render them in grey
int start = tokenStartIndex;
int length = tokenLength;
if (enclosedByBracket) {
start--;
length = length + 2;
}
doc.setCharacterAttributes(start, length, ontologyURIStyle, true);
}
代码示例来源:origin: protegeproject/protege
private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex,
int tokenLength) {
if (crossedOutEntities.contains(entity) || strikeThrough) {
doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false);
}
}
代码示例来源:origin: org.protege/protege-editor-owl
private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex,
int tokenLength) {
if(crossedOutEntities.contains(entity)) {
doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false);
}
}
代码示例来源:origin: edu.stanford.protege/protege-editor-owl
private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex,
int tokenLength) {
if(crossedOutEntities.contains(entity) || strikeThrough) {
doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false);
}
}
代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl
private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex,
int tokenLength) {
if(crossedOutEntities.contains(entity) || strikeThrough) {
doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-text
/** Remove guarded mark on a block of a document.
* @param doc styled document
* @param offset offset to start at
* @param len length of text to mark as unguarded
* @exception NullPointerException If the <code>doc</code> parameter
* is <code>null</code>.
*/
public static void unmarkGuarded(StyledDocument doc, int offset, int len) {
checkDocParameter(doc);
doc.setCharacterAttributes(offset, len, ATTR_REMOVE, false);
}
代码示例来源:origin: org.netbeans.api/org-openide-text
/** Mark part of a document as guarded (immutable to the user).
* @param doc styled document
* @param offset offset to start at
* @param len length of text to mark as guarded
* @exception NullPointerException If the <code>doc</code> parameter
* is <code>null</code>.
*/
public static void markGuarded(StyledDocument doc, int offset, int len) {
checkDocParameter(doc);
doc.setCharacterAttributes(offset, len, ATTR_ADD, false);
}
代码示例来源:origin: stackoverflow.com
Simple AttributeSet changed = new SimpleAttributeSet();
StyleConstants.setForeground(changed, Color.RED);
StyleConstants.setBackground(changed, Color.YELLOW);
// Change attributes on some text
StyledDocument doc = textPane.getStyledDocument();
doc.setCharacterAttributes(20, 4, changed, false);
代码示例来源:origin: stackoverflow.com
// Define a keyword attribute
SimpleAttributeSet keyWord = new SimpleAttributeSet();
StyleConstants.setForeground(keyWord, Color.RED);
StyleConstants.setBackground(keyWord, Color.YELLOW);
StyleConstants.setUnderline(keyWord, Boolean.TRUE );
StyleConstants.setBold(keyWord, true);
// Change attributes on some text
StyledDocument doc = textPane.getStyledDocument();
doc.setCharacterAttributes(start, end - start, keyWord, false);
代码示例来源:origin: edu.stanford.nlp/stanford-parser
/**
* Highlights specified text region by changing the character attributes
*/
private void highlightText(int start, int end, SimpleAttributeSet style) {
if (start < end) {
textPane.getStyledDocument().setCharacterAttributes(start, end - start + 1, style, false);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/** Mark part of a document as guarded (immutable to the user).
* @param doc styled document
* @param offset offset to start at
* @param len length of text to mark as guarded
* @exception NullPointerException If the <code>doc</code> parameter
* is <code>null</code>.
*/
public static void markGuarded (StyledDocument doc, int offset, int len) {
checkDocParameter(doc);
doc.setCharacterAttributes (offset, len, ATTR_ADD, false);
}
代码示例来源:origin: stackoverflow.com
JTextPane textPane = new JTextPane();
textPane.setText( "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight" );
StyledDocument doc = textPane.getStyledDocument();
// Define a keyword attribute
SimpleAttributeSet keyWord = new SimpleAttributeSet();
StyleConstants.setForeground(keyWord, Color.RED);
StyleConstants.setBackground(keyWord, Color.YELLOW);
// Change attributes on some text
doc.setCharacterAttributes(0, 5, keyWord, false);
代码示例来源:origin: stackoverflow.com
public static void increaseJTextPaneFont(JTextPane jtp) {
MutableAttributeSet attrs = jtp.getInputAttributes();
//first get the current size of the font
int size = StyleConstants.getFontSize(attrs);
//now increase by 2 (or whatever factor you like)
StyleConstants.setFontSize(attrs, size * 2);
StyledDocument doc = jtp.getStyledDocument();
doc.setCharacterAttributes(0, doc.getLength() + 1, attrs, false);
}
代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl
public void run() {
OWLObjectProperty prop = (OWLObjectProperty) entity;
OWLReasoner reasoner = getOWLModelManager().getReasoner();
boolean consistent = reasoner.isConsistent();
if(!consistent || reasoner.getBottomObjectPropertyNode().contains(prop)) {
doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true);
}
}
});
代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl
public void run() {
OWLReasoner reasoner = getOWLModelManager().getReasoner();
boolean consistent = reasoner.isConsistent();
if (!consistent || !getOWLModelManager().getReasoner().isSatisfiable((OWLClass) curEntity)) {
// Paint red because of inconsistency
doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true);
}
}
});
代码示例来源:origin: com.davidbracewell/hermes-core
public void removeRow(int index) {
int start = getStart(index);
int end = getEnd(index);
annotations.removeAll(annotations.overlapping(new Span(start, end)));
rows.remove(index);
editorPane.getStyledDocument()
.setCharacterAttributes(start, end - start, DEFAULT, true);
fireTableDataChanged();
}
内容来源于网络,如有侵权,请联系作者删除!