AdtUiUtils { public static Color overlayColor(int backgroundRgb, int foregroundRbg, float foregroundOpacity) { Color background = new Color(backgroundRgb); Color forground = new Color(foregroundRbg); return new Color( Math.round(background.getRed() * (1 - foregroundOpacity) + forground.getRed() * foregroundOpacity), Math.round(background.getGreen() * (1 - foregroundOpacity) + forground.getGreen() * foregroundOpacity), Math.round(background.getBlue() * (1 - foregroundOpacity) + forground.getBlue() * foregroundOpacity)); } private  AdtUiUtils(); static String shrinkToFit(String text, FontMetrics metrics, float availableSpace); static String shrinkToFit(String text, Predicate<String> textFitPredicate); static int unscale(int i); static Color overlayColor(int backgroundRgb, int foregroundRbg, float foregroundOpacity); static boolean isActionKeyDown(@NotNull InputEvent event); @JdkConstants.InputEventMask static int getActionMask(); static String getActionKeyText(); static JComponent createHorizontalSeparator(); @NotNull static JBScrollPane createNestedVScrollPane(@NotNull JComponent component); static final JBFont DEFAULT_FONT; static final JBFont EMPTY_TOOL_WINDOW_FONT; static final Color DEFAULT_FONT_COLOR; static final Color DEFAULT_BORDER_COLOR; static final Border DEFAULT_TOP_BORDER; static final Border DEFAULT_LEFT_BORDER; static final Border DEFAULT_BOTTOM_BORDER; static final Border DEFAULT_RIGHT_BORDER; static final Border DEFAULT_HORIZONTAL_BORDERS; static final Border DEFAULT_VERTICAL_BORDERS; static final GridBagConstraints GBC_FULL; }
@Test public void testOverlayColor() { float opacity = 0.8f; Color grey_0_8 = AdtUiUtils.overlayColor(Color.BLACK.getRGB(), Color.WHITE.getRGB(), opacity); long expected = Math.round(255 * opacity); assertThat(grey_0_8.getRed()).isEqualTo(expected); assertThat(grey_0_8.getGreen()).isEqualTo(expected); assertThat(grey_0_8.getBlue()).isEqualTo(expected); int background = 0xF000A0; int foreground = 0x00CC0B; Color mix = AdtUiUtils.overlayColor(background, foreground, 0.6f); assertThat(mix.getRed()).isEqualTo(Math.round(0xF0 * 0.4f)); assertThat(mix.getGreen()).isEqualTo(Math.round(0xCC * 0.6f)); assertThat(mix.getBlue()).isEqualTo(Math.round(0xA0 * 0.4f + 0x0B * 0.6f)); }