Java Code Examples for com.intellij.ui.Gray

The following are top voted examples for showing how to use com.intellij.ui.Gray. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: intellij-ce-playground   File: CompilerUIConfigurable.java   Source Code and License 6 votes vote down vote up
public CompilerUIConfigurable(@NotNull final Project project) {
  myProject = project;

  myPatternLegendLabel.setText(XmlStringUtil.wrapInHtml(
                                 "Use <b>;</b> to separate patterns and <b>!</b> to negate a pattern. " +
                                 "Accepted wildcards: <b>?</b> &mdash; exactly one symbol; <b>*</b> &mdash; zero or more symbols; " +
                                 "<b>/</b> &mdash; path separator; <b>/**/</b> &mdash; any number of directories; " +
                                 "<i>&lt;dir_name&gt;</i>:<i>&lt;pattern&gt;</i> &mdash; restrict to source roots with the specified name"
  ));
  myPatternLegendLabel.setForeground(new JBColor(Gray._50, Gray._130));
  tweakControls(project);
  myVMOptionsField.getDocument().addDocumentListener(new DocumentAdapter() {
    protected void textChanged(DocumentEvent e) {
      mySharedVMOptionsField.setEnabled(e.getDocument().getLength() == 0);
      myHeapSizeField.setEnabled(ContainerUtil.find(ParametersListUtil.parse(myVMOptionsField.getText()), new Condition<String>() {
        @Override
        public boolean value(String s) {
          return StringUtil.startsWithIgnoreCase(s, "-Xmx");
        }
      }) == null);
    }
  });
}
 
Example 2
Project: intellij-ce-playground   File: ZoomingDelegate.java   Source Code and License 6 votes vote down vote up
public void paint(Graphics g) {
  if (myCachedImage != null && myMagnificationPoint != null && myMagnification != 0) {
    double scale = magnificationToScale(myMagnification);
    int xoffset = (int)(myMagnificationPoint.x - myMagnificationPoint.x * scale);
    int yoffset = (int)(myMagnificationPoint.y - myMagnificationPoint.y * scale);

    Rectangle clip = g.getClipBounds();

    g.setColor(Gray._120);
    g.fillRect(clip.x, clip.y, clip.width, clip.height);

    Graphics2D translated = (Graphics2D)g.create();
    translated.translate(xoffset, yoffset);
    translated.scale(scale, scale);

    UIUtil.drawImage(translated, myCachedImage, 0, 0, null);
  }
}
 
Example 3
Project: intellij-ce-playground   File: StatusBarUI.java   Source Code and License 6 votes vote down vote up
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
  final Graphics2D g2d = (Graphics2D) g.create();

  final Color background = UIUtil.getPanelBackground();

  g2d.setColor(background);
  g2d.fillRect(0, 0, width, height);

  Color topColor = UIUtil.isUnderDarcula() ? BORDER_TOP_COLOR.darker().darker() : BORDER_TOP_COLOR;
  if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
    topColor = Gray.xC9;
  }
  g2d.setColor(topColor);
  g2d.drawLine(0, 0, width, 0);

  if (!UIUtil.isUnderDarcula()) {
    g2d.setColor(BORDER_BOTTOM_COLOR);
    g2d.drawLine(0, height, width, height);
  }

  g2d.dispose();
}
 
Example 4
Project: intellij-ce-playground   File: FloatingDecorator.java   Source Code and License 6 votes vote down vote up
public final void paint(final Graphics g){
  super.paint(g);
  final JBColor lightGray = new JBColor(Color.lightGray, Gray._95);
  final JBColor gray = new JBColor(Color.gray, Gray._95);
  if(ANCHOR_TOP==myAnchor){
    g.setColor(lightGray);
    UIUtil.drawLine(g, 0, 0, getWidth() - 1, 0);
    UIUtil.drawLine(g, 0, 0, 0, getHeight() - 1);
    g.setColor(JBColor.GRAY);
    UIUtil.drawLine(g, getWidth() - 1, 0, getWidth() - 1, getHeight() - 1);
  } else if(ANCHOR_LEFT==myAnchor){
    g.setColor(lightGray);
    UIUtil.drawLine(g, 0, 0, 0, getHeight() - 1);
  } else {
    if(ANCHOR_BOTTOM==myAnchor){
      g.setColor(lightGray);
      UIUtil.drawLine(g, 0, 0, 0, getHeight() - 1);
      g.setColor(gray);
      UIUtil.drawLine(g, 0, getHeight() - 1, getWidth() - 1, getHeight() - 1);
      UIUtil.drawLine(g, getWidth() - 1, 0, getWidth() - 1, getHeight() - 1);
    } else{ // RIGHT
      g.setColor(gray);
      UIUtil.drawLine(g, getWidth() - 1, 0, getWidth() - 1, getHeight() - 1);
    }
  }
}
 
Example 5
Project: intellij-ce-playground   File: IdeMenuBar.java   Source Code and License 6 votes vote down vote up
@Override
public Border getBorder() {
  //avoid moving lines
  if (myState == State.EXPANDING || myState == State.COLLAPSING) {
    return new EmptyBorder(0,0,0,0);
  }

  //fix for Darcula double border
  if (myState == State.TEMPORARY_EXPANDED && UIUtil.isUnderDarcula()) {
    return new CustomLineBorder(Gray._75, 0, 0, 1, 0);
  }

  //save 1px for mouse handler
  if (myState == State.COLLAPSED) {
    return new EmptyBorder(0, 0, 1, 0);
  }

  return UISettings.getInstance().SHOW_MAIN_TOOLBAR || UISettings.getInstance().SHOW_NAVIGATION_BAR ? super.getBorder() : null;
}
 
Example 6
Project: intellij-ce-playground   File: EditorEmptyTextPainter.java   Source Code and License 6 votes vote down vote up
public void paintEmptyText(@NotNull final JComponent splitters, @NotNull Graphics g) {
  UISettings.setupAntialiasing(g);
  g.setColor(new JBColor(Gray._80, Gray._160));
  g.setFont(JBUI.Fonts.label(16f));
  UIUtil.TextPainter painter = new UIUtil.TextPainter().withLineSpacing(1.8f);
  advertiseActions(splitters, painter);
  painter.draw(g, new PairFunction<Integer, Integer, Couple<Integer>>() {
    @Override
    public Couple<Integer> fun(Integer width, Integer height) {
      Dimension s = splitters.getSize();
      int w = (s.width - width) / 2;
      int h = s.height * 3 / 8; // fix vertical position @ golden ratio
      return Couple.of(w, h);
    }
  });
}
 
Example 7
Project: intellij-ce-playground   File: ActionToolbarImpl.java   Source Code and License 6 votes vote down vote up
@Override
protected void paintComponent(final Graphics g) {
  final Insets i = getInsets();
  if (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula()) {
    if (getParent() != null) {
      final JBColor col = new JBColor(Gray._128, Gray._111);
      final Graphics2D g2 = (Graphics2D)g;
      if (myOrientation == SwingConstants.HORIZONTAL) {
        UIUtil.drawDoubleSpaceDottedLine(g2, i.top + 2, getParent().getSize().height - 2 - i.top - i.bottom, 3, col, false);
      } else {
        UIUtil.drawDoubleSpaceDottedLine(g2, i.left + 2, getParent().getSize().width - 2 - i.left - i.right, 3, col, true);
      }
    }
  }
  else {
    g.setColor(UIUtil.getSeparatorColor());
    if (getParent() != null) {
      if (myOrientation == SwingConstants.HORIZONTAL) {
        UIUtil.drawLine(g, 3, 2, 3, getParent().getSize().height - 2);
      }
      else {
        UIUtil.drawLine(g, 2, 3, getParent().getSize().width - 2, 3);
      }
    }
  }
}
 
Example 8
Project: intellij-ce-playground   File: PreviewManagerImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void paint(Graphics g) {
  boolean isDarkBackground = UIUtil.isUnderDarcula();
  UISettings.setupAntialiasing(g);
  g.setColor(new JBColor(isDarkBackground ? Gray._230 : Gray._80, Gray._160));
  g.setFont(JBUI.Fonts.label(isDarkBackground ? 24f : 20f));

  UIUtil.TextPainter painter = new UIUtil.TextPainter().withLineSpacing(1.5f);
  painter.withShadow(true, new JBColor(Gray._200.withAlpha(100), Gray._0.withAlpha(255)));

  painter.appendLine("No files are open");//.underlined(new JBColor(Gray._150, Gray._180));
  painter.draw(g, new PairFunction<Integer, Integer, Couple<Integer>>() {
    @Override
    public Couple<Integer> fun(Integer width, Integer height) {
      Dimension s = EmptyStatePanel.this.getSize();
      return Couple.of((s.width - width) / 2, (s.height - height) / 2);
    }
  });
}
 
Example 9
Project: intellij-ce-playground   File: BegCellRenderer.java   Source Code and License 6 votes vote down vote up
protected void paintNode(Graphics g) {
  Color color;
  if (mySelected) {
    if (myHasFocus){
      color = getSelectionBackground();
    }
    else{
      color = Gray._223;
    }
  }
  else{
    color = getTextBackground();
    if (color == null){
      color = getBackground();
    }
  }
  if (color != null){
    int i1 = getBorderLeft();
    g.setColor(color);
    g.fillRect(i1 - 1, 0, getWidth() - i1, getHeight());
  }
}
 
Example 10
Project: intellij-ce-playground   File: AboutPopup.java   Source Code and License 6 votes vote down vote up
public void render(int indentX, int indentY, List<AboutBoxLine> lines) throws OverflowException {
  x = indentX;
  y = indentY;
  ApplicationInfoEx appInfo = (ApplicationInfoEx)ApplicationInfo.getInstance();
  for (AboutBoxLine line : lines) {
    final String s = line.getText();
    setFont(line.isBold() ? myBoldFont : myFont);
    if (line.getUrl() != null) {
      g2.setColor(myLinkColor);
      FontMetrics metrics = g2.getFontMetrics(font);
      myLinks.add(new Link(new Rectangle(x, yBase + y - fontAscent, metrics.stringWidth(s), fontHeight), line.getUrl()));
    }
    else {
      g2.setColor(Registry.is("ide.new.about") ? Gray.x33 : appInfo.getAboutForeground());
    }
    renderString(s, indentX);
    if (!line.isKeepWithNext() && !line.equals(lines.get(lines.size()-1))) {
      lineFeed(indentX, s);
    }
  }
}
 
Example 11
Project: intellij-ce-playground   File: MacIntelliJTextBorder.java   Source Code and License 6 votes vote down vote up
@Override
public void paintBorder(Component c, Graphics g2d, int x, int y, int width, int height) {
  if (TextFieldWithPopupHandlerUI.isSearchField(c)) {
    return;
  }
  Graphics2D g = (Graphics2D)g2d;
  //todo[kb]: make a better solution
  if (c.getParent() instanceof JComboBox) return;
  if (c.hasFocus()) {
    MacIntelliJBorderPainter.paintBorder(c, g, 0, 0, c.getWidth(), c.getHeight());
  }
  if (!IntelliJLaf.isGraphite() || !c.hasFocus()) {
    g.setColor(Gray.xB4);
    g.drawRect(3, 3, c.getWidth() - 6, c.getHeight() - 6);
  }
}
 
Example 12
Project: intellij-ce-playground   File: PluginHeaderPanel.java   Source Code and License 6 votes vote down vote up
public PluginHeaderPanel(@Nullable PluginManagerMain manager) {
  myManager = manager;
  final Font font = myName.getFont();
  myName.setFont(new Font(font.getFontName(), font.getStyle(), font.getSize() + 2));
  final JBColor greyed = new JBColor(Gray._130, Gray._200);
  myCategory.setForeground(greyed);
  myDownloads.setForeground(greyed);
  myUpdated.setForeground(greyed);
  myVersion.setForeground(greyed);
  final Font smallFont = new Font(font.getFontName(), font.getStyle(), font.getSize() - 1);
  myCategory.setFont(smallFont);
  myVersion.setFont(smallFont);
  myDownloads.setFont(smallFont);
  myUpdated.setFont(smallFont);
  myRoot.setVisible(false);
}
 
Example 13
Project: intellij-ce-playground   File: ColorIcon.java   Source Code and License 6 votes vote down vote up
@Override
public void paintIcon(final Component component, final Graphics g, final int i, final int j) {
  final int iconWidth = getIconWidth();
  final int iconHeight = getIconHeight();
  g.setColor(getIconColor());
  
  final int x = i + (iconWidth - myColorSize) / 2;
  final int y = j + (iconHeight - myColorSize) / 2;
  
  g.fillRect(x, y, myColorSize, myColorSize);
  
  if (myBorder) {
    g.setColor(Gray.x00.withAlpha(40));
    g.drawRect(x, y, myColorSize, myColorSize);
  }
}
 
Example 14
Project: intellij-ce-playground   File: BreadcrumbsXmlWrapper.java   Source Code and License 6 votes vote down vote up
@Override
public void itemHovered(@Nullable BreadcrumbsPsiItem item) {
  if (!Registry.is("editor.breadcrumbs.highlight.on.hover")) {
    return;
  }

  HighlightManager hm = HighlightManager.getInstance(myProject);
  if (myHighlighed != null) {
    for (RangeHighlighter highlighter : myHighlighed) {
      hm.removeSegmentHighlighter(myEditor, highlighter);
    }
    myHighlighed = null;
  }
  if (item != null) {
    final TextRange range = item.getPsiElement().getTextRange();
    final TextAttributes attributes = new TextAttributes();
    final CrumbPresentation p = item.getPresentation();
    final Color color = p != null ? p.getBackgroundColor(false, false, false) : BreadcrumbsComponent.ButtonSettings.DEFAULT_BG_COLOR;
    final Color background = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.CARET_ROW_COLOR);
    attributes.setBackgroundColor(XmlTagTreeHighlightingUtil.makeTransparent(color, background != null ? background : Gray._200, 0.3));
    myHighlighed = new ArrayList<RangeHighlighter>(1);
    int flags = HighlightManager.HIDE_BY_ESCAPE | HighlightManager.HIDE_BY_TEXT_CHANGE | HighlightManager.HIDE_BY_ANY_KEY;
    hm.addOccurrenceHighlight(myEditor, range.getStartOffset(), range.getEndOffset(), attributes, flags, myHighlighed, null);
  }
}
 
Example 15
Project: intellij-ce-playground   File: ColorComponent.java   Source Code and License 6 votes vote down vote up
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
  if (myColor.getAlpha() != 0xff) {
    final RoundRectangle2D.Double clip =
      new RoundRectangle2D.Double(x, y, myCellSize, myCellSize, ARC_SIZE, ARC_SIZE);
    GraphicsUtil.paintCheckeredBackground(g, clip);
  }

  g.setColor(myColor);
  g.fillRoundRect(x, y, myCellSize, myCellSize, ARC_SIZE, ARC_SIZE);

  myColor.getRGBComponents(myRgbaArray);
  if (Math.pow(1.0 - myRgbaArray[0], 2) + Math.pow(1.0 - myRgbaArray[1], 2) + Math.pow(1.0 - myRgbaArray[2], 2) < THRESHOLD_SQUARED_DISTANCE) {
    // Drawing a border to avoid displaying white boxes on a white background
    g.setColor(Gray._239);
    g.drawRoundRect(x, y, myCellSize, myCellSize - 1, ARC_SIZE, ARC_SIZE);
  }
}
 
Example 16
Project: intellij-ce-playground   File: IdeaDecompiler.java   Source Code and License 6 votes vote down vote up
@Nullable
@Override
protected JComponent createCenterPanel() {
  JPanel iconPanel = new JBPanel(new BorderLayout());
  iconPanel.add(new JBLabel(AllIcons.General.WarningDialog), BorderLayout.NORTH);

  myMessage = new JEditorPane();
  myMessage.setEditorKit(UIUtil.getHTMLEditorKit());
  myMessage.setEditable(false);
  myMessage.setPreferredSize(JBUI.size(500, 100));
  myMessage.setBorder(BorderFactory.createLineBorder(Gray._200));
  String text = "<div style='margin:5px;'>" + IdeaDecompilerBundle.message("legal.notice.text") + "</div>";
  myMessage.setText(text);

  JPanel panel = new JBPanel(new BorderLayout(10, 0));
  panel.add(iconPanel, BorderLayout.WEST);
  panel.add(myMessage, BorderLayout.CENTER);
  return panel;
}
 
Example 17
Project: material-theme-jetbrains   File: UIReplacer.java   Source Code and License 6 votes vote down vote up
static void patchStatusBar() throws Exception {
  if (MTConfig.getInstance().isMaterialTheme()) {
    // Replace Gray with a clear and transparent color
    final Gray gray = Gray._85;
    final Color alphaGray = gray.withAlpha(1);
    StaticPatcher.setFinalStatic(Gray.class, "_85", alphaGray);
    StaticPatcher.setFinalStatic(Gray.class, "_40", alphaGray);
    StaticPatcher.setFinalStatic(Gray.class, "_145", alphaGray);
    //        StaticPatcher.setFinalStatic(Gray.class, "_255", alphaGray);
    StaticPatcher.setFinalStatic(Gray.class, "_201", alphaGray);

    // Quick info border
    StaticPatcher.setFinalStatic(Gray.class, "_90", gray.withAlpha(25));

    // tool window color
    final boolean dark = MTConfig.getInstance().getSelectedTheme().isDark();
    StaticPatcher.setFinalStatic(Gray.class, "_15", dark ? Gray._15.withAlpha(255) : Gray._200.withAlpha(15));
    // This thing doesnt work on compiled jars...
    final Class<?> clazz = Class.forName("com.intellij.openapi.wm.impl.status.StatusBarUI$BackgroundPainter");

    StaticPatcher.setFinalStatic(clazz, "BORDER_TOP_COLOR", UIManager.getColor("StatusBar.topColor").brighter().brighter());
    StaticPatcher.setFinalStatic(clazz, "BORDER2_TOP_COLOR", UIManager.getColor("StatusBar.topColor2"));
    StaticPatcher.setFinalStatic(clazz, "BORDER_BOTTOM_COLOR", UIManager.getColor("StatusBar.bottomColor"));
    StaticPatcher.setFinalStatic(SettingsTreeView.class, "FOREGROUND", UIManager.getColor("Tree.foreground"));
  }
}
 
Example 18
Project: GitToolBox   File: ColoredNodeDecoration.java   Source Code and License 6 votes vote down vote up
private ColoredFragment makeStatusFragment(boolean prefix) {
  int style = SimpleTextAttributes.STYLE_PLAIN;
  if (config.projectViewStatusBold) {
    style |= SimpleTextAttributes.STYLE_BOLD;
  }
  if (config.projectViewStatusItalic) {
    style |= SimpleTextAttributes.STYLE_ITALIC;
  }
  Color color = config.projectViewStatusCustomColor ? config.getProjectViewStatusColor() : Gray._128;
  SimpleTextAttributes attributes = new SimpleTextAttributes(style, color);
  StringBand status = getStatusText();
  if (prefix) {
    String statusTemp = status.toString();
    status.setIndex(0);
    status.append(FontUtil.spaceAndThinSpace()).append(statusTemp);
  }
  return new ColoredFragment(status.toString(), attributes);
}
 
Example 19
Project: tools-idea   File: CompilerUIConfigurable.java   Source Code and License 6 votes vote down vote up
public CompilerUIConfigurable(@NotNull final Project project) {
  myProject = project;

  myPatternLegendLabel.setText("<html><body>" +
                               "Use <b>;</b> to separate patterns and <b>!</b> to negate a pattern. " +
                               "Accepted wildcards: <b>?</b> &mdash; exactly one symbol; <b>*</b> &mdash; zero or more symbols; " +
                               "<b>/</b> &mdash; path separator; <b>/**/</b> &mdash; any number of directories; " +
                               "<i>&lt;dir_name&gt;</i>:<i>&lt;pattern&gt;</i> &mdash; restrict to source roots with the specified name" +
                               "</body></html>");
  myPatternLegendLabel.setForeground(new JBColor(Gray._50, Gray._130));
  myCbUseExternalBuild.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      updateExternalMakeOptionControls(myCbUseExternalBuild.isSelected());
    }
  });

  tweakControls(project);
}
 
Example 20
Project: tools-idea   File: DarculaEditorTabsPainter.java   Source Code and License 6 votes vote down vote up
@Override
public void doPaintInactive(Graphics2D g2d,
                            Rectangle effectiveBounds,
                            int x,
                            int y,
                            int w,
                            int h,
                            Color tabColor,
                            int row,
                            int column,
                            boolean vertical) {
  if (tabColor != null) {
    g2d.setColor(tabColor);
    g2d.fillRect(x, y, w, h);
  } else {
    g2d.setPaint(UIUtil.getControlColor());
    g2d.fillRect(x, y, w, h);
  }

  g2d.setColor(Gray._0.withAlpha(10));
  g2d.drawRect(x, y, w - 1, h - 1);
}
 
Example 21
Project: tools-idea   File: DarculaEditorTabsPainter.java   Source Code and License 6 votes vote down vote up
@Override
public void doPaintBackground(Graphics2D g, Rectangle clip, boolean vertical, Rectangle rectangle) {
  g.setColor(UIUtil.getPanelBackground());
  g.fill(clip);

  g.setColor(new Color(0, 0, 0, 80));
  g.fill(clip);

  final int x = rectangle.x;
  final int y = rectangle.y;
  final int h = rectangle.height;
  g.setPaint(UIUtil.getGradientPaint(x, y, Gray._78.withAlpha(160), x, y + h, Gray._78.withAlpha(120)));
  final int w = rectangle.width;
  g.fillRect(x, rectangle.y, w, h + (vertical ? 1 : 0));

  if (!vertical) {
    g.setColor(Gray._78);
    g.drawLine(x, rectangle.y, x + w, rectangle.y);
  }
}
 
Example 22
Project: tools-idea   File: DefaultEditorTabsPainter.java   Source Code and License 6 votes vote down vote up
@Override
public void doPaintBackground(Graphics2D g, Rectangle clip, boolean vertical, Rectangle rectangle) {
  g.setColor(UIUtil.getPanelBackground());
  g.fill(clip);

  g.setColor(new Color(0, 0, 0, 80));
  g.fill(clip);

  final int x = rectangle.x;
  final int y = rectangle.y;
  g.setPaint(UIUtil.getGradientPaint(x, y, new Color(255, 255, 255, 160),
                               x, rectangle.y + rectangle.height, new Color(255, 255, 255, 120)));
  g.fillRect(x, rectangle.y, rectangle.width, rectangle.height + (vertical ? 1 : 0));

  if (!vertical) {
    g.setColor(Gray._210);
    g.drawLine(x, rectangle.y, x + rectangle.width, rectangle.y);

    drawShadow(g, rectangle.x, rectangle.width, rectangle.y + rectangle.height);
  }
}
 
Example 23
Project: tools-idea   File: ZoomingDelegate.java   Source Code and License 6 votes vote down vote up
public void paint(Graphics g) {
  if (myCachedImage != null && myMagnificationPoint != null && myMagnification != 0) {
    double scale = magnificationToScale(myMagnification);
    int xoffset = (int)(myMagnificationPoint.x - myMagnificationPoint.x * scale);
    int yoffset = (int)(myMagnificationPoint.y - myMagnificationPoint.y * scale);

    Rectangle clip = g.getClipBounds();

    g.setColor(Gray._120);
    g.fillRect(clip.x, clip.y, clip.width, clip.height);

    Graphics2D translated = (Graphics2D)g.create();
    translated.translate(xoffset, yoffset);
    translated.scale(scale, scale);

    UIUtil.drawImage(translated, myCachedImage, 0, 0, null);
  }
}
 
Example 24
Project: tools-idea   File: FloatingDecorator.java   Source Code and License 6 votes vote down vote up
public final void paint(final Graphics g){
  super.paint(g);
  final JBColor lightGray = new JBColor(Color.lightGray, Gray._95);
  final JBColor gray = new JBColor(Color.gray, Gray._95);
  if(ANCHOR_TOP==myAnchor){
    g.setColor(lightGray);
    UIUtil.drawLine(g, 0, 0, getWidth() - 1, 0);
    UIUtil.drawLine(g, 0, 0, 0, getHeight() - 1);
    g.setColor(JBColor.GRAY);
    UIUtil.drawLine(g, getWidth() - 1, 0, getWidth() - 1, getHeight() - 1);
  } else if(ANCHOR_LEFT==myAnchor){
    g.setColor(lightGray);
    UIUtil.drawLine(g, 0, 0, 0, getHeight() - 1);
  } else {
    if(ANCHOR_BOTTOM==myAnchor){
      g.setColor(lightGray);
      UIUtil.drawLine(g, 0, 0, 0, getHeight() - 1);
      g.setColor(gray);
      UIUtil.drawLine(g, 0, getHeight() - 1, getWidth() - 1, getHeight() - 1);
      UIUtil.drawLine(g, getWidth() - 1, 0, getWidth() - 1, getHeight() - 1);
    } else{ // RIGHT
      g.setColor(gray);
      UIUtil.drawLine(g, getWidth() - 1, 0, getWidth() - 1, getHeight() - 1);
    }
  }
}
 
Example 25
Project: tools-idea   File: IdeMenuBar.java   Source Code and License 6 votes vote down vote up
@Override
public Border getBorder() {
  //avoid moving lines
  if (myState == State.EXPANDING || myState == State.COLLAPSING) {
    return new EmptyBorder(0,0,0,0);
  }

  //fix for Darcula double border
  if (myState == State.TEMPORARY_EXPANDED && UIUtil.isUnderDarcula()) {
    return new CustomLineBorder(Gray._75, 0, 0, 1, 0);
  }

  //save 1px for mouse handler
  if (myState == State.COLLAPSED) {
    return new EmptyBorder(0, 0, 1, 0);
  }

  return super.getBorder();
}
 
Example 26
Project: tools-idea   File: FileEditorManagerImpl.java   Source Code and License 6 votes vote down vote up
private void initUI() {
  if (myPanels == null) {
    synchronized (myInitLock) {
      if (myPanels == null) {
        myPanels = new JPanel(new BorderLayout()) {
          @Override
          public Color getBackground() {
            boolean navBar = UISettings.getInstance().SHOW_NAVIGATION_BAR;
            if (navBar) {
              return  UIUtil.getSlightlyDarkerColor(UIUtil.isUnderAquaLookAndFeel() ? Gray._200 : UIUtil.getPanelBackground());
            } else {
              return UIUtil.isUnderAquaLookAndFeel() ? Gray._189 : UIUtil.getPanelBackground();
            }
          }
        };
        myPanels.setBorder(new MyBorder());
        mySplitters = new EditorsSplitters(this, myDockManager, true);
        myPanels.add(mySplitters, BorderLayout.CENTER);
      }
    }
  }
}
 
Example 27
Project: tools-idea   File: ActionToolbarImpl.java   Source Code and License 6 votes vote down vote up
@Override
protected void paintComponent(final Graphics g) {
  final Insets i = getInsets();
  if (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula()) {
    if (getParent() != null) {
      final JBColor col = new JBColor(Color.GRAY, Gray._111);
      final Graphics2D g2 = (Graphics2D)g;
      if (myOrientation == SwingConstants.HORIZONTAL) {
        UIUtil.drawDoubleSpaceDottedLine(g2, i.top + 2, getParent().getSize().height - 2 - i.top - i.bottom, 3, col, false);
      } else {
        UIUtil.drawDoubleSpaceDottedLine(g2, i.left + 2, getParent().getSize().width - 2 - i.left - i.right, 3, col, true);
      }
    }
  }
  else {
    g.setColor(UIUtil.getSeparatorColor());
    if (getParent() != null) {
      if (myOrientation == SwingConstants.HORIZONTAL) {
        UIUtil.drawLine(g, 3, 2, 3, getParent().getSize().height - 2);
      }
      else {
        UIUtil.drawLine(g, 2, 3, getParent().getSize().width - 2, 3);
      }
    }
  }
}
 
Example 28
Project: tools-idea   File: EditorHeaderComponent.java   Source Code and License 6 votes vote down vote up
@Override
protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  Color GRADIENT_C1 = new JBColor(getBackground(), JBColor.background());
  Color GRADIENT_C2 = new JBColor(new Color(Math.max(0, GRADIENT_C1.getRed() - 0x18), Math.max(0, GRADIENT_C1.getGreen() - 0x18),
                                            Math.max(0, GRADIENT_C1.getBlue() - 0x18)), Gray._75);

  final Graphics2D g2d = (Graphics2D)g;

  if (!UIUtil.isUnderGTKLookAndFeel()) {
    g2d.setPaint(UIUtil.getGradientPaint(0, 0, GRADIENT_C1, 0, getHeight(), GRADIENT_C2));
    g2d.fillRect(1, 1, getWidth(), getHeight() - 1);
    g2d.setPaint(null);
  }

  g.setColor(UIUtil.getBorderColor());
  g.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
}
 
Example 29
Project: tools-idea   File: BegCellRenderer.java   Source Code and License 6 votes vote down vote up
protected void paintNode(Graphics g) {
  Color color;
  if (mySelected) {
    if (myHasFocus){
      color = getSelectionBackground();
    }
    else{
      color = Gray._223;
    }
  }
  else{
    color = getTextBackground();
    if (color == null){
      color = getBackground();
    }
  }
  if (color != null){
    int i1 = getBorderLeft();
    g.setColor(color);
    g.fillRect(i1 - 1, 0, getWidth() - i1, getHeight());
  }
}
 
Example 30
Project: tools-idea   File: DarculaButtonPainter.java   Source Code and License 6 votes vote down vote up
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  final Graphics2D g2d = (Graphics2D)g;
  final Insets ins = getBorderInsets(c);
  final int yOff = (ins.top + ins.bottom) / 4;
  int offset = getOffset();
  if (c.hasFocus()) {
    DarculaUIUtil.paintFocusRing(g2d, offset, yOff, width - 2 * offset, height - 2 * yOff);
  } else {
    final GraphicsConfig config = new GraphicsConfig(g);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
    g2d.setPaint(
      UIUtil.getGradientPaint(width / 2, y + yOff + 1, Gray._80.withAlpha(90), width / 2, height - 2 * yOff, Gray._90.withAlpha(90)));
    //g.drawRoundRect(x + offset + 1, y + yOff + 1, width - 2 * offset, height - 2*yOff, 5, 5);

    ((Graphics2D)g).setPaint(Gray._100.withAlpha(180));
    g.drawRoundRect(x + offset, y + yOff, width - 2 * offset, height - 2*yOff, 5, 5);

    config.restore();
  }
}
 
Example 31
Project: tools-idea   File: DarculaTextBorder.java   Source Code and License 6 votes vote down vote up
@Override
public void paintBorder(Component c, Graphics g2, int x, int y, int width, int height) {
  if (DarculaTextFieldUI.isSearchField(c)) return;
  Graphics2D g = ((Graphics2D)g2);
  final GraphicsConfig config = new GraphicsConfig(g);
  g.translate(x, y);

  if (c.hasFocus()) {
    DarculaUIUtil.paintFocusRing(g, 2, 2, width-4, height-4);
  } else {
    boolean editable = !(c instanceof JTextComponent) || (((JTextComponent)c).isEditable());
    g.setColor(c.isEnabled() && editable ? Gray._100 : new Color(0x535353));
    g.drawRect(1, 1, width - 2, height - 2);
  }
  g.translate(-x, -y);
  config.restore();
}
 
Example 32
Project: tools-idea   File: JBRunnerTabs.java   Source Code and License 6 votes vote down vote up
@Override
protected void doPaintInactive(Graphics2D g2d,
                               boolean leftGhostExists,
                               TabLabel label,
                               Rectangle effectiveBounds,
                               boolean rightGhostExists, int row, int column) {
  Insets insets = getTabsBorder().getEffectiveBorder();
  final boolean dark = UIUtil.isUnderDarcula();
  int _x = effectiveBounds.x + insets.left;
  int _y = effectiveBounds.y + insets.top + 3;
  int _width = effectiveBounds.width - insets.left - insets.right;
  int _height = effectiveBounds.height - insets.top - insets.bottom - 3;
  _height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
  if (dark) {
    g2d.setPaint(UIUtil.getGradientPaint(_x, _y, ColorUtil.shift(UIUtil.getListBackground(), 1.3), _x, _y + effectiveBounds.height, UIUtil.getPanelBackground()));
    g2d.fillRect(_x, _y, _width, _height);

    g2d.setColor(Gray._0.withAlpha(50));
  } else {
    g2d.setPaint(UIUtil.getGradientPaint(_x, _y, new Color(255, 255, 255, 180), _x, _y + effectiveBounds.height, new Color(255, 255, 255, 100)));
    g2d.fillRect(_x, _y, _width, _height);

    g2d.setColor(new Color(255, 255, 255, 100));
    g2d.drawRect(_x, _y, _width - 1, _height - 1);
  }
}
 
Example 33
Project: jediterm   File: ZoomingDelegate.java   Source Code and License 6 votes vote down vote up
public void paint(Graphics g) {
  if (myCachedImage != null && myMagnificationPoint != null && myMagnification != 0) {
    double scale = magnificationToScale(myMagnification);
    int xoffset = (int)(myMagnificationPoint.x - myMagnificationPoint.x * scale);
    int yoffset = (int)(myMagnificationPoint.y - myMagnificationPoint.y * scale);

    Rectangle clip = g.getClipBounds();

    g.setColor(Gray._120);
    g.fillRect(clip.x, clip.y, clip.width, clip.height);

    Graphics2D translated = (Graphics2D)g.create();
    translated.translate(xoffset, yoffset);
    translated.scale(scale, scale);

    UIUtil.drawImage(translated, myCachedImage, 0, 0, null);
  }
}
 
Example 34
Project: consulo   File: ActionButtonUI.java   Source Code and License 6 votes vote down vote up
protected void paintBackground(ActionButton button, Graphics g, Dimension size, int state) {
  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.PUSHED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, size.width, size.height, ALPHA_20));
      g.fillRect(0, 0, size.width - 1, size.height - 1);

      g.setColor(ALPHA_120);
      g.drawLine(0, 0, 0, size.height - 2);
      g.drawLine(1, 0, size.width - 2, 0);

      g.setColor(ALPHA_30);
      g.drawRect(1, 1, size.width - 3, size.height - 3);
    }
    else if (state == ActionButtonComponent.POPPED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, Gray._235, 0, size.height, Gray._200));
      g.fillRect(1, 1, size.width - 3, size.height - 3);
    }
  }
  else {
    final Color bg = UIUtil.getPanelBackground();
    final boolean dark = UIUtil.isUnderDarcula();
    g.setColor(state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40);
    g.fillRect(JBUI.scale(1), JBUI.scale(1), size.width - JBUI.scale(2), size.height - JBUI.scale(2));
  }
}
 
Example 35
Project: consulo   File: IntelliJEditorTabsUI.java   Source Code and License 6 votes vote down vote up
public void doPaintBackground(Graphics2D g, Rectangle clip, boolean vertical, Rectangle rectangle) {
  g.setColor(UIUtil.getPanelBackground());
  g.fill(clip);

  g.setColor(new Color(0, 0, 0, 80));
  g.fill(clip);

  final int x = rectangle.x;
  final int y = rectangle.y;
  g.setPaint(UIUtil.getGradientPaint(x, y, new Color(255, 255, 255, 160), x, rectangle.y + rectangle.height, new Color(255, 255, 255, 120)));
  g.fillRect(x, rectangle.y, rectangle.width, rectangle.height + (vertical ? 1 : 0));

  if (!vertical) {
    g.setColor(Gray._210);
    g.drawLine(x, rectangle.y, x + rectangle.width, rectangle.y);

    drawShadow(g, rectangle.x, rectangle.width, rectangle.y + rectangle.height);
  }
}
 
Example 36
Project: consulo   File: DarculaEditorTabsUI.java   Source Code and License 6 votes vote down vote up
@Override
public void doPaintInactiveImpl(Graphics2D g2d,
                                Rectangle effectiveBounds,
                                int x,
                                int y,
                                int w,
                                int h,
                                Color tabColor,
                                int row,
                                int column,
                                boolean vertical) {
  if (tabColor != null) {
    g2d.setColor(tabColor);
    g2d.fillRect(x, y, w, h);
  }
  else {
    g2d.setPaint(UIUtil.getControlColor());
    g2d.fillRect(x, y, w, h);
  }

  g2d.setColor(Gray._0.withAlpha(10));
  g2d.drawRect(x, y, w - 1, h - 1);
}
 
Example 37
Project: consulo   File: DarculaEditorTabsUI.java   Source Code and License 6 votes vote down vote up
@Override
public void doPaintBackground(Graphics2D g, Rectangle clip, boolean vertical, Rectangle rectangle) {
  g.setColor(UIUtil.getPanelBackground());
  g.fill(clip);

  g.setColor(new Color(0, 0, 0, 80));
  g.fill(clip);

  final int x = rectangle.x;
  final int y = rectangle.y;
  final int h = rectangle.height;
  g.setPaint(UIUtil.getGradientPaint(x, y, Gray._78.withAlpha(160), x, y + h, Gray._78.withAlpha(120)));
  final int w = rectangle.width;
  g.fillRect(x, rectangle.y, w, h + (vertical ? 1 : 0));

  if (!vertical) {
    g.setColor(Gray._78);
    g.drawLine(x, rectangle.y, x + w, rectangle.y);
  }
}
 
Example 38
Project: consulo   File: ModernButtonlessScrollBarUI.java   Source Code and License 6 votes vote down vote up
private void paintMaxiThumb(Graphics2D g, JComponent c, Rectangle thumbBounds) {
  final boolean vertical = isVertical();
  int hGap = 0;
  int vGap = 0;

  int w = thumbBounds.width;
  int h = thumbBounds.height;

  if (vertical) {
    vGap -= JBUI.scale(1);
    h += JBUI.scale(1);
  }
  else {
    hGap -= JBUI.scale(1);
    w += JBUI.scale(1);
  }

  g.setColor(adjustColor(new JBColor(Gray._230, Gray._80)));
  g.fillRect(hGap, vGap, w, h);

  g.setColor(new JBColor(Gray._201, Gray._85));
  g.drawRect(hGap, vGap, w, h);
}
 
Example 39
Project: consulo   File: ModernDarkEditorTabsUI.java   Source Code and License 6 votes vote down vote up
@Override
public void doPaintBackground(Graphics2D g, Rectangle clip, boolean vertical, Rectangle rectangle) {
  g.setColor(UIUtil.getPanelBackground());
  g.fill(clip);

  g.setColor(new Color(0, 0, 0, 80));
  g.fill(clip);

  final int x = rectangle.x;
  final int y = rectangle.y;
  final int h = rectangle.height;
  g.setPaint(Gray._78.withAlpha(120));
  final int w = rectangle.width;
  g.fillRect(x, rectangle.y, w, h + (vertical ? 1 : 0));

  if (!vertical) {
    g.setColor(Gray._78);
    g.drawLine(x, rectangle.y, x + w, rectangle.y);
  }
}
 
Example 40
Project: consulo   File: MacEditorTabsUI.java   Source Code and License 6 votes vote down vote up
@Override
public void doPaintBackground(Graphics2D g, Rectangle clip, boolean vertical, Rectangle rectangle) {
  g.setColor(UIUtil.getPanelBackground());
  g.fill(clip);

  g.setColor(new Color(0, 0, 0, 80));
  g.fill(clip);

  final int x = rectangle.x;
  final int y = rectangle.y;
  g.setPaint(new Color(255, 255, 255, 160));
  g.fillRect(x, rectangle.y, rectangle.width, rectangle.height + (vertical ? 1 : 0));

  if (!vertical) {
    g.setColor(Gray._210);
    g.drawLine(x, rectangle.y, x + rectangle.width, rectangle.y);

    drawShadow(g, rectangle.x, rectangle.width, rectangle.y + rectangle.height);
  }
}
 
Example 41
Project: consulo   File: ModernWhiteEditorTabsUI.java   Source Code and License 6 votes vote down vote up
@Override
public void doPaintBackground(Graphics2D g, Rectangle clip, boolean vertical, Rectangle rectangle) {
  g.setColor(UIUtil.getPanelBackground());
  g.fill(clip);

  g.setColor(new Color(0, 0, 0, 80));
  g.fill(clip);

  final int x = rectangle.x;
  final int y = rectangle.y;
  g.setPaint(new Color(255, 255, 255, 160));
  g.fillRect(x, rectangle.y, rectangle.width, rectangle.height + (vertical ? 1 : 0));

  if (!vertical) {
    g.setColor(Gray._210);
    g.drawLine(x, rectangle.y, x + rectangle.width, rectangle.y);

    drawShadow(g, rectangle.x, rectangle.width, rectangle.y + rectangle.height);
  }
}
 
Example 42
Project: consulo   File: IdeMenuBar.java   Source Code and License 6 votes vote down vote up
@Override
public Border getBorder() {
  //avoid moving lines
  if (myState == State.EXPANDING || myState == State.COLLAPSING) {
    return new EmptyBorder(0,0,0,0);
  }

  //fix for Darcula double border
  if (myState == State.TEMPORARY_EXPANDED && UIUtil.isUnderDarcula()) {
    return new CustomLineBorder(Gray._75, 0, 0, 1, 0);
  }

  //save 1px for mouse handler
  if (myState == State.COLLAPSED) {
    return new EmptyBorder(0, 0, 1, 0);
  }

  return UISettings.getInstance().SHOW_MAIN_TOOLBAR || UISettings.getInstance().SHOW_NAVIGATION_BAR ? super.getBorder() : null;
}
 
Example 43
Project: consulo   File: PoppedIcon.java   Source Code and License 6 votes vote down vote up
private static void paintBackground(Graphics g, Dimension size, int state) {
  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.PUSHED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, size.width, size.height, ALPHA_20));
      g.fillRect(0, 0, size.width - 1, size.height - 1);

      g.setColor(ALPHA_120);
      g.drawLine(0, 0, 0, size.height - 2);
      g.drawLine(1, 0, size.width - 2, 0);

      g.setColor(ALPHA_30);
      g.drawRect(1, 1, size.width - 3, size.height - 3);
    }
    else if (state == ActionButtonComponent.POPPED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, Gray._235, 0, size.height, Gray._200));
      g.fillRect(1, 1, size.width - 3, size.height - 3);
    }
  }
  else {
    final Color bg = UIUtil.getPanelBackground();
    final boolean dark = UIUtil.isUnderDarcula();
    g.setColor(state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40);
    g.fillRect(JBUI.scale(1), JBUI.scale(1), size.width - JBUI.scale(2), size.height - JBUI.scale(2));
  }
}
 
Example 44
Project: consulo   File: BegCellRenderer.java   Source Code and License 6 votes vote down vote up
protected void paintNode(Graphics g) {
  Color color;
  if (mySelected) {
    if (myHasFocus){
      color = getSelectionBackground();
    }
    else{
      color = Gray._223;
    }
  }
  else{
    color = getTextBackground();
    if (color == null){
      color = getBackground();
    }
  }
  if (color != null){
    int i1 = getBorderLeft();
    g.setColor(color);
    g.fillRect(i1 - 1, 0, getWidth() - i1, getHeight());
  }
}
 
Example 45
Project: consulo   File: DarculaTextBorder.java   Source Code and License 6 votes vote down vote up
@Override
public void paintBorder(Component c, Graphics g2, int x, int y, int width, int height) {
  if (DarculaTextFieldUI.isSearchField(c)) return;
  Graphics2D g = ((Graphics2D)g2);
  final GraphicsConfig config = new GraphicsConfig(g);
  g.translate(x, y);

  if (c.hasFocus()) {
    DarculaUIUtil.paintFocusRing(g, new Rectangle(JBUI.scale(2), JBUI.scale(2), width - JBUI.scale(4), height - JBUI.scale(4)));
  }
  else {
    boolean editable = !(c instanceof JTextComponent) || (((JTextComponent)c).isEditable());
    g.setColor(c.isEnabled() && editable ? Gray._100 : new Color(0x535353));
    g.drawRect(JBUI.scale(1), JBUI.scale(1), width - JBUI.scale(2), height - JBUI.scale(2));
  }
  g.translate(-x, -y);
  config.restore();
}
 
Example 46
Project: consulo   File: PluginHeaderPanel.java   Source Code and License 6 votes vote down vote up
public PluginHeaderPanel(@Nullable PluginManagerMain manager, JTable pluginTable) {
  myManager = manager;
  myPluginTable = pluginTable;
  final Font font = myName.getFont();
  myName.setFont(new Font(font.getFontName(), font.getStyle(), font.getSize() + 2));
  final JBColor greyed = new JBColor(Gray._130, Gray._200);
  myCategory.setForeground(greyed);
  myDownloads.setForeground(greyed);
  myUpdated.setForeground(greyed);
  myVersion.setForeground(greyed);
  final Font smallFont = new Font(font.getFontName(), font.getStyle(), font.getSize() - 1);
  myCategory.setFont(smallFont);
  myVersion.setFont(smallFont);
  myDownloads.setFont(smallFont);
  myUpdated.setFont(smallFont);
  myRoot.setVisible(false);
}
 
Example 47
Project: consulo   File: ColorIcon.java   Source Code and License 6 votes vote down vote up
@Override
public void paintIcon(final Component component, final Graphics g, final int i, final int j) {
  final int iconWidth = getIconWidth();
  final int iconHeight = getIconHeight();
  g.setColor(getIconColor());

  final int size = getColorSize();
  final int x = i + (iconWidth - size) / 2;
  final int y = j + (iconHeight - size) / 2;

  g.fillRect(x, y, size, size);

  if (myBorder) {
    g.setColor(Gray.x00.withAlpha(40));
    g.drawRect(x, y, size, size);
  }
}
 
Example 48
Project: consulo   File: SearchTextArea.java   Source Code and License 6 votes vote down vote up
@Override
void paint(Graphics2D g) {
  Rectangle r = new Rectangle(getSize());
  JBInsets.removeFrom(r, getInsets());
  if (r.height % 2 == 1) r.height++;
  int arcSize = JBUI.scale(26);

  JBInsets.removeFrom(r, new JBInsets(1, 1, 1, 1));
  if (myTextArea.hasFocus()) {
    g.setColor(myTextArea.getBackground());
    RectanglePainter.FILL.paint(g, r.x, r.y, r.width, r.height, arcSize);
    DarculaUIUtil.paintSearchFocusRing(g, r, myTextArea, arcSize);
  }
  else {
    arcSize -= JBUI.scale(5);
    RectanglePainter
            .paint(g, r.x, r.y, r.width, r.height, arcSize, myTextArea.getBackground(), myTextArea.isEnabled() ? Gray._100 : Gray._83);
  }
}
 
Example 49
Project: reasonml-idea-plugin   File: RmlEditorLinePainter.java   Source Code and License 5 votes vote down vote up
private static TextAttributes getNormalAttributes() {
    TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.INLINED_VALUES);
    if (attributes == null || attributes.getForegroundColor() == null) {
        return new TextAttributes(new JBColor(Gray._135, new Color(0x3d8065)), null, null, null, Font.ITALIC);
    }
    return attributes;
}
 
Example 50
Project: GoogleTranslation   File: RequestRunnable.java   Source Code and License 5 votes vote down vote up
private void showPopupBalloon(final String result) {
    ApplicationManager.getApplication().invokeLater(() -> {
        mEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null);//解决因为TranslationPlugin而导致的泡泡显示错位问题
        JBPopupFactory factory = JBPopupFactory.getInstance();
        factory.createHtmlTextBalloonBuilder(result, null, new JBColor(Gray._242, Gray._0), null)
                .createBalloon()
                .show(factory.guessBestPopupLocation(mEditor), Balloon.Position.below);
    });
}
 
Example 51
Project: intellij-ce-playground   File: JavadocGenerationPanel.java   Source Code and License 5 votes vote down vote up
private void handleSlider() {
  int value = myScopeSlider.getValue();

  Dictionary labelTable = myScopeSlider.getLabelTable();
  for (Enumeration enumeration = labelTable.keys();  enumeration.hasMoreElements();) {
    Integer key = (Integer)enumeration.nextElement();
    JLabel label = (JLabel)labelTable.get(key);
    label.setForeground(key.intValue() <= value ? Color.black : Gray._100);
  }
}
 
Example 52
Project: intellij-ce-playground   File: WizardArrowUI.java   Source Code and License 5 votes vote down vote up
@Override
public void paint(Graphics g, JComponent c) {
  int w = c.getWidth();
  int h = c.getHeight();
  layout(myButton, SwingUtilities2.getFontMetrics(c, g), w, h);

  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  h-=4;
  if (!myButton.isSelected()) {
    w-=15;
  }
  final Path2D.Double path = new GeneralPath.Double();
  path.moveTo(0, 0);
  path.lineTo(w - h / 2, 0);
  path.lineTo(w, h / 2);
  path.lineTo(w-h/2, h);
  path.lineTo(0, h);
  path.lineTo(0, 0);
  g.setColor(myButton.isSelected() ? UIUtil.getListSelectionBackground() : Gray._255.withAlpha(200));
  ((Graphics2D)g).fill(path);
  g.setColor(Gray._0.withAlpha(50));
  ((Graphics2D)g).draw(path);
  config.restore();
  textRect.x = 2;
  textRect.y-=7;
  c.setForeground(UIUtil.getListForeground(myButton.isSelected()));
  GraphicsUtil.setupAntialiasing(g);
  paintText(g, c, textRect, myButton.getText());
}
 
Example 53
Project: intellij-ce-playground   File: TitlePanel.java   Source Code and License 5 votes vote down vote up
protected void paintComponent(Graphics g) {
  super.paintComponent(g);
  Graphics2D g2 = (Graphics2D) g;
  int width = getSize().width;
  int height = getSize().height;
  Object oldAntialiasing = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2.setPaint(new JBColor(Gray._247, UIUtil.getPanelBackground()));
  RoundRectangle2D rect = new RoundRectangle2D.Double(0, 0, width - 1, height - 1, 0, 0);
  g2.fill(rect);
  g2.setPaint(new JBColor(Color.GRAY, Gray._100));
  UIUtil.drawLine(g2, 0, height - 1, width - 1, height - 1);
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasing);
}
 
Example 54
Project: intellij-ce-playground   File: FixedComboBoxEditor.java   Source Code and License 5 votes vote down vote up
@Override
public Color getBackground() {
  if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
    Container parent = getParent();
    if (parent != null && !parent.isEnabled()) {
      return Gray.xF8;
    }
  }
  return super.getBackground();
}
 
Example 55
Project: intellij-ce-playground   File: OnOffButton.java   Source Code and License 5 votes vote down vote up
@Override
    public void paint(Graphics gr, JComponent c) {
      final OnOffButton button = (OnOffButton)c;
      final Dimension size = button.getSize();
      int w = size.width-8;
      int h = size.height-6;
      if (h % 2 == 1) {
        h--;
      }
      Graphics2D g = ((Graphics2D)gr);
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      int xOff = (myButton.getWidth() - w) / 2;
      int yOff = (myButton.getHeight() - h) / 2;
      g.translate(xOff, yOff);
      if (button.isSelected()) {
        g.setColor(new JBColor(new Color(74, 146, 73), new Color(77, 105, 76)));
        g.fillRoundRect(0, 0, w, h, 5, 5);
        g.setColor(new JBColor(Gray._192, Gray._80));
        g.drawRoundRect(0, 0, w, h, 5, 5);
        g.setColor(new JBColor(Gray._200, Gray._100));
        g.fillRoundRect(w - h, 1, h, h-1, 3, 3);
        g.setColor(UIUtil.getListForeground(true));
        g.drawString(button.getOnText(), h/2, h - 4);
      } else {
        g.setColor(UIUtil.getPanelBackground());
        g.fillRoundRect(0, 0, w, h, 5, 5);
        g.setColor(new JBColor(Gray._192, Gray._100));
        g.drawRoundRect(0, 0, w, h, 5, 5);
        g.setColor(UIUtil.getLabelDisabledForeground());
        g.drawString(button.getOffText(), h + 4 , h - 4);
        g.setColor(UIUtil.getBorderColor());
        g.setPaint(new GradientPaint(h, 0, new JBColor(Gray._158, Gray._100), 0, h, new JBColor(Gray._210, Gray._100)));
        g.fillRoundRect(0, 0, h, h, 3, 3);
//        g.setColor(UIUtil.getBorderColor());
//        g.drawOval(0, 0, h, h);
      }
      g.translate(-xOff, -yOff);
    }
 
Example 56
Project: intellij-ce-playground   File: ButtonlessScrollBarUI.java   Source Code and License 5 votes vote down vote up
private void paintMacThumb(Graphics g, Rectangle thumbBounds) {
  if (isMacScrollbarHiddenAndXcodeLikeScrollbar()) return;

  thumbBounds = getMacScrollBarBounds(thumbBounds, true);
  Graphics2D g2d = (Graphics2D)g;
  RenderingHints oldHints = g2d.getRenderingHints();
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

  JBColor baseColor = new JBColor(new NotNullProducer<Color>() {
    @NotNull
    @Override
    public Color produce() {
      return !isDark() ? Gray._0 : Gray._128;
    }
  });
  
  int arc = Math.min(thumbBounds.width, thumbBounds.height);

  if (alwaysPaintThumb()) {
    //noinspection UseJBColor
    g2d.setColor(new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), isDark() ? 100 : 40));
    g2d.fillRoundRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height, arc, arc);
    //g2d.drawRoundRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height, arc, arc);
  }

  if (!myMacScrollbarHidden) {
    g2d.setColor(adjustColor(baseColor));
    g2d.fillRoundRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height, arc, arc);
  }
  g2d.setRenderingHints(oldHints);
}
 
Example 57
Project: intellij-ce-playground   File: ButtonlessScrollBarUI.java   Source Code and License 5 votes vote down vote up
protected Color adjustColor(Color c) {
  if (isMacOverlayScrollbar()) {
    int alpha = (int)((120 + myMouseOverScrollbarExpandLevel * 20) * (1 - myMacScrollbarFadeLevel));
    //noinspection UseJBColor
    return new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha);
  }
  else {
    if (myThumbFadeColorShift == 0) return c;
    final int sign = isDark() ? -1 : 1;
    return Gray.get(Math.max(0, Math.min(255, c.getRed() - sign * myThumbFadeColorShift)));
  }
}
 
Example 58
Project: intellij-ce-playground   File: Stripe.java   Source Code and License 5 votes vote down vote up
private static void drawBorder(Graphics g, int x, int y, int width, int height, Insets insets) {
  if (insets.top == 1) g.drawLine(x, y, x + width, y);
  if (insets.right == 1) g.drawLine(x + width - 1, y, x + width - 1, y + height);
  if (insets.left == 1) g.drawLine(x, y, x, y + height);
  if (insets.bottom == 1) g.drawLine(x, y + height - 1, x + width, y + height - 1);

  if (UIUtil.isUnderDarcula()) {
    final Color c = g.getColor();
    if (insets.top == 2) {
      g.setColor(c);
      g.drawLine(x, y, x + width, y);
      g.setColor(Gray._85);
      g.drawLine(x, y + 1, x + width, y + 1);
    }
    if (insets.right == 2) {
      g.setColor(Gray._85);
      g.drawLine(x + width - 1, y, x + width - 1, y + height);
      g.setColor(c);
      g.drawLine(x + width - 2, y, x + width - 2, y + height);
    }
    if (insets.left == 2) {
      g.setColor(Gray._85);
      g.drawLine(x + 1, y, x + 1, y + height);
      g.setColor(c);
      g.drawLine(x, y, x, y + height);
    }
    if (insets.bottom == 2) {
      //do nothing
    }
  }
}
 
Example 59
Project: intellij-ce-playground   File: InternalDecorator.java   Source Code and License 5 votes vote down vote up
private void init() {
  enableEvents(AWTEvent.COMPONENT_EVENT_MASK);

  final JPanel contentPane = new JPanel(new BorderLayout());
  contentPane.add(myHeader, BorderLayout.NORTH);

  JPanel innerPanel = new JPanel(new BorderLayout());
  JComponent toolWindowComponent = myToolWindow.getComponent();
  innerPanel.add(toolWindowComponent, BorderLayout.CENTER);

  final NonOpaquePanel inner = new NonOpaquePanel(innerPanel);
  inner.setBorder(new EmptyBorder(-1, 0, 0, 0));

  contentPane.add(inner, BorderLayout.CENTER);
  add(contentPane, BorderLayout.CENTER);
  if (SystemInfo.isMac) {
    setBackground(new JBColor(Gray._200, Gray._90));
  }

  // Add listeners
  registerKeyboardAction(new ActionListener() {
    @Override
    public void actionPerformed(final ActionEvent e) {
      ToolWindowManager.getInstance(myProject).activateEditorComponent();
    }
  }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
 
Example 60
Project: intellij-ce-playground   File: InternalDecorator.java   Source Code and License 5 votes vote down vote up
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
  if (UIUtil.isUnderDarcula()) {
    g.setColor(Gray._40);
    doPaintBorder(c, g, x, y, width, height);
  }
  else {
    g.setColor(SystemInfo.isMac && UIUtil.isUnderIntelliJLaF() ? Gray.xC9 : Gray._155);
    doPaintBorder(c, g, x, y, width, height);
  }
}