use of javax.swing.text.DefaultStyledDocument in project binnavi by google.
the class BaseTypeTableCellRenderer method renderText.
public static String renderText(final TypeInstance instance) {
final StyledDocument document = new DefaultStyledDocument();
generateDocument(instance, false, document);
try {
return document.getText(0, document.getLength());
} catch (final BadLocationException exception) {
CUtilityFunctions.logException(exception);
}
return "";
}
use of javax.swing.text.DefaultStyledDocument in project binnavi by google.
the class BaseTypeTableCellRenderer method renderTypeLine.
public static FormattedCharacterBuffer renderTypeLine(final TypeInstance instance, Font font, int desiredWidth, final boolean renderData, final int line) {
DefaultStyledDocument document = new DefaultStyledDocument();
generateDocument(instance, renderData, document);
return convertDocumentToFormattedCharacterBuffer(document, font, desiredWidth);
}
use of javax.swing.text.DefaultStyledDocument in project android-classyshark by google.
the class DisplayArea method displaySearchResults.
@Override
public void displaySearchResults(List<String> filteredClassNames, List<Translator.ELEMENT> displayedManifestSearchResultsTokens, String textFromTypingArea) {
displayDataState = DisplayDataState.CLASSES_LIST;
StyleConstants.setFontSize(style, 18);
StyleConstants.setForeground(style, theme.getIdentifiersColor());
clearText();
Document doc = new DefaultStyledDocument();
jTextPane.setDocument(doc);
StyleConstants.setFontSize(style, 18);
StyleConstants.setBackground(style, theme.getBackgroundColor());
fillTokensToDoc(displayedManifestSearchResultsTokens, doc, true);
StyleConstants.setFontSize(style, 18);
StyleConstants.setForeground(style, theme.getIdentifiersColor());
StyleConstants.setBackground(style, theme.getBackgroundColor());
int displayedClassLimit = 50;
if (filteredClassNames.size() < displayedClassLimit) {
displayedClassLimit = filteredClassNames.size();
}
for (int i = 0; i < displayedClassLimit; i++) {
try {
doc.insertString(doc.getLength(), filteredClassNames.get(i) + "\n", style);
} catch (BadLocationException e) {
e.printStackTrace();
}
}
jTextPane.setDocument(doc);
jTextPane.setCaretPosition(1);
}
use of javax.swing.text.DefaultStyledDocument in project gradle by gradle.
the class TextPaneSearchInteraction method highlightText.
/**
* This highlights the text within the specified range
*
* @param startingIndex where to start the highlight
* @param endingIndex where to end the highlight
* @param ensureVisible true to scroll to the text
* @param isEmphasized true to use an emphasized highlight (versus a regular highlight). Useful for showing the 'current' highlighted result.
*/
public void highlightText(int startingIndex, int endingIndex, boolean ensureVisible, boolean isEmphasized) {
int length = endingIndex - startingIndex;
AttributeSet style;
if (isEmphasized) {
style = emphasizedHighlightStyle;
} else {
style = highlightStyle;
}
((DefaultStyledDocument) textComponentToSearch.getDocument()).setCharacterAttributes(startingIndex, length, style, true);
if (ensureVisible) {
Utility.scrollToText(textComponentToSearch, startingIndex, endingIndex);
textComponentToSearch.setCaretPosition(endingIndex);
}
textComponentToSearch.repaint();
}
Aggregations