1 18 package org.apache.batik.dom.svg; 19 20 import org.apache.batik.dom.AbstractDocument; 21 import org.apache.batik.dom.util.XLinkSupport; 22 import org.apache.batik.dom.util.XMLSupport; 23 import org.w3c.dom.Attr ; 24 import org.w3c.dom.DOMException ; 25 import org.w3c.dom.Node ; 26 import org.w3c.dom.svg.SVGColorProfileElement; 27 28 34 public class SVGOMColorProfileElement 35 extends SVGOMURIReferenceElement 36 implements SVGColorProfileElement { 37 38 41 protected final static AttributeInitializer attributeInitializer; 42 static { 43 attributeInitializer = new AttributeInitializer(5); 44 attributeInitializer.addAttribute(null, null, 45 SVG_RENDERING_INTENT_ATTRIBUTE, 46 SVG_AUTO_VALUE); 47 attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI, 48 null, "xmlns:xlink", 49 XLinkSupport.XLINK_NAMESPACE_URI); 50 attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI, 51 "xlink", "type", "simple"); 52 attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI, 53 "xlink", "show", "other"); 54 attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI, 55 "xlink", "actuate", "onLoad"); 56 } 57 58 61 protected SVGOMColorProfileElement() { 62 } 63 64 69 public SVGOMColorProfileElement(String prefix, AbstractDocument owner) { 70 super(prefix, owner); 71 72 } 73 74 77 public String getLocalName() { 78 return SVG_COLOR_PROFILE_TAG; 79 } 80 81 84 public String getLocal() { 85 return getAttributeNS(null, SVG_LOCAL_ATTRIBUTE); 86 } 87 88 91 public void setLocal(String local) throws DOMException { 92 setAttributeNS(null, SVG_LOCAL_ATTRIBUTE, local); 93 } 94 95 98 public String getName() { 99 return getAttributeNS(null, SVG_NAME_ATTRIBUTE); 100 } 101 102 105 public void setName(String name) throws DOMException { 106 setAttributeNS(null, SVG_NAME_ATTRIBUTE, name); 107 } 108 109 113 public short getRenderingIntent() { 114 Attr attr = getAttributeNodeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE); 115 if (attr == null) { 116 return RENDERING_INTENT_AUTO; 117 } 118 String val = attr.getValue(); 119 switch (val.length()) { 120 case 4: 121 if (val.equals(SVG_AUTO_VALUE)) { 122 return RENDERING_INTENT_AUTO; 123 } 124 break; 125 126 case 10: 127 if (val.equals(SVG_PERCEPTUAL_VALUE)) { 128 return RENDERING_INTENT_PERCEPTUAL; 129 } 130 if (val.equals(SVG_SATURATE_VALUE)) { 131 return RENDERING_INTENT_SATURATION; 132 } 133 break; 134 135 case 21: 136 if (val.equals(SVG_ABSOLUTE_COLORIMETRIC_VALUE)) { 137 return RENDERING_INTENT_ABSOLUTE_COLORIMETRIC; 138 } 139 if (val.equals(SVG_RELATIVE_COLORIMETRIC_VALUE)) { 140 return RENDERING_INTENT_RELATIVE_COLORIMETRIC; 141 } 142 } 143 return RENDERING_INTENT_UNKNOWN; 144 } 145 146 150 public void setRenderingIntent(short renderingIntent) throws DOMException { 151 switch (renderingIntent) { 152 case RENDERING_INTENT_AUTO: 153 setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE, 154 SVG_AUTO_VALUE); 155 break; 156 157 case RENDERING_INTENT_PERCEPTUAL: 158 setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE, 159 SVG_PERCEPTUAL_VALUE); 160 break; 161 162 case RENDERING_INTENT_RELATIVE_COLORIMETRIC: 163 setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE, 164 SVG_RELATIVE_COLORIMETRIC_VALUE); 165 break; 166 167 case RENDERING_INTENT_SATURATION: 168 setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE, 169 SVG_SATURATE_VALUE); 170 break; 171 172 case RENDERING_INTENT_ABSOLUTE_COLORIMETRIC: 173 setAttributeNS(null, SVG_RENDERING_INTENT_ATTRIBUTE, 174 SVG_ABSOLUTE_COLORIMETRIC_VALUE); 175 } 176 } 177 178 182 protected AttributeInitializer getAttributeInitializer() { 183 return attributeInitializer; 184 } 185 186 189 protected Node newNode() { 190 return new SVGOMColorProfileElement(); 191 } 192 } 193 | Popular Tags |