java.awt.Color present in the Lemur library

Hello everyone!.

I just noticed the presence of the java.awt.Color class in the Lemur library, this object is in the ColorChooser class where it is used to convert colors from HSB to RGB and vice versa.

...
import com.simsilica.lemur.style.Styles;
import java.awt.Color;


/**
 *
 *
 *  @author    Paul Speed
 */
public class ColorChooser extends Panel {

    public static final String ELEMENT_ID = "colorChooser";
    public static final String CONTAINER_ID = "container";
    public static final String COLORS_ID = "colors";
    public static final String BRIGHTNESS_ID = "brightness.slider";
    public static final String VALUE_ID = "value";

    public static final Texture2D defaultTexture = new Texture2D(256, 256, Image.Format.RGBA8);
    static {
        defaultTexture.getImage().setData(BufferUtils.createByteBuffer(256 * 256 * 4));
        ImageRaster raster = ImageRaster.create(defaultTexture.getImage());
        for( int i = 0; i < 256; i++ ) {
            for( int j = 0; j < 256; j++ ) {
                Color hsb = Color.getHSBColor(i/255f, j/255f, 0.5f);
                raster.setPixel(i, j, toJmeColor(hsb));
            }
        }
    }
...

With the java.awt package dependency being implemented, This class is a problem when running our games on mobile devices where we do not have this object.

I made some changes to not depend on java.awt.Color so that I can implement a ColorChooser component seamlessly on any platform. I would like that
in a later version of Lemur it will stop using java.awt.Color for conversion.

[ MODIFIED CODE ]
https://github.com/SwiftWolf/Lemur.git

[ ADDITIONAL CHARACTERISTICS ]
By the way, it implements a function (a ‘CheckboxGroup’ class) for the grouping of checkboxes, so that they act as radiobuttons (single selection in a family).

4 Likes