From ed69049c08d0bb90fab8925fcb06095da3278680 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 13 Feb 2025 19:19:01 +0100 Subject: [PATCH] UIDefaultsDump: dump contrast ratios --- .../dumps/uidefaults/FlatDarculaLaf_1.8.0.txt | 6 + .../dumps/uidefaults/FlatDarkLaf_1.8.0.txt | 120 ++++++++++++++ .../uidefaults/FlatIntelliJLaf_1.8.0.txt | 6 + .../dumps/uidefaults/FlatLightLaf_1.8.0.txt | 120 ++++++++++++++ .../dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt | 121 ++++++++++++++ .../uidefaults/FlatMacLightLaf_1.8.0.txt | 121 ++++++++++++++ .../dumps/uidefaults/FlatTestLaf_1.8.0.txt | 155 ++++++++++++++++++ .../testing/uidefaults/UIDefaultsDump.java | 139 +++++++++++++++- 8 files changed, 783 insertions(+), 5 deletions(-) diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt index cba7171f..88face3c 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt @@ -113,3 +113,9 @@ - ToggleButton.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatButtonBorder [UI] + ToggleButton.border [lazy] 3,3,3,3 false com.formdev.flatlaf.ui.FlatButtonBorder [UI] + + +#---- contrast ratio: ProgressBar ---- + +- contrast ratio: ProgressBar.selectionForeground #bbbbbb #4c87c8 2.0 !!!!! ++ contrast ratio: ProgressBar.selectionForeground #3c3f41 #a2a2a2 4.2 !!! diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt index a8cf1890..c5c7528b 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt @@ -1630,3 +1630,123 @@ textText #bbbbbb HSL 0 0 73 javax.swing.plaf.Colo window #3c3f41 HSL 204 4 25 javax.swing.plaf.ColorUIResource [UI] windowBorder #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] windowText #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] + + +#-------- Contrast Ratios -------- + +# WCAG 2 Contrast Requirements: minimum 4.5; enhanced 7.0 +# https://webaim.org/articles/contrast/#sc143 + + +#-- activeTitleForeground -- +InternalFrame.activeTitleForeground #bbbbbb #242526 8.0 + +#-- disabledForeground -- +ComboBox.disabledForeground #8c8c8c #3c3f41 3.2 !!!! +Label.disabledForeground #8c8c8c #3c3f41 3.2 !!!! +Spinner.disabledForeground #8c8c8c #3c3f41 3.2 !!!! + +#-- disabledText -- +Button.disabledText #8c8c8c #3c3f41 3.2 !!!! +CheckBox.disabledText #8c8c8c #3c3f41 3.2 !!!! +RadioButton.disabledText #8c8c8c #3c3f41 3.2 !!!! +ToggleButton.disabledText #8c8c8c #3c3f41 3.2 !!!! + +#-- dropCellForeground -- +List.dropCellForeground #bbbbbb #3c588b 3.7 !!!! +Table.dropCellForeground #bbbbbb #3c588b 3.7 !!!! +Tree.dropCellForeground #bbbbbb #3c588b 3.7 !!!! + +#-- focusCellForeground -- +Table.focusCellForeground #bbbbbb #46494b 4.7 !!! + +#-- foreground -- +Button.foreground #bbbbbb #4e5052 4.2 !!! +Button.default.foreground #bbbbbb #375a81 3.7 !!!! +CheckBox.foreground #bbbbbb #3c3f41 5.5 !! +CheckBoxMenuItem.foreground #bbbbbb #303234 6.7 ! +ColorChooser.foreground #bbbbbb #3c3f41 5.5 !! +ComboBox.foreground #bbbbbb #46494b 4.7 !!! +DesktopIcon.foreground #bbbbbb #555c68 3.5 !!!! +EditorPane.foreground #bbbbbb #46494b 4.7 !!! +FormattedTextField.foreground #bbbbbb #46494b 4.7 !!! +JideButton.foreground #bbbbbb #4e5052 4.2 !!! +JideLabel.foreground #bbbbbb #3c3f41 5.5 !! +JideSplitButton.foreground #bbbbbb #4e5052 4.2 !!! +JideTabbedPane.foreground #bbbbbb #3c3f41 5.5 !! +Label.foreground #bbbbbb #3c3f41 5.5 !! +List.foreground #bbbbbb #46494b 4.7 !!! +Menu.foreground #bbbbbb #303234 6.7 ! +MenuBar.foreground #bbbbbb #303234 6.7 ! +MenuItem.foreground #bbbbbb #303234 6.7 ! +OptionPane.foreground #bbbbbb #3c3f41 5.5 !! +Panel.foreground #bbbbbb #3c3f41 5.5 !! +PasswordField.foreground #bbbbbb #46494b 4.7 !!! +PopupMenu.foreground #bbbbbb #303234 6.7 ! +RadioButton.foreground #bbbbbb #3c3f41 5.5 !! +RadioButtonMenuItem.foreground #bbbbbb #303234 6.7 ! +RootPane.foreground #bbbbbb #3c3f41 5.5 !! +Spinner.foreground #bbbbbb #46494b 4.7 !!! +TabbedPane.foreground #bbbbbb #3c3f41 5.5 !! +Table.foreground #bbbbbb #46494b 4.7 !!! +TableHeader.foreground #bbbbbb #46494b 4.7 !!! +TextArea.foreground #bbbbbb #46494b 4.7 !!! +TextField.foreground #bbbbbb #46494b 4.7 !!! +TextPane.foreground #bbbbbb #46494b 4.7 !!! +TitlePane.foreground #bbbbbb #303234 6.7 ! +ToggleButton.foreground #bbbbbb #4e5052 4.2 !!! +ToolTip.foreground #bbbbbb #1e2021 8.5 +Tree.foreground #bbbbbb #46494b 4.7 !!! + +#-- inactiveForeground -- +EditorPane.inactiveForeground #8c8c8c #3c3f41 3.2 !!!! +FormattedTextField.inactiveForeground #8c8c8c #3c3f41 3.2 !!!! +PasswordField.inactiveForeground #8c8c8c #3c3f41 3.2 !!!! +TextArea.inactiveForeground #8c8c8c #3c3f41 3.2 !!!! +TextField.inactiveForeground #8c8c8c #3c3f41 3.2 !!!! +TextPane.inactiveForeground #8c8c8c #3c3f41 3.2 !!!! +TitlePane.inactiveForeground #8c8c8c #303234 3.8 !!!! + +#-- inactiveTitleForeground -- +InternalFrame.inactiveTitleForeground #8c8c8c #303233 3.8 !!!! + +#-- monthStringForeground -- +JXMonthView.monthStringForeground #bbbbbb #4c5052 4.2 !!! + +#-- selectedForeground -- +Button.selectedForeground #bbbbbb #676a6c 2.8 !!!!! +ToggleButton.selectedForeground #bbbbbb #676a6c 2.8 !!!!! + +#-- selectionBackground -- +ProgressBar.selectionBackground #bbbbbb #505456 4.0 !!! + +#-- selectionForeground -- +CheckBoxMenuItem.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +ComboBox.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +EditorPane.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +FormattedTextField.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +List.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +Menu.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +MenuItem.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +PasswordField.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +ProgressBar.selectionForeground #bbbbbb #4c87c8 2.0 !!!!! +RadioButtonMenuItem.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +Table.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +TextArea.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +TextField.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +TextPane.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! +Tree.selectionForeground #bbbbbb #4b6eaf 2.6 !!!!! + +#-- selectionInactiveForeground -- +List.selectionInactiveForeground #bbbbbb #0f2a3d 7.7 +Table.selectionInactiveForeground #bbbbbb #0f2a3d 7.7 +Tree.selectionInactiveForeground #bbbbbb #0f2a3d 7.7 + +#-- specialTitleForeground -- +TaskPane.specialTitleForeground #222222 #afafaf 7.3 + +#-- textForeground -- +Tree.textForeground #bbbbbb #46494b 4.7 !!! + +#-- titleForeground -- +JXTitledPanel.titleForeground #bbbbbb #4c5052 4.2 !!! diff --git a/flatlaf-testing/dumps/uidefaults/FlatIntelliJLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatIntelliJLaf_1.8.0.txt index 7b2d2fd2..4f3f4d0b 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatIntelliJLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatIntelliJLaf_1.8.0.txt @@ -133,3 +133,9 @@ - ToggleButton.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatButtonBorder [UI] + ToggleButton.border [lazy] 3,3,3,3 false com.formdev.flatlaf.ui.FlatButtonBorder [UI] + + +#---- contrast ratio: Button ---- + +- contrast ratio: Button.default.foreground #000000 #ffffff 21.0 ++ contrast ratio: Button.default.foreground #ffffff #478ac9 3.7 !!!! diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt index e366fe1d..90cda52f 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt @@ -1635,3 +1635,123 @@ textText #000000 HSL 0 0 0 javax.swing.plaf.Colo window #f2f2f2 HSL 0 0 95 javax.swing.plaf.ColorUIResource [UI] windowBorder #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] windowText #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] + + +#-------- Contrast Ratios -------- + +# WCAG 2 Contrast Requirements: minimum 4.5; enhanced 7.0 +# https://webaim.org/articles/contrast/#sc143 + + +#-- activeTitleForeground -- +InternalFrame.activeTitleForeground #000000 #ffffff 21.0 + +#-- disabledForeground -- +ComboBox.disabledForeground #8c8c8c #f2f2f2 3.0 !!!! +Label.disabledForeground #8c8c8c #f2f2f2 3.0 !!!! +Spinner.disabledForeground #8c8c8c #f2f2f2 3.0 !!!! + +#-- disabledText -- +Button.disabledText #8c8c8c #f2f2f2 3.0 !!!! +CheckBox.disabledText #8c8c8c #f2f2f2 3.0 !!!! +RadioButton.disabledText #8c8c8c #f2f2f2 3.0 !!!! +ToggleButton.disabledText #8c8c8c #f2f2f2 3.0 !!!! + +#-- dropCellForeground -- +List.dropCellForeground #ffffff #3f8fd9 3.4 !!!! +Table.dropCellForeground #ffffff #3f8fd9 3.4 !!!! +Tree.dropCellForeground #ffffff #3f8fd9 3.4 !!!! + +#-- focusCellForeground -- +Table.focusCellForeground #000000 #ffffff 21.0 + +#-- foreground -- +Button.foreground #000000 #ffffff 21.0 +Button.default.foreground #000000 #ffffff 21.0 +CheckBox.foreground #000000 #f2f2f2 18.8 +CheckBoxMenuItem.foreground #000000 #ffffff 21.0 +ColorChooser.foreground #000000 #f2f2f2 18.8 +ComboBox.foreground #000000 #ffffff 21.0 +DesktopIcon.foreground #000000 #c6d2dd 13.7 +EditorPane.foreground #000000 #ffffff 21.0 +FormattedTextField.foreground #000000 #ffffff 21.0 +JideButton.foreground #000000 #ffffff 21.0 +JideLabel.foreground #000000 #f2f2f2 18.8 +JideSplitButton.foreground #000000 #ffffff 21.0 +JideTabbedPane.foreground #000000 #f2f2f2 18.8 +Label.foreground #000000 #f2f2f2 18.8 +List.foreground #000000 #ffffff 21.0 +Menu.foreground #000000 #ffffff 21.0 +MenuBar.foreground #000000 #ffffff 21.0 +MenuItem.foreground #000000 #ffffff 21.0 +OptionPane.foreground #000000 #f2f2f2 18.8 +Panel.foreground #000000 #f2f2f2 18.8 +PasswordField.foreground #000000 #ffffff 21.0 +PopupMenu.foreground #000000 #ffffff 21.0 +RadioButton.foreground #000000 #f2f2f2 18.8 +RadioButtonMenuItem.foreground #000000 #ffffff 21.0 +RootPane.foreground #000000 #f2f2f2 18.8 +Spinner.foreground #000000 #ffffff 21.0 +TabbedPane.foreground #000000 #f2f2f2 18.8 +Table.foreground #000000 #ffffff 21.0 +TableHeader.foreground #000000 #ffffff 21.0 +TextArea.foreground #000000 #ffffff 21.0 +TextField.foreground #000000 #ffffff 21.0 +TextPane.foreground #000000 #ffffff 21.0 +TitlePane.foreground #000000 #ffffff 21.0 +ToggleButton.foreground #000000 #ffffff 21.0 +ToolTip.foreground #000000 #fafafa 20.1 +Tree.foreground #000000 #ffffff 21.0 + +#-- inactiveForeground -- +EditorPane.inactiveForeground #8c8c8c #f2f2f2 3.0 !!!! +FormattedTextField.inactiveForeground #8c8c8c #f2f2f2 3.0 !!!! +PasswordField.inactiveForeground #8c8c8c #f2f2f2 3.0 !!!! +TextArea.inactiveForeground #8c8c8c #f2f2f2 3.0 !!!! +TextField.inactiveForeground #8c8c8c #f2f2f2 3.0 !!!! +TextPane.inactiveForeground #8c8c8c #f2f2f2 3.0 !!!! +TitlePane.inactiveForeground #8c8c8c #ffffff 3.4 !!!! + +#-- inactiveTitleForeground -- +InternalFrame.inactiveTitleForeground #8c8c8c #fafafa 3.2 !!!! + +#-- monthStringForeground -- +JXMonthView.monthStringForeground #000000 #dfdfdf 15.8 + +#-- selectedForeground -- +Button.selectedForeground #000000 #cccccc 13.1 +ToggleButton.selectedForeground #000000 #cccccc 13.1 + +#-- selectionBackground -- +ProgressBar.selectionBackground #000000 #d1d1d1 13.8 + +#-- selectionForeground -- +CheckBoxMenuItem.selectionForeground #ffffff #2675bf 4.8 !!! +ComboBox.selectionForeground #ffffff #2675bf 4.8 !!! +EditorPane.selectionForeground #ffffff #2675bf 4.8 !!! +FormattedTextField.selectionForeground #ffffff #2675bf 4.8 !!! +List.selectionForeground #ffffff #2675bf 4.8 !!! +Menu.selectionForeground #ffffff #2675bf 4.8 !!! +MenuItem.selectionForeground #ffffff #2675bf 4.8 !!! +PasswordField.selectionForeground #ffffff #2675bf 4.8 !!! +ProgressBar.selectionForeground #ffffff #2285e1 3.8 !!!! +RadioButtonMenuItem.selectionForeground #ffffff #2675bf 4.8 !!! +Table.selectionForeground #ffffff #2675bf 4.8 !!! +TextArea.selectionForeground #ffffff #2675bf 4.8 !!! +TextField.selectionForeground #ffffff #2675bf 4.8 !!! +TextPane.selectionForeground #ffffff #2675bf 4.8 !!! +Tree.selectionForeground #ffffff #2675bf 4.8 !!! + +#-- selectionInactiveForeground -- +List.selectionInactiveForeground #000000 #d3d3d3 14.0 +Table.selectionInactiveForeground #000000 #d3d3d3 14.0 +Tree.selectionInactiveForeground #000000 #d3d3d3 14.0 + +#-- specialTitleForeground -- +TaskPane.specialTitleForeground #222222 #afafaf 7.3 + +#-- textForeground -- +Tree.textForeground #000000 #ffffff 21.0 + +#-- titleForeground -- +JXTitledPanel.titleForeground #222222 #dfdfdf 11.9 diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt index af6ef1bf..fdd8ff3f 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt @@ -1640,3 +1640,124 @@ textText #dddddd HSL 0 0 87 javax.swing.plaf.Colo window #1e1e1e HSL 0 0 12 javax.swing.plaf.ColorUIResource [UI] windowBorder #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI] windowText #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI] + + +#-------- Contrast Ratios -------- + +# WCAG 2 Contrast Requirements: minimum 4.5; enhanced 7.0 +# https://webaim.org/articles/contrast/#sc143 + + +#-- activeTitleForeground -- +InternalFrame.activeTitleForeground #dddddd #040404 15.1 + +#-- disabledForeground -- +ComboBox.disabledForeground #9a9a9a #232323 5.6 !! +Label.disabledForeground #9a9a9a #1e1e1e 5.9 !! +Spinner.disabledForeground #9a9a9a #232323 5.6 !! + +#-- disabledText -- +Button.disabledText #9a9a9a #3d3d3d 3.9 !!!! +CheckBox.disabledText #9a9a9a #1e1e1e 5.9 !! +RadioButton.disabledText #9a9a9a #1e1e1e 5.9 !! +ToggleButton.disabledText #9a9a9a #3d3d3d 3.9 !!!! + +#-- dropCellForeground -- +List.dropCellForeground #ffffff #003f99 9.7 +Table.dropCellForeground #ffffff #003f99 9.7 +Tree.dropCellForeground #ffffff #003f99 9.7 + +#-- focusCellForeground -- +Table.focusCellForeground #dddddd #282828 10.9 + +#-- foreground -- +Button.foreground #dddddd #565656 5.4 !! +Button.default.foreground #dddddd #007aff 3.0 !!!! +CheckBox.foreground #dddddd #1e1e1e 12.3 +CheckBoxMenuItem.foreground #dddddd #323232 9.4 +ColorChooser.foreground #dddddd #1e1e1e 12.3 +ComboBox.foreground #dddddd #565656 5.4 !! +DesktopIcon.foreground #dddddd #555c68 5.0 !! +EditorPane.foreground #dddddd #282828 10.9 +FormattedTextField.foreground #dddddd #282828 10.9 +JideButton.foreground #dddddd #565656 5.4 !! +JideLabel.foreground #dddddd #1e1e1e 12.3 +JideSplitButton.foreground #dddddd #565656 5.4 !! +JideTabbedPane.foreground #dddddd #1e1e1e 12.3 +Label.foreground #dddddd #1e1e1e 12.3 +List.foreground #dddddd #282828 10.9 +Menu.foreground #dddddd #323232 9.4 +MenuBar.foreground #dddddd #323232 9.4 +MenuItem.foreground #dddddd #323232 9.4 +OptionPane.foreground #dddddd #1e1e1e 12.3 +Panel.foreground #dddddd #1e1e1e 12.3 +PasswordField.foreground #dddddd #282828 10.9 +PopupMenu.foreground #dddddd #323232 9.4 +RadioButton.foreground #dddddd #1e1e1e 12.3 +RadioButtonMenuItem.foreground #dddddd #323232 9.4 +RootPane.foreground #dddddd #1e1e1e 12.3 +Spinner.foreground #dddddd #282828 10.9 +TabbedPane.foreground #dddddd #1e1e1e 12.3 +Table.foreground #dddddd #282828 10.9 +TableHeader.foreground #dddddd #282828 10.9 +TextArea.foreground #dddddd #282828 10.9 +TextField.foreground #dddddd #282828 10.9 +TextPane.foreground #dddddd #282828 10.9 +TitlePane.foreground #dddddd #323232 9.4 +ToggleButton.foreground #dddddd #565656 5.4 !! +ToolTip.foreground #dddddd #0f0f0f 14.1 +Tree.foreground #dddddd #282828 10.9 + +#-- inactiveForeground -- +EditorPane.inactiveForeground #9a9a9a #232323 5.6 !! +FormattedTextField.inactiveForeground #9a9a9a #232323 5.6 !! +PasswordField.inactiveForeground #9a9a9a #232323 5.6 !! +TextArea.inactiveForeground #9a9a9a #232323 5.6 !! +TextField.inactiveForeground #9a9a9a #232323 5.6 !! +TextPane.inactiveForeground #9a9a9a #232323 5.6 !! +TitlePane.inactiveForeground #9a9a9a #323232 4.6 !!! + +#-- inactiveTitleForeground -- +InternalFrame.inactiveTitleForeground #9a9a9a #111111 6.7 ! + +#-- monthStringForeground -- +JXMonthView.monthStringForeground #dddddd #4c5052 6.0 ! + +#-- selectedForeground -- +Button.selectedForeground #dddddd #707070 3.6 !!!! +ToggleButton.selectedForeground #dddddd #898989 2.6 !!!!! + +#-- selectionBackground -- +ProgressBar.selectionBackground #dddddd #323232 9.4 + +#-- selectionForeground -- +CheckBoxMenuItem.selectionForeground #ffffff #1458b8 6.7 ! +ComboBox.selectionForeground #ffffff #1458b8 6.7 ! +EditorPane.selectionForeground #ffffff #3d6490 6.1 ! +FormattedTextField.selectionForeground #ffffff #3d6490 6.1 ! +List.selectionForeground #ffffff #0054cc 6.7 ! +Menu.selectionForeground #ffffff #1458b8 6.7 ! +MenuBar.selectionForeground #dddddd #585858 5.2 !! +MenuItem.selectionForeground #ffffff #1458b8 6.7 ! +PasswordField.selectionForeground #ffffff #3d6490 6.1 ! +ProgressBar.selectionForeground #dddddd #007aff 3.0 !!!! +RadioButtonMenuItem.selectionForeground #ffffff #1458b8 6.7 ! +Table.selectionForeground #ffffff #0054cc 6.7 ! +TextArea.selectionForeground #ffffff #3d6490 6.1 ! +TextField.selectionForeground #ffffff #3d6490 6.1 ! +TextPane.selectionForeground #ffffff #3d6490 6.1 ! +Tree.selectionForeground #ffffff #0054cc 6.7 ! + +#-- selectionInactiveForeground -- +List.selectionInactiveForeground #dddddd #464646 6.9 ! +Table.selectionInactiveForeground #dddddd #464646 6.9 ! +Tree.selectionInactiveForeground #dddddd #464646 6.9 ! + +#-- specialTitleForeground -- +TaskPane.specialTitleForeground #222222 #afafaf 7.3 + +#-- textForeground -- +Tree.textForeground #dddddd #282828 10.9 + +#-- titleForeground -- +JXTitledPanel.titleForeground #dddddd #4c5052 6.0 ! diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt index 6f03f111..51fa1dad 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt @@ -1644,3 +1644,124 @@ textText #262626 HSL 0 0 15 javax.swing.plaf.Colo window #f6f6f6 HSL 0 0 96 javax.swing.plaf.ColorUIResource [UI] windowBorder #262626 HSL 0 0 15 javax.swing.plaf.ColorUIResource [UI] windowText #262626 HSL 0 0 15 javax.swing.plaf.ColorUIResource [UI] + + +#-------- Contrast Ratios -------- + +# WCAG 2 Contrast Requirements: minimum 4.5; enhanced 7.0 +# https://webaim.org/articles/contrast/#sc143 + + +#-- activeTitleForeground -- +InternalFrame.activeTitleForeground #262626 #ffffff 15.1 + +#-- disabledForeground -- +ComboBox.disabledForeground #b6b6b6 #fafafa 1.9 !!!!!! +Label.disabledForeground #b6b6b6 #f6f6f6 1.9 !!!!!! +Spinner.disabledForeground #b6b6b6 #fafafa 1.9 !!!!!! + +#-- disabledText -- +Button.disabledText #b6b6b6 #fafafa 1.9 !!!!!! +CheckBox.disabledText #b6b6b6 #f6f6f6 1.9 !!!!!! +RadioButton.disabledText #b6b6b6 #f6f6f6 1.9 !!!!!! +ToggleButton.disabledText #b6b6b6 #fafafa 1.9 !!!!!! + +#-- dropCellForeground -- +List.dropCellForeground #ffffff #1a79ff 4.0 !!! +Table.dropCellForeground #ffffff #1a79ff 4.0 !!! +Tree.dropCellForeground #ffffff #1a79ff 4.0 !!! + +#-- focusCellForeground -- +Table.focusCellForeground #262626 #ffffff 15.1 + +#-- foreground -- +Button.foreground #262626 #ffffff 15.1 +Button.default.foreground #f6f6f6 #007aff 3.7 !!!! +CheckBox.foreground #262626 #f6f6f6 14.0 +CheckBoxMenuItem.foreground #262626 #ececec 12.8 +ColorChooser.foreground #262626 #f6f6f6 14.0 +ComboBox.foreground #262626 #ffffff 15.1 +DesktopIcon.foreground #262626 #c6d2dd 9.8 +EditorPane.foreground #262626 #ffffff 15.1 +FormattedTextField.foreground #262626 #ffffff 15.1 +JideButton.foreground #262626 #ffffff 15.1 +JideLabel.foreground #262626 #f6f6f6 14.0 +JideSplitButton.foreground #262626 #ffffff 15.1 +JideTabbedPane.foreground #262626 #f6f6f6 14.0 +Label.foreground #262626 #f6f6f6 14.0 +List.foreground #262626 #ffffff 15.1 +Menu.foreground #262626 #ececec 12.8 +MenuBar.foreground #262626 #ececec 12.8 +MenuItem.foreground #262626 #ececec 12.8 +OptionPane.foreground #262626 #f6f6f6 14.0 +Panel.foreground #262626 #f6f6f6 14.0 +PasswordField.foreground #262626 #ffffff 15.1 +PopupMenu.foreground #262626 #ececec 12.8 +RadioButton.foreground #262626 #f6f6f6 14.0 +RadioButtonMenuItem.foreground #262626 #ececec 12.8 +RootPane.foreground #262626 #f6f6f6 14.0 +Spinner.foreground #262626 #ffffff 15.1 +TabbedPane.foreground #262626 #f6f6f6 14.0 +Table.foreground #262626 #ffffff 15.1 +TableHeader.foreground #262626 #ffffff 15.1 +TextArea.foreground #262626 #ffffff 15.1 +TextField.foreground #262626 #ffffff 15.1 +TextPane.foreground #262626 #ffffff 15.1 +TitlePane.foreground #262626 #ececec 12.8 +ToggleButton.foreground #262626 #ffffff 15.1 +ToolTip.foreground #262626 #fefefe 15.0 +Tree.foreground #262626 #ffffff 15.1 + +#-- inactiveForeground -- +EditorPane.inactiveForeground #b6b6b6 #fafafa 1.9 !!!!!! +FormattedTextField.inactiveForeground #b6b6b6 #fafafa 1.9 !!!!!! +PasswordField.inactiveForeground #b6b6b6 #fafafa 1.9 !!!!!! +TextArea.inactiveForeground #b6b6b6 #fafafa 1.9 !!!!!! +TextField.inactiveForeground #b6b6b6 #fafafa 1.9 !!!!!! +TextPane.inactiveForeground #b6b6b6 #fafafa 1.9 !!!!!! +TitlePane.inactiveForeground #b6b6b6 #ececec 1.7 !!!!!! + +#-- inactiveTitleForeground -- +InternalFrame.inactiveTitleForeground #b6b6b6 #fafafa 1.9 !!!!!! + +#-- monthStringForeground -- +JXMonthView.monthStringForeground #262626 #dfdfdf 11.4 + +#-- selectedForeground -- +Button.selectedForeground #262626 #cccccc 9.4 +ToggleButton.selectedForeground #262626 #cccccc 9.4 + +#-- selectionBackground -- +ProgressBar.selectionBackground #262626 #e9e9e9 12.5 + +#-- selectionForeground -- +CheckBoxMenuItem.selectionForeground #ffffff #3d9aff 2.9 !!!!! +ComboBox.selectionForeground #ffffff #3d9aff 2.9 !!!!! +EditorPane.selectionForeground #262626 #b3d7ff 10.1 +FormattedTextField.selectionForeground #262626 #b3d7ff 10.1 +List.selectionForeground #ffffff #005fe6 5.6 !! +Menu.selectionForeground #ffffff #3d9aff 2.9 !!!!! +MenuBar.selectionForeground #262626 #c6c6c6 8.9 +MenuItem.selectionForeground #ffffff #3d9aff 2.9 !!!!! +PasswordField.selectionForeground #262626 #b3d7ff 10.1 +ProgressBar.selectionForeground #ffffff #007aff 4.0 !!! +RadioButtonMenuItem.selectionForeground #ffffff #3d9aff 2.9 !!!!! +Table.selectionForeground #ffffff #005fe6 5.6 !! +TextArea.selectionForeground #262626 #b3d7ff 10.1 +TextField.selectionForeground #262626 #b3d7ff 10.1 +TextPane.selectionForeground #262626 #b3d7ff 10.1 +Tree.selectionForeground #ffffff #005fe6 5.6 !! + +#-- selectionInactiveForeground -- +List.selectionInactiveForeground #262626 #dcdcdc 11.0 +Table.selectionInactiveForeground #262626 #dcdcdc 11.0 +Tree.selectionInactiveForeground #262626 #dcdcdc 11.0 + +#-- specialTitleForeground -- +TaskPane.specialTitleForeground #222222 #afafaf 7.3 + +#-- textForeground -- +Tree.textForeground #262626 #ffffff 15.1 + +#-- titleForeground -- +JXTitledPanel.titleForeground #222222 #dfdfdf 11.9 diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt index 74a70884..82b7c47e 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt @@ -1689,3 +1689,158 @@ textText #ff0000 HSL 0 100 50 javax.swing.plaf.Colo window #ccffcc HSL 120 100 90 javax.swing.plaf.ColorUIResource [UI] windowBorder #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI] windowText #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI] + + +#-------- Contrast Ratios -------- + +# WCAG 2 Contrast Requirements: minimum 4.5; enhanced 7.0 +# https://webaim.org/articles/contrast/#sc143 + + +#-- activeTitleForeground -- +InternalFrame.activeTitleForeground #ffaaaa #880000 5.7 !! + +#-- disabledForeground -- +ComboBox.disabledForeground #000088 #e0e0e0 11.7 +Label.disabledForeground #000088 #ccffcc 13.8 +Spinner.disabledForeground #000088 #e0e0e0 11.7 + +#-- disabledSelectedForeground -- +Button.disabledSelectedForeground #ffcccc #112233 11.4 +Button.toolbar.disabledSelectedForeground #886666 #cccccc 3.2 !!!! +ToggleButton.disabledSelectedForeground #ffffff #44dd44 1.8 !!!!!! +ToggleButton.toolbar.disabledSelectedForeground #886666 #cccccc 3.2 !!!! + +#-- disabledText -- +Button.disabledText #000088 #e0e0e0 11.7 +CheckBox.disabledText #000088 #ccffcc 13.8 +RadioButton.disabledText #000088 #ccffcc 13.8 +ToggleButton.disabledText #000088 #e0e0e0 11.7 + +#-- dropCellForeground -- +List.dropCellForeground #00ff00 #ff0000 2.9 !!!!! +Table.dropCellForeground #00ff00 #ff0000 2.9 !!!!! +Tree.dropCellForeground #00ff00 #ff0000 2.9 !!!!! + +#-- focusCellForeground -- +Table.focusCellForeground #ff0000 #fffff0 4.0 !!! + +#-- focusForeground -- +ToggleButton.tab.focusForeground #008800 #dddddd 3.4 !!!! + +#-- focusedForeground -- +Button.focusedForeground #0000ff #00ffff 6.9 ! +Button.default.focusedForeground #0000ff #00ffff 6.9 ! +ToggleButton.focusedForeground #0000ff #00ffff 6.9 ! + +#-- foreground -- +Button.foreground #ff0000 #ccffcc 3.6 !!!! +CheckBox.foreground #ff0000 #ccffcc 3.6 !!!! +CheckBoxMenuItem.foreground #ff0000 #ffffff 4.0 !!! +ColorChooser.foreground #ff0000 #ccffcc 3.6 !!!! +ComboBox.foreground #ff0000 #ffffff 4.0 !!! +DesktopIcon.foreground #ff0000 #44ffda 3.2 !!!! +EditorPane.foreground #ff0000 #ffffff 4.0 !!! +FormattedTextField.foreground #ff0000 #ffffff 4.0 !!! +JideButton.foreground #ff0000 #ccffcc 3.6 !!!! +JideLabel.foreground #008800 #ccffcc 4.1 !!! +JideSplitButton.foreground #ff0000 #ccffcc 3.6 !!!! +JideTabbedPane.foreground #ff0000 #ccffcc 3.6 !!!! +Label.foreground #008800 #ccffcc 4.1 !!! +List.foreground #ff0000 #f0ffff 3.9 !!!! +Menu.foreground #ff0000 #ffffff 4.0 !!! +MenuBar.foreground #ff0000 #ffffff 4.0 !!! +MenuItem.foreground #ff0000 #ffffff 4.0 !!! +OptionPane.foreground #ff0000 #ffdddd 3.2 !!!! +Panel.foreground #ff0000 #ccffcc 3.6 !!!! +PasswordField.foreground #ff0000 #ffffff 4.0 !!! +PopupMenu.foreground #ff0000 #ffffff 4.0 !!! +RadioButton.foreground #ff0000 #ccffcc 3.6 !!!! +RadioButtonMenuItem.foreground #ff0000 #ffffff 4.0 !!! +RootPane.foreground #ff0000 #ccffcc 3.6 !!!! +Spinner.foreground #ff0000 #ffffff 4.0 !!! +TabbedPane.foreground #ff0000 #ccffcc 3.6 !!!! +Table.foreground #ff0000 #fffff0 4.0 !!! +TableHeader.foreground #ffffff #4444ff 6.0 ! +TextArea.foreground #ff0000 #ffffff 4.0 !!! +TextField.foreground #ff0000 #ffffff 4.0 !!! +TextPane.foreground #ff0000 #ffffff 4.0 !!! +TitlePane.foreground #0000ff #00ff00 6.3 ! +ToggleButton.foreground #ff0000 #ddddff 3.0 !!!! +ToolTip.foreground #ff0000 #eeeeff 3.5 !!!! +Tree.foreground #ff0000 #fff0ff 3.6 !!!! + +#-- hoverForeground -- +Button.hoverForeground #0000ff #ffff00 8.0 +Button.default.hoverForeground #0000ff #ffff00 8.0 +Button.toolbar.hoverForeground #000000 #ffffff 21.0 +TableHeader.hoverForeground #e6e6e6 #1111ff 6.6 ! +ToggleButton.hoverForeground #0000ff #ffff00 8.0 +ToggleButton.tab.hoverForeground #0000ff #eeeeee 7.4 +ToggleButton.toolbar.hoverForeground #000000 #ffffff 21.0 + +#-- inactiveForeground -- +EditorPane.inactiveForeground #000088 #e0e0e0 11.7 +FormattedTextField.inactiveForeground #000088 #e0e0e0 11.7 +PasswordField.inactiveForeground #000088 #e0e0e0 11.7 +TextArea.inactiveForeground #000088 #e0e0e0 11.7 +TextField.inactiveForeground #000088 #e0e0e0 11.7 +TextPane.inactiveForeground #000088 #e0e0e0 11.7 +TitlePane.inactiveForeground #ffffff #008800 4.6 !!! + +#-- inactiveTitleForeground -- +InternalFrame.inactiveTitleForeground #aaffaa #008800 3.9 !!!! + +#-- monthStringForeground -- +JXMonthView.monthStringForeground #0000ff #00ff00 6.3 ! + +#-- pressedForeground -- +Button.pressedForeground #0080ff #ffc800 2.4 !!!!! +Button.default.pressedForeground #0080ff #ffc800 2.4 !!!!! +Button.toolbar.pressedForeground #666666 #eeeeee 4.9 !!! +TableHeader.pressedForeground #cccccc #0000dd 6.4 ! +ToggleButton.pressedForeground #0080ff #ffc800 2.4 !!!!! +ToggleButton.toolbar.pressedForeground #666666 #eeeeee 4.9 !!! + +#-- selectedForeground -- +Button.selectedForeground #332211 #ffbbbb 9.5 +Button.toolbar.selectedForeground #880000 #dddddd 7.6 +TabbedPane.selectedForeground #0000ff #00ff00 6.3 ! +ToggleButton.selectedForeground #000000 #44ff44 15.6 +ToggleButton.tab.selectedForeground #ffffff #008800 4.6 !!! +ToggleButton.toolbar.selectedForeground #880000 #dddddd 7.6 + +#-- selectionBackground -- +ProgressBar.selectionBackground #000088 #88ff88 12.3 + +#-- selectionForeground -- +CheckBoxMenuItem.selectionForeground #ffff00 #00aa00 2.9 !!!!! +ComboBox.selectionForeground #ffff00 #00aa00 2.9 !!!!! +EditorPane.selectionForeground #ffff00 #00aa00 2.9 !!!!! +FormattedTextField.selectionForeground #ffff00 #00aa00 2.9 !!!!! +List.selectionForeground #ffff00 #00aa00 2.9 !!!!! +Menu.selectionForeground #ffff00 #00aa00 2.9 !!!!! +MenuBar.selectionForeground #00ff00 #ff0000 2.9 !!!!! +MenuItem.selectionForeground #ffff00 #00aa00 2.9 !!!!! +PasswordField.selectionForeground #ffff00 #00aa00 2.9 !!!!! +ProgressBar.selectionForeground #ff0000 #737373 1.2 !!!!!! +RadioButtonMenuItem.selectionForeground #ffff00 #00aa00 2.9 !!!!! +Table.selectionForeground #ffff00 #00aa00 2.9 !!!!! +TextArea.selectionForeground #ffff00 #00aa00 2.9 !!!!! +TextField.selectionForeground #ffff00 #00aa00 2.9 !!!!! +TextPane.selectionForeground #ffff00 #00aa00 2.9 !!!!! +Tree.selectionForeground #ffff00 #00aa00 2.9 !!!!! + +#-- selectionInactiveForeground -- +List.selectionInactiveForeground #ffffff #888888 3.5 !!!! +Table.selectionInactiveForeground #ffffff #888888 3.5 !!!! +Tree.selectionInactiveForeground #ffffff #888888 3.5 !!!! + +#-- specialTitleForeground -- +TaskPane.specialTitleForeground #444444 #00ffff 7.8 + +#-- textForeground -- +Tree.textForeground #ff0000 #fff0ff 3.6 !!!! + +#-- titleForeground -- +JXTitledPanel.titleForeground #ff00ff #ffff00 2.9 !!!!! diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java index fd30dffd..b0ac8641 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java @@ -38,6 +38,7 @@ import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; @@ -45,6 +46,7 @@ import java.util.Map; import java.util.Objects; import java.util.Properties; import java.util.TreeSet; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Predicate; import javax.swing.*; import javax.swing.UIDefaults.ActiveValue; @@ -63,6 +65,7 @@ import com.formdev.flatlaf.testing.FlatTestLaf; import com.formdev.flatlaf.themes.*; import com.formdev.flatlaf.ui.FlatLineBorder; import com.formdev.flatlaf.ui.FlatUIUtils; +import com.formdev.flatlaf.util.ColorFunctions; import com.formdev.flatlaf.util.ColorFunctions.ColorFunction; import com.jidesoft.plaf.LookAndFeelFactory; import com.formdev.flatlaf.util.DerivedColor; @@ -181,20 +184,20 @@ public class UIDefaultsDump // the lazy color InternalFrame.closeHoverBackground is resolved) defaults = (UIDefaults) defaults.clone(); - dump( dir, "", lookAndFeel, defaults, key -> !key.contains( "InputMap" ) ); + dump( dir, "", lookAndFeel, defaults, key -> !key.contains( "InputMap" ), true ); if( lookAndFeel.getClass() == FlatLightLaf.class || !(lookAndFeel instanceof FlatLaf) ) { - dump( dir, "_InputMap", lookAndFeel, defaults, key -> key.contains( "InputMap" ) ); + dump( dir, "_InputMap", lookAndFeel, defaults, key -> key.contains( "InputMap" ), false ); dumpActionMaps( dir, "_ActionMap", lookAndFeel, defaults ); } } private static void dump( File dir, String nameSuffix, - LookAndFeel lookAndFeel, UIDefaults defaults, Predicate keyFilter ) + LookAndFeel lookAndFeel, UIDefaults defaults, Predicate keyFilter, boolean contrastRatios ) { // dump to string StringWriter stringWriter = new StringWriter( 100000 ); - new UIDefaultsDump( lookAndFeel, defaults ).dump( new PrintWriter( stringWriter ), keyFilter ); + new UIDefaultsDump( lookAndFeel, defaults ).dump( new PrintWriter( stringWriter ), keyFilter, contrastRatios ); String name = lookAndFeel instanceof MyBasicLookAndFeel ? BasicLookAndFeel.class.getSimpleName() @@ -354,12 +357,15 @@ public class UIDefaultsDump Map defaults = new LinkedHashMap<>(); try( BufferedReader reader = new BufferedReader( in ) ) { String lastKey = null; + boolean inContrastRatios = false; String line; while( (line = reader.readLine()) != null ) { String trimmedLine = line.trim(); if( trimmedLine.isEmpty() || trimmedLine.startsWith( "#" ) ) { lastKey = null; + if( trimmedLine.contains( "#-------- Contrast Ratios --------" ) ) + inContrastRatios = true; continue; } @@ -374,6 +380,8 @@ public class UIDefaultsDump String key = line.substring( 0, sep ); String value = line.substring( sep ); + if( inContrastRatios ) + key = "contrast ratio: " + key; defaults.put( key, value ); lastKey = key; @@ -403,7 +411,7 @@ public class UIDefaultsDump out.printf( "OS %s%n", System.getProperty( "os.name" ) ); } - private void dump( PrintWriter out, Predicate keyFilter ) { + private void dump( PrintWriter out, Predicate keyFilter, boolean contrastRatios ) { dumpHeader( out ); defaults.entrySet().stream() @@ -428,6 +436,9 @@ public class UIDefaultsDump dumpValue( out, strKey, value ); out.println(); } ); + + if( contrastRatios ) + dumpContrastRatios( out ); } private void dumpActionMaps( PrintWriter out ) { @@ -829,6 +840,124 @@ public class UIDefaultsDump return new Color( newColor.getRGB(), true ); } + private void dumpContrastRatios( PrintWriter out ) { + out.printf( "%n%n#-------- Contrast Ratios --------%n%n" ); + out.println( "# WCAG 2 Contrast Requirements: minimum 4.5; enhanced 7.0" ); + out.println( "# https://webaim.org/articles/contrast/#sc143" ); + out.println(); + + HashMap fg2bgMap = new HashMap<>(); + defaults.keySet().stream() + .filter( key -> key instanceof String && ((String)key).endsWith( "ackground" ) ) + .map( key -> (String) key ) + .forEach( bgKey -> { + String fgKey = bgKey.replace( "Background", "Foreground" ).replace( "background", "foreground" ); + fg2bgMap.put( fgKey, bgKey ); + } ); + + // special cases + fg2bgMap.remove( "Button.disabledForeground" ); + fg2bgMap.put( "Button.disabledText", "Button.disabledBackground" ); + fg2bgMap.remove( "ToggleButton.disabledForeground" ); + fg2bgMap.put( "ToggleButton.disabledText", "ToggleButton.disabledBackground" ); + fg2bgMap.put( "CheckBox.foreground", "Panel.background" ); + fg2bgMap.put( "CheckBox.disabledText", "Panel.background" ); + fg2bgMap.put( "Label.foreground", "Panel.background" ); + fg2bgMap.put( "Label.disabledForeground", "Panel.background" ); + fg2bgMap.remove( "ProgressBar.foreground" ); + fg2bgMap.put( "ProgressBar.selectionForeground", "ProgressBar.foreground" ); + fg2bgMap.put( "ProgressBar.selectionBackground", "ProgressBar.background" ); + fg2bgMap.put( "RadioButton.foreground", "Panel.background" ); + fg2bgMap.put( "RadioButton.disabledText", "Panel.background" ); + fg2bgMap.remove( "ScrollBar.foreground" ); + fg2bgMap.remove( "ScrollBar.hoverButtonForeground" ); + fg2bgMap.remove( "ScrollBar.pressedButtonForeground" ); + fg2bgMap.remove( "ScrollPane.foreground" ); + fg2bgMap.remove( "Separator.foreground" ); + fg2bgMap.remove( "Slider.foreground" ); + fg2bgMap.remove( "SplitPane.foreground" ); + fg2bgMap.remove( "TextArea.disabledForeground" ); + fg2bgMap.put( "TextArea.inactiveForeground", "TextArea.disabledBackground" ); + fg2bgMap.remove( "TextPane.disabledForeground" ); + fg2bgMap.put( "TextPane.inactiveForeground", "TextPane.disabledBackground" ); + fg2bgMap.remove( "EditorPane.disabledForeground" ); + fg2bgMap.put( "EditorPane.inactiveForeground", "EditorPane.disabledBackground" ); + fg2bgMap.remove( "TextField.disabledForeground" ); + fg2bgMap.put( "TextField.inactiveForeground", "TextField.disabledBackground" ); + fg2bgMap.remove( "FormattedTextField.disabledForeground" ); + fg2bgMap.put( "FormattedTextField.inactiveForeground", "FormattedTextField.disabledBackground" ); + fg2bgMap.remove( "PasswordField.disabledForeground" ); + fg2bgMap.put( "PasswordField.inactiveForeground", "PasswordField.disabledBackground" ); + fg2bgMap.remove( "ToolBar.dockingForeground" ); + fg2bgMap.remove( "ToolBar.floatingForeground" ); + fg2bgMap.remove( "ToolBar.foreground" ); + fg2bgMap.remove( "ToolBar.hoverButtonGroupForeground" ); + fg2bgMap.remove( "Viewport.foreground" ); + + fg2bgMap.remove( "InternalFrame.closeHoverForeground" ); + fg2bgMap.remove( "InternalFrame.closePressedForeground" ); + fg2bgMap.remove( "TabbedPane.closeHoverForeground" ); + fg2bgMap.remove( "TabbedPane.closePressedForeground" ); + fg2bgMap.remove( "TitlePane.closeHoverForeground" ); + fg2bgMap.remove( "TitlePane.closePressedForeground" ); + +// out.println(); +// fg2bgMap.entrySet().stream() +// .sorted( (e1, e2) -> e1.getKey().compareTo( e2.getKey() ) ) +// .forEach( e -> { +// out.printf( "%-50s %s%n", e.getKey(), e.getValue() ); +// } ); +// out.println(); + + AtomicReference lastSubkey = new AtomicReference<>(); + + fg2bgMap.entrySet().stream() + .sorted( (e1, e2) -> { + String key1 = e1.getKey(); + String key2 = e2.getKey(); + int dot1 = key1.lastIndexOf( '.' ); + int dot2 = key2.lastIndexOf( '.' ); + if( dot1 < 0 || dot2 < 0 ) + return key1.compareTo( key2 ); + int r = key1.substring( dot1 + 1 ).compareTo( key2.substring( dot2 + 1 ) ); + if( r != 0 ) + return r; + return key1.substring( 0, dot1 ).compareTo( key2.substring( 0, dot2 ) ); + } ) + .forEach( e -> { + String fgKey = e.getKey(); + String bgKey = e.getValue(); + Color background = defaults.getColor( bgKey ); + Color foreground = defaults.getColor( fgKey ); + if( background != null && foreground != null ) { + float luma1 = ColorFunctions.luma( background ); + float luma2 = ColorFunctions.luma( foreground ); + float contrastRatio = (luma1 > luma2) + ? (luma1 + 0.05f) / (luma2 + 0.05f) + : (luma2 + 0.05f) / (luma1 + 0.05f); + String rateing = + contrastRatio < 1.95f ? " !!!!!!" : + contrastRatio < 2.95f ? " !!!!!" : + contrastRatio < 3.95f ? " !!!!" : + contrastRatio < 4.95f ? " !!!" : + contrastRatio < 5.95f ? " !!" : + contrastRatio < 6.95f ? " !" : + ""; + + String subkey = fgKey.substring( fgKey.lastIndexOf( '.' ) + 1 ); + if( !subkey.equals( lastSubkey.get() ) ) { + lastSubkey.set( subkey ); + out.println(); + out.println( "#-- " + subkey + " --" ); + } + + out.printf( "%-50s #%06x #%06x %4.1f%s%n", fgKey, + foreground.getRGB() & 0xffffff, background.getRGB() & 0xffffff, + contrastRatio, rateing ); + } + } ); + } + //---- class MyBasicLookAndFeel ------------------------------------------- public static class MyBasicLookAndFeel