KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > faceless > pdf > CMYKColorSpace


1 // $Id: CMYKColorSpace.java,v 1.3 2003/11/04 17:16:01 mike Exp $
2

3 package org.faceless.pdf;
4
5 import java.awt.color.*;
6 import java.awt.Color JavaDoc;
7
8 /**
9  * <p>
10  * A subclass of <tt>java.awt.color.ColorSpace</tt> representing
11  * the uncalibrated (device-dependent) CMYK color space available
12  * in PDF documents.
13  * </p><p>
14  * If colors need to be specified in CMYK, but accurate color
15  * (the kind available with an ICC Profile) is not required, this
16  * colorspace should be used, as it doesn't require an ICC profile
17  * to be embedded in the PDF (resulting in a smaller file).
18  * </p>
19  * @since 1.1.5
20  * @version $Revision: 1.3 $
21  */

22 public class CMYKColorSpace extends ColorSpace
23 {
24     private org.faceless.pdf2.CMYKColorSpace wrap;
25     static final CMYKColorSpace space = new CMYKColorSpace();
26
27     private CMYKColorSpace()
28     {
29         super(TYPE_CMYK, 4);
30     wrap=org.faceless.pdf2.CMYKColorSpace.getInstance();
31     }
32
33     /**
34      * Return a CMYK Color Space
35      */

36     public static CMYKColorSpace getInstance()
37     {
38     return space;
39     }
40
41     public float[] toRGB(float[] cmyk)
42     {
43     return wrap.toRGB(cmyk);
44     }
45
46     public float[] fromRGB(float[] rgb)
47     {
48     return wrap.fromRGB(rgb);
49     }
50
51     public float[] fromCIEXYZ(float[] xyz)
52     {
53     return wrap.fromCIEXYZ(xyz);
54     }
55
56     public float[] toCIEXYZ(float[] cmyk)
57     {
58     return wrap.toCIEXYZ(cmyk);
59     }
60
61     /**
62      * A convenience method, returning a color in the CMYK colorspace
63      * with the specified levels of cyan, magenta, yellow and black.
64      * The parameters must be in the range from 0.0 to 1.0, or an
65      * <tt>IllegalArgumentException is thrown</tt>
66      * @param c the level of cyan from 0.0 to 1.0
67      * @param m the level of magenta from 0.0 to 1.0
68      * @param y the level of yellow from 0.0 to 1.0
69      * @param k the level of black from 0.0 to 1.0
70      * @throws IllegalArgumentException
71      */

72     public static Color JavaDoc getColor(float c, float m, float y, float k)
73     {
74     return org.faceless.pdf2.CMYKColorSpace.getColor(c,m,y,k);
75     }
76 }
77
Popular Tags