Ignore:
Timestamp:
2015-12-30T21:26:57+01:00 (4 years ago)
Author:
Don-vip
Message:

fix #12259 - adjust colors contrast in relation editor and history dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ColorHelper.java

    r8846 r9223  
    7272        return code;
    7373    }
     74
     75    /**
     76     * Determines the correct foreground color (black or white) to use for the given background,
     77     * so the text will be readable.
     78     * @param bg background color
     79     * @return {@code Color#BLACK} or {@code Color#WHITE}
     80     * @since 9223
     81     */
     82    public static Color getForegroundColor(Color bg) {
     83        // http://stackoverflow.com/a/3943023/2257172
     84        return (bg.getRed()*0.299 + bg.getGreen()*0.587 + bg.getBlue()*0.114) > 186 ?
     85                Color.BLACK : Color.WHITE;
     86    }
    7487}
Note: See TracChangeset for help on using the changeset viewer.