Package com.simsilica.lemur.value
Class DefaultValueRenderer<T>
java.lang.Object
com.simsilica.lemur.value.DefaultValueRenderer<T>
- All Implemented Interfaces:
ValueRenderer<T>
,Cloneable
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a value renderer with no preconfigured style, element ID, or string function.DefaultValueRenderer
(ElementId elementId, String style) Creates a value renderer with the preconfigured elementID and style.Creates a value renderer with a custom string function and the preconfigured elementID and style.DefaultValueRenderer
(Function<? super T, String> toString) Creates a value renderer with the specified string function but no configured element ID or style. -
Method Summary
Modifier and TypeMethodDescriptionclone()
void
configureStyle
(ElementId elementId, String style) Default implementation uses the specified style unless the renderer already has an elementId and style set.protected Label
createView
(T value, boolean selected) Called by getView() to create the new view when the existing view doesn't exist.getStyle()
Returns a new view Panel or returns a reconfigured version of the existing Panel that will display the specified value.void
setElementId
(ElementId elementId) Sets a preconfigured ElementId for created Panels.void
setStringTransform
(Function<? super T, String> toString) Sets the function that will convert values to Strings.void
Sets a preconfigured style for created Panels.protected String
valueToString
(T value) Called by getView() and createView() to conver the value to a string.
-
Field Details
-
DEFAULT_ID
-
-
Constructor Details
-
DefaultValueRenderer
public DefaultValueRenderer()Creates a value renderer with no preconfigured style, element ID, or string function. The renderer will pick up the style information that the using GUI element prefers. -
DefaultValueRenderer
Creates a value renderer with the specified string function but no configured element ID or style. The renderer will pick up the style information that the using GUI element prefers. -
DefaultValueRenderer
Creates a value renderer with the preconfigured elementID and style. For non-null elementId and style, this will ignore any style set by the using GUI element. Values will be converted to Strings using String.valueOf(). -
DefaultValueRenderer
Creates a value renderer with a custom string function and the preconfigured elementID and style. This will ignore any style set by the using GUI element if elementId or style are non-null.
-
-
Method Details
-
clone
-
configureStyle
Default implementation uses the specified style unless the renderer already has an elementId and style set.- Specified by:
configureStyle
in interfaceValueRenderer<T>
-
setStringTransform
Sets the function that will convert values to Strings. Set to null to use the default String.valueOf() behavior. -
getStringTransform
-
setElementId
Sets a preconfigured ElementId for created Panels. If this is non-null then the default implementation of configureStyle() will ignore the configureStyle() elementId argument. -
getElementId
-
setStyle
Sets a preconfigured style for created Panels. If this is non-null then the default implementation of configureStyle() will ignore the configureStyle() style argument. -
getStyle
-
valueToString
Called by getView() and createView() to conver the value to a string. Default implementation passes the value to the current string transform. -
createView
Called by getView() to create the new view when the existing view doesn't exist. Subclasses can override this to provide custom Label subclasses (like Button) to present the view. The default implementation creates a regular Label. -
getView
Description copied from interface:ValueRenderer
Returns a new view Panel or returns a reconfigured version of the existing Panel that will display the specified value. The 'selected' flag can indicate if the value should appear as selected or focused. For example, some views may change their color or animate if they are the selected view.- Specified by:
getView
in interfaceValueRenderer<T>
-