1 17 18 19 20 package org.apache.fop.util; 21 22 import java.awt.Color ; 23 import java.awt.color.ColorSpace ; 24 25 31 public final class ColorExt extends Color { 32 private static final long serialVersionUID = 1L; 34 35 private float rgbReplacementRed; 37 private float rgbReplacementGreen; 38 private float rgbReplacementBlue; 39 40 private String iccProfileName; 41 private String iccProfileSrc; 42 private ColorSpace colorSpace; 43 44 private float[] colorValues; 45 46 49 private ColorExt(ColorSpace colorSpace, float[] colorValues, float opacity) { 50 super(colorSpace, colorValues, opacity); 51 } 52 53 56 private ColorExt(float red, float green, float blue, float opacity) { 57 super(red, green, blue, opacity); 58 } 59 60 82 public static ColorExt createFromFoRgbIcc(float redReplacement, 83 float greenReplacement, float blueReplacement, String profileName, 84 String profileSrc, ColorSpace colorSpace, float[] iccValues) { 85 ColorExt ce = new ColorExt(colorSpace, iccValues, 1.0f); 86 ce.rgbReplacementRed = redReplacement; 87 ce.rgbReplacementGreen = greenReplacement; 88 ce.rgbReplacementBlue = blueReplacement; 89 ce.iccProfileName = profileName; 90 ce.iccProfileSrc = profileSrc; 91 ce.colorSpace = colorSpace; 92 ce.colorValues = iccValues; 93 return ce; 94 } 95 96 120 public static ColorExt createFromSvgIccColor(float red, float green, 121 float blue, float opacity, String profileName, String profileHref, 122 ColorSpace profileCS, float[] colorValues) { 123 ColorExt ce = new ColorExt(red, green, blue, opacity); 124 ce.rgbReplacementRed = -1; 125 ce.rgbReplacementGreen = -1; 126 ce.rgbReplacementBlue = -1; 127 ce.iccProfileName = profileName; 128 ce.iccProfileSrc = profileHref; 129 ce.colorSpace = profileCS; 130 ce.colorValues = colorValues; 131 return ce; 132 133 } 134 135 140 public String getIccProfileName() { 141 return this.iccProfileName; 142 } 143 144 149 public String getIccProfileSrc() { 150 return this.iccProfileSrc; 151 } 152 153 156 public ColorSpace getOrigColorSpace() { 157 return this.colorSpace; 158 } 159 160 163 public float[] getOriginalColorComponents() { 164 return this.colorValues; 165 } 166 167 172 public String toFunctionCall() { 173 StringBuffer sb = new StringBuffer (40); 174 sb.append("fop-rgb-icc("); 175 sb.append(this.rgbReplacementRed + ","); 176 sb.append(this.rgbReplacementGreen + ","); 177 sb.append(this.rgbReplacementBlue + ","); 178 sb.append(this.iccProfileName + ","); 179 sb.append("\"" + this.iccProfileSrc + "\""); 180 float[] colorComponents = this.getColorComponents(null); 181 for (int ix = 0; ix < colorComponents.length; ix++) { 182 sb.append(","); 183 sb.append(colorComponents[ix]); 184 } 185 sb.append(")"); 186 return sb.toString(); 187 } 188 189 } 190 | Popular Tags |