本文整理汇总了Java中com.intellij.util.ui.GraphicsUtil类的典型用法代码示例。如果您正苦于以下问题:Java GraphicsUtil类的具体用法?Java GraphicsUtil怎么用?Java GraphicsUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsUtil类属于com.intellij.util.ui包,在下文中一共展示了GraphicsUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintComponent
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
Color bg = getBackground();
if (bg == null) {
bg = UIUtil.getPanelBackground();
}
g.setColor(bg);
if (isOpaque()) {
g.fillRect(0,0, getWidth() - 1, getHeight()-1);
}
final Border border = getBorder();
final Insets insets = border == null ? new Insets(0,0,0,0) : border.getBorderInsets(this);
int x = (getWidth() - insets.left - insets.right - myIcon.getIconWidth()) / 2;
int y = insets.top;
myIcon.paintIcon(this, g, x, y);
g.setFont(getFont());
y += myIcon.getIconHeight();
final FontMetrics metrics = getFontMetrics(getFont());
x = (getWidth() - insets.left - insets.right - metrics.stringWidth(myLabel)) / 2;
y += 1.5 * metrics.getHeight();
g.setColor(UIUtil.getLabelForeground());
GraphicsUtil.setupAAPainting(g);
g.drawString(myLabel, x, y);
}
示例2: paint
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
private void paint(Graphics2D g, int width) {
GraphicsUtil.setupAntialiasing(g);
if (!myApplied) {
Shape upperCurve = makeCurve(width, myStart1, myStart2, true);
Shape lowerCurve = makeCurve(width, myEnd1, myEnd2, false);
Path2D path = new Path2D.Double();
path.append(upperCurve, true);
path.append(lowerCurve, true);
g.setColor(myColor);
g.fill(path);
g.setColor(DiffUtil.getFramingColor(myColor));
g.draw(upperCurve);
g.draw(lowerCurve);
}
else {
g.setColor(myColor);
g.draw(makeCurve(width, myStart1 + 1, myStart2 + 1, true));
g.draw(makeCurve(width, myStart1 + 2, myStart2 + 2, true));
g.draw(makeCurve(width, myEnd1 + 1, myEnd2 + 1, false));
g.draw(makeCurve(width, myEnd1 + 2, myEnd2 + 2, false));
}
}
示例3: paintIcon
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
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();
}
示例4: paintBorder
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
protected void paintBorder(Graphics g, Dimension size, int state) {
GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
try {
if (UIUtil.isUnderAquaLookAndFeel()) {
if (state == ActionButtonComponent.POPPED) {
g.setColor(JBColor.GRAY);
((Graphics2D)g).draw(getShape(size));
}
}
else if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
//do nothing
}
else {
final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49;
g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift));
((Graphics2D)g).setStroke(BASIC_STROKE);
((Graphics2D)g).draw(getShape(size));
}
}
finally {
config.restore();
}
}
示例5: createUIComponents
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
private void createUIComponents() {
myButton = new JPanel(new BorderLayout()) {
{
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
GraphicsUtil.setupAAPainting(g);
((Graphics2D)g).setPaint(new GradientPaint(0, 0, BODY_COLOR_1, 0, getHeight(), BODY_COLOR_2));
g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
((Graphics2D)g).setStroke(new BasicStroke(UIUtil.isUnderDarcula() ? 2f : 1f));
g.setColor(BORDER_COLOR);
g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
}
};
myMessage = IdeTooltipManager.initPane("", new HintHint().setAwtTooltip(true), null);
myMessage.setFont(UIUtil.getLabelFont().deriveFont(UIUtil.getLabelFont().getSize() + 2f));
}
示例6: paintRowData
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
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();
}
示例7: paintLabel
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
private void paintLabel(Graphics g, int cell, Rectangle cellBounds, @Nullable String label, int thumbnailHeight) {
if (!StringUtil.isEmpty(label)) {
final Color fg;
if (hasFocus() && cell == mySelectedIndex && (getImage(cell) != null || UIUtil.isUnderDarcula())) {
fg = UIUtil.getTreeSelectionForeground();
}
else {
fg = UIUtil.getTreeForeground();
}
GraphicsUtil.setupAntialiasing(g);
g.setColor(fg);
FontMetrics fontMetrics = g.getFontMetrics();
LineMetrics metrics = fontMetrics.getLineMetrics(label, g);
int width = fontMetrics.stringWidth(label);
int textBoxTop = myCellMargin.top + thumbnailHeight;
int cellBottom = cellBounds.height - myCellMargin.bottom;
int textY = cellBounds.y + (cellBottom + textBoxTop + (int)(metrics.getHeight() - metrics.getDescent())) / 2 ;
int textX = (cellBounds.width - myCellMargin.left - myCellMargin.right - width) / 2 + cellBounds.x + myCellMargin.left;
g.drawString(label, textX, textY);
}
}
示例8: paintComponent
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
@Override
public void paintComponent(Graphics g) {
GraphicsUtil.setupAAPainting(g);
g.setColor(getBackgroundColor());
Dimension size = getSize();
g.fillRoundRect(0, 0, size.width, size.height, ARC_SIZE, ARC_SIZE);
g.setColor(JBColor.WHITE);
Image scaledImage = getScaledImage();
if (scaledImage != null) {
g.setFont(FONT);
g.drawString(myActivityName, PADDING, PADDING + FONT_METRICS.getAscent());
g.drawImage(scaledImage, PADDING, getTopShift(), null);
}
else {
Font font = g.getFont();
int vCenter = getHeight() / 2;
String message = "[" + (myLayoutFile == null ? "no xml resource" : myLayoutFile.getName()) + "]";
center(g, message, font, vCenter);
render(transform.myScale);
}
}
示例9: paintIcon
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
public void paintIcon(final Component c, Graphics graphics) {
if (myCounter <= 0)
return;
final Rectangle moreRect = getIconRec();
if (moreRect == null) return;
int iconY = getIconY(moreRect);
int iconX = getIconX(moreRect);
graphics.setFont(UIUtil.getLabelFont().deriveFont((float)Math.min(8, UIUtil.getButtonFont().getSize())));
int width = graphics.getFontMetrics().stringWidth(String.valueOf(myCounter));
iconX -= width / 2 + 1;
AllIcons.General.MoreTabs.paintIcon(c, graphics, iconX, iconY);
Graphics g = graphics.create();
try {
GraphicsUtil.setupAntialiasing(g, true, true);
UIUtil.drawStringWithHighlighting(g, String.valueOf(myCounter),
iconX + AllIcons.General.MoreTabs.getIconWidth() + 2,
iconY + AllIcons.General.MoreTabs.getIconHeight() - 5,
JBColor.BLACK,
ColorUtil.withAlpha(JBColor.WHITE, .9));
} finally {
g.dispose();
}
}
示例10: paint
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
public void paint(Graphics g) {
setBackground(UIUtil.getPanelBackground());
super.paint(g);
GraphicsUtil.setupAntialiasing(g);
FontMetrics metrics = getFontMetrics(getFont());
EditorColorsScheme colorScheme = myColorScheme != null
? myColorScheme
: EditorColorsManager.getInstance().getGlobalScheme();
g.setColor(myDiffType.getLegendColor(colorScheme));
final int RECT_WIDTH = 35;
g.fill3DRect(0, (getHeight() - 10) / 2, RECT_WIDTH, 10, true);
Font font = g.getFont();
if (font.getStyle() != Font.PLAIN) {
font = font.deriveFont(Font.PLAIN);
}
g.setFont(font);
g.setColor(UIUtil.getLabelForeground());
int textBaseline = (getHeight() - metrics.getHeight()) / 2 + metrics.getAscent();
g.drawString(myDiffType.getDisplayName(), RECT_WIDTH + UIUtil.DEFAULT_HGAP, textBaseline);
}
示例11: paintBorder
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
public void paintBorder(Graphics g, JComponent component, int state) {
if (state == ActionButtonComponent.NORMAL) return;
Rectangle r = new Rectangle(component.getWidth(), component.getHeight());
if (UIUtil.isUnderAquaLookAndFeel()) {
if (state == ActionButtonComponent.POPPED) {
g.setColor(ALPHA_30);
g.drawRoundRect(r.x, r.y, r.width - 2, r.height - 2, 4, 4);
}
}
else {
final double shift = UIUtil.isUnderDarcula() ? 1/0.49 : 0.49;
g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift));
((Graphics2D)g).setStroke(BASIC_STROKE);
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
g.drawRoundRect(r.x, r.y, r.width - 2, r.height - 2, 4, 4);
config.restore();
}
}
示例12: paint
import com.intellij.util.ui.GraphicsUtil; //导入依赖的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();
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();
}
示例13: paint
import com.intellij.util.ui.GraphicsUtil; //导入依赖的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();
}
示例14: paintIcon
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
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();
}
示例15: paintBorder
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
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();
}
}