Example usage for java.awt.color ColorSpace CS_CIEXYZ

List of usage examples for java.awt.color ColorSpace CS_CIEXYZ

Introduction

In this page you can find the example usage for java.awt.color ColorSpace CS_CIEXYZ.

Prototype

int CS_CIEXYZ

To view the source code for java.awt.color ColorSpace CS_CIEXYZ.

Click Source Link

Document

The CIEXYZ conversion color space defined above.

Usage

From source file:Main.java

public static void main(String[] args) {

    Color myColor = new Color(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ), new float[] { 0.1F, 0.2F, 0.3F },
            0.4F);//from  w  w  w.j av  a2  s . c  om

    System.out.println(Arrays.toString(myColor.getColorComponents(null)));

}

From source file:Main.java

public static void main(String[] args) {

    Color myColor = Color.RED;

    System.out.println(//from w w  w  .j  av  a2 s. co  m
            Arrays.toString(myColor.getComponents(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ), null)));

}

From source file:Main.java

public static void main(String[] args) {

    Color myColor = Color.RED;

    System.out.println(/* w  w  w  . ja v  a  2s . co  m*/
            Arrays.toString(myColor.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ), null)));

}

From source file:com.imaginary.home.lighting.Color.java

/**
 * Converts this color to {@link ColorMode#RGB}.
 * @return the RGB representation of this color
 *//*from   w w w . ja v a  2 s.c  o  m*/
public @Nonnull Color convertToRGB() {
    switch (colorMode) {
    case RGB:
        return this;
    case HSV:
        java.awt.Color c = new java.awt.Color(
                java.awt.Color.HSBtoRGB(components[0] / 65535f, (components[1] * 100f) / 254f, 1f));

        return new Color(ColorMode.RGB, ((float) c.getRed()) / 255f, ((float) c.getGreen()) / 255f,
                ((float) c.getBlue()) / 255f);
    case CIEXYZ:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_CIEXYZ);

        float[] tmp = cs.toRGB(components);
        return new Color(ColorMode.RGB, (tmp[0] * 100f) / 255f, (tmp[1] * 255f) / 100f, (tmp[2] * 255f) / 100f);
    case CT:
        // this is made up nonsense
        return new Color(ColorMode.RGB, 100f, 100f, 100f);
    }
    throw new RuntimeException("Invalid color mode: " + colorMode);
}