115 lines
3.0 KiB
Java
115 lines
3.0 KiB
Java
package envoy.client.ui;
|
|
|
|
import java.awt.color.ColorSpace;
|
|
|
|
/**
|
|
* This class further develops {@link java.awt.Color} by adding extra methods
|
|
* and more default colors.
|
|
*
|
|
* Project: <strong>envoy-client</strong><br>
|
|
* File: <strong>Color.java</strong><br>
|
|
* Created: <strong>23.12.2019</strong><br>
|
|
*
|
|
* @author Kai S. K. Engelbart
|
|
* @since Envoy Client v0.3-alpha
|
|
*/
|
|
@SuppressWarnings("javadoc")
|
|
public class Color extends java.awt.Color {
|
|
|
|
/**
|
|
* The color white. In the default sRGB space.
|
|
*/
|
|
public static final Color white = new Color(255, 255, 255);
|
|
|
|
/**
|
|
* The color light gray. In the default sRGB space.
|
|
*/
|
|
public static final Color lightGray = new Color(192, 192, 192);
|
|
|
|
/**
|
|
* The color gray. In the default sRGB space.
|
|
*/
|
|
public static final Color gray = new Color(128, 128, 128);
|
|
|
|
/**
|
|
* The color dark gray. In the default sRGB space.
|
|
*/
|
|
public static final Color darkGray = new Color(64, 64, 64);
|
|
|
|
/**
|
|
* The color black. In the default sRGB space.
|
|
*/
|
|
public static final Color black = new Color(0, 0, 0);
|
|
|
|
/**
|
|
* The color red. In the default sRGB space.
|
|
*/
|
|
public static final Color red = new Color(255, 0, 0);
|
|
|
|
/**
|
|
* The color pink. In the default sRGB space.
|
|
*/
|
|
public static final Color pink = new Color(255, 175, 175);
|
|
|
|
/**
|
|
* The color orange. In the default sRGB space.
|
|
*/
|
|
public static final Color orange = new Color(255, 200, 0);
|
|
|
|
/**
|
|
* The color yellow. In the default sRGB space.
|
|
*/
|
|
public static final Color yellow = new Color(255, 255, 0);
|
|
|
|
/**
|
|
* The color green. In the default sRGB space.
|
|
*/
|
|
public static final Color green = new Color(0, 255, 0);
|
|
|
|
/**
|
|
* The color magenta. In the default sRGB space.
|
|
*/
|
|
public static final Color magenta = new Color(255, 0, 255);
|
|
|
|
/**
|
|
* The color cyan. In the default sRGB space.
|
|
*/
|
|
public static final Color cyan = new Color(0, 255, 255);
|
|
|
|
/**
|
|
* The color blue. In the default sRGB space.
|
|
*/
|
|
public static final Color blue = new Color(0, 0, 255);
|
|
|
|
private static final long serialVersionUID = 0L;
|
|
|
|
public Color(java.awt.Color other) { this(other.getRGB()); }
|
|
|
|
public Color(int rgb) { super(rgb); }
|
|
|
|
public Color(int rgba, boolean hasalpha) { super(rgba, hasalpha); }
|
|
|
|
public Color(int r, int g, int b) { super(r, g, b); }
|
|
|
|
public Color(float r, float g, float b) { super(r, g, b); }
|
|
|
|
public Color(ColorSpace cspace, float[] components, float alpha) { super(cspace, components, alpha); }
|
|
|
|
public Color(int r, int g, int b, int a) { super(r, g, b, a); }
|
|
|
|
public Color(float r, float g, float b, float a) { super(r, g, b, a); }
|
|
|
|
/**
|
|
* @return the inversion of this {@link Color} by replacing the red, green and
|
|
* blue values by subtracting them form 255
|
|
* @since Envoy Client v0.3-alpha
|
|
*/
|
|
public Color invert() { return new Color(255 - getRed(), 255 - getGreen(), 255 - getBlue()); }
|
|
|
|
/**
|
|
* @return the hex value of this {@link Color}
|
|
* @since Envoy Client v0.3-alpha
|
|
*/
|
|
public String toHex() { return String.format("#%02x%02x%02x", getRed(), getGreen(), getBlue()); }
|
|
}
|