Search in sources :

Example 1 with Theme

use of org.fife.ui.rsyntaxtextarea.Theme in project knime-core by knime.

the class KnimeSyntaxTextArea method applySyntaxColors.

/**
 * Loads the theme from the {@link JSnippetTextArea}'s class package's {@code eclipse.xml} file.
 *
 * @throws IOException Problem with loading.
 */
protected void applySyntaxColors() throws IOException {
    InputStream in = JSnippetTextArea.class.getResourceAsStream("eclipse.xml");
    Theme theme = Theme.load(in);
    theme.apply(this);
}
Also used : InputStream(java.io.InputStream) Theme(org.fife.ui.rsyntaxtextarea.Theme)

Example 2 with Theme

use of org.fife.ui.rsyntaxtextarea.Theme in project zaproxy by zaproxy.

the class HttpPanelSyntaxHighlightTextArea method setLookAndFeel.

private void setLookAndFeel(boolean dark) {
    try {
        Theme theme = Theme.load(this.getClass().getResourceAsStream(dark ? RESOURCE_DARK : RESOURCE_LIGHT));
        theme.apply(this);
        setFont();
    } catch (IOException e) {
    // Ignore
    }
}
Also used : Theme(org.fife.ui.rsyntaxtextarea.Theme) IOException(java.io.IOException)

Example 3 with Theme

use of org.fife.ui.rsyntaxtextarea.Theme in project jmeter by apache.

the class JSyntaxTextArea method applyTheme.

/**
 * Apply XML Theme to syntax text area
 * @param jSyntaxTextArea
 */
private static void applyTheme(JSyntaxTextArea jSyntaxTextArea) {
    final boolean isDarklafTheme = LookAndFeelCommand.isDarklafTheme();
    final Theme theme = isDarklafTheme ? new DarklafRSyntaxTheme(jSyntaxTextArea) : DEFAULT_THEME;
    if (theme != null) {
        theme.apply(jSyntaxTextArea);
        Font font = jSyntaxTextArea.getFont();
        float scale = JMeterUIDefaults.INSTANCE.getScale();
        if (Math.abs(scale - 1.0f) > 0.01) {
            font = font.deriveFont(font.getSize2D() * scale);
            jSyntaxTextArea.setFont(font);
        }
    }
    if (!isDarklafTheme) {
        // Darklaf themes provide a custom background color for editors, so we don't overwrite it.
        Color color = UIManager.getColor("TextArea.background");
        if (color != null) {
            // Pretend syntax textarea theme was designed for the current LaF
            jSyntaxTextArea.setBackground(color);
        }
    }
}
Also used : DarklafRSyntaxTheme(com.github.weisj.darklaf.extensions.rsyntaxarea.DarklafRSyntaxTheme) Color(java.awt.Color) Theme(org.fife.ui.rsyntaxtextarea.Theme) DarklafRSyntaxTheme(com.github.weisj.darklaf.extensions.rsyntaxarea.DarklafRSyntaxTheme) Font(java.awt.Font)

Example 4 with Theme

use of org.fife.ui.rsyntaxtextarea.Theme in project knime-core by knime.

the class KnimeSyntaxTextArea method applySyntaxColors.

/**
 * Loads the theme from this class' package {@code eclipse.xml} file.
 *
 * @throws IOException Problem with loading.
 */
protected void applySyntaxColors() throws IOException {
    try (InputStream in = KnimeSyntaxTextArea.class.getResourceAsStream("eclipse.xml")) {
        Theme theme = Theme.load(in);
        theme.apply(this);
    }
}
Also used : InputStream(java.io.InputStream) Theme(org.fife.ui.rsyntaxtextarea.Theme)

Aggregations

Theme (org.fife.ui.rsyntaxtextarea.Theme)4 InputStream (java.io.InputStream)2 DarklafRSyntaxTheme (com.github.weisj.darklaf.extensions.rsyntaxarea.DarklafRSyntaxTheme)1 Color (java.awt.Color)1 Font (java.awt.Font)1 IOException (java.io.IOException)1