use of com.intellij.util.ui.ColorIcon in project android by JetBrains.
the class AndroidColorAnnotatorTest method checkAnnotationColor.
private static void checkAnnotationColor(Annotation annotation, Color expectedColor) {
GutterIconRenderer renderer = annotation.getGutterIconRenderer();
assertThat(renderer).isNotNull();
Icon icon = renderer.getIcon();
assertThat(icon).isInstanceOf(ColorIcon.class);
ColorIcon colorIcon = (ColorIcon) icon;
Color color = colorIcon.getIconColor();
assertThat(color).isEqualTo(expectedColor);
}
use of com.intellij.util.ui.ColorIcon in project intellij-community by JetBrains.
the class ColorObjectRenderer method calcValueIcon.
public Icon calcValueIcon(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener listener) throws EvaluateException {
final Value value = descriptor.getValue();
if (value instanceof ObjectReference) {
try {
final ObjectReference objRef = (ObjectReference) value;
final ReferenceType refType = objRef.referenceType();
final Field valueField = refType.fieldByName("value");
if (valueField != null) {
final Value rgbValue = objRef.getValue(valueField);
if (rgbValue instanceof IntegerValue) {
@SuppressWarnings("UseJBColor") final Color color = new Color(((IntegerValue) rgbValue).value(), true);
return JBUI.scale(new ColorIcon(16, 12, color, true));
}
}
} catch (Exception e) {
throw new EvaluateException(e.getMessage(), e);
}
}
return null;
}
use of com.intellij.util.ui.ColorIcon in project intellij-community by JetBrains.
the class JavaFxAnnotator method attachColorIcon.
private static void attachColorIcon(final PsiElement element, AnnotationHolder holder, String attributeValueText) {
try {
Color color = null;
if (attributeValueText.startsWith("#")) {
color = ColorUtil.fromHex(attributeValueText.substring(1));
} else {
final String hexCode = ColorMap.getHexCodeForColorName(StringUtil.toLowerCase(attributeValueText));
if (hexCode != null) {
color = ColorUtil.fromHex(hexCode);
}
}
if (color != null) {
final ColorIcon icon = JBUI.scale(new ColorIcon(8, color));
final Annotation annotation = holder.createInfoAnnotation(element, null);
annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element));
}
} catch (Exception ignored) {
}
}
Aggregations