FSF GCC merge 02/23/03
[official-gcc.git] / libjava / java / awt / color / ICC_ColorSpace.java
blob2ed247f52b05a50a193ee9556c506a2f0bda03cb
1 /* ICC_ColorSpace.java -- the canonical color space implementation
2 Copyright (C) 2000, 2002 Free Software Foundation
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package java.awt.color;
41 /**
42 * NEEDS DOCUMENTATION
44 * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
45 * @since 1.2
47 public class ICC_ColorSpace extends ColorSpace
49 /**
50 * Compatible with JDK 1.2+.
52 private static final long serialVersionUID = 3455889114070431483L;
54 /**
55 * @serial
57 private ICC_Profile thisProfile;
59 /**
60 * @serial
62 private float[] minVal;
64 /**
65 * @serial
67 private float[] maxVal;
69 /**
70 * @serial
72 private float[] diffMinMax;
74 /**
75 * @serial
77 private float[] invDiffMinMax;
79 /**
80 * @serial
82 private boolean needScaleInit;
84 /**
85 * Constructs a new ICC_ColorSpace from an ICC_Profile object.
87 * @exception IllegalArgumentException If profile is inappropriate for
88 * representing a ColorSpace.
90 public ICC_ColorSpace(ICC_Profile profile)
92 super(CS_sRGB, profile.getNumComponents());
93 thisProfile = profile;
96 public ICC_Profile getProfile()
98 return thisProfile;
102 * Transforms a color value assumed to be in this ColorSpace into a value in
103 * the default CS_sRGB color space.
105 * @exception ArrayIndexOutOfBoundsException If array length is not at least
106 * the number of components in this ColorSpace.
108 public float[] toRGB(float[] colorvalue)
110 if (colorvalue.length < numComponents)
111 throw new IllegalArgumentException ();
113 // FIXME: Always assumes sRGB:
114 return colorvalue;
118 * Transforms a color value assumed to be in the default CS_sRGB color space
119 * into this ColorSpace.
121 * @exception ArrayIndexOutOfBoundsException If array length is not at
122 * least 3.
124 public float[] fromRGB(float[] rgbvalue)
126 if (rgbvalue.length < 3)
127 throw new IllegalArgumentException ();
129 // FIXME: Always assumes sRGB:
130 return rgbvalue;
134 * Transforms a color value assumed to be in this ColorSpace into the
135 * CS_CIEXYZ conversion color space.
137 * @exception ArrayIndexOutOfBoundsException If array length is not at
138 * least the number of components in this ColorSpace.
140 public float[] toCIEXYZ(float[] colorvalue)
142 // FIXME: Not implemented
143 throw new UnsupportedOperationException();
147 * Transforms a color value assumed to be in the CS_CIEXYZ conversion color
148 * space into this ColorSpace.
150 * @exception ArrayIndexOutOfBoundsException If array length is not at
151 * least 3.
153 public float[] fromCIEXYZ(float[] colorvalue)
155 // FIXME: Not implemented
156 throw new UnsupportedOperationException();
160 * Returns the minimum normalized color component value for the specified
161 * component.
163 * @exception IllegalArgumentException If component is less than 0 or greater
164 * than numComponents - 1.
166 * @since 1.4
168 public float getMinValue(int idx)
170 if (type == TYPE_Lab && (idx == 1 || idx == 2))
171 return -128;
172 if (idx < 0 || idx >= numComponents)
173 throw new IllegalArgumentException();
174 return 0;
178 * Returns the maximum normalized color component value for the specified
179 * component.
181 * @exception IllegalArgumentException If component is less than 0 or greater
182 * than numComponents - 1.
184 * @since 1.4
186 public float getMaxValue(int idx)
188 if (type == TYPE_XYZ && idx >= 0 && idx <= 2)
189 return 1 + 32767 / 32768f;
190 else if (type == TYPE_Lab)
192 if (idx == 0)
193 return 100;
194 if (idx == 1 || idx == 2)
195 return 127;
197 if (idx < 0 || idx >= numComponents)
198 throw new IllegalArgumentException();
199 return 1;
201 } // class ICC_ColorSpace