use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class ElementBase method overlayIcons.
@NotNull
public static Icon overlayIcons(@NotNull Icon... icons) {
final LayeredIcon icon = new LayeredIcon(icons.length);
int i = 0;
for (Icon ic : icons) {
icon.setIcon(ic, i++);
}
return icon;
}
use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class IconUtil method addText.
@NotNull
public static Icon addText(@NotNull Icon base, @NotNull String text) {
LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(base, 0);
icon.setIcon(textToIcon(text, new JLabel(), JBUI.scale(6f)), 1, SwingConstants.SOUTH_EAST);
return icon;
}
use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class MethodHierarchyNodeDescriptor method update.
public final boolean update() {
int flags = Iconable.ICON_FLAG_VISIBILITY;
if (isMarkReadOnly()) {
flags |= Iconable.ICON_FLAG_READ_STATUS;
}
boolean changes = super.update();
final PsiElement psiClass = getPsiClass();
if (psiClass == null) {
final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
}
return true;
}
final Icon newRawIcon = psiClass.getIcon(flags);
final Icon newStateIcon = psiClass instanceof PsiClass ? calculateState((PsiClass) psiClass) : AllIcons.Hierarchy.MethodDefined;
if (changes || newRawIcon != myRawIcon || newStateIcon != myStateIcon) {
changes = true;
myRawIcon = newRawIcon;
myStateIcon = newStateIcon;
Icon newIcon = myRawIcon;
if (myIsBase) {
final LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(newIcon, 0);
icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0);
newIcon = icon;
}
if (myStateIcon != null) {
newIcon = new RowIcon(myStateIcon, newIcon);
}
setIcon(newIcon);
}
final CompositeAppearance oldText = myHighlightedText;
myHighlightedText = new CompositeAppearance();
TextAttributes classNameAttributes = null;
if (myColor != null) {
classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
}
if (psiClass instanceof PsiClass) {
myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass((PsiClass) psiClass, false), classNameAttributes);
myHighlightedText.getEnding().addText(" (" + JavaHierarchyUtil.getPackageName((PsiClass) psiClass) + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
} else if (psiClass instanceof PsiFunctionalExpression) {
myHighlightedText.getEnding().addText(ClassPresentationUtil.getFunctionalExpressionPresentation((PsiFunctionalExpression) psiClass, false));
}
myName = myHighlightedText.getText();
if (!Comparing.equal(myHighlightedText, oldText)) {
changes = true;
}
return changes;
}
use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class TypeHierarchyNodeDescriptor method update.
public final boolean update() {
boolean changes = super.update();
if (getPsiElement() == null) {
final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
}
return true;
}
if (changes && myIsBase) {
final LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(getIcon(), 0);
icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0);
setIcon(icon);
}
final PsiElement psiElement = getPsiClass();
final CompositeAppearance oldText = myHighlightedText;
myHighlightedText = new CompositeAppearance();
TextAttributes classNameAttributes = null;
if (myColor != null) {
classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
}
if (psiElement instanceof PsiClass) {
myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass((PsiClass) psiElement, false), classNameAttributes);
myHighlightedText.getEnding().addText(" (" + JavaHierarchyUtil.getPackageName((PsiClass) psiElement) + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
} else if (psiElement instanceof PsiFunctionalExpression) {
myHighlightedText.getEnding().addText(ClassPresentationUtil.getFunctionalExpressionPresentation(((PsiFunctionalExpression) psiElement), false));
}
myName = myHighlightedText.getText();
if (!Comparing.equal(myHighlightedText, oldText)) {
changes = true;
}
return changes;
}
use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class EditorWindow method getFileIcon.
/**
* @return icon which represents file's type and modification status
*/
private Icon getFileIcon(@NotNull final VirtualFile file) {
if (!file.isValid()) {
Icon fakeIcon = FileTypes.UNKNOWN.getIcon();
assert fakeIcon != null : "Can't find the icon for unknown file type";
return fakeIcon;
}
final Icon baseIcon = IconUtil.getIcon(file, Iconable.ICON_FLAG_READ_STATUS, getManager().getProject());
int count = 1;
final Icon pinIcon;
final EditorComposite composite = findFileComposite(file);
if (composite != null && composite.isPinned()) {
count++;
pinIcon = AllIcons.Nodes.TabPin;
} else {
pinIcon = null;
}
final Icon modifiedIcon;
UISettings settings = UISettings.getInstance();
if (settings.getMarkModifiedTabsWithAsterisk() || !settings.getHideTabsIfNeed()) {
modifiedIcon = settings.getMarkModifiedTabsWithAsterisk() && composite != null && composite.isModified() ? MODIFIED_ICON : GAP_ICON;
count++;
} else {
modifiedIcon = null;
}
if (count == 1)
return baseIcon;
int i = 0;
final LayeredIcon result = new LayeredIcon(count);
int xShift = !settings.getHideTabsIfNeed() ? 4 : 0;
result.setIcon(baseIcon, i++, xShift, 0);
if (pinIcon != null)
result.setIcon(pinIcon, i++, xShift, 0);
if (modifiedIcon != null)
result.setIcon(modifiedIcon, i++);
return JBUI.scale(result);
}
Aggregations