Class DefaultValueRenderer<T>

java.lang.Object
com.simsilica.lemur.value.DefaultValueRenderer<T>
All Implemented Interfaces:
ValueRenderer<T>, Cloneable

public class DefaultValueRenderer<T> extends Object implements ValueRenderer<T>, Cloneable
  • Field Details

    • DEFAULT_ID

      public static final ElementId 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

      public DefaultValueRenderer(Function<? super T,String> toString)
      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

      public DefaultValueRenderer(ElementId elementId, String style)
      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

      public DefaultValueRenderer(ElementId elementId, String style, Function<? super T,String> toString)
      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

      public DefaultValueRenderer<T> clone()
      Overrides:
      clone in class Object
    • configureStyle

      public void configureStyle(ElementId elementId, String style)
      Default implementation uses the specified style unless the renderer already has an elementId and style set.
      Specified by:
      configureStyle in interface ValueRenderer<T>
    • setStringTransform

      public void setStringTransform(Function<? super T,String> toString)
      Sets the function that will convert values to Strings. Set to null to use the default String.valueOf() behavior.
    • getStringTransform

      public Function<? super T,String> getStringTransform()
    • setElementId

      public void setElementId(ElementId elementId)
      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

      public ElementId getElementId()
    • setStyle

      public void setStyle(String style)
      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

      public String getStyle()
    • valueToString

      protected String valueToString(T value)
      Called by getView() and createView() to conver the value to a string. Default implementation passes the value to the current string transform.
    • createView

      protected Label createView(T value, boolean selected)
      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

      public Panel getView(T value, boolean selected, Panel existing)
      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 interface ValueRenderer<T>