--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java Fri Jan 23 17:43:29 2009 +0300
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java Fri Jan 23 21:14:31 2009 +0300
@@ -737,7 +737,7 @@
ICC_Profile(ProfileDeferralInfo pdi) {
this.deferralInfo = pdi;
this.profileActivator = new ProfileActivator() {
- public void activate() {
+ public void activate() throws ProfileDataException {
activateDeferredProfile();
}
};
@@ -830,20 +830,16 @@
case ColorSpace.CS_sRGB:
synchronized(ICC_Profile.class) {
if (sRGBprofile == null) {
- try {
- /*
- * Deferral is only used for standard profiles.
- * Enabling the appropriate access privileges is handled
- * at a lower level.
- */
- sRGBprofile = getDeferredInstance(
- new ProfileDeferralInfo("sRGB.pf",
- ColorSpace.TYPE_RGB,
- 3, CLASS_DISPLAY));
- } catch (IOException e) {
- throw new IllegalArgumentException(
- "Can't load standard profile: sRGB.pf");
- }
+ /*
+ * Deferral is only used for standard profiles.
+ * Enabling the appropriate access privileges is handled
+ * at a lower level.
+ */
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("sRGB.pf",
+ ColorSpace.TYPE_RGB, 3,
+ CLASS_DISPLAY);
+ sRGBprofile = getDeferredInstance(pInfo);
}
thisProfile = sRGBprofile;
}
@@ -853,7 +849,11 @@
case ColorSpace.CS_CIEXYZ:
synchronized(ICC_Profile.class) {
if (XYZprofile == null) {
- XYZprofile = getStandardProfile("CIEXYZ.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("CIEXYZ.pf",
+ ColorSpace.TYPE_XYZ, 3,
+ CLASS_DISPLAY);
+ XYZprofile = getDeferredInstance(pInfo);
}
thisProfile = XYZprofile;
}
@@ -863,7 +863,11 @@
case ColorSpace.CS_PYCC:
synchronized(ICC_Profile.class) {
if (PYCCprofile == null) {
- PYCCprofile = getStandardProfile("PYCC.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("PYCC.pf",
+ ColorSpace.TYPE_3CLR, 3,
+ CLASS_DISPLAY);
+ PYCCprofile = getDeferredInstance(pInfo);
}
thisProfile = PYCCprofile;
}
@@ -873,7 +877,11 @@
case ColorSpace.CS_GRAY:
synchronized(ICC_Profile.class) {
if (GRAYprofile == null) {
- GRAYprofile = getStandardProfile("GRAY.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("GRAY.pf",
+ ColorSpace.TYPE_GRAY, 1,
+ CLASS_DISPLAY);
+ GRAYprofile = getDeferredInstance(pInfo);
}
thisProfile = GRAYprofile;
}
@@ -883,7 +891,11 @@
case ColorSpace.CS_LINEAR_RGB:
synchronized(ICC_Profile.class) {
if (LINEAR_RGBprofile == null) {
- LINEAR_RGBprofile = getStandardProfile("LINEAR_RGB.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("LINEAR_RGB.pf",
+ ColorSpace.TYPE_RGB, 3,
+ CLASS_DISPLAY);
+ LINEAR_RGBprofile = getDeferredInstance(pInfo);
}
thisProfile = LINEAR_RGBprofile;
}
@@ -1047,9 +1059,7 @@
* code will take care of access privileges.
* @see activateDeferredProfile()
*/
- static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi)
- throws IOException {
-
+ static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi) {
if (!ProfileDeferralMgr.deferring) {
return getStandardProfile(pdi.filename);
}
@@ -1063,33 +1073,37 @@
}
- void activateDeferredProfile() {
- byte profileData[];
- FileInputStream fis;
- String fileName = deferralInfo.filename;
+ void activateDeferredProfile() throws ProfileDataException {
+ byte profileData[];
+ FileInputStream fis;
+ String fileName = deferralInfo.filename;
profileActivator = null;
deferralInfo = null;
if ((fis = openProfile(fileName)) == null) {
- throw new IllegalArgumentException("Cannot open file " + fileName);
+ throw new ProfileDataException("Cannot open file " + fileName);
}
try {
profileData = getProfileDataFromStream(fis);
fis.close(); /* close the file */
}
catch (IOException e) {
- throw new IllegalArgumentException("Invalid ICC Profile Data" +
- fileName);
+ ProfileDataException pde = new
+ ProfileDataException("Invalid ICC Profile Data" + fileName);
+ pde.initCause(e);
+ throw pde;
}
if (profileData == null) {
- throw new IllegalArgumentException("Invalid ICC Profile Data" +
+ throw new ProfileDataException("Invalid ICC Profile Data" +
fileName);
}
try {
ID = CMSManager.getModule().loadProfile(profileData);
} catch (CMMException c) {
- throw new IllegalArgumentException("Invalid ICC Profile Data" +
- fileName);
+ ProfileDataException pde = new
+ ProfileDataException("Invalid ICC Profile Data" + fileName);
+ pde.initCause(c);
+ throw pde;
}
}