1 18 package org.apache.batik.css.engine.value.svg; 19 20 import org.apache.batik.css.engine.value.AbstractValue; 21 import org.w3c.dom.DOMException ; 22 import org.w3c.dom.css.CSSValue; 23 24 30 public class ICCColor extends AbstractValue { 31 32 35 protected String colorProfile; 36 37 40 protected int count; 41 42 45 protected float[] colors = new float[5]; 46 47 50 public ICCColor(String name) { 51 colorProfile = name; 52 } 53 54 58 public short getCssValueType() { 59 return CSSValue.CSS_CUSTOM; 60 } 61 62 65 public String getColorProfile() throws DOMException { 66 return colorProfile; 67 } 68 69 72 public int getNumberOfColors() throws DOMException { 73 return count; 74 } 75 76 79 public float getColor(int i) throws DOMException { 80 return colors[i]; 81 } 82 83 86 public String getCssText() { 87 StringBuffer sb = new StringBuffer (); 88 sb.append("icc-color("); 89 sb.append(colorProfile); 90 for (int i = 0; i < count; i++) { 91 sb.append(", "); 92 sb.append(colors[i]); 93 } 94 sb.append(")"); 95 return sb.toString(); 96 } 97 98 101 public void append(float c) { 102 if (count == colors.length) { 103 float[] t = new float[count * 2]; 104 for (int i = 0; i < count; i++) { 105 t[i] = colors[i]; 106 } 107 colors = t; 108 } 109 colors[count++] = c; 110 } 111 } 112 | Popular Tags |