Search in sources :

Example 6 with DefaultStyledDocument

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 "";
}
Also used : DefaultStyledDocument(javax.swing.text.DefaultStyledDocument) StyledDocument(javax.swing.text.StyledDocument) DefaultStyledDocument(javax.swing.text.DefaultStyledDocument) BadLocationException(javax.swing.text.BadLocationException)

Example 7 with DefaultStyledDocument

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);
}
Also used : DefaultStyledDocument(javax.swing.text.DefaultStyledDocument)

Example 8 with DefaultStyledDocument

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);
}
Also used : DefaultStyledDocument(javax.swing.text.DefaultStyledDocument) Document(javax.swing.text.Document) DefaultStyledDocument(javax.swing.text.DefaultStyledDocument) BadLocationException(javax.swing.text.BadLocationException)

Example 9 with DefaultStyledDocument

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();
}
Also used : AttributeSet(javax.swing.text.AttributeSet) DefaultStyledDocument(javax.swing.text.DefaultStyledDocument)

Aggregations

DefaultStyledDocument (javax.swing.text.DefaultStyledDocument)9 BadLocationException (javax.swing.text.BadLocationException)4 Document (javax.swing.text.Document)4 AttributeSet (javax.swing.text.AttributeSet)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Element (javax.swing.text.Element)1 StyledDocument (javax.swing.text.StyledDocument)1 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)1 RTFEditorKit (javax.swing.text.rtf.RTFEditorKit)1