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

File JOSM-FlatLaf-blue-links-fix, 3.5 KB (added by DevCharly, 5 years ago)

fix blue links

Line 
1Index: src/org/openstreetmap/josm/gui/help/HelpBrowser.java
2===================================================================
3--- src/org/openstreetmap/josm/gui/help/HelpBrowser.java (revision 17046)
4+++ src/org/openstreetmap/josm/gui/help/HelpBrowser.java (working copy)
5@@ -135,6 +135,12 @@
6 return ss;
7 }
8 ss.addRule(css);
9+
10+ // overwrite link color
11+ String linkColor = JosmEditorPane.getLinkColor(null);
12+ if (linkColor != null) {
13+ ss.addRule("a {color: "+linkColor+"}");
14+ }
15 return ss;
16 }
17
18Index: src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java
19===================================================================
20--- src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java (revision 17046)
21+++ src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java (working copy)
22@@ -100,7 +100,7 @@
23 final Font f = UIManager.getFont("Label.font");
24 final StyleSheet ss = new StyleSheet();
25 ss.addRule((allBold ? "html" : "strong, b") + " {" + getFontRule(f) + '}');
26- ss.addRule("a {text-decoration: underline; color: blue}");
27+ ss.addRule("a {text-decoration: underline; color: "+getLinkColor("blue")+"}");
28 ss.addRule("h1 {" + getFontRule(GuiHelper.getTitleFont()) + '}');
29 ss.addRule("ol {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: decimal}");
30 ss.addRule("ul {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: disc}");
31@@ -140,6 +140,19 @@
32 );
33 }
34
35+ /**
36+ * Returns the color (in CSS format) that should be used for links.
37+ * If the current look and feel does not provide a link color, the passed default color is used.
38+ * @param defaultColor the default color
39+ * @return link color
40+ */
41+ public static String getLinkColor(String defaultColor) {
42+ Color color = UIManager.getColor("Component.linkColor");
43+ return (color != null)
44+ ? String.format("#%06x", color.getRGB() & 0xffffff)
45+ : defaultColor;
46+ }
47+
48 @Override
49 public void destroy() {
50 TextContextualPopupMenu.disableMenuFor(this, launcher);
51Index: src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java
52===================================================================
53--- src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java (revision 17046)
54+++ src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java (working copy)
55@@ -56,7 +56,7 @@
56 "bold",
57 f.isItalic() ? "italic" : "normal"
58 ) + '}');
59- ss.addRule("a {text-decoration: underline; color: blue}");
60+ ss.addRule("a {text-decoration: underline; color: "+JosmEditorPane.getLinkColor("blue")+"}");
61 ss.addRule("ul {margin-left: 1cm; list-style-type: disc}");
62 JosmHTMLEditorKit kit = new JosmHTMLEditorKit();
63 kit.setStyleSheet(ss);
64Index: src/org/openstreetmap/josm/gui/GettingStarted.java
65===================================================================
66--- src/org/openstreetmap/josm/gui/GettingStarted.java (revision 17046)
67+++ src/org/openstreetmap/josm/gui/GettingStarted.java (working copy)
68@@ -56,7 +56,7 @@
69 private static final String STYLE = "<style type=\"text/css\">\n"
70 + "body {font-family: sans-serif; font-weight: bold; }\n"
71 + "h1 {text-align: center; }\n"
72- + "a {color: #316ed9; }\n"
73+ + "a {color: "+JosmEditorPane.getLinkColor("#316ed9")+"; }\n"
74 + ".icon {font-size: 0; }\n"
75 + "</style>\n";
76