当前位置: 首页>>代码示例>>Java>>正文


Java ColorUtil.isDark方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditorColorsUtil.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:Bookmark.java

示例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>");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:AndroidJavaDocRenderer.java

示例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);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:39,代码来源:PopupListElementRenderer.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:UsageTreeColorsScheme.java

示例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();
}
 
开发者ID:JetBrains,项目名称:jediterm,代码行数:13,代码来源:ScrollColorProducer.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:BraceHighlightingHandler.java

示例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"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:PopupListElementRenderer.java

示例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();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:62,代码来源:BraceHighlightingHandler.java

示例10: isDarkEditor

import com.intellij.ui.ColorUtil; //导入方法依赖的package包/类
private static boolean isDarkEditor() {
  Color bg = EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground();
  return ColorUtil.isDark(bg);
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:5,代码来源:SchemaRetroTagLinePainter.java

示例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"));
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:57,代码来源:PopupListElementRenderer.java


注:本文中的com.intellij.ui.ColorUtil.isDark方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。