1 17 18 19 20 package org.apache.fop.fo.pagination; 21 22 import java.util.Iterator ; 24 import java.util.Map ; 25 26 import org.xml.sax.Locator ; 27 28 import org.apache.fop.apps.FOPException; 29 import org.apache.fop.fo.FONode; 30 import org.apache.fop.fo.FObj; 31 import org.apache.fop.fo.PropertyList; 32 import org.apache.fop.fo.ValidationException; 33 34 41 public class Declarations extends FObj { 42 43 private Map colorProfiles = null; 44 45 48 public Declarations(FONode parent) { 49 super(parent); 50 ((Root) parent).setDeclarations(this); 51 } 52 53 56 public void bind(PropertyList pList) throws FOPException { 57 } 59 60 65 protected void validateChildNode(Locator loc, String nsURI, String localName) 66 throws ValidationException { 67 if (FO_URI.equals(nsURI)) { 68 if (!localName.equals("color-profile")) { 69 invalidChildError(loc, nsURI, localName); 70 } 71 } } 73 74 79 protected void endOfNode() throws FOPException { 80 if (childNodes != null) { 81 for (Iterator iter = childNodes.iterator(); iter.hasNext();) { 82 FONode node = (FONode)iter.next(); 83 if (node.getName().equals("fo:color-profile")) { 84 ColorProfile cp = (ColorProfile)node; 85 if (!"".equals(cp.getColorProfileName())) { 86 addColorProfile(cp); 87 } else { 88 getLogger().warn("color-profile-name required for color profile"); 89 } 90 } else { 91 getLogger().debug("Ignoring element " + node.getName() 92 + " inside fo:declarations."); 93 } 94 } 95 } 96 childNodes = null; 97 } 98 99 private void addColorProfile(ColorProfile cp) { 100 if (colorProfiles == null) { 101 colorProfiles = new java.util.HashMap (); 102 } 103 if (colorProfiles.get(cp.getColorProfileName()) != null) { 104 getLogger().warn("Duplicate fo:color-profile profile name: " 106 + cp.getColorProfileName()); 107 } 108 colorProfiles.put(cp.getColorProfileName(), cp); 109 } 110 111 114 public String getLocalName() { 115 return "declarations"; 116 } 117 118 121 public int getNameId() { 122 return FO_DECLARATIONS; 123 } 124 125 133 public ColorProfile getColorProfile(String cpName) { 134 ColorProfile profile = null; 135 if (this.colorProfiles != null) { 136 profile = (ColorProfile)this.colorProfiles.get(cpName); 137 } 138 return profile; 139 } 140 141 142 } 143 | Popular Tags |