Browse Source

Updated code style

- Keep simple if in one line.
- Wrap enum declarations if necessary.
pull/214/head
weisj 4 years ago
parent
commit
ae473cb7a1
  1. 3
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java
  2. 24
      core/src/main/java/com/github/weisj/darklaf/LafManager.java
  3. 3
      core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java
  4. 3
      core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java
  5. 6
      core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java
  6. 3
      core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java
  7. 3
      core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java
  8. 3
      core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java
  9. 3
      core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java
  10. 9
      core/src/main/java/com/github/weisj/darklaf/components/RotatableIconAnimator.java
  11. 18
      core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java
  12. 6
      core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java
  13. 15
      core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java
  14. 6
      core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java
  15. 15
      core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java
  16. 6
      core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTree.java
  17. 3
      core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeModel.java
  18. 30
      core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeNode.java
  19. 3
      core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTree.java
  20. 12
      core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTreeModel.java
  21. 3
      core/src/main/java/com/github/weisj/darklaf/components/loading/LoadingIndicator.java
  22. 21
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java
  23. 3
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java
  24. 9
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java
  25. 12
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java
  26. 3
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java
  27. 3
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java
  28. 9
      core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java
  29. 9
      core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java
  30. 6
      core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java
  31. 3
      core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java
  32. 24
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java
  33. 6
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java
  34. 3
      core/src/main/java/com/github/weisj/darklaf/components/tree/TristateTreeNode.java
  35. 6
      core/src/main/java/com/github/weisj/darklaf/components/treetable/JTreeTable.java
  36. 3
      core/src/main/java/com/github/weisj/darklaf/components/treetable/model/DefaultTreeTableModel.java
  37. 6
      core/src/main/java/com/github/weisj/darklaf/components/treetable/model/TreeTableNode.java
  38. 6
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java
  39. 3
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java
  40. 3
      core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java
  41. 9
      core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java
  42. 6
      core/src/main/java/com/github/weisj/darklaf/graphics/GraphicsUtil.java
  43. 6
      core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java
  44. 6
      core/src/main/java/com/github/weisj/darklaf/listener/UIUpdater.java
  45. 3
      core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java
  46. 3
      core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java
  47. 15
      core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java
  48. 24
      core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java
  49. 12
      core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java
  50. 24
      core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java
  51. 3
      core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java
  52. 15
      core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java
  53. 9
      core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java
  54. 15
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java
  55. 24
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  56. 6
      core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java
  57. 27
      core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java
  58. 18
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java
  59. 12
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java
  60. 3
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java
  61. 6
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java
  62. 6
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java
  63. 9
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java
  64. 6
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java
  65. 18
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java
  66. 3
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java
  67. 9
      core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java
  68. 3
      core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java
  69. 6
      core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java
  70. 3
      core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java
  71. 6
      core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java
  72. 6
      core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java
  73. 39
      core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java
  74. 18
      core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java
  75. 3
      core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java
  76. 3
      core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java
  77. 3
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java
  78. 3
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/EventHelperUtil.java
  79. 12
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java
  80. 6
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java
  81. 21
      core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java
  82. 6
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java
  83. 3
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java
  84. 24
      core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java
  85. 3
      core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java
  86. 6
      core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java
  87. 3
      core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java
  88. 18
      core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DividerStyle.java
  89. 3
      core/src/main/java/com/github/weisj/darklaf/ui/splitpane/ThinSplitPaneDivider.java
  90. 12
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java
  91. 6
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java
  92. 18
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java
  93. 24
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java
  94. 12
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java
  95. 3
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java
  96. 3
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java
  97. 12
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java
  98. 15
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java
  99. 18
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java
  100. 21
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java
  101. Some files were not shown because too many files have changed in this diff Show More

3
core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -129,8 +129,7 @@ public class DarkLaf extends ThemedLookAndFeel {
LafManager.setTheme(currentTheme);
}
for (DefaultsInitTask task : INIT_TASKS) {
if (task.onlyDuringInstallation() && !isInitialized)
continue;
if (task.onlyDuringInstallation() && !isInitialized) continue;
task.run(currentTheme, defaults);
}
return defaults;

24
core/src/main/java/com/github/weisj/darklaf/LafManager.java

@ -131,8 +131,7 @@ public final class LafManager {
*/
public static void enabledPreferenceChangeReporting(final boolean enabled) {
ThemePreferencesHandler.getSharedInstance().enablePreferenceChangeReporting(enabled);
if (ThemeSettings.isInitialized())
ThemeSettings.getInstance().setSystemPreferencesEnabled(enabled);
if (ThemeSettings.isInitialized()) ThemeSettings.getInstance().setSystemPreferencesEnabled(enabled);
}
/**
@ -208,8 +207,7 @@ public final class LafManager {
* @see PreferredThemeStyle
*/
public static ThemeProvider getThemeProvider() {
if (themeProvider == null)
themeProvider = createDefaultThemeProvider();
if (themeProvider == null) themeProvider = createDefaultThemeProvider();
return themeProvider;
}
@ -247,8 +245,7 @@ public final class LafManager {
* @param themes the themes to register.
*/
public static void registerTheme(final Theme... themes) {
if (themes == null)
return;
if (themes == null) return;
for (Theme theme : themes) {
registerTheme(theme);
}
@ -376,8 +373,7 @@ public final class LafManager {
eventSupport.dispatchEvent(new ThemeChangeEvent(old, theme), ThemeChangeListener::themeChanged);
LOGGER.fine(() -> "Setting theme to " + theme);
}
if (ThemeSettings.isInitialized())
ThemeSettings.getInstance().refresh();
if (ThemeSettings.isInitialized()) ThemeSettings.getInstance().refresh();
}
/**
@ -416,8 +412,7 @@ public final class LafManager {
* @param theme the theme to install.
*/
public static void installTheme(final Theme theme) {
if (theme == getTheme() && isInstalled())
return;
if (theme == getTheme() && isInstalled()) return;
setTheme(theme);
install();
}
@ -529,15 +524,12 @@ public final class LafManager {
* @return the closes match. NonNull.
*/
public static Theme getClosestMatchForTheme(final Theme theme) {
if (theme == null)
return themeForPreferredStyle(null);
if (theme == null) return themeForPreferredStyle(null);
for (Theme registered : getRegisteredThemes()) {
if (registered.equals(theme))
return registered;
if (registered.equals(theme)) return registered;
}
for (Theme registered : getRegisteredThemes()) {
if (registered.getThemeClass().equals(theme.getThemeClass()))
return registered;
if (registered.getThemeClass().equals(theme.getThemeClass())) return registered;
}
return themeForPreferredStyle(null);
}

3
core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java

@ -168,8 +168,7 @@ public class ClosableTabComponent extends JPanel {
int tabCount = tabComponent.pane.getTabCount();
for (int i = tabCount - 1; i >= 0; i--) {
Component tabComp = tabComponent.pane.getTabComponentAt(i);
if (tabComp == tabComponent)
continue;
if (tabComp == tabComponent) continue;
if (tabComp instanceof ClosableTabComponent && ((ClosableTabComponent) tabComp).isClosable()) {
tabComponent.pane.removeTabAt(i);
}

3
core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java

@ -85,8 +85,7 @@ public class ClosableTabbedPane extends JTabbedPane {
*/
public void setTabClosable(final int index, final boolean closable) {
ClosableTabComponent tab = getClosableTabComponent(index);
if (tab != null)
tab.setClosable(closable);
if (tab != null) tab.setClosable(closable);
}
/**

6
core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java

@ -145,8 +145,7 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
protected Point updateLocation() {
PointerInfo pointerInfo = MouseInfo.getPointerInfo();
if (pointerInfo == null)
return null;
if (pointerInfo == null) return null;
Point mouseLocation = pointerInfo.getLocation();
Window pickerWindow = getPickerWindow();
@ -170,8 +169,7 @@ public abstract class ColorPipetteBase implements ColorPipette, AWTEventListener
@Override
public void eventDispatched(final AWTEvent event) {
if (pickerWindow == null || !pickerWindow.isVisible())
return;
if (pickerWindow == null || !pickerWindow.isVisible()) return;
switch (event.getID()) {
case MouseEvent.MOUSE_PRESSED:
((MouseEvent) event).consume();

3
core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java

@ -82,8 +82,7 @@ public class ColoredRadioButton extends JRadioButton {
private void updateColorUI() {
ColoredRadioButtonUI ui = DarkUIUtil.getUIOfType(getUI(), ColoredRadioButtonUI.class);
if (ui != null)
ui.setColors(color, focusColor);
if (ui != null) ui.setColors(color, focusColor);
repaint();
}

3
core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java

@ -40,8 +40,7 @@ public class DefaultButton extends JButton {
@Override
public void addNotify() {
super.addNotify();
if (requestFocusOnDisplay)
requestFocusInWindow();
if (requestFocusOnDisplay) requestFocusInWindow();
SwingUtilities.getRootPane(this).setDefaultButton(this);
}
}

3
core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java

@ -126,8 +126,7 @@ public class DefaultColorPipette extends ColorPipetteBase {
Window pickerWindow = getPickerWindow();
if (pickerWindow != null && pickerWindow.isShowing()) {
Point mouseLoc = updateLocation();
if (mouseLoc == null)
return;
if (mouseLoc == null) return;
final Color c = getPixelColor(mouseLoc);
if (!c.equals(getColor()) || !mouseLoc.equals(previousLocation) || force) {
setColor(c);

3
core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java

@ -177,8 +177,7 @@ public class OverlayScrollPane extends JLayeredPane implements PropertyChangeLis
}
protected void updateScrollPaneUI() {
if (scrollPane == null)
return;
if (scrollPane == null) return;
scrollPane.setLayout(new ScrollLayoutManagerDelegate((ScrollPaneLayout) scrollPane.getLayout()) {
@Override

9
core/src/main/java/com/github/weisj/darklaf/components/RotatableIconAnimator.java

@ -42,8 +42,7 @@ public class RotatableIconAnimator extends Timer {
public RotatableIconAnimator(final int frames, final RotatableIcon icon, final JComponent parent) {
super(100, null);
if (icon == null)
throw new IllegalArgumentException("Icon is null");
if (icon == null) throw new IllegalArgumentException("Icon is null");
addActionListener(this::onAction);
setRepeats(true);
this.icon = icon;
@ -52,8 +51,7 @@ public class RotatableIconAnimator extends Timer {
}
public void resume() {
if (!isRunning())
start();
if (!isRunning()) start();
}
public void onAction(final ActionEvent e) {
@ -71,7 +69,6 @@ public class RotatableIconAnimator extends Timer {
}
public void suspend() {
if (isRunning())
stop();
if (isRunning()) stop();
}
}

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

@ -36,33 +36,27 @@ public final class DarkBorders {
public static Border createLineBorder(final int top, final int left, final int bottom, final int right) {
if (top == 0 && left == 0 && bottom == 0 && right == 0) {
if (sharedBorderEmpty == null)
sharedBorderEmpty = createDarkLineBorder(0, 0, 0, 0);
if (sharedBorderEmpty == null) sharedBorderEmpty = createDarkLineBorder(0, 0, 0, 0);
return sharedBorderEmpty;
}
if (top == 1 && left == 0 && bottom == 0 && right == 0) {
if (sharedBorderT == null)
sharedBorderT = createDarkLineBorder(1, 0, 0, 0);
if (sharedBorderT == null) sharedBorderT = createDarkLineBorder(1, 0, 0, 0);
return sharedBorderT;
}
if (top == 0 && left == 1 && bottom == 0 && right == 0) {
if (sharedBorderL == null)
sharedBorderL = createDarkLineBorder(0, 1, 0, 0);
if (sharedBorderL == null) sharedBorderL = createDarkLineBorder(0, 1, 0, 0);
return sharedBorderL;
}
if (top == 0 && left == 0 && bottom == 1 && right == 0) {
if (sharedBorderB == null)
sharedBorderB = createDarkLineBorder(0, 0, 1, 0);
if (sharedBorderB == null) sharedBorderB = createDarkLineBorder(0, 0, 1, 0);
return sharedBorderB;
}
if (top == 0 && left == 0 && bottom == 0 && right == 1) {
if (sharedBorderR == null)
sharedBorderR = createDarkLineBorder(0, 0, 0, 1);
if (sharedBorderR == null) sharedBorderR = createDarkLineBorder(0, 0, 0, 1);
return sharedBorderR;
}
if (top == 1 && left == 1 && bottom == 1 && right == 1) {
if (sharedBorderTLBR == null)
sharedBorderTLBR = createDarkLineBorder(1, 1, 1, 1);
if (sharedBorderTLBR == null) sharedBorderTLBR = createDarkLineBorder(1, 1, 1, 1);
return sharedBorderTLBR;
}
return createDarkLineBorder(top, left, bottom, right);

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

@ -197,8 +197,7 @@ public class DropShadowBorder implements Border, Serializable {
}
protected void drawImage(final Graphics g, final Image image, final Point p) {
if (p == null)
return;
if (p == null) return;
g.drawImage(image, p.x, p.y, null);
}
@ -377,8 +376,7 @@ public class DropShadowBorder implements Border, Serializable {
public DropShadowBorder setShadowColor(final Color shadowColor) {
this.shadowColor = shadowColor;
if (shadowColor == null)
this.shadowColor = Color.BLACK;
if (shadowColor == null) this.shadowColor = Color.BLACK;
return this;
}

15
core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java

@ -43,8 +43,7 @@ public class PopupColorChooser extends JToolTip {
protected static ToolTipContext context;
protected SmallColorChooser getChooser(final Color initial, final Consumer<Color> callback) {
if (chooser == null)
chooser = new SmallColorChooser(initial, callback);
if (chooser == null) chooser = new SmallColorChooser(initial, callback);
SmallColorChooser smallColorChooser = chooser;
if (chooser.getParent() != null) {
// Already in use. Create new one.
@ -56,8 +55,7 @@ public class PopupColorChooser extends JToolTip {
}
protected ToolTipContext getContext() {
if (context == null)
context = createToolTipContext();
if (context == null) context = createToolTipContext();
return context;
}
@ -106,8 +104,7 @@ public class PopupColorChooser extends JToolTip {
AWTEventListener listener = event -> {
if (event instanceof MouseEvent) {
int id = event.getID();
if (id != MouseEvent.MOUSE_CLICKED && id != MouseEvent.MOUSE_PRESSED)
return;
if (id != MouseEvent.MOUSE_CLICKED && id != MouseEvent.MOUSE_PRESSED) return;
}
boolean doClose = event instanceof FocusEvent && (!(DarkUIUtil.hasFocus(toolTip, (FocusEvent) event)
|| DarkUIUtil.hasFocus(toolTip) || DarkUIUtil.hasFocus(parent, (FocusEvent) event)));
@ -126,10 +123,8 @@ public class PopupColorChooser extends JToolTip {
close.set(e -> {
popup.hide();
Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
if (window != null)
window.removeComponentListener(windowListener);
if (onClose != null)
onClose.accept(e);
if (window != null) window.removeComponentListener(windowListener);
if (onClose != null) onClose.accept(e);
});
SwingUtilities.invokeLater(() -> {
window.addComponentListener(windowListener);

6
core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java

@ -83,8 +83,7 @@ public class QuickColorChooser extends JPanel {
final Supplier<Color> supplier, final Supplier<Boolean> activationCheck) {
AtomicBoolean isShowing = new AtomicBoolean(false);
component.addMouseListener((MouseClickListener) e -> {
if (!component.isEnabled() || isShowing.get() || !activationCheck.get())
return;
if (!component.isEnabled() || isShowing.get() || !activationCheck.get()) return;
isShowing.set(true);
PopupColorChooser.showColorChooser(component, supplier.get(), c -> {
if (c != null) {
@ -99,8 +98,7 @@ public class QuickColorChooser extends JPanel {
}
public void setSelected(final boolean selected) {
if (checkBox != null)
checkBox.setSelected(selected);
if (checkBox != null) checkBox.setSelected(selected);
}
public Color getColor() {

15
core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java

@ -94,8 +94,7 @@ public class SmallColorChooser extends JPanel {
colorTriangle.addListener((c, o) -> {
previewComponent.setColor(c);
for (DarkColorModel model : COLOR_MODELS) {
if (o != model)
updateMap.get(model).run();
if (o != model) updateMap.get(model).run();
}
if (o != hexField) {
hexField.setText(ColorUtil.toHex(c));
@ -117,14 +116,12 @@ public class SmallColorChooser extends JPanel {
}
protected void setColor(final Object source, final DarkColorModel model, final int... values) {
if (isValueChanging())
return;
if (isValueChanging()) return;
setValueChanging(true);
if (model != null) {
colorTriangle.setColorFromModel(source, model, values);
}
if (callback != null)
callback.accept(colorTriangle.getColor());
if (callback != null) callback.accept(colorTriangle.getColor());
setValueChanging(false);
}
@ -259,8 +256,7 @@ public class SmallColorChooser extends JPanel {
label.setValue(String.valueOf(slider.getValue()));
slider.addChangeListener(e -> {
if (isValueChanging())
return;
if (isValueChanging()) return;
int[] values = new int[count];
for (int j = 0; j < count; j++) {
values[j] = sliders[j].getValue();
@ -318,8 +314,7 @@ public class SmallColorChooser extends JPanel {
public void setValue(final String value) {
this.value = value;
if (this.value == null)
this.value = "";
if (this.value == null) this.value = "";
setText(before + ": " + value + after);
}
}

6
core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTree.java

@ -82,15 +82,13 @@ public class FileTree extends JTree {
public Path getSelectedFile() {
TreePath path = getSelectionPath();
if (path == null)
return null;
if (path == null) return null;
return ((FileTreeNode) path.getLastPathComponent()).getFile();
}
public List<Path> getSelectedFiles() {
TreePath[] paths = getSelectionPaths();
if (paths == null)
return Collections.emptyList();
if (paths == null) return Collections.emptyList();
return Arrays.stream(getSelectionPaths()).map(TreePath::getLastPathComponent).map(FileTreeNode.class::cast)
.map(FileTreeNode::getFile).collect(Collectors.toList());
}

3
core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeModel.java

@ -72,8 +72,7 @@ public class FileTreeModel extends DefaultTreeModel {
}
public void setShowHiddenFiles(final boolean showHiddenFiles) {
if (showHiddenFiles == this.showHiddenFiles)
return;
if (showHiddenFiles == this.showHiddenFiles) return;
this.showHiddenFiles = showHiddenFiles;
reload();
}

30
core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeNode.java

@ -50,10 +50,8 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
@Override
public boolean equals(final Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FileTreeNode that = (FileTreeNode) o;
return Objects.equals(file, that.file);
}
@ -69,8 +67,7 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
private int addSorted(final List<FileTreeNode> nodes, final FileTreeNode node) {
int index = Collections.binarySearch(nodes, node);
if (index < 0)
index = ~index;
if (index < 0) index = ~index;
nodes.add(index, node);
model.register(node);
return index;
@ -90,10 +87,8 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
}
protected void reload(final int depth) {
if (depth < 0)
return;
if (children.get() == null)
return;
if (depth < 0) return;
if (children.get() == null) return;
List<FileTreeNode> fileList = children.get();
this.<ReloadOp>doInBackground(pub -> {
taskCount.getAndIncrement();
@ -131,8 +126,7 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
}
}
}, () -> {
if (depth > 0)
fileList.forEach(n -> n.reload(depth - 1));
if (depth > 0) fileList.forEach(n -> n.reload(depth - 1));
taskCount.getAndDecrement();
});
}
@ -245,15 +239,13 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
}
public boolean isNodeChild(final TreeNode aNode) {
if (aNode == null)
return false;
if (aNode == null) return false;
return (aNode.getParent() == this);
}
@Override
public int compareTo(final FileTreeNode o) {
if (o == null)
return -1;
if (o == null) return -1;
boolean thisDir = Files.isDirectory(file);
boolean oDir = Files.isDirectory(o.file);
if (thisDir == oDir) {
@ -289,8 +281,7 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
@Override
protected void reload(final int depth) {
if (depth < 0)
return;
if (depth < 0) return;
List<FileTreeNode> nodes = children.get();
createInitialDirectories().forEach(p -> {
FileTreeNode node = model.createNode(this, p);
@ -307,8 +298,7 @@ public class FileTreeNode implements TreeNode, Comparable<FileTreeNode> {
return false;
});
if (depth > 0)
children.get().forEach(n -> n.reload(depth - 1));
if (depth > 0) children.get().forEach(n -> n.reload(depth - 1));
}
@Override

3
core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTree.java

@ -48,8 +48,7 @@ public class WatchFileTree extends FileTree {
@Override
public void setFileTreeModel(final FileTreeModel fileTreeModel) {
if (getModel() == fileTreeModel)
return;
if (getModel() == fileTreeModel) return;
if (getModel() instanceof WatchFileTreeModel) {
((WatchFileTreeModel) getModel()).stopWatching();
}

12
core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTreeModel.java

@ -101,8 +101,7 @@ public class WatchFileTreeModel extends FileTreeModel {
}
public void startWatching() {
if (watchTask != null)
return;
if (watchTask != null) return;
isScheduled.set(true);
watchTask = scheduler.schedule(this::watch, 0, TimeUnit.SECONDS);
}
@ -158,10 +157,8 @@ public class WatchFileTreeModel extends FileTreeModel {
protected void register(final FileTreeNode node) {
synchronized (getLock()) {
WatchService ws = getWatchService();
if (ws == null || !Files.isDirectory(node.file))
return;
if (getNodeMap().containsKey(node.file))
return;
if (ws == null || !Files.isDirectory(node.file)) return;
if (getNodeMap().containsKey(node.file)) return;
try {
LOGGER.finer(() -> "Register watch service for \"" + node.file + "\"");
node.watchKey = node.file.register(ws, StandardWatchEventKinds.ENTRY_CREATE,
@ -174,8 +171,7 @@ public class WatchFileTreeModel extends FileTreeModel {
protected void unregister(final FileTreeNode node) {
synchronized (getLock()) {
if (node.watchKey == null)
return;
if (node.watchKey == null) return;
LOGGER.finer(() -> "Unregister watch service for \"" + node.file + "\"");
getNodeMap().remove(node.file);
node.watchKey.cancel();

3
core/src/main/java/com/github/weisj/darklaf/components/loading/LoadingIndicator.java

@ -79,8 +79,7 @@ public class LoadingIndicator extends JLabel {
}
private void setAnimatorState(final boolean running) {
if (running == animator.isRunning())
return;
if (running == animator.isRunning()) return;
if (running) {
animator.resume();
} else {

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

@ -91,11 +91,9 @@ public class JTabFrame extends JComponent {
protected void updatePopupUIs() {
if (popupLists != null) {
for (List<TabFramePopup> list : popupLists) {
if (list == null)
continue;
if (list == null) continue;
for (TabFramePopup popup : list) {
if (popup == null)
continue;
if (popup == null) continue;
popup.updateContentUI();
}
}
@ -551,11 +549,9 @@ public class JTabFrame extends JComponent {
*/
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;
if (content.isEnabled(a) == enabled && oldIndex == index) return;
TabFrameTab compAtIndex = getTabComponentAt(a, index);
if (!compAtIndex.isEnabled())
return;
if (!compAtIndex.isEnabled()) return;
compAtIndex.setSelected(enabled);
notifySelectionChange(compAtIndex);
setPopupVisibility(compAtIndex, enabled);
@ -631,8 +627,7 @@ public class JTabFrame extends JComponent {
* @param c the popup to close.
*/
public void closeTab(final TabFramePopup c) {
if (c == null)
return;
if (c == null) return;
closeTab(c.getAlignment(), c.getIndex());
}
@ -664,8 +659,7 @@ public class JTabFrame extends JComponent {
* @param c the popup to open.
*/
public void openTab(final TabFramePopup c) {
if (c == null)
return;
if (c == null) return;
openTab(c.getAlignment(), c.getIndex());
}
@ -924,8 +918,7 @@ public class JTabFrame extends JComponent {
* @return true if selected.
*/
public boolean isSelected(final Alignment a, final int index) {
if (a == null)
return false;
if (a == null) return false;
return selectedIndices[a.ordinal()] == index;
}

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

@ -181,8 +181,7 @@ public class TabFrameContentPane extends JPanel implements TabFrameContent {
* @param force whether to force the layout process.
*/
public void setEnabled(final Alignment a, final boolean enabled, final boolean force) {
if (enabled == isEnabled(a) && !force)
return;
if (enabled == isEnabled(a) && !force) return;
switch (a) {
case NORTH:
changeStatus(enabled, Alignment.NORTH_EAST, topSplit, topSplitter,

9
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java

@ -106,8 +106,7 @@ public class TabFrameTabContainer extends JPanel implements TabFrameTab {
@Override
public void setOrientation(final Alignment a) {
if (this.orientation == a)
return;
if (this.orientation == a) return;
Alignment oldOrientation = this.orientation;
this.orientation = a;
firePropertyChange(KEY_ORIENTATION, oldOrientation, orientation);
@ -120,8 +119,7 @@ public class TabFrameTabContainer extends JPanel implements TabFrameTab {
@Override
public void setSelected(final boolean selected) {
if (selected == this.selected)
return;
if (selected == this.selected) return;
boolean oldSelected = this.selected;
this.selected = selected;
firePropertyChange(KEY_SELECTED, oldSelected, selected);
@ -134,8 +132,7 @@ public class TabFrameTabContainer extends JPanel implements TabFrameTab {
@Override
public void setAccelerator(final int accelerator) {
if (this.accelerator == accelerator)
return;
if (this.accelerator == accelerator) return;
int oldAccelerator = this.accelerator;
this.accelerator = accelerator;
firePropertyChange(KEY_ACCELERATOR, oldAccelerator, accelerator);

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

@ -103,8 +103,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
@Override
public void setOrientation(final Alignment a) {
if (this.orientation == a)
return;
if (this.orientation == a) return;
Alignment oldOrientation = this.orientation;
this.orientation = a;
firePropertyChange(KEY_ORIENTATION, oldOrientation, orientation);
@ -117,8 +116,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
@Override
public void setSelected(final boolean selected) {
if (selected == this.selected)
return;
if (selected == this.selected) return;
boolean oldSelected = this.selected;
this.selected = selected;
firePropertyChange(KEY_SELECTED, oldSelected, selected);
@ -131,8 +129,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
@Override
public void setAccelerator(final int accelerator) {
if (this.accelerator == accelerator)
return;
if (this.accelerator == accelerator) return;
int oldAccelerator = this.accelerator;
this.accelerator = accelerator;
firePropertyChange(KEY_ACCELERATOR, oldAccelerator, accelerator);
@ -166,8 +163,7 @@ public class TabFrameTabLabel extends JLabel implements TabFrameTab {
* @param title the title
*/
public void setTitle(final String title) {
if (Objects.equals(title, this.title))
return;
if (Objects.equals(title, this.title)) return;
String oldTitle = this.title;
this.title = title;
firePropertyChange(KEY_TITLE, oldTitle, selected);

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

@ -138,8 +138,7 @@ public class TabbedPopup extends PanelPopup {
* @param component the component to add.
*/
public void setContentPane(final Component component) {
if (component == null)
return;
if (component == null) return;
if (getContentPanes().contains(component)) {
return;
}

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

@ -146,8 +146,7 @@ public class ToggleSplitPane extends JSplitPane {
@Override
public void setDividerLocation(final int location) {
if (isInLayout)
return;
if (isInLayout) return;
isInLayout = true;
if (resizable) {
super.setDividerLocation(location);

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

@ -85,16 +85,13 @@ public class LineHighlighter implements Highlighter.HighlightPainter, ChangeList
private void resetHighlight() {
// Use invokeLater to make sure updates to the Document are completed,
// otherwise Undo processing causes the modelToView method to loop.
if (component == null)
return;
if (component == null) return;
SwingUtilities.invokeLater(() -> {
try {
if (component == null)
return;
if (component == null) return;
int offset = component.getCaretPosition();
Rectangle view = component.modelToView(offset);
if (view == null)
return;
if (view == null) return;
Rectangle currentView = view.getBounds();
// Remove the highlighting from the previously highlighted line

9
core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java

@ -101,8 +101,7 @@ public class NumberingPane extends JComponent {
}
public void addIconListener(final int offset, final IconListener listener) throws BadLocationException {
if (textComponent == null)
return;
if (textComponent == null) return;
addIconListener(textComponent.getDocument().createPosition(offset), listener);
}
@ -117,8 +116,7 @@ public class NumberingPane extends JComponent {
}
public void removeIconListener(final int offset, final IconListener listener) throws BadLocationException {
if (textComponent == null)
return;
if (textComponent == null) return;
removeIconListener(textComponent.getDocument().createPosition(offset), listener);
}
@ -138,8 +136,7 @@ public class NumberingPane extends JComponent {
}
public List<IconListener> getIconListeners(final int offset) throws BadLocationException {
if (textComponent == null)
return new ArrayList<>();
if (textComponent == null) return new ArrayList<>();
return getIconListeners(textComponent.getDocument().createPosition(offset));
}

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

@ -84,8 +84,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
* @throws IllegalArgumentException if capacity is negative
*/
public void setCapacity(final int capacity) throws IllegalArgumentException {
if (capacity < 0)
throw new IllegalArgumentException("Negative history size is not supported");
if (capacity < 0) throw new IllegalArgumentException("Negative history size is not supported");
this.capacity = capacity;
}
@ -122,8 +121,7 @@ public class TextFieldHistoryPopup extends ScrollPopupMenu implements SearchList
@Override
public void show(final Component invoker, final int x, final int y) {
if (history.size() == 0)
return;
if (history.size() == 0) return;
super.show(invoker, x, y);
}

3
core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java

@ -64,8 +64,7 @@ public class JToggleButtonList extends JList<JToggleButton> {
@Override
public void actionPerformed(final ActionEvent e) {
int leadIndex = getSelectionModel().getLeadSelectionIndex();
if (leadIndex >= 0)
setSelected(leadIndex, !JToggleButtonList.this.isSelected(leadIndex));
if (leadIndex >= 0) setSelected(leadIndex, !JToggleButtonList.this.isSelected(leadIndex));
}
});
super.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

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

@ -42,8 +42,7 @@ public class ToolTipContext {
private static ToolTipContext defaultContext;
public static ToolTipContext getDefaultContext() {
if (defaultContext == null)
defaultContext = createDefaultContext();
if (defaultContext == null) defaultContext = createDefaultContext();
return defaultContext;
}
@ -66,14 +65,12 @@ public class ToolTipContext {
@Override
public void mouseMoved(final MouseEvent e) {
if (hotSpotArea == null)
return;
if (hotSpotArea == null) return;
checkExit(e);
}
private void checkExit(final MouseEvent e) {
if (!hideOnExit)
return;
if (!hideOnExit) return;
if (hotSpotArea != null) {
if (!hotSpotArea.contains(e.getPoint())) {
ToolTipManager.sharedInstance().mousePressed(null);
@ -466,8 +463,7 @@ public class ToolTipContext {
*/
public Point getToolTipLocation(final Point mp, final MouseEvent mouseEvent, final boolean centerHorizontally,
final boolean centerVertically) {
if (target == null)
return null;
if (target == null) return null;
updateToolTip();
MouseEvent event = processEvent(mouseEvent, mp);
Rectangle rect = getTargetRect(event, centerHorizontally, centerVertically);
@ -515,8 +511,7 @@ public class ToolTipContext {
}
private MouseEvent processEvent(final MouseEvent mouseEvent, final Point mp) {
if (mouseEvent != null)
return mouseEvent;
if (mouseEvent != null) return mouseEvent;
return new MouseEvent(target, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, mp.x, mp.y, 0, false, 0);
}
@ -542,8 +537,7 @@ public class ToolTipContext {
}
public void updateToolTipUI() {
if (toolTip != null)
toolTip.updateUI();
if (toolTip != null) toolTip.updateUI();
}
private Dimension getContentSize() {
@ -615,8 +609,7 @@ public class ToolTipContext {
}
public void setToolTip(final JToolTip toolTip) {
if (toolTip == null)
return;
if (toolTip == null) return;
this.toolTip = toolTip;
if (this.target != toolTip.getComponent()) {
this.toolTip.setComponent(this.target);
@ -629,8 +622,7 @@ public class ToolTipContext {
public ToolTipContext setFallBackPositionProvider(final Function<ToolTipContext, Point> fallBackPositionProvider) {
this.fallBackPositionProvider = fallBackPositionProvider;
if (fallBackPositionProvider == null)
this.fallBackPositionProvider = c -> null;
if (fallBackPositionProvider == null) this.fallBackPositionProvider = c -> null;
return this;
}
}

6
core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java

@ -35,10 +35,8 @@ public enum ToolTipStyle implements ToolTipConstants {
}
public static ToolTipStyle parse(final Object style) {
if (style instanceof ToolTipStyle)
return (ToolTipStyle) style;
if (style == null)
return null;
if (style instanceof ToolTipStyle) return (ToolTipStyle) style;
if (style == null) return null;
String name = style.toString();
if (VARIANT_PLAIN_BALLOON.equalsIgnoreCase(name) || ToolTipStyle.PLAIN_BALLOON.name().equalsIgnoreCase(name)) {
return ToolTipStyle.PLAIN_BALLOON;

3
core/src/main/java/com/github/weisj/darklaf/components/tree/TristateTreeNode.java

@ -112,8 +112,7 @@ public class TristateTreeNode extends DefaultMutableTreeNode implements LabeledT
for (Object node : children) {
if (node instanceof TristateTreeNode) {
TristateState nodeState = ((TristateTreeNode) node).getUserObject();
if (state == null)
state = nodeState;
if (state == null) state = nodeState;
if (state != nodeState) {
state = TristateState.INDETERMINATE_SEL;
break;

6
core/src/main/java/com/github/weisj/darklaf/components/treetable/JTreeTable.java

@ -73,8 +73,7 @@ public class JTreeTable extends JTable implements TreeSelectionListener {
DarkTreeUI ui = DarkUIUtil.getUIOfType(tree.getUI(), DarkTreeUI.class);
if (ui != null) {
CellHintPopupListener<JTree, ?> listener = ui.getPopupListener();
if (listener != null)
listener.repaint();
if (listener != null) listener.repaint();
}
});
}
@ -93,8 +92,7 @@ public class JTreeTable extends JTable implements TreeSelectionListener {
tree.processEvent(e);
}
}
if (((InputEvent) e).isConsumed())
return;
if (((InputEvent) e).isConsumed()) return;
}
super.processEvent(e);
}

3
core/src/main/java/com/github/weisj/darklaf/components/treetable/model/DefaultTreeTableModel.java

@ -61,8 +61,7 @@ public class DefaultTreeTableModel extends AbstractTreeTableModel {
@Override
public Object getValueAt(final Object node, final int column) {
TreeTableNode treeTableNode = DarkUIUtil.nullableCast(TreeTableNode.class, node);
if (treeTableNode == null)
return null;
if (treeTableNode == null) return null;
return treeTableNode.getValueAt(column);
}

6
core/src/main/java/com/github/weisj/darklaf/components/treetable/model/TreeTableNode.java

@ -41,8 +41,7 @@ public interface TreeTableNode extends TreeNode {
@Override
default int getIndex(final TreeNode node) {
if (!(node instanceof TreeTableNode))
return -1;
if (!(node instanceof TreeTableNode)) return -1;
return getIndex((TreeTableNode) node);
}
@ -57,8 +56,7 @@ public interface TreeTableNode extends TreeNode {
@Override
default TreeTableNode getChildAt(final int index) {
if (index < 0 || index >= getChildCount())
return null;
if (index < 0 || index >= getChildCount()) return null;
return getChildren().get(index);
}

6
core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java

@ -42,8 +42,7 @@ public class TristateButtonModel extends JToggleButton.ToggleButtonModel {
}
public void setIndeterminate() {
if (!allowsIndeterminate || isIndeterminate())
return;
if (!allowsIndeterminate || isIndeterminate()) return;
setState(isSelected() ? TristateState.INDETERMINATE_DES : TristateState.INDETERMINATE_SEL);
}
@ -79,8 +78,7 @@ public class TristateButtonModel extends JToggleButton.ToggleButtonModel {
}
public void setState(final TristateState state) {
if (this.state == state)
return;
if (this.state == state) return;
if (!allowsIndeterminate && state.isIndeterminate()) {
return;
}

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

@ -47,8 +47,7 @@ public class TristateCheckBox extends JCheckBox {
}
private void iterateState() {
if (!getModel().isEnabled())
return;
if (!getModel().isEnabled()) return;
getTristateModel().iterateState();
}

3
core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java

@ -115,8 +115,7 @@ public class TristateCheckBoxMenuItem extends JCheckBoxMenuItem {
}
private void iterateState() {
if (!getModel().isEnabled())
return;
if (!getModel().isEnabled()) return;
grabFocus();
getTristateModel().iterateState();

9
core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java

@ -65,8 +65,7 @@ public abstract class Animator {
public void reset() {
currentFrame %= totalFrames;
if (!forward)
currentFrame = totalFrames - currentFrame;
if (!forward) currentFrame = totalFrames - currentFrame;
}
private static ScheduledExecutorService createScheduler() {
@ -139,8 +138,7 @@ public abstract class Animator {
}
private void onTick() {
if (isDisposed() || ticker == null)
return;
if (isDisposed() || ticker == null) return;
if (startTime == -1) {
startTime = System.currentTimeMillis();
@ -151,8 +149,7 @@ public abstract class Animator {
final double totalTime = stopTime - startTime;
final int newFrame = (int) (passedTime * totalFrames / totalTime) + startFrame;
if (currentFrame > 0 && newFrame == currentFrame)
return;
if (currentFrame > 0 && newFrame == currentFrame) return;
currentFrame = newFrame;
if (currentFrame >= totalFrames) {

6
core/src/main/java/com/github/weisj/darklaf/graphics/GraphicsUtil.java

@ -41,13 +41,11 @@ public final class GraphicsUtil {
private GraphicsUtil() {}
public static void setOpaqueBuffered(final JComponent c, final boolean opaqueBuffered) {
if (c != null)
c.putClientProperty(KEY_OPAQUE_BUFFERED, opaqueBuffered);
if (c != null) c.putClientProperty(KEY_OPAQUE_BUFFERED, opaqueBuffered);
}
public static boolean isOpaqueBuffered(final JComponent c) {
if (!SystemInfo.isWindows)
return false;
if (!SystemInfo.isWindows) return false;
return PropertyUtil.getBooleanProperty(c, KEY_OPAQUE_BUFFERED);
}

6
core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java

@ -103,8 +103,7 @@ public class StringPainter {
public static <T extends JComponent> void drawStringImpl(final Graphics g, final T c, final View view,
final String text, final Rectangle textRect, final Font font, final FontMetrics fm, final int mnemIndex,
final Color background) {
if (text == null || text.equals(""))
return;
if (text == null || text.equals("")) return;
GraphicsContext context = GraphicsUtil.setupAntialiasing(g);
@ -212,8 +211,7 @@ public class StringPainter {
try {
Field surfaceField = graphics2D.getClass().getField("surfaceData");
Object surfaceDataValue = surfaceField.get(graphics2D);
if (surfaceDataValue == null)
return null;
if (surfaceDataValue == null) return null;
Field imgField;
try {

6
core/src/main/java/com/github/weisj/darklaf/listener/UIUpdater.java

@ -45,8 +45,7 @@ public class UIUpdater implements ThemeChangeListener {
* @param component the component.
*/
public static void registerComponent(final JComponent component) {
if (component == null)
return;
if (component == null) return;
removeComponent(component);
UIUpdater updater = new UIUpdater(component);
component.putClientProperty(KEY_UPDATER, updater);
@ -90,7 +89,6 @@ public class UIUpdater implements ThemeChangeListener {
@Override
public void themeInstalled(final ThemeChangeEvent e) {
if (component != null)
SwingUtilities.updateComponentTreeUI(component);
if (component != null) SwingUtilities.updateComponentTreeUI(component);
}
}

3
core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java

@ -43,8 +43,7 @@ public class DecorationsHandler {
private boolean decorationsEnabled = true;
public static DecorationsHandler getSharedInstance() {
if (sharedInstance == null)
setSharedInstance(new DecorationsHandler());
if (sharedInstance == null) setSharedInstance(new DecorationsHandler());
return sharedInstance;
}

3
core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java

@ -44,8 +44,7 @@ public class ThemePreferencesHandler {
private ThemePreferenceProvider preferenceProvider;
public static ThemePreferencesHandler getSharedInstance() {
if (sharedInstance == null)
setSharedInstance(new ThemePreferencesHandler());
if (sharedInstance == null) setSharedInstance(new ThemePreferencesHandler());
return sharedInstance;
}

15
core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java

@ -432,8 +432,7 @@ public class ThemeSettings implements ThemePreferenceListener {
private Theme getEffectiveTheme(final PreferredThemeStyle themeStyle) {
Theme baseTheme = getEffectiveBaseTheme(themeStyle);
if (baseTheme == null)
return null;
if (baseTheme == null) return null;
FontSizeRule fontSizeRule = getEffectiveFontSizeRule(baseTheme, themeStyle);
AccentColorRule accentColorRule = getEffectiveAccentColorRule(baseTheme);
return baseTheme.derive(fontSizeRule, accentColorRule);
@ -444,14 +443,12 @@ public class ThemeSettings implements ThemePreferenceListener {
}
private FontSizeRule getEffectiveFontSizeRule(final Theme theme, final PreferredThemeStyle preferredThemeStyle) {
if (theme == null)
return FontSizeRule.getDefault();
if (theme == null) return FontSizeRule.getDefault();
return isFontSizeFollowsSystem() ? preferredThemeStyle.getFontSizeRule() : getFontSizeRule();
}
private AccentColorRule getEffectiveAccentColorRule(final Theme theme) {
if (theme == null)
return AccentColorRule.getDefault();
if (theme == null) return AccentColorRule.getDefault();
return currentConfiguration.getAccentColorRule();
}
@ -466,10 +463,8 @@ public class ThemeSettings implements ThemePreferenceListener {
}
protected void applyTheme(final Theme theme) {
if (theme == null)
return;
if (LafManager.getTheme().appearsEqualTo(theme))
return;
if (theme == null) return;
if (LafManager.getTheme().appearsEqualTo(theme)) return;
SwingUtilities.invokeLater(() -> {
LafManager.installTheme(theme);
refresh();

24
core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java

@ -126,8 +126,7 @@ public class ThemeSettingsPanel extends JPanel {
boolean selected = Objects.equals(radioButton.getColor(), currentColor)
|| (radioButton == defaultButton && Objects.equals(defaultColor, currentColor));
bg.setSelected(radioButton.getModel(), selected);
if (selected)
return true;
if (selected) return true;
}
return false;
}
@ -257,8 +256,7 @@ public class ThemeSettingsPanel extends JPanel {
}
if (!updateButtonGroup(bg, color, defaultButton, defaultColor)) {
customButton.setSelected(true);
if (customButton.getColor() == null)
customButton.setColor(color);
if (customButton.getColor() == null) customButton.setColor(color);
}
}
@ -371,14 +369,10 @@ public class ThemeSettingsPanel extends JPanel {
if (!enabledSystemPreferences.getTristateModel().isIndeterminate()) {
boolean selected = enabledSystemPreferences.getTristateModel().isSelected();
if (themeFollowsSystem.isEnabled())
themeFollowsSystem.setSelected(selected);
if (accentColorFollowsSystem.isEnabled())
accentColorFollowsSystem.setSelected(selected);
if (selectionColorFollowsSystem.isEnabled())
selectionColorFollowsSystem.setSelected(selected);
if (fontSizeFollowsSystem.isEnabled())
fontSizeFollowsSystem.setSelected(selected);
if (themeFollowsSystem.isEnabled()) themeFollowsSystem.setSelected(selected);
if (accentColorFollowsSystem.isEnabled()) accentColorFollowsSystem.setSelected(selected);
if (selectionColorFollowsSystem.isEnabled()) selectionColorFollowsSystem.setSelected(selected);
if (fontSizeFollowsSystem.isEnabled()) fontSizeFollowsSystem.setSelected(selected);
}
update();
});
@ -564,8 +558,7 @@ public class ThemeSettingsPanel extends JPanel {
}
private AccentColorRule getAccentColorRule(final Theme theme) {
if (theme == null)
return AccentColorRule.getDefault();
if (theme == null) return AccentColorRule.getDefault();
Color accentColor = getAccentColor(theme, isAccentColorFollowsSystem());
Color selectionColor = getSelectionColor(theme, isSelectionColorFollowsSystem());
return AccentColorRule.fromColor(accentColor, selectionColor);
@ -592,8 +585,7 @@ public class ThemeSettingsPanel extends JPanel {
}
private FontSizeRule getFontSizeRule(final Theme theme, final PreferredThemeStyle preferredThemeStyle) {
if (theme == null)
return FontSizeRule.getDefault();
if (theme == null) return FontSizeRule.getDefault();
return isFontSizeFollowsSystem() ? preferredThemeStyle.getFontSizeRule()
: FontSizeRule.relativeAdjustment(fontSlider.getValue()); // Todo
}

12
core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java

@ -56,8 +56,7 @@ public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
return;
}
Properties props = currentTheme.loadAccentProperties();
if (props == null || props.isEmpty())
return;
if (props == null || props.isEmpty()) return;
if (accentColor != null) {
adjustColors(MAIN_ACCENT_LIST_KEY, accentColor, props, properties);
}
@ -78,8 +77,7 @@ public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
ColorInfo info = new ColorInfo();
for (Object o : list) {
setColorInfo(o, info);
if (info.key == null)
continue;
if (info.key == null) continue;
Object c = mapColor(info, hsb, properties);
if (c instanceof Color) {
properties.put(info.key, c);
@ -99,10 +97,8 @@ public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
if (o instanceof Pair<?, ?>) {
Object first = ((Pair<?, ?>) o).getFirst();
Object second = ((Pair<?, ?>) o).getSecond();
if (!(first instanceof String))
return;
if (!(second instanceof List<?>))
return;
if (!(first instanceof String)) return;
if (!(second instanceof List<?>)) return;
String key = first.toString();
List<?> list = (List<?>) second;
if (list.size() != 3 || !(list.get(0) instanceof Integer) || !(list.get(1) instanceof Integer)

24
core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java

@ -103,10 +103,8 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
}
private boolean systemKerningEnabled() {
if (SystemInfo.isMac)
return SystemInfo.isMacOSMojave;
if (SystemInfo.isWindows)
return SystemInfo.isWindowsVista;
if (SystemInfo.isMac) return SystemInfo.isMacOSMojave;
if (SystemInfo.isWindows) return SystemInfo.isWindowsVista;
return false;
}
@ -144,8 +142,7 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
Font font = entry.getValue();
String fontName = SystemInfo.isMacOSCatalina ? MAC_OS_CATALINA_FONT_NAME_FALLBACK : MAC_OS_FONT_NAME;
Font macFont = FontUtil.createFont(fontName, font.getStyle(), font.getSize());
if (SystemInfo.isMacOSMojave)
macFont = macFont.deriveFont(ENABLE_KERNING);
if (SystemInfo.isMacOSMojave) macFont = macFont.deriveFont(ENABLE_KERNING);
if (font instanceof UIResource) {
macFont = new DarkFontUIResource(macFont);
}
@ -154,8 +151,7 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
private Font mapWindowsFont(final Map.Entry<Object, Font> entry) {
Font font = entry.getValue();
if (!SystemInfo.isWindowsVista)
return font;
if (!SystemInfo.isWindowsVista) return font;
Font windowsFont = FontUtil.createFont(WINDOWS_10_FONT_NAME, font.getStyle(), font.getSize());
if (font instanceof UIResource) {
windowsFont = new DarkFontUIResource(windowsFont);
@ -167,26 +163,22 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
PropertyLoader.replacePropertiesOfType(Font.class, defaults, e -> kerningPredicate.test(e.getKey().toString()),
f -> {
Font font = f.deriveFont(ENABLE_KERNING);
if (f instanceof UIResource)
font = new DarkFontUIResource(font);
if (f instanceof UIResource) font = new DarkFontUIResource(font);
return font;
});
}
private void applyFontRule(final Theme currentTheme, final UIDefaults defaults) {
FontSizeRule rule = currentTheme.getFontSizeRule();
if (rule == null || rule.getType() == FontSizeRule.AdjustmentType.NO_ADJUSTMENT)
return;
if (rule == null || rule.getType() == FontSizeRule.AdjustmentType.NO_ADJUSTMENT) return;
PropertyLoader.replacePropertiesOfType(Font.class, defaults, f -> fontWithRule(f, rule));
}
private Font fontWithRule(final Font font, final FontSizeRule rule) {
if (font == null)
return null;
if (font == null) return null;
float size = font.getSize2D();
float newSize = rule.adjustFontSize(size);
if (newSize == size)
return font;
if (newSize == size) return font;
if (newSize <= 0) {
LOGGER.warning("Font " + font + " would be invisible after applying " + rule + ". Font won't be changed!");
return font;

3
core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java

@ -31,8 +31,7 @@ public abstract class UserPreferenceAdjustmentTask implements DefaultsAdjustment
@Override
public void run(final Theme currentTheme, final Properties properties) {
for (DefaultsAdjustmentTask task : getTasks()) {
if (task != null)
task.run(currentTheme, properties);
if (task != null) task.run(currentTheme, properties);
}
}

15
core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java

@ -89,10 +89,8 @@ public class DarkPopupFactory extends PopupFactory {
public static PopupType getPopupType(final Popup popup) {
String popupClassName = popup.getClass().getSimpleName();
if (popupClassName.endsWith("LightWeightPopup"))
return PopupType.LIGHT_WEIGHT;
if (popupClassName.endsWith("MediumWeightPopup"))
return PopupType.MEDIUM_WEIGHT;
if (popupClassName.endsWith("LightWeightPopup")) return PopupType.LIGHT_WEIGHT;
if (popupClassName.endsWith("MediumWeightPopup")) return PopupType.MEDIUM_WEIGHT;
return PopupType.HEAVY_WEIGHT;
}
@ -100,8 +98,7 @@ public class DarkPopupFactory extends PopupFactory {
if (type == PopupType.MEDIUM_WEIGHT) {
JRootPane rootPane = SwingUtilities.getRootPane(contents);
// Prevents decorations from being reinstalled.
if (rootPane != null)
rootPane.putClientProperty(DarkRootPaneUI.KEY_NO_DECORATIONS_UPDATE, true);
if (rootPane != null) rootPane.putClientProperty(DarkRootPaneUI.KEY_NO_DECORATIONS_UPDATE, true);
} else if (type == PopupType.HEAVY_WEIGHT) {
Window window = SwingUtilities.getWindowAncestor(contents);
if (window != null) {
@ -131,8 +128,7 @@ public class DarkPopupFactory extends PopupFactory {
* that is repainted with the proper popup background later. That is why we set window background
* explicitly.
*/
if (rootPane == null)
return;
if (rootPane == null) return;
rootPane.setOpaque(opaque);
if (opaque) {
Color bg = ColorUtil.toAlpha(rootPane.getBackground(), 255);
@ -188,8 +184,7 @@ public class DarkPopupFactory extends PopupFactory {
protected Color getTranslucentPopupBackground(final boolean decorated) {
Color c = UIManager.getColor("PopupMenu.translucentBackground");
if (!decorated)
c = new DarkColorUIResource(ColorUtil.toAlpha(c, 0));
if (!decorated) c = new DarkColorUIResource(ColorUtil.toAlpha(c, 0));
return c;
}

9
core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java

@ -63,10 +63,8 @@ public interface ButtonConstants {
}
static int chooseArc(final Component c, final int arc, final int minimum, final int altArc, final int roundedArc) {
if (ButtonConstants.isNoArc(c))
return minimum;
if (ButtonConstants.isRound(c))
return roundedArc;
if (ButtonConstants.isNoArc(c)) return minimum;
if (ButtonConstants.isRound(c)) return roundedArc;
boolean alt = ButtonConstants.chooseAlternativeArc(c);
return alt ? altArc : arc;
}
@ -89,8 +87,7 @@ public interface ButtonConstants {
}
static boolean isBorderlessVariant(final Component c) {
if (isBorderlessRectangular(c))
return true;
if (isBorderlessRectangular(c)) return true;
if (c instanceof JButton || c instanceof JToggleButton) {
return isBorderless(c) || doConvertToBorderless((AbstractButton) c);
}

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

@ -153,8 +153,7 @@ public class DarkButtonBorder implements Border, UIResource {
if (paintLeft) {
AlignmentExt corner = getCornerFlag(left);
Insets ins = new Insets(0, 0, 0, 0);
if (corner != null)
ins = corner.maskInsets(ins, borderSize);
if (corner != null) ins = corner.maskInsets(ins, borderSize);
int h = height - Math.max(0, getShadowSize(left) - borderSize);
g2.translate(-3 * borderSize + 1, -ins.top);
@ -166,8 +165,7 @@ public class DarkButtonBorder implements Border, UIResource {
if (paintRight) {
AlignmentExt corner = getCornerFlag(right);
Insets ins = new Insets(0, 0, 0, 0);
if (corner != null)
ins = corner.maskInsets(ins, borderSize);
if (corner != null) ins = corner.maskInsets(ins, borderSize);
int h = height - Math.max(0, getShadowSize(right) - borderSize);
g2.translate(width - borderSize - 1, -ins.top);
@ -180,8 +178,7 @@ public class DarkButtonBorder implements Border, UIResource {
if (paintTop) {
AlignmentExt corner = getCornerFlag(top);
Insets ins = new Insets(0, 0, 0, 0);
if (corner != null)
ins = corner.maskInsets(ins, borderSize);
if (corner != null) ins = corner.maskInsets(ins, borderSize);
g2.translate(-ins.left, -3 * borderSize + 1);
PaintUtil.paintFocusBorder(g2, width + ins.right + ins.left, 4 * borderSize, getFocusArc(top), borderSize);
@ -209,8 +206,7 @@ public class DarkButtonBorder implements Border, UIResource {
if (paintBottom) {
AlignmentExt corner = getCornerFlag(bottom);
Insets ins = new Insets(0, 0, 0, 0);
if (corner != null)
ins = corner.maskInsets(ins, borderSize);
if (corner != null) ins = corner.maskInsets(ins, borderSize);
g2.translate(-ins.left, height - borderSize - 1);
PaintUtil.paintFocusBorder(g2, width + ins.left + ins.right, 4 * borderSize, getFocusArc(bottom),
@ -270,8 +266,7 @@ public class DarkButtonBorder implements Border, UIResource {
protected Insets maskInsets(final Insets ins, final Component c, final int shadow) {
AlignmentExt alignment = getCornerFlag(c);
if (alignment == null)
return ins;
if (alignment == null) return ins;
Insets insetMask = new Insets(borderSize, borderSize, Math.max(borderSize, shadow), borderSize);
insetMask = alignment.maskInsetsInverted(insetMask);
ins.top -= insetMask.top;

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

@ -121,16 +121,11 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
squareInsets = UIManager.getInsets("Button.squareBorderInsets");
squareThinInsets = UIManager.getInsets("Button.squareThinBorderInsets");
borderlessRectangularInsets = UIManager.getInsets("Button.borderlessRectangularInsets");
if (insets == null)
insets = new Insets(0, 0, 0, 0);
if (thinInsets == null)
thinInsets = new Insets(0, 0, 0, 0);
if (squareThinInsets == null)
squareThinInsets = new Insets(0, 0, 0, 0);
if (squareInsets == null)
squareInsets = new Insets(0, 0, 0, 0);
if (borderlessRectangularInsets == null)
borderlessRectangularInsets = new Insets(0, 0, 0, 0);
if (insets == null) insets = new Insets(0, 0, 0, 0);
if (thinInsets == null) thinInsets = new Insets(0, 0, 0, 0);
if (squareThinInsets == null) squareThinInsets = new Insets(0, 0, 0, 0);
if (squareInsets == null) squareInsets = new Insets(0, 0, 0, 0);
if (borderlessRectangularInsets == null) borderlessRectangularInsets = new Insets(0, 0, 0, 0);
updateMargins(b);
}
@ -439,15 +434,13 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
protected void updateMargins(final AbstractButton b) {
Insets margin = b.getMargin();
if (margin != null && !(margin instanceof UIResource))
return;
if (margin != null && !(margin instanceof UIResource)) return;
Insets m = getMargins(b);
b.setMargin(new InsetsUIResource(m.top, m.left, m.bottom, m.right));
}
private Insets getMargins(final AbstractButton b) {
if (ButtonConstants.isBorderlessRectangular(b))
return borderlessRectangularInsets;
if (ButtonConstants.isBorderlessRectangular(b)) return borderlessRectangularInsets;
boolean square = ButtonConstants.isSquare(b);
return ButtonConstants.isThin(b) ? square ? squareThinInsets : thinInsets : square ? squareInsets : insets;
}
@ -457,8 +450,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
if (ButtonConstants.isBorderlessRectangular(c)) {
return super.contains(c, x, y);
}
if (!(x >= 0 && x <= c.getWidth() && y >= 0 && y <= c.getHeight()))
return false;
if (!(x >= 0 && x <= c.getWidth() && y >= 0 && y <= c.getHeight())) return false;
int bs = c.getBorder() instanceof DarkButtonBorder && !ButtonConstants.isBorderless(c) ? borderSize : 0;
int arc = getArc(c);
hitArea.setRoundRect(bs, bs, c.getWidth() - 2 * bs, c.getHeight() - 2 * bs, arc, arc);

6
core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java

@ -473,8 +473,7 @@ public class CellUtil {
int row = table.getEditingRow();
int col = table.getEditingColumn();
if (!table.getShowHorizontalLines()) {
if (row > CellUtil.getMinRowIndex(table))
g.fillRect(0, 0, width, 1);
if (row > CellUtil.getMinRowIndex(table)) g.fillRect(0, 0, width, 1);
g.fillRect(0, height - 1, width, 1);
}
boolean isWrapper = isInWrapper(c);
@ -529,8 +528,7 @@ public class CellUtil {
if (table != null && !table.getShowVerticalLines()) {
int cMin = getMinColumnIndex(table);
int column = table.getEditingColumn();
if (column > cMin)
ins.left++;
if (column > cMin) ins.left++;
}
return ins;
}

27
core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java

@ -85,8 +85,7 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
}
private void updatePopup(final I index, final Point p) {
if (cellContainer.getComponent() == null || index == null)
return;
if (cellContainer.getComponent() == null || index == null) return;
final boolean isEditing = cellContainer.isEditingCell(index);
final Rectangle allocation = cellContainer.getAllocation();
final Rectangle cellBounds = cellContainer.getCellBoundsAt(index, isEditing);
@ -140,10 +139,8 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
} else {
int upperDiff = Math.max(cellBounds.x + cellBounds.width - visibleBounds.x - visibleBounds.width, 0);
int lowerDiff = Math.max(visibleBounds.x - cellBounds.x, 0);
if (ltr && upperDiff > 0)
lowerDiff = 0;
if (!ltr && lowerDiff > 0)
upperDiff = 0;
if (ltr && upperDiff > 0) lowerDiff = 0;
if (!ltr && lowerDiff > 0) upperDiff = 0;
if (upperDiff >= lowerDiff) {
rect.x = visibleBounds.x + visibleBounds.width;
rect.width = upperDiff;
@ -163,8 +160,7 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
} else {
int upperDiff = Math.max(cellBounds.y + cellBounds.height - visibleBounds.y - visibleBounds.height, 0);
int lowerDiff = Math.max(visibleBounds.y - cellBounds.y, 0);
if (upperDiff > 0)
lowerDiff = 0;
if (upperDiff > 0) lowerDiff = 0;
if (upperDiff >= lowerDiff) {
rect.y = visibleBounds.y + visibleBounds.height;
rect.height = upperDiff;
@ -206,10 +202,8 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
}
public void repaint() {
if (!cellContainer.getComponent().isShowing())
return;
if (popup != null)
popupComponent.repaint();
if (!cellContainer.getComponent().isShowing()) return;
if (popup != null) popupComponent.repaint();
if (lastIndex != null) {
Point p = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(p, cellContainer.getComponent());
@ -246,8 +240,7 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
}
private void movePopup(final Rectangle bounds) {
if (popup == null)
return;
if (popup == null) return;
DarkPopupFactory.PopupType popupType = DarkPopupFactory.getPopupType(popup);
Window w = DarkUIUtil.getWindow(popupComponent);
if (popupType == DarkPopupFactory.PopupType.HEAVY_WEIGHT) {
@ -369,10 +362,8 @@ public class CellHintPopupListener<T extends JComponent, I> extends MouseInputAd
Component renderer = cellHintPopupListener.getRenderer();
if (rendererBounds != null && renderer != null) {
Color bg = cellHintPopupListener.getBackground(renderer);
if (bg == null)
bg = cellHintPopupListener.cellContainer.getComponent().getBackground();
if (bg == null)
bg = getBackground();
if (bg == null) bg = cellHintPopupListener.cellContainer.getComponent().getBackground();
if (bg == null) bg = getBackground();
if (bg != null) {
g.setColor(bg);
g.fillRect(0, 0, getWidth(), getHeight());

18
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java

@ -176,14 +176,12 @@ public class ColorTriangle extends JComponent {
protected void setHSBHue(final double hue) {
hueHSB = hue;
if (hueHSB < 0)
hueHSB += 1.0;
if (hueHSB < 0) hueHSB += 1.0;
}
protected void setHSLHue(final double hue) {
hueHSL = hue;
if (hueHSL < 0)
hueHSL += 1.0;
if (hueHSL < 0) hueHSL += 1.0;
}
protected void setValue(final double value) {
@ -310,8 +308,7 @@ public class ColorTriangle extends JComponent {
}
protected void setColorFromRGB(final Object source, final int r, final int g, final int b) {
if (isMessaging)
return;
if (isMessaging) return;
this.color = new Color(r, g, b);
double[] hsb = DarkColorModelHSB.RGBtoHSBValues(r, g, b);
double[] hsl = DarkColorModelHSL.RGBtoHSLValues(r, g, b);
@ -327,8 +324,7 @@ public class ColorTriangle extends JComponent {
}
protected void setColorFromHSL(final Object source, final double h, final double s, final double l) {
if (isMessaging)
return;
if (isMessaging) return;
setHSL(h, s, l);
color = DarkColorModelHSL.getColorFromHSLValues(h, s, l);
setHSB(DarkColorModelHSB.RGBtoHSBValues(color.getRed(), color.getGreen(), color.getBlue()));
@ -339,8 +335,7 @@ public class ColorTriangle extends JComponent {
}
protected void setColorFromHSB(final Object source, final double h, final double s, final double b) {
if (isMessaging)
return;
if (isMessaging) return;
setHSB(h, s, b);
color = DarkColorModelHSB.getColorFromHSBValues(h, s, b);
setHSL(DarkColorModelHSL.RGBtoHSLValues(color.getRed(), color.getGreen(), color.getBlue()));
@ -516,8 +511,7 @@ public class ColorTriangle extends JComponent {
protected Shape calculateCircleShape(final double x, final double y, final int size, final int outerSize) {
outerRadius = size / 2.0;
innerRadius = outerRadius - outerSize;
if (!circleInfo.update(x, y, size, outerSize) && circleShape != null)
return circleShape;
if (!circleInfo.update(x, y, size, outerSize) && circleShape != null) return circleShape;
Area outer = new Area(new Ellipse2D.Double(x, y, size, size));
Area inner = new Area(

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

@ -146,24 +146,20 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
@Override
public void colorChanged(final Color color, final Object source) {
if (isChanging || color == null)
return;
if (isChanging || color == null) return;
isChanging = true;
currentColor = color;
ColorSelectionModel model = getColorSelectionModel();
if (model != null)
model.setSelectedColor(currentColor);
if (model != null) model.setSelectedColor(currentColor);
applyColorToFields(color);
if (source != textHex)
textHex.setValue(color);
if (source != textHex) textHex.setValue(color);
previewComponent.setColor(color);
colorWheelPanel.setColor(color, this);
isChanging = false;
}
protected void onModelChange() {
if (isChanging)
return;
if (isChanging) return;
isChanging = true;
colorWheelPanel.setModel(getDarkColorModel());
updateDescriptors();

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

@ -44,8 +44,7 @@ public class DarkPreviewPanel extends JPanel {
private Color oldColor = null;
public void paintComponent(final Graphics g) {
if (oldColor == null)
oldColor = getForeground();
if (oldColor == null) oldColor = getForeground();
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());

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

@ -50,14 +50,12 @@ class RecentSwatchPanel extends SwatchPanel {
@Override
public String getToolTipText(final MouseEvent e) {
Color color = getColorForLocation(e.getX(), e.getY());
if (color == defaultRecentColor || color == null)
return null;
if (color == defaultRecentColor || color == null) return null;
return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue();
}
public void setMostRecentColor(final Color c) {
if (Objects.equals(colors[0], c))
return;
if (Objects.equals(colors[0], c)) return;
System.arraycopy(colors, 0, colors, 1, colors.length - 1);
colors[0] = c;
repaint();

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

@ -86,8 +86,7 @@ class SlideComponent extends JComponent implements ColorListener {
addMouseWheelListener(event -> {
int units = event.getUnitsToScroll();
if (units == 0)
return;
if (units == 0) return;
int pointerValue = this.pointerValue + units;
pointerValue = Math.max(pointerValue, OFFSET);
int size = this.vertical ? getHeight() : getWidth();
@ -183,8 +182,7 @@ class SlideComponent extends JComponent implements ColorListener {
borderColor = UIManager.getColor("ColorChooser.sliderBorderColor");
shadowColor = UIManager.getColor("ColorChooser.sliderShadow");
knobFill = UIManager.getColor("ColorChooser.sliderKnobColor");
if (toolTipContext != null)
toolTipContext.updateToolTipUI();
if (toolTipContext != null) toolTipContext.updateToolTipUI();
}
@Override

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

@ -114,8 +114,7 @@ abstract class SwatchPanel extends JPanel {
@Override
public void updateUI() {
super.updateUI();
if (toolTipContext != null)
toolTipContext.updateToolTipUI();
if (toolTipContext != null) toolTipContext.updateToolTipUI();
}
protected void initValues() {}
@ -128,8 +127,7 @@ abstract class SwatchPanel extends JPanel {
private Color getColorForCell(final int column, final int row) {
int index = (row * numSwatches.width) + column;
if (index >= colors.length)
return null;
if (index >= colors.length) return null;
return colors[(row * numSwatches.width) + column];
}
@ -178,8 +176,7 @@ abstract class SwatchPanel extends JPanel {
public String getToolTipText(final MouseEvent e) {
Color color = getColorForLocation(e.getX(), e.getY());
if (color == null)
return null;
if (color == null) return null;
return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue();
}

6
core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java

@ -51,10 +51,8 @@ public class DarkComboBoxBorder implements Border, UIResource {
borderColor = UIManager.getColor("ComboBox.activeBorderColor");
inactiveBorderColor = UIManager.getColor("ComboBox.inactiveBorderColor");
cellPadding = UIManager.getInsets("ComboBox.cellEditorInsets");
if (boxPadding == null)
boxPadding = new Insets(0, 0, 0, 0);
if (cellPadding == null)
cellPadding = new Insets(0, 0, 0, 0);
if (boxPadding == null) boxPadding = new Insets(0, 0, 0, 0);
if (cellPadding == null) cellPadding = new Insets(0, 0, 0, 0);
}
@Override

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

@ -75,8 +75,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
inactiveBackground = UIManager.getColor("ComboBox.inactiveBackground");
inactiveForeground = UIManager.getColor("ComboBox.disabledForeground");
arrowBackground = UIManager.getColor("ComboBox.arrowBackground");
if (boxPadding == null)
boxPadding = new Insets(0, 0, 0, 0);
if (boxPadding == null) boxPadding = new Insets(0, 0, 0, 0);
}
protected void installBorder(final JComponent c) {
@ -248,18 +247,14 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
}
protected Color getBackground(final JComboBox<?> c) {
if (!c.isEnabled())
return inactiveBackground;
if (c.isEditable())
return editBackground;
if (!c.isEnabled()) return inactiveBackground;
if (c.isEditable()) return editBackground;
return background;
}
protected Color getArrowBackground(final JComboBox<?> c) {
if (!c.isEnabled())
return inactiveBackground;
if (c.isEditable())
return arrowBackground;
if (!c.isEnabled()) return inactiveBackground;
if (c.isEditable()) return arrowBackground;
return background;
}
@ -272,8 +267,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
super.layoutContainer(parent);
if (ComboBoxConstants.isTreeOrTableCellEditor(comboBox)) {
int adj = borderSize / 2;
if (!comboBox.getComponentOrientation().isLeftToRight())
adj *= -1;
if (!comboBox.getComponentOrientation().isLeftToRight()) adj *= -1;
Rectangle bounds = arrowButton.getBounds();
bounds.x += adj;
arrowButton.setBounds(bounds);

3
core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java

@ -180,8 +180,7 @@ public class DarkComboPopup extends BasicComboPopup {
@Override
protected void togglePopup() {
if (comboBox.getItemCount() == 0)
return;
if (comboBox.getItemCount() == 0) return;
if (visible) {
visible = false;
hide();

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

@ -117,8 +117,7 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
protected JComponent createControlPanel(final JFileChooser fileChooser) {
JComponent accessoryPanel = getAccessoryPanel();
JComponent accessory = fileChooser.getAccessory();
if (accessory != null)
accessoryPanel.add(accessory);
if (accessory != null) accessoryPanel.add(accessory);
return accessoryPanel;
}
@ -366,8 +365,7 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
}
public BasicFileView getFileView() {
if (fileView == null)
fileView = createFileView();
if (fileView == null) fileView = createFileView();
return fileView;
}
@ -402,8 +400,7 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
} else {
try {
String mimeType = Files.probeContentType(f.toPath());
if (mimeType == null)
mimeType = "";
if (mimeType == null) mimeType = "";
if (mimeType.startsWith(MIME_IMAGE)) {
icon = imageFileIcon;
} else if (mimeType.startsWith(MIME_TEXT)) {

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

@ -116,8 +116,7 @@ public class DarkInternalFrameUI extends BasicInternalFrameUI implements Propert
}
protected boolean shouldShowMenuBar(final JInternalFrame internalFrame) {
if (internalFrame == null)
return false;
if (internalFrame == null) return false;
return internalFrame.isSelected() && !internalFrame.isClosed() && !internalFrame.isIcon();
}
}

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

@ -51,15 +51,13 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
}
public static ComponentUI createUI(final JComponent c) {
if (darkLabelUI == null)
darkLabelUI = new DarkLabelUI();
if (darkLabelUI == null) darkLabelUI = new DarkLabelUI();
return darkLabelUI;
}
@Override
public void installUI(final JComponent c) {
if (c != null)
super.installUI(c);
if (c != null) super.installUI(c);
}
@Override

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

@ -150,8 +150,7 @@ public class DarkListUI extends DarkListUIBridge implements CellConstants {
for (int column = colCounter - 1; rowBounds.height <= 0 && column >= 0; column--) {
rowBounds.height = getHeight(colCounter - 1, row);
}
if (rowBounds.height <= 0)
rowBounds.height = getHeight(0, 0);
if (rowBounds.height <= 0) rowBounds.height = getHeight(0, 0);
g.setClip(rowBounds.x, rowBounds.y, bgWidth > 0 ? bgWidth : rowBounds.width, rowBounds.height);
g.clipRect(paintBounds.x, paintBounds.y, paintBounds.width, paintBounds.height);

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

@ -77,8 +77,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
}
protected boolean isSelected(final JComponent menuItem) {
if (!(menuItem instanceof JMenuItem))
return false;
if (!(menuItem instanceof JMenuItem)) return false;
return menuItem.isEnabled() && ((JMenuItem) menuItem).isArmed();
}
@ -162,8 +161,7 @@ public class DarkMenuItemUIBase extends BasicMenuItemUI {
protected Color getAcceleratorForeground(final AbstractButton b) {
ButtonModel model = b.getModel();
if (!model.isEnabled())
return disabledForeground;
if (!model.isEnabled()) return disabledForeground;
if (model.isArmed() || (b instanceof JMenu && model.isSelected())) {
return acceleratorSelectionForeground;
} else {

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

@ -77,8 +77,7 @@ public class DarkMenuUI extends BasicMenuUI {
@Override
public void mouseReleased(final MouseEvent e) {
if (!menu.isEnabled())
return;
if (!menu.isEnabled()) return;
if (pressed && wasEnabled) {
pressed = false;
return;
@ -117,8 +116,7 @@ public class DarkMenuUI extends BasicMenuUI {
}
protected boolean isSelected(final JComponent menuItem) {
if (!(menuItem instanceof JMenuItem))
return false;
if (!(menuItem instanceof JMenuItem)) return false;
return menuItem.isEnabled() && ((JMenuItem) menuItem).isArmed();
}
}

39
core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java

@ -45,92 +45,79 @@ public class MenuItemLayoutDelegate extends JMenuItem {
@Override
public Insets getInsets(final Insets insets) {
if (delegate != null)
return delegate.getInsets(insets);
if (delegate != null) return delegate.getInsets(insets);
return super.getInsets(insets);
}
@Override
public Insets getInsets() {
if (delegate != null)
return delegate.getInsets();
if (delegate != null) return delegate.getInsets();
return super.getInsets();
}
@Override
public Font getFont() {
if (delegate != null)
return delegate.getFont();
if (delegate != null) return delegate.getFont();
return super.getFont();
}
@Override
public ComponentOrientation getComponentOrientation() {
if (delegate != null)
return delegate.getComponentOrientation();
if (delegate != null) return delegate.getComponentOrientation();
return super.getComponentOrientation();
}
@Override
public Container getParent() {
if (delegate != null)
return delegate.getParent();
if (delegate != null) return delegate.getParent();
return super.getParent();
}
@Override
public KeyStroke getAccelerator() {
if (delegate != null)
return delegate.getAccelerator();
if (delegate != null) return delegate.getAccelerator();
return super.getAccelerator();
}
@Override
public int getVerticalAlignment() {
if (delegate != null)
return delegate.getVerticalAlignment();
if (delegate != null) return delegate.getVerticalAlignment();
return super.getVerticalAlignment();
}
@Override
public int getHorizontalAlignment() {
if (delegate != null)
return delegate.getHorizontalAlignment();
if (delegate != null) return delegate.getHorizontalAlignment();
return super.getHorizontalAlignment();
}
@Override
public int getVerticalTextPosition() {
if (delegate != null)
return delegate.getVerticalTextPosition();
if (delegate != null) return delegate.getVerticalTextPosition();
return super.getVerticalTextPosition();
}
@Override
public int getHorizontalTextPosition() {
if (delegate != null)
return delegate.getHorizontalTextPosition();
if (delegate != null) return delegate.getHorizontalTextPosition();
return super.getHorizontalTextPosition();
}
@Override
public FontMetrics getFontMetrics(final Font font) {
if (delegate != null)
return delegate.getFontMetrics(font);
if (delegate != null) return delegate.getFontMetrics(font);
return super.getFontMetrics(font);
}
@Override
public Icon getIcon() {
if (delegate != null)
return delegate.getIcon();
if (delegate != null) return delegate.getIcon();
return super.getIcon();
}
@Override
public String getText() {
if (delegate != null)
return delegate.getText();
if (delegate != null) return delegate.getText();
return super.getText();
}
}

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

@ -141,8 +141,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
g.setColor(c.getBackground());
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
if (textComponent == null || viewport == null)
return;
if (textComponent == null || viewport == null) return;
FontMetrics metrics = textComponent.getFontMetrics(textComponent.getFont());
int descent = metrics.getDescent();
@ -165,12 +164,10 @@ public class DarkNumberingPaneUI extends ComponentUI {
@Override
public Dimension getPreferredSize(final JComponent c) {
if (textComponent == null || viewport == null)
return super.getPreferredSize(c);
if (textComponent == null || viewport == null) return super.getPreferredSize(c);
int lines = textComponent.getDocument().getDefaultRootElement().getElementCount();
int pad = 2 * OUTER_PAD;
if (maxIconWidth > 0)
pad += PAD;
if (maxIconWidth > 0) pad += PAD;
textWidth = numberingPane.getFontMetrics(numberingPane.getFont()).stringWidth(String.valueOf(lines));
return new Dimension(maxIconWidth + pad + textWidth, viewport.getView().getHeight());
}
@ -253,8 +250,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
@Override
public void mouseClicked(final MouseEvent e) {
if (textComponent == null)
return;
if (textComponent == null) return;
Point p = e.getPoint();
int width = numberingPane.getWidth();
if (p.x > PAD + OUTER_PAD + textWidth && p.x <= width - PAD) {
@ -290,8 +286,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
@Override
public void mousePressed(final MouseEvent e) {
if (textComponent == null)
return;
if (textComponent == null) return;
Point p = e.getPoint();
selectionLineStart = textComponent.viewToModel(new Point(0, p.y));
selectionLineEnd = textComponent.viewToModel(new Point(textComponent.getWidth(), p.y));
@ -309,8 +304,7 @@ public class DarkNumberingPaneUI extends ComponentUI {
@Override
public void mouseDragged(final MouseEvent e) {
if (numberingPane.getTextComponent() == null)
return;
if (numberingPane.getTextComponent() == null) return;
JTextComponent textPane = numberingPane.getTextComponent();
Point p = e.getPoint();
if (selectionLineEnd >= 0 && selectionLineStart >= 0) {

3
core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java

@ -31,8 +31,7 @@ public class DarkOptionPaneBorder extends EmptyBorder {
public DarkOptionPaneBorder() {
super(0, 0, 0, 0);
Insets insets = UIManager.getInsets("OptionPane.borderInsets");
if (insets == null)
insets = new Insets(0, 0, 0, 0);
if (insets == null) insets = new Insets(0, 0, 0, 0);
left = insets.left;
right = insets.right;
top = insets.top;

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

@ -32,8 +32,7 @@ public class DarkPanelUI extends BasicPanelUI {
private static PanelUI darkPanelUI;
public static ComponentUI createUI(final JComponent c) {
if (darkPanelUI == null)
darkPanelUI = new DarkPanelUI();
if (darkPanelUI == null) darkPanelUI = new DarkPanelUI();
return darkPanelUI;
}
}

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

@ -101,8 +101,7 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI {
@Override
public Popup getPopup(final JPopupMenu popup, final int x, final int y) {
PopupMenuContainer container = getPopupMenuContainer();
if (container == null)
return super.getPopup(popup, x, y);
if (container == null) return super.getPopup(popup, x, y);
int maxHeight = DarkUIUtil.getScreenBounds(popup, x, y, false).height;
return container.createPopup(popup, x, y, maxHeight);
}

3
core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/EventHelperUtil.java

@ -28,8 +28,7 @@ public class EventHelperUtil {
private static boolean eventHelperInstallerFlagSet;
public static void installEventHelper() {
if (eventHelperInstallerFlagSet)
return;
if (eventHelperInstallerFlagSet) return;
eventHelperInstallerFlagSet = true;
new DummyBasicLookAndFeel().initialize();
}

12
core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java

@ -56,14 +56,11 @@ public class MouseGrabberUtil {
private static ChangeListener getOldMouseGrabber() {
MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager();
for (ChangeListener listener : menuSelectionManager.getChangeListeners()) {
if (listener == null)
continue;
if (listener == null) continue;
Class<?> listenerClass = listener.getClass();
if (listenerClass == null)
continue;
if (listenerClass == null) continue;
Class<?> enclosingClass = listenerClass.getEnclosingClass();
if (enclosingClass == null)
continue;
if (enclosingClass == null) continue;
if (listenerClass.getName().endsWith("MouseGrabber")
&& enclosingClass.getName().endsWith("BasicPopupMenuUI")) {
return listener;
@ -77,8 +74,7 @@ public class MouseGrabberUtil {
* add our own implementation for it that is a bit more generous with closing the popup.
*/
private static void uninstallOldMouseGrabber(final ChangeListener oldMouseGrabber) {
if (oldMouseGrabber == null)
return;
if (oldMouseGrabber == null) return;
MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager();
menuSelectionManager.removeChangeListener(oldMouseGrabber);
if (oldMouseGrabber instanceof AWTEventListener) {

6
core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java

@ -65,8 +65,7 @@ public class PopupMenuContainer extends JPanel {
@Override
public void menuKeyPressed(final MenuKeyEvent e) {
SwingUtilities.invokeLater(() -> {
if (popupMenu == null)
return;
if (popupMenu == null) return;
MenuElement[] path = e.getMenuSelectionManager().getSelectedPath();
if (path.length == 0) {
return;
@ -98,8 +97,7 @@ public class PopupMenuContainer extends JPanel {
}
private void onHide() {
if (popupMenu == null)
return;
if (popupMenu == null) return;
popupMenu.removePopupMenuListener(this);
popupMenu.removeMenuKeyListener(menuKeyListener);
}

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

@ -79,8 +79,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
}
protected void installBorder(final JRootPane root) {
if (root == null)
return;
if (root == null) return;
LookAndFeel.installBorder(root, borderKeys[windowDecorationsStyle]);
}
@ -110,12 +109,9 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
protected int decorationsStyleFromWindow(final Window window, final int windowDecorationsStyle) {
if (DarkUIUtil.isUndecorated(window) || PropertyUtil.getBooleanProperty(rootPane, KEY_NO_DECORATIONS))
return JRootPane.NONE;
if (windowDecorationsStyle != JRootPane.NONE)
return windowDecorationsStyle;
if (window instanceof JFrame)
return JRootPane.FRAME;
if (window instanceof JDialog)
return JRootPane.PLAIN_DIALOG;
if (windowDecorationsStyle != JRootPane.NONE) return windowDecorationsStyle;
if (window instanceof JFrame) return JRootPane.FRAME;
if (window instanceof JDialog) return JRootPane.PLAIN_DIALOG;
return windowDecorationsStyle;
}
@ -155,8 +151,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
CustomTitlePane titlePane = DecorationsHandler.getSharedInstance().createTitlePane(root, style, window);
installLayout(root);
setTitlePane(root, titlePane);
if (titlePane != null)
titlePane.setDecorationsStyle(windowDecorationsStyle);
if (titlePane != null) titlePane.setDecorationsStyle(windowDecorationsStyle);
}
@Override
@ -188,8 +183,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
private void updateWindow(final Component parent) {
window = DarkUIUtil.getWindow(parent);
windowDecorationsStyle = decorationsStyleFromWindow(window, windowDecorationsStyle);
if (titlePane != null)
titlePane.setDecorationsStyle(windowDecorationsStyle);
if (titlePane != null) titlePane.setDecorationsStyle(windowDecorationsStyle);
installBorder(rootPane);
}
@ -211,8 +205,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
@Override
public void hierarchyChanged(final HierarchyEvent e) {
if (rootPane == null)
return;
if (rootPane == null) return;
Component parent = rootPane.getParent();
if (parent == null) {
return;

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

@ -151,14 +151,12 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis
@Override
public void adjustmentValueChanged(final AdjustmentEvent e) {
if (!e.getValueIsAdjusting())
return;
if (!e.getValueIsAdjusting()) return;
JScrollBar scrollBar = (JScrollBar) e.getAdjustable();
int extent = scrollBar.getModel().getExtent();
int value = scrollBar.getValue() + extent;
if (value == extent || value == scrollBar.getMaximum())
return;
if (value == extent || value == scrollBar.getMaximum()) return;
Point p = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(p, scrollbar);

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

@ -131,8 +131,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI implements ScrollBarConsta
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
}
float trackAlpha = scrollBarListener.getTrackAlpha();
if (trackAlpha == 0)
return;
if (trackAlpha == 0) return;
g.setColor(getTrackColor());
((Graphics2D) g).setComposite(COMPOSITE.derive(trackAlpha));
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);

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

@ -46,13 +46,11 @@ public class DarkSeparatorUI extends BasicSeparatorUI {
color = UIManager.getColor("Separator.foreground");
size = UIManager.getDimension("Separator.size");
insets = UIManager.getInsets("Separator.insets");
if (insets == null)
insets = new Insets(0, 0, 0, 0);
if (insets == null) insets = new Insets(0, 0, 0, 0);
}
public void paint(final Graphics g, final JComponent c) {
if (!(c instanceof JSeparator))
return;
if (!(c instanceof JSeparator)) return;
checkSize(c);
g.setColor(color);
if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) {
@ -77,31 +75,25 @@ public class DarkSeparatorUI extends BasicSeparatorUI {
}
private void checkSize(final JComponent c) {
if (resizeLock)
return;
if (resizeLock) return;
Container parent = c.getParent();
if (parent == null)
return;
if (parent == null) return;
LayoutManager lm = parent.getLayout();
if (!(lm instanceof BoxLayout || parent instanceof JToolBar))
return;
if (!(lm instanceof BoxLayout || parent instanceof JToolBar)) return;
resizeLock = true;
Dimension dim = parent.getSize();
Rectangle bounds = c.getBounds();
if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) {
if (bounds.height != dim.height)
c.setBounds(bounds.x, 0, bounds.width, dim.height);
if (bounds.height != dim.height) c.setBounds(bounds.x, 0, bounds.width, dim.height);
} else {
if (bounds.width != dim.width)
c.setBounds(0, bounds.y, dim.width, bounds.height);
if (bounds.width != dim.width) c.setBounds(0, bounds.y, dim.width, bounds.height);
}
resizeLock = false;
}
@SuppressWarnings("SuspiciousNameCombination")
public Dimension getPreferredSize(final JComponent c) {
if (c == null)
return new Dimension(size);
if (c == null) return new Dimension(size);
if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) {
return new Dimension(size.width, size.height);
} else {

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

@ -781,8 +781,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
int pos = isHorizontal() ? evt.getX() : evt.getY();
int loc = getLocationForValue(getSnappedValue(evt));
offset = (loc < 0) ? 0 : pos - loc;
if (iconRect.contains(evt.getPoint()))
return;
if (iconRect.contains(evt.getPoint())) return;
super.mousePressed(evt);
}

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

@ -55,10 +55,8 @@ public class DarkSpinnerBorder implements Border, UIResource {
borderSize = UIManager.getInt("Spinner.borderThickness");
cellInsets = UIManager.getInsets("Spinner.cellEditorInsets");
insets = UIManager.getInsets("Spinner.insets");
if (insets == null)
insets = new Insets(0, 0, 0, 0);
if (cellInsets == null)
cellInsets = new Insets(0, 0, 0, 0);
if (insets == null) insets = new Insets(0, 0, 0, 0);
if (cellInsets == null) cellInsets = new Insets(0, 0, 0, 0);
}
@Override

3
core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java

@ -133,8 +133,7 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements SpinnerConstants {
super.layoutContainer(parent);
if (SpinnerConstants.isTreeOrTableCellEditor(spinner)) {
int adj = borderSize / 2;
if (!spinner.getComponentOrientation().isLeftToRight())
adj *= -1;
if (!spinner.getComponentOrientation().isLeftToRight()) adj *= -1;
adjustButton(prevButton, adj);
adjustButton(nextButton, adj);
}

18
core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DividerStyle.java

@ -22,9 +22,9 @@
package com.github.weisj.darklaf.ui.splitpane;
public enum DividerStyle {
GRIP(SplitPaneConstants.STYLE_GRIP, false, true), GRIP_BORDERLESS(SplitPaneConstants.STYLE_GRIP_BORDERLESS, false,
false), LINE(SplitPaneConstants.STYLE_LINE, true,
true), INVISIBLE(SplitPaneConstants.STYLE_INVISIBLE, true, false);
GRIP(SplitPaneConstants.STYLE_GRIP, false, true),
GRIP_BORDERLESS(SplitPaneConstants.STYLE_GRIP_BORDERLESS, false, false),
LINE(SplitPaneConstants.STYLE_LINE, true, true), INVISIBLE(SplitPaneConstants.STYLE_INVISIBLE, true, false);
private final String name;
private final boolean isThin;
@ -42,8 +42,7 @@ public enum DividerStyle {
public static DividerStyle get(final Object style, final DividerStyle fallback) {
DividerStyle s = getNullableStyle(style);
if (s == null)
return fallback;
if (s == null) return fallback;
return s;
}
@ -65,17 +64,14 @@ public enum DividerStyle {
}
static DividerStyle getNullableStyle(final Object obj) {
if (obj == null)
return null;
if (obj instanceof DividerStyle)
return (DividerStyle) obj;
if (obj == null) return null;
if (obj instanceof DividerStyle) return (DividerStyle) obj;
try {
return valueOf(obj.toString());
} catch (IllegalArgumentException ignored) {
}
for (DividerStyle s : values()) {
if (s.name.equalsIgnoreCase(obj.toString()))
return s;
if (s.name.equalsIgnoreCase(obj.toString())) return s;
}
return null;
}

3
core/src/main/java/com/github/weisj/darklaf/ui/splitpane/ThinSplitPaneDivider.java

@ -55,8 +55,7 @@ final class ThinSplitPaneDivider extends BasicSplitPaneDivider {
@Override
public boolean contains(final Point p) {
if (!isEnabled())
return false;
if (!isEnabled()) return false;
return super.contains(p);
}

12
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java

@ -96,8 +96,7 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo
if (scrollPopupMenu.isVisible()) {
scrollPopupMenu.setVisible(false);
} else {
if (!ui.tabPane.isEnabled())
return;
if (!ui.tabPane.isEnabled()) return;
if (lastClickEvent == 0 || (System.currentTimeMillis() - lastClickEvent) > 250) {
Dimension pref = scrollPopupMenu.getPreferredSize();
boolean leftToRight = ui.tabPane.getComponentOrientation().isLeftToRight();
@ -135,19 +134,16 @@ public class DarkScrollableTabSupport extends ScrollableTabSupport implements Mo
@Override
public void mouseWheelMoved(final MouseWheelEvent e) {
if (!ui.tabPane.isEnabled() || ui.tabPane.getTabCount() == 0)
return;
if (!ui.tabPane.isEnabled() || ui.tabPane.getTabCount() == 0) return;
int tabPosition = ui.tabPane.getTabPlacement();
int scrollAmount = -1 * e.getUnitsToScroll() * e.getScrollAmount();
int scrolled;
if (tabPosition == SwingConstants.LEFT || tabPosition == SwingConstants.RIGHT) {
if (e.isShiftDown() || !moreTabsButton.isVisible())
return;
if (e.isShiftDown() || !moreTabsButton.isVisible()) return;
timer.stop();
scrolled = scroll(scrollAmount, false);
} else {
if (!e.isShiftDown() || !moreTabsButton.isVisible())
return;
if (!e.isShiftDown() || !moreTabsButton.isVisible()) return;
timer.stop();
scrolled = scroll(scrollAmount, true);
}

6
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java

@ -108,8 +108,7 @@ public class DarkTabbedPaneHandler extends TabbedPaneHandler {
} else if (DarkTabbedPaneUI.KEY_DND.equals(key)) {
ui.dndEnabled = PropertyUtil.getBooleanProperty(ui.tabPane, DarkTabbedPaneUI.KEY_DND);
DropTarget dropTarget = ui.tabPane.getDropTarget();
if (dropTarget != null)
dropTarget.setActive(ui.dndEnabled);
if (dropTarget != null) dropTarget.setActive(ui.dndEnabled);
} else if (PropertyKey.COMPONENT_ORIENTATION.equals(key)) {
ui.tabPane.doLayout();
ui.tabPane.repaint();
@ -183,8 +182,7 @@ public class DarkTabbedPaneHandler extends TabbedPaneHandler {
@Override
public void mouseDragged(final MouseEvent e) {
super.mouseDragged(e);
if (!ui.dndEnabled)
return;
if (!ui.dndEnabled) return;
if (origin == null) {
origin = e.getPoint();
pressedIndex = ui.tabForCoordinate(ui.tabPane, e.getX(), e.getY());

18
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java

@ -292,8 +292,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
ui.runCount = 0;
ui.selectedRun = -1;
if (tabCount == 0)
return;
if (tabCount == 0) return;
ui.selectedRun = 0;
ui.runCount = 1;
@ -475,8 +474,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
if (horizontal) {
if (leftToRight) {
if (ui.rects[tabCount - 1].x + ui.rects[tabCount - 1].width + buttonBounds.width > maxVal) {
if (button.getParent() != ui.tabPane)
ui.tabPane.add(button);
if (button.getParent() != ui.tabPane) ui.tabPane.add(button);
} else {
if (button.getParent() != ui.scrollableTabSupport.tabPanel) {
ui.scrollableTabSupport.tabPanel.add(button);
@ -485,8 +483,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
} else {
int x = ui.rects[tabCount - 1].x;
if (x - buttonBounds.width < minVal) {
if (button.getParent() != ui.tabPane)
ui.tabPane.add(button);
if (button.getParent() != ui.tabPane) ui.tabPane.add(button);
} else {
if (button.getParent() != ui.scrollableTabSupport.tabPanel) {
ui.scrollableTabSupport.tabPanel.add(button);
@ -495,8 +492,7 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
}
} else {
if (ui.rects[tabCount - 1].y + ui.rects[tabCount - 1].height + buttonBounds.height > maxVal) {
if (button.getParent() != ui.tabPane)
ui.tabPane.add(button);
if (button.getParent() != ui.tabPane) ui.tabPane.add(button);
} else {
if (button.getParent() != ui.scrollableTabSupport.tabPanel) {
ui.scrollableTabSupport.tabPanel.add(button);
@ -581,16 +577,14 @@ public class DarkTabbedPaneScrollLayout extends TabbedPaneScrollLayout {
}
protected void restoreHiddenTabsX(final int minX, final int maxX, final int tabCount) {
if (ui.maxVisible < 0 || ui.maxVisible >= tabCount)
return;
if (ui.maxVisible < 0 || ui.maxVisible >= tabCount) return;
int space = Math.max(maxX - ui.rects[ui.maxVisible].x - ui.rects[ui.maxVisible].width - ui.currentShiftXTmp, 0);
int shift = Math.min(minX - ui.rects[0].x - ui.currentShiftXTmp, space);
shiftTabsX(shift, minX, maxX, tabCount, true);
}
protected void restoreHiddenTabsY(final int minY, final int maxY, final int tabCount) {
if (ui.maxVisible < 0 || ui.maxVisible >= tabCount)
return;
if (ui.maxVisible < 0 || ui.maxVisible >= tabCount) return;
int space =
Math.max(maxY - ui.rects[ui.maxVisible].y - ui.rects[ui.maxVisible].height - ui.currentShiftYTmp, 0);
int shift = Math.min(minY - ui.rects[0].y - ui.currentShiftYTmp, space);

24
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java

@ -242,8 +242,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
protected void paintFocusIndicator(final Graphics g, final int tabPlacement, final Rectangle r, final int tabIndex,
final Rectangle iconRect, final Rectangle textRect, final boolean isSelected) {
if (isSelected) {
if (!drawFocusBar())
return;
if (!drawFocusBar()) return;
g.setColor(getAccentColor());
switch (tabPlacement) {
case LEFT:
@ -355,8 +354,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
@Override
public void setRolloverTab(final int index) {
if (dragging)
return;
if (dragging) return;
int oldRollover = rolloverTabIndex;
super.setRolloverTab(index);
if (oldRollover != getRolloverTab()) {
@ -413,10 +411,8 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
int height =
Math.max(super.calculateTabAreaHeight(tabPlacement, horizRunCount, maxTabHeight), getFallBackSize());
if (isHorizontalTabPlacement()) {
if (leadingComp != null)
height = Math.max(height, leadingComp.getPreferredSize().height);
if (trailingComp != null)
height = Math.max(height, trailingComp.getPreferredSize().height);
if (leadingComp != null) height = Math.max(height, leadingComp.getPreferredSize().height);
if (trailingComp != null) height = Math.max(height, trailingComp.getPreferredSize().height);
}
return height;
}
@ -425,10 +421,8 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
protected int calculateTabAreaWidth(final int tabPlacement, final int vertRunCount, final int maxTabWidth) {
int width = Math.max(super.calculateTabAreaWidth(tabPlacement, vertRunCount, maxTabWidth), getFallBackSize());
if (!isHorizontalTabPlacement()) {
if (leadingComp != null)
width = Math.max(width, leadingComp.getPreferredSize().width);
if (trailingComp != null)
width = Math.max(width, trailingComp.getPreferredSize().width);
if (leadingComp != null) width = Math.max(width, leadingComp.getPreferredSize().width);
if (trailingComp != null) width = Math.max(width, trailingComp.getPreferredSize().width);
}
return width;
}
@ -646,8 +640,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
}
protected Icon getMoreTabsIcon() {
if (moreTabsIcon == null)
moreTabsIcon = UIManager.getIcon("TabbedPane.moreTabs.icon");
if (moreTabsIcon == null) moreTabsIcon = UIManager.getIcon("TabbedPane.moreTabs.icon");
return moreTabsIcon;
}
@ -812,8 +805,7 @@ public class DarkTabbedPaneUI extends DarkTabbedPaneUIBridge {
}
public Icon getNewTabIcon() {
if (newTabIcon == null)
newTabIcon = UIManager.getIcon("TabbedPane.newTab.icon");
if (newTabIcon == null) newTabIcon = UIManager.getIcon("TabbedPane.newTab.icon");
return newTabIcon;
}

12
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java

@ -747,14 +747,10 @@ public abstract class DarkTabbedPaneUIBridge extends TabbedPaneUI implements Swi
// Fix for 6711145 BasicTabbedPanuUI should not throw a NPE if these
// keys are missing. So we are setting them to there default values here
// if the keys are missing.
if (tabInsets == null)
tabInsets = new Insets(0, 4, 1, 4);
if (selectedTabPadInsets == null)
selectedTabPadInsets = new Insets(2, 2, 2, 1);
if (tabAreaInsets == null)
tabAreaInsets = new Insets(3, 2, 0, 2);
if (contentBorderInsets == null)
contentBorderInsets = new Insets(2, 2, 3, 3);
if (tabInsets == null) tabInsets = new Insets(0, 4, 1, 4);
if (selectedTabPadInsets == null) selectedTabPadInsets = new Insets(2, 2, 2, 1);
if (tabAreaInsets == null) tabAreaInsets = new Insets(3, 2, 0, 2);
if (contentBorderInsets == null) contentBorderInsets = new Insets(2, 2, 3, 3);
}
// UI Rendering

3
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java

@ -448,8 +448,7 @@ public abstract class TabbedPaneLayout implements LayoutManager {
protected void rotateTabRuns(final int tabPlacement, final int selectedRun) {
for (int i = 0; i < selectedRun; i++) {
int save = ui.tabRuns[0];
if (ui.runCount - 1 >= 0)
System.arraycopy(ui.tabRuns, 1, ui.tabRuns, 0, ui.runCount - 1);
if (ui.runCount - 1 >= 0) System.arraycopy(ui.tabRuns, 1, ui.tabRuns, 0, ui.runCount - 1);
ui.tabRuns[ui.runCount - 1] = save;
}
}

3
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java

@ -291,8 +291,7 @@ public class TabbedPaneTransferHandler extends TransferHandler implements DropTa
@Override
public DataFlavor[] getTransferDataFlavors() {
if (tabFlavor == null)
return new DataFlavor[0];
if (tabFlavor == null) return new DataFlavor[0];
return new DataFlavor[] {tabFlavor};
}

12
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java

@ -109,8 +109,7 @@ public class TabbedPaneUtil implements SwingConstants {
public static Rectangle getDropRect(final DarkTabbedPaneUI ui, final JTabbedPane destTabbedPane,
final JTabbedPane source, final Point mouseLocation, final Rectangle tabBounds, final int tab,
final int sourceIndex, final int lastTab) {
if (destTabbedPane.getTabCount() == 0)
return new Rectangle(0, 0, 0, 0);
if (destTabbedPane.getTabCount() == 0) return new Rectangle(0, 0, 0, 0);
int tabPlacement = destTabbedPane.getTabPlacement();
Rectangle destRect = destTabbedPane.getBoundsAt(Math.min(tab, destTabbedPane.getTabCount() - 1));
@ -233,14 +232,12 @@ public class TabbedPaneUtil implements SwingConstants {
if (tabbedPane == sourcePane && sourceIndex == tab) {
// Nothing to do. Just select the tab to be sure.
Component comp = sourcePane.getTabComponentAt(tab);
if (comp != null)
comp.setVisible(true);
if (comp != null) comp.setVisible(true);
selectTab(sourcePane, sourceIndex);
return false;
}
int destIndex = tab;
if (tabbedPane.getTabCount() == 0)
destIndex = 0;
if (tabbedPane.getTabCount() == 0) destIndex = 0;
if (destIndex < 0 || destIndex > tabbedPane.getTabCount()) {
return false;
}
@ -256,8 +253,7 @@ public class TabbedPaneUtil implements SwingConstants {
int index = destIndex;
if (tabbedPane == sourcePane) {
if (sourceIndex < index)
index--;
if (sourceIndex < index) index--;
}
tabbedPane.insertTab(tabName, icon, comp, toolTip, index);

15
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java

@ -234,18 +234,15 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
setHeaderBackground(true);
}
} else if (TabFramePopup.KEY_CONTENT.equals(key)) {
if (content == null)
return;
if (content == null) return;
content.add((Component) evt.getNewValue(), BorderLayout.CENTER);
content.invalidate();
} else if (TabFramePopup.KEY_TITLE.equals(key)) {
if (label == null)
return;
if (label == null) return;
label.setText(evt.getNewValue().toString());
label.repaint();
} else if (TabFramePopup.KEY_ICON.equals(key)) {
if (label == null)
return;
if (label == null) return;
label.setIcon((Icon) evt.getNewValue());
label.repaint();
} else if (TabFramePopup.KEY_VISIBLE_TAB.equals(key)) {
@ -358,10 +355,8 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
public void eventDispatched(final AWTEvent event) {
if (event.getID() == FocusEvent.FOCUS_GAINED) {
Component focusOwner = FocusManager.getCurrentManager().getFocusOwner();
if (focusOwner instanceof JTabFrame)
return;
if (focusOwner instanceof JRootPane)
return;
if (focusOwner instanceof JTabFrame) return;
if (focusOwner instanceof JRootPane) return;
boolean focus = DarkUIUtil.hasFocus(popupComponent);
if (popupComponent.getTabFrame() != null) {
Container container =

18
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java

@ -91,11 +91,9 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC
}
protected void installAccelerator(final JTabFrame tabFrame) {
if (tabFrame == null)
return;
if (tabFrame == null) return;
int acc = tabContainer.getAccelerator();
if (acc < 0)
return;
if (acc < 0) return;
tabFrame.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
KeyStroke.getKeyStroke(UIManager.getString("TabFrame.acceleratorKeyCode") + " " + acc),
ACCELERATOR_PREFIX + acc);
@ -148,8 +146,7 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC
}
protected void uninstallAccelerator(final JTabFrame tabFrame) {
if (tabFrame == null)
return;
if (tabFrame == null) return;
int acc = tabContainer.getAccelerator();
String accAction = ACCELERATOR_PREFIX + acc;
tabFrame.getActionMap().remove(accAction);
@ -181,12 +178,10 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC
((Component) newVal).addMouseMotionListener(dragListener);
}
} else if (TabFrameTab.KEY_SELECTED.equals(key)) {
if (tabContainer == null)
return;
if (tabContainer == null) return;
tabContainer.repaint();
} else if (TabFrameTab.KEY_ACCELERATOR.equals(key)) {
if (tabContainer == null)
return;
if (tabContainer == null) return;
uninstallAccelerator(tabContainer.getTabFrame());
installAccelerator(tabContainer.getTabFrame());
} else if (TabFrameTab.KEY_TAB_FRAME_PARENT.equals(key)) {
@ -209,8 +204,7 @@ public class DarkTabFrameTabContainerUI extends DarkPanelUI implements PropertyC
}
public Color getBackground(final TabFrameTabContainer tab) {
if (printing)
return tab.getBackground();
if (printing) return tab.getBackground();
return tab.isSelected() ? selectedColor
: hoverListener.isHover() && !tab.getTabFrame().isInTransfer() ? hoverColor : tab.getBackground();
}

21
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java

@ -50,8 +50,7 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
private final MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (!tabComponent.isEnabled())
return;
if (!tabComponent.isEnabled()) return;
if (SwingUtilities.isLeftMouseButton(e)) {
tabComponent.getTabFrame().toggleTab(tabComponent.getOrientation(), tabComponent.getIndex(),
!tabComponent.isSelected());
@ -143,8 +142,7 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
updateText();
} else if (TabFrameTab.KEY_ACCELERATOR.equals(key)) {
updateText();
if (tabComponent == null)
return;
if (tabComponent == null) return;
uninstallAccelerator(tabComponent.getTabFrame());
installAccelerator(tabComponent.getTabFrame());
} else if (TabFrameTab.KEY_ORIENTATION.equals(key)) {
@ -175,11 +173,9 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
}
protected void installAccelerator(final JTabFrame tabFrame) {
if (tabFrame == null)
return;
if (tabFrame == null) return;
int acc = tabComponent.getAccelerator();
if (acc < 0)
return;
if (acc < 0) return;
tabFrame.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
KeyStroke.getKeyStroke(UIManager.getString("TabFrame.acceleratorKeyCode") + " " + acc),
ACCELERATOR_PREFIX + acc);
@ -207,16 +203,14 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
}
protected void uninstallAccelerator(final JTabFrame tabFrame) {
if (tabFrame == null)
return;
if (tabFrame == null) return;
int acc = tabComponent.getAccelerator();
String accAction = ACCELERATOR_PREFIX + acc;
tabFrame.getActionMap().remove(accAction);
}
public Color getBackground(final TabFrameTabLabel tab) {
if (printing || !tab.isEnabled())
return tab.getBackground();
if (printing || !tab.isEnabled()) return tab.getBackground();
return tab.isSelected() ? selectedColor
: hoverListener.isHover() && !tab.getTabFrame().isInTransfer() ? hoverColor : tab.getBackground();
}
@ -227,8 +221,7 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
}
public Color getTabForeground(final TabFrameTabLabel tab) {
if (printing)
return tab.getForeground();
if (printing) return tab.getForeground();
return tab.isSelected() ? selectedFontColor
: hoverListener.isHover() && !tab.getTabFrame().isInTransfer() ? fontHoverColor : tab.getForeground();
}

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

Loading…
Cancel
Save