Java 类com.intellij.util.ui.ColorIcon 实例源码

项目:intellij-ce-playground    文件:ColorObjectRenderer.java   
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 new ColorIcon(16, 12, color, true);
        }
      }
    }
    catch (Exception e) {
      throw new EvaluateException(e.getMessage(), e);
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:VariableLookupItem.java   
@Override
public void renderElement(LookupElementPresentation presentation) {
  boolean qualify = myHelper != null && !myHelper.willBeImported();

  PsiVariable variable = getObject();
  String name = variable.getName();
  if (qualify && variable instanceof PsiField && ((PsiField)variable).getContainingClass() != null) {
    name = ((PsiField)variable).getContainingClass().getName() + "." + name;
  }
  presentation.setItemText(name);

  presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(this, presentation.isReal()));
  presentation.setStrikeout(JavaElementLookupRenderer.isToStrikeout(this));

  if (myHelper != null) {
    myHelper.renderElement(presentation, qualify, true, getSubstitutor());
  }
  if (myColor != null) {
    presentation.setTypeText("", new ColorIcon(12, myColor));
  } else {
    presentation.setTypeText(getType().getPresentableText());
  }
}
项目:intellij-ce-playground    文件:JavaFxAnnotator.java   
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 = new ColorIcon(8, color);
      final Annotation annotation = holder.createInfoAnnotation(element, null);
      annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element));
    }
  }
  catch (Exception ignored) {
  }
}
项目:tools-idea    文件:NodeRendererSettings.java   
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) {
          final Color color = new Color(((IntegerValue)rgbValue).value(), true);
          return new ColorIcon(16, 12, color, true);
        }
      }
    }
    catch (Exception e) {
      throw new EvaluateException(e.getMessage(), e);
    }
  }
  return null;
}
项目:tools-idea    文件:JavaFxAnnotator.java   
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 = ColorSampleLookupValue.getHexCodeForColorName(StringUtil.toLowerCase(attributeValueText));
      if (hexCode != null) {
        color = ColorUtil.fromHex(hexCode);
      }
    }
    if (color != null) {
      final ColorIcon icon = new ColorIcon(8, color);
      final Annotation annotation = holder.createInfoAnnotation(element, null);
      annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element));
    }
  }
  catch (Exception ignored) {
  }
}
项目:consulo-javafx    文件:JavaFxAnnotator.java   
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 = ColorSampleLookupValue.getHexCodeForColorName(StringUtil.toLowerCase(attributeValueText));
      if (hexCode != null) {
        color = ColorUtil.fromHex(hexCode);
      }
    }
    if (color != null) {
      final ColorIcon icon = new ColorIcon(8, color);
      final Annotation annotation = holder.createInfoAnnotation(element, null);
      annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element));
    }
  }
  catch (Exception ignored) {
  }
}
项目:intellij-ce-playground    文件:AnnotationsRenderer.java   
@NotNull
private static Result renderColorInt(int value) {
  int alpha = value >>> 24;
  boolean hasAlpha = alpha != 0;

  //noinspection UseJBColor
  final Color color = new Color(value, hasAlpha);
  String result = String.format(Locale.US, "0x%1$08x {a=%2$02d r=%3$02d g=%4$02d b=%5$02d}", value, color.getAlpha(), color.getRed(),
                                color.getGreen(), color.getBlue());
  return new Result(result, new ColorIcon(16, 12, color, true));
}
项目:consulo    文件:GoToHashOrRefPopup.java   
@Nonnull
@Override
public LookupElementBuilder createLookupBuilder(@Nonnull VcsRef item) {
  LookupElementBuilder lookupBuilder = super.createLookupBuilder(item);
  if (myColorManager.isMultipleRoots()) {
    lookupBuilder = lookupBuilder
      .withTypeText(getTypeText(item),
                    new ColorIcon(15, VcsLogGraphTable.getRootBackgroundColor(item.getRoot(), myColorManager)),
                    true);
  }
  return lookupBuilder;
}
项目:consulo-css    文件:KeywordColorXStyleSheetValue.java   
@NotNull
@Override
public List<LookupElement> getLookupElements(String value)
{
    List<LookupElement> list = new ArrayList<LookupElement>();
    for(Map.Entry<String, String> entry : myDefaultColors.entrySet())
    {
        LookupElementBuilder builder = LookupElementBuilder.create(entry.getKey());
        builder = builder.withIcon(new ColorIcon(12, ColorUtil.fromHex(entry.getValue())));
        builder = builder.withTypeText(entry.getValue(), true);
        list.add(builder);
    }
    return list;
}
项目:consulo-java    文件:VariableLookupItem.java   
@Override
public void renderElement(LookupElementPresentation presentation)
{
    boolean qualify = myHelper != null && !myHelper.willBeImported();

    PsiVariable variable = getObject();
    String name = variable.getName();
    if(qualify && variable instanceof PsiField && ((PsiField) variable).getContainingClass() != null)
    {
        name = ((PsiField) variable).getContainingClass().getName() + "." + name;
    }
    presentation.setItemText(name);

    presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(this, presentation.isReal()));
    presentation.setStrikeout(JavaElementLookupRenderer.isToStrikeout(this));

    if(myHelper != null)
    {
        myHelper.renderElement(presentation, qualify, true, getSubstitutor());
    }
    if(myColor != null)
    {
        presentation.setTypeText("", JBUI.scale(new ColorIcon(12, myColor)));
    }
    else
    {
        presentation.setTypeText(getType().getPresentableText());
    }
    if(myTailText != null && StringUtil.isEmpty(presentation.getTailText()))
    {
        if(myTailText.startsWith(EQ))
        {
            presentation.appendTailTextItalic(" (" + myTailText + ")", true);
        }
        else
        {
            presentation.setTailText(myTailText, true);
        }
    }
}
项目:consulo-java    文件:ColorObjectRenderer.java   
@Override
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 new ColorIcon(16, 12, color, true);
                }
            }
        }
        catch(Exception e)
        {
            throw new EvaluateException(e.getMessage(), e);
        }
    }
    return null;
}
项目:intellij-ce-playground    文件:SeverityRenderer.java   
public static Icon getIcon(@NotNull HighlightDisplayLevel level) {
  Icon icon = level.getIcon();
  return icon instanceof HighlightDisplayLevel.ColoredIcon
               ? new ColorIcon(icon.getIconWidth(), ((HighlightDisplayLevel.ColoredIcon)icon).getColor())
               : icon;
}
项目:intellij-ce-playground    文件:FileColorSettingsTable.java   
@Override
Icon getIcon(FileColorConfiguration configuration) {
  Color color = myManager.getColor(configuration.getColorName());
  return color == null ? EmptyIcon.ICON_16 : new ColorIcon(16, 13, color, true);
}
项目:intellij-ce-playground    文件:AndroidColorAnnotator.java   
@NotNull
@Override
public Icon getIcon() {
  final Color color = getCurrentColor();
  return color == null ? EmptyIcon.create(ICON_SIZE) : new ColorIcon(ICON_SIZE, color);
}
项目:intellij-ce-playground    文件:JavaFxAnnotator.java   
public ColorIconRenderer(ColorIcon icon, PsiElement element) {
  myIcon = icon;
  myElement = element;
}
项目:tools-idea    文件:UiInspectorAction.java   
public JComponent setValue(@NotNull final Color value) {
  setText("r:" + value.getRed() + ", g:" + value.getGreen() + ", b:" + value.getBlue());
  setIcon(new ColorIcon(13, 11, value, true));
  return this;
}
项目:tools-idea    文件:JavaFxAnnotator.java   
public ColorIconRenderer(ColorIcon icon, PsiElement element) {
  myIcon = icon;
  myElement = element;
}
项目:consulo-javafx    文件:JavaFxAnnotator.java   
public ColorIconRenderer(ColorIcon icon, PsiElement element) {
  myIcon = icon;
  myElement = element;
}
项目:consulo    文件:SeverityRenderer.java   
public static Icon getIcon(@Nonnull HighlightDisplayLevel level) {
  Icon icon = level.getIcon();
  return icon instanceof HighlightDisplayLevel.ColoredIcon
         ? new ColorIcon(icon.getIconWidth(), ((HighlightDisplayLevel.ColoredIcon)icon).getColor())
         : icon;
}