public final class StyleManager extends Object
ComponentDescriptor
s usage for adjusting default component settings.
It also manages global and per-component Skin
s and custom component Painter
s.Skin
,
SkinExtension
,
StyleId
,
StyleData
Constructor and Description |
---|
StyleManager() |
Modifier and Type | Method and Description |
---|---|
static void |
addExtensions(SkinExtension... extensions)
Adds new
SkinExtension s which will either be loaded right away if manager is initialized or later on if its not. |
static void |
addSkinListener(SkinListener listener)
Adds skin change listener.
|
static void |
addStyleListener(JComponent component,
StyleListener listener)
Adds
StyleListener . |
static void |
fireSkinChanged(Skin previous,
Skin current)
Informs listeners about skin change.
|
static Painter |
getCustomPainter(JComponent component)
Returns custom
Painter used for the specified JComponent . |
protected static StyleData |
getData(JComponent component)
Returns component style data.
|
static LazyInstance<? extends Skin> |
getDefaultSkin()
Returns
LazyInstance for default Skin . |
static ComponentDescriptor |
getDescriptor(Class<? extends JComponent> componentClass)
Returns
ComponentDescriptor for the specified JComponent class. |
static ComponentDescriptor |
getDescriptor(JComponent component)
Returns
ComponentDescriptor for the specified JComponent . |
static ComponentDescriptor |
getDescriptor(String id)
Returns
ComponentDescriptor with the specified identifier. |
static List<ComponentDescriptor> |
getDescriptors()
Returns immutable list of all registered
ComponentDescriptor s. |
static int |
getDescriptorsCount()
Returns all registered
ComponentDescriptor s count. |
static List<SkinExtension> |
getExtensions()
Returns list of installed
SkinExtension s. |
static Skin |
getSkin()
Returns currently applied
Skin . |
static Skin |
getSkin(JComponent component)
Returns skin currently applied to the specified component.
|
static StyleId |
getStyleId(JComponent component)
Returns component
StyleId . |
static void |
initialize()
Initializes
StyleManager settings. |
static void |
installSkin(JComponent component)
Applies current skin to the skinnable component.
|
static boolean |
isStrictStyleChecks()
Returns whether strict style checks are enabled or not.
|
static boolean |
isSupported(JComponent component)
Returns whether or not styling of the specified
JComponent is supported. |
static boolean |
isSupported(String id)
Returns whether or not styling is supported for the component with the specified identifier.
|
static void |
registerComponentDescriptor(ComponentDescriptor descriptor)
Registers new
ComponentDescriptor . |
static void |
removeSkinListener(SkinListener listener)
Removes skin change listener.
|
static void |
removeStyleListener(JComponent component,
StyleListener listener)
Removes
StyleListener . |
static boolean |
resetCustomPainter(JComponent component)
Resets custom
Painter for the specified JComponent to default one. |
static Skin |
resetSkin(JComponent component)
Resets skin for the specified component and all of its children linked via
StyleId . |
static StyleId |
resetStyleId(JComponent component)
Resets
StyleId to default value. |
static Painter |
setCustomPainter(JComponent component,
Painter painter)
Sets custom
Painter for the specified JComponent . |
static void |
setDefaultSkin(Class<? extends Skin> skin,
Object... arguments)
Changes default
Skin used upon StyleManager initialization. |
static void |
setDefaultSkin(LazyInstance<? extends Skin> skin)
Changes default
Skin used upon StyleManager initialization. |
static void |
setDefaultSkin(String skin,
Object... arguments)
Changes default
Skin used upon StyleManager initialization. |
static Skin |
setSkin(Class<? extends Skin> skin,
Object... arguments)
|
static Skin |
setSkin(JComponent component,
Skin skin)
Applies specified custom skin to the skinnable component and all of its children linked via
StyleId . |
static Skin |
setSkin(JComponent component,
Skin skin,
boolean recursively)
Applies specified custom skin to the skinnable component and all of its children linked via
StyleId . |
static Skin |
setSkin(LazyInstance<? extends Skin> skin)
|
static Skin |
setSkin(Skin skin)
|
static Skin |
setSkin(String skin,
Object... arguments)
|
static void |
setStrictStyleChecks(boolean strict)
Sets whether strict style checks are enabled or not.
|
static StyleId |
setStyleId(JComponent component,
StyleId id)
Sets new component
StyleId . |
static void |
uninstallSkin(JComponent component)
Removes skin applied to the specified component and returns it.
|
static void |
unregisterComponentDescriptor(ComponentDescriptor descriptor)
Unregisters existing
ComponentDescriptor . |
static void |
updateSkin(JComponent component)
Updates current skin in the skinnable component.
|
public static void initialize()
StyleManager
settings.public static boolean isStrictStyleChecks()
public static void setStrictStyleChecks(boolean strict)
strict
- whether strict style checks are enabled or notpublic static int getDescriptorsCount()
ComponentDescriptor
s count.ComponentDescriptor
s count@NotNull public static List<ComponentDescriptor> getDescriptors()
ComponentDescriptor
s.ComponentDescriptor
s@NotNull public static ComponentDescriptor getDescriptor(@NotNull String id)
ComponentDescriptor
with the specified identifier.id
- ComponentDescriptor
identifierComponentDescriptor
with the specified identifier@NotNull public static ComponentDescriptor getDescriptor(@NotNull JComponent component)
ComponentDescriptor
for the specified JComponent
.component
- JComponent
to find ComponentDescriptor
forComponentDescriptor
for the specified JComponent
@NotNull public static ComponentDescriptor getDescriptor(@NotNull Class<? extends JComponent> componentClass)
ComponentDescriptor
for the specified JComponent
class.
This method will also ensure that returned ComponentDescriptor
is never null
.componentClass
- JComponent
class to find ComponentDescriptor
forComponentDescriptor
for the specified JComponent
classpublic static boolean isSupported(@NotNull String id)
id
- identifier of the component to check styling support fortrue
if styling is supported for the component with the specified identifier, false
otherwisepublic static boolean isSupported(@NotNull JComponent component)
JComponent
is supported.component
- component to check styling support fortrue
if styling of the specified JComponent
is supported, false
otherwisepublic static void registerComponentDescriptor(@NotNull ComponentDescriptor descriptor)
ComponentDescriptor
.
It will replace any other ComponentDescriptor
registered for the same JComponent
type.
Manager initialization is not required to register ComponentDescriptor
.descriptor
- ComponentDescriptor
to registerpublic static void unregisterComponentDescriptor(@NotNull ComponentDescriptor descriptor)
ComponentDescriptor
.
Manager initialization is not required to unregister ComponentDescriptor
.descriptor
- ComponentDescriptor
to register@NotNull public static LazyInstance<? extends Skin> getDefaultSkin()
LazyInstance
for default Skin
.LazyInstance
for default Skin
public static void setDefaultSkin(@NotNull String skin, @NotNull Object... arguments)
Skin
used upon StyleManager
initialization.
StyleManager
doesn't need to be initialized to change it.public static void setDefaultSkin(@NotNull Class<? extends Skin> skin, @NotNull Object... arguments)
Skin
used upon StyleManager
initialization.
StyleManager
doesn't need to be initialized to change it.public static void setDefaultSkin(@NotNull LazyInstance<? extends Skin> skin)
Skin
used upon StyleManager
initialization.
Manager initialization is not required to change default Skin
.skin
- default skin class@NotNull public static Skin getSkin()
Skin
.Skin
@Nullable public static Skin setSkin(@NotNull Class<? extends Skin> skin, @NotNull Object... arguments)
@Nullable public static Skin setSkin(@NotNull LazyInstance<? extends Skin> skin)
Skin
based on the LazyInstance
to all Styleable
components.
That Skin
will also be applied to all Styleable
components created afterwards.skin
- LazyInstance
for Skin
Skin
public static void addExtensions(@NotNull SkinExtension... extensions)
SkinExtension
s which will either be loaded right away if manager is initialized or later on if its not.
Manager initialization is not required to provide additional SkinExtension
s.extensions
- SkinExtension
s to add@NotNull public static List<SkinExtension> getExtensions()
SkinExtension
s.SkinExtension
s@NotNull public static StyleId getStyleId(@NotNull JComponent component)
StyleId
.@NotNull public static StyleId setStyleId(@NotNull JComponent component, @NotNull StyleId id)
StyleId
.@NotNull public static StyleId resetStyleId(@NotNull JComponent component)
StyleId
to default value.public static void installSkin(@NotNull JComponent component)
component
- component to apply skin topublic static void updateSkin(@NotNull JComponent component)
component
- component to update skin forpublic static void uninstallSkin(@NotNull JComponent component)
component
- component to remove skin frompublic static Skin getSkin(@NotNull JComponent component)
component
- component to retrieve applied skin from@Nullable public static Skin setSkin(@NotNull JComponent component, @NotNull Skin skin)
StyleId
.
Actual linked children information is stored within StyleData
data objects.
Custom skin provided using this method will not be replaced if application skin changes.component
- component to apply skin toskin
- skin to be applied@Nullable public static Skin setSkin(@NotNull JComponent component, @NotNull Skin skin, boolean recursively)
StyleId
.
Actual linked children information is stored within StyleData
data objects.
Custom skin provided using this method will not be replaced if application skin changes.component
- component to apply skin toskin
- skin to be appliedrecursively
- whether or not should apply skin to child components@Nullable public static Skin resetSkin(@NotNull JComponent component)
StyleId
.
Actual linked children information is stored within StyleData
data objects.
Resetting component skin will also include it back into the skin update cycle in case global skin will be changed.component
- component to reset skin forpublic static void addStyleListener(@NotNull JComponent component, @NotNull StyleListener listener)
StyleListener
.component
- JComponent
to add listener forlistener
- StyleListener
public static void removeStyleListener(@NotNull JComponent component, @NotNull StyleListener listener)
StyleListener
.component
- JComponent
to remove listener forlistener
- StyleListener
@Nullable public static Painter getCustomPainter(@NotNull JComponent component)
Painter
used for the specified JComponent
.component
- JComponent
to retrieve custom Painter
forPainter
used for the specified JComponent
@Nullable public static Painter setCustomPainter(@NotNull JComponent component, @NotNull Painter painter)
Painter
for the specified JComponent
.component
- JComponent
to change custom Painter
forpainter
- custom Painter
Painter
previously used for the specified JComponent
public static boolean resetCustomPainter(@NotNull JComponent component)
Painter
for the specified JComponent
to default one.component
- JComponent
to reset custom Painter
fortrue
if custom Painter
was successfully resetted, false
otherwise@NotNull protected static StyleData getData(@NotNull JComponent component)
component
- component to retrieve style data forpublic static void addSkinListener(@NotNull SkinListener listener)
listener
- skin change listener to addpublic static void removeSkinListener(@NotNull SkinListener listener)
listener
- skin change listener to removeCopyright © 2020. All rights reserved.