Search in sources :

Example 1 with DarklafRSyntaxTheme

use of com.github.weisj.darklaf.extensions.rsyntaxarea.DarklafRSyntaxTheme 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)

Aggregations

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