RUBY-5272 Find usages shouldn​'​t use foreground attributes for elements in presentation

This commit is contained in:
Oleg Shpynov
2009-11-03 19:12:33 +03:00
parent 7f0d02ad94
commit 94c2318b89
@@ -29,6 +29,7 @@ import com.intellij.usages.*;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.*;
/**
* @author max
@@ -131,6 +132,19 @@ class UsageViewTreeCellRenderer extends ColoredTreeCellRenderer {
original = new SimpleTextAttributes(original.getStyle() | SimpleTextAttributes.STYLE_BOLD, original.getFgColor(), original.getWaveColor());
}
}
// Fix problems with black background or white text as foreground
// Logic of checking hsb component was taken from CssColorGutterRenderer
if (original.getBgColor() != null){
Color fgColor = original.getFgColor();
if (fgColor != null){
final float hsb[] = new float[3];
Color.RGBtoHSB(fgColor.getRed(), fgColor.getGreen(), fgColor.getBlue(), hsb);
if (hsb[2] > 0.7f){
fgColor = null;
}
}
return new SimpleTextAttributes(original.getStyle(), fgColor, original.getWaveColor());
}
return original;
}