1 /* 2 * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.java2d.cmm; 27 28 import java.util.Vector; 29 30 31 /** 32 * A class to manage the deferral of CMM initialization of profile 33 * data for internal ICC_Profile objects - i.e. when we "trust" that 34 * the profile data is valid and we think it may not be needed. An 35 * example is the sRGB profile which gets loaded by any program doing 36 * graphics, but which may not be needed if the program does not need 37 * high quality color conversion. 38 */ 39 public class ProfileDeferralMgr { 40 41 public static boolean deferring = true; 42 private static Vector aVector; 43 44 /** 45 * Records a ProfileActivator object whose activate method will 46 * be called if the CMM needs to be activated. 47 */ 48 public static void registerDeferral(ProfileActivator pa) { 49 50 if (!deferring) { 51 return; 52 } 53 if (aVector == null) { 54 aVector = new Vector(3, 3); 55 } 56 aVector.addElement(pa); 57 return; 58 } 59 60 61 /** 62 * Removes a ProfileActivator object from the vector of ProfileActivator 63 * objects whose activate method will be called if the CMM needs to be 64 * activated. 65 */ 66 public static void unregisterDeferral(ProfileActivator pa) { 67 68 if (!deferring) { 69 return; 70 } 71 if (aVector == null) { 72 return; 73 } 74 aVector.removeElement(pa); 75 return; 76 } 77 78 /** 79 * Removes a ProfileActivator object from the vector of ProfileActivator 80 * objects whose activate method will be called if the CMM needs to be 81 * activated. 82 */ 83 public static void activateProfiles() { 84 85 int i, n; 86 87 deferring = false; 88 if (aVector == null) { 89 return; 90 } 91 n = aVector.size(); 92 for (i = 0; i < n; i++) { 93 ((ProfileActivator) aVector.get(i)).activate(); 94 } 95 aVector.removeAllElements(); 96 aVector = null; 97 return; 98 } 99 100 }