本文整理汇总了Java中com.intellij.ui.ColorUtil.isDark方法的典型用法代码示例。如果您正苦于以下问题:Java ColorUtil.isDark方法的具体用法?Java ColorUtil.isDark怎么用?Java ColorUtil.isDark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ui.ColorUtil
的用法示例。
在下文中一共展示了ColorUtil.isDark方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColorSchemeForBackground
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
/**
* @return the appropriate color scheme for UI other than text editor (QuickDoc, UsagesView, etc.)
* depending on the current LAF, current editor color scheme and background color.
*/
public static EditorColorsScheme getColorSchemeForBackground(@Nullable Color background) {
EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
boolean dark1 = background == null ? UIUtil.isUnderDarcula() : ColorUtil.isDark(background);
boolean dark2 = ColorUtil.isDark(globalScheme.getDefaultBackground());
if (dark1 != dark2) {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
if (scheme != null) {
return scheme;
}
}
return globalScheme;
}
示例2: darkBackground
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
private static boolean darkBackground() {
Color gutterBackground = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.GUTTER_BACKGROUND);
if (gutterBackground == null) {
gutterBackground = EditorColors.GUTTER_BACKGROUND.getDefaultColor();
}
return ColorUtil.isDark(gutterBackground);
}
示例3: renderColorToHtml
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
public void renderColorToHtml(@NotNull HtmlBuilder builder, @NotNull Color color) {
int width = 200;
int height = 100;
if (mySmall) {
int divisor = 3;
width /= divisor;
height /= divisor;
}
String colorString = String.format(Locale.US, "rgb(%d,%d,%d)", color.getRed(), color.getGreen(), color.getBlue());
String foregroundColor = ColorUtil.isDark(color) ? "white" : "black";
String css = "background-color:" + colorString +
";width:" + width + "px;text-align:center;vertical-align:middle;";
// Use <table> tag such that we can center the color text (Java's HTML renderer doesn't support
// vertical-align:middle on divs)
builder.addHtml("<table style=\"" + css + "\" border=\"0\"><tr height=\"" + height + "\">");
builder.addHtml("<td align=\"center\" valign=\"middle\" height=\"" + height + "\" style=\"color:" + foregroundColor + "\">");
builder.addHtml("#");
int alpha = color.getAlpha();
// If not opaque, include alpha
if (alpha != 255) {
String alphaString = Integer.toHexString(alpha);
builder.addHtml((alphaString.length() < 2 ? "0" : "") + alphaString);
}
builder.addHtml(ColorUtil.toHex(color));
builder.addHtml("</td></tr></table>");
}
示例4: customizeComponent
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
@Override
protected void customizeComponent(JList list, Object value, boolean isSelected) {
ListPopupStep<Object> step = myPopup.getListStep();
boolean isSelectable = step.isSelectable(value);
myTextLabel.setEnabled(isSelectable);
if (step.isMnemonicsNavigationEnabled()) {
final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value);
if (pos != -1) {
String text = myTextLabel.getText();
text = text.substring(0, pos) + text.substring(pos + 1);
myTextLabel.setText(text);
myTextLabel.setDisplayedMnemonicIndex(pos);
}
}
else {
myTextLabel.setDisplayedMnemonicIndex(-1);
}
if (step.hasSubstep(value) && isSelectable) {
myNextStepLabel.setVisible(true);
final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground());
myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted
: AllIcons.Icons.Ide.NextStep
: AllIcons.Icons.Ide.NextStepGrayed);
}
else {
myNextStepLabel.setVisible(false);
//myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON);
}
if (isSelected) {
setSelected(myNextStepLabel);
}
else {
setDeselected(myNextStepLabel);
}
}
示例5: readExternal
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
@Override
public void readExternal(Element element) throws InvalidDataException {
if (myColorsScheme == null){
Color color = UIUtil.getTreeTextBackground();
if (color != null && ColorUtil.isDark(color)) {
myColorsScheme = (EditorColorsScheme)myEditorColorsManager.getGlobalScheme().clone();
}
else {
myColorsScheme = (EditorColorsScheme)myEditorColorsManager.getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME).clone();
}
}
myColorsScheme.readExternal(element);
}
示例6: isDark
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
static boolean isDark(Component c) {
Container parent = c.getParent();
if (parent instanceof JScrollPane) {
JScrollPane pane = (JScrollPane)parent;
Object property = pane.getClientProperty(BRIGHTNESS_FROM_VIEW);
if (property instanceof Boolean && (Boolean)property) {
Color color = JBScrollPane.getViewBackground(pane);
if (color != null) return ColorUtil.isDark(color);
}
}
return UIUtil.isUnderDarcula();
}
示例7: createLineMarkerRenderer
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
@Nullable
public static LineMarkerRenderer createLineMarkerRenderer(boolean matched) {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
final TextAttributes attributes =
matched ? scheme.getAttributes(CodeInsightColors.MATCHED_BRACE_ATTRIBUTES)
: scheme.getAttributes(CodeInsightColors.UNMATCHED_BRACE_ATTRIBUTES);
Color color = attributes.getBackgroundColor();
if (color == null) return null;
color = ColorUtil.isDark(scheme.getDefaultBackground()) ? ColorUtil.shift(color, 1.5d) : color.darker();
return new MyLineMarkerRenderer(color);
}
示例8: customizeComponent
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
@Override
protected void customizeComponent(JList list, Object value, boolean isSelected) {
ListPopupStep<Object> step = myPopup.getListStep();
boolean isSelectable = step.isSelectable(value);
myTextLabel.setEnabled(isSelectable);
if (!isSelected && step instanceof BaseListPopupStep) {
Color bg = ((BaseListPopupStep)step).getBackgroundFor(value);
Color fg = ((BaseListPopupStep)step).getForegroundFor(value);
if (fg != null) myTextLabel.setForeground(fg);
if (bg != null) UIUtil.setBackgroundRecursively(myComponent, bg);
}
if (step.isMnemonicsNavigationEnabled()) {
final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value);
if (pos != -1) {
String text = myTextLabel.getText();
text = text.substring(0, pos) + text.substring(pos + 1);
myTextLabel.setText(text);
myTextLabel.setDisplayedMnemonicIndex(pos);
}
}
else {
myTextLabel.setDisplayedMnemonicIndex(-1);
}
if (step.hasSubstep(value) && isSelectable) {
myNextStepLabel.setVisible(true);
final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground());
myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted
: AllIcons.Icons.Ide.NextStep
: AllIcons.Icons.Ide.NextStepGrayed);
}
else {
myNextStepLabel.setVisible(false);
//myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON);
}
setSelected(myNextStepLabel, isSelected);
if (myShortcutLabel != null) {
myShortcutLabel.setText("");
if (value instanceof ShortcutProvider) {
ShortcutSet set = ((ShortcutProvider)value).getShortcut();
if (set != null) {
Shortcut shortcut = ArrayUtil.getFirstElement(set.getShortcuts());
if (shortcut != null) {
myShortcutLabel.setText(" " + KeymapUtil.getShortcutText(shortcut));
}
}
}
setSelected(myShortcutLabel, isSelected);
myShortcutLabel.setForeground(isSelected ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground"));
}
}
示例9: highlightBraces
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
private void highlightBraces(@Nullable TextRange lBrace, @Nullable TextRange rBrace, boolean matched, boolean scopeHighlighting, @NotNull FileType fileType) {
if (!matched && fileType == FileTypes.PLAIN_TEXT) {
return;
}
EditorColorsScheme scheme = myEditor.getColorsScheme();
final TextAttributes attributes =
matched ? scheme.getAttributes(CodeInsightColors.MATCHED_BRACE_ATTRIBUTES)
: scheme.getAttributes(CodeInsightColors.UNMATCHED_BRACE_ATTRIBUTES);
if (rBrace != null && !scopeHighlighting) {
highlightBrace(rBrace, matched);
}
if (lBrace != null && !scopeHighlighting) {
highlightBrace(lBrace, matched);
}
FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject); // null in default project
if (fileEditorManager == null || !myEditor.equals(fileEditorManager.getSelectedTextEditor())) {
return;
}
if (lBrace != null && rBrace !=null) {
final int startLine = myEditor.offsetToLogicalPosition(lBrace.getStartOffset()).line;
final int endLine = myEditor.offsetToLogicalPosition(rBrace.getEndOffset()).line;
if (endLine - startLine > 0) {
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (myProject.isDisposed() || myEditor.isDisposed()) return;
Color color = attributes.getBackgroundColor();
if (color == null) return;
color = ColorUtil.isDark(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground()) ? ColorUtil.shift(color, 1.5d) : color.darker();
lineMarkFragment(startLine, endLine, color);
}
};
if (!scopeHighlighting) {
myAlarm.addRequest(runnable, 300);
}
else {
runnable.run();
}
}
else {
if (!myCodeInsightSettings.HIGHLIGHT_SCOPE) {
removeLineMarkers();
}
}
if (!scopeHighlighting) {
showScopeHint(lBrace.getStartOffset(), lBrace.getEndOffset());
}
}
else {
if (!myCodeInsightSettings.HIGHLIGHT_SCOPE) {
removeLineMarkers();
}
}
}
示例10: isDarkEditor
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
private static boolean isDarkEditor() {
Color bg = EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground();
return ColorUtil.isDark(bg);
}
示例11: customizeComponent
import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
@Override
protected void customizeComponent(JList<? extends E> list, E value, boolean isSelected) {
ListPopupStep<Object> step = myPopup.getListStep();
boolean isSelectable = step.isSelectable(value);
myTextLabel.setEnabled(isSelectable);
if (!isSelected && step instanceof BaseListPopupStep) {
Color bg = ((BaseListPopupStep)step).getBackgroundFor(value);
Color fg = ((BaseListPopupStep)step).getForegroundFor(value);
if (fg != null) myTextLabel.setForeground(fg);
if (bg != null) UIUtil.setBackgroundRecursively(myComponent, bg);
}
if (step.isMnemonicsNavigationEnabled()) {
final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value);
if (pos != -1) {
String text = myTextLabel.getText();
text = text.substring(0, pos) + text.substring(pos + 1);
myTextLabel.setText(text);
myTextLabel.setDisplayedMnemonicIndex(pos);
}
}
else {
myTextLabel.setDisplayedMnemonicIndex(-1);
}
if (step.hasSubstep(value) && isSelectable) {
myNextStepLabel.setVisible(true);
final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground());
myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted
: AllIcons.Icons.Ide.NextStep
: AllIcons.Icons.Ide.NextStepGrayed);
}
else {
myNextStepLabel.setVisible(false);
//myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON);
}
setSelected(myNextStepLabel, isSelected);
if (myShortcutLabel != null) {
myShortcutLabel.setEnabled(isSelectable);
myShortcutLabel.setText("");
if (value instanceof ShortcutProvider) {
ShortcutSet set = ((ShortcutProvider)value).getShortcut();
if (set != null) {
Shortcut shortcut = ArrayUtil.getFirstElement(set.getShortcuts());
if (shortcut != null) {
myShortcutLabel.setText(" " + KeymapUtil.getShortcutText(shortcut));
}
}
}
setSelected(myShortcutLabel, isSelected);
myShortcutLabel.setForeground(isSelected ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground"));
}
}