Class AbstractDelegate<C extends JComponent>
- Type Parameters:
C- The type of the component that is delegated.
- Direct Known Subclasses:
ComponentDelegate,SplitButtonDelegate,SplitItemDelegate
Instances of this class are passed to various user event
Action handlers.
You can use this to change the state of the component, schedule animations
for the component or query the tree of the components.-
Method Summary
Modifier and TypeMethodDescriptionprotected final Cprotected final boolean_isUndefinedColor(Color color) Checks if the given color is the undefined color constant with respect to regular object identity instead of value equality.protected final boolean_isUndefinedFont(Font font) Checks if the given font is the undefined font constant with respect to regular object identity instead of value equality.protected final List<JComponent> A library internal utility method that exposes the sibling components of the delegated component.final AnimationDispatcheranimateFor(double duration, TimeUnit unit) Exposes access the animation builder API, where you can define the conditions under which the animation should be executed and then dispatch the animation to the EDT through theAnimationDispatcher.go(Animation)method.final voidanimateFor(double duration, TimeUnit unit, Animation animation) Use this to schedule and run the provided animation to be executed on the EDT.final AnimationDispatcheranimateFor(LifeTime lifeTime) Exposes access the animation builder API, where you can define the conditions under which the animation should be executed and then dispatch the animation to the EDT through theAnimationDispatcher.go(Animation)method.final voidanimateFor(LifeTime lifeTime, Animation animation) Use this to schedule and run the provided animation to be executed on the EDT.final voidanimateStyleFor(double duration, TimeUnit unit, AnimatedStyler<C> styler) A common use case is to animate the style of a component when a user event occurs.final voidanimateStyleFor(LifeTime lifetime, AnimatedStyler<C> styler) A common use case is to animate the style of a component when a user event occurs.final <T extends JComponent>
OptionalUI<T> Use this to query the UI tree and find anyJComponentof a particular type and id (the name of the component).final <T extends JComponent>
OptionalUI<T> Use this to query the UI tree and find anyJComponentof a particular type and id (the name of the component).final <T extends JComponent>
OptionalUI<T> Use this to query the UI tree and find anyJComponentbased on a specific type and a predicate which is used to test if a particular component in the tree is the one you are looking for.final <T extends JComponent>
List<T> Use this to query the UI tree and find allJComponents based on a specific type and a predicate which is used to test if a particular component in the tree is the one you are looking for.final <T extends JComponent>
List<T> findAllByGroup(Class<T> type, Enum<?> group) Use this to query the UI tree and find allJComponents of a particular type and also that belong to a particular style group.final <T extends JComponent>
List<T> findAllByGroup(Class<T> type, String group) Use this to query the UI tree and find allJComponents of a particular type and also that belong to a particular style group.final List<JComponent> findAllByGroup(Enum<?> group) Use this to query the UI tree and find allJComponents that belong to a particular style group.final List<JComponent> findAllByGroup(String group) Use this to query the UI tree and find allJComponents that belong to a particular style group.final Cget()This is a delegate to the underlying component, but not every method of the component is delegated.final ColorAs a delegate to the underlying component, you can use this method to conveniently get the background color of the component.final BorderAs a delegate to the underlying component, you can use this method to conveniently get the border of the component.final BoundsAs a delegate to the underlying component, you can use this method to conveniently get the bounds of the component in the form of an immutableBoundsvalue object.final CursorAs a delegate to the underlying component, you can use this method to conveniently get theCursorof the component.final FontgetFont()As a delegate to the underlying component, you can use this method to conveniently get the font of the component.final ColorAs a delegate to the underlying component, you can use this method to conveniently get the foreground color of the component.final intAs a delegate to the underlying component, you can use this method to conveniently get the height of the component.final PositionAs a delegate to the underlying component, you can use this method to conveniently access the location of the component relative to its parent in the form of an immutablePositionvalue object.final SizeAs a delegate to the underlying component, you can use this method to conveniently get the maximum size of the component.final SizeAs a delegate to the underlying component, you can use this method to conveniently get the minimum size of the component.final ContainerThis is class a delegate API, which means that it represents the API of a wrapped component.final SizeAs a delegate to the underlying component, you can use this method to conveniently get the preferred size of the component.floatgetScale()The number returned by this method is used to scale the UI to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).final SizegetSize()As a delegate to the underlying component, you can use this method to conveniently get the size of the component.final StringAs a delegate to the underlying component, you can use this method to conveniently get the tooltip of the component.final intgetWidth()As a delegate to the underlying component, you can use this method to conveniently get the width of the component.final intgetX()As a delegate to the underlying component, you can use this method to conveniently access the x-coordinate of the component relative to its parent.final intgetY()As a delegate to the underlying component, you can use this method to conveniently access the y-coordinate of the component relative to its parent.final booleanAs a delegate to the underlying component, you can use this method to conveniently check if the component is enabled.final booleanisOpaque()As a delegate to the underlying component, you can use this method to conveniently check if the component is opaque.final booleanAs a delegate to the underlying component, you can use this method to conveniently check if the component is visible.final voidpaint(AnimationStatus status, Painter painter) A common use case is to render something on top of theUI.ComponentArea.BODYof the component using theGraphics2Dinstance of the component.final voidpaint(UI.ComponentArea area, AnimationStatus status, Painter painter) A common use case is to render something on top of the component using theGraphics2Dinstance of the component.final voidpaint(UI.ComponentArea area, UI.Layer layer, AnimationStatus status, Painter painter) A common use case is to render something on top of the component using theGraphics2Dinstance used by the component to render itself.final voidpaint(UI.Layer layer, AnimationStatus status, Painter painter) A common use case is to render something on top of theUI.ComponentArea.BODYof the component using theGraphics2Dinstance of the component.final voidparentDelegate(sprouts.Action<AbstractDelegate<JComponent>> action) Use this method to delegate to the parent of the component.floatscale()The number returned by this method is used to scale the UI to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).doublescale(double value) Use this method inside customPainterimplementations (seepaint(AnimationStatus, Painter)) to scale adoublevalue by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).floatscale(float value) Use this method inside customPainterimplementations (seepaint(AnimationStatus, Painter)) to scale afloatvalue by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).intscale(int value) Use this method inside customPainterimplementations (seepaint(AnimationStatus, Painter)) to scale anintvalue by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).final AbstractDelegate<C> setBackground(Color color) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final AbstractDelegate<C> setBackgroundColor(double r, double g, double b) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final AbstractDelegate<C> setBackgroundColor(double r, double g, double b, double a) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final AbstractDelegate<C> setBackgroundColor(int r, int g, int b) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final AbstractDelegate<C> setBackgroundColor(int r, int g, int b, int a) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final AbstractDelegate<C> As a delegate to the underlying component, you can use this method to conveniently set the border of the component.final AbstractDelegate<C> setBounds(int x, int y, int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the bounds of the component.final AbstractDelegate<C> As a delegate to the underlying component, you can use this method to conveniently set the bounds of the component.final AbstractDelegate<C> Delegates to theComponent.setBounds(int, int, int, int)method of the underlying component.final AbstractDelegate<C> As a delegate to the underlying component, you can use this method to conveniently set theCursorof the component.final AbstractDelegate<C> As a delegate to the underlying component, you can use this method to conveniently set theUI.Cursorof the component.final AbstractDelegate<C> setEnabled(boolean enabled) As a delegate to the underlying component, you can use this method to conveniently enable or disable the component.final AbstractDelegate<C> As a delegate to the underlying component, you can use this method to conveniently set the font of the component.final AbstractDelegate<C> setForeground(Color color) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final AbstractDelegate<C> setForegroundColor(double r, double g, double b) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final AbstractDelegate<C> setForegroundColor(double r, double g, double b, double a) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final AbstractDelegate<C> setForegroundColor(int r, int g, int b) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final AbstractDelegate<C> setForegroundColor(int r, int g, int b, int a) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final AbstractDelegate<C> setHeight(int height) As a delegate to the underlying component, you can use this method to conveniently set the height of the component.final AbstractDelegate<C> setMaxHeight(int height) As a delegate to the underlying component, you can use this method to conveniently set the maximum height of the component.final AbstractDelegate<C> setMaxSize(int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component.final AbstractDelegate<C> setMaxSize(Dimension size) As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component.final AbstractDelegate<C> setMaxSize(Size size) As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component.final AbstractDelegate<C> setMaxWidth(int width) As a delegate to the underlying component, you can use this method to conveniently set the maximum width of the component.final AbstractDelegate<C> setMinHeight(int height) As a delegate to the underlying component, you can use this method to conveniently set the minimum height of the component.final AbstractDelegate<C> setMinSize(int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component.final AbstractDelegate<C> setMinSize(Dimension size) As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component.final AbstractDelegate<C> setMinSize(Size size) As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component.final AbstractDelegate<C> setMinWidth(int width) As a delegate to the underlying component, you can use this method to conveniently set the minimum width of the component.final AbstractDelegate<C> setOpaque(boolean opaque) As a delegate to the underlying component, you can use this method to conveniently make the component opaque or transparent.final AbstractDelegate<C> setPrefHeight(int height) As a delegate to the underlying component, you can use this method to conveniently set the preferred height of the component.final AbstractDelegate<C> setPrefSize(int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component.final AbstractDelegate<C> setPrefSize(Dimension size) As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component.final AbstractDelegate<C> setPrefSize(Size size) As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component.final AbstractDelegate<C> setPrefWidth(int width) As a delegate to the underlying component, you can use this method to conveniently set the preferred width of the component.final AbstractDelegate<C> setSize(int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the size of the component.final AbstractDelegate<C> As a delegate to the underlying component, you can use this method to conveniently set the size of the component.final AbstractDelegate<C> As a delegate to the underlying component, you can use this method to conveniently set the size of the component.final AbstractDelegate<C> setTooltip(String text) As a delegate to the underlying component, you can use this method to conveniently set the tooltip of the component.final AbstractDelegate<C> setVisible(boolean visible) As a delegate to the underlying component, you can use this method to conveniently enable or disable the component.final AbstractDelegate<C> setWidth(int width) As a delegate to the underlying component, you can use this method to conveniently set the width of the component.shapeOf(UI.ComponentArea area) As a delegate to the underlying component, you can use this method to access a specificUI.ComponentAreaof the component.final voidstyle(AnimationStatus state, Styler<C> styler) A common use case is to style the component based on the current animation state.
-
Method Details
-
_isUndefinedFont
Checks if the given font is the undefined font constant with respect to regular object identity instead of value equality. This is a deliberate design choice to allow the user to use theUI.Font.UNDEFINEDconstant instead ofnullas a placeholder for the absence of a font.- Parameters:
font- The font to check.- Returns:
trueif the font is the undefined font constant,falseotherwise.
-
_isUndefinedColor
Checks if the given color is the undefined color constant with respect to regular object identity instead of value equality. This is a deliberate design choice to allow the user to use theUI.Color.UNDEFINEDconstant instead ofnullas a placeholder for the absence of a color.- Parameters:
color- The color to check.- Returns:
trueif the color is the undefined color constant,falseotherwise.
-
_component
-
_siblingsSource
A library internal utility method that exposes the sibling components of the delegated component.- Returns:
- A list of sibling components.
-
get
This is a delegate to the underlying component, but not every method of the component is delegated. This method allows you to access the underlying component directly.Note that this method expects that the accessing thread is the event dispatch thread, not the application thread. If you want to access the component from the application thread, you should use
UI.run(() -> delegate.component()).- Returns:
- The underlying component.
- Throws:
IllegalStateException- If the accessing thread is not the event dispatch thread.
-
getX
public final int getX()As a delegate to the underlying component, you can use this method to conveniently access the x-coordinate of the component relative to its parent.- Returns:
- The x-coordinate of the component relative to its parent.
-
getY
public final int getY()As a delegate to the underlying component, you can use this method to conveniently access the y-coordinate of the component relative to its parent.- Returns:
- The y-coordinate of the component relative to its parent.
-
getLocation
As a delegate to the underlying component, you can use this method to conveniently access the location of the component relative to its parent in the form of an immutablePositionvalue object. The value returned by this method is equal to the coordinate values returned bygetX()andgetY().- Returns:
- The location of the component relative to its parent.
-
getParent
This is class a delegate API, which means that it represents the API of a wrapped component. This method allows you to access the parent of the underlying component. In essence, this is a delegate toComponent.getParent().- Returns:
- The parent
Containerof the underlying component. - Throws:
IllegalStateException- If the accessing thread is not the event dispatch thread.
-
setBackground
As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)for more information.- Parameters:
color- The color that should be used to paint the background of the component. If this parameter isnullthen this component will inherit the background color of its parent.- Returns:
- The delegate itself.
-
setBackgroundColor
As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)for more information.- Parameters:
r- The red component of the color as a double between 0 and 1.g- The green component of the color as a double between 0 and 1.b- The blue component of the color as a double between 0 and 1.- Returns:
- The delegate itself.
-
setBackgroundColor
As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)for more information.- Parameters:
r- The red component of the color as a double between 0 and 1.g- The green component of the color as a double between 0 and 1.b- The blue component of the color as a double between 0 and 1.a- The alpha component of the color as a double between 0 and 1.- Returns:
- The delegate itself.
-
setBackgroundColor
As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)for more information.- Parameters:
r- The red component of the color as an integer between 0 and 255.g- The green component of the color as an integer between 0 and 255.b- The blue component of the color as an integer between 0 and 255.- Returns:
- The delegate itself.
-
setBackgroundColor
As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)for more information.- Parameters:
r- The red component of the color as an integer between 0 and 255.g- The green component of the color as an integer between 0 and 255.b- The blue component of the color as an integer between 0 and 255.a- The alpha component of the color as an integer between 0 and 255.- Returns:
- The delegate itself.
-
getBackground
As a delegate to the underlying component, you can use this method to conveniently get the background color of the component.See
Component.getBackground()for more information.- Returns:
- The background color of the component, or
UI.Color.UNDEFINEDif the component does not have a background color (i.e.Component.getBackground()returnsnull). The return value will never benull.
-
setForeground
As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)for more information.- Parameters:
color- The color that should be used to paint the foreground of the component. If this parameter isnullthen this component will inherit the foreground color of its parent.- Returns:
- The delegate itself.
-
getForeground
As a delegate to the underlying component, you can use this method to conveniently get the foreground color of the component.See
Component.getForeground()for more information.- Returns:
- The foreground color of the component, or
UI.Color.UNDEFINEDif the component does not have a foreground color (i.e.Component.getForeground()returnsnull). The return value will never benull.
-
setForegroundColor
As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)for more information.- Parameters:
r- The red component of the color as a double between 0 and 1.g- The green component of the color as a double between 0 and 1.b- The blue component of the color as a double between 0 and 1.- Returns:
- The delegate itself.
-
setForegroundColor
As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)for more information.- Parameters:
r- The red component of the color as a double between 0 and 1.g- The green component of the color as a double between 0 and 1.b- The blue component of the color as a double between 0 and 1.a- The alpha component of the color as a double between 0 and 1.- Returns:
- The delegate itself.
-
setForegroundColor
As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)for more information.- Parameters:
r- The red component of the color as an integer between 0 and 255.g- The green component of the color as an integer between 0 and 255.b- The blue component of the color as an integer between 0 and 255.- Returns:
- The delegate itself.
-
setForegroundColor
As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)for more information.- Parameters:
r- The red component of the color as an integer between 0 and 255.g- The green component of the color as an integer between 0 and 255.b- The blue component of the color as an integer between 0 and 255.a- The alpha component of the color as an integer between 0 and 255.- Returns:
- The delegate itself.
-
setFont
As a delegate to the underlying component, you can use this method to conveniently set the font of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setFont(Font)for more information.- Parameters:
font- The font that should be used to paint the text of the component. If this parameter isUI.Font.UNDEFINEDthen this component will inherit the font of its parent. Null is not allowed.- Returns:
- The delegate itself.
-
getFont
As a delegate to the underlying component, you can use this method to conveniently get the font of the component.See
Component.getFont()for more information.- Returns:
- The font of the component.
-
setBorder
As a delegate to the underlying component, you can use this method to conveniently set the border of the component. This method returns the delegate itself, so you can chain calls to this method.Note that this method is a delegate to
JComponent.setBorder(Border).- Parameters:
border- The border that should be used to paint the border of the component. If this parameter isnullthen this component will inherit the border of its parent.- Returns:
- The delegate itself.
-
getBorder
As a delegate to the underlying component, you can use this method to conveniently get the border of the component.Note that this method is a delegate to
JComponent.getBorder().- Returns:
- The border of the component.
-
setBounds
As a delegate to the underlying component, you can use this method to conveniently set the bounds of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBounds(int, int, int, int)for more information.- Parameters:
x- The x coordinate of the new location of the component. This is relative to the component's parent.y- The y coordinate of the new location of the component. This is relative to the component's parent.width- The new width of the component.height- The new height of the component.- Returns:
- The delegate itself, so you can chain calls to this method.
-
setBounds
Delegates to theComponent.setBounds(int, int, int, int)method of the underlying component. The bounds consist of a location and a size which are relative to the component's parent.- Parameters:
bounds- The new bounds of the component. This is relative to the component's parent.- Returns:
- The delegate itself, so you can chain calls to this method.
-
setBounds
As a delegate to the underlying component, you can use this method to conveniently set the bounds of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBounds(Rectangle)for more information.- Parameters:
bounds- The new bounds of the component. This is relative to the component's parent.- Returns:
- The delegate itself, so you can chain calls to this method.
-
getBounds
As a delegate to the underlying component, you can use this method to conveniently get the bounds of the component in the form of an immutableBoundsvalue object. The bounds consist of a location and a size which are relative to the component's parent.See
Component.getBounds()for more information.- Returns:
- The bounds of the component. This is relative to the component's parent.
-
shapeOf
As a delegate to the underlying component, you can use this method to access a specificUI.ComponentAreaof the component. This method returns anOptionalvalue, which means that the component area may not be present. TheUI.ComponentArea.BORDERfor example, may not be present in case of there not being a border width defined throughUIForAnySwing.withStyle(Styler).See
ComponentExtension.getComponentArea(UI.ComponentArea)for more information.- Parameters:
area- The component area to access.- Returns:
- An optional value that contains the component area if it is present.
-
setPrefSize
As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)for more information.- Parameters:
size- The preferred size of the component.- Returns:
- The delegate itself.
-
setPrefSize
As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)for more information.- Parameters:
size- The preferred size of the component.- Returns:
- The delegate itself.
-
setPrefSize
As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)for more information.- Parameters:
width- The preferred width of the component.height- The preferred height of the component.- Returns:
- The delegate itself.
-
setPrefWidth
As a delegate to the underlying component, you can use this method to conveniently set the preferred width of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)for more information.- Parameters:
width- The preferred width of the component.- Returns:
- The delegate itself.
-
setPrefHeight
As a delegate to the underlying component, you can use this method to conveniently set the preferred height of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)for more information.- Parameters:
height- The preferred height of the component.- Returns:
- The delegate itself.
-
getPrefSize
As a delegate to the underlying component, you can use this method to conveniently get the preferred size of the component. The preferred size is used by the layout manager to determine the size of the component.See
Component.getPreferredSize()for more information.- Returns:
- The preferred size of the component.
-
setMinSize
As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)for more information.- Parameters:
size- The minimum size of the component.- Returns:
- The delegate itself.
-
setMinSize
As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)for more information.- Parameters:
size- The minimum size of the component.- Returns:
- The delegate itself.
-
setMinSize
As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)for more information.- Parameters:
width- The minimum width of the component.height- The minimum height of the component.- Returns:
- The delegate itself.
-
setMinWidth
As a delegate to the underlying component, you can use this method to conveniently set the minimum width of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)for more information.- Parameters:
width- The minimum width of the component.- Returns:
- The delegate itself.
-
setMinHeight
As a delegate to the underlying component, you can use this method to conveniently set the minimum height of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)for more information.- Parameters:
height- The minimum height of the component.- Returns:
- The delegate itself.
-
getMinSize
As a delegate to the underlying component, you can use this method to conveniently get the minimum size of the component. The minimum size is used by the layout manager to determine the size of the component.See
Component.getMinimumSize()for more information.- Returns:
- The minimum size of the component.
-
setMaxSize
As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)for more information.- Parameters:
size- The maximum size of the component.- Returns:
- The delegate itself.
-
setMaxSize
As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)for more information.- Parameters:
size- The maximum size of the component.- Returns:
- The delegate itself.
-
setMaxSize
As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)for more information.- Parameters:
width- The maximum width of the component.height- The maximum height of the component.- Returns:
- The delegate itself.
-
setMaxWidth
As a delegate to the underlying component, you can use this method to conveniently set the maximum width of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)for more information.- Parameters:
width- The maximum width of the component.- Returns:
- The delegate itself.
-
setMaxHeight
As a delegate to the underlying component, you can use this method to conveniently set the maximum height of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)for more information.- Parameters:
height- The maximum height of the component.- Returns:
- The delegate itself.
-
getMaxSize
As a delegate to the underlying component, you can use this method to conveniently get the maximum size of the component. The maximum size is used by the layout manager to determine the size of the component.See
Component.getMaximumSize()for more information.- Returns:
- The maximum size of the component.
-
setSize
As a delegate to the underlying component, you can use this method to conveniently set the size of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)for more information.- Parameters:
size- The size of the component.- Returns:
- The delegate itself.
-
setSize
As a delegate to the underlying component, you can use this method to conveniently set the size of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)for more information.- Parameters:
size- The size of the component.- Returns:
- The delegate itself.
-
setSize
As a delegate to the underlying component, you can use this method to conveniently set the size of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)for more information.- Parameters:
width- The width of the component.height- The height of the component.- Returns:
- The delegate itself.
-
setWidth
As a delegate to the underlying component, you can use this method to conveniently set the width of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)for more information.- Parameters:
width- The width of the component.- Returns:
- The delegate itself.
-
setHeight
As a delegate to the underlying component, you can use this method to conveniently set the height of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)for more information.- Parameters:
height- The height of the component.- Returns:
- The delegate itself.
-
getSize
As a delegate to the underlying component, you can use this method to conveniently get the size of the component. The size is used by the layout manager to determine the size of the component.See
Component.getSize()for more information.- Returns:
- The size of the component.
-
getWidth
public final int getWidth()As a delegate to the underlying component, you can use this method to conveniently get the width of the component. The size is used by the layout manager to determine the size of the component.See
Component.getSize()for more information.- Returns:
- The width of the component.
-
getHeight
public final int getHeight()As a delegate to the underlying component, you can use this method to conveniently get the height of the component. The size is used by the layout manager to determine the size of the component.See
Component.getSize()for more information.- Returns:
- The height of the component.
-
setCursor
As a delegate to the underlying component, you can use this method to conveniently set theUI.Cursorof the component.- Parameters:
cursor- TheUI.Cursorwhich should be set.- Returns:
- The delegate itself.
-
setCursor
As a delegate to the underlying component, you can use this method to conveniently set theCursorof the component.- Parameters:
cursor- TheCursorwhich should be set.- Returns:
- The delegate itself.
-
getCursor
As a delegate to the underlying component, you can use this method to conveniently get theCursorof the component.- Returns:
- The
Cursorof the component.
-
setTooltip
As a delegate to the underlying component, you can use this method to conveniently set the tooltip of the component. This method returns the delegate itself, so you can chain calls to this method.See
JComponent.setToolTipText(String)for more information.- Parameters:
text- The tooltip text.- Returns:
- The delegate itself.
- Throws:
NullPointerException- If the text is null, use an empty string to model the absence of a tooltip.
-
getTooltip
As a delegate to the underlying component, you can use this method to conveniently get the tooltip of the component.See
JComponent.getToolTipText()for more information.- Returns:
- The tooltip text.
-
setEnabled
As a delegate to the underlying component, you can use this method to conveniently enable or disable the component. This method returns the delegate itself, so you can chain calls to this method.See
JComponent.setEnabled(boolean)for more information.- Parameters:
enabled- True if the component should be enabled, false otherwise.- Returns:
- The delegate itself.
-
isEnabled
public final boolean isEnabled()As a delegate to the underlying component, you can use this method to conveniently check if the component is enabled.See
Component.isEnabled()for more information.- Returns:
- True if the component is enabled, false otherwise.
-
setVisible
As a delegate to the underlying component, you can use this method to conveniently enable or disable the component. This method returns the delegate itself, so you can chain calls to this method.See
JComponent.setVisible(boolean)for more information.- Parameters:
visible- True if the component should be visible, false otherwise.- Returns:
- The delegate itself.
-
isVisible
public final boolean isVisible()As a delegate to the underlying component, you can use this method to conveniently check if the component is visible.See
Component.isVisible()for more information.- Returns:
- True if the component is visible, false otherwise.
-
setOpaque
As a delegate to the underlying component, you can use this method to conveniently make the component opaque or transparent. This method returns the delegate itself, so you can chain calls to this method.See
JComponent.setOpaque(boolean)for more information.- Parameters:
opaque- True if the component should be opaque, false otherwise.- Returns:
- The delegate itself.
-
isOpaque
public final boolean isOpaque()As a delegate to the underlying component, you can use this method to conveniently check if the component is opaque.See
JComponent.isOpaque()for more information.- Returns:
- True if the component is opaque, false otherwise.
-
find
Use this to query the UI tree and find anyJComponentof a particular type and id (the name of the component).- Type Parameters:
T- The type parameter of the component which should be found.- Parameters:
type- TheJComponenttype which should be found in the swing tree.id- The ide of theJComponentwhich should be found in the swing tree.- Returns:
- An
Optionalinstance which may or may not contain the requested component.
-
find
Use this to query the UI tree and find anyJComponentof a particular type and id (the name of the component).- Type Parameters:
T- The type parameter of the component which should be found.- Parameters:
type- TheJComponenttype which should be found in the swing tree.id- The ide of theJComponentwhich should be found in the swing tree.- Returns:
- An
Optionalinstance which may or may not contain the requested component.
-
find
Use this to query the UI tree and find anyJComponentbased on a specific type and a predicate which is used to test if a particular component in the tree is the one you are looking for.- Type Parameters:
T- The type parameter of the component which should be found.- Parameters:
type- TheJComponenttype which should be found in the swing tree.predicate- The predicate which should be used to test theJComponent.- Returns:
- An
Optionalinstance which may or may not contain the requested component.
-
findAll
Use this to query the UI tree and find allJComponents based on a specific type and a predicate which is used to test if a particular component in the tree is the one you are looking for.- Type Parameters:
T- The type parameter of the component which should be found.- Parameters:
type- TheJComponenttype which should be found in the swing tree.predicate- The predicate which should be used to test theJComponent.- Returns:
- A list of
JComponentinstances which match the given type and predicate.
-
findAllByGroup
Use this to query the UI tree and find allJComponents of a particular type and also that belong to a particular style group.- Type Parameters:
T- The type parameter of the component which should be found.- Parameters:
type- TheJComponenttype which should be found in the swing tree.group- The style group which should be used to test theJComponent.- Returns:
- A list of
JComponentinstances which match the given type and group.
-
findAllByGroup
Use this to query the UI tree and find allJComponents that belong to a particular style group.- Parameters:
group- The style group which should be used to check if a particularJComponentbelongs to it.- Returns:
- A list of
JComponentinstances which all have the given style group. - Throws:
NullPointerException- If the group is null.
-
findAllByGroup
Use this to query the UI tree and find allJComponents of a particular type and also that belong to a particular style group.- Type Parameters:
T- The type parameter of the component which should be found.- Parameters:
type- TheJComponenttype which should be found in the swing tree.group- The style group which should be used to test theJComponent.- Returns:
- A list of
JComponentinstances which match the given type and predicate.
-
findAllByGroup
Use this to query the UI tree and find allJComponents that belong to a particular style group.- Parameters:
group- The style group which should be used to check if a particularJComponentbelongs to it.- Returns:
- A list of
JComponentinstances which all have the given style group.
-
paint
A common use case is to render something on top of theUI.ComponentArea.BODYof the component using theGraphics2Dinstance of the component. This method allows you to attach a paint task to the component, which the EDT will process in the next repaint event cycle, and remove when the animation expires. This ensures that custom rendering is not erased by a potential repaint of the component after a user event.Here is an example of how to use this method as part of a fancy button animation:
You may also be interested in doing style animations, if so, maybe consider taking a look atUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, status -> { double r = 300 * status.progress() * it.scale(); double x = it.mouseX() - r / 2; double y = it.mouseY() - r / 2; it.paint(status, g -> { g.setColor(new Color(1f, 1f, 0f, (float) (1 - status.progress()))); g.fillOval((int) x, (int) y, (int) r, (int) r); }); }))UIForAnySwing.withTransitoryStyle(sprouts.Observable, LifeTime, AnimatedStyler)to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)to see how to do 2 state switch based styling animations.- Parameters:
status- The current animation progress status, which is important so that the rendering can be synchronized with the animation.painter- The rendering task which should be executed on the EDT at the end of the current event cycle.
-
paint
A common use case is to render something on top of the component using theGraphics2Dinstance of the component. This method allows you to attach a paint task to the component, which the EDT will process in the next repaint event cycle, and remove when the animation expires. This ensures that custom rendering is not erased by a potential repaint of the component after a user event.
Additionally, you can specify the area of the component which should be painted.Here is an example of how to use this method as part of a button animation:
You may also be interested in doing style animations, if so, maybe consider taking a look atUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, status -> { double r = 300 * status.progress() * it.scale(); double x = it.mouseX() - r / 2; double y = it.mouseY() - r / 2; it.paint(UI.ComponentArea.BORDER, state, g -> { g.setColor(new Color(1f, 1f, 0f, (float) (1 - status.progress()))); g.fillOval((int) x, (int) y, (int) r, (int) r); }); }))UIForAnySwing.withTransitoryStyle(sprouts.Observable, LifeTime, AnimatedStyler)to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)to see how to do 2 state switch based styling animations.- Parameters:
area- The area of the component which should be painted.status- The current animation progress status, which needs to be provided so that the rendering can be synchronized with the animation.painter- The rendering task which should be executed on the EDT at the end of the current event cycle.
-
paint
A common use case is to render something on top of theUI.ComponentArea.BODYof the component using theGraphics2Dinstance of the component. This method allows you to attach a paint task to the component, which the EDT will process in the next repaint event cycle, and remove when the animation expires. This ensures that custom rendering is not erased by a potential repaint of the component after a user event.Here is an example of how to use this method as part of a fancy button animation:
You may also be interested in doing style animations, if so, maybe consider taking a look atUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, status -> { double r = 300 * status.progress() * it.scale(); double x = it.mouseX() - r / 2; double y = it.mouseY() - r / 2; it.paint(UI.Layer.CONTENT, status, g -> { g.setColor(new Color(1f, 1f, 0f, (float) (1 - status.progress()))); g.fillOval((int) x, (int) y, (int) r, (int) r); }); }))UIForAnySwing.withTransitoryStyle(sprouts.Observable, LifeTime, AnimatedStyler)to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)to see how to do 2 state switch based styling animations.- Parameters:
layer- The layer of the component which should be painted on.status- The current animation progress status, which is important so that the rendering can be synchronized with the animation.painter- The rendering task which should be executed on the EDT at the end of the current event cycle.
-
paint
public final void paint(UI.ComponentArea area, UI.Layer layer, AnimationStatus status, Painter painter) A common use case is to render something on top of the component using theGraphics2Dinstance used by the component to render itself. This method allows you to attach a paint task to the component, which the EDT will process in the next repaint event cycle, and remove when the animation expires. This ensures that custom rendering is not erased by a potential repaint of the component after a user event.
Additionally, you can specify the area of the component which should be painted as well as a layer onto which the painter should paint.Here is an example of how to use this method as part of a button animation:
You may also be interested in doing style animations, if so, maybe consider taking a look atUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, status -> { double r = 300 * status.progress() * it.scale(); double x = it.mouseX() - r / 2; double y = it.mouseY() - r / 2; it.paint(UI.ComponentArea.BODY, UI.Layer.CONTENT, state, g -> { g.setColor(new Color(1f, 1f, 0f, (float) (1 - status.progress()))); g.fillOval((int) x, (int) y, (int) r, (int) r); }); }))UIForAnySwing.withTransitoryStyle(sprouts.Observable, LifeTime, AnimatedStyler)to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)to see how to do 2 state switch based styling animations.- Parameters:
area- The area of the component which should be painted.layer- The layer of the component which should be painted.status- The current animation progress status, which needs to be provided so that the rendering can be synchronized with the animation.painter- An implementation of a simple functional interface receiving aGraphics2Dinstance for doing paint operations...
-
parentDelegate
Use this method to delegate to the parent of the component. This is useful if you want to apply a style or animation to the parent of a component which just received an event, like a mouse click event.Here is an example demonstrating how to apply a style to the parent of a component when it is clicked:
UI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it .parentDelegate( parent -> parent .style( style -> style .borderWidth(6) .borderColor(Color.RED) .borderRadius(60) ) ) )
And here another more advanced example demonstrating how to do animated painting on the parent of a component that is being dragged away:
The paint method draws a circle around the drag origin of the drag event which gets smaller and more opaque as the animation progresses for a duration of 1 second.label("Drag me away") .withDragAway( conf -> conf .onDragStart( it -> { it.parentDelegate( parent -> parent .animateFor(1, TimeUnit.SECONDS, status -> { double r = 320 * status.fadeOut() * it.getScale(); double x = it.getEvent().getDragOrigin().getX() - r / 2; double y = it.getEvent().getDragOrigin().getY() - r / 2; parent.paint(status, g -> { g.setColor(new Color(0f, 1f, 1f, (float) status.fadeIn())); g.fillOval((int) x, (int) y, (int) r, (int) r); }); }) ); }) )
You may also be interested in doing style animations, if so, maybe consider taking a look at
UIForAnySwing.withTransitoryStyle(sprouts.Observable, LifeTime, AnimatedStyler)to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)to see how to do 2 state switch based styling animations.- Parameters:
action- The action which should be executed on the delegate of the parent component.
-
animateStyleFor
A common use case is to animate the style of a component when a user event occurs. This method allows you to dispatch a styling animation to the EDT which will cause the component style to updated repeatedly until the animation expires. Because animation styles are applied last, it is guaranteed not to be overwritten by otherStylerlambdas. Note that the provided styling will be removed automatically when the animation expires, so no manual cleanup is required.Here is an example of how to use this method as part of a fancy styling animation:
Not that the effect of this method can also be modelled usingUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateStyleFor(2, TimeUnit.SECONDS, (state, style) -> .borderWidthAt(UI.Edge.BOTTOM, (int)(6 * state.progress()) ) .borderColor( new Color(0f, 1f, 1f, (float) (1 - state.progress())) ) .borderRadius( (int)(60 * state.progress()) ) ))animateFor(LifeTime, Animation)andstyle(AnimationStatus, Styler)as follows:
Also seeUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, status -> { it.style(status, style -> style // This is the same as the animateStyleFor() method above! ); }))animateStyleFor(LifeTime, AnimatedStyler)for a version of this method which uses aLifeTimeinstead of a duration. If you are interested in doing more advanced style animations, consider taking a look atUIForAnySwing.withTransitoryStyle(sprouts.Observable, LifeTime, AnimatedStyler)to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)to see how to do 2 state switch based styling animations.- Parameters:
duration- The duration of the animation.unit- The time unit of the duration.styler- The styling animation task which should be executed on the EDT at the end of the current event cycle. It receives both the current animation state and theComponentStyleDelegatefor which you can define the style properties.
-
animateStyleFor
A common use case is to animate the style of a component when a user event occurs. This method allows you to dispatch a styling animation to the EDT which will cause the component style to updated repeatedly until the animation expires. Because animation styles are applied last, it is guaranteed not to be overwritten by otherStylerlambdas. Note that the provided styling will be removed automatically when the animation expires, so no manual cleanup is required.Here is an example of how to use this method as part of a fancy styling animation:
Not that the effect of this method can also be modelled usingUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateStyleFor(UI.lifetime(2, TimeUnit.SECONDS), (state, style) -> .borderWidthAt(UI.Edge.BOTTOM, (int)(6 * state.progress()) ) .borderColor( new Color(0f, 1f, 1f, (float) (1 - state.progress())) ) .borderRadius( (int)(60 * state.progress()) ) ))animateFor(LifeTime, Animation)andstyle(AnimationStatus, Styler)as follows:
Also seeUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(UI.lifetime(2, TimeUnit.SECONDS), status -> { it.style(status, style -> style // This is the same as the animateStyleFor() method above! ); }))animateStyleFor(double, TimeUnit, AnimatedStyler)for a version of this method which uses aLifeTimeinstead of a duration. If you are interested in doing more advanced style animations, consider taking a look atUIForAnySwing.withTransitoryStyle(sprouts.Observable, LifeTime, AnimatedStyler)to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)to see how to do 2 state switch based styling animations.- Parameters:
lifetime- The lifetime of the animation. The animation will be removed automatically when the lifetime expires.styler- The styling animation task which should be executed on the EDT at the end of the current event cycle. It receives both the current animation state and theComponentStyleDelegatefor which you can define the style properties.
-
style
A common use case is to style the component based on the current animation state. This method allows you to dispatch a styling task to the EDT which will be executed before the next component repaint. Because animation styles are applied last, it is guaranteed not to be overwritten by other styles. The provided styling will be removed when the animation expires.Here is an example of how to use this method as part of a fancy styling animation:
UI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, status -> { it.style(status, style -> style .borderWidth((int)(10 * status.progress())) .borderColor(new Color(1f, 1f, 0f, (float) (1 - status.progress()))) .borderRadius((int)(100 * status.progress())) ); }))- Parameters:
state- The current animation state, which is important so that the styling can be synchronized with the animation.styler- The styling task which should be executed on the EDT at the end of the current event cycle.
-
animateFor
Exposes access the animation builder API, where you can define the conditions under which the animation should be executed and then dispatch the animation to the EDT through theAnimationDispatcher.go(Animation)method.- Parameters:
duration- The duration of the animation.unit- The time unit of the duration.- Returns:
- An
AnimationDispatcherinstance which can be used to define how the animation should be executed.
-
animateFor
Exposes access the animation builder API, where you can define the conditions under which the animation should be executed and then dispatch the animation to the EDT through theAnimationDispatcher.go(Animation)method.- Parameters:
lifeTime- The lifetime of the animation.- Returns:
- An
AnimationDispatcherinstance which can be used to define how the animation should be executed.
-
animateFor
Use this to schedule and run the provided animation to be executed on the EDT. A single animation iteration may be executed multiple times for the given duration in order to achieve a smooth transition.
Here an example of how to use this method on a "Save" button:UI.button("Save").withPrefSize(400, 400) .onMouseClick( it -> it .animateFor( UI.lifetime(1, TimeUnit.SECONDS) .startingIn( 0.5, TimeUnit.SECONDS ) ) .go( myAnimation ) )- Parameters:
lifeTime- The lifetime of the animation.animation- The animation that should be executed.
-
animateFor
Use this to schedule and run the provided animation to be executed on the EDT. A single animation iteration may be executed multiple times for the given duration in order to achieve a smooth transition.- Parameters:
duration- The duration of the animation.unit- The time unit of the duration.animation- The animation that should be executed.
-
getScale
public float getScale()The number returned by this method is used to scale the UI to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI). Use it inside customPainterimplementations (seepaint(AnimationStatus, Painter)) to scale customGraphics2Dpainting operations.- Returns:
- The current UI scale factor, which is used to scale the UI for high resolution displays (high dots-per-inch, or DPI).
-
scale
public float scale()The number returned by this method is used to scale the UI to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI). Use it inside customPainterimplementations (seepaint(AnimationStatus, Painter)) to scale customGraphics2Dpainting operations.- Returns:
- The current UI scale factor, which is used to scale the UI for high resolution displays (high dots-per-inch, or DPI).
-
scale
public int scale(int value) Use this method inside customPainterimplementations (seepaint(AnimationStatus, Painter)) to scale anintvalue by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).- Parameters:
value- Theintvalue to scale.- Returns:
- The scaled
intvalue.
-
scale
public float scale(float value) Use this method inside customPainterimplementations (seepaint(AnimationStatus, Painter)) to scale afloatvalue by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).- Parameters:
value- Thefloatvalue to scale.- Returns:
- The scaled
floatvalue.
-
scale
public double scale(double value) Use this method inside customPainterimplementations (seepaint(AnimationStatus, Painter)) to scale adoublevalue by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).- Parameters:
value- Thedoublevalue to scale.- Returns:
- The scaled
doublevalue.
-