Java Code Examples for com.intellij.ui.ColorUtil#isDark()
The following examples show how to use
com.intellij.ui.ColorUtil#isDark() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterProjectStep.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void updateSdkField(JTextComponent sdkEditor) { FlutterSdk current = FlutterSdk.forPath(sdkEditor.getText()); Color color = sdkBackgroundColor; if (current == null) { if (ColorUtil.isDark(sdkBackgroundColor)) { color = ColorUtil.darker(JBColor.YELLOW, 5); } else { color = ColorUtil.desaturate(JBColor.YELLOW, 15); } } sdkEditor.setBackground(color); }
Example 2
Source File: FlutterProjectStep.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void updateSdkField(JTextComponent sdkEditor) { FlutterSdk current = FlutterSdk.forPath(sdkEditor.getText()); Color color = sdkBackgroundColor; if (current == null) { if (ColorUtil.isDark(sdkBackgroundColor)) { color = ColorUtil.darker(JBColor.YELLOW, 5); } else { color = ColorUtil.desaturate(JBColor.YELLOW, 15); } } sdkEditor.setBackground(color); }
Example 3
Source File: EditorColorsUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * @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; }
Example 4
Source File: PopupListElementRenderer.java From consulo with Apache License 2.0 | 4 votes |
@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 (step instanceof BaseListPopupStep) { Color bg = ((BaseListPopupStep<E>)step).getBackgroundFor(value); Color fg = ((BaseListPopupStep<E>)step).getForegroundFor(value); if (!isSelected && fg != null) myTextLabel.setForeground(fg); if (!isSelected && bg != null) UIUtil.setBackgroundRecursively(myComponent, bg); if (bg != null && mySeparatorComponent.isVisible() && myCurrentIndex > 0) { E prevValue = list.getModel().getElementAt(myCurrentIndex - 1); // separator between 2 colored items shall get color too if (Comparing.equal(bg, ((BaseListPopupStep<E>)step).getBackgroundFor(prevValue))) { myRendererComponent.setBackground(bg); } } } if (step.isMnemonicsNavigationEnabled()) { MnemonicNavigationFilter<Object> filter = step.getMnemonicNavigationFilter(); int pos = filter == null ? -1 : filter.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(myComponent, isSelected && isSelectable); setSelected(myTextLabel, isSelected && isSelectable); setSelected(myNextStepLabel, isSelected && isSelectable); 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 && isSelectable); myShortcutLabel.setForeground(isSelected && isSelectable ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground")); } }
Example 5
Source File: BraceHighlightingHandler.java From consulo with Apache License 2.0 | 4 votes |
private void highlightBraces(@Nullable TextRange lBrace, @Nullable TextRange rBrace, boolean matched, boolean scopeHighlighting, @Nonnull FileType fileType) { if (!matched && fileType == PlainTextFileType.INSTANCE) { 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 = () -> { 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 { removeLineMarkers(); } if (!scopeHighlighting) { showScopeHint(lBrace.getStartOffset(), lBrace.getEndOffset()); } } else { if (!myCodeInsightSettings.HIGHLIGHT_SCOPE) { removeLineMarkers(); } } }