本文整理汇总了Java中com.intellij.ui.ColorUtil.softer方法的典型用法代码示例。如果您正苦于以下问题:Java ColorUtil.softer方法的具体用法?Java ColorUtil.softer怎么用?Java ColorUtil.softer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ui.ColorUtil
的用法示例。
在下文中一共展示了ColorUtil.softer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColorForObject
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
@Nullable
public static <T> Color getColorForObject(T object, Project project, @NotNull Function<T, PsiElement> converter) {
Color color = null;
final PsiElement psi = converter.fun(object);
if (psi != null) {
if (!psi.isValid()) return null;
final VirtualFile file = PsiUtilCore.getVirtualFile(psi);
if (file != null) {
color = FileColorManager.getInstance(project).getFileColor(file);
} else if (psi instanceof PsiDirectory) {
color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
} else if (psi instanceof PsiDirectoryContainer) {
final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
for (PsiDirectory dir : dirs) {
Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
if (c != null && color == null) {
color = c;
} else if (c != null) {
color = null;
break;
}
}
}
}
return color == null ? null : ColorUtil.softer(color);
}
示例2: getColorForObject
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
@Nullable
public static <T> Color getColorForObject(T object, Project project, @Nonnull Function<T, PsiElement> converter) {
Color color = null;
final PsiElement psi = converter.fun(object);
if (psi != null) {
if (!psi.isValid()) return null;
final VirtualFile file = PsiUtilCore.getVirtualFile(psi);
if (file != null) {
color = FileColorManager.getInstance(project).getFileColor(file);
}
else if (psi instanceof PsiDirectory) {
color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
}
else if (psi instanceof PsiDirectoryContainer) {
final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
for (PsiDirectory dir : dirs) {
Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
if (c != null && color == null) {
color = c;
}
else if (c != null) {
color = null;
break;
}
}
}
}
return color == null ? null : ColorUtil.softer(color);
}