Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make IntelliJ color preview recognize a custom Color class?

In IntelliJ there's a feature where you can preview colors in the gutter for regular rgb colors using the Color class. However, there are some cases where I prefer the HSL color model, which Java doesn't have, so I made my own class that extends Color. Colors instantiated through the custom class don't have previews; is there any way I can tell IntelliJ how to extract a preview from my class?

Example of what I'm talking about

Here's a short preview of the HSLColor class:

public class HSLColor extends Color
{
    private float[] hsl;
    private float alpha;
    
    public HSLColor(float h, float s, float l, float a)
    {
        this(toRGB(h, s, l, a));
        hsl = new float[]{h, s, l};
        alpha = a;
    }
    
    private HSLColor(float[] rgba)
    {
        super(rgba[0], rgba[1], rgba[2], rgba[3]);
    }
}
like image 781
Eric Xu Avatar asked Oct 27 '25 14:10

Eric Xu


1 Answers

It's not possible without modifying IDE source code or creating a custom plug-in.

Either submit a feature request, or write your own plug-in for that.

like image 72
CrazyCoder Avatar answered Oct 30 '25 06:10

CrazyCoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!