@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); }
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)); } }
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(); }
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(); } }
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)); }
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(); }
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); } }
@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); } }
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(); } }
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); }
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(); } }
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(); }
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(); }
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(); }
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(); } }
@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(); } }); }
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(); } }
@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)); }
@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); }
@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()); }
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(); }
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(); }
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(); }
@Override public void paint(Graphics g) { GraphicsUtil.setupAntialiasing(g); super.paint(g); LayoutManager layout = getLayout(); if (layout instanceof MyLayout) { ((MyLayout)layout).paintIfNeed(g); } }
@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); } }
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(); }
@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); } }
@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); }
@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); } }
@Override public void paint(Graphics g, JComponent c) { int w = c.getWidth(); int h = c.getHeight(); if (isHelpButton(c)) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, getButtonColor1(), 0, h, getButtonColor2())); int off = JBUI.scale(22); int x = (w - off) / 2; int y = (h - off) / 2; g.fillOval(x, y, off, off); AllIcons.Actions.Help.paintIcon(c, g, x + JBUI.scale(3), y + JBUI.scale(3)); } else { 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 (isDefaultButton(c)) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, getSelectedButtonColor1(), 0, h, getSelectedButtonColor2())); } else { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, getButtonColor1(), 0, h, getButtonColor2())); } } int rad = JBUI.scale(square ? 3 : 5); g.fillRoundRect(JBUI.scale(square ? 2 : 4), yOff, w - 2 * JBUI.scale(4), h - 2 * yOff, rad, rad); } config.restore(); super.paint(g, c); } }
public static Icon getLiveIndicator(@Nullable final Icon base) { return new LayeredIcon(base, new Icon() { @SuppressWarnings("UseJBColor") @Override public void paintIcon(Component c, Graphics g, int x, int y) { int iSize = JBUI.scale(4); Graphics2D g2d = (Graphics2D)g.create(); try { GraphicsUtil.setupAAPainting(g2d); g2d.setColor(Color.GREEN); Ellipse2D.Double shape = new Ellipse2D.Double(x + getIconWidth() - JBUI.scale(iSize), y + getIconHeight() - iSize, iSize, iSize); g2d.fill(shape); g2d.setColor(ColorUtil.withAlpha(Color.BLACK, .40)); g2d.draw(shape); } finally { g2d.dispose(); } } @Override public int getIconWidth() { return base != null ? base.getIconWidth() : 13; } @Override public int getIconHeight() { return base != null ? base.getIconHeight() : 13; } }); }
private static JRadioButtonMenuItem createRadioButtonMenuItem(final String message) { return new JRadioButtonMenuItem(message) { @Override public void paint(Graphics g) { GraphicsUtil.setupAntialiasing(g); super.paint(g); } }; }
@Override public void executePaint(Component component, Graphics2D g) { if (myBoundingBox == null) return; GraphicsUtil.setupAAPainting(g); g.setColor(ColorUtil.toAlpha(myColor, 200)); g.setStroke(new BasicStroke(2)); g.draw(myBoundingBox); g.setColor(ColorUtil.toAlpha(myColor, 40)); g.fill(myBoundingBox); }