diff --git a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java b/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java index 29ef0483..ef841d55 100644 --- a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java +++ b/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; diff --git a/core/src/main/java/com/github/weisj/darklaf/LafManager.java b/core/src/main/java/com/github/weisj/darklaf/LafManager.java index 2d5a260a..f6d81c2c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/LafManager.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java b/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java index 483d1cf1..0f45bbe8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabComponent.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java b/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java index 1e0ce597..f087675d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ClosableTabbedPane.java +++ b/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); } /** diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java b/core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java index 8d01e605..cca91698 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ColorPipetteBase.java +++ b/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(); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java b/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java index cacdf545..27deb34c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/ColoredRadioButton.java +++ b/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(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java b/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java index 363c2904..8760554f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/DefaultButton.java +++ b/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); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java b/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java index 2ec7deeb..81edbc9d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/DefaultColorPipette.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java b/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java index 8a112eae..9edb55c5 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java +++ b/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 diff --git a/core/src/main/java/com/github/weisj/darklaf/components/RotatableIconAnimator.java b/core/src/main/java/com/github/weisj/darklaf/components/RotatableIconAnimator.java index 151142d5..ce968c2c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/RotatableIconAnimator.java +++ b/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(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java b/core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java index 2784c347..06f597a1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java b/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java index 49488b0c..7f98d45e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java b/core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java index 41af31c6..18659071 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java +++ b/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 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); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java b/core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java index 00565224..e9de7906 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/color/QuickColorChooser.java @@ -83,8 +83,7 @@ public class QuickColorChooser extends JPanel { final Supplier supplier, final Supplier 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() { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java b/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java index 62376a46..ea0a212c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java +++ b/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); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTree.java b/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTree.java index 5803c6f0..217e4e2d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTree.java +++ b/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 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()); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeModel.java b/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeModel.java index 619b1fab..a36712ac 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeModel.java +++ b/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(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeNode.java b/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeNode.java index 0a8a02b7..e0471f71 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeNode.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/filetree/FileTreeNode.java @@ -50,10 +50,8 @@ public class FileTreeNode implements TreeNode, Comparable { @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 { private int addSorted(final List 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 { } 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 fileList = children.get(); this.doInBackground(pub -> { taskCount.getAndIncrement(); @@ -131,8 +126,7 @@ public class FileTreeNode implements TreeNode, Comparable { } } }, () -> { - 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 { } 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 { @Override protected void reload(final int depth) { - if (depth < 0) - return; + if (depth < 0) return; List nodes = children.get(); createInitialDirectories().forEach(p -> { FileTreeNode node = model.createNode(this, p); @@ -307,8 +298,7 @@ public class FileTreeNode implements TreeNode, Comparable { 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 diff --git a/core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTree.java b/core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTree.java index 5832b193..12987ad1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTree.java +++ b/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(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTreeModel.java b/core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTreeModel.java index bfe760f7..4b4ec686 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/filetree/WatchFileTreeModel.java +++ b/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(); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/loading/LoadingIndicator.java b/core/src/main/java/com/github/weisj/darklaf/components/loading/LoadingIndicator.java index b466af83..fdb8193c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/loading/LoadingIndicator.java +++ b/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 { diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java index e4a33c0e..ec94a623 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java +++ b/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 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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java index 2e04e425..efa86fa7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java +++ b/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, diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java index 9653b10b..0c7b29d6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java index 665e27f5..c052e8af 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java index 181037ca..3db0417b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabbedPopup.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java b/core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java index 35595d5a..db9d166f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tabframe/ToggleSplitPane.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java b/core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java index 4564a29d..cc73114a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/LineHighlighter.java +++ b/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 diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java b/core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java index 10194a28..53512eec 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/NumberingPane.java +++ b/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 getIconListeners(final int offset) throws BadLocationException { - if (textComponent == null) - return new ArrayList<>(); + if (textComponent == null) return new ArrayList<>(); return getIconListeners(textComponent.getDocument().createPosition(offset)); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java b/core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java index 378e7bcc..c6f134e6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/TextFieldHistoryPopup.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java b/core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java index e84911ca..25445d8f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java @@ -64,8 +64,7 @@ public class JToggleButtonList extends JList { @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); diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java index 5c74c58a..f9c47b8b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java +++ b/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 fallBackPositionProvider) { this.fallBackPositionProvider = fallBackPositionProvider; - if (fallBackPositionProvider == null) - this.fallBackPositionProvider = c -> null; + if (fallBackPositionProvider == null) this.fallBackPositionProvider = c -> null; return this; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java index 8b673e42..05b9239a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipStyle.java +++ b/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; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tree/TristateTreeNode.java b/core/src/main/java/com/github/weisj/darklaf/components/tree/TristateTreeNode.java index 3c2d2f31..9a95c9ca 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tree/TristateTreeNode.java +++ b/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; diff --git a/core/src/main/java/com/github/weisj/darklaf/components/treetable/JTreeTable.java b/core/src/main/java/com/github/weisj/darklaf/components/treetable/JTreeTable.java index 73270e75..4d1c0509 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/treetable/JTreeTable.java +++ b/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 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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/treetable/model/DefaultTreeTableModel.java b/core/src/main/java/com/github/weisj/darklaf/components/treetable/model/DefaultTreeTableModel.java index 0636e11a..bcf80627 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/treetable/model/DefaultTreeTableModel.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/treetable/model/TreeTableNode.java b/core/src/main/java/com/github/weisj/darklaf/components/treetable/model/TreeTableNode.java index 8497a3f2..2b863726 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/treetable/model/TreeTableNode.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java index c254654c..a8e98fa0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateButtonModel.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java index 3ea64dbc..7a11d96d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBox.java +++ b/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(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java b/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java index 5882c645..cb727065 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tristate/TristateCheckBoxMenuItem.java +++ b/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(); diff --git a/core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java b/core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java index 87cc25c6..1a0e4d1c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java +++ b/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) { diff --git a/core/src/main/java/com/github/weisj/darklaf/graphics/GraphicsUtil.java b/core/src/main/java/com/github/weisj/darklaf/graphics/GraphicsUtil.java index 4fea0b51..102e6c95 100644 --- a/core/src/main/java/com/github/weisj/darklaf/graphics/GraphicsUtil.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java b/core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java index 7c425d9a..28b250df 100644 --- a/core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java +++ b/core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java @@ -103,8 +103,7 @@ public class StringPainter { public static 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 { diff --git a/core/src/main/java/com/github/weisj/darklaf/listener/UIUpdater.java b/core/src/main/java/com/github/weisj/darklaf/listener/UIUpdater.java index 14bd1324..96e687d2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/listener/UIUpdater.java +++ b/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); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java b/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java index 59cd0b05..ee9f56b9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/platform/DecorationsHandler.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java b/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java index f2fe3b3f..4c0b401b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/platform/ThemePreferencesHandler.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java index 4abf8a1e..bb44870a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java +++ b/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(); diff --git a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java index 71cda1d3..787ddca9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java +++ b/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 } diff --git a/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java b/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java index 8b09f52e..b66dfc3a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java +++ b/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) diff --git a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java index 9ca47687..18c1687e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java +++ b/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 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; diff --git a/core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java b/core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java index 2dff4ddc..47b1e384 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/UserPreferenceAdjustmentTask.java +++ b/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); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java b/core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java index b4cacdca..b10348fb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java index f317e553..c9db8f05 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java index 543f7983..3057f3c7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java +++ b/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; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java index f8930fd9..b38c2c61 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java index b0526e31..bce5c3a8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java index 356daefb..56bc6bef 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/hint/CellHintPopupListener.java @@ -85,8 +85,7 @@ public class CellHintPopupListener 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 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 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 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 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 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()); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java index a7a560c0..ff4eff25 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java +++ b/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( diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java index 78f70bfa..f138b007 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java +++ b/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(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java index b3aa6815..fa97d20c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkPreviewPanel.java +++ b/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()); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java index 0b24e360..287ab46a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/RecentSwatchPanel.java +++ b/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(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java index 9bb3a602..543d00db 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java +++ b/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 diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java index 8f6f21ea..deb84528 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java +++ b/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(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java index cd9f267e..17d4efe3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java +++ b/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 diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java index ccf1600a..0df8be51 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java index 940895f5..c540bd68 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java +++ b/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(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java index dea511da..4cd5d3e6 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java +++ b/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)) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java index 1325162b..8f3b1aef 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameUI.java +++ b/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(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java index 461e93d4..829ef3db 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java +++ b/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 diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java index 5b2bb0ee..e0d899ac 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java index 7120f206..9f869a85 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuItemUIBase.java +++ b/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 { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java index e3b9be5a..9432ed3b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java +++ b/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(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java index 3a59b16b..69ff66ec 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/MenuItemLayoutDelegate.java +++ b/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(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java index efbdf63d..0e4e8043 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/numberingpane/DarkNumberingPaneUI.java +++ b/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) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java index b1b7782e..27f32252 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/optionpane/DarkOptionPaneBorder.java +++ b/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; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java index 1b9b2ba8..20088faa 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java +++ b/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; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java index 21dc1b9f..7a73e846 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/EventHelperUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/EventHelperUtil.java index 4a67288b..57de9807 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/EventHelperUtil.java +++ b/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(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java index 6251d918..15af8f54 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java +++ b/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) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java index 5f099e56..607979ba 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/PopupMenuContainer.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java index 04b5118c..8f51894c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java +++ b/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; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java index b9d567f7..9faea5e7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java index 68d76dc9..8d583ecc 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java index db4dd024..05b7dd9e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/separator/DarkSeparatorUI.java +++ b/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 { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java index 85859926..93bbed76 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java index 37363140..19c290be 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java +++ b/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 diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java index 5451b4ed..567115a7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DividerStyle.java b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DividerStyle.java index 4cb6d055..6eaa9703 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DividerStyle.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/ThinSplitPaneDivider.java b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/ThinSplitPaneDivider.java index ee164484..2991830a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/ThinSplitPaneDivider.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java index 5fe47181..e71a178a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkScrollableTabSupport.java +++ b/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); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java index 75e374ac..9b4bf4d0 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneHandler.java +++ b/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()); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java index 393f3225..22d8c9bd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneScrollLayout.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java index 3491a710..f6f31384 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUI.java +++ b/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; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java index 149690e6..fce93794 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java +++ b/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 diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java index dd22df31..889e363d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneLayout.java +++ b/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; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java index 9d140d84..88495eae 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneTransferHandler.java +++ b/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}; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java index 6e2bb0cc..d4d1c6d3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/TabbedPaneUtil.java +++ b/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); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java index 162ff6ed..a8a4dcb2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java +++ b/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 = diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java index 8fc5e539..bc9ad8ba 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java +++ b/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(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java index 92981e87..2d68837e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java +++ b/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(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java index b68a0b08..72eaaead 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java @@ -394,40 +394,32 @@ public class DarkTabFrameUI extends TabFrameUI implements AWTEventListener { int threshold = size; int index = -10; if (tabFrame.getTopTabCount() == 0) { - if (layout.isDraggedOver(Alignment.NORTH)) - threshold *= 2; + if (layout.isDraggedOver(Alignment.NORTH)) threshold *= 2; if (p.y < threshold) { a = p.x >= tabFrame.getWidth() / 2 ? Alignment.NORTH_EAST : Alignment.NORTH; } - if (p.y < size) - index = -1; + if (p.y < size) index = -1; } if (a == null && tabFrame.getBottomTabCount() == 0) { - if (layout.isDraggedOver(Alignment.SOUTH)) - threshold *= 2; + if (layout.isDraggedOver(Alignment.SOUTH)) threshold *= 2; if (p.y > tabFrame.getHeight() - threshold) { a = p.x >= tabFrame.getWidth() / 2 ? Alignment.SOUTH : Alignment.SOUTH_WEST; } - if (p.y > tabFrame.getHeight() - size) - index = -1; + if (p.y > tabFrame.getHeight() - size) index = -1; } if (a == null && tabFrame.getLeftTabCount() == 0) { - if (layout.isDraggedOver(Alignment.WEST)) - threshold *= 2; + if (layout.isDraggedOver(Alignment.WEST)) threshold *= 2; if (p.x < threshold) { a = p.y >= tabFrame.getHeight() / 2 ? Alignment.WEST : Alignment.NORTH_WEST; } - if (p.x < size) - index = -1; + if (p.x < size) index = -1; } if (a == null && tabFrame.getRightTabCount() == 0) { - if (layout.isDraggedOver(Alignment.EAST)) - threshold *= 2; + if (layout.isDraggedOver(Alignment.EAST)) threshold *= 2; if (p.x > tabFrame.getWidth() - threshold) { a = p.y >= tabFrame.getHeight() / 2 ? Alignment.SOUTH_EAST : Alignment.EAST; } - if (p.x > tabFrame.getWidth() - size) - index = -1; + if (p.x > tabFrame.getWidth() - size) index = -1; } layout.setDraggedOver(false); if (a != null) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java index 90fcdc69..23595418 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabDragListener.java @@ -55,12 +55,9 @@ public class TabDragListener extends MouseAdapter { @SuppressWarnings("unchecked") @Override public void mouseDragged(final MouseEvent e) { - if (!tabComponent.isEnabled()) - return; - if (origin == null) - origin = e.getPoint(); - if (distance(origin, e.getPoint()) < 100) - return; + if (!tabComponent.isEnabled()) return; + if (origin == null) origin = e.getPoint(); + if (distance(origin, e.getPoint()) < 100) return; TransferHandler th = tabComponent.getTabFrame().getTransferHandler(); if (th != null && tabComponent.getTabFrame().isDndEnabled()) { Point p = e.getPoint(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java index e43c55b4..48aa9b90 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java @@ -80,14 +80,10 @@ public class TabFrameLayout implements LayoutManager { int leftCount = tabFrame.getLeftTabCount(); int rightCount = tabFrame.getRightTabCount(); - if (isDraggedOver(Alignment.NORTH)) - topCount++; - if (isDraggedOver(Alignment.SOUTH)) - bottomCount++; - if (isDraggedOver(Alignment.EAST)) - rightCount++; - if (isDraggedOver(Alignment.WEST)) - leftCount++; + if (isDraggedOver(Alignment.NORTH)) topCount++; + if (isDraggedOver(Alignment.SOUTH)) bottomCount++; + if (isDraggedOver(Alignment.EAST)) rightCount++; + if (isDraggedOver(Alignment.WEST)) leftCount++; ui.getDropComponentBottom().setSize(0, 0); ui.getDropComponentLeft().setSize(0, 0); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java index e8f52486..17db92ff 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java @@ -85,8 +85,7 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg } private TabFrameUI getUI(final Component c) { - if (c instanceof JTabFrame) - return ((JTabFrame) c).getUI(); + if (c instanceof JTabFrame) return ((JTabFrame) c).getUI(); return null; } @@ -345,8 +344,7 @@ public class TabFrameTransferHandler extends TransferHandler implements DropTarg @Override public DataFlavor[] getTransferDataFlavors() { - if (tabFlavor == null) - return new DataFlavor[0]; + if (tabFlavor == null) return new DataFlavor[0]; return new DataFlavor[] {tabFlavor}; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java index b709e811..01403e3d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java @@ -198,16 +198,14 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants { } protected boolean isScrollPaneRtl() { - if (!isInScrollPane()) - return false; + if (!isInScrollPane()) return false; Container comp = DarkUIUtil.getUnwrappedParent(table).getParent(); return !comp.getComponentOrientation().isLeftToRight(); } protected boolean scrollBarVisible() { JScrollPane comp = DarkUIUtil.getParentOfType(JScrollPane.class, table, 2); - if (comp == null) - return false; + if (comp == null) return false; OverlayScrollPane overlayScrollPane = DarkUIUtil.getParentOfType(OverlayScrollPane.class, table, 3); return overlayScrollPane == null && comp.getVerticalScrollBar().isVisible(); } @@ -273,8 +271,7 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants { int tableHeight = getPreferredSize(table).height; g.setColor(parent.getBackground()); int width = vacatedColumnRect.width; - if (draggedColumnIndex < cMax) - width--; + if (draggedColumnIndex < cMax) width--; g.fillRect(vacatedColumnRect.x, 0, width, tableHeight); @@ -309,8 +306,7 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants { } // Left if (dist != 0 || !onLeftEdge) { - if (draggedColumnIndex == cMin && scrollBarVisible() && isScrollPaneRtl()) - x1++; + if (draggedColumnIndex == cMin && scrollBarVisible() && isScrollPaneRtl()) x1++; g.fillRect(x1 - 1, y1, 1, y2 - y1); } // Right @@ -377,13 +373,11 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants { default: break; } - if (table == null) - return false; + if (table == null) return false; KeyStroke stroke = KeyStroke.getKeyStroke(event.getExtendedKeyCode(), event.getModifiersEx()); String actionName = String.valueOf(table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).get(stroke)); - if ("null".equals(actionName)) - actionName = null; + if ("null".equals(actionName)) actionName = null; String cutActionName = String.valueOf(TransferHandler.getCutAction().getValue(Action.NAME)); String copyActionName = String.valueOf(TransferHandler.getCopyAction().getValue(Action.NAME)); return Objects.equals(actionName, copyActionName) || Objects.equals(actionName, cutActionName); @@ -409,10 +403,8 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants { if (isEditorCell) { if (!table.getShowVerticalLines()) { - if (column > cMin) - x--; - if (column > cMin && column < cMax) - w++; + if (column > cMin) x--; + if (column > cMin && column < cMax) w++; } } if (isEditorCell) { @@ -429,8 +421,7 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants { protected TableCellRenderer getCellRenderer(final int row, final int column) { TableCellRenderer renderer = table.getCellRenderer(row, column); - if (renderer instanceof DarkTableCellRendererDelegate) - return renderer; + if (renderer instanceof DarkTableCellRendererDelegate) return renderer; if (rendererDelegate == null) { rendererDelegate = new DarkTableCellRendererDelegate(renderer); } @@ -465,8 +456,7 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants { if (isFileList && SwingUtilities.isLeftMouseButton(e)) { int row = table.rowAtPoint(e.getPoint()); JFileChooser fc = getFileChooser(); - if (row < 0 || fc == null) - return; + if (row < 0 || fc == null) return; int column = getFileNameColumnIndex(); boolean isSelected = table.getSelectionModel().getLeadSelectionIndex() == row && table.getColumnModel().getSelectionModel().getLeadSelectionIndex() == column; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableCellContainer.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableCellContainer.java index 63072d16..3ea83f1c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableCellContainer.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableCellContainer.java @@ -72,8 +72,7 @@ public class TableCellContainer implements IndexedCellContainer position) { - if (position == null) - return null; + if (position == null) return null; int row = position.getFirst(); int column = position.getSecond(); boolean isSelected = table.isCellSelected(row, column); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java index d4e27d01..70aa8443 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java @@ -547,32 +547,27 @@ public abstract class TableUIBridge extends BasicTableUI { @Override public void focusGained(final FocusEvent e) { - if (focusListener != null) - focusListener.focusGained(e); + if (focusListener != null) focusListener.focusGained(e); } @Override public void focusLost(final FocusEvent e) { - if (focusListener != null) - focusListener.focusLost(e); + if (focusListener != null) focusListener.focusLost(e); } @Override public void keyPressed(final KeyEvent e) { - if (keyListener != null) - keyListener.keyPressed(e); + if (keyListener != null) keyListener.keyPressed(e); } @Override public void keyReleased(final KeyEvent e) { - if (keyListener != null) - keyListener.keyReleased(e); + if (keyListener != null) keyListener.keyReleased(e); } @Override public void keyTyped(final KeyEvent e) { - if (keyListener != null) - keyListener.keyTyped(e); + if (keyListener != null) keyListener.keyTyped(e); } public void mouseClicked(final MouseEvent e) {} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderUI.java index dc5d2d34..ef9003a8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderUI.java @@ -285,8 +285,7 @@ public class DarkTableHeaderUI extends BasicTableHeaderUI { } protected boolean isScrollPaneRtl() { - if (!isInScrollPane()) - return false; + if (!isInScrollPane()) return false; Container comp = DarkUIUtil.getUnwrappedParent(header).getParent(); return !comp.getComponentOrientation().isLeftToRight(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java index 902f9fe1..18aaa63d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java @@ -68,12 +68,10 @@ public class DarkTableCellEditorDelegate extends TableCellEditorDelegate { @Override public boolean isCellEditable(final EventObject anEvent) { - if (anEvent == null) - return super.isCellEditable(null); + if (anEvent == null) return super.isCellEditable(null); JTable table = ((JTable) anEvent.getSource()); if (anEvent instanceof KeyEvent) { - if (DarkTableUI.ignoreKeyCodeOnEdit((KeyEvent) anEvent, table)) - return false; + if (DarkTableUI.ignoreKeyCodeOnEdit((KeyEvent) anEvent, table)) return false; } if (TableConstants.isBooleanRenderingEnabled(table)) { if (anEvent instanceof MouseEvent && isMouseOverBooleanRenderer((MouseEvent) anEvent, table)) { @@ -138,8 +136,7 @@ public class DarkTableCellEditorDelegate extends TableCellEditorDelegate { } if (editorComponent instanceof JTextField) { int alignment = getHorizontalAlignment(rendererComp); - if (alignment >= 0) - ((JTextField) editorComponent).setHorizontalAlignment(alignment); + if (alignment >= 0) ((JTextField) editorComponent).setHorizontalAlignment(alignment); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/IconWrapper.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/IconWrapper.java index faf537c6..802a7448 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/IconWrapper.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/IconWrapper.java @@ -57,8 +57,7 @@ public class IconWrapper extends JPanel { @Override public void doLayout() { - if (c == null) - return; + if (c == null) return; int w = getWidth(); int h = getHeight(); Border b = c.getBorder(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneUI.java index 78950b26..14602285 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/taskpane/DarkTaskPaneUI.java @@ -89,8 +89,7 @@ public class DarkTaskPaneUI extends MetalTaskPaneUI { } protected boolean isCollapsed() { - if (!group.isAnimated()) - return group.isCollapsed(); + if (!group.isAnimated()) return group.isCollapsed(); return isCollapsed; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java index 105492fd..58661205 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkCaret.java @@ -100,8 +100,7 @@ public class DarkCaret extends DefaultCaret implements UIResource { private boolean isEndOfLine(final JTextComponent target, final int dot) { Document doc = target.getDocument(); - if (dot >= doc.getLength()) - return true; + if (dot >= doc.getLength()) return true; try { return target.getText(dot, 1).equals("\n"); } catch (BadLocationException e) { @@ -188,8 +187,8 @@ public class DarkCaret extends DefaultCaret implements UIResource { } public enum CaretStyle { - VERTICAL_LINE_STYLE(1, false), UNDERLINE_STYLE(1, true), BLOCK_STYLE(1, true), BLOCK_BORDER_STYLE(1, - true), THICK_VERTICAL_LINE_STYLE(2, false); + VERTICAL_LINE_STYLE(1, false), UNDERLINE_STYLE(1, true), BLOCK_STYLE(1, true), BLOCK_BORDER_STYLE(1, true), + THICK_VERTICAL_LINE_STYLE(2, false); private final int size; private final boolean charWidth; @@ -425,8 +424,7 @@ public class DarkCaret extends DefaultCaret implements UIResource { protected boolean isPositionLTR(int position, final Position.Bias bias) { Document doc = getComponent().getDocument(); - if (bias == Position.Bias.Backward && --position < 0) - position = 0; + if (bias == Position.Bias.Backward && --position < 0) position = 0; return isLeftToRight(doc, position, position); } @@ -503,8 +501,7 @@ public class DarkCaret extends DefaultCaret implements UIResource { dot = Math.max(dot, 0); // The position (0,Backward) is out of range so disallow it. - if (dot == 0) - dotBias = Position.Bias.Forward; + if (dot == 0) dotBias = Position.Bias.Forward; dotLtr = isPositionLTR(d, dotBias); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java index 9c87246d..1bb40b59 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java @@ -95,8 +95,7 @@ public class DarkFormattedTextFieldUI extends DarkTextFieldUI implements Propert public void changedUpdate(final DocumentEvent e) {} protected void update() { - if (textField == null) - return; + if (textField == null) return; textField.putClientProperty(DarkTextUI.KEY_HAS_ERROR, !isInputValid(textField)); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java index f0d6576c..65bfe292 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java @@ -120,8 +120,7 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge { @Override public void mouseClicked(final MouseEvent e) { - if (hasShowIcon(getComponent())) - return; + if (hasShowIcon(getComponent())) return; super.mouseClicked(e); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java index ad97ea82..ff97de52 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java @@ -70,8 +70,7 @@ public class DarkTextBorder implements Border, UIResource { searchArc = UIManager.getInt("TextField.searchArc"); searchFocusArc = UIManager.getInt("TextField.searchFocusArc"); padding = UIManager.getInsets("TextField.insets"); - if (padding == null) - padding = new Insets(0, 0, 0, 0); + if (padding == null) padding = new Insets(0, 0, 0, 0); } protected static boolean hasError(final Component c) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java index a49c09e3..4f6f2e86 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java @@ -158,14 +158,12 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh boolean ltr = c.getComponentOrientation().isLeftToRight(); if (doPaintLeftIcon(c)) { int w = getLeftIcon(c).getIconWidth() + padding.left; - if (ltr) - r.x += w; + if (ltr) r.x += w; r.width -= w; } if (doPaintRightIcon(c)) { int w = getRightIcon(c).getIconWidth() + padding.right; - if (!ltr) - r.x += w; + if (!ltr) r.x += w; r.width -= w; } } @@ -193,8 +191,7 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh protected ClickAction getActionUnder(final Point p) { JTextComponent c = getComponent(); - if (!c.isEnabled()) - return ClickAction.NONE; + if (!c.isEnabled()) return ClickAction.NONE; if (isOver(getRightIconCoord(), getRightIcon(c), p) && doPaintRightIcon(c)) { return ClickAction.RIGHT_ACTION; } @@ -230,10 +227,8 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh protected void paintIcons(final Graphics g) { JTextComponent c = getComponent(); - if (doPaintLeftIcon(c)) - paintLeftIcon(g); - if (doPaintRightIcon(c)) - paintRightIcon(g); + if (doPaintLeftIcon(c)) paintLeftIcon(g); + if (doPaintRightIcon(c)) paintRightIcon(g); } protected boolean doPaintLeftIcon(final JTextComponent c) { @@ -297,8 +292,7 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh search = UIManager.getIcon("TextField.search.search.icon"); searchDisabled = UIManager.getIcon("TextField.search.search.disabled.icon"); padding = UIManager.getInsets("TextField.insets"); - if (padding == null) - padding = new Insets(0, 0, 0, 0); + if (padding == null) padding = new Insets(0, 0, 0, 0); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java index 1808a9cf..39b0e9d9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java @@ -78,8 +78,7 @@ public abstract class DarkTextUI extends BasicTextUI } protected DarkCaret getDarkCaret() { - if (darkCaret == null) - darkCaret = createDarkCaret(); + if (darkCaret == null) darkCaret = createDarkCaret(); return darkCaret; } @@ -117,8 +116,7 @@ public abstract class DarkTextUI extends BasicTextUI } public static boolean isBorderlessTextField(final JTextComponent textComponent) { - if (textComponent == null) - return false; + if (textComponent == null) return false; String className = textComponent.getClass().getName(); return "javax.swing.plaf.basic.BasicComboBoxEditor$BorderlessTextField".equals(className); } @@ -146,12 +144,10 @@ public abstract class DarkTextUI extends BasicTextUI // OpenJDK BorderlessTextField has a bug with its setBorder implementation // so we reset the border // See https://mail.openjdk.java.net/pipermail/swing-dev/2020-March/010226.html - if (editor.getBorder() != null) - editor.setBorder(null); + if (editor.getBorder() != null) editor.setBorder(null); return; } - if (uninstalling) - return; + if (uninstalling) return; MarginBorderWrapper.installBorder(editor); } @@ -277,16 +273,14 @@ public abstract class DarkTextUI extends BasicTextUI } else if (border != null) { ins = border.getBorderInsets(editor); } - if (ins == null) - ins = new Insets(0, 0, 0, 0); + if (ins == null) ins = new Insets(0, 0, 0, 0); g.fillRect(ins.left, ins.top, editor.getWidth() - ins.left - ins.right, editor.getHeight() - ins.top - ins.bottom); } } protected boolean isInCell(final JComponent c) { - if (getBorder(c) instanceof DarkTextBorder) - return false; + if (getBorder(c) instanceof DarkTextBorder) return false; return DarkUIUtil.getParentOfType(JSpinner.class, c, 2) != null || DarkUIUtil.isInCell(c) || PropertyUtil.getBooleanProperty(c, KEY_IS_TREE_EDITOR) || PropertyUtil.getBooleanProperty(c, KEY_IS_TABLE_EDITOR) @@ -297,8 +291,7 @@ public abstract class DarkTextUI extends BasicTextUI Container parent = comp.getParent(); if (parent instanceof JSpinner.DefaultEditor) { JSpinner spinner = DarkUIUtil.getParentOfType(JSpinner.class, comp, 2); - if (spinner != null) - parent = spinner.getParent(); + if (spinner != null) parent = spinner.getParent(); } else if (parent instanceof JComboBox) { parent = parent.getParent(); } @@ -350,8 +343,7 @@ public abstract class DarkTextUI extends BasicTextUI } protected DefaultTextRenderer getDefaultTextRenderer() { - if (defaultTextRenderer == null) - defaultTextRenderer = createDefaultTextRenderer(); + if (defaultTextRenderer == null) defaultTextRenderer = createDefaultTextRenderer(); return defaultTextRenderer; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/action/DarkTextAction.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/action/DarkTextAction.java index 0486ad3b..ff5c6aad 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/action/DarkTextAction.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/action/DarkTextAction.java @@ -39,8 +39,7 @@ public abstract class DarkTextAction extends TextAction { } protected void setupDeleteMode(final JTextComponent textComponent, final boolean isDeleteMode) { - if (textComponent == null) - return; + if (textComponent == null) return; Caret c = textComponent.getCaret(); if (c instanceof DarkCaret) { ((DarkCaret) c).setExpandMode(isDeleteMode); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyEditorPane.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyEditorPane.java index 6c90b51c..2334c33b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyEditorPane.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyEditorPane.java @@ -59,29 +59,25 @@ public class DummyEditorPane extends JEditorPane { @Override public Document getDocument() { - if (editorPane == null) - return super.getDocument(); + if (editorPane == null) return super.getDocument(); return editorPane.getDocument(); } @Override public Font getFont() { - if (editorPane == null) - return null; + if (editorPane == null) return null; return editorPane.getFont(); } @Override public Color getForeground() { - if (editorPane == null) - return null; + if (editorPane == null) return null; return editorPane.getForeground(); } @Override public Color getBackground() { - if (editorPane == null) - return null; + if (editorPane == null) return null; return editorPane.getBackground(); } @@ -143,8 +139,7 @@ public class DummyEditorPane extends JEditorPane { public void setLayout(final LayoutManager mgr) { if (mgr instanceof DocumentListener) { Document doc = getDocument(); - if (doc != null) - doc.removeDocumentListener((DocumentListener) mgr); + if (doc != null) doc.removeDocumentListener((DocumentListener) mgr); } } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextArea.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextArea.java index 4b0535ca..9f1971cb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextArea.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextArea.java @@ -89,8 +89,7 @@ public class DummyTextArea extends JTextArea { public void setLayout(final LayoutManager mgr) { if (mgr instanceof DocumentListener) { Document doc = getDocument(); - if (doc != null) - doc.removeDocumentListener((DocumentListener) mgr); + if (doc != null) doc.removeDocumentListener((DocumentListener) mgr); } } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextComponent.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextComponent.java index 8f7303f6..f59fa736 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextComponent.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextComponent.java @@ -90,8 +90,7 @@ public class DummyTextComponent extends JTextComponent { public void setLayout(final LayoutManager mgr) { if (mgr instanceof DocumentListener) { Document doc = getDocument(); - if (doc != null) - doc.removeDocumentListener((DocumentListener) mgr); + if (doc != null) doc.removeDocumentListener((DocumentListener) mgr); } } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/CopyMenuItem.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/CopyMenuItem.java index f2d509de..d3ea2336 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/CopyMenuItem.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/CopyMenuItem.java @@ -45,8 +45,7 @@ public class CopyMenuItem extends EditMenuItem { @Override public void actionPerformed(final ActionEvent e) { - if (editor != null) - editor.copy(); + if (editor != null) editor.copy(); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/CutMenuItem.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/CutMenuItem.java index 52166448..01326b54 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/CutMenuItem.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/CutMenuItem.java @@ -46,7 +46,6 @@ public class CutMenuItem extends CopyMenuItem { @Override public void actionPerformed(final ActionEvent e) { - if (editor != null) - editor.cut(); + if (editor != null) editor.cut(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/PasteMenuItem.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/PasteMenuItem.java index 730c40a9..f8212b56 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/PasteMenuItem.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/popup/PasteMenuItem.java @@ -46,7 +46,6 @@ public class PasteMenuItem extends EditMenuItem { @Override public void actionPerformed(final ActionEvent e) { - if (editor != null) - editor.paste(); + if (editor != null) editor.paste(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonKeyHandler.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonKeyHandler.java index 8fcfb6a3..10603d56 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonKeyHandler.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonKeyHandler.java @@ -38,13 +38,11 @@ public class DarkToggleButtonKeyHandler implements KeyListener { if (stroke != null && e.getSource() instanceof AbstractButton) { AbstractButton source = (AbstractButton) e.getSource(); ButtonModel model = source.getModel(); - if (!(model instanceof DefaultButtonModel)) - model = null; + if (!(model instanceof DefaultButtonModel)) model = null; DefaultButtonModel bm = model != null ? (DefaultButtonModel) model : null; ButtonGroup group = bm != null ? bm.getGroup() : null; - if (group == null || group.getButtonCount() == 0) - group = null; + if (group == null || group.getButtonCount() == 0) group = null; KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Container comp = group != null ? group.getElements().nextElement() : source; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonUI.java index 34633e28..70fcecba 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonUI.java @@ -139,8 +139,7 @@ public class DarkToggleButtonUI extends DarkButtonUI implements ToggleButtonCons boolean clicked = b.getModel().isArmed(); boolean isSelected = b.isSelected(); if (b.isEnabled()) { - if (isSelected) - return PropertyUtil.chooseColor(b.getBackground(), background); + if (isSelected) return PropertyUtil.chooseColor(b.getBackground(), background); if (clicked) { return clickBackground; } else if (rollOver) { @@ -235,8 +234,7 @@ public class DarkToggleButtonUI extends DarkButtonUI implements ToggleButtonCons @Override public boolean contains(final JComponent c, final int x, final int y) { - if (!ToggleButtonConstants.isSlider(c)) - return super.contains(c, x, y); + if (!ToggleButtonConstants.isSlider(c)) return super.contains(c, x, y); if ((hitArea.isEmpty()) && c instanceof JToggleButton) { JToggleButton b = (JToggleButton) c; layoutSlider(b, b.getFontMetrics(layoutDelegate.getFont()), b.getWidth(), b.getHeight()); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonFocusNavigationActions.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonFocusNavigationActions.java index ae920c72..8326c7c3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonFocusNavigationActions.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/ToggleButtonFocusNavigationActions.java @@ -39,8 +39,7 @@ public class ToggleButtonFocusNavigationActions { } public void installActions() { - if (button == null) - return; + if (button == null) return; traversalKeysEnabled = button.getFocusTraversalKeysEnabled(); button.setFocusTraversalKeysEnabled(false); button.addKeyListener(keyListener); @@ -55,8 +54,7 @@ public class ToggleButtonFocusNavigationActions { } public void uninstallActions() { - if (button == null) - return; + if (button == null) return; if (!button.getFocusTraversalKeysEnabled()) { button.setFocusTraversalKeysEnabled(traversalKeysEnabled); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java index 3c359518..5081411e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java @@ -37,8 +37,7 @@ import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonMenuItemConstants; public class DarkRadioButtonMenuItemUI extends DarkMenuItemUIBase implements ToggleButtonMenuItemConstants { private final MouseClickListener clickListener = e -> SwingUtilities.invokeLater(() -> { - if (menuItem != null) - menuItem.setArmed(true); + if (menuItem != null) menuItem.setArmed(true); }); protected MenuItemLayoutDelegate layoutDelegate = new ToggleButtonMenuItemLayoutDelegate(null); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarBorder.java index 758408cb..508f0bbb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarBorder.java @@ -93,8 +93,7 @@ public class DarkToolBarBorder extends AbstractBorder implements UIResource, Swi if (parent instanceof JComponent && ((JComponent) parent).getLayout() instanceof BorderLayout) { BorderLayout layout = (BorderLayout) ((JComponent) parent).getLayout(); Object constraints = layout.getConstraints(c); - if (constraints != null) - return constraints.toString(); + if (constraints != null) return constraints.toString(); } } return ""; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUI.java index 1dae9d2a..0a08b9b2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/toolbar/DarkToolBarUI.java @@ -94,10 +94,8 @@ public class DarkToolBarUI extends BasicToolBarUI { boolean visible = false; Window ancestor = SwingUtilities.getWindowAncestor(toolBar); - if (ancestor != null) - visible = ancestor.isVisible(); - if (dragWindow != null) - stopDrag(); + if (ancestor != null) visible = ancestor.isVisible(); + if (dragWindow != null) stopDrag(); floating = b; RootPaneContainer floatingTB = getFloatingToolBar(); @@ -123,13 +121,11 @@ public class DarkToolBarUI extends BasicToolBarUI { } } } else { - if (floatingTB instanceof Window) - ((Window) floatingTB).setVisible(false); + if (floatingTB instanceof Window) ((Window) floatingTB).setVisible(false); floatingTB.getContentPane().remove(toolBar); String constraint = getDockingConstraint(dockingSource, p); - if (constraint == null) - constraint = BorderLayout.NORTH; + if (constraint == null) constraint = BorderLayout.NORTH; setOrientation(mapConstraintToOrientation(constraint)); dockingSource.add(toolBar, constraint); updateDockingSource(dockingSource); @@ -179,8 +175,7 @@ public class DarkToolBarUI extends BasicToolBarUI { } protected String getDockingConstraint(final Component c, final Point p) { - if (p == null) - return constraintBeforeFloating; + if (p == null) return constraintBeforeFloating; if (c.contains(p)) { if (p.y < horizontalDim.height && isDockable(c, BorderLayout.NORTH)) { return BorderLayout.NORTH; @@ -214,8 +209,7 @@ public class DarkToolBarUI extends BasicToolBarUI { DarkDragWindow dw = getDragWindow(); Point offset = dw.getOffset(); PointerInfo pointerInfo = MouseInfo.getPointerInfo(); - if (pointerInfo == null) - return; + if (pointerInfo == null) return; Point global = pointerInfo.getLocation(); Point dragPoint = new Point(global.x - offset.x, global.y - offset.y); @@ -244,8 +238,7 @@ public class DarkToolBarUI extends BasicToolBarUI { @Override public void setOrientation(final int orientation) { toolBar.setOrientation(orientation); - if (dragWindow != null) - dragWindow.setOrientation(orientation); + if (dragWindow != null) dragWindow.setOrientation(orientation); } protected int mapConstraintToOrientation(final String constraint) { @@ -296,8 +289,7 @@ public class DarkToolBarUI extends BasicToolBarUI { } public RootPaneContainer getFloatingToolBar() { - if (floatingToolBar == null) - floatingToolBar = createFloatingWindow(toolBar); + if (floatingToolBar == null) floatingToolBar = createFloatingWindow(toolBar); return floatingToolBar; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java index 432d1487..b5696ec4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java @@ -63,8 +63,7 @@ public class DarkToolTipUI extends BasicToolTipUI protected final MouseListener mouseListener = new MouseAdapter() { @Override public void mouseEntered(final MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1) - return; + if (e.getButton() == MouseEvent.BUTTON1) return; /* * We redispatch the event to the ToolTipManager with a corrected location. Because the * ToolTipManager check for outside using >= width/height instead of > width/height and due to the @@ -73,10 +72,8 @@ public class DarkToolTipUI extends BasicToolTipUI */ Point p = e.getPoint(); Component c = toolTip.getComponent(); - if (p.x == c.getWidth()) - p.x--; - if (p.y == c.getHeight()) - p.y--; + if (p.x == c.getWidth()) p.x--; + if (p.y == c.getHeight()) p.y--; p.x = Math.max(p.x, 0); p.y = Math.max(p.y, 0); ToolTipManager.sharedInstance().mouseEntered(new MouseEvent(c, e.getID(), e.getWhen(), e.getModifiersEx(), @@ -345,8 +342,7 @@ public class DarkToolTipUI extends BasicToolTipUI protected void updateTipText(final JToolTip tooltip) { effectiveTipText = tooltip.getTipText(); - if (effectiveTipText == null) - effectiveTipText = ""; + if (effectiveTipText == null) effectiveTipText = ""; } protected void scheduleAnimation() { @@ -361,10 +357,8 @@ public class DarkToolTipUI extends BasicToolTipUI JComponent comp = toolTip.getComponent(); ToolTipStyle style = comp != null ? ToolTipStyle.parse(comp.getClientProperty(KEY_STYLE)) : null; ToolTipStyle tooltipStyle = ToolTipStyle.parse(toolTip.getClientProperty(KEY_STYLE)); - if (style == null) - style = tooltipStyle; - if (style == null) - style = ToolTipStyle.parse(UIManager.get("ToolTip.defaultStyle")); + if (style == null) style = tooltipStyle; + if (style == null) style = ToolTipStyle.parse(UIManager.get("ToolTip.defaultStyle")); if (style != tooltipStyle) { toolTip.putClientProperty(KEY_STYLE, style); } @@ -407,8 +401,7 @@ public class DarkToolTipUI extends BasicToolTipUI public void paintNow(final int frame, final int totalFrames, final int cycle) { alpha = ((float) frame * MAX_ALPHA) / totalFrames; Window window = SwingUtilities.getWindowAncestor(toolTip); - if (window != null) - window.setOpacity(alpha); + if (window != null) window.setOpacity(alpha); Border border = toolTip.getBorder(); if (border instanceof DarkTooltipBorder) { ((DarkTooltipBorder) border).setSkipShadow(false); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java index 402f84e7..44d24172 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java @@ -49,8 +49,7 @@ public class DarkTooltipBorder implements Border, AlignableTooltipBorder { public DarkTooltipBorder() { margin = UIManager.getInsets("ToolTip.borderInsets"); - if (margin == null) - margin = new Insets(0, 0, 0, 0); + if (margin == null) margin = new Insets(0, 0, 0, 0); bubbleBorder = new BubbleBorder(UIManager.getColor("ToolTip.borderColor")); bubbleBorder.setThickness(1); bubbleBorder.setPointerSize(8); @@ -75,14 +74,12 @@ public class DarkTooltipBorder implements Border, AlignableTooltipBorder { @Override public int getPointerOffset(final Component c, final Dimension dimension, final int thicknessFactor) { - if (!showPointer || isPlain(c)) - return 0; + if (!showPointer || isPlain(c)) return 0; int offset = (int) bubbleBorder.getOffset(dimension.width - 2 * shadowBorder.getShadowSize(), dimension.height) + shadowBorder.getShadowSize(); int thickness = bubbleBorder.getThickness(); Alignment align = bubbleBorder.getPointerSide(); - if (align.isWest(false)) - offset += thicknessFactor * thickness; + if (align.isWest(false)) offset += thicknessFactor * thickness; return offset; } @@ -110,8 +107,7 @@ public class DarkTooltipBorder implements Border, AlignableTooltipBorder { @Override public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { - if (c instanceof JToolTip && ((JToolTip) c).getTipText() == null) - return; + if (c instanceof JToolTip && ((JToolTip) c).getTipText() == null) return; GraphicsContext context = new GraphicsContext(g); if (isPlain(c)) { g.setColor(bubbleBorder.getColor()); @@ -190,15 +186,13 @@ public class DarkTooltipBorder implements Border, AlignableTooltipBorder { } protected boolean isPlain(final Component c) { - if (!(c instanceof JComponent)) - return false; + if (!(c instanceof JComponent)) return false; Object prop = ((JComponent) c).getClientProperty(DarkToolTipUI.KEY_STYLE); return prop == ToolTipStyle.PLAIN || DarkToolTipUI.VARIANT_PLAIN.equals(prop); } public int getShadowSize(final Component c) { - if (isPlain(c)) - return 0; + if (isPlain(c)) return 0; return shadowBorder.getShadowSize(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java index ed11de44..205a541d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java @@ -36,12 +36,10 @@ public class ToolTipUtil { public static void applyContext(final JToolTip toolTip) { JComponent target = toolTip.getComponent(); - if (target == null) - return; + if (target == null) return; ToolTipContext context = getToolTipContext(toolTip); - if (context == null) - return; + if (context == null) return; context.setTarget(target); context.setToolTip(toolTip); @@ -109,12 +107,10 @@ public class ToolTipUtil { if ((centerHorizontally || centerVertically) && a.isDiagonal()) { pos = tryPosition(a, context, p, tooltipBounds, boundary, screenBoundary, setter, centerHorizontally, centerVertically); - if (pos != null) - break; + if (pos != null) break; } pos = tryPosition(a, context, p, tooltipBounds, boundary, screenBoundary, setter, false, false); - if (pos != null) - break; + if (pos != null) break; } return pos; } @@ -138,8 +134,7 @@ public class ToolTipUtil { Point screenPos = new Point(pos.x, pos.y); SwingUtilities.convertPointToScreen(screenPos, context.getTarget()); tooltipBounds.setLocation(screenPos); - if (!fits(tooltipBounds, boundary, screenBoundary)) - pos = null; + if (!fits(tooltipBounds, boundary, screenBoundary)) pos = null; return pos; } @@ -170,8 +165,7 @@ public class ToolTipUtil { public static void moveToolTip(final JToolTip toolTip, final int x, final int y, final JComponent target) { Window window = DarkUIUtil.getWindow(toolTip); - if (window == null) - return; + if (window == null) return; Point p = new Point(x, y); SwingUtilities.convertPointToScreen(p, target); WindowUtil.moveWindow(window, toolTip, p.x, p.y); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkDefaultTreeEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkDefaultTreeEditor.java index 57b2fd20..ae6a5149 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkDefaultTreeEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkDefaultTreeEditor.java @@ -142,8 +142,7 @@ public class DarkDefaultTreeEditor extends DefaultTreeCellEditor { protected Object getValue(final JTree tree, final int row) { TreePath path = tree.getPathForRow(row); - if (path == null) - return false; + if (path == null) return false; return DarkTreeCellRendererDelegate.unwrapValue(path.getLastPathComponent()); } @@ -196,22 +195,19 @@ public class DarkDefaultTreeEditor extends DefaultTreeCellEditor { protected DarkTreeCellRendererDelegate getRendererDelegate(final JTree tree) { DarkTreeUI ui = DarkUIUtil.getUIOfType(tree.getUI(), DarkTreeUI.class); - if (ui == null) - return null; + if (ui == null) return null; return DarkUIUtil.nullableCast(DarkTreeCellRendererDelegate.class, ui.getCellRenderer()); } protected JComponent getBooleanRendererComponent(final JTree tree) { DarkTreeCellRendererDelegate rend = getRendererDelegate(tree); - if (rend == null) - return null; + if (rend == null) return null; return rend.getBooleanRenderer(tree).getButton(); } protected JComponent getTristateRendererComponent(final JTree tree) { DarkTreeCellRendererDelegate rend = getRendererDelegate(tree); - if (rend == null) - return null; + if (rend == null) return null; return rend.getTristateRenderer(tree).getButton(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java index cf95392c..64a2ee11 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java @@ -95,14 +95,12 @@ public class DarkTreeCellEditor extends DefaultCellEditor implements TreeCellEdi comboBox.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(final PopupMenuEvent e) { - if (tree != null) - tree.repaint(); + if (tree != null) tree.repaint(); } @Override public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) { - if (tree != null) - tree.repaint(); + if (tree != null) tree.repaint(); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java index ba5db3eb..9647cb39 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java @@ -139,8 +139,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C collapsed = UIManager.getIcon("Tree.collapsed.unselected.unfocused.icon"); collapsedDisabled = UIManager.getIcon("Tree.collapsed.disabled.icon"); leadSelectionBorderInsets = UIManager.getInsets("Tree.leadSelectionBorderInsets"); - if (leadSelectionBorderInsets == null) - leadSelectionBorderInsets = new Insets(1, 1, 1, 1); + if (leadSelectionBorderInsets == null) leadSelectionBorderInsets = new Insets(1, 1, 1, 1); PropertyUtil.installBooleanProperty(tree, KEY_RENDER_BOOLEAN_AS_CHECKBOX, "Tree.renderBooleanAsCheckBox"); PropertyUtil.installProperty(tree, KEY_BOOLEAN_RENDER_TYPE, UIManager.getString("Tree.booleanRenderType")); PropertyUtil.installProperty(tree, KEY_LINE_STYLE, UIManager.getString("Tree.defaultLineStyle")); @@ -296,15 +295,13 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C protected boolean paintSingleRow(final Graphics g, final Rectangle paintBounds, final Insets insets, final TreePath path, final int row) { - if (path == null) - return false; + if (path == null) return false; final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport) tree.getParent()).getViewPosition().x : 0; final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth(); final Rectangle cellBounds = getPathBounds(path, insets, boundsBuffer); - if (cellBounds == null) - return false; + if (cellBounds == null) return false; final int boundsX = cellBounds.x; final int boundsWidth = cellBounds.width; @@ -352,8 +349,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C */ protected void paintVerticalLegs(final Graphics g, final Rectangle clipBounds, final Rectangle rowBounds, final Insets insets, final TreePath path) { - if (!shouldPaintLines()) - return; + if (!shouldPaintLines()) return; int depth = path.getPathCount() - 1; if (depth == 0 && (!isRootVisible() || !getShowsRootHandles())) { // Parent is the root, which isn't visible. @@ -364,8 +360,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C TreePath parentPath = path; for (int currentDepth = depth - 1; currentDepth >= 0; currentDepth--) { - if (currentDepth == 0 && !isRootVisible()) - continue; + if (currentDepth == 0 && !isRootVisible()) continue; int lineX = getRowX(-1, currentDepth); if (tree.getComponentOrientation().isLeftToRight()) { @@ -374,8 +369,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C lineX = tree.getWidth() - lineX - insets.right + getRightChildIndent() - 1; } - if (lineX > clipRight || lineX < clipLeft) - continue; + if (lineX > clipRight || lineX < clipLeft) continue; parentPath = parentPath.getParentPath(); g.setColor(getLineColor(parentPath)); @@ -411,8 +405,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C @Override public void update(final Graphics g, final JComponent c) { - if (popupListener != null) - popupListener.repaint(); + if (popupListener != null) popupListener.repaint(); super.update(g, c); } @@ -445,8 +438,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C } protected Icon getExpandedIcon(final boolean selected, final boolean focused) { - if (!tree.isEnabled()) - return expandedDisabled; + if (!tree.isEnabled()) return expandedDisabled; if (selected) { return focused ? expandedFocusSelected : expandedSelected; } else { @@ -455,8 +447,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C } protected Icon getCollapsedIcon(final boolean selected, final boolean focused) { - if (!tree.isEnabled()) - return collapsedDisabled; + if (!tree.isEnabled()) return collapsedDisabled; if (selected) { return focused ? collapsedFocusSelected : collapsedSelected; } else { @@ -470,15 +461,11 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C protected boolean isChildOfSelectionPath(final TreePath path) { TreePath p = tree.isEditing() ? tree.getEditingPath() : tree.getSelectionPath(); - if (p == null) - return false; - if (Objects.equals(p, path)) - return true; - if (tree.isExpanded(p)) - return false; + if (p == null) return false; + if (Objects.equals(p, path)) return true; + if (tree.isExpanded(p)) return false; TreePath parent = p.getParentPath(); - if (parent == null) - return false; + if (parent == null) return false; return Objects.equals(parent.getLastPathComponent(), path.getLastPathComponent()); } @@ -533,12 +520,10 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C if (isExpanded) { Icon expandedIcon = getExpandedIcon(); - if (expandedIcon != null) - drawCentered(tree, g, expandedIcon, iconCenterX, iconCenterY); + if (expandedIcon != null) drawCentered(tree, g, expandedIcon, iconCenterX, iconCenterY); } else { Icon collapsedIcon = getCollapsedIcon(); - if (collapsedIcon != null) - drawCentered(tree, g, collapsedIcon, iconCenterX, iconCenterY); + if (collapsedIcon != null) drawCentered(tree, g, collapsedIcon, iconCenterX, iconCenterY); } } } @@ -588,16 +573,14 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C protected static boolean isLeaf(final JTree tree, final int row) { TreePath path = tree.getPathForRow(row); - if (path != null) - return tree.getModel().isLeaf(path.getLastPathComponent()); + if (path != null) return tree.getModel().isLeaf(path.getLastPathComponent()); return true; } protected abstract static class TreeUIAction extends AbstractAction implements UIResource { protected static void installActions(final JTree tree) { - if (PropertyUtil.getBooleanProperty(tree, KEY_MAC_ACTIONS_INSTALLED)) - return; + if (PropertyUtil.getBooleanProperty(tree, KEY_MAC_ACTIONS_INSTALLED)) return; tree.putClientProperty(KEY_MAC_ACTIONS_INSTALLED, Boolean.TRUE); @@ -608,11 +591,9 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C @Override public void actionPerformed(final ActionEvent e) { JTree tree = getTree(e); - if (tree == null) - return; + if (tree == null) return; int selectionRow = tree.getLeadSelectionRow(); - if (selectionRow == -1) - return; + if (selectionRow == -1) return; if (isLeaf(tree, selectionRow) || tree.isExpanded(selectionRow)) { if (!PropertyUtil.getBooleanProperty(tree, KEY_IS_TABLE_TREE)) { @@ -633,11 +614,9 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C @Override public void actionPerformed(final ActionEvent e) { final JTree tree = getTree(e); - if (tree == null) - return; + if (tree == null) return; int selectionRow = tree.getLeadSelectionRow(); - if (selectionRow == -1) - return; + if (selectionRow == -1) return; if (isLeaf(tree, selectionRow) || tree.isCollapsed(selectionRow)) { if (!PropertyUtil.getBooleanProperty(tree, KEY_IS_TABLE_TREE)) { @@ -689,24 +668,20 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C } protected void toggleEdit(final JTree tree) { - if (tree == null) - return; + if (tree == null) return; if (tree.isEditing()) { tree.stopEditing(); return; } int selectionRow = tree.getLeadSelectionRow(); - if (selectionRow == -1) - return; + if (selectionRow == -1) return; tree.startEditingAtPath(tree.getPathForRow(selectionRow)); } protected void move(final JTree tree, final int offset) { - if (tree == null) - return; + if (tree == null) return; int selectionRow = tree.getLeadSelectionRow(); - if (selectionRow == -1) - return; + if (selectionRow == -1) return; moveTo(tree, selectionRow + offset); } @@ -727,8 +702,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C boolean ltr = tree.getComponentOrientation().isLeftToRight(); int ident = ui.getRightChildIndent(); int extra = ident - 1 + icon.getIconWidth() / 2; - if (ltr) - bounds.x -= extra; + if (ltr) bounds.x -= extra; bounds.width += extra; } } @@ -737,11 +711,9 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C protected boolean acceptExpandCollapseAction(final Object sender, final boolean collapsed) { JTree tree = DarkUIUtil.nullableCast(JTree.class, sender); - if (tree == null) - return false; + if (tree == null) return false; int selectionRow = tree.getLeadSelectionRow(); - if (selectionRow == -1) - return false; + if (selectionRow == -1) return false; final boolean collapsedOrExpanded = collapsed ? tree.isCollapsed(selectionRow) : tree.isExpanded(selectionRow); if (isLeaf(tree, selectionRow) || collapsedOrExpanded) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeCellContainer.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeCellContainer.java index d8e7cd16..45219efd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeCellContainer.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeCellContainer.java @@ -57,8 +57,7 @@ public class TreeCellContainer implements IndexedCellContainer { @Override public Color getBackgroundAt(final Integer position, final Component renderer) { - if (position == null) - return null; + if (position == null) return null; return CellUtil.getTreeBackground(tree, tree.isRowSelected(position), position); } @@ -69,8 +68,7 @@ public class TreeCellContainer implements IndexedCellContainer { @Override public Component getCellRendererComponent(final Integer row) { - if (row == null) - return null; + if (row == null) return null; TreeCellRenderer renderer = ui.getCellRenderer(); TreePath path = tree.getPathForRow(row); boolean isExpanded = tree.isExpanded(row); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererComponent.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererComponent.java index 855beac7..2d60b151 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererComponent.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/TreeRendererComponent.java @@ -68,8 +68,7 @@ public class TreeRendererComponent extends Container { private int getOffset() { Icon icon = defaultRenderer.getIcon(); - if (icon == null) - return 0; + if (icon == null) return 0; return icon.getIconWidth() + defaultRenderer.getIconTextGap(); } @@ -111,8 +110,7 @@ public class TreeRendererComponent extends Container { icon.paintIcon(this, g, width - icon.getIconWidth(), yLoc); } } - if (renderComponent != null) - renderComponent.paint(g); + if (renderComponent != null) renderComponent.paint(g); } /** Calculate the y location for the icon. */ @@ -128,21 +126,18 @@ public class TreeRendererComponent extends Container { @Override public void setFont(final Font f) { super.setFont(f); - if (renderComponent != null) - renderComponent.setFont(f); + if (renderComponent != null) renderComponent.setFont(f); } @Override public void setForeground(final Color c) { super.setForeground(c); - if (renderComponent != null) - renderComponent.setForeground(c); + if (renderComponent != null) renderComponent.setForeground(c); } @Override public void setBackground(final Color c) { super.setBackground(c); - if (renderComponent != null) - renderComponent.setBackground(c); + if (renderComponent != null) renderComponent.setBackground(c); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java index b51aa90b..e49c8f4b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java @@ -95,8 +95,7 @@ public final class DarkUIUtil { } public static Insets addInsets(final Insets ins1, final Insets ins2) { - if (ins2 == null) - return ins1; + if (ins2 == null) return ins1; if (ins1 != null) { ins1.left += ins2.left; ins1.right += ins2.right; @@ -108,8 +107,7 @@ public final class DarkUIUtil { } public static Dimension addInsets(final Dimension dim, final Insets ins) { - if (dim == null || ins == null) - return dim; + if (dim == null || ins == null) return dim; dim.width += ins.left + ins.right; dim.height += ins.top + ins.bottom; return dim; @@ -125,8 +123,7 @@ public final class DarkUIUtil { } public static void repaint(final Component component) { - if (component != null && component.isVisible()) - component.repaint(); + if (component != null && component.isVisible()) component.repaint(); } public static void repaint(final JComponent component, final Rectangle bounds) { @@ -175,10 +172,8 @@ public final class DarkUIUtil { * @return true if the component or one of its subcomponents has the focus. */ public static boolean hasFocus(final Component c, final FocusEvent e) { - if (c == null) - return false; - if (c.hasFocus()) - return true; + if (c == null) return false; + if (c.hasFocus()) return true; if (c instanceof Window) { return hasFocus(c); } @@ -194,20 +189,17 @@ public final class DarkUIUtil { public static boolean hasFocus(final Window w) { Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); - if (owner == null) - return false; + if (owner == null) return false; return SwingUtilities.getWindowAncestor(owner) == w; } public static Container getUnwrappedParent(final Component comp) { - if (comp == null) - return null; + if (comp == null) return null; return SwingUtilities.getUnwrappedParent(comp); } public static Component unwrapComponent(final Component component) { - if (component == null) - return null; + if (component == null) return null; if (!(component.getParent() instanceof JLayer) && !(component.getParent() instanceof JViewport)) return component; Container parent = component.getParent(); @@ -238,8 +230,7 @@ public final class DarkUIUtil { } public static boolean isInCell(final Component c) { - if (getParentOfType(DarkTableHeaderRendererPane.class, c, CELL_SEARCH_DEPTH) != null) - return false; + if (getParentOfType(DarkTableHeaderRendererPane.class, c, CELL_SEARCH_DEPTH) != null) return false; return getParentOfType(c, CELL_SEARCH_DEPTH, CellRendererPane.class, CellEditor.class, TableCellRenderer.class, TableCellEditor.class, TreeCellRenderer.class, TreeCellEditor.class, ListCellRenderer.class, CellRenderer.class) != null; @@ -255,8 +246,7 @@ public final class DarkUIUtil { if (cls.isAssignableFrom(eachParent.getClass())) { return cls.cast(eachParent); } - if (depth >= searchDepth) - break; + if (depth >= searchDepth) break; depth++; } return null; @@ -276,8 +266,7 @@ public final class DarkUIUtil { return cls.cast(eachParent); } } - if (depth >= searchDepth) - break; + if (depth >= searchDepth) break; depth++; } return null; @@ -308,12 +297,10 @@ public final class DarkUIUtil { MenuElement result; if (forward) { result = nextEnabledChild(e, fromIndex + 1, e.length - 1); - if (result == null) - result = nextEnabledChild(e, 0, fromIndex - 1); + if (result == null) result = nextEnabledChild(e, 0, fromIndex - 1); } else { result = previousEnabledChild(e, fromIndex - 1, 0); - if (result == null) - result = previousEnabledChild(e, e.length - 1, fromIndex + 1); + if (result == null) result = previousEnabledChild(e, e.length - 1, fromIndex + 1); } return result; } @@ -346,8 +333,7 @@ public final class DarkUIUtil { public static boolean isOverText(final MouseEvent e, final int index, final JList list) { Rectangle bounds = list.getCellBounds(index, index); - if (!bounds.contains(e.getPoint())) - return false; + if (!bounds.contains(e.getPoint())) return false; // noinspection unchecked Component cellRenderer = ((ListCellRenderer) list.getCellRenderer()).getListCellRendererComponent(list, list.getModel().getElementAt(index), index, false, false); @@ -370,8 +356,7 @@ public final class DarkUIUtil { public static boolean isOverText(final MouseEvent e, final int row, final int column, final JTable table) { Rectangle bounds = table.getCellRect(row, column, false); - if (!bounds.contains(e.getPoint())) - return false; + if (!bounds.contains(e.getPoint())) return false; Component cellRenderer = table.getCellRenderer(row, column).getTableCellRendererComponent(table, table.getValueAt(row, column), false, false, row, column); if (cellRenderer instanceof JLabel) { @@ -404,8 +389,7 @@ public final class DarkUIUtil { public static Insets getBorderInsets(final JComponent comp) { Border border = comp.getBorder(); - if (border == null) - return new InsetsUIResource(0, 0, 0, 0); + if (border == null) return new InsetsUIResource(0, 0, 0, 0); return border.getBorderInsets(comp); } @@ -417,8 +401,7 @@ public final class DarkUIUtil { } public static Rectangle getScreenBounds(final JComponent target, final Point p) { - if (p == null) - return getScreenBounds(target, target.getLocationOnScreen()); + if (p == null) return getScreenBounds(target, target.getLocationOnScreen()); return getScreenBounds(target, p.x, p.y); } @@ -450,8 +433,7 @@ public final class DarkUIUtil { } public static GraphicsConfiguration getGraphicsConfigurationForLocation(final int x, final int y) { - if (GraphicsEnvironment.isHeadless()) - return null; + if (GraphicsEnvironment.isHeadless()) return null; GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); for (GraphicsDevice device : devices) { @@ -523,8 +505,7 @@ public final class DarkUIUtil { } public static Dimension getPreferredSize(final JComponent component) { - if (component == null) - return new Dimension(0, 0); + if (component == null) return new Dimension(0, 0); LayoutManager menuBarLayout = component.getLayout(); Dimension size = null; if (menuBarLayout != null) { @@ -534,8 +515,7 @@ public final class DarkUIUtil { } public static T nullableCast(final Class type, final Object o) { - if (type != null && type.isInstance(o)) - return type.cast(o); + if (type != null && type.isInstance(o)) return type.cast(o); return null; } } diff --git a/core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java b/core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java index 96c4eeff..ddd08911 100644 --- a/core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java +++ b/core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java @@ -116,8 +116,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai */ @Override public void paint(final Graphics g, final int offs0, final int offs1, final Shape bounds, final JTextComponent c) { - if (!enabled) - return; + if (!enabled) return; Graphics2D g2d = (Graphics2D) g; GraphicsContext context = new GraphicsContext(g2d); color = c.getSelectedTextColor(); @@ -160,8 +159,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai @Override public Shape paintLayer(final Graphics g, final int offs0, final int offs1, final Shape bounds, final JTextComponent c, final View view) { - if (!enabled) - return bounds; + if (!enabled) return bounds; color = (Color) view.getAttributes().getAttribute(StyleConstantsEx.SelectedForeground); if (color == null) { color = StyleConstants.getForeground(view.getAttributes()); @@ -253,8 +251,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai int nextLineStart = currentLineEnd + 1; int nextLineEnd = getOffset(c, c.getWidth(), getPosRect(c, nextLineStart).y); - if (nextLineEnd < nextLineStart) - nextLineEnd = nextLineStart; + if (nextLineEnd < nextLineStart) nextLineEnd = nextLineStart; boolean isEndOfLine = offs1 >= c.getDocument().getLength() - 1 || getPosRect(c, offs1 + 1).y > posOffs1.y; boolean isStartOfLine = offs0 == 0 || getPosRect(c, offs0 - 1).y < posOffs0.y; @@ -308,8 +305,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai paintPreviousLine = hasLineAbove && (previousLineStart == previousLineEnd || previousLineEnd == selectionStart); previousLineVisible = hasLineAbove; - if (nextLineRect.y != posEnd.y) - nextLineVisible = hasLineBelow; + if (nextLineRect.y != posEnd.y) nextLineVisible = hasLineBelow; boolean extendRight = isPaintingPreceding || (hasLineBelow && (endX(layerRect) == endX(currentLineRect))); extendRight &= offs1 < selectionEnd; @@ -319,8 +315,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai extendLine(c, ins, layerRect, extendLeft, extendRight); extendLine(c, ins, currentLineRect, extendLeft, extendRight); - if (isPaintingPreceding) - layerRect.height = currentLineRect.height; + if (isPaintingPreceding) layerRect.height = currentLineRect.height; } boolean canRoundLeft = rounded && (isStartOfLine || startX(currentLineRect) == startX(layerRect)); @@ -497,14 +492,10 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai * First paint the whole rounded rectangle and remove any non visible arcs. */ g.fillRoundRect(r.x, r.y, r.width, r.height, aw, ah); - if (!topLeft) - g.fillRect(r.x, r.y, aw, ah); - if (!topRight) - g.fillRect(r.x + r.width - aw, r.y, aw, ah); - if (!bottomLeft) - g.fillRect(r.x, r.y + r.height - ah, aw, ah); - if (!bottomRight) - g.fillRect(r.x + r.width - aw, r.y + r.height - ah, aw, ah); + if (!topLeft) g.fillRect(r.x, r.y, aw, ah); + if (!topRight) g.fillRect(r.x + r.width - aw, r.y, aw, ah); + if (!bottomLeft) g.fillRect(r.x, r.y + r.height - ah, aw, ah); + if (!bottomRight) g.fillRect(r.x + r.width - aw, r.y + r.height - ah, aw, ah); } context.restoreClip(); return shape; @@ -512,8 +503,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai private Rectangle paintArcs(final Graphics2D g, final GraphicsContext context, final Rectangle r, final boolean topLeft, final boolean topRight, final boolean bottomLeft, final boolean bottomRight) { - if (r.isEmpty()) - return r; + if (r.isEmpty()) return r; Rectangle alloc = new Rectangle(r); if (topLeft || bottomLeft) { alloc.x -= arcSize; diff --git a/core/src/test/java/documentation/CreateUITable.java b/core/src/test/java/documentation/CreateUITable.java index 92c19fc8..2905cbdc 100644 --- a/core/src/test/java/documentation/CreateUITable.java +++ b/core/src/test/java/documentation/CreateUITable.java @@ -76,8 +76,7 @@ public class CreateUITable { String htmlFile = workingFolder + "defaults_" + os + ".html"; Files.createDirectories(new File(workingFolder).toPath()); File f = new File(htmlFile); - if (!f.exists()) - Files.createFile(f.toPath()); + if (!f.exists()) Files.createFile(f.toPath()); try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(htmlFile), StandardCharsets.UTF_8)) { @@ -98,12 +97,9 @@ public class CreateUITable { Set groups = defaults.keySet().stream().map(key -> { String s = key.toString(); - if (s.startsWith("%")) - return "%"; - if (s.contains(".")) - return s.split("\\.")[0]; - if (s.endsWith("UI")) - return s.substring(0, s.length() - 2); + if (s.startsWith("%")) return "%"; + if (s.contains(".")) return s.split("\\.")[0]; + if (s.endsWith("UI")) return s.substring(0, s.length() - 2); return misc + s; }).collect(Collectors.toSet()); @@ -135,12 +131,9 @@ public class CreateUITable { builder.append(StringUtil.repeat(IDENT, ident)).append("

").append(heading).append("

\n"); Set> values = defaults.entrySet().stream().filter(entry -> { String key = entry.getKey().toString(); - if (key.startsWith("%")) - return true; - if (key.endsWith("UI")) - return key.substring(0, key.length() - 2).equals(group); - if (key.contains(".")) - return key.split("\\.")[0].equals(group); + if (key.startsWith("%")) return true; + if (key.endsWith("UI")) return key.substring(0, key.length() - 2).equals(group); + if (key.contains(".")) return key.split("\\.")[0].equals(group); return key.equals(group); }).collect(Collectors.toSet()); appendTable(builder, values, ident); @@ -161,8 +154,7 @@ public class CreateUITable { .forEach(entry -> appendRow(builder, entry, ident + 1)); values.stream().filter(entry -> !entry.getKey().toString().endsWith("UI")).sorted((o1, o2) -> { int res = o1.getValue().getClass().getSimpleName().compareTo(o2.getValue().getClass().getSimpleName()); - if (res != 0) - return res; + if (res != 0) return res; Object val1 = o1.getValue(); Object val2 = o2.getValue(); if (val1 instanceof Comparable) { @@ -246,8 +238,7 @@ public class CreateUITable { new File(workingFolder + "img/").mkdirs(); String fileName = "img/" + name + ".png"; File imageFile = new File(workingFolder + fileName); - if (!imageFile.createNewFile()) - return fileName; + if (!imageFile.createNewFile()) return fileName; if (value instanceof Icon) { size.width = Math.max(size.width, ((Icon) value).getIconWidth()); size.height = Math.max(size.height, ((Icon) value).getIconHeight()); @@ -290,13 +281,11 @@ public class CreateUITable { String id = ((LinearGradient) child).getId(); String match = "=\"url\\(#" + id + "\\)\""; String fillReplacement = "fill=\"#" + ColorUtil.toHex(color) + "\""; - if (opacity != 1) - fillReplacement += " fill-opacity=\"" + opacity + "\""; + if (opacity != 1) fillReplacement += " fill-opacity=\"" + opacity + "\""; svg = svg.replaceAll("fill" + match, fillReplacement); String strokeReplacement = "stroke=\"#" + ColorUtil.toHex(color) + "\""; - if (opacity != 1) - strokeReplacement += " stroke-opacity=\"" + opacity + "\""; + if (opacity != 1) strokeReplacement += " stroke-opacity=\"" + opacity + "\""; svg = svg.replaceAll("stroke" + match, strokeReplacement); } } @@ -306,8 +295,7 @@ public class CreateUITable { private Color getColor(final UIDefaults defaults, final String key) { Object obj = getValue(defaults.get(key)); - if (obj instanceof Color) - return (Color) obj; + if (obj instanceof Color) return (Color) obj; return null; } @@ -355,8 +343,7 @@ public class CreateUITable { } else if (value instanceof Character) { return value.toString(); } - if (value == null) - return "null"; + if (value == null) return "null"; return value.getClass().getSimpleName(); } } diff --git a/core/src/test/java/test/TooltipTest.java b/core/src/test/java/test/TooltipTest.java index a09c6c3d..656a327b 100644 --- a/core/src/test/java/test/TooltipTest.java +++ b/core/src/test/java/test/TooltipTest.java @@ -83,8 +83,7 @@ public class TooltipTest extends AbstractImageTest { Color bg = c.getBackground(); Assertions.assertNotNull(bg, "Background is null for " + c); Assertions.assertEquals(0, bg.getAlpha(), "Background " + bg + " is opaque " + c); - if (c instanceof Window) - break; + if (c instanceof Window) break; } Assertions.assertEquals(c, window, "Did not traverse full hierarchy"); @@ -105,8 +104,7 @@ public class TooltipTest extends AbstractImageTest { }); Exception e = exception.get(); - if (e != null) - Assertions.fail(e.getMessage()); + if (e != null) Assertions.fail(e.getMessage()); } private int getAlpha(final int rgb) { diff --git a/core/src/test/java/ui/ComponentDemo.java b/core/src/test/java/ui/ComponentDemo.java index b64214d5..a2b30030 100644 --- a/core/src/test/java/ui/ComponentDemo.java +++ b/core/src/test/java/ui/ComponentDemo.java @@ -158,8 +158,7 @@ public interface ComponentDemo { Enumeration enumeration = bg.getElements(); while (enumeration.hasMoreElements()) { JMenuItem mi = (JMenuItem) enumeration.nextElement(); - if (Objects.equals(currentThemeName, mi.getName())) - return mi; + if (Objects.equals(currentThemeName, mi.getName())) return mi; } return null; } diff --git a/core/src/test/java/ui/button/GroupedButtonDemo.java b/core/src/test/java/ui/button/GroupedButtonDemo.java index 7033c748..87d42c31 100644 --- a/core/src/test/java/ui/button/GroupedButtonDemo.java +++ b/core/src/test/java/ui/button/GroupedButtonDemo.java @@ -65,8 +65,7 @@ public class GroupedButtonDemo implements ComponentDemo { setSelectedIcon(selected); putClientProperty(DarkButtonUI.KEY_THIN, true); putClientProperty(DarkButtonUI.KEY_CORNER, a); - if (prev != null) - prev.putClientProperty(DarkButtonUI.KEY_RIGHT_NEIGHBOUR, this); + if (prev != null) prev.putClientProperty(DarkButtonUI.KEY_RIGHT_NEIGHBOUR, this); putClientProperty(DarkButtonUI.KEY_LEFT_NEIGHBOUR, prev); setSelected(isSelected); bg.add(this); diff --git a/core/src/test/java/ui/tree/CheckBoxTreeDemo.java b/core/src/test/java/ui/tree/CheckBoxTreeDemo.java index 0f5eb494..60e7cb64 100644 --- a/core/src/test/java/ui/tree/CheckBoxTreeDemo.java +++ b/core/src/test/java/ui/tree/CheckBoxTreeDemo.java @@ -49,8 +49,7 @@ public class CheckBoxTreeDemo implements ComponentDemo { } private TristateTreeNode populate(final TristateTreeNode node, final int count, final int depth) { - if (depth == 0) - return node; + if (depth == 0) return node; for (int i = 0; i < count; i++) { node.add(populate(new TristateTreeNode(StringUtil.repeat("Node", depth)), count, depth - 1)); } diff --git a/core/src/test/java/util/ResourceWalker.java b/core/src/test/java/util/ResourceWalker.java index abcaab34..a93cc485 100644 --- a/core/src/test/java/util/ResourceWalker.java +++ b/core/src/test/java/util/ResourceWalker.java @@ -45,8 +45,7 @@ public class ResourceWalker implements AutoCloseable { } public Stream stream() { - if (stream != null) - throw new IllegalStateException("Stream already open"); + if (stream != null) throw new IllegalStateException("Stream already open"); Stream s = Arrays.stream(packages).flatMap(this::walk); stream = s; return s; @@ -108,11 +107,9 @@ public class ResourceWalker implements AutoCloseable { } private Stream walkFolder(final File file) { - if (!file.isDirectory()) - return Stream.of(file); + if (!file.isDirectory()) return Stream.of(file); File[] files = file.listFiles(); - if (files == null) - files = new File[0]; + if (files == null) files = new File[0]; return Arrays.stream(files).flatMap(this::walkFolder); } } diff --git a/darklaf_java.eclipseformat.xml b/darklaf_java.eclipseformat.xml index b2e895ed..1b4d8524 100644 --- a/darklaf_java.eclipseformat.xml +++ b/darklaf_java.eclipseformat.xml @@ -33,7 +33,7 @@ - + @@ -289,7 +289,7 @@ - + diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java index d3772f5a..c384bcf5 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java @@ -88,8 +88,7 @@ public class JNIThemeInfoMacOS { public static Color getSelectionColor() { int rgba = nativeGetSelectionColor(); // If rgba == 0 then it has an alpha channel != 255, so it is invalid. - if (rgba == 0) - return null; + if (rgba == 0) return null; return new Color(rgba); } diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java index 335b2a98..747e358b 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSPreferenceMonitor.java @@ -74,16 +74,14 @@ public class MacOSPreferenceMonitor { } private void stop() { - if (!running) - return; + if (!running) return; running = false; LOGGER.info("Stopped preference monitoring."); JNIThemeInfoMacOS.deletePreferenceChangeListener(listenerHandle); } public void setRunning(final boolean running) { - if (running == isRunning()) - return; + if (running == isRunning()) return; if (running) { start(); } else { diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSThemePreferenceProvider.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSThemePreferenceProvider.java index d138e81a..fb424a89 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSThemePreferenceProvider.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSThemePreferenceProvider.java @@ -38,8 +38,7 @@ public class MacOSThemePreferenceProvider implements ThemePreferenceProvider { @Override public PreferredThemeStyle getPreference() { - if (!MacOSLibrary.get().isLoaded()) - return fallbackStyle; + if (!MacOSLibrary.get().isLoaded()) return fallbackStyle; boolean darkMode = JNIThemeInfoMacOS.isDarkThemeEnabled(); boolean highContrast = JNIThemeInfoMacOS.isHighContrastEnabled(); Color accentColor = JNIThemeInfoMacOS.getAccentColor(); @@ -65,8 +64,7 @@ public class MacOSThemePreferenceProvider implements ThemePreferenceProvider { @Override public void setReporting(final boolean reporting) { - if (reporting && !MacOSLibrary.get().isLoaded()) - MacOSLibrary.get().updateLibrary(); + if (reporting && !MacOSLibrary.get().isLoaded()) MacOSLibrary.get().updateLibrary(); synchronized (monitor) { monitor.setRunning(reporting); } diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java index d13589d7..270a773b 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSDecorationsUtil.java @@ -35,8 +35,7 @@ public class MacOSDecorationsUtil { private static final String TRANSPARENT_TITLE_BAR_KEY = "apple.awt.transparentTitleBar"; protected static DecorationInformation installDecorations(final JRootPane rootPane) { - if (rootPane == null) - return null; + if (rootPane == null) return null; Window window = SwingUtilities.getWindowAncestor(rootPane); long windowHandle = JNIDecorationsMacOS.getComponentPointer(window); if (windowHandle == 0) { @@ -66,8 +65,7 @@ public class MacOSDecorationsUtil { } protected static void uninstallDecorations(final DecorationInformation information) { - if (information == null || information.windowHandle == 0) - return; + if (information == null || information.windowHandle == 0) return; if (information.jniInstalled) { JNIDecorationsMacOS.uninstallDecorations(information.windowHandle); } else { diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java index 684d0124..f32bf8af 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java @@ -175,8 +175,7 @@ public class MacOSTitlePane extends CustomTitlePane { @Override public Dimension getPreferredSize() { - if (decorationInformation == null) - return new Dimension(0, 0); + if (decorationInformation == null) return new Dimension(0, 0); int height = decorationInformation.titleBarHeight; if (hideTitleBar()) { height = 0; diff --git a/native-utils/src/main/java/com/github/weisj/darklaf/platform/AbstractLibrary.java b/native-utils/src/main/java/com/github/weisj/darklaf/platform/AbstractLibrary.java index 2843e58d..a06edc0d 100644 --- a/native-utils/src/main/java/com/github/weisj/darklaf/platform/AbstractLibrary.java +++ b/native-utils/src/main/java/com/github/weisj/darklaf/platform/AbstractLibrary.java @@ -86,17 +86,14 @@ public abstract class AbstractLibrary { } protected void info(final String message) { - if (logger != null) - logger.info(message); + if (logger != null) logger.info(message); } protected void warning(final String message) { - if (logger != null) - logger.warning(message); + if (logger != null) logger.warning(message); } protected void error(final String message, final Throwable e) { - if (logger != null) - logger.log(Level.SEVERE, message, e); + if (logger != null) logger.log(Level.SEVERE, message, e); } } diff --git a/native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java b/native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java index f18e51aa..f04993cd 100644 --- a/native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java +++ b/native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java @@ -91,8 +91,7 @@ public class NativeUtil { Path temp = temporaryDir.resolve(filename); try (InputStream is = NativeUtil.class.getResourceAsStream(path)) { - if (!temporaryDir.toFile().canWrite()) - throw new IOException("Can't write to temporary directory."); + if (!temporaryDir.toFile().canWrite()) throw new IOException("Can't write to temporary directory."); Files.copy(is, temp.toAbsolutePath(), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { delete(temp); diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java b/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java index 60aad9ed..8a1d3dd2 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java @@ -124,8 +124,7 @@ public final class PropertyLoader { Object parsed = parseValue(key, value, accumulator, currentDefaults, iconLoader); if (parsed != null) { String k = parseKey(key); - if (parsed instanceof FallbackValue && accumulator.containsKey(k)) - continue; + if (parsed instanceof FallbackValue && accumulator.containsKey(k)) continue; accumulator.put(parseKey(key), parsed); } else { currentDefaults.remove(parseKey(key)); @@ -158,8 +157,7 @@ public final class PropertyLoader { } private static String parseKey(final String key) { - if (debugMode) - return key; + if (debugMode) return key; return key.startsWith(String.valueOf(REFERENCE_PREFIX)) ? key.substring(1) : key; } @@ -217,8 +215,7 @@ public final class PropertyLoader { } else if (value.startsWith(String.valueOf(REFERENCE_PREFIX))) { returnVal = parseReference(key, value, accumulator, currentDefaults); } - if (!(returnVal instanceof LoadError)) - return maybeWrap(returnVal, isFallback); + if (!(returnVal instanceof LoadError)) return maybeWrap(returnVal, isFallback); return maybeWrap(value, isFallback); } @@ -291,21 +288,14 @@ public final class PropertyLoader { } else { break; } - if (val.isEmpty()) - break; + if (val.isEmpty()) break; } - if (base == null) - base = parseExplicitFont(value); - if (base == null && accumulator.get(key) instanceof Font) - base = (Font) accumulator.get(key); - if (base == null) - base = currentDefaults.getFont(key); - if (base == null) - base = FontUtil.createFont(null, Font.PLAIN, 12); - if (size <= 0) - size = base.getSize(); - if (style < 0) - style = base.getStyle(); + if (base == null) base = parseExplicitFont(value); + if (base == null && accumulator.get(key) instanceof Font) base = (Font) accumulator.get(key); + if (base == null) base = currentDefaults.getFont(key); + if (base == null) base = FontUtil.createFont(null, Font.PLAIN, 12); + if (size <= 0) size = base.getSize(); + if (style < 0) style = base.getStyle(); Font font = base.deriveFont(style, size); font = new DarkFontUIResource(font.deriveFont(attributes)); return font; @@ -362,10 +352,8 @@ public final class PropertyLoader { String rest = key.substring(index + 1); key = key.substring(0, index); Font font = null; - if (accumulator.get(key) instanceof Font) - font = (Font) accumulator.get(key); - if (font == null) - font = currentDefaults.getFont(key); + if (accumulator.get(key) instanceof Font) font = (Font) accumulator.get(key); + if (font == null) font = currentDefaults.getFont(key); return new Pair<>(font, rest); } @@ -377,15 +365,13 @@ public final class PropertyLoader { private static List parseList(final ParseFunction mapper, final String value, final Map accumulator, final UIDefaults currentDefaults, final IconLoader iconLoader, final char start, final char end, final char delimiter) { - if (value == null || value.isEmpty()) - return new ArrayList<>(); + if (value == null || value.isEmpty()) return new ArrayList<>(); String val = value; if (val.charAt(0) == start) { val = value.substring(1, value.length() - 1); } String[] values = val.split(String.valueOf(delimiter)); - if (values.length == 0) - return Collections.emptyList(); + if (values.length == 0) return Collections.emptyList(); return Arrays.stream(values).map(k -> mapper.parseValue(k, accumulator, currentDefaults, iconLoader)) .collect(Collectors.toList()); } @@ -475,8 +461,7 @@ public final class PropertyLoader { } public static String asKey(final String key) { - if (debugMode) - return REFERENCE_PREFIX + key; + if (debugMode) return REFERENCE_PREFIX + key; return key; } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java index edf75767..15e9a5dc 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/CustomThemedIcon.java @@ -87,8 +87,7 @@ public class CustomThemedIcon extends ThemedSVGIcon { */ public T getPropertyOfType(final Object key, final Class type) { Object obj = getProperty(key); - if (type != null && type.isInstance(obj)) - return type.cast(obj); + if (type != null && type.isInstance(obj)) return type.cast(obj); return null; } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java index 01a31072..546be7f6 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java @@ -149,8 +149,7 @@ public class DarkSVGIcon implements DerivableIcon, RotateIcon, Seri GraphicsConfiguration gc = c != null ? c.getGraphicsConfiguration() : null; double sx = Scale.getScaleX(gc); double sy = Scale.getScaleY(gc); - if (!update && Scale.equalWithError(scaleX, sx) && Scale.equalWithError(scaleY, sy) && image != null) - return; + if (!update && Scale.equalWithError(scaleX, sx) && Scale.equalWithError(scaleY, sy) && image != null) return; scaleX = sx; scaleY = sy; double effectiveScaleX = loadedWithExtraScale ? scaleX * extraScale : scaleX; @@ -196,10 +195,8 @@ public class DarkSVGIcon implements DerivableIcon, RotateIcon, Seri private boolean isExactRotation(final double rotation) { double r = rotation; - if (r < 0) - r += 2 * Math.PI; - if (r > 2 * Math.PI) - r -= 2 * Math.PI; + if (r < 0) r += 2 * Math.PI; + if (r > 2 * Math.PI) r -= 2 * Math.PI; return Scale.equalWithError(r, 0) || Scale.equalWithError(r, Math.PI / 2) || Scale.equalWithError(r, Math.PI) || Scale.equalWithError(r, 3 * Math.PI / 2); } @@ -239,8 +236,7 @@ public class DarkSVGIcon implements DerivableIcon, RotateIcon, Seri } public SVGIcon getSVGIcon() { - if (!loaded.get()) - ensureSVGLoaded(); + if (!loaded.get()) ensureSVGLoaded(); return icon; } } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/DerivableImageIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/DerivableImageIcon.java index adbbf4de..02e2fb21 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/DerivableImageIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/DerivableImageIcon.java @@ -174,8 +174,7 @@ public class DerivableImageIcon implements DerivableIcon, Ac */ public DerivableImageIcon(final ImageIcon icon, final int width, final int height, final int scalingMode) { this(icon != null ? icon.getImage() : null, width, height, scalingMode); - if (icon != null) - setDescription(icon.getDescription()); + if (icon != null) setDescription(icon.getDescription()); } /** @@ -270,24 +269,20 @@ public class DerivableImageIcon implements DerivableIcon, Ac private void calculateSize() { Image originalImage = original.get(); if (originalImage != null && (width < 0 || height < 0)) { - if (width < 0) - width = originalImage.getWidth(null); - if (height < 0) - height = originalImage.getHeight(null); + if (width < 0) width = originalImage.getWidth(null); + if (height < 0) height = originalImage.getHeight(null); } } @Override public int getIconWidth() { - if (width < 0) - calculateSize(); + if (width < 0) calculateSize(); return width; } @Override public int getIconHeight() { - if (height < 0) - calculateSize(); + if (height < 0) calculateSize(); return height; } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java index b64d5faf..e0611c72 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java @@ -105,10 +105,8 @@ public final class IconColorMapper { } } - if (opacity1 < 0) - opacity1 = opacity; - if (opacity2 < 0) - opacity2 = opacity; + if (opacity1 < 0) opacity1 = opacity; + if (opacity2 < 0) opacity2 = opacity; } Color c = resolveColor(id, getFallbacks(colorFallbacks), FALLBACK_COLOR, defaults); @@ -168,14 +166,12 @@ public final class IconColorMapper { } private static String[] getFallbacks(final StyleAttribute fallbacks) { - if (fallbacks == null) - return new String[0]; + if (fallbacks == null) return new String[0]; return fallbacks.getStringList(); } private static float getOpacity(final String key, final String[] fallbacks, final Map propertyMap) { - if ((key == null || key.isEmpty()) && (fallbacks == null || fallbacks.length == 0)) - return -1; + if ((key == null || key.isEmpty()) && (fallbacks == null || fallbacks.length == 0)) return -1; // UIManager defaults to 0, if the value isn't an integer (or null). Number obj = get(propertyMap, key, fallbacks, Number.class); if (obj instanceof Integer) { @@ -244,8 +240,7 @@ public final class IconColorMapper { private static T get(final Map map, final Object key, final Object[] fallbacks, final Class type) { T obj = getFromMap(map, key, fallbacks, type); - if (obj == null) - return getFromMap(UIManager.getDefaults(), key, fallbacks, type); + if (obj == null) return getFromMap(UIManager.getDefaults(), key, fallbacks, type); return obj; } @@ -257,8 +252,7 @@ public final class IconColorMapper { obj = map.get(fallbacks[i]); } } - if (type.isInstance(obj)) - return type.cast(obj); + if (type.isInstance(obj)) return type.cast(obj); return null; } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java index d2767433..c9b1879b 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java @@ -249,8 +249,7 @@ public final class IconLoader { return awareIconMap.get(key); } Icon icon = getWildcardIcon(iconMap, key, w, h); - if (icon != null) - return icon; + if (icon != null) return icon; } // Icon not found or caching is disabled. @@ -393,14 +392,12 @@ public final class IconLoader { } private int getDefaultWidth(final String path) { - if (!isSVGIcon(path)) - return -1; + if (!isSVGIcon(path)) return -1; return DEFAULT_W; } private int getDefaultHeight(final String path) { - if (!isSVGIcon(path)) - return -1; + if (!isSVGIcon(path)) return -1; return DEFAULT_H; } @@ -427,10 +424,8 @@ public final class IconLoader { @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; IconKey iconKey = (IconKey) o; @@ -438,10 +433,8 @@ public final class IconLoader { // Math any size. return Objects.equals(path, iconKey.path); } - if (w != iconKey.w) - return false; - if (h != iconKey.h) - return false; + if (w != iconKey.w) return false; + if (h != iconKey.h) return false; return Objects.equals(path, iconKey.path); } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconUtil.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconUtil.java index 089ecbbd..7d02cc2c 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconUtil.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconUtil.java @@ -50,8 +50,7 @@ public class IconUtil { } public static Image createFrameIcon(final Icon icon, final Window c) { - if (icon == null) - return null; + if (icon == null) return null; if (c != null) { if (isDynamic(icon)) { windowIconSet.put(c, icon); @@ -77,8 +76,7 @@ public class IconUtil { } public static Image iconToImage(final Icon icon, final Component c) { - if (icon == null) - return null; + if (icon == null) return null; int w = icon.getIconWidth(); int h = icon.getIconHeight(); GraphicsConfiguration gc = c.getGraphicsConfiguration(); @@ -90,8 +88,7 @@ public class IconUtil { } public static Image createScaledImage(final Icon icon, final double scalex, final double scaley) { - if (icon == null) - return null; + if (icon == null) return null; int w = (int) (scalex * icon.getIconWidth()); int h = (int) (scaley * icon.getIconHeight()); if (icon instanceof ImageSource) { diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIconSupplier.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIconSupplier.java index c3a74112..a9da3999 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIconSupplier.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIconSupplier.java @@ -40,8 +40,7 @@ public class LazyImageIconSupplier extends AbstractLazyIconSupplier i @Override public Image get() { ImageIcon imageIcon = getIcon(); - if (imageIcon != null) - return imageIcon.getImage(); + if (imageIcon != null) return imageIcon.getImage(); return null; } } diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/StateIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/StateIcon.java index 3e1f1008..80855ce5 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/StateIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/StateIcon.java @@ -69,8 +69,7 @@ public class StateIcon implements Icon { } public Icon getIcon(final Component c) { - if (!(c instanceof AbstractButton)) - return icon != null ? icon : EmptyIcon.create(0); + if (!(c instanceof AbstractButton)) return icon != null ? icon : EmptyIcon.create(0); AbstractButton b = (AbstractButton) c; boolean selected = b.isSelected(); boolean enabled = b.isEnabled(); diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/TwoIcon.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/TwoIcon.java index edf474f5..59e9e7ce 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/TwoIcon.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/TwoIcon.java @@ -78,8 +78,7 @@ public class TwoIcon implements Icon { int l = leftIcon.getIconWidth(); int r = rightIcon.getIconWidth(); int gap = 0; - if (l != 0 && r != 0) - gap = iconGap; + if (l != 0 && r != 0) gap = iconGap; return l + r + gap; } diff --git a/property-loader/src/test/java/com/github/weisj/darklaf/icons/IconUtilTest.java b/property-loader/src/test/java/com/github/weisj/darklaf/icons/IconUtilTest.java index 9b2a7455..5b965148 100644 --- a/property-loader/src/test/java/com/github/weisj/darklaf/icons/IconUtilTest.java +++ b/property-loader/src/test/java/com/github/weisj/darklaf/icons/IconUtilTest.java @@ -33,8 +33,7 @@ public class IconUtilTest { @Test public void testWeakFrameCache() { - if (GraphicsEnvironment.isHeadless()) - return; + if (GraphicsEnvironment.isHeadless()) return; Object obj = new Object(); WeakReference ref = new WeakReference<>(obj); int count = 100; diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java index 25998779..34842fa5 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java @@ -93,8 +93,7 @@ public abstract class Theme implements Comparable, Comparator { * @return true if dark. */ public static boolean isDark(final Theme theme) { - if (theme == null) - return false; + if (theme == null) return false; return theme.getColorToneRule() == ColorToneRule.DARK; } @@ -105,8 +104,7 @@ public abstract class Theme implements Comparable, Comparator { * @return true if the theme is a high contrast theme. */ public static boolean isHighContrast(final Theme theme) { - if (theme == null) - return false; + if (theme == null) return false; return theme.getContrastRule() == ContrastRule.HIGH_CONTRAST; } @@ -360,8 +358,7 @@ public abstract class Theme implements Comparable, Comparator { */ public final Properties loadPropertyFile(final String name, final boolean silent) { Level level = LOGGER.getLevel(); - if (silent) - LOGGER.setLevel(Level.OFF); + if (silent) LOGGER.setLevel(Level.OFF); Properties properties = load(getPropertyFilePath(name)); LOGGER.setLevel(level); return properties; @@ -430,22 +427,18 @@ public abstract class Theme implements Comparable, Comparator { @Override public int compareTo(final Theme o) { - if (o == null) - return 1; + if (o == null) return 1; int stringComp = getName().compareTo(o.getName()); int contrastCompare = Boolean.compare(isHighContrast(this), isHighContrast(o)); int toneCompare = Boolean.compare(isDark(this), isDark(o)); - if (contrastCompare != 0) - return contrastCompare; - if (toneCompare != 0) - return toneCompare; + if (contrastCompare != 0) return contrastCompare; + if (toneCompare != 0) return toneCompare; return stringComp; } @Override public int compare(final Theme o1, final Theme o2) { - if (o1 == null) - return -1; + if (o1 == null) return -1; return o1.compareTo(o2); } @@ -460,10 +453,8 @@ public abstract class Theme implements Comparable, Comparator { * @return true if they appear equal. */ public boolean appearsEqualTo(final Theme theme) { - if (theme == null) - return false; - if (!Objects.equals(getThemeClass(), theme.getThemeClass())) - return false; + if (theme == null) return false; + if (!Objects.equals(getThemeClass(), theme.getThemeClass())) return false; return Objects.equals(getAccentColorRule(), theme.getAccentColorRule()) && Objects.equals(getColorToneRule(), theme.getColorToneRule()) && Objects.equals(getContrastRule(), theme.getContrastRule()) diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java index 0f8ca831..fa944798 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/AccentColorRule.java @@ -61,13 +61,10 @@ public class AccentColorRule { @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; AccentColorRule that = (AccentColorRule) o; - if (!Objects.equals(accentColor, that.accentColor)) - return false; + if (!Objects.equals(accentColor, that.accentColor)) return false; return Objects.equals(selectionColor, that.selectionColor); } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/DefaultThemeProvider.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/DefaultThemeProvider.java index 253ad1f6..87d6a552 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/DefaultThemeProvider.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/DefaultThemeProvider.java @@ -73,8 +73,7 @@ public class DefaultThemeProvider implements ThemeProvider { @Override public Theme getTheme(final PreferredThemeStyle themeStyle) { - if (themeStyle == null) - return lightTheme; + if (themeStyle == null) return lightTheme; boolean dark = themeStyle.getColorToneRule() == ColorToneRule.DARK; boolean highContrast = themeStyle.getContrastRule() == ContrastRule.HIGH_CONTRAST; Theme theme = dark ? highContrast ? darkHighContrastTheme : darkTheme diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizePreset.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizePreset.java index 54eb066d..22f14dec 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizePreset.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizePreset.java @@ -35,8 +35,7 @@ public enum FontSizePreset { } public float adjustFontSize(final float size) { - if (percentage <= 0) - return size; + if (percentage <= 0) return size; return getType().adjustSize(size, percentage / 100f); } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java index 6be89d33..542c67bb 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/FontSizeRule.java @@ -61,8 +61,7 @@ public class FontSizeRule { } public float adjustFontSize(final float size) { - if (preset != null) - return preset.adjustFontSize(size); + if (preset != null) return preset.adjustFontSize(size); return type.adjustSize(size, relativeAdjustment); } @@ -96,17 +95,14 @@ public class FontSizeRule { } public int getPercentage() { - if (preset != null) - return preset.getPercentage(); + if (preset != null) return preset.getPercentage(); return Math.round(relativeAdjustment * 100); } @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; FontSizeRule that = (FontSizeRule) o; return Float.compare(that.getPercentage(), getPercentage()) == 0; } diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java b/theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java index 6f708411..1242b201 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/info/PreferredThemeStyle.java @@ -35,10 +35,8 @@ public class PreferredThemeStyle { } public PreferredThemeStyle(final ContrastRule contrastRule, final ColorToneRule colorToneRule) { - if (contrastRule == null) - throw new IllegalArgumentException("null is not a valid contrast rule"); - if (colorToneRule == null) - throw new IllegalArgumentException("null is not a valid style rule"); + if (contrastRule == null) throw new IllegalArgumentException("null is not a valid contrast rule"); + if (colorToneRule == null) throw new IllegalArgumentException("null is not a valid style rule"); this.contrastRule = contrastRule; this.colorToneRule = colorToneRule; this.fontSizeRule = FontSizeRule.getDefault(); @@ -47,12 +45,9 @@ public class PreferredThemeStyle { public PreferredThemeStyle(final ContrastRule contrastRule, final ColorToneRule colorToneRule, final AccentColorRule accentColorRule) { - if (contrastRule == null) - throw new IllegalArgumentException("null is not a valid contrast rule"); - if (colorToneRule == null) - throw new IllegalArgumentException("null is not a valid style rule"); - if (accentColorRule == null) - throw new IllegalArgumentException("null is not a valid accent color rule"); + if (contrastRule == null) throw new IllegalArgumentException("null is not a valid contrast rule"); + if (colorToneRule == null) throw new IllegalArgumentException("null is not a valid style rule"); + if (accentColorRule == null) throw new IllegalArgumentException("null is not a valid accent color rule"); this.contrastRule = contrastRule; this.colorToneRule = colorToneRule; this.fontSizeRule = FontSizeRule.getDefault(); @@ -61,12 +56,9 @@ public class PreferredThemeStyle { public PreferredThemeStyle(final ContrastRule contrastRule, final ColorToneRule colorToneRule, final FontSizeRule fontSizeRule) { - if (contrastRule == null) - throw new IllegalArgumentException("null is not a valid contrast rule"); - if (colorToneRule == null) - throw new IllegalArgumentException("null is not a valid style rule"); - if (fontSizeRule == null) - throw new IllegalArgumentException("null is not a valid font size rule"); + if (contrastRule == null) throw new IllegalArgumentException("null is not a valid contrast rule"); + if (colorToneRule == null) throw new IllegalArgumentException("null is not a valid style rule"); + if (fontSizeRule == null) throw new IllegalArgumentException("null is not a valid font size rule"); this.contrastRule = contrastRule; this.colorToneRule = colorToneRule; this.fontSizeRule = fontSizeRule; @@ -75,14 +67,10 @@ public class PreferredThemeStyle { public PreferredThemeStyle(final ContrastRule contrastRule, final ColorToneRule colorToneRule, final AccentColorRule accentColorRule, final FontSizeRule fontSizeRule) { - if (contrastRule == null) - throw new IllegalArgumentException("null is not a valid contrast rule"); - if (colorToneRule == null) - throw new IllegalArgumentException("null is not a valid style rule"); - if (fontSizeRule == null) - throw new IllegalArgumentException("null is not a valid font size rule"); - if (accentColorRule == null) - throw new IllegalArgumentException("null is not a valid accent color rule"); + if (contrastRule == null) throw new IllegalArgumentException("null is not a valid contrast rule"); + if (colorToneRule == null) throw new IllegalArgumentException("null is not a valid style rule"); + if (fontSizeRule == null) throw new IllegalArgumentException("null is not a valid font size rule"); + if (accentColorRule == null) throw new IllegalArgumentException("null is not a valid accent color rule"); this.contrastRule = contrastRule; this.colorToneRule = colorToneRule; this.fontSizeRule = fontSizeRule; @@ -113,10 +101,8 @@ public class PreferredThemeStyle { @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; PreferredThemeStyle that = (PreferredThemeStyle) o; return contrastRule == that.contrastRule && colorToneRule == that.colorToneRule && Objects.equals(fontSizeRule, that.fontSizeRule) diff --git a/theme/src/main/java/com/github/weisj/darklaf/theme/laf/RenamedTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/laf/RenamedTheme.java index 8239cc29..f8a40e71 100644 --- a/theme/src/main/java/com/github/weisj/darklaf/theme/laf/RenamedTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/laf/RenamedTheme.java @@ -42,8 +42,7 @@ public class RenamedTheme extends ThemeDelegate { @Override public String getDisplayName() { - if (name != null) - return name; + if (name != null) return name; return super.getDisplayName(); } } diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java b/utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java index fb846ff6..0d26d402 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java @@ -29,34 +29,23 @@ import java.util.function.BiFunction; /** @author Jannis Weis */ public enum Alignment { NORTH(AlignmentHelper.align(HOR_CENTER_INSIDE, VERT_TOP_INSIDE), - AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_TOP_OUTSIDE)), SOUTH( - AlignmentHelper.align(HOR_CENTER_INSIDE, VERT_BOTTOM_INSIDE), - AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_BOTTOM_OUTSIDE)), EAST( - AlignmentHelper.align(HOR_RIGHT_INSIDE, VERT_CENTER_INSIDE), - AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_CENTER_OUTSIDE)), WEST( - AlignmentHelper.align(HOR_LEFT_INSIDE, VERT_CENTER_INSIDE), - AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_CENTER_OUTSIDE)), NORTH_EAST( - AlignmentHelper.align(HOR_RIGHT_INSIDE, VERT_TOP_INSIDE), - AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_TOP_OUTSIDE)), NORTH_WEST( - AlignmentHelper.align(HOR_LEFT_INSIDE, VERT_TOP_INSIDE), - AlignmentHelper.align(HOR_LEFT_OUTSIDE, - VERT_TOP_OUTSIDE)), SOUTH_EAST( - AlignmentHelper.align(HOR_RIGHT_INSIDE, - VERT_BOTTOM_INSIDE), - AlignmentHelper.align(HOR_RIGHT_OUTSIDE, - VERT_BOTTOM_OUTSIDE)), SOUTH_WEST( - AlignmentHelper.align( - HOR_LEFT_INSIDE, - VERT_BOTTOM_INSIDE), - AlignmentHelper.align( - HOR_LEFT_OUTSIDE, - VERT_BOTTOM_OUTSIDE)), CENTER( - AlignmentHelper - .align(HOR_CENTER_INSIDE, - VERT_CENTER_INSIDE), - AlignmentHelper - .align(HOR_CENTER_OUTSIDE, - VERT_CENTER_OUTSIDE)); + AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_TOP_OUTSIDE)), + SOUTH(AlignmentHelper.align(HOR_CENTER_INSIDE, VERT_BOTTOM_INSIDE), + AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_BOTTOM_OUTSIDE)), + EAST(AlignmentHelper.align(HOR_RIGHT_INSIDE, VERT_CENTER_INSIDE), + AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_CENTER_OUTSIDE)), + WEST(AlignmentHelper.align(HOR_LEFT_INSIDE, VERT_CENTER_INSIDE), + AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_CENTER_OUTSIDE)), + NORTH_EAST(AlignmentHelper.align(HOR_RIGHT_INSIDE, VERT_TOP_INSIDE), + AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_TOP_OUTSIDE)), + NORTH_WEST(AlignmentHelper.align(HOR_LEFT_INSIDE, VERT_TOP_INSIDE), + AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_TOP_OUTSIDE)), + SOUTH_EAST(AlignmentHelper.align(HOR_RIGHT_INSIDE, VERT_BOTTOM_INSIDE), + AlignmentHelper.align(HOR_RIGHT_OUTSIDE, VERT_BOTTOM_OUTSIDE)), + SOUTH_WEST(AlignmentHelper.align(HOR_LEFT_INSIDE, VERT_BOTTOM_INSIDE), + AlignmentHelper.align(HOR_LEFT_OUTSIDE, VERT_BOTTOM_OUTSIDE)), + CENTER(AlignmentHelper.align(HOR_CENTER_INSIDE, VERT_CENTER_INSIDE), + AlignmentHelper.align(HOR_CENTER_OUTSIDE, VERT_CENTER_OUTSIDE)); private final BiFunction alignInside; private final BiFunction alignOutside; diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentExt.java b/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentExt.java index f952caf1..e421276e 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentExt.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/AlignmentExt.java @@ -24,10 +24,10 @@ package com.github.weisj.darklaf.util; import java.awt.*; public enum AlignmentExt { - NORTH(Alignment.NORTH), SOUTH(Alignment.SOUTH), EAST(Alignment.EAST), WEST(Alignment.WEST), NORTH_EAST( - Alignment.NORTH_EAST), NORTH_WEST(Alignment.NORTH_WEST), SOUTH_EAST(Alignment.SOUTH_EAST), SOUTH_WEST( - Alignment.SOUTH_WEST), CENTER(Alignment.CENTER), LEFT( - null), MIDDLE_HORIZONTAL(null), RIGHT(null), TOP(null), MIDDLE_VERTICAL(null), BOTTOM(null); + NORTH(Alignment.NORTH), SOUTH(Alignment.SOUTH), EAST(Alignment.EAST), WEST(Alignment.WEST), + NORTH_EAST(Alignment.NORTH_EAST), NORTH_WEST(Alignment.NORTH_WEST), SOUTH_EAST(Alignment.SOUTH_EAST), + SOUTH_WEST(Alignment.SOUTH_WEST), CENTER(Alignment.CENTER), LEFT(null), MIDDLE_HORIZONTAL(null), RIGHT(null), + TOP(null), MIDDLE_VERTICAL(null), BOTTOM(null); private final Alignment parent; diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java b/utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java index dee16d72..b561058f 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java @@ -29,10 +29,8 @@ import javax.swing.plaf.UIResource; public final class ColorUtil { public static Color blendColors(final Color color1, final Color color2, final double percent) { - if (percent == 1) - return color1; - if (percent == 0) - return color2; + if (percent == 1) return color1; + if (percent == 0) return color2; double inverse_percent = 1.0 - percent; int redPart = (int) (color1.getRed() * percent + color2.getRed() * inverse_percent); int greenPart = (int) (color1.getGreen() * percent + color2.getGreen() * inverse_percent); @@ -67,8 +65,7 @@ public final class ColorUtil { } public static String toHex(final Color color) { - if (color == null) - return ""; + if (color == null) return ""; int r = color.getRed(); int b = color.getBlue(); int g = color.getGreen(); diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/LazyValue.java b/utils/src/main/java/com/github/weisj/darklaf/util/LazyValue.java index 91f26a5a..33a9d006 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/LazyValue.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/LazyValue.java @@ -64,8 +64,7 @@ public class LazyValue { } public T get() { - if (value == null) - value = load(); + if (value == null) value = load(); return value; } } diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java b/utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java index d45d42d7..912de440 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java @@ -34,20 +34,17 @@ import javax.swing.plaf.UIResource; public class PropertyUtil { public static void installBackground(final Component component, final Color color) { - if (component == null || color == null) - return; + if (component == null || color == null) return; component.setBackground(chooseColor(component.getBackground(), color)); } public static void installForeground(final Component component, final Color color) { - if (component == null || color == null) - return; + if (component == null || color == null) return; component.setForeground(chooseColor(component.getForeground(), color)); } public static void installBorder(final JComponent component, final Border border) { - if (component == null) - return; + if (component == null) return; Border b = component.getBorder(); if (b == null || b instanceof UIResource) { component.setBorder(border); @@ -77,8 +74,7 @@ public class PropertyUtil { } public static boolean getBooleanProperty(final JComponent c, final String property, final boolean defaultValue) { - if (c == null) - return defaultValue; + if (c == null) return defaultValue; Object obj = c.getClientProperty(property); if (!defaultValue) { return Boolean.TRUE.equals(obj); @@ -92,22 +88,19 @@ public class PropertyUtil { } public static boolean isPropertyEqual(final JComponent c, final String property, final T checkValue) { - if (c == null) - return false; + if (c == null) return false; Object obj = c.getClientProperty(property); return Objects.equals(checkValue, obj); } public static T getObject(final Component c, final String key, final Class type, final T defaultValue) { - if (!(c instanceof JComponent)) - return defaultValue; + if (!(c instanceof JComponent)) return defaultValue; return getObject((JComponent) c, key, type, defaultValue); } public static T getObject(final JComponent c, final String key, final Class type, final T defaultValue) { Object obj = c.getClientProperty(key); - if (type.isInstance(obj)) - return type.cast(obj); + if (type.isInstance(obj)) return type.cast(obj); return defaultValue; } @@ -173,8 +166,7 @@ public class PropertyUtil { public static List getList(final UIDefaults defaults, final String key, final Class type) { Object obj = defaults.get(key); - if (!(obj instanceof List)) - return Collections.emptyList(); + if (!(obj instanceof List)) return Collections.emptyList(); List list = (List) obj; return asTypedList(list, type); } @@ -185,8 +177,7 @@ public class PropertyUtil { } public static Color chooseColor(final Color currentColor, final Color newColor) { - if (ColorUtil.canOverwriteColor(currentColor)) - return newColor; + if (ColorUtil.canOverwriteColor(currentColor)) return newColor; return currentColor; } } diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/Scale.java b/utils/src/main/java/com/github/weisj/darklaf/util/Scale.java index d5470a22..6237daef 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/Scale.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/Scale.java @@ -47,29 +47,25 @@ public class Scale { } public static double scaleWidth(final double value, final GraphicsConfiguration gc) { - if (gc == null) - return scaleWidth(value); + if (gc == null) return scaleWidth(value); AffineTransform transform = gc.getDefaultTransform(); return transform.getScaleX() * value; } public static double scaleHeight(final double value, final GraphicsConfiguration gc) { - if (gc == null) - return scaleHeight(value); + if (gc == null) return scaleHeight(value); AffineTransform transform = gc.getDefaultTransform(); return transform.getScaleY() * value; } public static double inverseScaleWidth(final double value, final GraphicsConfiguration gc) { - if (gc == null) - return inverseScaleWidth(value); + if (gc == null) return inverseScaleWidth(value); AffineTransform transform = gc.getDefaultTransform(); return (1 / transform.getScaleX()) * value; } public static double inverseScaleHeight(final double value, final GraphicsConfiguration gc) { - if (gc == null) - return inverseScaleHeight(value); + if (gc == null) return inverseScaleHeight(value); AffineTransform transform = gc.getDefaultTransform(); return (1 / transform.getScaleY()) * value; } @@ -131,14 +127,12 @@ public class Scale { } public static double getScaleX(final GraphicsConfiguration gc) { - if (gc == null) - return SCALE_X; + if (gc == null) return SCALE_X; return gc.getDefaultTransform().getScaleX(); } public static double getScaleY(final GraphicsConfiguration gc) { - if (gc == null) - return SCALE_Y; + if (gc == null) return SCALE_Y; return gc.getDefaultTransform().getScaleY(); } diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java b/utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java index ac8f7955..d2e55d75 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java @@ -34,8 +34,7 @@ public final class StringUtil { private StringUtil() {} public static String toHtml(final String text) { - if (text == null) - return ""; + if (text == null) return ""; if (!text.startsWith("") && text.contains("\n")) { return "" + text.replaceAll("\n", "<\\br>") + ""; } @@ -191,10 +190,8 @@ public final class StringUtil { } public static String repeat(final String s, final int count) { - if (count <= 0) - return ""; - if (count == 1) - return s; + if (count <= 0) return ""; + if (count == 1) return s; StringBuilder builder = new StringBuilder(s.length() * count); for (int i = 0; i < count; i++) { builder.append(s); diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java index c31825fb..26065986 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsPreferenceMonitor.java @@ -72,16 +72,14 @@ public class WindowsPreferenceMonitor { } private void stop() { - if (!running) - return; + if (!running) return; LOGGER.info("Stopped preference monitoring."); running = false; JNIThemeInfoWindows.deleteEventHandler(eventHandler); } public void setRunning(final boolean running) { - if (running == isRunning()) - return; + if (running == isRunning()) return; if (running) { start(); } else { diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsThemePreferenceProvider.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsThemePreferenceProvider.java index 65487b89..257948a0 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsThemePreferenceProvider.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsThemePreferenceProvider.java @@ -35,8 +35,7 @@ public class WindowsThemePreferenceProvider implements ThemePreferenceProvider { @Override public PreferredThemeStyle getPreference() { - if (!WindowsLibrary.get().isLoaded()) - return fallbackStyle; + if (!WindowsLibrary.get().isLoaded()) return fallbackStyle; boolean darkMode = JNIThemeInfoWindows.isDarkThemeEnabled(); boolean highContrast = JNIThemeInfoWindows.isHighContrastEnabled(); long fontScaling = JNIThemeInfoWindows.getFontScaleFactor(); @@ -54,8 +53,7 @@ public class WindowsThemePreferenceProvider implements ThemePreferenceProvider { } private Color createColorFromRGB(final int rgb) { - if (rgb == 0) - return null; + if (rgb == 0) return null; return new Color(rgb); } @@ -69,8 +67,7 @@ public class WindowsThemePreferenceProvider implements ThemePreferenceProvider { @Override public void setReporting(final boolean reporting) { - if (reporting && !WindowsLibrary.get().isLoaded()) - WindowsLibrary.get().updateLibrary(); + if (reporting && !WindowsLibrary.get().isLoaded()) WindowsLibrary.get().updateLibrary(); synchronized (monitor) { monitor.setRunning(reporting); } diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java index a282bdcf..f2d22699 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java @@ -238,8 +238,7 @@ public class WindowsTitlePane extends CustomTitlePane { public void install() { if (window != null) { - if (!installDecorations()) - return; + if (!installDecorations()) return; if (window instanceof Frame) { titleLabel.setText(((Frame) window).getTitle()); setState(((Frame) window).getExtendedState()); @@ -267,10 +266,8 @@ public class WindowsTitlePane extends CustomTitlePane { } private boolean installDecorations() { - if (getDecorationStyle() == JRootPane.NONE) - return false; - if (!window.isDisplayable()) - return false; + if (getDecorationStyle() == JRootPane.NONE) return false; + if (!window.isDisplayable()) return false; if (window instanceof Dialog || window instanceof Frame) { windowHandle = PointerUtil.getHWND(window); if (windowHandle != 0) { @@ -705,8 +702,7 @@ public class WindowsTitlePane extends CustomTitlePane { private boolean hideTitleBar() { String title = titleLabel.getText(); - if (title == null) - title = ""; + if (title == null) title = ""; return windowHandle == 0 || (getDecorationStyle() == JRootPane.NONE && (menuBar == null || !menuBar.isVisible()) && title.length() == 0) // e.g. VCLJ achieves fullscreen by hiding the titlebar through jni and setting visibility @@ -717,16 +713,14 @@ public class WindowsTitlePane extends CustomTitlePane { @Override public Dimension getPreferredSize() { - if (hideTitleBar()) - return new Dimension(0, 0); + if (hideTitleBar()) return new Dimension(0, 0); int height = computeHeight(); int width = computeWidth(); return new Dimension(width, height + 1); } private int computeHeight() { - if (hideTitleBar()) - return 0; + if (hideTitleBar()) return 0; FontMetrics fm = rootPane.getFontMetrics(getFont()); int height = fm.getHeight() + 7; if (menuBar != null) { @@ -793,8 +787,7 @@ public class WindowsTitlePane extends CustomTitlePane { } public void layoutContainer(final Container c) { - if (hideTitleBar()) - return; + if (hideTitleBar()) return; boolean leftToRight = isLeftToRight(window); boolean frame = getDecorationStyle() == JRootPane.FRAME; boolean undecorated = getDecorationStyle() == JRootPane.NONE; @@ -904,8 +897,7 @@ public class WindowsTitlePane extends CustomTitlePane { repaint(); } else if (PropertyKey.BACKGROUND.equals(name) && pce.getNewValue() instanceof Color) { Color color = (Color) pce.getNewValue(); - if (color == null) - return; + if (color == null) return; JNIDecorationsWindows.setBackground(windowHandle, color.getRed(), color.getGreen(), color.getBlue()); } }