Ticket #19819: JOSM-FlatLaf-blue-links-fix.diff

File JOSM-FlatLaf-blue-links-fix.diff, 3.8 KB (added by DevCharly, 6 years ago)

fix blue links (updated to use ColorHelper.color2html())

  • src/org/openstreetmap/josm/gui/help/HelpBrowser.java

     
    135135            return ss;
    136136        }
    137137        ss.addRule(css);
     138
     139        // overwrite link color
     140        String linkColor = JosmEditorPane.getLinkColor(null);
     141        if (linkColor != null) {
     142            ss.addRule("a {color: "+linkColor+"}");
     143        }
    138144        return ss;
    139145    }
    140146
  • src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java

     
    1515import javax.swing.text.html.StyleSheet;
    1616
    1717import org.openstreetmap.josm.gui.util.GuiHelper;
     18import org.openstreetmap.josm.tools.ColorHelper;
    1819import org.openstreetmap.josm.tools.Destroyable;
    1920import org.openstreetmap.josm.tools.HttpClient;
    2021import org.openstreetmap.josm.tools.LanguageInfo;
     
    100101        final Font f = UIManager.getFont("Label.font");
    101102        final StyleSheet ss = new StyleSheet();
    102103        ss.addRule((allBold ? "html" : "strong, b") + " {" + getFontRule(f) + '}');
    103         ss.addRule("a {text-decoration: underline; color: blue}");
     104        ss.addRule("a {text-decoration: underline; color: "+getLinkColor("blue")+"}");
    104105        ss.addRule("h1 {" + getFontRule(GuiHelper.getTitleFont()) + '}');
    105106        ss.addRule("ol {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: decimal}");
    106107        ss.addRule("ul {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: disc}");
     
    140141        );
    141142    }
    142143
     144    /**
     145     * Returns the color (in CSS format) that should be used for links.
     146     * If the current look and feel does not provide a link color, the passed default color is used.
     147     * @param defaultColor the default color
     148     * @return link color
     149     */
     150    public static String getLinkColor(String defaultColor) {
     151        Color color = UIManager.getColor("Component.linkColor");
     152        return (color != null) ? ColorHelper.color2html(color) : defaultColor;
     153    }
     154
    143155    @Override
    144156    public void destroy() {
    145157        TextContextualPopupMenu.disableMenuFor(this, launcher);
  • src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java

     
    5656                "bold",
    5757                f.isItalic() ? "italic" : "normal"
    5858        ) + '}');
    59         ss.addRule("a {text-decoration: underline; color: blue}");
     59        ss.addRule("a {text-decoration: underline; color: "+JosmEditorPane.getLinkColor("blue")+"}");
    6060        ss.addRule("ul {margin-left: 1cm; list-style-type: disc}");
    6161        JosmHTMLEditorKit kit = new JosmHTMLEditorKit();
    6262        kit.setStyleSheet(ss);
  • src/org/openstreetmap/josm/gui/GettingStarted.java

     
    5656    private static final String STYLE = "<style type=\"text/css\">\n"
    5757            + "body {font-family: sans-serif; font-weight: bold; }\n"
    5858            + "h1 {text-align: center; }\n"
    59             + "a {color: #316ed9; }\n"
     59            + "a {color: "+JosmEditorPane.getLinkColor("#316ed9")+"; }\n"
    6060            + ".icon {font-size: 0; }\n"
    6161            + "</style>\n";
    6262