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


Java ColorUtil类代码示例

本文整理汇总了Java中com.intellij.ui.ColorUtil的典型用法代码示例。如果您正苦于以下问题:Java ColorUtil类的具体用法?Java ColorUtil怎么用?Java ColorUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ColorUtil类属于com.intellij.ui包,在下文中一共展示了ColorUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTaskInfoPanel

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
@Override
public JComponent createTaskInfoPanel(Project project) {
  myTaskTextPane = new JTextPane();
  final JBScrollPane scrollPane = new JBScrollPane(myTaskTextPane);
  myTaskTextPane.setContentType(new HTMLEditorKit().getContentType());
  final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
  int fontSize = editorColorsScheme.getEditorFontSize();
  final String fontName = editorColorsScheme.getEditorFontName();
  final Font font = new Font(fontName, Font.PLAIN, fontSize);
  String bodyRule = "body { font-family: " + font.getFamily() + "; " +
                    "font-size: " + font.getSize() + "pt; }" +
                    "pre {font-family: Courier; display: inline; ine-height: 50px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; background-color:"
                    + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}" +
                    "code {font-family: Courier; display: flex; float: left; background-color:"
                    + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}";
  ((HTMLDocument)myTaskTextPane.getDocument()).getStyleSheet().addRule(bodyRule);
  myTaskTextPane.setEditable(false);
  if (!UIUtil.isUnderDarcula()) {
    myTaskTextPane.setBackground(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground());
  }
  myTaskTextPane.setBorder(new EmptyBorder(20, 20, 0, 10));
  myTaskTextPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
  return scrollPane;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:25,代码来源:StudySwingToolWindow.java

示例2: paintIcon

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
public void paintIcon(final Component c, Graphics graphics) {
  if (myCounter <= 0)
    return;
  final Rectangle moreRect = getIconRec();

  if (moreRect == null) return;

  int iconY = getIconY(moreRect);
  int iconX = getIconX(moreRect);
  graphics.setFont(UIUtil.getLabelFont().deriveFont((float)Math.min(8, UIUtil.getButtonFont().getSize())));
  int width = graphics.getFontMetrics().stringWidth(String.valueOf(myCounter));
  iconX -= width / 2 + 1;

  AllIcons.General.MoreTabs.paintIcon(c, graphics, iconX, iconY);
  Graphics g = graphics.create();
  try {
    UISettings.setupAntialiasing(g);
    UIUtil.drawStringWithHighlighting(g, String.valueOf(myCounter),
                                      iconX + AllIcons.General.MoreTabs.getIconWidth() + 2,
                                      iconY + AllIcons.General.MoreTabs.getIconHeight() - 5,
                                      JBColor.BLACK,
                                      ColorUtil.withAlpha(JBColor.WHITE, .9));
  } finally {
    g.dispose();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MoreTabsIcon.java

示例3: paintBorder

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
protected void paintBorder(Graphics g, Dimension size, int state) {
  GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  try {
    if (UIUtil.isUnderAquaLookAndFeel()) {
      if (state == ActionButtonComponent.POPPED) {
        g.setColor(JBColor.GRAY);
        ((Graphics2D)g).draw(getShape(size));
      }
    }
    else if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
      //do nothing
    }
    else {
      final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49;
      g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift));
      ((Graphics2D)g).setStroke(BASIC_STROKE);
      ((Graphics2D)g).draw(getShape(size));
    }
  }
  finally {
    config.restore();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:IdeaActionButtonLook.java

示例4: createDialogBalloonBuilder

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
@NotNull
@Override
public BalloonBuilder createDialogBalloonBuilder(@NotNull JComponent content, String title) {
  final BalloonPopupBuilderImpl builder = new BalloonPopupBuilderImpl(myStorage, content);
  final Color bg = UIManager.getColor("Panel.background");
  final Color borderOriginal = Color.darkGray;
  final Color border = ColorUtil.toAlpha(borderOriginal, 75);
  builder
    .setDialogMode(true)
    .setTitle(title)
    .setAnimationCycle(200)
    .setFillColor(bg).setBorderColor(border).setHideOnClickOutside(false)
    .setHideOnKeyOutside(false)
    .setHideOnAction(false)
    .setCloseButtonEnabled(true)
    .setShadow(true);

  return builder;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PopupFactoryImpl.java

示例5: initGlobalScopes

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
private void initGlobalScopes() {
  PropertiesComponent propertyComponent = PropertiesComponent.getInstance();
  for (String scopeName : predefinedScopeNameToPropertyKey.keySet()) {
    if (findConfiguration(scopeName, false) == null) {
      String color = propertyComponent.getValue(predefinedScopeNameToPropertyKey.get(scopeName));
      if (color == null) {
        // backward compatibility, previously it was saved incorrectly as scope name instead of specified property key
        color = propertyComponent.getValue(scopeName);
        if (color == null) {
          color = predefinedScopeNameToColor.get(scopeName);
        }
      }

      if (!color.isEmpty()) {
        final Color col = ColorUtil.fromHex(color, null);
        final String name = col == null ? null : FileColorManagerImpl.getColorName(col);
        myApplicationLevelConfigurations.add(new FileColorConfiguration(scopeName, name == null ? color : name));
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FileColorsModel.java

示例6: updateCustomButton

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
private void updateCustomButton() {
  final Object item = myScopeComboBox.getSelectedItem();
  if (item instanceof String) {
    Color color = myConfiguration == null ? null : ColorUtil.fromHex(myConfiguration.getColorName(), null);
    if (color == null) {
      color = ColorUtil.getColor(myScopeNames.get(item).getClass());
    }
    if (color != null) {
      final String colorName = ColorSelectionComponent.findColorName(color);
      if (colorName != null) {
        myColorSelectionComponent.setSelectedColor(colorName);
      } else {
        myColorSelectionComponent.setCustomButtonColor(color);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:FileColorConfigurationEditDialog.java

示例7: getColor

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
@Override
@SuppressWarnings({"MethodMayBeStatic"})
@Nullable
public Color getColor(@NotNull final String name) {
  Color color = ourDefaultColors.get(name);
  if (color != null) {
    return color;
  }

  if ("ffffe4".equals(name) || "494539".equals(name)) {
    return new JBColor(0xffffe4, 0x494539);
  }

  if ("e7fadb".equals(name) || "2a3b2c".equals(name)) {
    return new JBColor(0xe7fadb, 0x2a3b2c);
  }

  return ColorUtil.fromHex(name, null);

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:FileColorManagerImpl.java

示例8: attachColorIcon

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
private static void attachColorIcon(final PsiElement element, AnnotationHolder holder, String attributeValueText) {
  try {
    Color color = null;
    if (attributeValueText.startsWith("#")) {
      color = ColorUtil.fromHex(attributeValueText.substring(1));
    } else {
      final String hexCode = ColorMap.getHexCodeForColorName(StringUtil.toLowerCase(attributeValueText));
      if (hexCode != null) {
        color = ColorUtil.fromHex(hexCode);
      }
    }
    if (color != null) {
      final ColorIcon icon = new ColorIcon(8, color);
      final Annotation annotation = holder.createInfoAnnotation(element, null);
      annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element));
    }
  }
  catch (Exception ignored) {
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaFxAnnotator.java

示例9: paint

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
public void paint(Editor editor, Graphics g, Rectangle r) {
  final TextAttributes color = editor.getColorsScheme().getAttributes(myKey);
  Color bgColor = color.getBackgroundColor();
  if (bgColor == null) {
    bgColor = color.getForegroundColor();
  }
  if (editor.getSettings().isLineNumbersShown() || ((EditorGutterComponentEx)editor.getGutter()).isAnnotationsShown()) {
    if (bgColor != null) {
      bgColor = ColorUtil.toAlpha(bgColor, 150);
    }
  }
  if (bgColor != null) {
    g.setColor(bgColor);
  }
  g.fillRect(r.x, r.y, r.width, r.height);
  final LineData lineData = getLineData(editor.xyToLogicalPosition(new Point(0, r.y)).line);
  if (lineData != null && lineData.isCoveredByOneTest()) {
    g.drawImage( ImageLoader.loadFromResource("/gutter/unique.png"), r.x, r.y, 8, 8, editor.getComponent());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CoverageLineMarkerRenderer.java

示例10: patchPanels

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
static void patchPanels() throws Exception {
  if (MTConfig.getInstance().isMaterialTheme()) {
    final Color color = UIManager.getColor("Panel.background");
    StaticPatcher.setFinalStatic(UIUtil.class, "CONTRAST_BORDER_COLOR", ColorUtil.withAlpha(color, .05));
    StaticPatcher.setFinalStatic(UIUtil.class, "BORDER_COLOR", color);
    StaticPatcher.setFinalStatic(UIUtil.class, "AQUA_SEPARATOR_FOREGROUND_COLOR", color);
    //        StaticPatcher.setFinalStatic(HelpTooltip.class, "BACKGROUND_COLOR", color);
  }

  final Field[] fields = DarculaUIUtil.class.getDeclaredFields();
  final Object[] objects = Arrays.stream(fields)
                                 .filter(f -> f.getType().equals(Color.class))
                                 .toArray();
  final Color accentColor = ColorUtil.fromHex(MTConfig.getInstance().getAccentColor());
  final JBColor accentJBColor = new JBColor(accentColor, accentColor);
  StaticPatcher.setFinalStatic((Field) objects[0], accentJBColor);
  //      StaticPatcher.setFinalStatic((Field) objects[1], accentJBColor);

  final Field[] fields2 = IdeaActionButtonLook.class.getDeclaredFields();
  final Object[] objects2 = Arrays.stream(fields2)
                                  .filter(f -> f.getType().equals(Color.class))
                                  .toArray();

  StaticPatcher.setFinalStatic((Field) objects2[1], accentJBColor);
}
 
开发者ID:ChrisRM,项目名称:material-theme-jetbrains,代码行数:26,代码来源:UIReplacer.java

示例11: patchAutocomplete

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
static void patchAutocomplete() throws Exception {
  final String accentColor = MTConfig.getInstance().getAccentColor();
  final JBColor jbAccentColor = new JBColor(ColorUtil.fromHex(accentColor), ColorUtil.fromHex(accentColor));

  final Color defaultValue = UIUtil.getListSelectionBackground();
  final Color backgroundSelectedColor = ObjectUtils.notNull(UIManager.getColor("Autocomplete.selectionbackground"), defaultValue);

  final Field[] fields = LookupCellRenderer.class.getDeclaredFields();
  final Object[] objects = Arrays.stream(fields)
                                 .filter(f -> f.getType().equals(Color.class))
                                 .toArray();

  // SELECTED BACKGROUND COLOR
  StaticPatcher.setFinalStatic((Field) objects[3], backgroundSelectedColor);
  // SELECTED NON FOCUSED BACKGROUND COLOR
  StaticPatcher.setFinalStatic((Field) objects[4], backgroundSelectedColor);

  // Completion foreground color
  StaticPatcher.setFinalStatic((Field) objects[7], jbAccentColor);
  // Selected completion foregronud color
  StaticPatcher.setFinalStatic((Field) objects[8], jbAccentColor);
}
 
开发者ID:ChrisRM,项目名称:material-theme-jetbrains,代码行数:23,代码来源:UIReplacer.java

示例12: setError

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
public void setError(String text) {
  final Dimension oldSize = getPreferredSize();
  myText = text;

  if (text == null) {
    myLabel.setText("");
    myLabel.setIcon(null);
    setVisible(false);
    setBorder(null);
  }
  else {
    myLabel.setText(XmlStringUtil.wrapInHtml("<font color='#" + ColorUtil.toHex(JBColor.RED)+ "'><left>" + text + "</left></b></font>"));
    myLabel.setIcon(AllIcons.Actions.Lightning);
    myLabel.setBorder(new EmptyBorder(4, 10, 0, 2));
    setVisible(true);
  }

  final Dimension size = getPreferredSize();
  if (oldSize.height < size.height) {
    revalidate();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:DialogWrapper.java

示例13: paintIcon

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
public void paintIcon(final Component c, Graphics graphics) {
  if (myCounter <= 0)
    return;
  final Rectangle moreRect = getIconRec();

  if (moreRect == null) return;

  int iconY = getIconY(moreRect);
  int iconX = getIconX(moreRect);
  graphics.setFont(UIUtil.getLabelFont().deriveFont((float)Math.min(8, UIUtil.getButtonFont().getSize())));
  int width = graphics.getFontMetrics().stringWidth(String.valueOf(myCounter));
  iconX -= width / 2 + 1;

  AllIcons.General.MoreTabs.paintIcon(c, graphics, iconX, iconY);
  Graphics g = graphics.create();
  try {
    GraphicsUtil.setupAntialiasing(g, true, true);
    UIUtil.drawStringWithHighlighting(g, String.valueOf(myCounter),
                                      iconX + AllIcons.General.MoreTabs.getIconWidth() + 2,
                                      iconY + AllIcons.General.MoreTabs.getIconHeight() - 5,
                                      JBColor.BLACK,
                                      ColorUtil.withAlpha(JBColor.WHITE, .9));
  } finally {
    g.dispose();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:MoreTabsIcon.java

示例14: paintBorder

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
public void paintBorder(Graphics g, JComponent component, int state) {
  if (state == ActionButtonComponent.NORMAL) return;
  Rectangle r = new Rectangle(component.getWidth(), component.getHeight());

  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.POPPED) {
      g.setColor(ALPHA_30);
      g.drawRoundRect(r.x, r.y, r.width - 2, r.height - 2, 4, 4);
    }
  }
  else {
    final double shift = UIUtil.isUnderDarcula() ? 1/0.49 : 0.49;
    g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift));
    ((Graphics2D)g).setStroke(BASIC_STROKE);
    final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
    g.drawRoundRect(r.x, r.y, r.width - 2, r.height - 2, 4, 4);
    config.restore();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:IdeaActionButtonLook.java

示例15: createDialogBalloonBuilder

import com.intellij.ui.ColorUtil; //导入依赖的package包/类
@NotNull
@Override
public BalloonBuilder createDialogBalloonBuilder(@NotNull JComponent content, String title) {
  final BalloonPopupBuilderImpl builder = new BalloonPopupBuilderImpl(myStorage, content);
  final Color bg = UIManager.getColor("Panel.background");
  final Color borderOriginal = Color.darkGray;
  final Color border = ColorUtil.toAlpha(borderOriginal, 75);
  builder
    .setDialogMode(true)
    .setTitle(title)
    .setAnimationCycle(200)
    .setFillColor(bg)
    .setBorderColor(border)
    .setHideOnClickOutside(false)
    .setHideOnKeyOutside(false)
    .setHideOnAction(false)
    .setCloseButtonEnabled(true)
    .setShadow(true);

  return builder;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:PopupFactoryImpl.java


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