diff --git a/java/jdkAnnotations/java/awt/annotations.xml b/java/jdkAnnotations/java/awt/annotations.xml index 74edac03f2b4..2f5dca858835 100644 --- a/java/jdkAnnotations/java/awt/annotations.xml +++ b/java/jdkAnnotations/java/awt/annotations.xml @@ -137,6 +137,9 @@ + + + @@ -152,6 +155,12 @@ + + + + + + @@ -248,6 +257,9 @@ + + + diff --git a/java/jdkAnnotations/java/lang/annotations.xml b/java/jdkAnnotations/java/lang/annotations.xml index 62277e2d9364..85221f3da3f0 100644 --- a/java/jdkAnnotations/java/lang/annotations.xml +++ b/java/jdkAnnotations/java/lang/annotations.xml @@ -49,6 +49,9 @@ + + + diff --git a/java/jdkAnnotations/javax/swing/annotations.xml b/java/jdkAnnotations/javax/swing/annotations.xml index 3713bec61165..491030598873 100644 --- a/java/jdkAnnotations/javax/swing/annotations.xml +++ b/java/jdkAnnotations/javax/swing/annotations.xml @@ -491,6 +491,12 @@ + + + + + + diff --git a/platform/platform-api/src/com/intellij/ui/paint/EffectPainter2D.java b/platform/platform-api/src/com/intellij/ui/paint/EffectPainter2D.java index 7140acaf1661..227fc6e6c180 100644 --- a/platform/platform-api/src/com/intellij/ui/paint/EffectPainter2D.java +++ b/platform/platform-api/src/com/intellij/ui/paint/EffectPainter2D.java @@ -321,7 +321,7 @@ public enum EffectPainter2D implements RegionPainter2D { } @Nullable - BufferedImage getImage(Graphics2D g, Color color, double height) { + BufferedImage getImage(@NotNull Graphics2D g, Color color, double height) { ConcurrentHashMap cache = UIUtil.isJreHiDPI(g) ? myHiDPICache : myNormalCache; int key = Objects.hash(color.getRGB(), JBUI.sysScale(g), height); BufferedImage image = cache.get(key); @@ -333,7 +333,7 @@ public enum EffectPainter2D implements RegionPainter2D { } @Nullable - BufferedImage createImage(Graphics2D g, Paint paint, double height) { + BufferedImage createImage(@NotNull Graphics2D g, Paint paint, double height) { double period = getPeriod(height); int width = (int)period << (paint instanceof Color ? 8 : 1); if (width <= 0 || height <= 0) return null; diff --git a/platform/util/src/com/intellij/openapi/ui/GraphicsConfig.java b/platform/util/src/com/intellij/openapi/ui/GraphicsConfig.java index 745290e9684b..78d283dbd680 100644 --- a/platform/util/src/com/intellij/openapi/ui/GraphicsConfig.java +++ b/platform/util/src/com/intellij/openapi/ui/GraphicsConfig.java @@ -16,6 +16,8 @@ package com.intellij.openapi.ui; +import org.jetbrains.annotations.NotNull; + import java.awt.*; import java.util.Map; @@ -28,7 +30,7 @@ public class GraphicsConfig { private final Composite myComposite; private final Stroke myStroke; - public GraphicsConfig(Graphics g) { + public GraphicsConfig(@NotNull Graphics g) { myG = (Graphics2D)g; myHints = (Map)myG.getRenderingHints().clone(); myComposite = myG.getComposite(); diff --git a/platform/util/src/com/intellij/ui/JBColor.java b/platform/util/src/com/intellij/ui/JBColor.java index fb59176a5515..ce176b3173ef 100644 --- a/platform/util/src/com/intellij/ui/JBColor.java +++ b/platform/util/src/com/intellij/ui/JBColor.java @@ -22,7 +22,7 @@ import static com.intellij.util.ObjectUtils.notNull; */ @SuppressWarnings("UseJBColor") public class JBColor extends Color { - public final static Color PanelBackground = namedColor("Panel.background", 0xffffff); + public static final Color PanelBackground = namedColor("Panel.background", 0xffffff); private static class Lazy { private static volatile boolean DARK = UIUtil.isUnderDarcula(); @@ -47,11 +47,13 @@ public class JBColor extends Color { func = function; } + @NotNull public static JBColor namedColor(@NotNull String propertyName, int defaultValueRGB) { return namedColor(propertyName, new Color(defaultValueRGB)); } + @NotNull public static JBColor namedColor(@NotNull final String propertyName, @NotNull final Color defaultColor) { return new JBColor(new NotNullProducer() { @NotNull diff --git a/platform/util/src/com/intellij/util/JBHiDPIScaledImage.java b/platform/util/src/com/intellij/util/JBHiDPIScaledImage.java index 070b80c6c436..565a5edb8a2a 100644 --- a/platform/util/src/com/intellij/util/JBHiDPIScaledImage.java +++ b/platform/util/src/com/intellij/util/JBHiDPIScaledImage.java @@ -110,7 +110,6 @@ public class JBHiDPIScaledImage extends BufferedImage { * @param height the height in user coordinate space * @param rm the rounding mode to apply when converting width/height to the device space * @param type the type - * @param rm the rounding mode */ public JBHiDPIScaledImage(@Nullable GraphicsConfiguration gc, double width, double height, int type, @NotNull RoundingMode rm) { this(JBUI.sysScale(gc), width, height, type, rm); diff --git a/platform/util/src/com/intellij/util/RetinaImage.java b/platform/util/src/com/intellij/util/RetinaImage.java index feab4dac397a..262bd3b83f94 100644 --- a/platform/util/src/com/intellij/util/RetinaImage.java +++ b/platform/util/src/com/intellij/util/RetinaImage.java @@ -64,7 +64,7 @@ public class RetinaImage { // [tav] todo: create HiDPIImage class } @NotNull - public static BufferedImage create(Graphics2D g, double width, double height, int type, RoundingMode rm) { + public static BufferedImage create(Graphics2D g, double width, double height, int type, @NotNull RoundingMode rm) { return new JBHiDPIScaledImage(g, width, height, type, rm); } @@ -74,12 +74,12 @@ public class RetinaImage { // [tav] todo: create HiDPIImage class } @NotNull - public static BufferedImage create(GraphicsConfiguration gc, double width, double height, int type, RoundingMode rm) { + public static BufferedImage create(GraphicsConfiguration gc, double width, double height, int type, @NotNull RoundingMode rm) { return new JBHiDPIScaledImage(gc, width, height, type, rm); } @NotNull - public static BufferedImage create(ScaleContext ctx, double width, double height, int type, RoundingMode rm) { + public static BufferedImage create(ScaleContext ctx, double width, double height, int type, @NotNull RoundingMode rm) { return new JBHiDPIScaledImage(ctx, width, height, type, rm); } diff --git a/platform/util/src/com/intellij/util/ui/JBUI.java b/platform/util/src/com/intellij/util/ui/JBUI.java index 10303d4924d1..0504661b6587 100644 --- a/platform/util/src/com/intellij/util/ui/JBUI.java +++ b/platform/util/src/com/intellij/util/ui/JBUI.java @@ -425,8 +425,9 @@ public class JBUI { * @return the result */ public static float setUserScaleFactor(float scale) { - if (DEBUG_USER_SCALE_FACTOR.isNotNull()) { - float debugScale = ObjectUtils.notNull(DEBUG_USER_SCALE_FACTOR.get()); + Float factor = DEBUG_USER_SCALE_FACTOR.get(); + if (factor != null) { + float debugScale = factor; if (scale == debugScale) { setUserScaleFactorProperty(debugScale); // set the debug value as is, or otherwise ignore } @@ -494,6 +495,7 @@ public class JBUI { return new JBValue.UIInteger(key, defValue); } + @NotNull public static JBDimension size(int width, int height) { return new JBDimension(width, height); } @@ -662,6 +664,7 @@ public class JBUI { @SuppressWarnings("UseDPIAwareBorders") public static class Borders { + @NotNull public static JBEmptyBorder empty(int top, int left, int bottom, int right) { if (top == 0 && left == 0 && bottom == 0 && right == 0) { return SHARED_EMPTY_INSTANCE; @@ -811,6 +814,7 @@ public class JBUI { /** * Creates a context with all scale factors set to 1. */ + @NotNull public static BaseScaleContext createIdentity() { return create(USR_SCALE.of(1)); } @@ -937,8 +941,13 @@ public class JBUI { @Override public int hashCode() { - return Double.valueOf(usrScale.value).hashCode() * 10 + - Double.valueOf(objScale.value).hashCode(); + return hash(usrScale.value) * 31 + hash(objScale.value); + } + + private static int hash(double value) { + // todo replace with Double.hashCode(double) when language level goes up to 8 + long bits = Double.doubleToLongBits(value); + return (int)(bits ^ (bits >>> 32)); } /** @@ -1009,7 +1018,7 @@ public class JBUI { * @param dataProvider provides a data object matching the passed scale context */ public Cache(@NotNull Function dataProvider) { - this.myDataProvider = dataProvider; + myDataProvider = dataProvider; } /** @@ -1733,20 +1742,24 @@ public class JBUI { public static class Focus { private static final Color GRAPHITE_COLOR = new JBColor(new Color(0x8099979d, true), new Color(0x676869)); + @NotNull public static Color focusColor() { return UIUtil.isGraphite() ? GRAPHITE_COLOR : JBColor.namedColor("Component.focusColor", JBColor.namedColor("Focus.borderColor", 0x8ab2eb)); } + @NotNull public static Color defaultButtonColor() { return UIUtil.isUnderDarcula() ? JBColor.namedColor("Button.default.focusColor", JBColor.namedColor("Focus.defaultButtonBorderColor", 0x97c3f3)) : focusColor(); } + @NotNull public static Color errorColor(boolean active) { return active ? JBColor.namedColor("Component.errorFocusColor", JBColor.namedColor("Focus.activeErrorBorderColor", 0xe53e4d)) : JBColor.namedColor("Component.inactiveErrorFocusColor", JBColor.namedColor("Focus.inactiveErrorBorderColor", 0xebbcbc)); } + @NotNull public static Color warningColor(boolean active) { return active ? JBColor.namedColor("Component.warningFocusColor", JBColor.namedColor("Focus.activeWarningBorderColor", 0xe2a53a)) : JBColor.namedColor("Component.inactiveWarningFocusColor", JBColor.namedColor("Focus.inactiveWarningBorderColor", 0xffd385)); @@ -1764,30 +1777,37 @@ public class JBUI { } public static class BigPopup { + @NotNull public static Color headerBackground() { return JBColor.namedColor("SearchEverywhere.Header.background", 0xf2f2f2); } + @NotNull public static Insets tabInsets() { return insets(0, 12); } + @NotNull public static Color selectedTabColor() { return JBColor.namedColor("SearchEverywhere.Tab.selectedBackground", 0xdedede); } + @NotNull public static Color selectedTabTextColor() { return JBColor.namedColor("SearchEverywhere.Tab.selectedForeground", 0x000000); } + @NotNull public static Color searchFieldBackground() { return JBColor.namedColor("SearchEverywhere.SearchField.background", 0xffffff); } + @NotNull public static Color searchFieldBorderColor() { return JBColor.namedColor("SearchEverywhere.SearchField.borderColor", 0xbdbdbd); } + @NotNull public static Insets searchFieldInsets() { return insets(0, 6, 0, 5); } @@ -1796,26 +1816,32 @@ public class JBUI { return scale(600); } + @NotNull public static Color listSeparatorColor() { return JBColor.namedColor("SearchEverywhere.List.separatorColor", Gray.xDC); } + @NotNull public static Color listTitleLabelForeground() { return JBColor.namedColor("SearchEverywhere.List.separatorForeground", UIUtil.getLabelDisabledForeground()); } + @NotNull public static Color searchFieldGrayForeground() { return JBColor.namedColor("SearchEverywhere.SearchField.infoForeground", JBColor.GRAY); } + @NotNull public static Color advertiserForeground() { return JBColor.namedColor("SearchEverywhere.Advertiser.foreground", JBColor.GRAY); } + @NotNull public static Border advertiserBorder() { return new JBEmptyBorder(insets("SearchEverywhere.Advertiser.foreground", insetsLeft(8))); } + @NotNull public static Color advertiserBackground() { return JBColor.namedColor("SearchEverywhere.Advertiser.background", 0xf2f2f2); } @@ -1824,55 +1850,66 @@ public class JBUI { public static class Advertiser { private static final JBInsets DEFAULT_AD_INSETS = insets(1, 5); + @NotNull public static Color foreground() { return JBColor.namedColor("Popup.Advertiser.foreground", UIUtil.getLabelForeground()); } + @NotNull public static Color background() { return JBColor.namedColor("Popup.Advertiser.background", UIUtil.getLabelBackground()); } + @NotNull public static Border border() { return new JBEmptyBorder(insets("Popup.Advertiser.borderInsets", DEFAULT_AD_INSETS)); } + @NotNull public static Color borderColor() { return JBColor.namedColor("Popup.Advertiser.borderColor", Gray._135); } } public static class Validator { + @NotNull public static Color errorBorderColor() { return JBColor.namedColor("ValidationTooltip.errorBorderColor", 0xE0A8A9); } + @NotNull public static Color errorBackgroundColor() { return JBColor.namedColor("ValidationTooltip.errorBackground", JBColor.namedColor("ValidationTooltip.errorBackgroundColor", 0xF5E6E7)); } + @NotNull public static Color warningBorderColor() { return JBColor.namedColor("ValidationTooltip.warningBorderColor", 0xE0CEA8); } + @NotNull public static Color warningBackgroundColor() { return JBColor.namedColor("ValidationTooltip.warningBackground", JBColor.namedColor("ValidationTooltip.warningBackgroundColor", 0xF5F0E6)); } } - @SuppressWarnings("UnregisteredNamedColor") public static class Link { + @NotNull public static Color linkColor() { return JBColor.namedColor("Link.activeForeground", JBColor.namedColor("link.foreground", 0x589df6)); } + @NotNull public static Color linkHoverColor() { return JBColor.namedColor("Link.hoverForeground", JBColor.namedColor("link.hover.foreground", linkColor())); } + @NotNull public static Color linkPressedColor() { return JBColor.namedColor("Link.pressedForeground", JBColor.namedColor("link.pressed.foreground", new JBColor(0xf00000, 0xba6f25))); } + @NotNull public static Color linkVisitedColor() { return JBColor.namedColor("Link.visitedForeground", JBColor.namedColor("link.visited.foreground", new JBColor(0x800080, 0x9776a9))); } diff --git a/platform/util/src/com/intellij/util/ui/MacUIUtil.java b/platform/util/src/com/intellij/util/ui/MacUIUtil.java index f0f17312eddd..cb00033f14ea 100644 --- a/platform/util/src/com/intellij/util/ui/MacUIUtil.java +++ b/platform/util/src/com/intellij/util/ui/MacUIUtil.java @@ -128,6 +128,7 @@ public class MacUIUtil { } } + @NotNull public static Cursor getInvertedTextCursor() { if (INVERTED_TEXT_CURSOR == null) { final Toolkit toolkit = Toolkit.getDefaultToolkit(); diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 367dc29881f3..31ec5a65d25e 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -127,7 +127,7 @@ public class UIUtil { putWindowClientProperty(dialog, "PossibleOwner", Boolean.TRUE); } - public static boolean isPossibleOwner(Dialog dialog) { + public static boolean isPossibleOwner(@NotNull Dialog dialog) { return isWindowClientPropertyTrue(dialog, "PossibleOwner"); } @@ -194,7 +194,8 @@ public class UIUtil { } } - public static Cursor getTextCursor(final Color backgroundColor) { + @NotNull + public static Cursor getTextCursor(@NotNull Color backgroundColor) { return SystemInfo.isMac && ColorUtil.isDark(backgroundColor) ? MacUIUtil.getInvertedTextCursor() : Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR); } @@ -215,10 +216,12 @@ public class UIUtil { drawLine(g, startX, bottomY, endX, bottomY, null, color); } + @NotNull public static RGBImageFilter getGrayFilter() { return GrayFilter.namedFilter("grayFilter", new GrayFilter(33, -35, 100)); } + @NotNull public static RGBImageFilter getTextGrayFilter() { return GrayFilter.namedFilter("text.grayFilter", new GrayFilter(20, 0, 100)); } @@ -277,9 +280,9 @@ public class UIUtil { @SuppressWarnings("AssignmentReplaceableWithOperatorAssignment") public int filterRGB(int x, int y, int rgb) { // Use NTSC conversion formula. - int gray = (int)((0.30 * ((rgb >> 16) & 0xff) + - 0.59 * ((rgb >> 8) & 0xff) + - 0.11 * (rgb & 0xff))); + int gray = (int)(0.30 * (rgb >> 16 & 0xff) + + 0.59 * (rgb >> 8 & 0xff) + + 0.11 * (rgb & 0xff)); if (brightness >= 0) { gray = (int)((gray + brightness * 255) / (1 + brightness)); @@ -289,10 +292,12 @@ public class UIUtil { } if (contrast >= 0) { - if (gray >= 127) + if (gray >= 127) { gray = (int)(gray + (255 - gray) * contrast); - else + } + else { gray = (int)(gray - gray * contrast); + } } else { gray = (int)(127 + (gray - 127) * (contrast + 1)); @@ -303,18 +308,19 @@ public class UIUtil { return (a << 24) | (gray << 16) | (gray << 8) | gray; } + @NotNull public GrayFilterUIResource asUIResource() { return new GrayFilterUIResource(this); } public static class GrayFilterUIResource extends GrayFilter implements UIResource { - public GrayFilterUIResource(GrayFilter filter) { + public GrayFilterUIResource(@NotNull GrayFilter filter) { super(filter.origBrightness, filter.origContrast, filter.alpha); } } @NotNull - public static GrayFilter namedFilter(String resourceName, GrayFilter defaultFilter) { + public static GrayFilter namedFilter(@NotNull String resourceName, @NotNull GrayFilter defaultFilter) { return ObjectUtils.notNull((GrayFilter)UIManager.get(resourceName), defaultFilter); } } @@ -325,7 +331,8 @@ public class UIUtil { return false; } - public static Couple getCellColors(JTable table, boolean isSel, int row, int column) { + @NotNull + public static Couple getCellColors(@NotNull JTable table, boolean isSel, int row, int column) { return Couple.of(isSel ? table.getSelectionForeground() : table.getForeground(), isSel ? table.getSelectionBackground() : table.getBackground()); } @@ -345,7 +352,7 @@ public class UIUtil { } } - public static boolean isDialogFont(Font font) { + public static boolean isDialogFont(@NotNull Font font) { return Font.DIALOG.equals(font.getFamily(Locale.US)); } @@ -353,7 +360,7 @@ public class UIUtil { JScrollPane scrollPane = c != null ? getParentOfType(JScrollPane.class, c) : null; if (scrollPane == null) return true; Rectangle viewRect = scrollPane.getViewport().getViewRect(); - return (c.getHeight() == viewRect.y + viewRect.height); + return c.getHeight() == viewRect.y + viewRect.height; } public enum FontSize {NORMAL, SMALL, MINI} @@ -378,7 +385,7 @@ public class UIUtil { private static final Key UNDO_MANAGER = Key.create("undoManager"); private static final AbstractAction REDO_ACTION = new AbstractAction() { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { UndoManager manager = getClientProperty(e.getSource(), UNDO_MANAGER); if (manager != null && manager.canRedo()) { manager.redo(); @@ -387,7 +394,7 @@ public class UIUtil { }; private static final AbstractAction UNDO_ACTION = new AbstractAction() { @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { UndoManager manager = getClientProperty(e.getSource(), UNDO_MANAGER); if (manager != null && manager.canUndo()) { manager.undo(); @@ -415,13 +422,14 @@ public class UIUtil { @Deprecated public static final Border DEBUG_MARKER_BORDER = new Border() { + @NotNull @Override public Insets getBorderInsets(Component c) { return JBUI.emptyInsets(); } @Override - public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + public void paintBorder(Component c, @NotNull Graphics g, int x, int y, int width, int height) { Graphics g2 = g.create(); try { g2.setColor(JBColor.RED); @@ -492,6 +500,7 @@ public class UIUtil { private static volatile boolean jreHiDPI_earlierVersion; @TestOnly + @NotNull public static AtomicReference test_jreHiDPI() { if (jreHiDPI.get() == null) isJreHiDPIEnabled(); // force init return jreHiDPI; @@ -556,7 +565,7 @@ public class UIUtil { * on the other hand. So let's use a dedicated method. It is rather safe because it caches a * value that has been got on AppKit previously. */ - static boolean isOracleMacRetinaDevice (GraphicsDevice device) { + static boolean isOracleMacRetinaDevice(GraphicsDevice device) { Boolean isRetina = devicesToRetinaSupportCacheMap.get(device); if (isRetina != null) { @@ -600,7 +609,7 @@ public class UIUtil { * @return false if the device of the Graphics2D is not a retina device, * jdk is an Apple JDK or Oracle API has been changed. */ - private static boolean isMacRetina(Graphics2D g) { + private static boolean isMacRetina(@NotNull Graphics2D g) { GraphicsConfiguration configuration = g.getDeviceConfiguration(); if (configuration == null) { return false; @@ -638,7 +647,7 @@ public class UIUtil { } } - public static boolean isRetina(Graphics2D graphics) { + public static boolean isRetina(@NotNull Graphics2D graphics) { return SystemInfo.isMac ? DetectRetinaKit.isMacRetina(graphics) : isRetina(); } @@ -772,6 +781,7 @@ public class UIUtil { component.putClientProperty(key, value); } + @NotNull public static String getHtmlBody(@NotNull String text) { int htmlIndex = 6 + text.indexOf(""); if (htmlIndex < 6) { @@ -792,12 +802,13 @@ public class UIUtil { return text.substring(bodyIndex, Math.min(bodyCloseIndex, htmlCloseIndex)); } - public static String getHtmlBody(Html html) { + @NotNull + public static String getHtmlBody(@NotNull Html html) { String result = getHtmlBody(html.getText()); return html.isKeepFont() ? result : result.replaceAll("", "").replaceAll("", ""); } - public static void drawLinePickedOut(Graphics graphics, int x, int y, int x1, int y1) { + public static void drawLinePickedOut(@NotNull Graphics graphics, int x, int y, int x1, int y1) { if (x == x1) { int minY = Math.min(y, y1); int maxY = Math.max(y, y1); @@ -813,7 +824,7 @@ public class UIUtil { } } - public static boolean isReallyTypedEvent(KeyEvent e) { + public static boolean isReallyTypedEvent(@NotNull KeyEvent e) { char c = e.getKeyChar(); if (c < 0x20 || c == 0x7F) return false; @@ -853,6 +864,7 @@ public class UIUtil { drawDottedRectangle(g, bounds.x, textY, bounds.x + bounds.width - 1, textY + textHeight - 1); } + @NotNull public static Rectangle getLabelTextBounds(@NotNull final JLabel label) { final Dimension size = label.getPreferredSize(); Icon icon = label.getIcon(); @@ -891,11 +903,11 @@ public class UIUtil { return maxHeight; } - public static void setEnabled(Component component, boolean enabled, boolean recursively) { + public static void setEnabled(@NotNull Component component, boolean enabled, boolean recursively) { setEnabled(component, enabled, recursively, false); } - public static void setEnabled(Component component, boolean enabled, boolean recursively, final boolean visibleOnly) { + public static void setEnabled(@NotNull Component component, boolean enabled, boolean recursively, final boolean visibleOnly) { JBIterable all = recursively ? uiTraverser(component).expandAndFilter( visibleOnly ? new Condition() { @Override @@ -906,7 +918,7 @@ public class UIUtil { Color fg = enabled ? getLabelForeground() : getLabelDisabledForeground(); for (Component c : all) { c.setEnabled(enabled); - if (fg != null && c instanceof JLabel) { + if (c instanceof JLabel) { c.setForeground(fg); } } @@ -916,11 +928,11 @@ public class UIUtil { * @deprecated Use {@link LinePainter2D#paint(Graphics2D, double, double, double, double)} instead. */ @Deprecated - public static void drawLine(Graphics g, int x1, int y1, int x2, int y2) { + public static void drawLine(@NotNull Graphics g, int x1, int y1, int x2, int y2) { LinePainter2D.paint((Graphics2D)g, x1, y1, x2, y2); } - public static void drawLine(Graphics2D g, int x1, int y1, int x2, int y2, @Nullable Color bgColor, @Nullable Color fgColor) { + public static void drawLine(@NotNull Graphics2D g, int x1, int y1, int x2, int y2, @Nullable Color bgColor, @Nullable Color fgColor) { Color oldFg = g.getColor(); Color oldBg = g.getBackground(); if (fgColor != null) { @@ -938,12 +950,12 @@ public class UIUtil { } } - public static void drawWave(Graphics2D g, Rectangle rectangle) { + public static void drawWave(@NotNull Graphics2D g, @NotNull Rectangle rectangle) { WavePainter.forColor(g.getColor()).paint(g, (int)rectangle.getMinX(), (int) rectangle.getMaxX(), (int) rectangle.getMaxY()); } @NotNull - public static String[] splitText(String text, FontMetrics fontMetrics, int widthLimit, char separator) { + public static String[] splitText(@NotNull String text, @NotNull FontMetrics fontMetrics, int widthLimit, char separator) { ArrayList lines = new ArrayList(); String currentLine = ""; StringBuilder currentAtom = new StringBuilder(); @@ -997,6 +1009,7 @@ public class UIUtil { } + @NotNull public static Font getLabelFont(@NotNull FontSize size) { return getFont(size, null); } @@ -1008,7 +1021,7 @@ public class UIUtil { return base.deriveFont(getFontSize(size)); } - public static float getFontSize(FontSize size) { + public static float getFontSize(@NotNull FontSize size) { int defSize = getLabelFont().getSize(); switch (size) { case SMALL: @@ -1020,7 +1033,8 @@ public class UIUtil { } } - public static Color getLabelFontColor(FontColor fontColor) { + @NotNull + public static Color getLabelFontColor(@NotNull FontColor fontColor) { Color defColor = getLabelForeground(); if (fontColor == FontColor.BRIGHTER) { return new JBColor(new Color(Math.min(defColor.getRed() + 50, 255), Math.min(defColor.getGreen() + 50, 255), Math.min( @@ -1099,14 +1113,17 @@ public class UIUtil { return UIManager.getColor("Label.background"); } + @NotNull public static Color getLabelForeground() { return JBColor.namedColor("Label.foreground", new JBColor(Gray._0, Gray.xBB)); } + @NotNull public static Color getLabelDisabledForeground() { return JBColor.namedColor("Label.disabledForeground", JBColor.GRAY); } + @NotNull public static Color getContextHelpForeground() { return JBColor.namedColor("Label.infoForeground", Gray.x78); } @@ -1143,11 +1160,13 @@ public class UIUtil { return UIManager.getColor("TableHeader.background"); } + @NotNull @Deprecated public static Color getTreeTextForeground() { return getTreeForeground(); } + @NotNull @Deprecated public static Color getTreeTextBackground() { return getTreeBackground(); @@ -1161,11 +1180,13 @@ public class UIUtil { return UIManager.getColor("textActiveText"); } + @NotNull public static Color getInactiveTextColor() { return JBColor.namedColor("Component.infoForeground", JBColor.GRAY); } - public static Color getSlightlyDarkerColor(Color c) { + @NotNull + public static Color getSlightlyDarkerColor(@NotNull Color c) { float[] hsl = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), new float[3]); return new Color(Color.HSBtoRGB(hsl[0], hsl[1], hsl[2] - .08f > 0 ? hsl[2] - .08f : hsl[2])); } @@ -1185,16 +1206,17 @@ public class UIUtil { /** * @deprecated use com.intellij.util.ui.UIUtil#getInactiveTextColor() */ + @NotNull @Deprecated public static Color getTextInactiveTextColor() { return getInactiveTextColor(); } - public static void installPopupMenuColorAndFonts(final JComponent contentPane) { + public static void installPopupMenuColorAndFonts(@NotNull JComponent contentPane) { LookAndFeel.installColorsAndFont(contentPane, "PopupMenu.background", "PopupMenu.foreground", "PopupMenu.font"); } - public static void installPopupMenuBorder(final JComponent contentPane) { + public static void installPopupMenuBorder(@NotNull JComponent contentPane) { LookAndFeel.installBorder(contentPane, "PopupMenu.border"); } @@ -1210,14 +1232,17 @@ public class UIUtil { return UIManager.getInt("Tree.leftChildIndent"); } + @NotNull public static Color getToolTipBackground() { return JBColor.namedColor("ToolTip.background", new JBColor(Gray.xF2, new Color(0x3c3f41))); } + @NotNull public static Color getToolTipActionBackground() { return JBColor.namedColor("ToolTip.Actions.background", new JBColor(Gray.xEB, new Color(0x43474a))); } + @NotNull public static Color getToolTipForeground() { return JBColor.namedColor("ToolTip.foreground", new JBColor(Gray.x00, Gray.xBB)); } @@ -1234,7 +1259,7 @@ public class UIUtil { return UIManager.getColor("Button.select"); } - public static Integer getPropertyMaxGutterIconWidth(final String propertyPrefix) { + public static Integer getPropertyMaxGutterIconWidth(@NotNull String propertyPrefix) { return (Integer)UIManager.get(propertyPrefix + ".maxGutterIconWidth"); } @@ -1246,7 +1271,7 @@ public class UIUtil { return UIManager.get("MenuItem.disabledForeground"); } - public static Object getTabbedPanePaintContentBorder(final JComponent c) { + public static Object getTabbedPanePaintContentBorder(@NotNull final JComponent c) { return c.getClientProperty("TabbedPane.paintContentBorder"); } @@ -1258,6 +1283,7 @@ public class UIUtil { return UIManager.getColor("Table.gridColor"); } + @NotNull public static Color getPanelBackground() { return JBColor.PanelBackground; } @@ -1290,8 +1316,8 @@ public class UIUtil { return UIManager.getColor("TabbedPane.background"); } - public static void setSliderIsFilled(final JSlider slider, final boolean value) { - slider.putClientProperty("JSlider.isFilled", Boolean.valueOf(value)); + public static void setSliderIsFilled(@NotNull final JSlider slider, final boolean value) { + slider.putClientProperty("JSlider.isFilled", value); } public static Color getLabelTextForeground() { @@ -1310,6 +1336,7 @@ public class UIUtil { return UIManager.getFont("Menu.font"); } + @NotNull @Deprecated public static Color getSeparatorForeground() { return JBUI.CurrentTheme.CustomFrameDecorations.separatorForeground(); @@ -1331,6 +1358,7 @@ public class UIUtil { return UIManager.getColor("nimbusBlueGrey"); } + @NotNull @Deprecated public static Color getSeparatorColor() { return JBUI.CurrentTheme.CustomFrameDecorations.separatorForeground(); @@ -1340,11 +1368,11 @@ public class UIUtil { return UIManager.getBorder("Table.focusCellHighlightBorder"); } - public static void setLineStyleAngled(final ClientPropertyHolder component) { + public static void setLineStyleAngled(@NotNull final ClientPropertyHolder component) { component.putClientProperty("JTree.lineStyle", "Angled"); } - public static void setLineStyleAngled(final JTree component) { + public static void setLineStyleAngled(@NotNull final JTree component) { component.putClientProperty("JTree.lineStyle", "Angled"); } @@ -1355,6 +1383,7 @@ public class UIUtil { /** * @deprecated use com.intellij.util.ui.UIUtil#getPanelBackground() instead */ + @NotNull @Deprecated public static Color getPanelBackgound() { return getPanelBackground(); @@ -1388,14 +1417,17 @@ public class UIUtil { return ObjectUtils.notNull(UIManager.getIcon("OptionPane.warningIcon"), AllIcons.General.WarningDialog); } + @NotNull public static Icon getBalloonInformationIcon() { return AllIcons.General.BalloonInformation; } + @NotNull public static Icon getBalloonWarningIcon() { return AllIcons.General.BalloonWarning; } + @NotNull public static Icon getBalloonErrorIcon() { return AllIcons.General.BalloonError; } @@ -1404,6 +1436,7 @@ public class UIUtil { return UIManager.getIcon("RadioButton.icon"); } + @NotNull public static Icon getTreeNodeIcon(boolean expanded, boolean selected, boolean focused) { boolean white = selected && focused || isUnderDarcula(); @@ -1413,8 +1446,8 @@ public class UIUtil { int width = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth()); int height = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth()); - return new CenteredIcon(expanded ? (white ? getTreeSelectedExpandedIcon() : getTreeExpandedIcon()) - : (white ? getTreeSelectedCollapsedIcon() : getTreeCollapsedIcon()), + return new CenteredIcon(expanded ? white ? getTreeSelectedExpandedIcon() : getTreeExpandedIcon() + : white ? getTreeSelectedCollapsedIcon() : getTreeCollapsedIcon(), width, height, false); } @@ -1612,7 +1645,8 @@ public class UIUtil { "Dust Sand".equalsIgnoreCase(gtkTheme); } - public static Color shade(final Color c, final double factor, final double alphaFactor) { + @NotNull + public static Color shade(@NotNull Color c, final double factor, final double alphaFactor) { assert factor >= 0 : factor; //noinspection UseJBColor return new Color( @@ -1623,7 +1657,8 @@ public class UIUtil { ); } - public static Color mix(final Color c1, final Color c2, final double factor) { + @NotNull + public static Color mix(@NotNull Color c1, final Color c2, final double factor) { assert 0 <= factor && factor <= 1.0 : factor; final double backFactor = 1.0 - factor; //noinspection UseJBColor @@ -1652,10 +1687,12 @@ public class UIUtil { return 1; } + @NotNull public static Insets getListCellPadding() { return JBUI.insets(getListCellVPadding(), getListCellHPadding()); } + @NotNull public static Insets getListViewportPadding() { return isUnderNativeMacLookAndFeel() ? JBUI.insets(1, 0) : JBUI.emptyInsets(); } @@ -1664,10 +1701,11 @@ public class UIUtil { return !isUnderNativeMacLookAndFeel(); } - public static boolean isControlKeyDown(MouseEvent mouseEvent) { + public static boolean isControlKeyDown(@NotNull MouseEvent mouseEvent) { return SystemInfo.isMac ? mouseEvent.isMetaDown() : mouseEvent.isControlDown(); } + @NotNull public static String[] getValidFontNames(final boolean familyName) { Set result = new TreeSet(); @@ -1692,6 +1730,7 @@ public class UIUtil { return ArrayUtil.toStringArray(result); } + @NotNull public static String[] getStandardFontSizes() { return STANDARD_FONT_SIZES; } @@ -1711,7 +1750,7 @@ public class UIUtil { } } - public static void setupEnclosingDialogBounds(final JComponent component) { + public static void setupEnclosingDialogBounds(@NotNull final JComponent component) { component.revalidate(); component.repaint(); final Window window = SwingUtilities.windowForComponent(component); @@ -1721,6 +1760,7 @@ public class UIUtil { } } + @NotNull public static String displayPropertiesToCSS(Font font, Color fg) { @NonNls StringBuilder rule = new StringBuilder("body {"); if (font != null) { @@ -1746,7 +1786,7 @@ public class UIUtil { return rule.toString(); } - public static void appendColor(final Color color, final StringBuilder sb) { + public static void appendColor(@NotNull final Color color, @NotNull StringBuilder sb) { if (color.getRed() < 16) sb.append('0'); sb.append(Integer.toHexString(color.getRed())); if (color.getGreen() < 16) sb.append('0'); @@ -1755,7 +1795,7 @@ public class UIUtil { sb.append(Integer.toHexString(color.getBlue())); } - public static void drawDottedRectangle(Graphics g, Rectangle r) { + public static void drawDottedRectangle(@NotNull Graphics g, @NotNull Rectangle r) { drawDottedRectangle(g, r.x, r.y, r.x + r.width, r.y + r.height); } @@ -1766,7 +1806,7 @@ public class UIUtil { * @param x1 right bottom X coordinate. * @param y1 right bottom Y coordinate. */ - public static void drawDottedRectangle(Graphics g, int x, int y, int x1, int y1) { + public static void drawDottedRectangle(@NotNull Graphics g, int x, int y, int x1, int y1) { int i1; for (i1 = x; i1 <= x1; i1 += 2) { drawLine(g, i1, y, i1, y); @@ -1796,7 +1836,7 @@ public class UIUtil { * @param fgColor Foreground color (optional) * @param opaque If opaque the image will be dr */ - public static void drawBoldDottedLine(final Graphics2D g, + public static void drawBoldDottedLine(@NotNull Graphics2D g, final int startX, final int endX, final int lineY, @@ -1812,7 +1852,7 @@ public class UIUtil { } @SuppressWarnings("UnregisteredNamedColor") - public static void drawSearchMatch(final Graphics2D g, + public static void drawSearchMatch(@NotNull Graphics2D g, final float startX, final float endX, final int height) { @@ -1821,11 +1861,9 @@ public class UIUtil { drawSearchMatch(g, startX, endX, height, c1, c2); } - public static void drawSearchMatch(Graphics2D g, float startXf, float endXf, int height, Color c1, Color c2) { - final boolean drawRound = endXf - startXf > 4; - + public static void drawSearchMatch(@NotNull Graphics2D g, float startXf, float endXf, int height, Color c1, Color c2) { GraphicsConfig config = new GraphicsConfig(g); - float alpha = ((float)JBUI.getInt("SearchMatch.transparency", 70) / 100f); + float alpha = JBUI.getInt("SearchMatch.transparency", 70) / 100f; alpha = alpha < 0 || alpha > 1 ? 0.7f : alpha; g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); g.setPaint(getGradientPaint(startXf, 2, c1, startXf, height - 5, c2)); @@ -1843,6 +1881,7 @@ public class UIUtil { g.fillRect(startX, 3, endX - startX, height - 5); + final boolean drawRound = endXf - startXf > 4; if (drawRound) { drawLine(g ,startX - 1, 4, startX - 1, height - 4); drawLine(g ,endX, 4, endX, height - 4); @@ -1858,14 +1897,14 @@ public class UIUtil { config.restore(); } - public static void drawRectPickedOut(Graphics2D g, int x, int y, int w, int h) { + public static void drawRectPickedOut(@NotNull Graphics2D g, int x, int y, int w, int h) { drawLine(g ,x + 1, y, x + w - 1, y); drawLine(g ,x + w, y + 1, x + w, y + h - 1); drawLine(g ,x + w - 1, y + h, x + 1, y + h); drawLine(g ,x, y + 1, x, y + h - 1); } - private static void drawBoringDottedLine(final Graphics2D g, + private static void drawBoringDottedLine(@NotNull final Graphics2D g, final int startX, final int endX, final int lineY, @@ -1903,17 +1942,17 @@ public class UIUtil { g.setColor(oldColor); } - public static void drawGradientHToolbarBackground(final Graphics g, final int width, final int height) { + public static void drawGradientHToolbarBackground(@NotNull Graphics g, final int width, final int height) { final Graphics2D g2d = (Graphics2D)g; g2d.setPaint(getGradientPaint(0, 0, Gray._215, 0, height, Gray._200)); g2d.fillRect(0, 0, width, height); } - public static void drawHeader(Graphics g, int x, int width, int height, boolean active, boolean drawTopLine) { + public static void drawHeader(@NotNull Graphics g, int x, int width, int height, boolean active, boolean drawTopLine) { drawHeader(g, x, width, height, active, false, drawTopLine, true); } - public static void drawHeader(Graphics g, + public static void drawHeader(@NotNull Graphics g, int x, int width, int height, @@ -1930,12 +1969,13 @@ public class UIUtil { if (drawTopLine) drawLine(g ,x, 0, width, 0); if (drawBottomLine) drawLine(g ,x, height - 1, width, height - 1); - } finally { + } + finally { config.restore(); } } - public static void drawDoubleSpaceDottedLine(final Graphics2D g, + public static void drawDoubleSpaceDottedLine(@NotNull final Graphics2D g, final int start, final int end, final int xOrY, @@ -1953,7 +1993,7 @@ public class UIUtil { } } - private static void drawAppleDottedLine(final Graphics2D g, + private static void drawAppleDottedLine(@NotNull final Graphics2D g, final int startX, final int endX, final int lineY, @@ -1978,7 +2018,7 @@ public class UIUtil { /** This method is intended to use when user settings are not accessible yet. * Use it to set up default RenderingHints. */ - public static void applyRenderingHints(final Graphics g) { + public static void applyRenderingHints(@NotNull Graphics g) { Graphics2D g2d = (Graphics2D)g; Toolkit tk = Toolkit.getDefaultToolkit(); //noinspection HardCodedStringLiteral @@ -2040,7 +2080,7 @@ public class UIUtil { * @throws IllegalArgumentException if {@code width} or {@code height} is not greater than 0 */ @NotNull - public static BufferedImage createImage(GraphicsConfiguration gc, double width, double height, int type, RoundingMode rm) { + public static BufferedImage createImage(GraphicsConfiguration gc, double width, double height, int type, @NotNull RoundingMode rm) { if (isJreHiDPI(gc)) { return RetinaImage.create(gc, width, height, type, rm); } @@ -2053,7 +2093,7 @@ public class UIUtil { * @throws IllegalArgumentException if {@code width} or {@code height} is not greater than 0 */ @NotNull - public static BufferedImage createImage(ScaleContext ctx, double width, double height, int type, RoundingMode rm) { + public static BufferedImage createImage(ScaleContext ctx, double width, double height, int type, @NotNull RoundingMode rm) { if (isJreHiDPI(ctx)) { return RetinaImage.create(ctx, width, height, type, rm); } @@ -2143,7 +2183,7 @@ public class UIUtil { drawImage(g, image, x, y, width, height, null, observer); } - private static void drawImage(Graphics g, Image image, int x, int y, int width, int height, @Nullable BufferedImageOp op, ImageObserver observer) { + private static void drawImage(@NotNull Graphics g, @NotNull Image image, int x, int y, int width, int height, @Nullable BufferedImageOp op, ImageObserver observer) { Rectangle srcBounds = width >= 0 && height >= 0 ? new Rectangle(x, y, width, height) : null; drawImage(g, image, new Rectangle(x, y, width, height), srcBounds, op, observer); } @@ -2181,10 +2221,7 @@ public class UIUtil { @Nullable Rectangle dstBounds, @Nullable Rectangle srcBounds, @Nullable BufferedImageOp op, - @Nullable ImageObserver observer) - { - Graphics2D invG = null; - double scale = 1; + @Nullable ImageObserver observer) { int userWidth = ImageUtil.getUserWidth(image); int userHeight = ImageUtil.getUserHeight(image); @@ -2200,6 +2237,8 @@ public class UIUtil { } boolean hasDstSize = dw >= 0 && dh >= 0; + Graphics2D invG = null; + double scale = 1; if (image instanceof JBHiDPIScaledImage) { JBHiDPIScaledImage hidpiImage = (JBHiDPIScaledImage)image; Image delegate = hidpiImage.getDelegate(); @@ -2274,7 +2313,7 @@ public class UIUtil { drawImage(g, image, x, y, -1, -1, op, null); } - public static void paintWithXorOnRetina(@NotNull Dimension size, @NotNull Graphics g, Consumer paintRoutine) { + public static void paintWithXorOnRetina(@NotNull Dimension size, @NotNull Graphics g, @NotNull Consumer paintRoutine) { paintWithXorOnRetina(size, g, true, paintRoutine); } @@ -2284,7 +2323,7 @@ public class UIUtil { public static void paintWithXorOnRetina(@NotNull Dimension size, @NotNull Graphics g, boolean useRetinaCondition, - Consumer paintRoutine) { + @NotNull Consumer paintRoutine) { if (!useRetinaCondition || !isJreHiDPI((Graphics2D)g) || Registry.is("ide.mac.retina.disableDrawingFix")) { paintRoutine.consume((Graphics2D)g); } @@ -2329,13 +2368,7 @@ public class UIUtil { public static void dispatchAllInvocationEvents() { assert EdtInvocationManager.getInstance().isEventDispatchThread() : Thread.currentThread() + "; EDT: "+getEventQueueThread(); EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); - Method dispatchEventMethod; - try { - dispatchEventMethod = eventQueue.getClass().getDeclaredMethod("dispatchEvent", AWTEvent.class); - } - catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } + Method dispatchEventMethod = ReflectionUtil.getDeclaredMethod(eventQueue.getClass(), "dispatchEvent", AWTEvent.class); for (int i = 1; ; i++) { AWTEvent event = eventQueue.peekEvent(); if (event == null) break; @@ -2359,6 +2392,7 @@ public class UIUtil { } } + @NotNull private static Thread getEventQueueThread() { EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); try { @@ -2390,7 +2424,7 @@ public class UIUtil { } } - public static void addAwtListener(final AWTEventListener listener, long mask, Disposable parent) { + public static void addAwtListener(@NotNull final AWTEventListener listener, long mask, @NotNull Disposable parent) { Toolkit.getDefaultToolkit().addAWTEventListener(listener, mask); Disposer.register(parent, new Disposable() { @Override @@ -2408,19 +2442,19 @@ public class UIUtil { component.removePropertyChangeListener("ancestor", listener); } - public static void drawVDottedLine(Graphics2D g, int lineX, int startY, int endY, @Nullable final Color bgColor, final Color fgColor) { + public static void drawVDottedLine(@NotNull Graphics2D g, int lineX, int startY, int endY, @Nullable final Color bgColor, final Color fgColor) { if (bgColor != null) { g.setColor(bgColor); drawLine(g, lineX, startY, lineX, endY); } g.setColor(fgColor); - for (int i = (startY / 2) * 2; i < endY; i += 2) { + for (int i = startY / 2 * 2; i < endY; i += 2) { g.drawRect(lineX, i, 0, 0); } } - public static void drawHDottedLine(Graphics2D g, int startX, int endX, int lineY, @Nullable final Color bgColor, final Color fgColor) { + public static void drawHDottedLine(@NotNull Graphics2D g, int startX, int endX, int lineY, @Nullable final Color bgColor, final Color fgColor) { if (bgColor != null) { g.setColor(bgColor); drawLine(g, startX, lineY, endX, lineY); @@ -2428,12 +2462,12 @@ public class UIUtil { g.setColor(fgColor); - for (int i = (startX / 2) * 2; i < endX; i += 2) { + for (int i = startX / 2 * 2; i < endX; i += 2) { g.drawRect(i, lineY, 0, 0); } } - public static void drawDottedLine(Graphics2D g, int x1, int y1, int x2, int y2, @Nullable final Color bgColor, final Color fgColor) { + public static void drawDottedLine(@NotNull Graphics2D g, int x1, int y1, int x2, int y2, @Nullable final Color bgColor, final Color fgColor) { if (x1 == x2) { drawVDottedLine(g, x1, y1, y2, bgColor, fgColor); } @@ -2445,7 +2479,7 @@ public class UIUtil { } } - public static void drawStringWithHighlighting(Graphics g, String s, int x, int y, Color foreground, Color highlighting) { + public static void drawStringWithHighlighting(@NotNull Graphics g, @NotNull String s, int x, int y, Color foreground, Color highlighting) { g.setColor(highlighting); boolean isRetina = isJreHiDPI((Graphics2D)g); float scale = 1 / JBUI.sysScale((Graphics2D)g); @@ -2466,7 +2500,7 @@ public class UIUtil { * @param horzCentered if true, the string will be centered horizontally * @param vertCentered if true, the string will be centered vertically */ - public static void drawCenteredString(Graphics2D g, Rectangle rect, String str, boolean horzCentered, boolean vertCentered) { + public static void drawCenteredString(@NotNull Graphics2D g, @NotNull Rectangle rect, @NotNull String str, boolean horzCentered, boolean vertCentered) { FontMetrics fm = g.getFontMetrics(g.getFont()); int textWidth = fm.stringWidth(str) - 1; int x = horzCentered ? Math.max(rect.x, rect.x + (rect.width - textWidth) / 2) : rect.x; @@ -2483,7 +2517,7 @@ public class UIUtil { * @param rect the {@link Rectangle} to use as bounding box * @param str the string to draw */ - public static void drawCenteredString(Graphics2D g, Rectangle rect, String str) { + public static void drawCenteredString(@NotNull Graphics2D g, @NotNull Rectangle rect, @NotNull String str) { drawCenteredString(g, rect, str, true, true); } @@ -2500,24 +2534,24 @@ public class UIUtil { } - public static boolean isCloseClick(MouseEvent e) { + public static boolean isCloseClick(@NotNull MouseEvent e) { return isCloseClick(e, MouseEvent.MOUSE_PRESSED); } - public static boolean isCloseClick(MouseEvent e, int effectiveType) { + public static boolean isCloseClick(@NotNull MouseEvent e, int effectiveType) { if (e.isPopupTrigger() || e.getID() != effectiveType) return false; return e.getButton() == MouseEvent.BUTTON2 || e.getButton() == MouseEvent.BUTTON1 && e.isShiftDown(); } - public static boolean isActionClick(MouseEvent e) { + public static boolean isActionClick(@NotNull MouseEvent e) { return isActionClick(e, MouseEvent.MOUSE_PRESSED); } - public static boolean isActionClick(MouseEvent e, int effectiveType) { + public static boolean isActionClick(@NotNull MouseEvent e, int effectiveType) { return isActionClick(e, effectiveType, false); } - public static boolean isActionClick(MouseEvent e, int effectiveType, boolean allowShift) { + public static boolean isActionClick(@NotNull MouseEvent e, int effectiveType, boolean allowShift) { if (!allowShift && isCloseClick(e) || e.isPopupTrigger() || e.getID() != effectiveType) return false; return e.getButton() == MouseEvent.BUTTON1; } @@ -2573,11 +2607,13 @@ public class UIUtil { } } + @NotNull @Language("HTML") public static String getCssFontDeclaration(@NotNull Font font) { return getCssFontDeclaration(font, null, null, null); } + @NotNull @Language("HTML") public static String getCssFontDeclaration(@NotNull Font font, @Nullable Color fgColor, @Nullable Color linkColor, @Nullable String liImg) { StringBuilder builder = new StringBuilder().append("