From 12526c3e47f8e22dd2d18149198c3086d5948824 Mon Sep 17 00:00:00 2001 From: mkpaz Date: Wed, 22 Feb 2023 21:08:06 +0400 Subject: [PATCH] Update themes Javadoc --- .../atlantafx/base/theme/CupertinoDark.java | 12 +++++++++ .../atlantafx/base/theme/CupertinoLight.java | 12 +++++++++ .../java/atlantafx/base/theme/Dracula.java | 9 +++++++ .../java/atlantafx/base/theme/NordDark.java | 12 +++++++++ .../java/atlantafx/base/theme/NordLight.java | 12 +++++++++ .../java/atlantafx/base/theme/PrimerDark.java | 12 +++++++++ .../atlantafx/base/theme/PrimerLight.java | 12 +++++++++ .../java/atlantafx/base/theme/Styles.java | 18 +++++++++++++ .../main/java/atlantafx/base/theme/Theme.java | 25 ++++++++++++++++--- 9 files changed, 121 insertions(+), 3 deletions(-) diff --git a/base/src/main/java/atlantafx/base/theme/CupertinoDark.java b/base/src/main/java/atlantafx/base/theme/CupertinoDark.java index 24d6306..b1ac54f 100644 --- a/base/src/main/java/atlantafx/base/theme/CupertinoDark.java +++ b/base/src/main/java/atlantafx/base/theme/CupertinoDark.java @@ -4,6 +4,9 @@ package atlantafx.base.theme; import atlantafx.base.Preview; +/** + * A theme based on IOS color palette. + */ @Preview public class CupertinoDark implements Theme { @@ -11,16 +14,25 @@ public class CupertinoDark implements Theme { // Default constructor } + /** + * {@inheritDoc} + */ @Override public String getName() { return "Cupertino Dark"; } + /** + * {@inheritDoc} + */ @Override public String getUserAgentStylesheet() { return "/atlantafx/base/theme/cupertino-dark.css"; } + /** + * {@inheritDoc} + */ @Override public boolean isDarkMode() { return true; diff --git a/base/src/main/java/atlantafx/base/theme/CupertinoLight.java b/base/src/main/java/atlantafx/base/theme/CupertinoLight.java index 61bd699..65c2170 100644 --- a/base/src/main/java/atlantafx/base/theme/CupertinoLight.java +++ b/base/src/main/java/atlantafx/base/theme/CupertinoLight.java @@ -4,6 +4,9 @@ package atlantafx.base.theme; import atlantafx.base.Preview; +/** + * A theme based on IOS color palette. + */ @Preview public class CupertinoLight implements Theme { @@ -11,16 +14,25 @@ public class CupertinoLight implements Theme { // Default constructor } + /** + * {@inheritDoc} + */ @Override public String getName() { return "Cupertino Light"; } + /** + * {@inheritDoc} + */ @Override public String getUserAgentStylesheet() { return "/atlantafx/base/theme/cupertino-light.css"; } + /** + * {@inheritDoc} + */ @Override public boolean isDarkMode() { return false; diff --git a/base/src/main/java/atlantafx/base/theme/Dracula.java b/base/src/main/java/atlantafx/base/theme/Dracula.java index 6ea6c6c..9757e5c 100644 --- a/base/src/main/java/atlantafx/base/theme/Dracula.java +++ b/base/src/main/java/atlantafx/base/theme/Dracula.java @@ -14,16 +14,25 @@ public class Dracula implements Theme { // Default constructor } + /** + * {@inheritDoc} + */ @Override public String getName() { return "Dracula"; } + /** + * {@inheritDoc} + */ @Override public String getUserAgentStylesheet() { return "/atlantafx/base/theme/dracula.css"; } + /** + * {@inheritDoc} + */ @Override public boolean isDarkMode() { return true; diff --git a/base/src/main/java/atlantafx/base/theme/NordDark.java b/base/src/main/java/atlantafx/base/theme/NordDark.java index 5c27e37..6e62be4 100755 --- a/base/src/main/java/atlantafx/base/theme/NordDark.java +++ b/base/src/main/java/atlantafx/base/theme/NordDark.java @@ -2,22 +2,34 @@ package atlantafx.base.theme; +/** + * A theme based on Nord color palette. + */ public final class NordDark implements Theme { public NordDark() { // Default constructor } + /** + * {@inheritDoc} + */ @Override public String getName() { return "Nord Dark"; } + /** + * {@inheritDoc} + */ @Override public String getUserAgentStylesheet() { return "/atlantafx/base/theme/nord-dark.css"; } + /** + * {@inheritDoc} + */ @Override public boolean isDarkMode() { return true; diff --git a/base/src/main/java/atlantafx/base/theme/NordLight.java b/base/src/main/java/atlantafx/base/theme/NordLight.java index 652a225..598a546 100755 --- a/base/src/main/java/atlantafx/base/theme/NordLight.java +++ b/base/src/main/java/atlantafx/base/theme/NordLight.java @@ -2,22 +2,34 @@ package atlantafx.base.theme; +/** + * A theme based on Nord color palette. + */ public final class NordLight implements Theme { public NordLight() { // Default constructor } + /** + * {@inheritDoc} + */ @Override public String getName() { return "Nord Light"; } + /** + * {@inheritDoc} + */ @Override public String getUserAgentStylesheet() { return "/atlantafx/base/theme/nord-light.css"; } + /** + * {@inheritDoc} + */ @Override public boolean isDarkMode() { return false; diff --git a/base/src/main/java/atlantafx/base/theme/PrimerDark.java b/base/src/main/java/atlantafx/base/theme/PrimerDark.java index 634dda8..39e24fe 100755 --- a/base/src/main/java/atlantafx/base/theme/PrimerDark.java +++ b/base/src/main/java/atlantafx/base/theme/PrimerDark.java @@ -2,22 +2,34 @@ package atlantafx.base.theme; +/** + * A theme based on Github Primer color palette. + */ public final class PrimerDark implements Theme { public PrimerDark() { // Default constructor } + /** + * {@inheritDoc} + */ @Override public String getName() { return "Primer Dark"; } + /** + * {@inheritDoc} + */ @Override public String getUserAgentStylesheet() { return "/atlantafx/base/theme/primer-dark.css"; } + /** + * {@inheritDoc} + */ @Override public boolean isDarkMode() { return true; diff --git a/base/src/main/java/atlantafx/base/theme/PrimerLight.java b/base/src/main/java/atlantafx/base/theme/PrimerLight.java index 829ed02..a9319a6 100755 --- a/base/src/main/java/atlantafx/base/theme/PrimerLight.java +++ b/base/src/main/java/atlantafx/base/theme/PrimerLight.java @@ -2,22 +2,34 @@ package atlantafx.base.theme; +/** + * A theme based on Github Primer color palette. + */ public final class PrimerLight implements Theme { public PrimerLight() { // Default constructor } + /** + * {@inheritDoc} + */ @Override public String getName() { return "Primer Light"; } + /** + * {@inheritDoc} + */ @Override public String getUserAgentStylesheet() { return "/atlantafx/base/theme/primer-light.css"; } + /** + * {@inheritDoc} + */ @Override public boolean isDarkMode() { return false; diff --git a/base/src/main/java/atlantafx/base/theme/Styles.java b/base/src/main/java/atlantafx/base/theme/Styles.java index 34a85bb..01b736b 100644 --- a/base/src/main/java/atlantafx/base/theme/Styles.java +++ b/base/src/main/java/atlantafx/base/theme/Styles.java @@ -6,6 +6,10 @@ import javafx.css.PseudoClass; import javafx.scene.Node; import javafx.scene.control.TabPane; +/** + * A set of constants and utility methods that simplifies adding + * CSS classes programmatically. + */ @SuppressWarnings("unused") public final class Styles { @@ -84,6 +88,10 @@ public final class Styles { // Default constructor } + /** + * Adds given style class to the node if it's not present, otherwise + * removes it. + */ public static void toggleStyleClass(Node node, String styleClass) { if (node == null) { throw new NullPointerException("Node cannot be null!"); @@ -100,6 +108,11 @@ public final class Styles { } } + /** + * Adds given style class to the node and removes the excluded classes. + * This method is supposed to be used when only one from a set of classes + * have to be present at once. + */ public static void addStyleClass(Node node, String styleClass, String... excludes) { if (node == null) { throw new NullPointerException("Node cannot be null!"); @@ -114,6 +127,11 @@ public final class Styles { node.getStyleClass().add(styleClass); } + /** + * Activates given pseudo-class to the node and deactivates the excluded pseudo-classes. + * This method is supposed to be used when only one from a set of pseudo-classes + * have to be present at once. + */ public static void activatePseudoClass(Node node, PseudoClass pseudoClass, PseudoClass... excludes) { if (node == null) { throw new NullPointerException("Node cannot be null!"); diff --git a/base/src/main/java/atlantafx/base/theme/Theme.java b/base/src/main/java/atlantafx/base/theme/Theme.java index 2c5333a..9794d50 100755 --- a/base/src/main/java/atlantafx/base/theme/Theme.java +++ b/base/src/main/java/atlantafx/base/theme/Theme.java @@ -5,17 +5,33 @@ package atlantafx.base.theme; import static javafx.application.Application.STYLESHEET_CASPIAN; import static javafx.application.Application.STYLESHEET_MODENA; -// This is merely a wrapper around stylesheet paths. -// Let's hope JavaFX theme support will be merged. -// https://github.com/openjdk/jfx/pull/511 +import javafx.application.Application; + +/** + * Basic theme interface. + */ public interface Theme { + /** + * Returns theme name. + */ String getName(); + /** + * Returns the path to the theme user-agent stylesheet. + * See {@link Application#setUserAgentStylesheet(String)} for more info. + */ String getUserAgentStylesheet(); + /** + * Signifies whether the theme uses a light font on a dark background + * or vise versa. + */ boolean isDarkMode(); + /** + * Simple factory method for instantiating a new theme. + */ static Theme of(final String name, final String userAgentStylesheet, final boolean darkMode) { if (name == null) { throw new NullPointerException("Name cannot be null!"); @@ -43,6 +59,9 @@ public interface Theme { }; } + /** + * Returns whether the theme is a standard theme provided by the OpenJFX or a custom theme. + */ default boolean isDefault() { return STYLESHEET_MODENA.equals(getUserAgentStylesheet()) || STYLESHEET_CASPIAN.equals(getUserAgentStylesheet());