Update themes Javadoc
This commit is contained in:
parent
318cc43894
commit
12526c3e47
@ -4,6 +4,9 @@ package atlantafx.base.theme;
|
||||
|
||||
import atlantafx.base.Preview;
|
||||
|
||||
/**
|
||||
* A theme based on <a href="https://developer.apple.com/design/">IOS</a> 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;
|
||||
|
@ -4,6 +4,9 @@ package atlantafx.base.theme;
|
||||
|
||||
import atlantafx.base.Preview;
|
||||
|
||||
/**
|
||||
* A theme based on <a href="https://developer.apple.com/design/">IOS</a> 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;
|
||||
|
@ -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;
|
||||
|
@ -2,22 +2,34 @@
|
||||
|
||||
package atlantafx.base.theme;
|
||||
|
||||
/**
|
||||
* A theme based on <a href="https://primer.style/">Nord</a> 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;
|
||||
|
@ -2,22 +2,34 @@
|
||||
|
||||
package atlantafx.base.theme;
|
||||
|
||||
/**
|
||||
* A theme based on <a href="https://www.nordtheme.com/">Nord</a> 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;
|
||||
|
@ -2,22 +2,34 @@
|
||||
|
||||
package atlantafx.base.theme;
|
||||
|
||||
/**
|
||||
* A theme based on <a href="https://primer.style/">Github Primer</a> 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;
|
||||
|
@ -2,22 +2,34 @@
|
||||
|
||||
package atlantafx.base.theme;
|
||||
|
||||
/**
|
||||
* A theme based on <a href="https://primer.style/">Github Primer</a> 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;
|
||||
|
@ -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!");
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user