Java 类com.intellij.openapi.ui.GraphicsConfig 实例源码

项目:intellij-ce-playground    文件:Tree.java   
protected void paintFileColorGutter(final Graphics g) {
  final GraphicsConfig config = new GraphicsConfig(g);
  final Rectangle rect = getVisibleRect();
  final int firstVisibleRow = getClosestRowForLocation(rect.x, rect.y);
  final int lastVisibleRow = getClosestRowForLocation(rect.x, rect.y + rect.height);

  for (int row = firstVisibleRow; row <= lastVisibleRow; row++) {
    final TreePath path = getPathForRow(row);
    if (path != null) {
      final Rectangle bounds = getRowBounds(row);
      Object component = path.getLastPathComponent();
      final Object[] pathObjects = path.getPath();
      if (component instanceof LoadingNode && pathObjects.length > 1) {
        component = pathObjects[pathObjects.length - 2];
      }

      Color color = getFileColorFor((DefaultMutableTreeNode)component);
      if (color != null) {
        g.setColor(color);
        g.fillRect(0, bounds.y, getWidth(), bounds.height);
      }
    }
  }
  config.restore();
}
项目:intellij-ce-playground    文件:CaptionIcon.java   
public void paintIcon(Component c, Graphics g, int x, int y) {
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);

  ((Graphics2D)g).setPaint(myBgrnd);

  myForm.draw(c, (Graphics2D)g, myWidth, myHeight, x, y, myWithContinuation, myEmphasize);

  g.setFont(myFont);
  g.setColor(UIUtil.getTextAreaForeground());
  g.drawString(myText, x + 4, y + myHeight - 3);  // -2

  g.setColor(myBgrnd.darker().darker());
  g.setFont(myPlusFont);
  if (myWithContinuation) {
    g.drawString(" +", x + myWidth - 2 - myAddWidth, y + myHeight - 3);
  }

  config.restore();
}
项目:intellij-ce-playground    文件:IdeaActionButtonLook.java   
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();
  }
}
项目:intellij-ce-playground    文件:DarculaTextFieldUI.java   
@Override
protected void paintBackground(Graphics graphics) {
  Graphics2D g = (Graphics2D)graphics;
  final JTextComponent c = getComponent();
  final Container parent = c.getParent();
  final Rectangle r = getDrawingRect();
  if (c.isOpaque() && parent != null) {
    g.setColor(parent.getBackground());
    g.fillRect(0, 0, c.getWidth(), c.getHeight());
  }
  final GraphicsConfig config = new GraphicsConfig(g);
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

  final Border border = c.getBorder();
  if (isSearchField(c)) {
    paintSearchField(g, c, r);
  } else if (border instanceof DarculaTextBorder) {
    paintDarculaBackground(g, c, border);
  } else {
    super.paintBackground(g);
  }
  config.restore();
}
项目:intellij-ce-playground    文件:DarculaTextBorder.java   
@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(getBorderColor(c.isEnabled() && editable));
    g.drawRect(1, 1, width - 2, height - 2);
  }
  g.translate(-x, -y);
  config.restore();
}
项目:intellij-ce-playground    文件:TestTreeView.java   
private static void paintRowData(Tree tree, String duration, Rectangle bounds, Graphics2D g, boolean isSelected, boolean hasFocus) {
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  g.setFont(tree.getFont().deriveFont(Font.PLAIN, UIUtil.getFontSize(UIUtil.FontSize.SMALL)));
  final FontMetrics metrics = tree.getFontMetrics(g.getFont());
  int totalWidth = metrics.stringWidth(duration) + 2;
  int x = bounds.x + bounds.width - totalWidth;
  g.setColor(isSelected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeBackground());
  final int leftOffset = 5;
  g.fillRect(x - leftOffset, bounds.y, totalWidth + leftOffset, bounds.height);
  g.translate(0, bounds.y - 1);
  if (isSelected) {
    if (!hasFocus && UIUtil.isUnderAquaBasedLookAndFeel()) {
      g.setColor(UIUtil.getTreeForeground());
    }
    else {
      g.setColor(UIUtil.getTreeSelectionForeground());
    }
  }
  else {
    g.setColor(new JBColor(0x808080, 0x808080));
  }
  g.drawString(duration, x, SimpleColoredComponent.getTextBaseLine(tree.getFontMetrics(tree.getFont()), bounds.height) + 1);
  g.translate(0, -bounds.y + 1);
  config.restore();
}
项目:material-theme-jetbrains    文件:MTTableHeaderUI.java   
@Override
public void paint(final Graphics g2, final JComponent c) {
  final Color borderColor = UIManager.getColor("TableHeader.borderColor");

  final Graphics2D g = (Graphics2D) g2;
  final GraphicsConfig config = new GraphicsConfig(g);
  final Color bg = c.getBackground();
  g.setColor(bg);
  final int h = c.getHeight();
  final int w = c.getWidth();
  g.fillRect(0, 0, w, h);

  g.setColor(borderColor);
  g.drawLine(0, h - 1, w, h - 1);

  config.restore();

  super.paint(g, c);
}
项目:material-theme-jetbrains    文件:MTTextFieldUI.java   
@Override
protected void paintBackground(final Graphics graphics) {
  Graphics2D g = (Graphics2D) graphics;
  final JTextComponent c = getComponent();
  final Container parent = c.getParent();
  final Rectangle r = getDrawingRect();
  if (c.isOpaque() && parent != null) {
    g.setColor(parent.getBackground());
    g.fillRect(0, 0, c.getWidth(), c.getHeight());
  }
  final GraphicsConfig config = new GraphicsConfig(g);
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

  final Border border = c.getBorder();
  if (isSearchField(c)) {
    paintSearchField(g, c, r, border);
  } else if (border instanceof MTTextBorder) {
    paintDarculaBackground(g, c, border);
  } else {
    super.paintBackground(g);
  }
  config.restore();
}
项目:tools-idea    文件:Tree.java   
protected void paintFileColorGutter(final Graphics g) {
  final GraphicsConfig config = new GraphicsConfig(g);
  final Rectangle rect = getVisibleRect();
  final int firstVisibleRow = getClosestRowForLocation(rect.x, rect.y);
  final int lastVisibleRow = getClosestRowForLocation(rect.x, rect.y + rect.height);

  for (int row = firstVisibleRow; row <= lastVisibleRow; row++) {
    final TreePath path = getPathForRow(row);
    if (path != null) {
      final Rectangle bounds = getRowBounds(row);
      Object component = path.getLastPathComponent();
      final Object[] pathObjects = path.getPath();
      if (component instanceof LoadingNode && pathObjects.length > 1) {
        component = pathObjects[pathObjects.length - 2];
      }

      Color color = getFileColorFor(((DefaultMutableTreeNode)component));
      if (color != null) {
        g.setColor(color);
        g.fillRect(0, bounds.y, getWidth(), bounds.height);
      }
    }
  }
  config.restore();
}
项目:tools-idea    文件:CaptionIcon.java   
public void paintIcon(Component c, Graphics g, int x, int y) {
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);

  ((Graphics2D)g).setPaint(myBgrnd);

  myForm.draw(c, (Graphics2D)g, myWidth, myHeight, x, y, myWithContinuation, myEmphasize);

  g.setFont(myFont);
  g.setColor(UIUtil.getTextAreaForeground());
  g.drawString(myText, x + 4, y + myHeight - 3);  // -2

  g.setColor(myBgrnd.darker().darker());
  g.setFont(myPlusFont);
  if (myWithContinuation) {
    g.drawString(" +", x + myWidth - 2 - myAddWidth, y + myHeight - 3);
  }

  config.restore();
}
项目:tools-idea    文件:IdeaActionButtonLook.java   
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();
  }
}
项目:tools-idea    文件:DarculaButtonPainter.java   
@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();
  }
}
项目:tools-idea    文件:DarculaTextBorder.java   
@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();
}
项目:consulo    文件:TestTreeView.java   
private static void paintRowData(Tree tree, String duration, Rectangle bounds, Graphics2D g, boolean isSelected, boolean hasFocus) {
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  g.setFont(tree.getFont().deriveFont(Font.PLAIN, UIUtil.getFontSize(UIUtil.FontSize.SMALL)));
  final FontMetrics metrics = tree.getFontMetrics(g.getFont());
  int totalWidth = metrics.stringWidth(duration) + 2;
  int x = bounds.x + bounds.width - totalWidth;
  g.setColor(isSelected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeBackground());
  final int leftOffset = 5;
  g.fillRect(x - leftOffset, bounds.y, totalWidth + leftOffset, bounds.height);
  g.translate(0, bounds.y - 1);
  if (isSelected) {
    if (!hasFocus && UIUtil.isUnderAquaBasedLookAndFeel()) {
      g.setColor(UIUtil.getTreeForeground());
    }
    else {
      g.setColor(UIUtil.getTreeSelectionForeground());
    }
  }
  else {
    g.setColor(new JBColor(0x808080, 0x808080));
  }
  g.drawString(duration, x, SimpleColoredComponent.getTextBaseLine(tree.getFontMetrics(tree.getFont()), bounds.height) + 1);
  g.translate(0, -bounds.y + 1);
  config.restore();
}
项目:consulo    文件:Tree.java   
protected void paintFileColorGutter(final Graphics g) {
  final GraphicsConfig config = new GraphicsConfig(g);
  final Rectangle rect = getVisibleRect();
  final int firstVisibleRow = getClosestRowForLocation(rect.x, rect.y);
  final int lastVisibleRow = getClosestRowForLocation(rect.x, rect.y + rect.height);

  for (int row = firstVisibleRow; row <= lastVisibleRow; row++) {
    final TreePath path = getPathForRow(row);
    if (path != null) {
      final Rectangle bounds = getRowBounds(row);
      Object component = path.getLastPathComponent();
      final Object[] pathObjects = path.getPath();
      if (component instanceof LoadingNode && pathObjects.length > 1) {
        component = pathObjects[pathObjects.length - 2];
      }

      Color color = getFileColorFor(TreeUtil.getUserObject(component));
      if (color != null) {
        g.setColor(color);
        g.fillRect(0, bounds.y, getWidth(), bounds.height);
      }
    }
  }
  config.restore();
}
项目:consulo    文件:RectangleReferencePainter.java   
public void paint(@Nonnull Graphics2D g2, int x, int y, int height) {
  if (myLabels.isEmpty()) return;

  GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
  g2.setFont(getReferenceFont());
  g2.setStroke(new BasicStroke(1.5f));

  FontMetrics fontMetrics = g2.getFontMetrics();

  x += PaintParameters.LABEL_PADDING;
  for (Pair<String, Color> label : myLabels) {
    Dimension size = myLabelPainter.calculateSize(label.first, fontMetrics);
    int paddingY = y + (height - size.height) / 2;
    myLabelPainter.paint(g2, label.first, x, paddingY, getLabelColor(label.second));
    x += size.width + PaintParameters.LABEL_PADDING;
  }

  config.restore();
}
项目:consulo    文件:RectanglePainter.java   
public void paint(@Nonnull Graphics2D g2, @Nonnull String text, int paddingX, int paddingY, @Nonnull Color color) {
  GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
  g2.setFont(getLabelFont());
  g2.setStroke(new BasicStroke(1.5f));

  FontMetrics fontMetrics = g2.getFontMetrics();
  int width = fontMetrics.stringWidth(text) + 2 * TEXT_PADDING_X;
  int height = fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING;

  g2.setColor(color);
  if (mySquare) {
    g2.fillRect(paddingX, paddingY, width, height);
  }
  else {
    g2.fill(new RoundRectangle2D.Double(paddingX, paddingY, width, height, LABEL_ARC, LABEL_ARC));
  }

  g2.setColor(JBColor.BLACK);
  int x = paddingX + TEXT_PADDING_X;
  int y = paddingY + SimpleColoredComponent.getTextBaseLine(fontMetrics, height);
  g2.drawString(text, x, y);

  config.restore();
}
项目:consulo    文件:LabelIcon.java   
private void paintIcon(@Nonnull Graphics2D g2) {
  GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);

  float scale = mySize / 8.0f;

  for (int i = myColors.length - 1; i >= 0; i--) {
    if (i != myColors.length - 1) {
      g2.setColor(myBgColor);
      paintTag(g2, scale, scale * 2 * i + 1, 0);
    }
    g2.setColor(myColors[i]);
    paintTag(g2, scale, scale * 2 * i, 0);
  }

  config.restore();
}
项目:consulo    文件:ActionButtonUI.java   
protected void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.POPPED) {
      g.setColor(ALPHA_30);
      g.drawRoundRect(0, 0, size.width - 2, size.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(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4));
    config.restore();
  }
}
项目:consulo    文件:CaptionIcon.java   
public void paintIcon(Component c, Graphics g, int x, int y) {
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);

  ((Graphics2D)g).setPaint(myBgrnd);

  myForm.draw(c, (Graphics2D)g, myWidth, myHeight, x, y, myWithContinuation, myEmphasize);

  g.setFont(myFont);
  g.setColor(UIUtil.getTextAreaForeground());
  g.drawString(myText, x + 4, y + myHeight - 3);  // -2

  g.setColor(myBgrnd.darker().darker());
  g.setFont(myPlusFont);
  if (myWithContinuation) {
    g.drawString(" +", x + myWidth - 2 - myAddWidth, y + myHeight - 3);
  }

  config.restore();
}
项目:consulo    文件:PoppedIcon.java   
private static void paintBorder(Graphics g, Dimension size, int state) {
  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.POPPED) {
      g.setColor(ALPHA_30);
      g.drawRoundRect(0, 0, size.width - 2, size.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(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4));
    config.restore();
  }
}
项目:consulo    文件:DarculaTextBorder.java   
@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();
}
项目:consulo    文件:DarculaButtonUI.java   
@Override
public void paint(Graphics g, JComponent c) {
  final Border border = c.getBorder();
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  final boolean square = isSquare(c);
  if (c.isEnabled() && border != null) {
    final Insets ins = border.getBorderInsets(c);
    final int yOff = (ins.top + ins.bottom) / 4;
    if (!square) {
      if (((JButton)c).isDefaultButton()) {
        ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, getSelectedButtonColor1(), 0, c.getHeight(), getSelectedButtonColor2()));
      }
      else {
        ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, getButtonColor1(), 0, c.getHeight(), getButtonColor2()));
      }
    }
    g.fillRoundRect(JBUI.scale(square ? 2 : 4), yOff, c.getWidth() - JBUI.scale(8), c.getHeight() - 2 * yOff, JBUI.scale(square ? 3 : 5),
                    JBUI.scale(square ? 3 : 5));
  }
  config.restore();
  super.paint(g, c);
}
项目:consulo    文件:TwoColorsIcon.java   
@Override
public void paintIcon(final Component component, Graphics g, int x, int y) {
  Graphics2D g2d = (Graphics2D)g.create();
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g2d);
  try {
    final int w = getIconWidth();
    final int h = getIconHeight();
    g2d.setPaint(getPaint(getIconColor()));
    g2d.fillPolygon(new int[]{x, x + w, x}, new int[]{y, y, y + h}, 3);
    g2d.setPaint(getPaint(mySecondColor));
    g2d.fillPolygon(new int[]{x + w, x + w, x}, new int[]{y, y + h, y + h}, 3);
  }
  catch (Exception e) {
    g2d.dispose();
  }
  finally {
    config.restore();
  }
}
项目:consulo    文件:UIUtil.java   
public static void drawWave(Graphics2D g, Rectangle rectangle) {
  GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  Stroke oldStroke = g.getStroke();
  try {
    g.setStroke(new BasicStroke(0.7F));
    double cycle = 4;
    final double wavedAt = rectangle.y + (double)rectangle.height / 2 - .5;
    GeneralPath wavePath = new GeneralPath();
    wavePath.moveTo(rectangle.x, wavedAt - Math.cos(rectangle.x * 2 * Math.PI / cycle));
    for (int x = rectangle.x + 1; x <= rectangle.x + rectangle.width; x++) {
      wavePath.lineTo(x, wavedAt - Math.cos(x * 2 * Math.PI / cycle));
    }
    g.draw(wavePath);
  }
  finally {
    config.restore();
    g.setStroke(oldStroke);
  }
}
项目:consulo    文件:ConfigurationErrorsComponent.java   
@Override
protected void paintComponent(Graphics g) {
  final Graphics2D g2d = (Graphics2D)g;

  final Rectangle bounds = getBounds();
  final Insets insets = getInsets();

  final GraphicsConfig cfg = new GraphicsConfig(g);
  cfg.setAntialiasing(true);

  final Shape shape = new RoundRectangle2D.Double(insets.left, insets.top, bounds.width - 1 - insets.left - insets.right,
                                                  bounds.height - 1 - insets.top - insets.bottom, 6, 6);
  g2d.setColor(JBColor.WHITE);
  g2d.fill(shape);

  Color bgColor = getBackground();

  g2d.setColor(bgColor);
  g2d.fill(shape);

  g2d.setColor(getBackground().darker());
  g2d.draw(shape);
  cfg.restore();

  super.paintComponent(g);
}
项目:intellij-ce-playground    文件:ConfigurationErrorsComponent.java   
@Override
protected void paintComponent(Graphics g) {
  final Graphics2D g2d = (Graphics2D)g;

  final Rectangle bounds = getBounds();
  final Insets insets = getInsets();

  final GraphicsConfig cfg = new GraphicsConfig(g);
  cfg.setAntialiasing(true);

  final Shape shape = new RoundRectangle2D.Double(insets.left, insets.top, bounds.width - 1 - insets.left - insets.right,
                                                  bounds.height - 1 - insets.top - insets.bottom, 6, 6);

  if (mySelected) {
    g2d.setColor(UIUtil.getListSelectionBackground());
    g2d.fillRect(0, 0, bounds.width, bounds.height);
  }

  g2d.setColor(Color.WHITE);
  g2d.fill(shape);


  Color bgColor = getBackground();

  g2d.setColor(bgColor);
  g2d.fill(shape);

  g2d.setColor(myHasFocus || mySelected ? getBackground().darker().darker() : getBackground().darker());
  g2d.draw(shape);
  cfg.restore();

  super.paintComponent(g);
}
项目:intellij-ce-playground    文件:WizardArrowUI.java   
@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());
}
项目:intellij-ce-playground    文件:DiffDividerDrawUtil.java   
public static void paintSeparators(@NotNull Graphics2D gg,
                                   int width,
                                   @NotNull Editor editor1,
                                   @NotNull Editor editor2,
                                   @NotNull DividerSeparatorPaintable paintable) {
  List<DividerSeparator> polygons = createVisibleSeparators(editor1, editor2, paintable);

  GraphicsConfig config = GraphicsUtil.setupAAPainting(gg);
  for (DividerSeparator polygon : polygons) {
    polygon.paint(gg, width);
  }
  config.restore();
}
项目:intellij-ce-playground    文件:DiffDividerDrawUtil.java   
public static void paintSeparatorsOnScrollbar(@NotNull Graphics2D gg,
                                              int width,
                                              @NotNull Editor editor1,
                                              @NotNull Editor editor2,
                                              @NotNull DividerSeparatorPaintable paintable) {
  List<DividerSeparator> polygons = createVisibleSeparators(editor1, editor2, paintable);

  GraphicsConfig config = GraphicsUtil.setupAAPainting(gg);
  for (DividerSeparator polygon : polygons) {
    polygon.paintOnScrollbar(gg, width);
  }
  config.restore();
}
项目:intellij-ce-playground    文件:DiffDividerDrawUtil.java   
public static void paintPolygons(@NotNull Graphics2D gg,
                                 int width,
                                 boolean paintBorder,
                                 boolean curved,
                                 @NotNull Editor editor1,
                                 @NotNull Editor editor2,
                                 @NotNull DividerPaintable paintable) {
  List<DividerPolygon> polygons = createVisiblePolygons(editor1, editor2, paintable);

  GraphicsConfig config = GraphicsUtil.setupAAPainting(gg);
  for (DividerPolygon polygon : polygons) {
    polygon.paint(gg, width, paintBorder, curved);
  }
  config.restore();
}
项目:intellij-ce-playground    文件:CardActionsPanel.java   
@Override
public void paintComponent(Graphics g) {
  super.paintComponent(g);

  AnAction action = getAction();
  if (action instanceof ActivateCard) {
    Rectangle bounds = getBounds();

    Icon icon = AllIcons.Actions.Forward; //AllIcons.Icons.Ide.NextStepGrayed;
    int y = (bounds.height - icon.getIconHeight()) / 2;
    int x = bounds.width - icon.getIconWidth() - 15;

    if (getPopState() == POPPED) {
      final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
      g.setColor(WelcomeScreenColors.CAPTION_BACKGROUND);
      g.fillOval(x - 3, y - 3, icon.getIconWidth() + 6, icon.getIconHeight() + 6);

      g.setColor(WelcomeScreenColors.GROUP_ICON_BORDER_COLOR);
      g.drawOval(x - 3, y - 3, icon.getIconWidth() + 6, icon.getIconHeight() + 6);
      config.restore();
    }
    else {
      icon = IconLoader.getDisabledIcon(icon);
    }

    icon.paintIcon(this, g, x, y);
  }
}
项目:intellij-ce-playground    文件:InlineProgressIndicator.java   
protected void paintComponent(final Graphics g) {
  if (myCompact) {
    super.paintComponent(g);
    return;
  }

  final GraphicsConfig c = GraphicsUtil.setupAAPainting(g);
  UISettings.setupAntialiasing(g);

  int arc = 8;
  Color bg = getBackground();
  final Rectangle bounds = myProcessName.getBounds();
  final Rectangle label = SwingUtilities.convertRectangle(myProcessName.getParent(), bounds, this);

  g.setColor(UIUtil.getPanelBackground());
  g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc);

  if (!UIUtil.isUnderDarcula()) {
    bg = ColorUtil.toAlpha(bg.darker().darker(), 230);
    g.setColor(bg);

    g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc);

    g.setColor(UIUtil.getPanelBackground());
    g.fillRoundRect(0, getHeight() / 2, getWidth() - 1, getHeight() / 2, arc, arc);
    g.fillRect(0, (int)label.getMaxY() + 1, getWidth() - 1, getHeight() / 2);
  } else {
    bg = bg.brighter();
    g.setColor(bg);
    g.drawLine(0, (int)label.getMaxY() + 1, getWidth() - 1, (int)label.getMaxY() + 1);
  }

  g.setColor(bg);
  g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc);

  c.restore();
}
项目:intellij-ce-playground    文件:ComboContentLayout.java   
@Override
public void paintComponent(Graphics g) {
  if (!isToDrawCombo()) return;

  Rectangle r = myComboLabel.getBounds();
  if (UIUtil.isUnderDarcula()) {
    g.setColor(ColorUtil.toAlpha(UIUtil.getLabelForeground(), 20));
    g.drawLine(r.width, 0, r.width, r.height);
    g.setColor(ColorUtil.toAlpha(UIUtil.getBorderColor(), 50));
    g.drawLine(r.width-1, 0, r.width-1, r.height);
    return;
  }
  if (myImage == null || myImage.getHeight() != r.height || myImage.getWidth() != r.width) {
    myImage = UIUtil.createImage(r.width, r.height, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D g2d = myImage.createGraphics();
    final GraphicsConfig c = new GraphicsConfig(g);
    c.setAntialiasing(true);

    g2d.setPaint(UIUtil.getGradientPaint(0, 0, new Color(0, 0, 0, 10), 0, r.height, new Color(0, 0, 0, 30)));
    g2d.fillRect(0, 0, r.width, r.height);

    g2d.setColor(new Color(0, 0, 0, 60));
    g2d.drawLine(0, 0, 0, r.height);
    g2d.drawLine(r.width - 1, 0, r.width - 1, r.height);

    g2d.setColor(new Color(255, 255, 255, 80));
    g2d.drawRect(1, 0, r.width - 3, r.height - 1);

    g2d.dispose();
  }

  UIUtil.drawImage(g, myImage, isIdVisible() ? r.x : r.x - 2, r.y, null);
}
项目:intellij-ce-playground    文件:ComboContentLayout.java   
@Override
public void paintChildren(Graphics g) {
  if (!isToDrawCombo()) return;

  final GraphicsConfig c = new GraphicsConfig(g);
  c.setAntialiasing(true);

  final Graphics2D g2d = (Graphics2D)g;
  c.restore();
}
项目:intellij-ce-playground    文件:EditorWindow.java   
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
  GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  Font oldFont = g.getFont();
  try {
    g.setFont(UIUtil.getLabelFont());
    g.setColor(JBColor.foreground());
    g.drawString("*", 0, 10);
  } finally {
    config.restore();
    g.setFont(oldFont);
  }
}
项目:intellij-ce-playground    文件:SidePanelCountLabel.java   
@Override
protected void paintComponent(Graphics g) {
  g.setColor(isSelected() ? UIUtil.getListSelectionBackground() : UIUtil.SIDE_PANEL_BACKGROUND);
  g.fillRect(0, 0, getWidth(), getHeight());
  if (StringUtil.isEmpty(getText())) return;
  final JBColor deepBlue = new JBColor(new Color(0x97A4B2), new Color(92, 98, 113));
  g.setColor(isSelected() ? Gray._255.withAlpha(UIUtil.isUnderDarcula() ? 100 : 220) : deepBlue);
  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  g.fillRoundRect(0, 3, getWidth() - 6 - 1, getHeight() - 6, getHeight() - 6, getHeight() - 6);
  config.restore();
  setForeground(isSelected() ? deepBlue.darker() : UIUtil.getListForeground(true));

  super.paintComponent(g);
}
项目:intellij-ce-playground    文件:SidePanelSeparator.java   
@Override
protected void paintComponent(Graphics g) {
  if (Registry.is("ide.new.project.settings")) {
    final JBColor separatorColor = new JBColor(GroupedElementsRenderer.POPUP_SEPARATOR_FOREGROUND, Gray._80);
    g.setColor(separatorColor);
    if ("--".equals(getCaption())) {
      final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
      final int h = getHeight() / 2;
      g.drawLine(30, h, getWidth() - 30, h);
      ((Graphics2D)g).setPaint(new GradientPaint(5, h, ColorUtil.toAlpha(separatorColor, 0), 30, h, separatorColor));
      g.drawLine(5, h, 30, h);
      ((Graphics2D)g).setPaint(
        new GradientPaint(getWidth() - 5, h, ColorUtil.toAlpha(separatorColor, 0), getWidth() - 30, h, separatorColor));
      g.drawLine(getWidth() - 5, h, getWidth() - 30, h);
      config.restore();
      return;
    }
    Rectangle viewR = new Rectangle(0, getVgap(), getWidth() - 1, getHeight() - getVgap() - 1);
    Rectangle iconR = new Rectangle();
    Rectangle textR = new Rectangle();
    String s = SwingUtilities
      .layoutCompoundLabel(g.getFontMetrics(), getCaption(), null, CENTER,
                           LEFT,
                           CENTER,
                           LEFT,
                           viewR, iconR, textR, 0);
    GraphicsUtil.setupAAPainting(g);
    g.setColor(new JBColor(Gray._255.withAlpha(80), Gray._0.withAlpha(80)));
    g.drawString(s, textR.x + 10, textR.y + 1 + g.getFontMetrics().getAscent());
    g.setColor(new JBColor(new Color(0x5F6D7B), Gray._120));
    g.drawString(s, textR.x + 10, textR.y + g.getFontMetrics().getAscent());
  }
  else {
    super.paintComponent(g);
  }
}
项目:intellij-ce-playground    文件:SwitcherToolWindowsListRenderer.java   
@Override
protected void doPaint(Graphics2D g) {
  GraphicsConfig config = new GraphicsConfig(g);
  if (hide) {
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.15f));
  }
  super.doPaint(g);
  config.restore();
}
项目:intellij-ce-playground    文件:DarculaButtonPainter.java   
@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;
  final boolean square = DarculaButtonUI.isSquare(c);
  int offset = JBUI.scale(square ? 1 : getOffset());
  int w = c.getWidth();
  int h = c.getHeight();
  int diam = JBUI.scale(22);

  if (c.hasFocus()) {
    if (DarculaButtonUI.isHelpButton((JComponent)c)) {
        DarculaUIUtil.paintFocusOval(g2d, (w - diam) / 2, (h - diam) / 2, diam, diam);
    } else {
      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 + JBUI.scale(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));
    if (DarculaButtonUI.isHelpButton((JComponent)c)) {
      g.drawOval((w - diam) / 2, (h - diam) / 2, diam, diam);
    } else {
      g.translate(x,y);
      int r = JBUI.scale(square ? 3 : 5);
      g.drawRoundRect(offset, yOff, width - 2 * offset, height - 2 * yOff, r, r);
      g.translate(-x,-y);
    }

    config.restore();
  }
}