本文整理汇总了Java中com.intellij.util.ui.GraphicsUtil类的典型用法代码示例。如果您正苦于以下问题:Java GraphicsUtil类的具体用法?Java GraphicsUtil怎么用?Java GraphicsUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsUtil类属于com.intellij.util.ui包,在下文中一共展示了GraphicsUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PreferenceButton.java
示例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));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:DividerPolygon.java
示例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();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:CaptionIcon.java
示例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();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:IdeaActionButtonLook.java
示例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));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GotItPanel.java
示例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();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TestTreeView.java
示例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);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ASGallery.java
示例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);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AndroidRootComponent.java
示例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();
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:MoreTabsIcon.java
示例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);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:DiffStatusBar.java
示例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();
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:IdeaActionButtonLook.java
示例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();
}
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:RectangleReferencePainter.java
示例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();
}
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:RectanglePainter.java
示例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();
}
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:LabelIcon.java
示例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();
}
}
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:ActionButtonUI.java
示例16: windowOpened
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
@Override
public void windowOpened(final WindowEvent e) {
if (SystemInfo.isMacOSLion) {
Window window = e.getWindow();
if (window instanceof Dialog) {
ID _native = MacUtil.findWindowForTitle(((Dialog)window).getTitle());
if (_native != null && _native.intValue() > 0) {
// see MacMainFrameDecorator
// NSCollectionBehaviorFullScreenAuxiliary = 1 << 8
Foundation.invoke(_native, "setCollectionBehavior:", 1 << 8);
}
}
}
SwingUtilities.invokeLater(() -> {
myOpened = true;
final DialogWrapper activeWrapper = getActiveWrapper();
for (JComponent c : UIUtil.uiTraverser(e.getWindow()).filter(JComponent.class)) {
GraphicsUtil.setAntialiasingType(c, AntialiasingType.getAAHintForSwingComponent());
}
if (activeWrapper == null) {
myFocusedCallback.setRejected();
myTypeAheadDone.setRejected();
}
});
}
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:DialogWrapperPeerImpl.java
示例17: paintBorder
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
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();
}
}
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:PoppedIcon.java
示例18: customize
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
@Override
public void customize(JList list, AntialiasingType value, int index, boolean selected, boolean hasFocus) {
if (value == AntialiasingType.SUBPIXEL) {
GraphicsUtil.generatePropertiesForAntialiasing(SUBPIXEL_HINT, this::setClientProperty);
}
else if (value == AntialiasingType.GREYSCALE) {
GraphicsUtil.generatePropertiesForAntialiasing(GREYSCALE_HINT, this::setClientProperty);
}
else if (value == AntialiasingType.OFF) {
GraphicsUtil.generatePropertiesForAntialiasing(null, this::setClientProperty);
}
if (useEditorAASettings) {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
setFont(new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize()));
}
setText(String.valueOf(value));
}
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:AppearanceConfigurable.java
示例19: paint
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
@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);
}
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:DarculaButtonUI.java
示例20: paint
import com.intellij.util.ui.GraphicsUtil; //导入依赖的package包/类
@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());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:WizardArrowUI.java
注:本文中的com.intellij.util.ui.GraphicsUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论