Java 类com.intellij.ui.paint.RectanglePainter 实例源码

项目:consulo    文件:SearchTextArea.java   
@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);
  }
}
项目:material-theme-jetbrains    文件:UIReplacer.java   
protected void draw(final Graphics2D g, final int x, final int y, final int width, final int height) {
  RectanglePainter.DRAW.paint(g, x, y, width, height, null);
}
项目:jediterm    文件:ScrollPainter.java   
@Override
protected void fill(Graphics2D g, int x, int y, int width, int height, boolean border) {
  RectanglePainter.FILL.paint(g, x, y, width, height, Math.min(width, height));
}
项目:jediterm    文件:ScrollPainter.java   
@Override
protected void draw(Graphics2D g, int x, int y, int width, int height) {
  RectanglePainter.DRAW.paint(g, x, y, width, height, Math.min(width, height));
}
项目:consulo    文件:BreadcrumbsComponent.java   
@Override
public void paint(@Nonnull final Crumb c, @Nonnull final Graphics2D g2, final int height, final int pageOffset) {
  final PainterSettings s = getSettings();
  final Font oldFont = g2.getFont();
  final int offset = c.getOffset() - pageOffset;

  final int width = c.getWidth();
  RectanglePainter.paint(g2, offset + 2, 2, width - 4, height - 4, ROUND_VALUE + 2, s.getBackgroundColor(c), s.getBorderColor(c));

  final Color textColor = s.getForegroundColor(c);
  if (textColor != null) {
    g2.setColor(textColor);
  }

  final Font font = s.getFont(g2, c);
  if (font != null) {
    g2.setFont(font);
  }

  final FontMetrics fm = g2.getFontMetrics();

  String string = c.getString();
  if (fm.stringWidth(string) > width) {
    final int dotsWidth = fm.stringWidth("...");
    final StringBuilder sb = new StringBuilder();
    int length = 0;
    for (int i = 0; i < string.length(); i++) {
      final int charWidth = fm.charWidth(string.charAt(i));
      if (length + charWidth + dotsWidth > width) {
        break;
      }

      length += charWidth;
      sb.append(string.charAt(i));
    }

    string = sb.append("...").toString();
  }

  g2.drawString(string, offset + ROUND_VALUE + 5, height - fm.getDescent() - 5);

  g2.setFont(oldFont);
}