Browse Source

Removed annotations, as they weren't used consequently and clashed with some builds.

Signed-off-by: weisj <weisj@arcor.de>
pull/27/head
weisj 5 years ago
parent
commit
6254d97f1d
  1. 1
      build.gradle
  2. 38
      src/main/java/com/github/weisj/darklaf/DarkLaf.java
  3. 5
      src/main/java/com/github/weisj/darklaf/LafManager.java
  4. 13
      src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java
  5. 10
      src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java
  6. 10
      src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java
  7. 17
      src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java
  8. 18
      src/main/java/com/github/weisj/darklaf/components/ArrowButton.java
  9. 4
      src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java
  10. 28
      src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java
  11. 11
      src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java
  12. 16
      src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java
  13. 8
      src/main/java/com/github/weisj/darklaf/components/ScrollPopupMenu.java
  14. 48
      src/main/java/com/github/weisj/darklaf/components/alignment/Alignment.java
  15. 11
      src/main/java/com/github/weisj/darklaf/components/alignment/AlignmentHelper.java
  16. 66
      src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java
  17. 10
      src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java
  18. 16
      src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java
  19. 4
      src/main/java/com/github/weisj/darklaf/components/border/MutableLineBorder.java
  20. 4
      src/main/java/com/github/weisj/darklaf/components/border/WeakLineBorder.java
  21. 74
      src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java
  22. 3
      src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java
  23. 4
      src/main/java/com/github/weisj/darklaf/components/tabframe/TabArea.java
  24. 74
      src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java
  25. 6
      src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java
  26. 6
      src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java
  27. 5
      src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java
  28. 3
      src/main/java/com/github/weisj/darklaf/components/tooltip/DarkToolTip.java
  29. 31
      src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java
  30. 5
      src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java
  31. 14
      src/main/java/com/github/weisj/darklaf/components/uiresource/Insets2D.java
  32. 4
      src/main/java/com/github/weisj/darklaf/decorators/HoverListener.java
  33. 4
      src/main/java/com/github/weisj/darklaf/decorators/LayoutManagerDelegate.java
  34. 4
      src/main/java/com/github/weisj/darklaf/decorators/MouseResponder.java
  35. 10
      src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java
  36. 12
      src/main/java/com/github/weisj/darklaf/icons/DarkUIAwareIcon.java
  37. 21
      src/main/java/com/github/weisj/darklaf/icons/EmptyIcon.java
  38. 7
      src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java
  39. 33
      src/main/java/com/github/weisj/darklaf/icons/IconLoader.java
  40. 4
      src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java
  41. 7
      src/main/java/com/github/weisj/darklaf/icons/RotatableIcon.java
  42. 3
      src/main/java/com/github/weisj/darklaf/icons/ScaledIcon.java
  43. 3
      src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java
  44. 7
      src/main/java/com/github/weisj/darklaf/log/LogFormatter.java
  45. 9
      src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java
  46. 3
      src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorations.java
  47. 5
      src/main/java/com/github/weisj/darklaf/theme/Theme.java
  48. 10
      src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java
  49. 129
      src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  50. 47
      src/main/java/com/github/weisj/darklaf/ui/button/DarkToggleButtonUI.java
  51. 3
      src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java
  52. 10
      src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxMenuItemUI.java
  53. 27
      src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxUI.java
  54. 5
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPipette.java
  55. 8
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPreviewComponent.java
  56. 30
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorValueFormatter.java
  57. 3
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheel.java
  58. 4
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheelPanel.java
  59. 10
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java
  60. 5
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserUI.java
  61. 7
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java
  62. 6
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/MainSwatchPanel.java
  63. 4
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java
  64. 9
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java
  65. 16
      src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java
  66. 19
      src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java
  67. 5
      src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java
  68. 5
      src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java
  69. 4
      src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconUI.java
  70. 3
      src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameBorder.java
  71. 7
      src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java
  72. 6
      src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java
  73. 3
      src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java
  74. 3
      src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellRenderer.java
  75. 13
      src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java
  76. 3
      src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java
  77. 4
      src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java
  78. 4
      src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarUI.java
  79. 179
      src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java
  80. 173
      src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java
  81. 17
      src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java
  82. 4
      src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java
  83. 6
      src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java
  84. 5
      src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuBorder.java
  85. 7
      src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuSeparatorUI.java
  86. 13
      src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java
  87. 78
      src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarUI.java
  88. 11
      src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java
  89. 21
      src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonUI.java
  90. 3
      src/main/java/com/github/weisj/darklaf/ui/rootpane/CloseButtonUI.java
  91. 10
      src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java
  92. 67
      src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkTitlePane.java
  93. 8
      src/main/java/com/github/weisj/darklaf/ui/rootpane/SubstanceRootLayout.java
  94. 6
      src/main/java/com/github/weisj/darklaf/ui/rootpane/TitlePaneIcon.java
  95. 49
      src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java
  96. 6
      src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java
  97. 4
      src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollLayoutManagerDelegate.java
  98. 8
      src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java
  99. 91
      src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java
  100. 5
      src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java
  101. Some files were not shown because too many files have changed in this diff Show More

1
build.gradle

@ -31,7 +31,6 @@ repositories {
dependencies {
compile 'com.metsci.ext.com.kitfox.svg:svg-salamander:[0.1.19,)'
compile 'org.jetbrains:annotations:16.0.1'
compile 'net.java.dev.jna:jna:4.1.0'
compile 'org.swinglabs:jxlayer:3.0.4'
compileOnly 'org.swinglabs:swingx:1.6.1'

38
src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -29,8 +29,6 @@ import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.util.PropertyLoader;
import com.github.weisj.darklaf.util.SystemInfo;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.awt.AppContext;
import javax.swing.*;
@ -72,13 +70,13 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
final String name = UIManager.getSystemLookAndFeelClassName();
base = (BasicLookAndFeel) Class.forName(name).getDeclaredConstructor().newInstance();
}
} catch (@NotNull final Exception e) {
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e.getStackTrace());
throw new IllegalStateException("Could not load base LaF class." + e.getMessage());
}
}
@Contract(pure = true)
public static boolean isDecorationsEnabled() {
return LafManager.getTheme().useCustomDecorations() && decorationsEnabled;
}
@ -113,7 +111,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
JDialog.setDefaultLookAndFeelDecorated(true);
return defaults;
} catch (@NotNull final Exception e) {
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.toString(), e.getStackTrace());
}
return super.getDefaults();
@ -128,14 +126,14 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
}
}
@NotNull
@Override
public String getName() {
return NAME;
}
@SuppressWarnings({"HardCodedStringLiteral"})
private static void initInputMapDefaults(@NotNull final UIDefaults defaults) {
private static void initInputMapDefaults(final UIDefaults defaults) {
// Make ENTER work in JTrees
final InputMap treeInputMap = (InputMap) defaults.get("Tree.focusInputMap");
if (treeInputMap != null) {
@ -172,7 +170,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
}
}
private void loadThemeDefaults(@NotNull final UIDefaults defaults) {
private void loadThemeDefaults(final UIDefaults defaults) {
Properties uiProps = new Properties();
final Theme currentTheme = LafManager.getTheme();
currentTheme.loadDefaults(uiProps, defaults);
@ -189,7 +187,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
}
@SuppressWarnings({"HardCodedStringLiteral"})
private void initIdeaDefaults(@NotNull final UIDefaults defaults) {
private void initIdeaDefaults(final UIDefaults defaults) {
defaults.put("Table.ancestorInputMap", new UIDefaults.LazyInputMap(
new Object[]{
"ctrl C", "copy",
@ -244,20 +242,20 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
}));
}
@NotNull
@Override
public String getID() {
return getName();
}
private static void patchComboBox(@NotNull final UIDefaults metalDefaults, @NotNull final UIDefaults defaults) {
private static void patchComboBox(final UIDefaults metalDefaults, final UIDefaults defaults) {
defaults.remove("ComboBox.ancestorInputMap");
defaults.remove("ComboBox.actionMap");
defaults.put("ComboBox.ancestorInputMap", metalDefaults.get("ComboBox.ancestorInputMap"));
defaults.put("ComboBox.actionMap", metalDefaults.get("ComboBox.actionMap"));
}
private static void installCutCopyPasteShortcuts(@NotNull final InputMap inputMap,
private static void installCutCopyPasteShortcuts(final InputMap inputMap,
final boolean useSimpleActionKeys) {
final String copyActionKey = useSimpleActionKeys ? "copy" : DefaultEditorKit.copyAction;
final String pasteActionKey = useSimpleActionKeys ? "paste" : DefaultEditorKit.pasteAction;
@ -272,7 +270,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK), DefaultEditorKit.cutAction);
}
private void installGlobals(@NotNull final Properties uiProps, final UIDefaults defaults) {
private void installGlobals(final Properties uiProps, final UIDefaults defaults) {
final HashMap<String, Object> globalSettings = new HashMap<>();
final String prefix = "global.";
for (final Object key : uiProps.keySet()) {
@ -292,7 +290,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
}
}
@NotNull
@Override
public String getDescription() {
return "Dark Look and feel based on Darcula-LAF";
@ -341,7 +339,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
"loadSystemColors", UIDefaults.class, String[].class, boolean.class);
superMethod.setAccessible(true);
superMethod.invoke(base, defaults, systemColors, useNative);
} catch (@NotNull final Exception e) {
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.toString(), e.getStackTrace());
}
}
@ -355,28 +353,28 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
return true;
}
private void callInit(@NotNull final String method, final UIDefaults defaults) {
private void callInit(final String method, final UIDefaults defaults) {
try {
final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method, UIDefaults.class);
superMethod.setAccessible(true);
superMethod.invoke(base, defaults);
} catch (@NotNull final Exception e) {
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.toString(), e.getStackTrace());
}
}
private void call(@NotNull final String method) {
private void call(final String method) {
try {
final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method);
superMethod.setAccessible(true);
superMethod.invoke(base);
} catch (@NotNull final Exception e) {
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.toString(), e.getStackTrace());
}
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
public void propertyChange(final PropertyChangeEvent evt) {
if ("lookAndFeel".equals(evt.getPropertyName())) {
if (UIManager.getLookAndFeel() == this) {
PropertyLoader.finish();

5
src/main/java/com/github/weisj/darklaf/LafManager.java

@ -26,7 +26,6 @@ package com.github.weisj.darklaf;
import com.github.weisj.darklaf.theme.DarculaTheme;
import com.github.weisj.darklaf.theme.IntelliJTheme;
import com.github.weisj.darklaf.theme.Theme;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -139,7 +138,7 @@ public final class LafManager {
try {
UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName());
updateLaf();
} catch (@NotNull final ClassNotFoundException
} catch (final ClassNotFoundException
| InstantiationException
| IllegalAccessException
| UnsupportedLookAndFeelException e) {
@ -156,7 +155,7 @@ public final class LafManager {
}
}
private static void updateLafRecursively(@NotNull final Window window) {
private static void updateLafRecursively(final Window window) {
for (final Window childWindow : window.getOwnedWindows()) {
updateLafRecursively(childWindow);
}

13
src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.color;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -37,12 +34,12 @@ public class DarkColorModel {
private final String prefix;
private final String[] labels;
@Contract(pure = true)
public DarkColorModel() {
this("rgb", "Red", "Green", "Blue");
}
@Contract(pure = true)
public DarkColorModel(final String name, final String... labels) {
this.prefix = "ColorChooser." + name;
this.labels = labels;
@ -64,7 +61,7 @@ public class DarkColorModel {
return 0;
}
public final String getText(@NotNull final Component component, final String suffix) {
public final String getText(final Component component, final String suffix) {
return UIManager.getString(this.prefix + suffix + "Text", component.getLocale());
}
@ -85,11 +82,11 @@ public class DarkColorModel {
return new char[]{Character.MIN_VALUE, Character.MIN_VALUE, Character.MIN_VALUE, Character.MIN_VALUE};
}
public int[] getValuesFromColor(@NotNull final Color color) {
public int[] getValuesFromColor(final Color color) {
return new int[]{color.getRed(), color.getGreen(), color.getBlue()};
}
public Color getColorFromValues(@NotNull final int[] values) {
public Color getColorFromValues(final int[] values) {
return new Color(values[0], values[1], values[2]);
}
}

10
src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.color;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
/**
@ -65,11 +63,11 @@ public class DarkColorModelCMYK extends DarkColorModel {
}
@Override
public int[] getValuesFromColor(@NotNull final Color color) {
public int[] getValuesFromColor(final Color color) {
return RGBtoCMYK(color.getRed(), color.getGreen(), color.getBlue());
}
@NotNull
private static int[] RGBtoCMYK(final int r, final int g, final int b) {
double max = DarkColorModelHSL.max(r / 255.0, g / 255.0, b / 255.0);
if (max > 0.0f) {
@ -86,12 +84,12 @@ public class DarkColorModelCMYK extends DarkColorModel {
}
@Override
public Color getColorFromValues(@NotNull final int[] values) {
public Color getColorFromValues(final int[] values) {
int[] rgb = CMYKtoRGB(values[0] / 100.0, values[1] / 100.0, values[2] / 100.0, values[3] / 100.0);
return new Color(rgb[0], rgb[1], rgb[2]);
}
@NotNull
private static int[] CMYKtoRGB(final double c, final double m, final double y, final double k) {
rgb[0] = (int) Math.round(255 * (1.0f + c * k - k - c));
rgb[1] = (int) Math.round(255 * (1.0f + m * k - k - m));

10
src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.color;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
/**
@ -61,12 +58,11 @@ public class DarkColorModelHSB extends DarkColorModel {
}
@Override
public int[] getValuesFromColor(@NotNull final Color color) {
public int[] getValuesFromColor(final Color color) {
return RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue());
}
@Contract("_, _, _ -> new")
@NotNull
public static int[] RGBtoHSB(final int r, final int g, final int b) {
double hue, saturation, brightness;
int cmax = Math.max(r, g);
@ -105,7 +101,7 @@ public class DarkColorModelHSB extends DarkColorModel {
}
@Override
public Color getColorFromValues(@NotNull final int[] values) {
public Color getColorFromValues(final int[] values) {
int[] rgb = HSBtoRGB(values[0] / 360.0, values[1] / 100.0, values[2] / 100.0);
return new Color(rgb[0], rgb[1], rgb[2]);
}

17
src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.color;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
/**
@ -61,11 +58,11 @@ public class DarkColorModelHSL extends DarkColorModel {
}
@Override
public int[] getValuesFromColor(@NotNull final Color color) {
public int[] getValuesFromColor(final Color color) {
return RGBtoHSL(color.getRed(), color.getGreen(), color.getBlue());
}
@NotNull
private static int[] RGBtoHSL(final int r, final int g, final int b) {
double max = max(r, g, b) / 255.0;
double min = min(r, g, b) / 255.0;
@ -83,7 +80,7 @@ public class DarkColorModelHSL extends DarkColorModel {
return hsl;
}
@Contract(pure = true)
protected static double max(final double red, final double green, final double blue) {
double max = Math.max(red, green);
return Math.max(max, blue);
@ -94,7 +91,7 @@ public class DarkColorModelHSL extends DarkColorModel {
return Math.min(min, blue);
}
@Contract(pure = true)
private static double getHue(final double red, final double green, final double blue,
final double max, final double min) {
double hue = max - min;
@ -115,12 +112,12 @@ public class DarkColorModelHSL extends DarkColorModel {
}
@Override
public Color getColorFromValues(@NotNull final int[] values) {
public Color getColorFromValues(final int[] values) {
int[] rgb = HSLtoRGB(values[0] / 360.0, values[1] / 100.0, values[2] / 100.0);
return new Color(rgb[0], rgb[1], rgb[2]);
}
@NotNull
private static int[] HSLtoRGB(final double h, final double saturation, final double lightness) {
double hue = h;
@ -139,7 +136,7 @@ public class DarkColorModelHSL extends DarkColorModel {
return rgb;
}
@Contract(pure = true)
private static double normalize(final double q, final double p, final double color) {
if (color < 1.0f) {
return p + (q - p) * color;

18
src/main/java/com/github/weisj/darklaf/components/ArrowButton.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.icons.UIAwareIcon;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.DimensionUIResource;
@ -37,18 +35,18 @@ import java.awt.*;
*/
public final class ArrowButton implements SwingConstants {
@Contract(pure = true)
private ArrowButton() {
}
@NotNull
public static JButton createUpDownArrow(final JComponent parent, final int orientation,
final boolean center) {
return createUpDownArrow(parent, orientation, center, false,
new Insets(0, 0, 0, 0));
}
@NotNull
public static JButton createUpDownArrow(final JComponent parent, final int orientation,
final boolean center, final boolean applyInsetsOnSize,
final Insets insets) {
@ -66,8 +64,7 @@ public final class ArrowButton implements SwingConstants {
return createUpDownArrow(parent, icon, icon.getDual(), orientation, center, applyInsetsOnSize, insets);
}
@Contract("_, _, _, _, _, _, _ -> new")
@NotNull
public static JButton createUpDownArrow(final JComponent parent,
final Icon activeIcon, final Icon inactiveIcon,
final int orientation, final boolean center,
@ -103,14 +100,13 @@ public final class ArrowButton implements SwingConstants {
getIcon().paintIcon(this, g, x, y);
}
@NotNull
@Override
public Insets getInsets() {
return getInsets(new Insets(0, 0, 0, 0));
}
@NotNull
@Contract("_ -> param1")
@Override
public Insets getInsets(final Insets i) {
i.left = insets.left;
@ -120,7 +116,7 @@ public final class ArrowButton implements SwingConstants {
return i;
}
@Contract(pure = true)
@Override
public boolean isOpaque() {
return false;

4
src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.components;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.beans.PropertyVetoException;
@ -85,7 +83,7 @@ public class ClosableTabbedPane extends JTabbedPane {
return false;
}
private void notifyTabListeners(@NotNull final TabEvent event) {
private void notifyTabListeners(final TabEvent event) {
TabListener[] listeners = listenerList.getListeners(TabListener.class);
switch (event.getID()) {
case TabEvent.TAB_CLOSED:

28
src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java

@ -28,8 +28,6 @@ package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.ui.colorchooser.ColorListener;
import com.github.weisj.darklaf.ui.colorchooser.ColorPipette;
import com.github.weisj.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.plaf.basic.BasicRootPaneUI;
@ -51,13 +49,13 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
private Color currentColor;
private Color initialColor;
public ColorPipetteBase(@NotNull final JComponent parent, @NotNull final ColorListener colorListener) {
public ColorPipetteBase(final JComponent parent, final ColorListener colorListener) {
this.parent = parent;
this.colorListener = colorListener;
robot = createRobot();
}
@Nullable
private static Robot createRobot() {
try {
return new Robot();
@ -78,28 +76,28 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
this.closeAction = closeAction;
}
protected Color getPixelColor(@NotNull final Point location) {
protected Color getPixelColor(final Point location) {
return robot.getPixelColor(location.x, location.y);
}
@Nullable
protected Color getInitialColor() {
return initialColor;
}
@Override
public void setInitialColor(@Nullable final Color initialColor) {
public void setInitialColor(final Color initialColor) {
this.initialColor = initialColor;
setColor(initialColor);
}
@Nullable
@Override
public Color getColor() {
return currentColor;
}
protected void setColor(@Nullable final Color color) {
protected void setColor(final Color color) {
currentColor = color;
}
@ -140,7 +138,7 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
Toolkit.getDefaultToolkit().removeAWTEventListener(this);
}
@NotNull
protected Window getOrCreatePickerWindow() {
if (pickerWindow == null) {
Window owner = SwingUtilities.getWindowAncestor(parent);
@ -152,7 +150,7 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
return pickerWindow;
}
@Nullable
protected Point updateLocation() {
PointerInfo pointerInfo = MouseInfo.getPointerInfo();
if (pointerInfo == null) return null;
@ -169,18 +167,18 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
return new PickerWindow(parent);
}
@Nullable
protected Window getPickerWindow() {
return pickerWindow;
}
protected Point adjustPickerLocation(@NotNull final Point mouseLocation, @NotNull final Window pickerWindow) {
protected Point adjustPickerLocation(final Point mouseLocation, final Window pickerWindow) {
return new Point(mouseLocation.x - pickerWindow.getWidth() / 2,
mouseLocation.y - pickerWindow.getHeight() / 2);
}
@Override
public void eventDispatched(@NotNull final AWTEvent event) {
public void eventDispatched(final AWTEvent event) {
if (pickerWindow == null || !pickerWindow.isVisible()) return;
switch (event.getID()) {
case MouseEvent.MOUSE_PRESSED:
@ -221,7 +219,7 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
protected abstract void updatePipette(final boolean force);
protected void notifyListener(@NotNull final Color c) {
protected void notifyListener(final Color c) {
colorListener.colorChanged(c, this);
}

11
src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java

@ -27,7 +27,6 @@ import com.github.weisj.darklaf.ui.colorchooser.ColorListener;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import com.github.weisj.darklaf.util.TimerUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -52,7 +51,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
private Graphics2D zoomGraphics;
private BufferedImage zoomImage;
public DefaultColorPipette(@NotNull final JComponent parent, @NotNull final ColorListener colorListener) {
public DefaultColorPipette(final JComponent parent, final ColorListener colorListener) {
super(parent, colorListener);
timer = TimerUtil.createNamedTimer("DefaultColorPipette", 5, e -> updatePipette());
borderColor = UIManager.getColor("ColorChooser.pipetteBorderColor");
@ -63,7 +62,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
}
@Override
protected Color getPixelColor(@NotNull final Point location) {
protected Color getPixelColor(final Point location) {
return super.getPixelColor(getHotSPot(location));
}
@ -81,7 +80,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
}
@Override
@NotNull
protected Window getOrCreatePickerWindow() {
Window pickerWindow = getPickerWindow();
if (pickerWindow == null) {
@ -122,7 +121,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
}
@Override
protected Point adjustPickerLocation(@NotNull final Point mouseLocation, @NotNull final Window pickerWindow) {
protected Point adjustPickerLocation(final Point mouseLocation, final Window pickerWindow) {
Point p = super.adjustPickerLocation(mouseLocation, pickerWindow);
p.x += DIALOG_SIZE / 2 - MOUSE_OFF_X;
p.y -= DIALOG_SIZE / 2 + MOUSE_OFF_Y;
@ -164,7 +163,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
zoomImage = null;
}
protected Point getHotSPot(@NotNull final Point location) {
protected Point getHotSPot(final Point location) {
location.x -= MOUSE_OFF_X - 2;
location.y -= MOUSE_OFF_Y + 2;
return location;

16
src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.ui.scrollpane.ScrollLayoutManagerDelegate;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ScrollPaneUI;
@ -91,7 +89,7 @@ public class OverlayScrollPane extends JLayeredPane {
*
* @return the scrollPane
*/
@NotNull
public JScrollPane getScrollPane() {
return scrollPane;
}
@ -113,8 +111,7 @@ public class OverlayScrollPane extends JLayeredPane {
controlPanel.showHorizontalScrollBar(policy != JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
@Contract(pure = true)
@NotNull
public JScrollBar getVerticalScrollBar() {
return scrollPane.verticalScrollBar;
}
@ -124,8 +121,7 @@ public class OverlayScrollPane extends JLayeredPane {
return scrollPane.getPreferredSize();
}
@Contract(pure = true)
@NotNull
public JScrollBar getHorizontalScrollBar() {
return scrollPane.horizontalScrollBar;
}
@ -145,7 +141,7 @@ public class OverlayScrollPane extends JLayeredPane {
setOpaque(false);
}
@Contract(pure = true)
@Override
public boolean isOpaque() {
return false;
@ -259,7 +255,7 @@ public class OverlayScrollPane extends JLayeredPane {
private boolean showVertical;
private boolean showHorizontal;
private ControlPanel(@NotNull final OScrollPane scrollPane) {
private ControlPanel(final OScrollPane scrollPane) {
setLayout(null);
scrollPane.setVerticalScrollBar(scrollPane.verticalScrollBar);
@ -301,7 +297,7 @@ public class OverlayScrollPane extends JLayeredPane {
&& scrollPane.verticalScrollBar.getBounds().contains(x, y);
}
@Contract(pure = true)
@Override
public boolean isOpaque() {
return false;

8
src/main/java/com/github/weisj/darklaf/components/ScrollPopupMenu.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.components;
import com.github.weisj.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.MenuKeyEvent;
@ -79,7 +77,7 @@ public class ScrollPopupMenu extends JPopupMenu {
addMenuKeyListener(menuKeyListener);
}
@NotNull
private OverlayScrollPane createScrollPane() {
view = new JPanel(new BorderLayout());
view.add(this, BorderLayout.CENTER);
@ -106,7 +104,7 @@ public class ScrollPopupMenu extends JPopupMenu {
}
@Override
public JMenuItem add(@NotNull final JMenuItem menuItem) {
public JMenuItem add(final JMenuItem menuItem) {
menuItem.getModel().addChangeListener(e -> contentPane.repaint(menuItem.getBounds()));
return super.add(menuItem);
}
@ -133,7 +131,7 @@ public class ScrollPopupMenu extends JPopupMenu {
*
* @return scroll pane;
*/
@Nullable
public JScrollPane getScrollPane() {
return scrollPane;
}

48
src/main/java/com/github/weisj/darklaf/components/alignment/Alignment.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.components.alignment;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.function.BiFunction;
@ -67,7 +64,7 @@ public enum Alignment {
private final BiFunction<Dimension, Rectangle, Point> alignInside;
private final BiFunction<Dimension, Rectangle, Point> alignOutside;
@Contract(pure = true)
Alignment(final BiFunction<Dimension, Rectangle, Point> alignInside,
final BiFunction<Dimension, Rectangle, Point> alignOutside) {
this.alignInside = alignInside;
@ -83,11 +80,11 @@ public enum Alignment {
* @param hint preferred alignment.
* @return fitting alignment. If none is found the default is {@link Alignment#CENTER}.
*/
@NotNull
public static Alignment getAlignment(@NotNull final Point point,
@NotNull final Dimension size,
@NotNull final Rectangle outerBounds,
@NotNull final Alignment hint) {
public static Alignment getAlignment(final Point point,
final Dimension size,
final Rectangle outerBounds,
final Alignment hint) {
if (hint.canBeAligned(point, size, outerBounds)) {
return hint;
}
@ -108,9 +105,9 @@ public enum Alignment {
* @param outerBounds boundaries.
* @return true if can be aligned.
*/
public boolean canBeAligned(@NotNull final Point point,
@NotNull final Dimension size,
@NotNull final Rectangle outerBounds) {
public boolean canBeAligned(final Point point,
final Dimension size,
final Rectangle outerBounds) {
Point p = relativePos(size, point);
return p.x >= outerBounds.x && p.y >= outerBounds.y
&& p.x + size.width < outerBounds.x + outerBounds.width
@ -124,7 +121,7 @@ public enum Alignment {
* @param alignAt point to align at.
* @return top/left position of aligned rectangle
*/
public Point relativePos(@NotNull final Dimension toAlign, @NotNull final Point alignAt) {
public Point relativePos(final Dimension toAlign, final Point alignAt) {
return alignOutside(toAlign, new Rectangle(alignAt.x, alignAt.y, 0, 0));
}
@ -135,8 +132,8 @@ public enum Alignment {
* @param innerBounds bounds of inside rectangle
* @return top/left point of aligned rectangle
*/
public Point alignOutside(@NotNull final Dimension toAlign,
@NotNull final Rectangle innerBounds) {
public Point alignOutside(final Dimension toAlign,
final Rectangle innerBounds) {
return this.alignOutside.apply(toAlign, innerBounds);
}
@ -146,7 +143,7 @@ public enum Alignment {
*
* @return the index.
*/
@Contract(pure = true)
public int getIndex() {
return this.ordinal();
}
@ -156,8 +153,8 @@ public enum Alignment {
*
* @return Alignment opposite on the compass.
*/
@Contract(pure = true)
@NotNull
@SuppressWarnings("Duplicates")
public Alignment opposite() {
switch (this) {
@ -184,8 +181,7 @@ public enum Alignment {
}
}
@NotNull
@Contract(pure = true)
@SuppressWarnings("Duplicates")
public Alignment anticlockwise() {
switch (this) {
@ -212,8 +208,7 @@ public enum Alignment {
}
}
@NotNull
@Contract(pure = true)
@SuppressWarnings("Duplicates")
public Alignment clockwise() {
switch (this) {
@ -240,9 +235,8 @@ public enum Alignment {
}
}
@NotNull
@Contract(pure = true)
public Insets maskInsets(@NotNull final Insets insets) {
public Insets maskInsets(final Insets insets) {
switch (this) {
case NORTH:
return new Insets(insets.top, 0, 0, 0);
@ -274,8 +268,8 @@ public enum Alignment {
* @param outerBounds bounds of outer rectangle
* @return top/left point of aligned rectangle
*/
public Point alignInside(@NotNull final Dimension toAlign,
@NotNull final Rectangle outerBounds) {
public Point alignInside(final Dimension toAlign,
final Rectangle outerBounds) {
return this.alignInside.apply(toAlign, outerBounds);
}
}

11
src/main/java/com/github/weisj/darklaf/components/alignment/AlignmentHelper.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.components.alignment;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.function.BiFunction;
@ -58,10 +55,10 @@ final class AlignmentHelper {
* @param mapperY y component mapper.
* @return mapper that aligns a rectangle relative to other rectangle.
*/
@NotNull
@Contract(pure = true)
static BiFunction<Dimension, Rectangle, Point> align(@NotNull final Mapper mapperX,
@NotNull final Mapper mapperY) {
static BiFunction<Dimension, Rectangle, Point> align(final Mapper mapperX,
final Mapper mapperY) {
return (d, p) -> new Point(mapperX.apply(d, p), mapperY.apply(d, p));
}

66
src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java

@ -26,8 +26,6 @@ package com.github.weisj.darklaf.components.border;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.border.AbstractBorder;
import java.awt.*;
@ -95,7 +93,7 @@ public class BubbleBorder extends AbstractBorder {
* @param color border colour
* @return this
*/
@NotNull
public BubbleBorder setColor(final Color color) {
this.color = color;
return this;
@ -137,7 +135,7 @@ public class BubbleBorder extends AbstractBorder {
* @param n new thickness
* @return this
*/
@NotNull
public BubbleBorder setThickness(final int n) {
thickness = Math.max(n, 0);
stroke = new BasicStroke(thickness);
@ -153,34 +151,13 @@ public class BubbleBorder extends AbstractBorder {
return radius;
}
/**
* Set the corner radius.
*
* @param radius radius of corner.
* @return this
*/
@NotNull
public BubbleBorder setRadius(final int radius) {
this.radius = radius;
return setPointerSize(pointerSize);
}
/**
* Get the pointer size.
*
* @return size of pointer.
*/
public int getPointerSize() {
return pointerSize;
}
/**
* Set the pointer size Clips at 0.
*
* @param size size of pointer.
* @return this
*/
@NotNull
public BubbleBorder setPointerSize(final int size) {
pointerSize = Math.max(size, 0);
int left = thickness;
@ -212,6 +189,27 @@ public class BubbleBorder extends AbstractBorder {
return this;
}
/**
* Get the pointer size.
*
* @return size of pointer.
*/
public int getPointerSize() {
return pointerSize;
}
/**
* Set the corner radius.
*
* @param radius radius of corner.
* @return this
*/
public BubbleBorder setRadius(final int radius) {
this.radius = radius;
return setPointerSize(pointerSize);
}
/**
* Get the Alignment the pointer follows. Default is {@link Alignment#NORTH}
*
@ -229,7 +227,7 @@ public class BubbleBorder extends AbstractBorder {
* @param side direction in which the pointer should point.
* @return this.
*/
@NotNull
public BubbleBorder setPointerSide(final Alignment side) {
this.pointerSide = side;
setPointerSize(pointerSize);
@ -240,7 +238,7 @@ public class BubbleBorder extends AbstractBorder {
return (int) calculatePointerPad(w, h, Alignment.NORTH_WEST);
}
@Contract(pure = true)
private double calculatePointerPad(final int width, final int height, final Alignment side) {
double pointerPad;
switch (side) {
@ -268,19 +266,19 @@ public class BubbleBorder extends AbstractBorder {
}
@Override
public void paintBorder(@NotNull final Component c, final Graphics g,
public void paintBorder(final Component c, final Graphics g,
final int x, final int y, final int width, final int height) {
Area area = getInnerArea(x, y, width, height);
paintBorder(g, area);
}
@NotNull
@Override
public Insets getBorderInsets(final Component c) {
return new Insets(insets.top, insets.left, insets.bottom, insets.right);
}
@NotNull
@Override
public Insets getBorderInsets(final Component c, final Insets insets) {
return getBorderInsets(c);
@ -306,15 +304,15 @@ public class BubbleBorder extends AbstractBorder {
config.restore();
}
@Contract("_, _, _, _ -> new")
public RoundRectangle2D.Double calculateBubbleRect(final int x, final int y,
final int width, final int height) {
return new RoundRectangle2D.Double(x + insets.left, y + insets.top, width - insets.left - insets.right,
height - insets.top - insets.bottom, radius, radius);
}
@NotNull
private Path2D creatPointerShape(final double pointerPad, @NotNull final RoundRectangle2D.Double bubble) {
private Path2D creatPointerShape(final double pointerPad, final RoundRectangle2D.Double bubble) {
final double w = pointerWidth / 2.0;
final Path2D pointer = new Path2D.Double(Path2D.WIND_EVEN_ODD);
double x = bubble.x;

10
src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.components.border;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
import java.util.Map;
@ -36,14 +34,14 @@ public final class DarkBorders {
private static Map<WeakLineBorder, WeakLineBorder> lineBorderMap = new WeakHashMap<>();
private static Map<WeakLineBorder, WeakLineBorder> lineWidgetBorderMap = new WeakHashMap<>();
@NotNull
public static Border createLineBorder(final int top, final int left, final int bottom, final int right) {
return createBorder(top, left, bottom, right, lineBorderMap, "border");
}
@NotNull
private static Border createBorder(final int top, final int left, final int bottom, final int right,
@NotNull final Map<WeakLineBorder, WeakLineBorder> map, final String key) {
final Map<WeakLineBorder, WeakLineBorder> map, final String key) {
WeakLineBorder border = null;
KEY.setInsets(top, left, bottom, right);
if (map.containsKey(KEY)) {
@ -57,7 +55,7 @@ public final class DarkBorders {
return border;
}
@NotNull
public static Border createWidgetLineBorder(final int top, final int left, final int bottom, final int right) {
return createBorder(top, left, bottom, right, lineWidgetBorderMap, "borderSecondary");
}

16
src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java

@ -25,8 +25,6 @@ package com.github.weisj.darklaf.components.border;
import com.github.weisj.darklaf.util.ImageUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.border.Border;
import java.awt.*;
@ -65,18 +63,18 @@ public class DropShadowBorder implements Border, Serializable {
private boolean showBottomShadow;
private boolean showRightShadow;
@Contract(pure = true)
public DropShadowBorder() {
this(Color.BLACK, 5);
}
@Contract(pure = true)
public DropShadowBorder(final Color shadowColor, final int shadowSize) {
this(shadowColor, shadowSize, .5f, 12, false, true,
true, true);
}
@Contract(pure = true)
public DropShadowBorder(final Color shadowColor, final int shadowSize,
final float shadowOpacity, final int cornerSize, final boolean showTopShadow,
final boolean showLeftShadow, final boolean showBottomShadow, final boolean showRightShadow) {
@ -90,7 +88,7 @@ public class DropShadowBorder implements Border, Serializable {
this.showRightShadow = showRightShadow;
}
@Contract(pure = true)
public DropShadowBorder(final boolean showLeftShadow) {
this(Color.BLACK, 5, .5f, 12,
false, showLeftShadow, true, true);
@ -99,7 +97,7 @@ public class DropShadowBorder implements Border, Serializable {
/**
* {@inheritDoc}
*/
public void paintBorder(final Component c, @NotNull final Graphics graphics,
public void paintBorder(final Component c, final Graphics graphics,
final int x, final int y, final int width, final int height) {
/*
* 1) Get images for this border
@ -235,7 +233,7 @@ public class DropShadowBorder implements Border, Serializable {
}
@SuppressWarnings("SuspiciousNameCombination")
@NotNull
private Map<Position, BufferedImage> getImages(final Graphics2D g2) {
//first, check to see if an image for this size has already been rendered
//if so, use the cache. Else, draw and save
@ -337,7 +335,7 @@ public class DropShadowBorder implements Border, Serializable {
* Returns a new BufferedImage that represents a subregion of the given BufferedImage. (Note that this method does
* not use BufferedImage.getSubimage(), which will defeat image acceleration strategies on later JDKs.)
*/
@NotNull
private BufferedImage getSubImage(final BufferedImage img, final int x, final int y, final int w, final int h) {
BufferedImage ret = ImageUtil.createCompatibleTranslucentImage(w, h);
Graphics2D g2 = ret.createGraphics();

4
src/main/java/com/github/weisj/darklaf/components/border/MutableLineBorder.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.components.border;
import org.jetbrains.annotations.NotNull;
import javax.swing.border.EmptyBorder;
import java.awt.*;
@ -42,7 +40,7 @@ public class MutableLineBorder extends EmptyBorder {
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g, final int x, final int y,
public void paintBorder(final Component c, final Graphics g, final int x, final int y,
final int width, final int height) {
g.setColor(getColor());
g.fillRect(x, y, width - right, top);

4
src/main/java/com/github/weisj/darklaf/components/border/WeakLineBorder.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.components.border;
import org.jetbrains.annotations.Contract;
class WeakLineBorder extends MutableLineBorder {
private int left;
@ -49,7 +47,7 @@ class WeakLineBorder extends MutableLineBorder {
return result;
}
@Contract(value = "null -> false", pure = true)
@Override
public boolean equals(final Object o) {
if (this == o) return true;

74
src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java

@ -25,8 +25,6 @@ package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.ui.tabframe.TabFrameTransferHandler;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
@ -170,13 +168,15 @@ public class JTabFrame extends JComponent {
}
/**
* Get a list of tab components at the given alignment position.
* Insert a tab. A default tab component and popup component will be created.
*
* @param a the alignment position.
* @return list of tab components at position.
* @param c the component to add.
* @param a the alignment position to add at.{@link TabFramePosition#getAlignment()}
* @param index the index to insert at.{@link TabFramePosition#getIndex()}
*/
public List<TabFrameTab> tabsForAlignment(@NotNull final Alignment a) {
return tabLists[a.ordinal()];
public void insertTab(final Component c, final Alignment a, final int index) {
String title = c.getName();
insertTab(c, title == null ? "" : title, a, index);
}
/**
@ -242,18 +242,6 @@ public class JTabFrame extends JComponent {
return new TabFrameContentPane();
}
/**
* Insert a tab. A default tab component and popup component will be created.
*
* @param c the component to add.
* @param a the alignment position to add at.{@link TabFramePosition#getAlignment()}
* @param index the index to insert at.{@link TabFramePosition#getIndex()}
*/
public void insertTab(@NotNull final Component c, final Alignment a, final int index) {
String title = c.getName();
insertTab(c, title == null ? "" : title, a, index);
}
/**
* Insert a tab. A default tab component and popup component will be created.
*
@ -262,7 +250,7 @@ public class JTabFrame extends JComponent {
* @param a the alignment position to add at.{@link TabFramePosition#getAlignment()}
* @param index the index to insert at.{@link TabFramePosition#getIndex()}
*/
public void insertTab(@NotNull final Component c, final String title, final Alignment a, final int index) {
public void insertTab(final Component c, final String title, final Alignment a, final int index) {
insertTab(c, title, null, a, index);
}
@ -275,7 +263,7 @@ public class JTabFrame extends JComponent {
* @param a the alignment position to add at.{@link TabFramePosition#getAlignment()}
* @param index the index to insert at.{@link TabFramePosition#getIndex()}
*/
public void insertTab(@NotNull final Component c, final String title, final Icon icon, final Alignment a,
public void insertTab(final Component c, final String title, final Icon icon, final Alignment a,
final int index) {
TabFramePopup popup = new PanelPopup(title, icon, c);
insertTab(popup, title, icon, a, index);
@ -290,7 +278,7 @@ public class JTabFrame extends JComponent {
* @param a the alignment position to add at.{@link TabFramePosition#getAlignment()}
* @param index the index to insert at.{@link TabFramePosition#getIndex()}
*/
public void insertTab(@NotNull final TabFramePopup c, final String title, final Icon icon, final Alignment a,
public void insertTab(final TabFramePopup c, final String title, final Icon icon, final Alignment a,
final int index) {
if (a == Alignment.CENTER) {
return;
@ -306,7 +294,7 @@ public class JTabFrame extends JComponent {
* @param a the alignment position to add at.{@link TabFramePosition#getAlignment()}
* @param index the index to insert at.{@link TabFramePosition#getIndex()}
*/
public void insertTab(@NotNull final TabFramePopup c, final TabFrameTab tab, final Alignment a, final int index) {
public void insertTab(final TabFramePopup c, final TabFrameTab tab, final Alignment a, final int index) {
if (a == Alignment.CENTER) {
return;
}
@ -318,14 +306,10 @@ public class JTabFrame extends JComponent {
c.setIndex(index);
}
protected TabFrameTab createDefaultTab(final String text, final Icon icon, final Alignment a, final int index) {
return new TabFrameTabLabel(text, icon, a, index, this);
}
/*
* Inserts a tab component at the given position.
*/
private void insertTabComp(@NotNull final TabFrameTab tabComp, final Alignment a, final int index) {
private void insertTabComp(final TabFrameTab tabComp, final Alignment a, final int index) {
tabComp.setOrientation(a);
getTabContainer(a).add(tabComp.getComponent());
List<TabFrameTab> tabs = tabsForAlignment(a);
@ -340,13 +324,17 @@ public class JTabFrame extends JComponent {
tabs.add(index, tabComp);
}
protected TabFrameTab createDefaultTab(final String text, final Icon icon, final Alignment a, final int index) {
return new TabFrameTabLabel(text, icon, a, index, this);
}
/**
* Get a list of components at the given alignment position.
*
* @param a the alignment position.
* @return list of components at position.
*/
public List<TabFramePopup> compsForAlignment(@NotNull final Alignment a) {
public List<TabFramePopup> compsForAlignment(final Alignment a) {
return popupLists[a.ordinal()];
}
@ -356,8 +344,8 @@ public class JTabFrame extends JComponent {
* @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @return the tab container.
*/
@Contract(pure = true)
public JComponent getTabContainer(@NotNull final Alignment a) {
public JComponent getTabContainer(final Alignment a) {
switch (a) {
case NORTH:
case NORTH_EAST:
@ -378,6 +366,16 @@ public class JTabFrame extends JComponent {
}
}
/**
* Get a list of tab components at the given alignment position.
*
* @param a the alignment position.
* @return list of tab components at position.
*/
public List<TabFrameTab> tabsForAlignment(final Alignment a) {
return tabLists[a.ordinal()];
}
/**
* Get the container that holds the top tab components.
*
@ -461,7 +459,7 @@ public class JTabFrame extends JComponent {
/*
* Set the tab component at the given position.
*/
private void setTabComponent(@NotNull final TabFrameTab tab, final Alignment a, final int index) {
private void setTabComponent(final TabFrameTab tab, final Alignment a, final int index) {
List<TabFrameTab> tabs = tabsForAlignment(a);
TabFrameTab oldComp = tabs.get(index);
getTabContainer(a).remove(oldComp.getComponent());
@ -528,7 +526,7 @@ public class JTabFrame extends JComponent {
* @param index the index.{@link TabFramePosition#getIndex()}
* @param enabled true if visible.
*/
public void toggleTab(@NotNull final Alignment a, final int index, final boolean enabled) {
public void toggleTab(final Alignment a, final int index, final boolean enabled) {
int oldIndex = selectedIndices[a.getIndex()];
if (content.isEnabled(a) == enabled && oldIndex == index) return;
TabFrameTab compAtIndex = getTabComponentAt(a, index);
@ -565,7 +563,7 @@ public class JTabFrame extends JComponent {
/*
* Set the visibility of the popup.
*/
private void setPopupVisibility(@NotNull final TabFrameTab tabComponent,
private void setPopupVisibility(final TabFrameTab tabComponent,
final boolean selected) {
Alignment a = tabComponent.getOrientation();
TabFramePopup c = compsForAlignment(a).get(tabComponent.getIndex());
@ -669,7 +667,7 @@ public class JTabFrame extends JComponent {
* @param tabComp the tab to move.
* @param a the new alignment position.{@link TabFramePosition#getAlignment()}
*/
public void moveTab(@NotNull final TabFrameTab tabComp, final Alignment a) {
public void moveTab(final TabFrameTab tabComp, final Alignment a) {
if (a == tabComp.getOrientation()) {
return;
}
@ -823,7 +821,7 @@ public class JTabFrame extends JComponent {
* @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @return the peer position.{@link TabFramePosition#getAlignment()}
*/
public Alignment getPeer(@NotNull final Alignment a) {
public Alignment getPeer(final Alignment a) {
switch (a) {
case NORTH:
case SOUTH:
@ -889,7 +887,7 @@ public class JTabFrame extends JComponent {
* @param a the alignment position.{@link TabFramePosition#getAlignment()}
* @return the current selected index at the alignment position.
*/
public int getSelectedIndex(@NotNull final Alignment a) {
public int getSelectedIndex(final Alignment a) {
return selectedIndices[a.ordinal()];
}
@ -954,7 +952,7 @@ public class JTabFrame extends JComponent {
private Alignment a;
private int index;
@Contract(pure = true)
public TabFramePosition(final Alignment a, final int index) {
this.a = a;
this.index = index;

3
src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java

@ -24,7 +24,6 @@
package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import org.jetbrains.annotations.Contract;
import javax.swing.*;
import java.awt.*;
@ -132,7 +131,7 @@ public class PanelPopup extends JPanel implements TabFramePopup {
}
}
@Contract(pure = true)
private boolean isOpen() {
return open;
}

4
src/main/java/com/github/weisj/darklaf/components/tabframe/TabArea.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.components.tabframe;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -36,7 +34,7 @@ public final class TabArea extends JPanel {
}
@Override
public void paint(@NotNull final Graphics g) {
public void paint(final Graphics g) {
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
paintChildren(g);

74
src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java

@ -25,8 +25,6 @@ package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.decorators.AncestorAdapter;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.AncestorEvent;
@ -137,7 +135,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
return new TabFrameSplitPane(name);
}
protected <T> void setupSplitterPanes(@NotNull final BiConsumer<? super ToggleSplitPane, T> consumer,
protected <T> void setupSplitterPanes(final BiConsumer<? super ToggleSplitPane, T> consumer,
final T flag) {
consumer.accept(bottomSplitter, flag);
consumer.accept(leftSplitter, flag);
@ -145,7 +143,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
consumer.accept(topSplitter, flag);
}
protected <T> void setupSplitPanes(@NotNull final BiConsumer<? super ToggleSplitPane, T> consumer,
protected <T> void setupSplitPanes(final BiConsumer<? super ToggleSplitPane, T> consumer,
final T flag) {
consumer.accept(topSplit, flag);
consumer.accept(leftSplit, flag);
@ -169,6 +167,16 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
}
}
/**
* Show or hide the corresponding panel.
*
* @param a position of panel.
* @param enabled true if should be shown.
*/
public void setEnabled(final Alignment a, final boolean enabled) {
setEnabled(a, enabled, false);
}
/**
* Show or hide the corresponding panel.
*
@ -176,7 +184,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
* @param enabled true if should be shown.
* @param force whether to force the layout process.
*/
public void setEnabled(@NotNull final Alignment a, final boolean enabled, final boolean force) {
public void setEnabled(final Alignment a, final boolean enabled, final boolean force) {
if (enabled == isEnabled(a) && !force) return;
switch (a) {
case NORTH:
@ -251,11 +259,11 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
* @param proportions the layout proportions
* @param weights the layout weights
*/
private void changeStatus(final boolean enabled, @NotNull final Alignment peer,
@NotNull final ToggleSplitPane split,
@NotNull final ToggleSplitPane splitter,
@NotNull final LayoutProportions proportions,
@NotNull final LayoutWeights weights) {
private void changeStatus(final boolean enabled, final Alignment peer,
final ToggleSplitPane split,
final ToggleSplitPane splitter,
final LayoutProportions proportions,
final LayoutWeights weights) {
if (enabled) {
enable(split, weights.splitEnable);
if (!isEnabled(peer)) {
@ -274,13 +282,13 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
/*
* Update the flags.
*/
private void setEnabledFlag(@NotNull final Alignment a, final boolean e) {
private void setEnabledFlag(final Alignment a, final boolean e) {
if (a != Alignment.CENTER) {
enabled[a.getIndex()] = e;
}
}
private void enable(@NotNull final ToggleSplitPane splitPane, final double weight) {
private void enable(final ToggleSplitPane splitPane, final double weight) {
boolean restore = !splitPane.isResizable();
splitPane.setEnabled(true);
splitPane.setResizable(true);
@ -290,16 +298,6 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
}
}
private void disable(@NotNull final ToggleSplitPane splitPane, final double weight, final double location) {
if (splitPane.isResizable()) {
splitPane.savePosition();
}
splitPane.setResizeWeight(weight);
splitPane.forceSetDividerLocation(location);
splitPane.setEnabled(false);
splitPane.setResizable(false);
}
public Component getContent() {
return cont;
}
@ -309,14 +307,14 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
rightSplit.setLeftComponent(pane);
}
/**
* Show or hide the corresponding panel.
*
* @param a position of panel.
* @param enabled true if should be shown.
*/
public void setEnabled(@NotNull final Alignment a, final boolean enabled) {
setEnabled(a, enabled, false);
private void disable(final ToggleSplitPane splitPane, final double weight, final double location) {
if (splitPane.isResizable()) {
splitPane.savePosition();
}
splitPane.setResizeWeight(weight);
splitPane.forceSetDividerLocation(location);
splitPane.setEnabled(false);
splitPane.setResizable(false);
}
/**
@ -325,7 +323,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
* @param a the position of the panel.
* @return true if enabled.
*/
public boolean isEnabled(@NotNull final Alignment a) {
public boolean isEnabled(final Alignment a) {
if (a == Alignment.CENTER) {
return false;
} else {
@ -333,7 +331,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
}
}
public void setComponentAt(@NotNull final Alignment a, final Component c) {
public void setComponentAt(final Alignment a, final Component c) {
switch (a) {
case NORTH:
((PopupContainer) topSplitter.getLeftComponent()).setPopup(c);
@ -374,13 +372,13 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
*
* @return array of status of panels.
*/
@NotNull
public boolean[] getStatus() {
return enabled;
}
@Override
public PopupContainer getContainer(@NotNull final Alignment alignment) {
public PopupContainer getContainer(final Alignment alignment) {
PopupContainer popupComponent;
switch (alignment) {
case NORTH:
@ -419,8 +417,8 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
* @param a the position.
* @return the popup component at position.
*/
@NotNull
public Component getPopupComponent(@NotNull final Alignment a) {
public Component getPopupComponent(final Alignment a) {
return getContainer(a).getPopup();
}
@ -430,7 +428,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
protected final double splitDisable;
protected final double splitterDisable;
@Contract(pure = true)
public LayoutProportions(final double splitRestore, final double splitterPeerDisable,
final double splitDisable, final double splitterDisable) {
this.splitRestore = splitRestore;
@ -446,7 +444,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
protected final double splitDisable;
protected final double splitterPeerDisable;
@Contract(pure = true)
public LayoutWeights(final double splitEnable, final double splitterDisable,
final double splitDisable, final double splitterPeerDisable) {
this.splitEnable = splitEnable;

6
src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java

@ -26,8 +26,6 @@ package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.ui.tabframe.DarkTabFrameTabLabelUI;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@ -57,7 +55,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
* @param parent the parent layout manager.
*/
public TabFrameTabLabel(final String title, final Icon icon, final Alignment orientation,
final int index, @NotNull final JTabFrame parent) {
final int index, final JTabFrame parent) {
this.index = index;
this.accelerator = -1;
this.parent = parent;
@ -157,7 +155,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
*
* @param title the title
*/
public void setTitle(@Nullable final String title) {
public void setTitle(final String title) {
if (Objects.equals(title, this.title)) return;
String oldTitle = this.title;
this.title = title;

6
src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.components.text;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@ -59,8 +57,8 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
this.color = color;
}
public void paint(@NotNull final Graphics g, final int p0, final int p1, final Shape bounds,
@NotNull final JTextComponent c) {
public void paint(final Graphics g, final int p0, final int p1, final Shape bounds,
final JTextComponent c) {
try {
Rectangle r = c.modelToView(c.getCaretPosition());
g.setColor(color);

5
src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java

@ -26,7 +26,6 @@ package com.github.weisj.darklaf.components.text;
import com.github.weisj.darklaf.components.ScrollPopupMenu;
import com.github.weisj.darklaf.decorators.PlainAction;
import com.github.weisj.darklaf.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -55,7 +54,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
* @param capacity the length of the history.
* @param maxH maximum height.
*/
public TextFieldHistoryPopup(@NotNull final SearchTextField textField, final int capacity, final int maxH) {
public TextFieldHistoryPopup(final SearchTextField textField, final int capacity, final int maxH) {
super(maxH);
this.textField = textField;
textField.addSearchListener(this);
@ -107,7 +106,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
}
@Override
public void searchPerformed(@NotNull final SearchEvent e) {
public void searchPerformed(final SearchEvent e) {
String text = e.getText();
if (!StringUtil.isBlank(text)) {
addEntry(text);

3
src/main/java/com/github/weisj/darklaf/components/tooltip/DarkToolTip.java

@ -28,7 +28,6 @@ import com.github.weisj.darklaf.decorators.AncestorAdapter;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder;
import com.github.weisj.darklaf.util.Animator;
import com.github.weisj.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
@ -134,7 +133,7 @@ public class DarkToolTip extends JToolTip implements PropertyChangeListener {
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
public void propertyChange(final PropertyChangeEvent evt) {
if ("tiptext".equals(evt.getPropertyName())) {
setPreferredSize(getUI().getPreferredSize(this));
if (!Objects.equals(evt.getNewValue(), evt.getOldValue())) {

31
src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java

@ -27,9 +27,6 @@ import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.alignment.AlignmentStrategy;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder;
import com.github.weisj.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@ -90,7 +87,7 @@ public class ToolTipContext implements ToolTipListener {
*
* @param c the component which the tooltip belongs to.
*/
@Contract("null -> fail")
public ToolTipContext(final JComponent c) {
this(c, null, null, null, true, null);
}
@ -105,7 +102,7 @@ public class ToolTipContext implements ToolTipListener {
* @param alignInside {@link #setAlignInside(boolean)}
* @param toolTipRectSupplier {@link #setToolTipRectSupplier(Function)}
*/
@Contract("null, _, _, _, _, _ -> fail")
public ToolTipContext(final JComponent c, final Alignment alignment, final Alignment centerAlignment,
final AlignmentStrategy alignmentStrategy,
final boolean alignInside, final Function<MouseEvent, Rectangle> toolTipRectSupplier) {
@ -274,7 +271,7 @@ public class ToolTipContext implements ToolTipListener {
* @param c the component which the tooltip belongs to.
* @param alignment {@link #setAlignment(Alignment)}
*/
@Contract("null, _ -> fail")
public ToolTipContext(final JComponent c, final Alignment alignment) {
this(c, alignment, null, null, true, null);
}
@ -286,7 +283,7 @@ public class ToolTipContext implements ToolTipListener {
* @param alignment {@link #setAlignment(Alignment)}
* @param centerAlignment {@link #setCenterAlignment(Alignment)}
*/
@Contract("null, _, _ -> fail")
public ToolTipContext(final JComponent c, final Alignment alignment, final Alignment centerAlignment) {
this(c, alignment, centerAlignment, null, true, null);
}
@ -298,7 +295,7 @@ public class ToolTipContext implements ToolTipListener {
* @param alignment {@link #setAlignment(Alignment)}
* @param alignInside {@link #setAlignInside(boolean)}
*/
@Contract("null, _, _ -> fail")
public ToolTipContext(final JComponent c, final Alignment alignment, final boolean alignInside) {
this(c, alignment, null, null, alignInside, null);
}
@ -311,7 +308,7 @@ public class ToolTipContext implements ToolTipListener {
* @param centerAlignment {@link #setCenterAlignment(Alignment)}
* @param alignInside {@link #setAlignInside(boolean)}
*/
@Contract("null, _, _, _ -> fail")
public ToolTipContext(final JComponent c, final Alignment alignment, final Alignment centerAlignment,
final boolean alignInside) {
this(c, alignment, centerAlignment, null, alignInside, null);
@ -324,7 +321,7 @@ public class ToolTipContext implements ToolTipListener {
* @param alignment {@link #setAlignment(Alignment)}
* @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)}
*/
@Contract("null, _, _ -> fail")
public ToolTipContext(final JComponent c, final Alignment alignment, final AlignmentStrategy alignmentStrategy) {
this(c, alignment, null, alignmentStrategy, true, null);
}
@ -337,7 +334,7 @@ public class ToolTipContext implements ToolTipListener {
* @param centerAlignment {@link #setCenterAlignment(Alignment)}
* @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)}
*/
@Contract("null, _, _, _ -> fail")
public ToolTipContext(final JComponent c, final Alignment alignment, final Alignment centerAlignment,
final AlignmentStrategy alignmentStrategy) {
this(c, alignment, centerAlignment, alignmentStrategy, true, null);
@ -351,7 +348,7 @@ public class ToolTipContext implements ToolTipListener {
* @param alignmentStrategy {@link #setAlignmentStrategy(AlignmentStrategy)}
* @param alignInside {@link #setAlignInside(boolean)}
*/
@Contract("null, _, _, _ -> fail")
public ToolTipContext(final JComponent c, final Alignment alignment, final AlignmentStrategy alignmentStrategy,
final boolean alignInside) {
this(c, alignment, null, alignmentStrategy, alignInside, null);
@ -410,11 +407,11 @@ public class ToolTipContext implements ToolTipListener {
/**
* Calculates the tooltip location.
*
* @see JComponent#getToolTipLocation(MouseEvent)
* @param event the mouse event.
* @return the tooltip location.
* @see JComponent#getToolTipLocation(MouseEvent)
*/
public Point getToolTipLocation(@NotNull final MouseEvent event) {
public Point getToolTipLocation(final MouseEvent event) {
Rectangle rect = toolTipRectSupplier.apply(event);
if (applyInsetsToRect) {
DarkUIUtil.applyInsets(rect, c.getInsets(calcInsets));
@ -471,8 +468,8 @@ public class ToolTipContext implements ToolTipListener {
return dim;
}
@Nullable
private Point alignCenter(final Dimension dim, @NotNull final Rectangle rect) {
private Point alignCenter(final Dimension dim, final Rectangle rect) {
rect.x += rect.width / 2;
rect.y += rect.height / 2;
rect.width = 1;
@ -492,7 +489,7 @@ public class ToolTipContext implements ToolTipListener {
return adjustPoint(p, alignment, dim, true);
}
@Contract("_, _, _, _ -> param1")
private Point adjustPoint(final Point p, final Alignment align, final Dimension dim, final boolean outside) {
int factor = outside ? 1 : -1;
if (align == Alignment.NORTH_EAST || align == Alignment.SOUTH_EAST) {

5
src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.components.tristate;
import com.github.weisj.darklaf.DarkLaf;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ChangeListener;
@ -76,8 +74,7 @@ public class TristateCheckBox extends JCheckBox {
return (TristateButtonModel) super.getModel();
}
@NotNull
@Contract(pure = true)
public String getUIClassID() {
if (UIManager.getLookAndFeel() instanceof DarkLaf) {
return "TristateCheckBoxUI";

14
src/main/java/com/github/weisj/darklaf/components/uiresource/Insets2D.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.components.uiresource;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
public final class Insets2D implements Cloneable {
public double top;
@ -41,7 +38,7 @@ public final class Insets2D implements Cloneable {
* @param bottom the inset from the bottom.
* @param right the inset from the right.
*/
@Contract(pure = true)
public Insets2D(final double top, final double left, final double bottom, final double right) {
this.top = top;
this.left = left;
@ -65,7 +62,7 @@ public final class Insets2D implements Cloneable {
this.right = right;
}
@Contract(pure = true)
@Override
public int hashCode() {
double sum1 = left + bottom;
@ -76,7 +73,7 @@ public final class Insets2D implements Cloneable {
return (int) (sum3 * (sum3 + 1) / 2 + val2);
}
@Contract(value = "null -> false", pure = true)
@Override
public boolean equals(final Object obj) {
if (obj instanceof Insets2D) {
@ -87,14 +84,13 @@ public final class Insets2D implements Cloneable {
return false;
}
@NotNull
@Contract(value = " -> new", pure = true)
@Override
public Insets2D clone() {
return new Insets2D(top, left, bottom, right);
}
@NotNull
public String toString() {
return getClass().getName() + "[top=" + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";
}

4
src/main/java/com/github/weisj/darklaf/decorators/HoverListener.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.decorators;
import org.jetbrains.annotations.Contract;
import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@ -38,7 +36,7 @@ public class HoverListener implements MouseListener {
private boolean hover = false;
private boolean scheduled = false;
@Contract(pure = true)
public HoverListener(final JComponent component) {
this.component = component;
}

4
src/main/java/com/github/weisj/darklaf/decorators/LayoutManagerDelegate.java

@ -23,14 +23,12 @@
*/
package com.github.weisj.darklaf.decorators;
import org.jetbrains.annotations.Contract;
import java.awt.*;
public class LayoutManagerDelegate implements LayoutManager {
private final LayoutManager delegate;
@Contract(pure = true)
public LayoutManagerDelegate(final LayoutManager delegate) {
if (delegate == null) {
throw new IllegalArgumentException("Delegate is null");

4
src/main/java/com/github/weisj/darklaf/decorators/MouseResponder.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.decorators;
import org.jetbrains.annotations.Contract;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.function.Consumer;
@ -33,7 +31,7 @@ public class MouseResponder implements MouseListener {
private final Consumer<MouseEvent> consumer;
@Contract(pure = true)
public MouseResponder(final Consumer<MouseEvent> consumer) {
this.consumer = consumer;
}

10
src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.icons;
import com.kitfox.svg.app.beans.SVGIcon;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -56,7 +54,7 @@ public class DarkSVGIcon implements Icon, Serializable {
* @param displayWidth display width of icon.
* @param displayHeight display height of icon.
*/
public DarkSVGIcon(@NotNull final URI uri, final int displayWidth, final int displayHeight) {
public DarkSVGIcon(final URI uri, final int displayWidth, final int displayHeight) {
this.uri = uri;
size = new Dimension(displayWidth, displayHeight);
icon = new SVGIcon();
@ -65,8 +63,8 @@ public class DarkSVGIcon implements Icon, Serializable {
loaded = new AtomicBoolean(false);
}
@Contract(pure = true)
private DarkSVGIcon(final int width, final int height, @NotNull final DarkSVGIcon icon) {
private DarkSVGIcon(final int width, final int height, final DarkSVGIcon icon) {
this.size = new Dimension(width, height);
this.icon = icon.icon;
this.uri = icon.uri;
@ -104,7 +102,7 @@ public class DarkSVGIcon implements Icon, Serializable {
* @param y the y coordinate
* @param rotation the rotation in radians.
*/
public void paintIcon(final Component c, @NotNull final Graphics g, final int x, final int y,
public void paintIcon(final Component c, final Graphics g, final int x, final int y,
final double rotation) {
ensureLoaded();
Graphics2D g2 = (Graphics2D) g.create();

12
src/main/java/com/github/weisj/darklaf/icons/DarkUIAwareIcon.java

@ -25,8 +25,6 @@ package com.github.weisj.darklaf.icons;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.Theme;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.UIResource;
@ -61,7 +59,7 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
* @param h height of icon.
* @param parentClass the class to resolve the path while lazy loading.
*/
@Contract(pure = true)
public DarkUIAwareIcon(final String darkKey, final String lightKey, final int w, final int h,
final Class<?> parentClass) {
this.darkKey = darkKey;
@ -72,8 +70,8 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
this.dual = new DarkUIAwareIcon(this);
}
@Contract(pure = true)
private DarkUIAwareIcon(@NotNull final DarkUIAwareIcon dual) {
private DarkUIAwareIcon(final DarkUIAwareIcon dual) {
this.darkKey = dual.lightKey;
this.lightKey = dual.darkKey;
this.dual = dual;
@ -82,7 +80,7 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
this.parentClass = dual.parentClass;
}
public void paintIcon(final Component c, @NotNull final Graphics g2,
public void paintIcon(final Component c, final Graphics g2,
final int x, final int y, final double scale) {
ensureLoaded();
Graphics2D g = (Graphics2D) g2.create();
@ -98,7 +96,7 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
}
}
@Contract(pure = true)
private boolean isLoaded() {
return loaded && LafManager.getTheme().equals(currentTheme);
}

21
src/main/java/com/github/weisj/darklaf/icons/EmptyIcon.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.icons;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
@ -41,23 +38,23 @@ public final class EmptyIcon implements Icon, UIResource {
private final int width;
private final int height;
@Contract(pure = true)
private EmptyIcon(final int width, final int height) {
this.width = width;
this.height = height;
}
@NotNull
public static Icon create(@NotNull final Icon base) {
public static Icon create(final Icon base) {
return create(base.getIconWidth(), base.getIconHeight());
}
@NotNull
public static Icon create(final int width, final int height) {
return width == height ? create(width) : new EmptyIcon(width, height);
}
@NotNull
public static Icon create(final int size) {
Icon icon = cache.get(size);
if (icon == null && size < 129) {
@ -69,23 +66,23 @@ public final class EmptyIcon implements Icon, UIResource {
public void paintIcon(final Component component, final Graphics g, final int i, final int j) {
}
@Contract(pure = true)
public int getIconWidth() {
return this.width;
}
@Contract(pure = true)
public int getIconHeight() {
return this.height;
}
@Contract(pure = true)
public int hashCode() {
int sum = this.width + this.height;
return sum * (sum + 1) / 2 + this.width;
}
@Contract(value = "null -> false", pure = true)
public boolean equals(final Object o) {
if (this == o) {
return true;

7
src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java

@ -32,7 +32,6 @@ import com.kitfox.svg.SVGRoot;
import com.kitfox.svg.SVGUniverse;
import com.kitfox.svg.animation.AnimationElement;
import com.kitfox.svg.app.beans.SVGIcon;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -46,7 +45,7 @@ import java.util.logging.Logger;
public final class IconColorMapper {
private static final Logger LOGGER = Logger.getLogger(IconLoader.class.getName());
public static void patchColors(@NotNull final SVGIcon svgIcon) {
public static void patchColors(final SVGIcon svgIcon) {
SVGUniverse universe = svgIcon.getSvgUniverse();
SVGDiagram diagram = universe.getDiagram(svgIcon.getSvgURI());
try {
@ -56,7 +55,7 @@ public final class IconColorMapper {
}
}
private static void loadColors(@NotNull final SVGDiagram diagram) throws SVGElementException {
private static void loadColors(final SVGDiagram diagram) throws SVGElementException {
SVGRoot root = diagram.getRoot();
SVGElement defs = diagram.getElement("colors");
if (defs == null) return;
@ -80,7 +79,7 @@ public final class IconColorMapper {
}
}
@NotNull
private static LinearGradient createColor(final Color c, final String name) throws SVGElementException {
LinearGradient grad = new LinearGradient();
grad.addAttribute("id", AnimationElement.AT_XML, name);

33
src/main/java/com/github/weisj/darklaf/icons/IconLoader.java

@ -23,10 +23,6 @@
*/
package com.github.weisj.darklaf.icons;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.net.URISyntaxException;
import java.util.HashMap;
@ -48,13 +44,13 @@ public final class IconLoader {
private final Map<IconKey, DarkUIAwareIcon> awareIconMap = new HashMap<>();
private final Map<IconKey, Icon> iconMap = new HashMap<>();
@Contract(pure = true)
private IconLoader(final Class<?> parentClass) {
this.parentClass = parentClass;
iconLoaderMap.put(parentClass, this);
}
@Contract(pure = true)
public static IconLoader get() {
return instance;
}
@ -87,9 +83,9 @@ public final class IconLoader {
/*
* Helper method to create the icons.
*/
@Contract(value = "_, _, _ -> new", pure = true)
@NotNull
public DarkUIAwareIcon create(@NotNull final String name, final int w, final int h) {
public DarkUIAwareIcon create(final String name, final int w, final int h) {
return new DarkUIAwareIcon("dark/" + name, "light/" + name, w, h, parentClass);
}
@ -133,8 +129,11 @@ public final class IconLoader {
}
}
@NotNull
public Icon loadSVGIcon(@NotNull final String name, final int w, final int h, final boolean themed) {
public Icon loadSVGIcon(final String name, final boolean themed) {
return loadSVGIcon(name, DEFAULT_W, DEFAULT_H, themed);
}
public Icon loadSVGIcon(final String name, final int w, final int h, final boolean themed) {
try {
if (themed) {
return new ThemedSVGIcon(Objects.requireNonNull(parentClass.getResource(name).toURI()), w, h);
@ -148,12 +147,7 @@ public final class IconLoader {
return EmptyIcon.create(0);
}
@NotNull
public Icon loadSVGIcon(@NotNull final String name, final boolean themed) {
return loadSVGIcon(name, DEFAULT_W, DEFAULT_H, themed);
}
@Nullable
public ImageIcon createImageIcon(final String path,
final String description) {
java.net.URL imgURL = parentClass.getResource(path);
@ -170,7 +164,7 @@ public final class IconLoader {
int w;
int h;
@Contract(pure = true)
private IconKey(final String path, final int w, final int h) {
this.path = path;
this.w = w;
@ -182,7 +176,7 @@ public final class IconLoader {
return Objects.hash(path, w, h);
}
@Contract(value = "null -> false", pure = true)
@Override
public boolean equals(final Object o) {
if (this == o) return true;
@ -199,8 +193,7 @@ public final class IconLoader {
return Objects.equals(path, iconKey.path);
}
@NotNull
@Contract(pure = true)
@Override
public String toString() {
return "[path=" + path + ", w=" + w + ", h=" + h + "]";

4
src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.icons;
import org.jetbrains.annotations.Contract;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
@ -42,7 +40,7 @@ public abstract class LazyIcon implements Icon, UIResource {
private boolean loaded;
private Icon icon;
@Contract(pure = true)
public LazyIcon(final String path, final IconLoader.IconKey key, final Class<?> parentClass) {
this.path = path;
this.key = key;

7
src/main/java/com/github/weisj/darklaf/icons/RotatableIcon.java

@ -24,7 +24,6 @@
package com.github.weisj.darklaf.icons;
import com.github.weisj.darklaf.components.alignment.Alignment;
import org.jetbrains.annotations.Contract;
import javax.swing.*;
import java.awt.*;
@ -35,12 +34,12 @@ public class RotatableIcon implements Icon {
private Icon icon;
private Alignment alignment;
@Contract(pure = true)
public RotatableIcon() {
this(null);
}
@Contract(pure = true)
public RotatableIcon(final Icon icon) {
setIcon(icon);
this.alignment = null;
@ -63,7 +62,7 @@ public class RotatableIcon implements Icon {
}
}
@Contract(pure = true)
private double getAngle() {
double angle = 0.0;
switch (alignment) {

3
src/main/java/com/github/weisj/darklaf/icons/ScaledIcon.java

@ -24,7 +24,6 @@
package com.github.weisj.darklaf.icons;
import com.github.weisj.darklaf.util.Scale;
import org.jetbrains.annotations.Contract;
import javax.swing.*;
import java.awt.*;
@ -33,7 +32,7 @@ public class ScaledIcon implements Icon {
private Image img;
@Contract(pure = true)
public ScaledIcon(final Image img) {
this.img = img;
}

3
src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java

@ -25,7 +25,6 @@ package com.github.weisj.darklaf.icons;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.Theme;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.net.URI;
@ -37,7 +36,7 @@ public class ThemedSVGIcon extends DarkSVGIcon {
private Theme currentTheme;
public ThemedSVGIcon(@NotNull final URI uri, final int displayWidth, final int displayHeight) {
public ThemedSVGIcon(final URI uri, final int displayWidth, final int displayHeight) {
super(uri, displayWidth, displayHeight);
}

7
src/main/java/com/github/weisj/darklaf/log/LogFormatter.java

@ -24,7 +24,6 @@
package com.github.weisj.darklaf.log;
import com.github.weisj.darklaf.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -49,7 +48,7 @@ public class LogFormatter extends Formatter {
public static final String ANSI_BOLD_OFF = "\u001B[2m";
@Override
public String format(@NotNull final LogRecord record) {
public String format(final LogRecord record) {
StringBuilder builder = new StringBuilder();
builder.append(ANSI_BLUE);
@ -99,14 +98,14 @@ public class LogFormatter extends Formatter {
return builder.toString();
}
@NotNull
private String calculateDateString(final long milliseconds) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(milliseconds);
return dateFormat.format(date);
}
private String getMessageColor(@NotNull final LogRecord record) {
private String getMessageColor(final LogRecord record) {
if (record.getLevel() == Level.SEVERE) {
return ANSI_RED;
} else if (record.getLevel() == Level.WARNING) {

9
src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.platform;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -55,7 +52,7 @@ public class NativeUtil {
*/
private static File temporaryDir;
@Contract(pure = true)
private NativeUtil() {
}
@ -73,7 +70,7 @@ public class NativeUtil {
* java.lang.String)}).
* @throws FileNotFoundException If the file could not be found inside the JAR.
*/
@Contract("null -> fail")
public static void loadLibraryFromJar(final String path) throws IOException {
if (null == path || !path.startsWith("/")) {
@ -120,7 +117,7 @@ public class NativeUtil {
}
}
@NotNull
private static File createTempDirectory(final String prefix) throws IOException {
String tempDir = System.getProperty("java.io.tmpdir");
File generatedDir = new File(tempDir, prefix + System.nanoTime());

3
src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorations.java

@ -28,7 +28,6 @@ import com.github.weisj.darklaf.platform.NativeUtil;
import com.github.weisj.darklaf.util.SystemInfo;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import org.jetbrains.annotations.Contract;
import java.awt.*;
import java.io.IOException;
@ -107,7 +106,7 @@ public class JNIDecorations {
}
}
@Contract(pure = true)
public static boolean isCustomDecorationSupported() {
return supported;
}

5
src/main/java/com/github/weisj/darklaf/theme/Theme.java

@ -27,7 +27,6 @@ import com.github.weisj.darklaf.DarkLaf;
import com.github.weisj.darklaf.DarkMetalTheme;
import com.github.weisj.darklaf.util.PropertyLoader;
import com.github.weisj.darklaf.util.SystemInfo;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
@ -76,7 +75,7 @@ public abstract class Theme {
* @param properties the properties to load the values into.
* @param currentDefaults the current ui defaults.
*/
public void loadDefaults(@NotNull final Properties properties, final UIDefaults currentDefaults) {
public void loadDefaults(final Properties properties, final UIDefaults currentDefaults) {
String name = getResourcePath() + getName() + "_defaults.properties";
PropertyLoader.putProperties(load(name), properties, currentDefaults);
}
@ -87,7 +86,7 @@ public abstract class Theme {
* @param properties the properties to load the values into.
* @param currentDefaults the current ui defaults.
*/
public void loadGlobals(@NotNull final Properties properties, final UIDefaults currentDefaults) {
public void loadGlobals(final Properties properties, final UIDefaults currentDefaults) {
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "globals", "properties/"),
properties, currentDefaults);
}

10
src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java

@ -25,8 +25,6 @@ package com.github.weisj.darklaf.ui.button;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
@ -72,7 +70,7 @@ public class DarkButtonBorder implements Border, UIResource {
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g,
public void paintBorder(final Component c, final Graphics g,
final int x, final int y, final int width, final int height) {
if (DarkButtonUI.isShadowVariant(c) || DarkButtonUI.isLabelButton(c)) {
return;
@ -116,7 +114,7 @@ public class DarkButtonBorder implements Border, UIResource {
return square ? alt ? focusArc : squareFocusArc : alt ? squareFocusArc : focusArc;
}
private void paintShadow(@NotNull final Graphics2D g2, final int width, final int height, final int arc) {
private void paintShadow(final Graphics2D g2, final int width, final int height, final int arc) {
GraphicsContext context = new GraphicsContext(g2);
int borderSize = getBorderSize();
int shadowSize = getShadowSize();
@ -142,7 +140,7 @@ public class DarkButtonBorder implements Border, UIResource {
return borderSize;
}
protected Color getBorderColor(@NotNull final Component c) {
protected Color getBorderColor(final Component c) {
if (c.hasFocus()) {
return focusBorderColor;
} else if (c instanceof JButton && ((JButton) c).isDefaultButton() && c.isEnabled()) {
@ -171,7 +169,7 @@ public class DarkButtonBorder implements Border, UIResource {
return false;
}
@Contract("null -> false")
public static boolean isThin(final Component c) {
return c instanceof JButton
&& Boolean.TRUE.equals(((JButton) c).getClientProperty("JButton.thin"));

129
src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

@ -27,8 +27,6 @@ import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import com.github.weisj.darklaf.util.SystemInfo;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.SwingUtilities2;
import javax.swing.*;
@ -69,8 +67,7 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
private int arc;
private int squareArc;
@NotNull
@Contract(value = "_ -> new", pure = true)
public static ComponentUI createUI(final JComponent c) {
return new DarkButtonUI();
}
@ -102,7 +99,7 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
squareArc = UIManager.getInt("Button.squareArc");
}
@Contract("null -> false")
public static boolean isSquare(final Component c) {
return c instanceof JButton && Boolean.TRUE.equals(((JButton) c).getClientProperty("JButton.square"));
}
@ -120,7 +117,7 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
}
@Override
protected void paintText(@NotNull final Graphics g, final JComponent c,
protected void paintText(final Graphics g, final JComponent c,
final Rectangle textRect, final String text) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
AbstractButton button = (AbstractButton) c;
@ -159,7 +156,15 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
return c instanceof JButton && ((JButton) c).isDefaultButton();
}
protected void paintButton(final Graphics g, @NotNull final JComponent c) {
protected Color getForeground(final AbstractButton button) {
Color fg = button.getForeground();
if (fg instanceof UIResource && isDefaultButton(button) && !isShadowVariant(button)) {
fg = defaultForeground;
}
return fg;
}
protected void paintButton(final Graphics g, final JComponent c) {
Graphics2D g2 = (Graphics2D) g;
if (shouldDrawBackground(c)) {
AbstractButton b = (AbstractButton) c;
@ -191,62 +196,21 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
}
}
protected String layout(@NotNull final AbstractButton b, final JComponent c, final FontMetrics fm,
final int width, final int height) {
Insets i = b.getInsets();
viewRect.x = i.left;
viewRect.y = i.top;
viewRect.width = width - (i.right + viewRect.x);
viewRect.height = height - (i.bottom + viewRect.y);
textRect.x = textRect.y = textRect.width = textRect.height = 0;
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
// layout the text and icon
return SwingUtilities.layoutCompoundLabel(
b, fm, b.getText(), b.getIcon(),
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewRect, iconRect, textRect,
b.getText() == null ? 0 : b.getIconTextGap());
}
protected void paintIcon(final Graphics g, @NotNull final AbstractButton b, final JComponent c) {
if (b.getIcon() != null) {
g.setClip(iconRect);
paintIcon(g, c, iconRect);
}
}
protected Color getShadowColor(@NotNull final AbstractButton c) {
Object colorHover = c.getClientProperty("JButton.shadow.hover");
Object colorClick = c.getClientProperty("JButton.shadow.click");
return c.getModel().isArmed() ? colorClick instanceof Color ? (Color) colorClick : shadowClick
: colorHover instanceof Color ? (Color) colorHover : shadowHover;
}
private boolean shouldDrawBackground(@NotNull final JComponent c) {
private boolean shouldDrawBackground(final JComponent c) {
if (isLabelButton(c)) return false;
AbstractButton button = (AbstractButton) c;
Border border = c.getBorder();
return c.isEnabled() && border != null && button.isContentAreaFilled();
}
protected int getArc(final Component c) {
if (DarkButtonUI.isNoArc(c)) return 0;
boolean square = DarkButtonUI.isSquare(c);
boolean alt = DarkButtonUI.chooseAlternativeArc(c);
return square ? alt ? arc : squareArc : alt ? squareArc : arc;
}
@Contract("null -> false")
public static boolean isShadowVariant(final Component c) {
if (isFullShadow(c)) return true;
return c instanceof JButton
&& "shadow".equals(((JButton) c).getClientProperty("JButton.variant"));
protected Color getShadowColor(final AbstractButton c) {
Object colorHover = c.getClientProperty("JButton.shadow.hover");
Object colorClick = c.getClientProperty("JButton.shadow.click");
return c.getModel().isArmed() ? colorClick instanceof Color ? (Color) colorClick : shadowClick
: colorHover instanceof Color ? (Color) colorHover : shadowHover;
}
protected Color getBackgroundColor(@NotNull final JComponent c) {
protected Color getBackgroundColor(final JComponent c) {
boolean defaultButton = isDefaultButton(c);
boolean rollOver = (c instanceof JButton && (((JButton) c).isRolloverEnabled()
&& (((JButton) c).getModel().isRollover())));
@ -274,7 +238,41 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
}
}
@Contract("null -> false")
protected int getArc(final Component c) {
if (DarkButtonUI.isNoArc(c)) return 0;
boolean square = DarkButtonUI.isSquare(c);
boolean alt = DarkButtonUI.chooseAlternativeArc(c);
return square ? alt ? arc : squareArc : alt ? squareArc : arc;
}
public static boolean isShadowVariant(final Component c) {
if (isFullShadow(c)) return true;
return c instanceof JButton
&& "shadow".equals(((JButton) c).getClientProperty("JButton.variant"));
}
protected String layout(final AbstractButton b, final JComponent c, final FontMetrics fm,
final int width, final int height) {
Insets i = b.getInsets();
viewRect.x = i.left;
viewRect.y = i.top;
viewRect.width = width - (i.right + viewRect.x);
viewRect.height = height - (i.bottom + viewRect.y);
textRect.x = textRect.y = textRect.width = textRect.height = 0;
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
// layout the text and icon
return SwingUtilities.layoutCompoundLabel(
b, fm, b.getText(), b.getIcon(),
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewRect, iconRect, textRect,
b.getText() == null ? 0 : b.getIconTextGap());
}
public static boolean isFullShadow(final Component c) {
return c instanceof JButton
&& "fullShadow".equals(((JButton) c).getClientProperty("JButton.variant"));
@ -299,27 +297,26 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
context.restore();
}
protected Color getForeground(@NotNull final AbstractButton button) {
Color fg = button.getForeground();
if (fg instanceof UIResource && isDefaultButton(button) && !isShadowVariant(button)) {
fg = defaultForeground;
protected void paintIcon(final Graphics g, final AbstractButton b, final JComponent c) {
if (b.getIcon() != null) {
g.setClip(iconRect);
paintIcon(g, c, iconRect);
}
return fg;
}
@Contract("null -> false")
public static boolean chooseAlternativeArc(final Component c) {
return c instanceof JButton
&& Boolean.TRUE.equals(((JButton) c).getClientProperty("JButton.alternativeArc"));
}
@Contract("null -> false")
public static boolean isLabelButton(final Component c) {
return c instanceof JButton
&& "onlyLabel".equals(((JButton) c).getClientProperty("JButton.variant"));
}
@Contract("null -> false")
public static boolean isNoArc(final Component c) {
return c instanceof JButton
&& Boolean.TRUE.equals(((JButton) c).getClientProperty("JButton.noArc"));
@ -337,7 +334,7 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
}
@Override
public boolean contains(@NotNull final JComponent c, final int x, final int y) {
public boolean contains(final JComponent c, final int x, final int y) {
if (isLabelButton(c)) {
return super.contains(c, x, y);
}
@ -349,7 +346,7 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
public void propertyChange(final PropertyChangeEvent evt) {
String key = evt.getPropertyName();
if (key.startsWith("JButton.")) {
button.repaint();

47
src/main/java/com/github/weisj/darklaf/ui/button/DarkToggleButtonUI.java

@ -26,8 +26,6 @@ package com.github.weisj.darklaf.ui.button;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.SwingUtilities2;
import javax.swing.*;
@ -71,8 +69,7 @@ public class DarkToggleButtonUI extends DarkButtonUI {
protected Color sliderBorderColor;
protected Color inactiveSliderBorderColor;
@NotNull
@Contract(value = "_ -> new", pure = true)
public static ComponentUI createUI(final JComponent c) {
return new DarkToggleButtonUI();
}
@ -93,7 +90,7 @@ public class DarkToggleButtonUI extends DarkButtonUI {
}
@Override
public void paint(final Graphics g, @NotNull final JComponent c) {
public void paint(final Graphics g, final JComponent c) {
if (isSlider(c)) {
GraphicsContext config = GraphicsUtil.setupStrokePainting(g);
AbstractButton b = (AbstractButton) c;
@ -109,8 +106,19 @@ public class DarkToggleButtonUI extends DarkButtonUI {
}
}
protected Color getBackgroundColor(final JComponent c) {
if (c instanceof JToggleButton && c.isEnabled()) {
if (((JToggleButton) c).isSelected()) {
return background;
} else {
return backgroundInactive;
}
}
return super.getBackgroundColor(c);
}
@Override
protected String layout(@NotNull final AbstractButton b, final JComponent c,
protected String layout(final AbstractButton b, final JComponent c,
final FontMetrics fm, final int width, final int height) {
if (isSlider(c)) {
Insets i = b.getInsets();
@ -139,19 +147,8 @@ public class DarkToggleButtonUI extends DarkButtonUI {
}
}
protected Color getBackgroundColor(@NotNull final JComponent c) {
if (c instanceof JToggleButton && c.isEnabled()) {
if (((JToggleButton) c).isSelected()) {
return background;
} else {
return backgroundInactive;
}
}
return super.getBackgroundColor(c);
}
@Override
public boolean contains(@NotNull final JComponent c, final int x, final int y) {
public boolean contains(final JComponent c, final int x, final int y) {
if (!isSlider(c)) return super.contains(c, x, y);
if (!(x >= 0 && x <= c.getWidth() && y >= 0 && y <= c.getHeight())) return false;
Rectangle bounds = getSliderBounds(c);
@ -159,13 +156,13 @@ public class DarkToggleButtonUI extends DarkButtonUI {
bounds.height, bounds.height).contains(x, y);
}
@Contract("null -> false")
private static boolean isSlider(final JComponent c) {
return c instanceof JToggleButton
&& "slider".equals(c.getClientProperty("JToggleButton.variant"));
}
private void paintSlider(@NotNull final Graphics2D g, final AbstractButton c) {
private void paintSlider(final Graphics2D g, final AbstractButton c) {
Rectangle bounds = getSliderBounds(c);
g.translate(bounds.x, bounds.y);
@ -198,8 +195,8 @@ public class DarkToggleButtonUI extends DarkButtonUI {
config.restore();
}
@NotNull
private Rectangle getSliderBounds(@NotNull final JComponent c) {
private Rectangle getSliderBounds(final JComponent c) {
int x = borderSize;
int y = (c.getHeight() - sliderSize.height) / 2;
rect.x = x;
@ -212,18 +209,18 @@ public class DarkToggleButtonUI extends DarkButtonUI {
return rect;
}
protected Color getToggleBorderColor(@NotNull final AbstractButton b) {
protected Color getToggleBorderColor(final AbstractButton b) {
if (b.hasFocus()) {
return focusBorderColor;
}
return b.isEnabled() ? borderColor : inactiveBorderColor;
}
protected Color getSliderColor(@NotNull final AbstractButton b) {
protected Color getSliderColor(final AbstractButton b) {
return b.isEnabled() ? sliderColor : inactiveSliderColor;
}
protected Color getSliderBorderColor(@NotNull final AbstractButton b) {
protected Color getSliderBorderColor(final AbstractButton b) {
return b.isEnabled() ? sliderBorderColor : inactiveSliderBorderColor;
}

3
src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java

@ -27,7 +27,6 @@ import com.github.weisj.darklaf.components.SelectableTreeNode;
import com.github.weisj.darklaf.decorators.CellRenderer;
import com.github.weisj.darklaf.ui.tree.DarkTreeCellRenderer;
import com.github.weisj.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.table.TableCellRenderer;
@ -45,7 +44,7 @@ public class DarkCellRendererToggleButton<T extends JToggleButton & CellEditorTo
private final T toggleButton;
public DarkCellRendererToggleButton(@NotNull final T toggleButton) {
public DarkCellRendererToggleButton(final T toggleButton) {
this.toggleButton = toggleButton;
}

10
src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxMenuItemUI.java

@ -27,8 +27,6 @@ import com.github.weisj.darklaf.decorators.MouseClickListener;
import com.github.weisj.darklaf.ui.menu.DarkMenuItemUIBase;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.MenuItemLayoutHelper;
import javax.swing.*;
@ -51,8 +49,6 @@ public class DarkCheckBoxMenuItemUI extends DarkMenuItemUIBase {
private Icon checkBoxSelectedFocusedIcon;
@NotNull
@Contract(value = "_ -> new", pure = true)
public static ComponentUI createUI(final JComponent c) {
return new DarkCheckBoxMenuItemUI();
}
@ -63,8 +59,8 @@ public class DarkCheckBoxMenuItemUI extends DarkMenuItemUIBase {
c.putClientProperty("CheckBoxMenuItem.doNotCloseOnMouseClick", Boolean.TRUE);
}
protected void paintCheckIcon(final Graphics g2, @NotNull final MenuItemLayoutHelper lh,
@NotNull final MenuItemLayoutHelper.LayoutResult lr,
protected void paintCheckIcon(final Graphics g2, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr,
final Color holdc, final Color foreground) {
Graphics2D g = (Graphics2D) g2;
GraphicsContext config = GraphicsUtil.setupStrokePainting(g);
@ -74,7 +70,7 @@ public class DarkCheckBoxMenuItemUI extends DarkMenuItemUIBase {
g.setColor(foreground);
}
protected Icon getCheckBoxIcon(@NotNull final AbstractButton b) {
protected Icon getCheckBoxIcon(final AbstractButton b) {
boolean selected = b.isSelected();
boolean enabled = b.isEnabled();
boolean hasFocus = b.hasFocus();

27
src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxUI.java

@ -27,8 +27,6 @@ import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.SwingUtilities2;
import javax.swing.*;
@ -77,8 +75,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
private Icon checkBoxSelectedDisabledIcon;
private Icon checkBoxSelectedFocusedIcon;
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkCheckBoxUI();
}
@ -133,7 +130,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
}
@Override
public synchronized void paint(final Graphics g2d, @NotNull final JComponent c) {
public synchronized void paint(final Graphics g2d, final JComponent c) {
Graphics2D g = (Graphics2D) g2d;
JCheckBox b = (JCheckBox) c;
FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, c.getFont());
@ -159,7 +156,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
}
}
protected String layoutCheckBox(@NotNull final JCheckBox b, final FontMetrics fm) {
protected String layoutCheckBox(final JCheckBox b, final FontMetrics fm) {
Insets i = b.getInsets();
size = b.getSize(size);
viewRect.x = i.left;
@ -179,14 +176,14 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
return text;
}
private void paintBackground(@NotNull final JComponent c, final Graphics2D g) {
private void paintBackground(final JComponent c, final Graphics2D g) {
if (c.isOpaque()) {
g.setColor(c.getBackground());
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
}
public static Icon getIconBullet(final JComponent c, final Graphics2D g, @NotNull final AbstractButton b) {
public static Icon getIconBullet(final JComponent c, final Graphics2D g, final AbstractButton b) {
ButtonModel model = b.getModel();
Icon icon = b.getIcon();
if (!model.isEnabled()) {
@ -220,7 +217,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
return icon;
}
protected Icon getCheckIcon(@NotNull final AbstractButton b) {
protected Icon getCheckIcon(final AbstractButton b) {
boolean selected = b.isSelected();
boolean enabled = b.isEnabled();
boolean hasFocus = b.hasFocus();
@ -230,7 +227,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
: checkBoxDisabledIcon;
}
protected void paintDarkCheck(final JComponent c, final Graphics2D g, @NotNull final JCheckBox b) {
protected void paintDarkCheck(final JComponent c, final Graphics2D g, final JCheckBox b) {
GraphicsContext config = new GraphicsContext(g);
boolean enabled = b.isEnabled();
g.translate(iconRect.x + ICON_OFF, iconRect.y + ICON_OFF);
@ -243,7 +240,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
config.restore();
}
public static void paintText(@NotNull final Graphics2D g, @NotNull final AbstractButton b,
public static void paintText(final Graphics2D g, final AbstractButton b,
final Rectangle textRect, final String text, final FontMetrics fm,
final Color disabledTextColor) {
GraphicsContext context = GraphicsUtil.setupAntialiasing(g);
@ -266,7 +263,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
return new IconUIResource(EmptyIcon.create(20));
}
protected void paintCheckBorder(@NotNull final Graphics2D g, final boolean enabled, final boolean focus,
protected void paintCheckBorder(final Graphics2D g, final boolean enabled, final boolean focus,
final boolean selected, final int arcSize, final int borderSize) {
Graphics2D g2 = (Graphics2D) g.create();
Color bgColor = getFillColor(selected, enabled);
@ -287,7 +284,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
g2.dispose();
}
protected void paintCheckArrow(@NotNull final Graphics2D g, final boolean enabled, final boolean focus) {
protected void paintCheckArrow(final Graphics2D g, final boolean enabled, final boolean focus) {
GraphicsContext config = GraphicsUtil.setupStrokePainting(g);
g.setStroke(new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
Color color = getCheckColor(focus, enabled);
@ -318,7 +315,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
}
@Override
public boolean contains(@NotNull final JComponent c, final int x, final int y) {
public boolean contains(final JComponent c, final int x, final int y) {
if (hitArea.isEmpty() && c instanceof JCheckBox) {
layoutCheckBox((JCheckBox) c, c.getFontMetrics(c.getFont()));
}
@ -326,7 +323,7 @@ public class DarkCheckBoxUI extends MetalCheckBoxUI implements PropertyChangeLis
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
public void propertyChange(final PropertyChangeEvent evt) {
String key = evt.getPropertyName();
if ("componentOrientation".equals(key)) {
checkBox.repaint();

5
src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPipette.java

@ -25,7 +25,6 @@
package com.github.weisj.darklaf.ui.colorchooser;
import com.github.weisj.darklaf.components.Disposable;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.awt.image.ImageObserver;
@ -35,9 +34,9 @@ import java.awt.image.ImageObserver;
* @author Konstantin Bulenkov
*/
public interface ColorPipette extends ImageObserver, Disposable {
void setInitialColor(@Nullable Color initialColor);
void setInitialColor(Color initialColor);
@Nullable
Color getColor();
Window show();

8
src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPreviewComponent.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.ui.colorchooser;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -47,7 +44,7 @@ final class ColorPreviewComponent extends JComponent {
}
@Override
protected void paintComponent(@NotNull final Graphics g) {
protected void paintComponent(final Graphics g) {
final Insets i = getInsets();
final Rectangle r = getBounds();
@ -67,8 +64,7 @@ final class ColorPreviewComponent extends JComponent {
g.fillRect(i.left, i.top + height - 1, width, 1);
}
@NotNull
@Contract(value = " -> new", pure = true)
@Override
public Dimension getPreferredSize() {
return new Dimension(100, 32);

30
src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorValueFormatter.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.ui.colorchooser;
import com.github.weisj.darklaf.color.DarkColorModel;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.text.AttributeSet;
@ -56,7 +54,7 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
private JFormattedTextField text;
private final DocumentFilter filter = new DocumentFilter() {
@Override
public void remove(@NotNull final FilterBypass fb, final int offset,
public void remove(final FilterBypass fb, final int offset,
final int length) throws BadLocationException {
if (isValid(fb.getDocument().getLength() - length)) {
fb.remove(offset, length);
@ -67,8 +65,8 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
}
@Override
public void insertString(@NotNull final FilterBypass fb, final int offset,
@NotNull final String text, final AttributeSet set) throws BadLocationException {
public void insertString(final FilterBypass fb, final int offset,
final String text, final AttributeSet set) throws BadLocationException {
if (isValid(fb.getDocument().getLength() + text.length())
&& isValid(text)) {
StringBuilder newText = new StringBuilder(fb.getDocument().getText(0, fb.getDocument().getLength()));
@ -83,8 +81,8 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
}
@Override
public void replace(@NotNull final FilterBypass fb, final int offset, final int length,
@NotNull final String text, final AttributeSet set) throws BadLocationException {
public void replace(final FilterBypass fb, final int offset, final int length,
final String text, final AttributeSet set) throws BadLocationException {
if (isValid(fb.getDocument().getLength() + text.length() - length) && isValid(text)) {
StringBuilder newText = new StringBuilder(fb.getDocument().getText(0, fb.getDocument().getLength()));
newText.replace(offset, offset + length, text);
@ -107,9 +105,9 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
errorTimer.setRepeats(false);
}
@NotNull
static ColorValueFormatter init(final DarkColorModel model, final int index,
final boolean hex, @NotNull final JFormattedTextField text) {
final boolean hex, final JFormattedTextField text) {
ColorValueFormatter formatter = new ColorValueFormatter(model, index, hex);
text.setFormatterFactory(new DefaultFormatterFactory(formatter));
text.setMinimumSize(text.getPreferredSize());
@ -151,7 +149,7 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
this.transparencyEnabled = transparencyEnabled;
}
public void focusGained(@NotNull final FocusEvent event) {
public void focusGained(final FocusEvent event) {
Object source = event.getSource();
if (source instanceof JFormattedTextField) {
this.text = (JFormattedTextField) source;
@ -167,7 +165,7 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
SwingUtilities.invokeLater(() -> text.select(0, 0));
}
@Contract(pure = true)
private boolean isValid(final int length) {
return (0 <= length) && (length <= getLength());
}
@ -176,12 +174,12 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
return hex ? getHexLength() : String.valueOf(model.getMaximum(fieldIndex)).length();
}
@Contract(pure = true)
private int getHexLength() {
return transparencyEnabled ? 8 : 6;
}
private boolean isValid(@NotNull final String text) {
private boolean isValid(final String text) {
int length = text.length();
for (int i = 0; i < length; i++) {
char ch = text.charAt(i);
@ -202,7 +200,7 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
}
@Override
public Object stringToValue(@NotNull final String text) throws ParseException {
public Object stringToValue(final String text) throws ParseException {
try {
if (text.isEmpty()) {
return model.getDefault(fieldIndex);
@ -238,7 +236,7 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
}
}
@Contract("null -> fail")
@Override
public String valueToString(final Object object) throws ParseException {
if (object instanceof Integer && !hex) {
@ -258,7 +256,7 @@ public final class ColorValueFormatter extends JFormattedTextField.AbstractForma
throw new ParseException("illegal object", 0);
}
@Contract(pure = true)
@Override
protected DocumentFilter getDocumentFilter() {
return this.filter;

3
src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheel.java

@ -27,7 +27,6 @@ package com.github.weisj.darklaf.ui.colorchooser;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -118,7 +117,7 @@ public class ColorWheel extends JComponent {
setColor(ColorUtil.toAlpha(rgb, opacity), this, h, s, b);
}
public void setColor(@NotNull final Color color, final Object source,
public void setColor(final Color color, final Object source,
final float h, final float s, final float b) {
myColor = color;
myHue = h;

4
src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorWheelPanel.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.ui.colorchooser;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import java.awt.*;
@ -77,7 +75,7 @@ public class ColorWheelPanel extends JPanel {
}
}
public void setColor(@NotNull final Color color, final Object source) {
public void setColor(final Color color, final Object source) {
float[] hsb = new float[3];
Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);

10
src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java

@ -28,8 +28,6 @@ import com.github.weisj.darklaf.color.DarkColorModel;
import com.github.weisj.darklaf.components.DefaultColorPipette;
import com.github.weisj.darklaf.decorators.AncestorAdapter;
import com.github.weisj.darklaf.util.ColorUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.colorchooser.AbstractColorChooserPanel;
@ -68,7 +66,7 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
private Icon pipetteIcon;
private Icon pipetteHoverIcon;
@Contract("null -> fail")
public DarkColorChooserPanel(final DarkColorModel... colorModels) {
if (colorModels == null || colorModels.length == 0) {
throw new IllegalArgumentException("Must pass at least one valid colorModel");
@ -186,7 +184,7 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
return (DarkColorModel) formatBox.getSelectedItem();
}
@NotNull
private JComponent buildTopPanel(final boolean enablePipette) {
final JPanel result = new JPanel(new BorderLayout());
@ -241,7 +239,7 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
return result;
}
@NotNull
private JFormattedTextField createColorField(final boolean hex) {
JFormattedTextField field = new JFormattedTextField(0);
field.setColumns(hex ? 8 : 4);
@ -399,7 +397,7 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
}
private void applyColorToHEX(@NotNull final Color c) {
private void applyColorToHEX(final Color c) {
boolean changingOld = isChanging;
isChanging = true;
boolean transparencyEnabled = isColorTransparencySelectionEnabled();

5
src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserUI.java

@ -27,8 +27,6 @@ import com.github.weisj.darklaf.color.DarkColorModel;
import com.github.weisj.darklaf.color.DarkColorModelCMYK;
import com.github.weisj.darklaf.color.DarkColorModelHSL;
import com.github.weisj.darklaf.decorators.AncestorAdapter;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.colorchooser.AbstractColorChooserPanel;
@ -73,8 +71,7 @@ public class DarkColorChooserUI extends BasicColorChooserUI {
}
};
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkColorChooserUI();
}

7
src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java

@ -25,7 +25,6 @@ package com.github.weisj.darklaf.ui.colorchooser;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.NotNull;
import sun.swing.SwingUtilities2;
import javax.swing.*;
@ -80,7 +79,7 @@ public class DarkPreviewPanel extends JPanel {
return new Dimension(x, y);
}
private int paintSquares(@NotNull final Graphics g, final int offsetX) {
private int paintSquares(final Graphics g, final int offsetX) {
Color color = getForeground();
g.setColor(Color.white);
@ -146,7 +145,7 @@ public class DarkPreviewPanel extends JPanel {
}
private int paintText(@NotNull final Graphics g, final int offsetX) {
private int paintText(final Graphics g, final int offsetX) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
g.setFont(getFont());
JComponent host = getColorChooser();
@ -183,7 +182,7 @@ public class DarkPreviewPanel extends JPanel {
return width + TEXT_GAP * 3;
}
private int paintSwatch(@NotNull final Graphics g, final int offsetX) {
private int paintSwatch(final Graphics g, final int offsetX) {
g.setColor(oldColor);
g.fillRect(offsetX, 0, SWATCH_WIDTH, SQUARE_SIZE + SQUARE_GAP / 2);
g.setColor(getForeground());

6
src/main/java/com/github/weisj/darklaf/ui/colorchooser/MainSwatchPanel.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.ui.colorchooser;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -50,8 +47,7 @@ class MainSwatchPanel extends SwatchPanel {
}
}
@NotNull
@Contract(value = " -> new", pure = true)
private int[] initRawValues() {
return new int[]{
0, 0, 0,

4
src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.ui.colorchooser;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
@ -54,7 +52,7 @@ class RecentSwatchPanel extends SwatchPanel {
}
@Override
public String getToolTipText(@NotNull final MouseEvent e) {
public String getToolTipText(final MouseEvent e) {
Color color = getColorForLocation(e.getX(), e.getY());
if (color == defaultRecentColor || color == null) return null;
return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue();

9
src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java

@ -28,8 +28,6 @@ import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -118,8 +116,7 @@ class SlideComponent extends JComponent implements ColorListener {
setToolTipText(getToolTipText(null));
}
@NotNull
@Contract(" -> new")
private Rectangle getKnobRect() {
if (vertical) {
return new Rectangle(1, pointerValue - 6, 12, 12);
@ -221,7 +218,7 @@ class SlideComponent extends JComponent implements ColorListener {
drawKnob(g2d, vertical ? 7 : pointerValue, vertical ? pointerValue : 7, vertical);
}
protected void drawKnob(@NotNull final Graphics2D g2d, int x, int y, final boolean vertical) {
protected void drawKnob(final Graphics2D g2d, int x, int y, final boolean vertical) {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (vertical) {
y -= 6;
@ -309,7 +306,7 @@ class SlideComponent extends JComponent implements ColorListener {
}
}
@Contract(pure = true)
private static float getMaxValue(final Unit unit) {
return LEVEL.equals(unit) ? LEVEL_MAX_VALUE : PERCENT_MAX_VALUE;
}

16
src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java

@ -27,9 +27,6 @@ import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@ -134,15 +131,14 @@ abstract class SwatchPanel extends JPanel {
return getColorForCell(selCol, selRow);
}
@Nullable
@Contract(pure = true)
private Color getColorForCell(final int column, final int row) {
int index = (row * numSwatches.width) + column;
if (index >= colors.length) return null;
return colors[(row * numSwatches.width) + column];
}
public void paintComponent(@NotNull final Graphics g) {
public void paintComponent(final Graphics g) {
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
for (int row = 0; row < numSwatches.height; row++) {
@ -167,7 +163,7 @@ abstract class SwatchPanel extends JPanel {
}
}
@Contract(pure = true)
private int getYForRow(final int row) {
return row * (swatchSize.height + gap.height);
}
@ -186,7 +182,7 @@ abstract class SwatchPanel extends JPanel {
return new Dimension(x, y);
}
public String getToolTipText(@NotNull final MouseEvent e) {
public String getToolTipText(final MouseEvent e) {
Color color = getColorForLocation(e.getX(), e.getY());
if (color == null) return null;
return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue();
@ -218,8 +214,8 @@ abstract class SwatchPanel extends JPanel {
return new Point(column, row);
}
@NotNull
protected Rectangle getSwatchBounds(@NotNull final MouseEvent e) {
protected Rectangle getSwatchBounds(final MouseEvent e) {
Point p = getCoordinatesForLocation(e.getX(), e.getY());
int x = getXForColumn(p.x);
int y = getYForRow(p.y);

19
src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java

@ -27,8 +27,6 @@ import com.github.weisj.darklaf.components.ArrowButton;
import com.github.weisj.darklaf.ui.list.DarkListCellRenderer;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
@ -76,8 +74,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC
protected Color arrowBackgroundEnd;
private Insets boxPadding;
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkComboBoxUI();
}
@ -140,7 +137,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC
process(e);
}
private void process(@NotNull final KeyEvent e) {
private void process(final KeyEvent e) {
final int code = e.getKeyCode();
if ((code == KeyEvent.VK_UP || code == KeyEvent.VK_DOWN) && e.getModifiersEx() == 0) {
comboBox.dispatchEvent(e);
@ -187,7 +184,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC
paintCurrentValue(g, r, hasFocus);
}
private void paintBackground(final Graphics g, @NotNull final JComponent c, final int width, final int height) {
private void paintBackground(final Graphics g, final JComponent c, final int width, final int height) {
final Container parent = c.getParent();
if (parent != null && parent.isOpaque()) {
g.setColor(parent.getBackground());
@ -207,18 +204,18 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC
}
}
protected Color getBackground(@NotNull final JComboBox c) {
protected Color getBackground(final JComboBox c) {
if (!c.isEnabled()) return inactiveBackground;
if (c.isEditable()) return editBackground;
return background;
}
protected static boolean isTableCellEditor(@NotNull final Component c) {
protected static boolean isTableCellEditor(final Component c) {
return c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty("JComboBox.isTableCellEditor"));
}
protected static boolean isTreeCellEditor(@NotNull final Component c) {
protected static boolean isTreeCellEditor(final Component c) {
return c instanceof JComponent
&& Boolean.TRUE.equals(((JComponent) c).getClientProperty("JComboBox.isTreeCellEditor"));
}
@ -396,7 +393,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC
}
}
protected Paint getArrowBackground(@NotNull final JComboBox<?> c) {
protected Paint getArrowBackground(final JComboBox<?> c) {
if (!c.isEnabled()) return inactiveBackground;
if (c.isEditable()) {
return new GradientPaint(0, borderSize, arrowBackgroundStart,
@ -427,7 +424,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
public void propertyChange(final PropertyChangeEvent evt) {
String key = evt.getPropertyName();
if ("componentOrientation".equals(key)) {
comboBox.doLayout();

5
src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java

@ -25,8 +25,6 @@ package com.github.weisj.darklaf.ui.filechooser;
import com.github.weisj.darklaf.components.tooltip.TooltipAwareButton;
import com.github.weisj.darklaf.components.tooltip.TooltipAwareToggleButton;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.FilePane;
import javax.accessibility.AccessibleContext;
@ -47,8 +45,7 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
super(b);
}
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkFileChooserUI((JFileChooser) c);
}

5
src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java

@ -27,7 +27,6 @@ import com.github.weisj.darklaf.ui.list.DarkListCellRenderer;
import com.github.weisj.darklaf.ui.table.DarkTableCellEditor;
import com.github.weisj.darklaf.ui.table.DarkTableCellRenderer;
import com.github.weisj.darklaf.ui.table.TextFieldTableCellEditorBorder;
import org.jetbrains.annotations.NotNull;
import sun.awt.AWTAccessor;
import sun.awt.shell.ShellFolder;
import sun.awt.shell.ShellFolderColumnInfo;
@ -1765,7 +1764,7 @@ public class DarkFilePaneUIBridge extends JPanel implements PropertyChangeListen
JFileChooser chooser;
DateFormat df;
DetailsTableCellRenderer(@NotNull final JFileChooser chooser) {
DetailsTableCellRenderer(final JFileChooser chooser) {
this.chooser = chooser;
df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT,
chooser.getLocale());
@ -1898,7 +1897,7 @@ public class DarkFilePaneUIBridge extends JPanel implements PropertyChangeListen
@SuppressWarnings("serial") // JDK-implementation class
protected class FileRenderer extends DarkListCellRenderer {
public Component getListCellRendererComponent(@NotNull final JList<?> list, final Object value,
public Component getListCellRendererComponent(final JList<?> list, final Object value,
final int index, boolean isSelected,
final boolean cellHasFocus) {

4
src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkDesktopIconUI.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.ui.internalframe;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.MatteBorder;
import javax.swing.plaf.ComponentUI;
@ -112,7 +110,7 @@ public class DarkDesktopIconUI extends BasicDesktopIconUI {
}
class TitleListener implements PropertyChangeListener {
public void propertyChange(@NotNull final PropertyChangeEvent e) {
public void propertyChange(final PropertyChangeEvent e) {
if (e.getPropertyName().equals("title")) {
button.setText((String) e.getNewValue());
}

3
src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameBorder.java

@ -24,7 +24,6 @@
package com.github.weisj.darklaf.ui.internalframe;
import com.github.weisj.darklaf.components.border.DropShadowBorder;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.InsetsUIResource;
@ -43,7 +42,7 @@ public class DarkInternalFrameBorder extends DropShadowBorder implements UIResou
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics graphics, final int x, final int y,
public void paintBorder(final Component c, final Graphics graphics, final int x, final int y,
final int width, final int height) {
if (c instanceof JInternalFrame && ((JInternalFrame) c).isMaximum()) {
return;

7
src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java

@ -25,7 +25,6 @@ package com.github.weisj.darklaf.ui.internalframe;
import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.ui.rootpane.TitlePaneIcon;
import org.jetbrains.annotations.NotNull;
import sun.swing.SwingUtilities2;
import javax.accessibility.AccessibleContext;
@ -153,7 +152,7 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane {
setButtonIcons();
}
protected void addSystemMenuItems(@NotNull final JMenu systemMenu) {
protected void addSystemMenuItems(final JMenu systemMenu) {
JMenuItem mi = systemMenu.add(restoreAction);
mi.setMnemonic(getButtonMnemonic("restore"));
mi.setIcon(minimizeIcon);
@ -184,7 +183,7 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane {
}
@Override
public void paintComponent(@NotNull final Graphics g) {
public void paintComponent(final Graphics g) {
g.setColor(getTitleBackground());
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(border);
@ -208,7 +207,7 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane {
return frame.isSelected() ? selectedTitleColor : notSelectedTitleColor;
}
@NotNull
private static JButton createButton(final String accessibleName) {
JButton button = new JButton();
button.setFocusable(false);

6
src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.ui.internalframe;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicInternalFrameUI;
@ -40,8 +37,7 @@ public class DarkInternalFrameUI extends BasicInternalFrameUI {
super(b);
}
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent b) {
return new DarkInternalFrameUI((JInternalFrame) b);
}

3
src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java

@ -25,7 +25,6 @@ package com.github.weisj.darklaf.ui.label;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
@ -39,7 +38,7 @@ public class DarkLabelUI extends BasicLabelUI {
protected static final DarkLabelUI darkLabelUI = new DarkLabelUI();
@Contract(pure = true)
public static ComponentUI createUI(final JComponent c) {
return darkLabelUI;
}

3
src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellRenderer.java

@ -24,7 +24,6 @@
package com.github.weisj.darklaf.ui.list;
import com.github.weisj.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ListUI;
@ -33,7 +32,7 @@ import java.awt.*;
public class DarkListCellRenderer extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(@NotNull final JList<?> list, final Object value,
public Component getListCellRendererComponent(final JList<?> list, final Object value,
final int index, final boolean isSelected,
final boolean cellHasFocus) {
if (getHorizontalAlignment() != CENTER) {

13
src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.ui.list;
import com.github.weisj.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
@ -42,8 +40,7 @@ public class DarkListUI extends DarkListUIBridge {
UIManager.put("List.cellRenderer", new DarkListCellRenderer());
}
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent list) {
return new DarkListUI();
}
@ -141,10 +138,10 @@ public class DarkListUI extends DarkListUIBridge {
rendererPane.removeAll();
}
protected void paintCell(final Graphics g, final int index, @NotNull final Rectangle rowBounds,
@NotNull final ListCellRenderer<Object> cellRenderer,
@NotNull final ListModel<Object> dataModel,
@NotNull final ListSelectionModel selModel, final int leadIndex, final int row) {
protected void paintCell(final Graphics g, final int index, final Rectangle rowBounds,
final ListCellRenderer<Object> cellRenderer,
final ListModel<Object> dataModel,
final ListSelectionModel selModel, final int leadIndex, final int row) {
boolean empty = index >= list.getModel().getSize();
Object value = empty ? null : dataModel.getElementAt(index);
boolean cellHasFocus = list.hasFocus() && (index == leadIndex);

3
src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java

@ -28,7 +28,6 @@ import com.github.weisj.darklaf.ui.DragRecognitionSupport;
import com.github.weisj.darklaf.util.DarkSwingUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.LazyActionMap;
import org.jetbrains.annotations.NotNull;
import sun.swing.DefaultLookup;
import sun.swing.SwingUtilities2;
import sun.swing.UIAction;
@ -251,7 +250,7 @@ public class DarkListUIBridge extends BasicListUI {
*
* @param map the map
*/
public static void loadActionMap(@NotNull final LazyActionMap map) {
public static void loadActionMap(final LazyActionMap map) {
map.put(new Actions(Actions.SELECT_PREVIOUS_COLUMN));
map.put(new Actions(Actions.SELECT_PREVIOUS_COLUMN_EXTEND));
map.put(new Actions(Actions.SELECT_PREVIOUS_COLUMN_CHANGE_LEAD));

4
src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.ui.menu;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource;
@ -43,7 +41,7 @@ public class DarkMenuBarBorder implements Border, UIResource {
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g, final int x, final int y,
public void paintBorder(final Component c, final Graphics g, final int x, final int y,
final int w, final int h) {
g.setColor(borderColor);
g.fillRect(x, y + h - 1, w, 1);

4
src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarUI.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.ui.menu;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.metal.MetalMenuBarUI;
import java.awt.*;
@ -44,7 +42,7 @@ public class DarkMenuBarUI extends MetalMenuBarUI {
}
@Override
public void paint(@NotNull final Graphics g, @NotNull final JComponent c) {
public void paint(final Graphics g, final JComponent c) {
g.setColor(background);
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}

179
src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java

@ -28,8 +28,6 @@ import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import com.github.weisj.darklaf.util.LazyActionMap;
import com.github.weisj.darklaf.util.StringUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.MenuItemLayoutHelper;
import sun.swing.SwingUtilities2;
import sun.swing.UIAction;
@ -46,13 +44,12 @@ import java.awt.event.ActionEvent;
*/
public class DarkMenuItemUIBase extends BasicMenuItemUI {
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkMenuItemUIBase();
}
public static void loadActionMap(@NotNull final LazyActionMap map) {
public static void loadActionMap(final LazyActionMap map) {
map.put(new Actions(Actions.CLICK));
}
@ -76,7 +73,51 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
return menuItem.isEnabled() && ((JMenuItem) menuItem).isArmed();
}
protected void paintCheckIcon(final Graphics g, @NotNull final MenuItemLayoutHelper lh,
private static void rightAlignAccText(final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr) {
Rectangle accRect = lr.getAccRect();
ButtonModel model = lh.getMenuItem().getModel();
if (model.isEnabled()) {
accRect.x = lh.getViewRect().x + lh.getViewRect().width
- lh.getMenuItem().getIconTextGap() - lr.getAccRect().width;
}
}
protected void paintMenuItem(final Graphics g, final JComponent c,
final Icon checkIcon, final Icon arrowIcon,
final Color background, final Color foreground,
final int defaultTextIconGap) {
// Save original graphics font and color
Font holdf = g.getFont();
Color holdc = g.getColor();
JMenuItem mi = (JMenuItem) c;
g.setFont(mi.getFont());
Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
DarkUIUtil.applyInsets(viewRect, mi.getInsets());
MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter,
mi.getComponentOrientation().isLeftToRight(), mi.getFont(),
acceleratorFont, MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix());
MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
paintBackground(g, mi, background);
paintCheckIcon(g, lh, lr, holdc, foreground);
paintIcon(g, lh, lr, holdc);
g.setColor(foreground);
paintText(g, lh, lr);
paintAccText(g, lh, lr);
paintArrowIcon(g, lh, lr, foreground);
// Restore original graphics font and color
g.setColor(holdc);
g.setFont(holdf);
}
protected void paintCheckIcon(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr,
final Color holdc, final Color foreground) {
if (lh.getCheckIcon() != null) {
@ -95,45 +136,6 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
}
}
protected void paintIcon(final Graphics g, @NotNull final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr, final Color holdc) {
if (lh.getIcon() != null) {
Icon icon;
ButtonModel model = lh.getMenuItem().getModel();
if (!model.isEnabled()) {
icon = lh.getMenuItem().getDisabledIcon();
} else if (model.isPressed() && model.isArmed()) {
icon = lh.getMenuItem().getPressedIcon();
if (icon == null) {
// Use default icon
icon = lh.getMenuItem().getIcon();
}
} else {
icon = lh.getMenuItem().getIcon();
}
if (icon != null) {
icon.paintIcon(lh.getMenuItem(), g, lr.getIconRect().x, lr.getIconRect().y);
g.setColor(holdc);
}
}
}
protected void paintText(final Graphics g, @NotNull final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
if (!StringUtil.isBlank(lh.getText())) {
if (lh.getHtmlView() != null) {
// Text is HTML
lh.getHtmlView().paint(g, lr.getTextRect());
} else {
// Text isn't HTML
paintText(g, lh.getMenuItem(), lr.getTextRect(), lh.getText());
}
}
config.restore();
}
protected void paintAccText(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
@ -175,7 +177,46 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
config.restore();
}
protected void paintArrowIcon(final Graphics g, @NotNull final MenuItemLayoutHelper lh,
protected void paintIcon(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr, final Color holdc) {
if (lh.getIcon() != null) {
Icon icon;
ButtonModel model = lh.getMenuItem().getModel();
if (!model.isEnabled()) {
icon = lh.getMenuItem().getDisabledIcon();
} else if (model.isPressed() && model.isArmed()) {
icon = lh.getMenuItem().getPressedIcon();
if (icon == null) {
// Use default icon
icon = lh.getMenuItem().getIcon();
}
} else {
icon = lh.getMenuItem().getIcon();
}
if (icon != null) {
icon.paintIcon(lh.getMenuItem(), g, lr.getIconRect().x, lr.getIconRect().y);
g.setColor(holdc);
}
}
}
protected void paintText(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
if (!StringUtil.isBlank(lh.getText())) {
if (lh.getHtmlView() != null) {
// Text is HTML
lh.getHtmlView().paint(g, lr.getTextRect());
} else {
// Text isn't HTML
paintText(g, lh.getMenuItem(), lr.getTextRect(), lh.getText());
}
}
config.restore();
}
protected void paintArrowIcon(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr,
final Color foreground) {
if (lh.getArrowIcon() != null) {
@ -191,52 +232,8 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
}
}
private static void rightAlignAccText(@NotNull final MenuItemLayoutHelper lh,
@NotNull final MenuItemLayoutHelper.LayoutResult lr) {
Rectangle accRect = lr.getAccRect();
ButtonModel model = lh.getMenuItem().getModel();
if (model.isEnabled()) {
accRect.x = lh.getViewRect().x + lh.getViewRect().width
- lh.getMenuItem().getIconTextGap() - lr.getAccRect().width;
}
}
protected void paintMenuItem(@NotNull final Graphics g, final JComponent c,
final Icon checkIcon, final Icon arrowIcon,
final Color background, final Color foreground,
final int defaultTextIconGap) {
// Save original graphics font and color
Font holdf = g.getFont();
Color holdc = g.getColor();
JMenuItem mi = (JMenuItem) c;
g.setFont(mi.getFont());
Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
DarkUIUtil.applyInsets(viewRect, mi.getInsets());
MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter,
mi.getComponentOrientation().isLeftToRight(), mi.getFont(),
acceleratorFont, MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix());
MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
paintBackground(g, mi, background);
paintCheckIcon(g, lh, lr, holdc, foreground);
paintIcon(g, lh, lr, holdc);
g.setColor(foreground);
paintText(g, lh, lr);
paintAccText(g, lh, lr);
paintArrowIcon(g, lh, lr, foreground);
// Restore original graphics font and color
g.setColor(holdc);
g.setFont(holdf);
}
@Override
protected void paintBackground(@NotNull final Graphics g, @NotNull final JMenuItem menuItem, final Color bgColor) {
protected void paintBackground(final Graphics g, final JMenuItem menuItem, final Color bgColor) {
ButtonModel model = menuItem.getModel();
Color oldColor = g.getColor();
int menuWidth = menuItem.getWidth();

173
src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java

@ -27,7 +27,6 @@ import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import com.github.weisj.darklaf.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import sun.swing.MenuItemLayoutHelper;
import sun.swing.SwingUtilities2;
@ -70,7 +69,51 @@ public class DarkMenuUI extends BasicMenuUI {
return menuItem.isEnabled() && ((JMenuItem) menuItem).isArmed();
}
protected void paintCheckIcon(final Graphics g, @NotNull final MenuItemLayoutHelper lh,
private static void rightAlignAccText(final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr) {
Rectangle accRect = lr.getAccRect();
ButtonModel model = lh.getMenuItem().getModel();
if (model.isEnabled()) {
accRect.x = lh.getViewRect().x + lh.getViewRect().width
- lh.getMenuItem().getIconTextGap() - lr.getAccRect().width;
}
}
protected void paintMenuItem(final Graphics g, final JComponent c,
final Icon checkIcon, final Icon arrowIcon,
final Color background, final Color foreground,
final int defaultTextIconGap) {
// Save original graphics font and color
Font holdf = g.getFont();
Color holdc = g.getColor();
JMenuItem mi = (JMenuItem) c;
g.setFont(mi.getFont());
Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
DarkUIUtil.applyInsets(viewRect, mi.getInsets());
MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter,
mi.getComponentOrientation().isLeftToRight(), mi.getFont(),
acceleratorFont, MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix());
MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
paintBackground(g, mi, background);
paintCheckIcon(g, lh, lr, holdc, foreground);
paintIcon(g, lh, lr, holdc);
g.setColor(foreground);
paintText(g, lh, lr);
paintAccText(g, lh, lr);
paintArrowIcon(g, lh, lr, foreground);
// Restore original graphics font and color
g.setColor(holdc);
g.setFont(holdf);
}
protected void paintCheckIcon(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr,
final Color holdc, final Color foreground) {
if (lh.getCheckIcon() != null) {
@ -89,45 +132,6 @@ public class DarkMenuUI extends BasicMenuUI {
}
}
protected void paintIcon(final Graphics g, @NotNull final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr, final Color holdc) {
if (lh.getIcon() != null) {
Icon icon;
ButtonModel model = lh.getMenuItem().getModel();
if (!model.isEnabled()) {
icon = lh.getMenuItem().getDisabledIcon();
} else if (model.isPressed() && model.isArmed()) {
icon = lh.getMenuItem().getPressedIcon();
if (icon == null) {
// Use default icon
icon = lh.getMenuItem().getIcon();
}
} else {
icon = lh.getMenuItem().getIcon();
}
if (icon != null) {
icon.paintIcon(lh.getMenuItem(), g, lr.getIconRect().x, lr.getIconRect().y);
g.setColor(holdc);
}
}
}
protected void paintText(final Graphics g, @NotNull final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
if (!StringUtil.isBlank(lh.getText())) {
if (lh.getHtmlView() != null) {
// Text is HTML
lh.getHtmlView().paint(g, lr.getTextRect());
} else {
// Text isn't HTML
paintText(g, lh.getMenuItem(), lr.getTextRect(), lh.getText());
}
}
config.restore();
}
protected void paintAccText(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
@ -169,7 +173,46 @@ public class DarkMenuUI extends BasicMenuUI {
config.restore();
}
protected void paintArrowIcon(final Graphics g, @NotNull final MenuItemLayoutHelper lh,
protected void paintIcon(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr, final Color holdc) {
if (lh.getIcon() != null) {
Icon icon;
ButtonModel model = lh.getMenuItem().getModel();
if (!model.isEnabled()) {
icon = lh.getMenuItem().getDisabledIcon();
} else if (model.isPressed() && model.isArmed()) {
icon = lh.getMenuItem().getPressedIcon();
if (icon == null) {
// Use default icon
icon = lh.getMenuItem().getIcon();
}
} else {
icon = lh.getMenuItem().getIcon();
}
if (icon != null) {
icon.paintIcon(lh.getMenuItem(), g, lr.getIconRect().x, lr.getIconRect().y);
g.setColor(holdc);
}
}
}
protected void paintText(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
if (!StringUtil.isBlank(lh.getText())) {
if (lh.getHtmlView() != null) {
// Text is HTML
lh.getHtmlView().paint(g, lr.getTextRect());
} else {
// Text isn't HTML
paintText(g, lh.getMenuItem(), lr.getTextRect(), lh.getText());
}
}
config.restore();
}
protected void paintArrowIcon(final Graphics g, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr,
final Color foreground) {
if (lh.getArrowIcon() != null) {
@ -185,52 +228,8 @@ public class DarkMenuUI extends BasicMenuUI {
}
}
private static void rightAlignAccText(@NotNull final MenuItemLayoutHelper lh,
@NotNull final MenuItemLayoutHelper.LayoutResult lr) {
Rectangle accRect = lr.getAccRect();
ButtonModel model = lh.getMenuItem().getModel();
if (model.isEnabled()) {
accRect.x = lh.getViewRect().x + lh.getViewRect().width
- lh.getMenuItem().getIconTextGap() - lr.getAccRect().width;
}
}
protected void paintMenuItem(@NotNull final Graphics g, final JComponent c,
final Icon checkIcon, final Icon arrowIcon,
final Color background, final Color foreground,
final int defaultTextIconGap) {
// Save original graphics font and color
Font holdf = g.getFont();
Color holdc = g.getColor();
JMenuItem mi = (JMenuItem) c;
g.setFont(mi.getFont());
Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
DarkUIUtil.applyInsets(viewRect, mi.getInsets());
MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter,
mi.getComponentOrientation().isLeftToRight(), mi.getFont(),
acceleratorFont, MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix());
MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
paintBackground(g, mi, background);
paintCheckIcon(g, lh, lr, holdc, foreground);
paintIcon(g, lh, lr, holdc);
g.setColor(foreground);
paintText(g, lh, lr);
paintAccText(g, lh, lr);
paintArrowIcon(g, lh, lr, foreground);
// Restore original graphics font and color
g.setColor(holdc);
g.setFont(holdf);
}
@Override
protected void paintBackground(@NotNull final Graphics g, @NotNull final JMenuItem menuItem, final Color bgColor) {
protected void paintBackground(final Graphics g, final JMenuItem menuItem, final Color bgColor) {
ButtonModel model = menuItem.getModel();
Color oldColor = g.getColor();
int menuWidth = menuItem.getWidth();

17
src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java

@ -30,8 +30,6 @@ import com.github.weisj.darklaf.components.text.NumberingPane;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@ -69,8 +67,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
protected int maxIconWidth = 0;
protected Color oldBackground;
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkNumberingPaneUI();
}
@ -149,7 +146,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
}
@Override
public void paint(final Graphics g, @NotNull final JComponent c) {
public void paint(final Graphics g, final JComponent c) {
if (c.isOpaque()) {
g.setColor(c.getBackground());
g.fillRect(0, 0, c.getWidth(), c.getHeight());
@ -185,7 +182,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
return new Dimension(maxIconWidth + pad + textWidth, viewport.getView().getHeight());
}
protected int drawHighlightBackground(@NotNull final Graphics g, final int currOffset) {
protected int drawHighlightBackground(final Graphics g, final int currOffset) {
g.setColor(backgroundHighlight);
Rectangle rect;
try {
@ -197,8 +194,8 @@ public class DarkNumberingPaneUI extends ComponentUI {
return rect.y;
}
protected void drawNumbering(@NotNull final Graphics g, final int startLine, final int endLine, final int yCur,
@NotNull final Element root, final int descent) {
protected void drawNumbering(final Graphics g, final int startLine, final int endLine, final int yCur,
final Element root, final int descent) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
g.setColor(numberingPane.getForeground());
int digits = String.valueOf(root.getElementCount()).length();
@ -214,7 +211,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
config.restore();
}
protected void paintIcons(final Graphics g, final int startLine, final int endLine, @NotNull final Element root) {
protected void paintIcons(final Graphics g, final int startLine, final int endLine, final Element root) {
List<Map.Entry<Position, Icon>> icons = numberingPane.getIconsInRange(root.getElement(startLine).getStartOffset(),
root.getElement(endLine).getEndOffset());
for (Map.Entry<Position, Icon> icon : icons) {
@ -323,7 +320,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
public void propertyChange(final PropertyChangeEvent evt) {
String key = evt.getPropertyName();
if ("caret".equals(key)) {
if (evt.getNewValue() instanceof Caret) {

4
src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneUI.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.ui.optionpane;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.DefaultLookup;
import javax.swing.*;
@ -36,8 +34,6 @@ import java.awt.*;
public class DarkOptionPaneUI extends BasicOptionPaneUI {
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent x) {
return new DarkOptionPaneUI();
}

6
src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.ui.panel;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicPanelUI;
@ -35,8 +32,7 @@ import javax.swing.plaf.basic.BasicPanelUI;
*/
public class DarkPanelUI extends BasicPanelUI {
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkPanelUI();
}

5
src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuBorder.java

@ -24,7 +24,6 @@
package com.github.weisj.darklaf.ui.popupmenu;
import com.github.weisj.darklaf.components.border.MutableLineBorder;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.InsetsUIResource;
@ -41,12 +40,12 @@ public class DarkPopupMenuBorder extends MutableLineBorder implements UIResource
}
@Override
public void paintBorder(final Component c, @NotNull final Graphics g, final int x, final int y, final int width, final int height) {
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
setColor(UIManager.getDefaults().getColor("PopupMenu.borderColor"));
super.paintBorder(c, g, x, y, width, height);
}
@NotNull
@Override
public Insets getBorderInsets(final Component c) {
return new InsetsUIResource(1, 1, 1, 1);

7
src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuSeparatorUI.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.ui.popupmenu;
import com.github.weisj.darklaf.ui.separator.DarkSeparatorUI;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
@ -36,15 +34,14 @@ import java.awt.*;
*/
public class DarkPopupMenuSeparatorUI extends DarkSeparatorUI {
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkPopupMenuSeparatorUI();
}
@Override
public void paint(@NotNull final Graphics g, @NotNull final JComponent c) {
public void paint(final Graphics g, final JComponent c) {
Dimension s = c.getSize();
g.setColor(UIManager.getDefaults().getColor("PopupMenu.borderColor"));
g.fillRect(0, 0, s.width, 1);

13
src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java

@ -24,8 +24,6 @@
package com.github.weisj.darklaf.ui.popupmenu;
import com.github.weisj.darklaf.util.ReflectionUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
@ -63,13 +61,12 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI {
public static final StringBuilder MOUSE_GRABBER_KEY = new StringBuilder(
"javax.swing.plaf.basic.BasicPopupMenuUI.MouseGrabber");
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent x) {
return new DarkPopupMenuUI();
}
@NotNull
static List<JPopupMenu> getPopups() {
MenuSelectionManager msm = MenuSelectionManager.defaultManager();
MenuElement[] p = msm.getSelectedPath();
@ -138,7 +135,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI {
}
}
void grabWindow(@NotNull final MenuElement[] newPath) {
void grabWindow(final MenuElement[] newPath) {
// A grab needs to be added
final Toolkit tk = Toolkit.getDefaultToolkit();
java.security.AccessController.doPrivileged(
@ -377,12 +374,12 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI {
protected static class StringBufferWrapper {
private final StringBuffer buffer;
@Contract(pure = true)
protected StringBufferWrapper(final StringBuffer buffer) {
this.buffer = buffer;
}
@Contract(value = "null -> false", pure = true)
@Override
public boolean equals(final Object obj) {
if (obj instanceof StringBuffer) {

78
src/main/java/com/github/weisj/darklaf/ui/progressbar/DarkProgressBarUI.java

@ -26,8 +26,6 @@ package com.github.weisj.darklaf.ui.progressbar;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
@ -59,8 +57,7 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha
private Color passedColor;
private Color passedEndColor;
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkProgressBarUI();
}
@ -99,7 +96,7 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha
}
@Override
protected void paintIndeterminate(@NotNull final Graphics g, @NotNull final JComponent c) {
protected void paintIndeterminate(final Graphics g, final JComponent c) {
Graphics2D g2 = (Graphics2D) g.create();
try {
@ -183,11 +180,11 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha
}
}
protected static boolean hasFailed(@NotNull final JComponent c) {
protected static boolean hasFailed(final JComponent c) {
return Boolean.TRUE.equals(c.getClientProperty("JProgressBar.failed"));
}
protected static boolean hasPassed(@NotNull final JComponent c) {
protected static boolean hasPassed(final JComponent c) {
return Boolean.TRUE.equals(c.getClientProperty("JProgressBar.passed"));
}
@ -199,14 +196,43 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha
return indeterminateEndColor;
}
@NotNull
@Contract("_, _, _, _, _ -> new")
private Shape getShapedRect(final float x, final float y, final float w, final float h, final float ar) {
return new RoundRectangle2D.Float(x, y, w, h, ar, ar);
}
private void paintString(final Graphics2D g, final int x, final int y,
final int w, final int h, final int fillStart, final int amountFull) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
String progressString = progressBar.getString();
g.setFont(progressBar.getFont());
Point renderLocation = getStringPlacement(g, progressString, x, y, w, h);
if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) {
g.setColor(getSelectionBackground());
g.drawString(progressString, renderLocation.x, renderLocation.y);
g.setColor(getSelectionForeground());
g.clipRect(fillStart, y, amountFull, h);
g.drawString(progressString, renderLocation.x, renderLocation.y);
} else { // VERTICAL
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2);
g.setFont(progressBar.getFont().deriveFont(rotate));
renderLocation = getStringPlacement(g, progressString, x, y, w, h);
g.setColor(getSelectionBackground());
g.drawString(progressString, renderLocation.x, renderLocation.y);
g.clipRect(x, fillStart, w, amountFull);
g.setColor(getSelectionForeground());
g.drawString(progressString, renderLocation.x, renderLocation.y);
}
config.restore();
}
@Override
protected void paintDeterminate(@NotNull final Graphics g, final JComponent c) {
protected void paintDeterminate(final Graphics g, final JComponent c) {
Graphics2D g2 = (Graphics2D) g.create();
try {
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
@ -275,36 +301,6 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha
}
}
private void paintString(@NotNull final Graphics2D g, final int x, final int y,
final int w, final int h, final int fillStart, final int amountFull) {
GraphicsContext config = GraphicsUtil.setupAntialiasing(g);
String progressString = progressBar.getString();
g.setFont(progressBar.getFont());
Point renderLocation = getStringPlacement(g, progressString, x, y, w, h);
if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) {
g.setColor(getSelectionBackground());
g.drawString(progressString, renderLocation.x, renderLocation.y);
g.setColor(getSelectionForeground());
g.clipRect(fillStart, y, amountFull, h);
g.drawString(progressString, renderLocation.x, renderLocation.y);
} else { // VERTICAL
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2);
g.setFont(progressBar.getFont().deriveFont(rotate));
renderLocation = getStringPlacement(g, progressString, x, y, w, h);
g.setColor(getSelectionBackground());
g.drawString(progressString, renderLocation.x, renderLocation.y);
g.clipRect(x, fillStart, w, amountFull);
g.setColor(getSelectionForeground());
g.drawString(progressString, renderLocation.x, renderLocation.y);
}
config.restore();
}
protected Color getRemainderColor() {
return trackColor;
}
@ -342,7 +338,7 @@ public class DarkProgressBarUI extends BasicProgressBarUI implements PropertyCha
}
}
@Contract(pure = true)
private static boolean isSimplified() {
return UIManager.getBoolean("ProgressBar.isSimplified");
}

11
src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java

@ -25,8 +25,6 @@ package com.github.weisj.darklaf.ui.radiobutton;
import com.github.weisj.darklaf.decorators.MouseClickListener;
import com.github.weisj.darklaf.ui.menu.DarkMenuItemUIBase;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.MenuItemLayoutHelper;
import javax.swing.*;
@ -48,8 +46,7 @@ public class DarkRadioButtonMenuItemUI extends DarkMenuItemUIBase {
private Icon radioSelectedDisabledIcon;
private Icon radioSelectedFocusedIcon;
@NotNull
@Contract(value = "_ -> new", pure = true)
public static ComponentUI createUI(final JComponent c) {
return new DarkRadioButtonMenuItemUI();
}
@ -64,14 +61,14 @@ public class DarkRadioButtonMenuItemUI extends DarkMenuItemUIBase {
}
@Override
protected void paintCheckIcon(final Graphics g2, @NotNull final MenuItemLayoutHelper lh,
@NotNull final MenuItemLayoutHelper.LayoutResult lr,
protected void paintCheckIcon(final Graphics g2, final MenuItemLayoutHelper lh,
final MenuItemLayoutHelper.LayoutResult lr,
final Color holdc, final Color foreground) {
Rectangle rect = lr.getCheckRect();
getRadioIcon(lh.getMenuItem()).paintIcon(lh.getMenuItem(), g2, rect.x, rect.y);
}
protected Icon getRadioIcon(@NotNull final AbstractButton b) {
protected Icon getRadioIcon(final AbstractButton b) {
boolean selected = b.isSelected();
boolean enabled = b.isEnabled();
boolean hasFocus = b.hasFocus();

21
src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonUI.java

@ -28,8 +28,6 @@ import com.github.weisj.darklaf.ui.checkbox.DarkCheckBoxUI;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import sun.swing.SwingUtilities2;
import javax.swing.*;
@ -74,8 +72,7 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha
private Icon radioSelectedDisabledIcon;
private Icon radioSelectedFocusedIcon;
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkRadioButtonUI();
}
@ -116,7 +113,7 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha
}
@Override
public synchronized void paint(final Graphics g2d, @NotNull final JComponent c) {
public synchronized void paint(final Graphics g2d, final JComponent c) {
Graphics2D g = (Graphics2D) g2d;
AbstractButton b = (AbstractButton) c;
@ -157,7 +154,7 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha
button.removePropertyChangeListener(this);
}
protected String layoutRadioButton(@NotNull final AbstractButton b, final FontMetrics fm) {
protected String layoutRadioButton(final AbstractButton b, final FontMetrics fm) {
Insets i = b.getInsets();
size = b.getSize(size);
viewRect.x = i.left;
@ -178,14 +175,14 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha
return text;
}
private void paintBackground(@NotNull final JComponent c, final Graphics2D g) {
private void paintBackground(final JComponent c, final Graphics2D g) {
if (c.isOpaque()) {
g.setColor(c.getBackground());
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
}
protected Icon getRadioIcon(@NotNull final AbstractButton b) {
protected Icon getRadioIcon(final AbstractButton b) {
boolean selected = b.isSelected();
boolean enabled = b.isEnabled();
boolean hasFocus = b.hasFocus();
@ -195,7 +192,7 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha
: radioDisabledIcon;
}
protected void paintDarkBullet(final JComponent c, final Graphics2D g, @NotNull final AbstractButton b) {
protected void paintDarkBullet(final JComponent c, final Graphics2D g, final AbstractButton b) {
GraphicsContext config = GraphicsUtil.setupStrokePainting(g);
boolean enabled = b.isEnabled();
g.translate(iconRect.x + ICON_OFF, iconRect.y + ICON_OFF);
@ -214,7 +211,7 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha
return new IconUIResource(EmptyIcon.create(20));
}
protected void paintCheckBorder(@NotNull final Graphics2D g, final boolean enabled, final boolean focus,
protected void paintCheckBorder(final Graphics2D g, final boolean enabled, final boolean focus,
final boolean selected) {
Graphics2D g2 = (Graphics2D) g.create();
Color bgColor = getFillColor(selected, enabled);
@ -233,7 +230,7 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha
g2.dispose();
}
protected void paintCheckBullet(@NotNull final Graphics2D g, final boolean enabled, final boolean focus) {
protected void paintCheckBullet(final Graphics2D g, final boolean enabled, final boolean focus) {
Color color = getCheckColor(focus, enabled);
g.setColor(color);
g.translate(0.2, 0.2);
@ -266,7 +263,7 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
public void propertyChange(final PropertyChangeEvent evt) {
String key = evt.getPropertyName();
if ("componentOrientation".equals(key)) {
radioButton.repaint();

3
src/main/java/com/github/weisj/darklaf/ui/rootpane/CloseButtonUI.java

@ -24,7 +24,6 @@
package com.github.weisj.darklaf.ui.rootpane;
import com.github.weisj.darklaf.ui.button.DarkButtonUI;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -45,7 +44,7 @@ public class CloseButtonUI extends DarkButtonUI {
}
@Override
protected Color getShadowColor(@NotNull final AbstractButton c) {
protected Color getShadowColor(final AbstractButton c) {
return c.getModel().isArmed() ? closeClick : closeHover;
}
}

10
src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java

@ -25,8 +25,6 @@
package com.github.weisj.darklaf.ui.rootpane;
import com.github.weisj.darklaf.platform.windows.JNIDecorations;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
@ -53,8 +51,6 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
private PropertyChangeListener propertyChangeListener;
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent comp) {
return new DarkRootPaneUI();
}
@ -159,7 +155,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
}
}
public void installBorder(@NotNull final JRootPane root) {
public void installBorder(final JRootPane root) {
int style = root.getWindowDecorationStyle();
if (style == JRootPane.NONE) {
LookAndFeel.uninstallBorder(root);
@ -172,7 +168,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
return new DarkTitlePane(root);
}
private void setTitlePane(@NotNull final JRootPane root, final DarkTitlePane titlePane) {
private void setTitlePane(final JRootPane root, final DarkTitlePane titlePane) {
JLayeredPane layeredPane = root.getLayeredPane();
JComponent oldTitlePane = getTitlePane();
@ -202,7 +198,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
root.setLayout(layoutManager);
}
@Contract(pure = true)
protected JComponent getTitlePane() {
return titlePane;
}

67
src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkTitlePane.java

@ -28,9 +28,6 @@ import com.github.weisj.darklaf.decorators.AncestorAdapter;
import com.github.weisj.darklaf.icons.ScaledIcon;
import com.github.weisj.darklaf.platform.windows.JNIDecorations;
import com.github.weisj.darklaf.util.Scale;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import sun.awt.SunToolkit;
import javax.accessibility.AccessibleContext;
@ -60,19 +57,23 @@ public class DarkTitlePane extends JComponent {
private static final int ICON_WIDTH = 32;
private static final int ICON_SIZE = ICON_WIDTH - 3 * PAD;
private final JRootPane rootPane;
private final ContainerListener rootPaneContainerListener = new ContainerListener() {
private final ContainerListener layeredPaneContainerListener = new ContainerListener() {
@Override
public void componentAdded(@NotNull final ContainerEvent e) {
if (e.getChild() instanceof JLayeredPane) {
((JLayeredPane) e.getChild()).addContainerListener(layeredPaneContainerListener);
public void componentAdded(final ContainerEvent e) {
if (e.getChild() instanceof JMenuBar) {
menuBar = getRootPane().getJMenuBar();
//Otherwise a white bar will appear where the menuBar used to be.
menuBar.setPreferredSize(new Dimension(0, 0));
add(menuBar);
}
if (getRootPane().getJMenuBar() == null && menuBar != null) {
remove(menuBar);
menuBar = null;
}
}
@Override
public void componentRemoved(@NotNull final ContainerEvent e) {
if (e.getChild() instanceof JLayeredPane) {
((JLayeredPane) e.getChild()).removeContainerListener(layeredPaneContainerListener);
}
public void componentRemoved(final ContainerEvent e) {
}
};
private boolean oldResizable;
@ -109,23 +110,19 @@ public class DarkTitlePane extends JComponent {
};
private long windowHandle;
private JMenuBar menuBar;
private final ContainerListener layeredPaneContainerListener = new ContainerListener() {
private final ContainerListener rootPaneContainerListener = new ContainerListener() {
@Override
public void componentAdded(@NotNull final ContainerEvent e) {
if (e.getChild() instanceof JMenuBar) {
menuBar = getRootPane().getJMenuBar();
//Otherwise a white bar will appear where the menuBar used to be.
menuBar.setPreferredSize(new Dimension(0, 0));
add(menuBar);
}
if (getRootPane().getJMenuBar() == null && menuBar != null) {
remove(menuBar);
menuBar = null;
public void componentAdded(final ContainerEvent e) {
if (e.getChild() instanceof JLayeredPane) {
((JLayeredPane) e.getChild()).addContainerListener(layeredPaneContainerListener);
}
}
@Override
public void componentRemoved(final ContainerEvent e) {
if (e.getChild() instanceof JLayeredPane) {
((JLayeredPane) e.getChild()).removeContainerListener(layeredPaneContainerListener);
}
}
};
private int state;
@ -148,12 +145,12 @@ public class DarkTitlePane extends JComponent {
setLayout(createLayout());
}
@NotNull
private static JButton createButton(final String accessibleName, final Icon icon, final Action action) {
return createButton(accessibleName, icon, action, false);
}
@NotNull
private static JButton createButton(final String accessibleName, final Icon icon, final Action action,
final boolean close) {
JButton button;
@ -241,14 +238,12 @@ public class DarkTitlePane extends JComponent {
addAncestorListener(ancestorListener);
}
@NotNull
@Contract(" -> new")
private WindowListener createWindowListener() {
return new DarkTitlePane.WindowHandler();
}
@NotNull
@Contract(value = " -> new", pure = true)
private PropertyChangeListener createWindowPropertyChangeListener() {
return new PropertyChangeHandler();
}
@ -328,7 +323,7 @@ public class DarkTitlePane extends JComponent {
return windowIconButton;
}
@NotNull
private JPopupMenu createMenu() {
JPopupMenu menu = new JPopupMenu();
if (getWindowDecorationStyle() == JRootPane.FRAME) {
@ -337,7 +332,7 @@ public class DarkTitlePane extends JComponent {
return menu;
}
private void addMenuItems(@NotNull final JPopupMenu menu) {
private void addMenuItems(final JPopupMenu menu) {
menu.add(new JMenuItem(restoreAction) {{
setDisabledIcon(restoreIcon);
}});
@ -362,7 +357,7 @@ public class DarkTitlePane extends JComponent {
}
}
@Contract(pure = true)
private Window getWindow() {
return window;
}
@ -409,8 +404,7 @@ public class DarkTitlePane extends JComponent {
}
}
@NotNull
@Contract(value = " -> new", pure = true)
private LayoutManager createLayout() {
return new TitlePaneLayout();
}
@ -461,8 +455,7 @@ public class DarkTitlePane extends JComponent {
return rootPane;
}
@Nullable
@Contract(pure = true)
private Frame getFrame() {
Window window = getWindow();
@ -543,7 +536,7 @@ public class DarkTitlePane extends JComponent {
}
}
protected boolean isResizable(final Window window, @NotNull final JRootPane rootPane) {
protected boolean isResizable(final Window window, final JRootPane rootPane) {
if (JRootPane.NONE == rootPane.getWindowDecorationStyle()) {
return false;
} else {
@ -747,7 +740,7 @@ public class DarkTitlePane extends JComponent {
}
protected class PropertyChangeHandler implements PropertyChangeListener {
public void propertyChange(@NotNull final PropertyChangeEvent pce) {
public void propertyChange(final PropertyChangeEvent pce) {
String name = pce.getPropertyName();
if ("resizable".equals(name) || "state".equals(name)) {
Frame frame = getFrame();

8
src/main/java/com/github/weisj/darklaf/ui/rootpane/SubstanceRootLayout.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.ui.rootpane;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@ -40,7 +38,7 @@ class SubstanceRootLayout implements LayoutManager2 {
public void removeLayoutComponent(final Component comp) {
}
public Dimension preferredLayoutSize(@NotNull final Container parent) {
public Dimension preferredLayoutSize(final Container parent) {
Dimension cpd, mbd, tpd;
int cpWidth = 0;
int cpHeight = 0;
@ -86,7 +84,7 @@ class SubstanceRootLayout implements LayoutManager2 {
cpHeight + mbHeight + tpHeight + i.top + i.bottom);
}
public Dimension minimumLayoutSize(@NotNull final Container parent) {
public Dimension minimumLayoutSize(final Container parent) {
Dimension cpd, mbd, tpd;
int cpWidth = 0;
int cpHeight = 0;
@ -174,7 +172,7 @@ class SubstanceRootLayout implements LayoutManager2 {
public void addLayoutComponent(final Component comp, final Object constraints) {
}
public Dimension maximumLayoutSize(@NotNull final Container target) {
public Dimension maximumLayoutSize(final Container target) {
Dimension cpd, mbd, tpd;
int cpWidth = Integer.MAX_VALUE;
int cpHeight = Integer.MAX_VALUE;

6
src/main/java/com/github/weisj/darklaf/ui/rootpane/TitlePaneIcon.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.ui.rootpane;
import org.jetbrains.annotations.Contract;
import javax.swing.*;
import java.awt.*;
@ -37,7 +35,7 @@ public class TitlePaneIcon implements Icon {
private final Icon inactiveIcon;
private boolean active = true;
@Contract(pure = true)
public TitlePaneIcon(final Icon active, final Icon inactive) {
this.activeIcon = active;
this.inactiveIcon = inactive;
@ -52,7 +50,7 @@ public class TitlePaneIcon implements Icon {
currentIcon().paintIcon(c, g, x, y);
}
@Contract(pure = true)
private Icon currentIcon() {
return active ? activeIcon : inactiveIcon;
}

49
src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java

@ -26,8 +26,6 @@ package com.github.weisj.darklaf.ui.scrollpane;
import com.github.weisj.darklaf.decorators.MouseMovementListener;
import com.github.weisj.darklaf.util.Animator;
import com.github.weisj.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@ -109,7 +107,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
};
private final AdjustmentListener adjustmentListener = new AdjustmentListener() {
@Override
public void adjustmentValueChanged(@NotNull final AdjustmentEvent e) {
public void adjustmentValueChanged(final AdjustmentEvent e) {
if (!e.getValueIsAdjusting()) return;
JScrollBar scrollBar = (JScrollBar) e.getAdjustable();
@ -130,7 +128,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
private final MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseReleased(@NotNull final MouseEvent e) {
public void mouseReleased(final MouseEvent e) {
if (!getTrackBounds().contains(e.getPoint())) {
mouseOverTrack = false;
resetTrackAnimator();
@ -166,15 +164,14 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
}
};
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkScrollBarUI();
}
@SuppressWarnings("MagicConstant")
public static void doScroll(@NotNull final JScrollBar toScroll, final JViewport vp,
@NotNull final MouseWheelEvent e, final boolean leftToRight) {
public static void doScroll(final JScrollBar toScroll, final JViewport vp,
final MouseWheelEvent e, final boolean leftToRight) {
int direction = e.getWheelRotation() < 0 ? -1 : 1;
int orientation = toScroll.getOrientation();
if (!leftToRight && orientation == JScrollBar.HORIZONTAL) {
@ -325,7 +322,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
}
}
static void scrollByBlock(@NotNull final JScrollBar scrollbar, final int direction) {
static void scrollByBlock(final JScrollBar scrollbar, final int direction) {
// This method is called from BasicScrollPaneUI to implement wheel
// scrolling, and also from scrollByBlock().
int oldValue = scrollbar.getValue();
@ -436,7 +433,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
return new EmptyButton();
}
protected void paintTrack(@NotNull final Graphics g, @NotNull final JComponent c, @NotNull final Rectangle bounds) {
protected void paintTrack(final Graphics g, final JComponent c, final Rectangle bounds) {
if (c.isOpaque()) {
g.setColor(scrollbar.getBackground());
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
@ -448,13 +445,13 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
g2.dispose();
}
protected void paintThumb(@NotNull final Graphics g, final JComponent c, @NotNull final Rectangle thumbBounds) {
protected void paintThumb(final Graphics g, final JComponent c, final Rectangle thumbBounds) {
if (!thumbBounds.isEmpty() && scrollbar.isEnabled()) {
paintMaxiThumb((Graphics2D) g, thumbBounds);
}
}
protected void paintMaxiThumb(@NotNull final Graphics2D g, @NotNull final Rectangle rect) {
protected void paintMaxiThumb(final Graphics2D g, final Rectangle rect) {
final Composite c = g.getComposite();
g.setComposite(COMPOSITE.derive(THUMB_ALPHA));
Color thumbColor = getThumbColor();
@ -466,7 +463,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
g.setComposite(c);
}
@NotNull
private Color getThumbColor() {
return DarkUIUtil.blendColors(thumbFadeEndColor, thumbFadeStartColor, thumbAlpha);
}
@ -492,8 +489,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
return true;
}
@NotNull
@Contract(value = " -> new", pure = true)
protected Color getTrackColor() {
return trackBackground;
}
@ -515,8 +511,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
return scrollbar.getClientProperty("ScrollBar.thin") == Boolean.TRUE;
}
@NotNull
@Contract(" -> new")
private Animator createTrackFadeoutAnimator() {
return new Animator("Track fadeout", FADEOUT_FRAMES_COUNT,
FADEOUT_FRAMES_COUNT * FADEOUT_FRAME_COUNT_FACTOR, false) {
@ -540,8 +535,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
};
}
@NotNull
@Contract(" -> new")
private Animator createThumbFadeoutAnimator() {
return new Animator("Adjustment fadeout", FADEOUT_FRAMES_COUNT,
FADEOUT_FRAMES_COUNT * FADEOUT_FRAME_COUNT_FACTOR, false) {
@ -566,8 +560,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
};
}
@NotNull
@Contract(" -> new")
private Animator createTrackFadeinAnimator() {
return new Animator("Track fadein", FADEIN_FRAMES_COUNT,
FADEIN_FRAMES_COUNT * FADEIN_FRAME_COUNT_FACTOR, false) {
@ -588,8 +581,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
};
}
@NotNull
@Contract(" -> new")
private Animator createThumbFadeinAnimator() {
return new Animator("Adjustment fadein", FADEIN_FRAMES_COUNT / 2,
FADEIN_FRAMES_COUNT * FADEIN_FRAME_COUNT_FACTOR, false) {
@ -621,7 +613,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
resetAnimators(thumbFadeinAnimator, thumbFadeoutAnimator, mouseOverThumb, thumbAlpha, MAX_THUMB_ALPHA);
}
private void resetAnimators(@NotNull final Animator fadeInAnimator, @NotNull final Animator fadeOutAnimator,
private void resetAnimators(final Animator fadeInAnimator, final Animator fadeOutAnimator,
final boolean overAnimatedComponent, final float currentAlpha, final float maxAlpha) {
fadeInAnimator.reset();
fadeOutAnimator.reset();
@ -654,22 +646,19 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
setRequestFocusEnabled(false);
}
@NotNull
@Contract(pure = true)
@Override
public Dimension getPreferredSize() {
return getMaximumSize();
}
@NotNull
@Contract(value = " -> new", pure = true)
@Override
public Dimension getMaximumSize() {
return new Dimension(0, 0);
}
@NotNull
@Contract(pure = true)
@Override
public Dimension getMinimumSize() {
return getMaximumSize();

6
src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.ui.scrollpane;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollPaneUI;
@ -96,8 +93,7 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI {
};
private ScrollPaneLayout oldLayout;
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkScrollPaneUI();
}

4
src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollLayoutManagerDelegate.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.ui.scrollpane;
import org.jetbrains.annotations.Contract;
import javax.swing.*;
import java.awt.*;
@ -34,7 +32,7 @@ import java.awt.*;
public class ScrollLayoutManagerDelegate extends ScrollPaneLayout {
private final ScrollPaneLayout delegate;
@Contract(pure = true)
public ScrollLayoutManagerDelegate(final ScrollPaneLayout delegate) {
if (delegate == null) {
throw new IllegalArgumentException("Delegate is null");

8
src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java

@ -23,9 +23,6 @@
*/
package com.github.weisj.darklaf.ui.separator;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSeparatorUI;
@ -36,13 +33,12 @@ import java.awt.*;
*/
public class DarkSeparatorUI extends BasicSeparatorUI {
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkSeparatorUI();
}
public void paint(final Graphics g, @NotNull final JComponent c) {
public void paint(final Graphics g, final JComponent c) {
Dimension s = c.getSize();
g.setColor(UIManager.getDefaults().getColor("Separator.foreground"));

91
src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java

@ -27,8 +27,6 @@ import com.github.weisj.darklaf.decorators.MouseClickListener;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
@ -102,8 +100,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
super(b);
}
@NotNull
@Contract("_ -> new")
public static ComponentUI createUI(final JComponent c) {
return new DarkSliderUI((JSlider) c);
}
@ -205,7 +202,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
}
@Override
public void paint(@NotNull final Graphics g2, final JComponent c) {
public void paint(final Graphics g2, final JComponent c) {
super.paint(g2, c);
if (showVolumeIcon(c)) {
getVolumeIcon().paintIcon(c, g2, iconRect.x, iconRect.y);
@ -326,7 +323,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
}
}
@NotNull
protected Color getDisabledTickColor() {
return inactiveTickForeground;
}
@ -364,8 +361,24 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
}
}
private static boolean isVolumeSlider(@NotNull final JComponent c) {
return "volume".equals(c.getClientProperty("Slider.variant"));
private Area getHorizontalSliderShape(final Area track) {
double x = thumbRect.x + thumbRect.width / 2.0;
Area leftArea = new Area(new Rectangle2D.Double(0, 0, x, slider.getHeight()));
Area rightArea = new Area(new Rectangle2D.Double(x, 0, slider.getWidth() - x, slider.getHeight()));
if (slider.getComponentOrientation().isLeftToRight()) {
if (slider.getInverted()) {
track.intersect(rightArea);
} else {
track.intersect(leftArea);
}
} else {
if (!slider.getInverted()) {
track.intersect(rightArea);
} else {
track.intersect(leftArea);
}
}
return track;
}
protected Icon getVolumeIcon() {
@ -390,8 +403,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
return slider.getOrientation() == JSlider.HORIZONTAL;
}
@NotNull
@Contract(" -> new")
private Area getHorizontalTrackShape() {
int arc = arcSize;
int yOff = (trackRect.height / 2) - trackSize / 2;
@ -405,30 +417,17 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
}
}
@Contract("_ -> param1")
@NotNull
private Area getHorizontalSliderShape(@NotNull final Area track) {
double x = thumbRect.x + thumbRect.width / 2.0;
Area leftArea = new Area(new Rectangle2D.Double(0, 0, x, slider.getHeight()));
Area rightArea = new Area(new Rectangle2D.Double(x, 0, slider.getWidth() - x, slider.getHeight()));
if (slider.getComponentOrientation().isLeftToRight()) {
private Area getVerticalSliderShape(final Area track) {
int y = thumbRect.y + thumbRect.height / 2;
if (slider.getInverted()) {
track.intersect(rightArea);
} else {
track.intersect(leftArea);
}
} else {
if (!slider.getInverted()) {
track.intersect(rightArea);
track.intersect(new Area(new Rectangle2D.Double(0, 0, slider.getWidth(), y)));
} else {
track.intersect(leftArea);
}
track.intersect(new Area(new Rectangle2D.Double(0, y, slider.getWidth(), slider.getHeight() - y)));
}
return track;
}
@NotNull
@Contract(" -> new")
private Area getVerticalTrackShape() {
int arc = arcSize;
int xOff = (trackRect.width / 2) - trackSize / 2;
@ -447,19 +446,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
return isPlainThumb() && showVolumeIcon(slider) ? ICON_BAR_EXT : 0;
}
@Contract("_ -> param1")
@NotNull
private Area getVerticalSliderShape(@NotNull final Area track) {
int y = thumbRect.y + thumbRect.height / 2;
if (slider.getInverted()) {
track.intersect(new Area(new Rectangle2D.Double(0, 0, slider.getWidth(), y)));
} else {
track.intersect(new Area(new Rectangle2D.Double(0, y, slider.getWidth(), slider.getHeight() - y)));
}
return track;
}
private void paintPlainSliderThumb(@NotNull final Graphics2D g) {
private void paintPlainSliderThumb(final Graphics2D g) {
int r = plainThumbRadius;
int x = isHorizontal() ? 4 : (thumbRect.width - r) / 2;
int y = isHorizontal() ? (thumbRect.height - r) / 2 : 4;
@ -481,6 +468,10 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
g.translate(-x, -y);
}
private static boolean isVolumeSlider(final JComponent c) {
return "volume".equals(c.getClientProperty("Slider.variant"));
}
private void paintSliderThumb(final Graphics2D g) {
Path2D thumb = getThumbShape();
if (paintFocus()) {
@ -511,7 +502,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
}
}
@NotNull
private Path2D getHorizontalThumbShape() {
int w = thumbRect.width;
int h = thumbRect.height;
@ -526,7 +517,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
return shape;
}
@NotNull
private Path2D getVerticalThumbShapeLR() {
int w = thumbRect.width;
int h = thumbRect.height;
@ -541,7 +532,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
return shape;
}
@NotNull
private Path2D getVerticalThumbShapeRL() {
int w = thumbRect.width;
int h = thumbRect.height;
@ -556,7 +547,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
return shape;
}
@NotNull
protected Color getThumbColor() {
if (isVolumeSlider(slider)) {
return slider.isEnabled() ? volumeThumbBackground : volumeThumbInactiveBackground;
@ -565,17 +556,17 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
}
}
@NotNull
protected Color getThumbBorderColor() {
return slider.isEnabled() ? thumbBorderColor : thumbInactiveBorderColor;
}
@NotNull
protected Color getTrackBackground() {
return trackBackground;
}
@NotNull
protected Color getSelectedTrackColor() {
if (isVolumeSlider(slider)) {
return slider.isEnabled() ? selectedVolumeTrackBackground : selectedVolumeTrackInactiveBackground;
@ -584,12 +575,12 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
}
}
private boolean instantScrollEnabled(@NotNull final JComponent c) {
private boolean instantScrollEnabled(final JComponent c) {
return Boolean.TRUE.equals(c.getClientProperty("Slider.instantScrollEnabled"));
}
@Override
public void propertyChange(@NotNull final PropertyChangeEvent evt) {
public void propertyChange(final PropertyChangeEvent evt) {
String key = evt.getPropertyName();
if ("Slider.variant".equals(key)) {
slider.repaint();

5
src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java

@ -25,7 +25,6 @@ package com.github.weisj.darklaf.ui.spinner;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
@ -54,7 +53,7 @@ public class DarkSpinnerBorder implements Border, UIResource {
}
@Override
public void paintBorder(@NotNull final Component c, final Graphics g2,
public void paintBorder(final Component c, final Graphics g2,
final int x, final int y, final int width, final int height) {
boolean tableCellEditor = DarkSpinnerUI.isTableCellEditor(c);
boolean treeCellEditor = !tableCellEditor && DarkSpinnerUI.isTreeCellEditor(c);
@ -109,7 +108,7 @@ public class DarkSpinnerBorder implements Border, UIResource {
config.restore();
}
protected Color getBorderColor(@NotNull final Component c) {
protected Color getBorderColor(final Component c) {
return c.isEnabled() ? borderColor : inactiveBorderColor;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save