01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Oleg V. Khaschansky
19: * @version $Revision$
20: */package java.awt.color;
21:
22: import org.apache.harmony.awt.internal.nls.Messages;
23:
24: public class ICC_ProfileRGB extends ICC_Profile {
25: private static final long serialVersionUID = 8505067385152579334L;
26:
27: ICC_ProfileRGB(long profileHandle) {
28: super (profileHandle);
29: }
30:
31: public static final int REDCOMPONENT = 0;
32:
33: public static final int GREENCOMPONENT = 1;
34:
35: public static final int BLUECOMPONENT = 2;
36:
37: // awt.15E=Unknown component. Must be REDCOMPONENT, GREENCOMPONENT or BLUECOMPONENT.
38: private static final String UNKNOWN_COMPONENT_MSG = Messages
39: .getString("awt.15E"); //$NON-NLS-1$
40:
41: @Override
42: public short[] getTRC(int component) {
43: switch (component) {
44: case REDCOMPONENT:
45: return super .getTRC(icSigRedTRCTag);
46: case GREENCOMPONENT:
47: return super .getTRC(icSigGreenTRCTag);
48: case BLUECOMPONENT:
49: return super .getTRC(icSigBlueTRCTag);
50: default:
51: }
52:
53: throw new IllegalArgumentException(UNKNOWN_COMPONENT_MSG);
54: }
55:
56: @Override
57: public float getGamma(int component) {
58: switch (component) {
59: case REDCOMPONENT:
60: return super .getGamma(icSigRedTRCTag);
61: case GREENCOMPONENT:
62: return super .getGamma(icSigGreenTRCTag);
63: case BLUECOMPONENT:
64: return super .getGamma(icSigBlueTRCTag);
65: default:
66: }
67:
68: throw new IllegalArgumentException(UNKNOWN_COMPONENT_MSG);
69: }
70:
71: public float[][] getMatrix() {
72: float[][] m = new float[3][3]; // The matrix
73:
74: float[] redXYZ = getXYZValue(icSigRedColorantTag);
75: float[] greenXYZ = getXYZValue(icSigGreenColorantTag);
76: float[] blueXYZ = getXYZValue(icSigBlueColorantTag);
77:
78: m[0][0] = redXYZ[0];
79: m[1][0] = redXYZ[1];
80: m[2][0] = redXYZ[2];
81:
82: m[0][1] = greenXYZ[0];
83: m[1][1] = greenXYZ[1];
84: m[2][1] = greenXYZ[2];
85:
86: m[0][2] = blueXYZ[0];
87: m[1][2] = blueXYZ[1];
88: m[2][2] = blueXYZ[2];
89:
90: return m;
91: }
92:
93: @Override
94: public float[] getMediaWhitePoint() {
95: return super.getMediaWhitePoint();
96: }
97: }
|