本文整理汇总了Java中com.intellij.ui.SimpleColoredComponent.getTextBaseLine方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleColoredComponent.getTextBaseLine方法的具体用法?Java SimpleColoredComponent.getTextBaseLine怎么用?Java SimpleColoredComponent.getTextBaseLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ui.SimpleColoredComponent
的用法示例。
在下文中一共展示了SimpleColoredComponent.getTextBaseLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import com.intellij.ui.SimpleColoredComponent; //导入方法依赖的package包/类
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();
}
示例2: paintIcon
import com.intellij.ui.SimpleColoredComponent; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
UISettings.setupAntialiasing(g);
Font originalFont = g.getFont();
Color originalColor = g.getColor();
g.setFont(myFont);
x += (getIconWidth() - myWidth) / 2;
y += SimpleColoredComponent.getTextBaseLine(g.getFontMetrics(), getIconHeight());
if (SystemInfo.isLinux) {
if (myStr.length() == 1) {
x--;
}
}
else if (myStr.length() == 2) {
x++;
}
g.setColor(myTextColor);
g.drawString(myStr, x, y);
g.setFont(originalFont);
g.setColor(originalColor);
}
示例3: paint
import com.intellij.ui.SimpleColoredComponent; //导入方法依赖的package包/类
protected Rectangle paint(@NotNull Graphics2D g2,
@NotNull String text,
int paddingX,
int paddingY,
int textPadding,
@NotNull Color color) {
g2.setFont(getFont());
g2.setStroke(new BasicStroke(1.5f));
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FontMetrics fontMetrics = g2.getFontMetrics();
int width = fontMetrics.stringWidth(text) + 2 * TEXT_PADDING_X + textPadding;
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 + textPadding + TEXT_PADDING_X;
int y = paddingY + SimpleColoredComponent.getTextBaseLine(fontMetrics, height);
g2.drawString(text, x, y);
return new Rectangle(x, y, width, height);
}
示例4: paintComponent
import com.intellij.ui.SimpleColoredComponent; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
Point point = UIUtil.getLocationOnScreen(this);
if (point != null) {
Rectangle bounds = getBounds();
myScreenBounds = new Rectangle(point.x, point.y, bounds.width, bounds.height);
}
FontMetrics metrics = g.getFontMetrics();
int baseLine = SimpleColoredComponent.getTextBaseLine(metrics, metrics.getHeight());
myRowIndexControl.setBaseLine(
baseLine + ArrangementConstants.VERTICAL_GAP + myDelegate.getUiComponent().getBounds().y - myRowIndexControl.getBounds().y
);
super.paintComponent(g);
}
示例5: paintComponent
import com.intellij.ui.SimpleColoredComponent; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
Point point = UIUtil.getLocationOnScreen(this);
if (point != null) {
Rectangle bounds = getBounds();
myScreenBounds = new Rectangle(point.x, point.y, bounds.width, bounds.height);
}
FontMetrics metrics = g.getFontMetrics();
int baseLine = SimpleColoredComponent.getTextBaseLine(metrics, metrics.getHeight());
myRowIndexControl.setBaseLine(
baseLine + ArrangementConstants.VERTICAL_GAP + myDelegate.getUiComponent().getBounds().y - myRowIndexControl.getBounds().y
);
super.paintComponent(g);
}
示例6: paint
import com.intellij.ui.SimpleColoredComponent; //导入方法依赖的package包/类
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();
int baseLine = SimpleColoredComponent.getTextBaseLine(fontMetrics, height);
g2.setColor(myBackground);
g2.fillRect(x, y, myWidth, height);
if (myGreyBackground != null && myCompact) {
g2.setColor(myGreyBackground);
g2.fillRect(x, y + baseLine - fontMetrics.getAscent() - TOP_TEXT_PADDING,
myWidth,
fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING);
}
x += LEFT_PADDING;
for (Pair<String, LabelIcon> label : myLabels) {
LabelIcon icon = label.second;
String text = label.first;
if (myGreyBackground != null && !myCompact) {
g2.setColor(myGreyBackground);
g2.fill(new RoundRectangle2D.Double(x - LEFT_PADDING, y + baseLine - fontMetrics.getAscent() - TOP_TEXT_PADDING,
icon.getIconWidth() + fontMetrics.stringWidth(text) + 3 * LEFT_PADDING,
fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING, LABEL_ARC, LABEL_ARC));
}
icon.paintIcon(null, g2, x, y + (height - icon.getIconHeight()) / 2);
x += icon.getIconWidth();
g2.setColor(myForeground);
g2.drawString(text, x, y + baseLine);
x += fontMetrics.stringWidth(text) + (myCompact ? COMPACT_MIDDLE_PADDING : MIDDLE_PADDING);
}
config.restore();
}