From 7d24621c18785e8e038ab9fda30e3a2a99387c3f Mon Sep 17 00:00:00 2001 From: Bane Stojkovic Date: Sun, 22 Feb 2026 22:34:10 +0100 Subject: [PATCH] Cleanup of code that doesn't work for fixing tooltip colors on linux mint (kde bug) --- .../src/main/java/org/diylc/DIYLCStarter.java | 4 -- .../main/java/org/diylc/utils/SwingUtils.java | 71 ------------------- 2 files changed, 75 deletions(-) delete mode 100644 diylc/diylc-swing/src/main/java/org/diylc/utils/SwingUtils.java diff --git a/diylc/diylc-swing/src/main/java/org/diylc/DIYLCStarter.java b/diylc/diylc-swing/src/main/java/org/diylc/DIYLCStarter.java index 9a504613..1141aa09 100644 --- a/diylc/diylc-swing/src/main/java/org/diylc/DIYLCStarter.java +++ b/diylc/diylc-swing/src/main/java/org/diylc/DIYLCStarter.java @@ -42,7 +42,6 @@ import org.diylc.serialization.ProjectFileManager; import org.diylc.swing.gui.MainFrame; import org.diylc.swing.gui.TemplateDialog; import org.diylc.swing.plugins.file.ProjectDrawingProvider; -import org.diylc.utils.SwingUtils; /** * Main class that runs DIYLC. @@ -139,9 +138,6 @@ public class DIYLCStarter { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - // Fix tooltip colors for Linux systems where they may be unreadable - SwingUtils.fixTooltipColors(); - // Apply configurable font scaling from VM argument: -Dorg.diylc.fontScaleFactor=X org.diylc.utils.FontScalingUtils.applyFontScaling(); } catch (Exception e) { diff --git a/diylc/diylc-swing/src/main/java/org/diylc/utils/SwingUtils.java b/diylc/diylc-swing/src/main/java/org/diylc/utils/SwingUtils.java deleted file mode 100644 index f1458ef0..00000000 --- a/diylc/diylc-swing/src/main/java/org/diylc/utils/SwingUtils.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * DIY Layout Creator (DIYLC). - * Copyright (c) 2009-2025 held jointly by the individual authors. - * - * This file is part of DIYLC. - * - * DIYLC is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * DIYLC is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with DIYLC. If not, see . - * - */ -package org.diylc.utils; - -import java.awt.Color; -import java.util.function.Function; -import javax.swing.UIManager; - -/** - * Utility class for Swing UI-related operations. - * - * @author Branislav Stojkovic - */ -public class SwingUtils { - - /** - * Fixes tooltip colors for Linux systems where they may be unreadable. - * Some Linux L&F themes set white text on light backgrounds, making tooltips invisible. - * This method ensures tooltips always have dark text on light background for readability. - * - * Should be called after UIManager.setLookAndFeel() to override system defaults. - */ - public static void fixTooltipColors() { - Color tooltipBg = UIManager.getColor("ToolTip.background"); - Color tooltipFg = UIManager.getColor("ToolTip.foreground"); - - // Helper function to calculate brightness (0.0 = black, 1.0 = white) - Function getBrightness = (c) -> { - return (0.299 * c.getRed() + 0.587 * c.getGreen() + 0.114 * c.getBlue()) / 255.0; - }; - - // Check if we have a problematic color combination (light text on light background) - boolean needsFix = false; - if (tooltipFg != null && tooltipBg != null) { - double fgBrightness = getBrightness.apply(tooltipFg); - double bgBrightness = getBrightness.apply(tooltipBg); - // If both foreground and background are light, it's unreadable - if (fgBrightness > 0.7 && bgBrightness > 0.5) { - needsFix = true; - } - } else if (tooltipFg == null || tooltipBg == null) { - // Missing color definitions - set safe defaults - needsFix = true; - } - - if (needsFix) { - UIManager.put("ToolTip.background", new Color(255, 255, 220)); // Light yellow - UIManager.put("ToolTip.foreground", Color.BLACK); - } - } -} -