1 17 18 19 20 package org.apache.fop.fo.properties; 21 22 import java.awt.Color ; 23 24 import org.apache.fop.apps.FOUserAgent; 25 import org.apache.fop.fo.FObj; 26 import org.apache.fop.fo.PropertyList; 27 import org.apache.fop.fo.expr.PropertyException; 28 import org.apache.fop.util.ColorUtil; 29 30 33 public class ColorProperty extends Property { 34 35 38 protected final Color color; 39 40 41 44 public static class Maker extends PropertyMaker { 45 46 49 public Maker(int propId) { 50 super(propId); 51 } 52 53 72 public Property convertProperty(Property p, 73 PropertyList propertyList, FObj fo) 74 throws PropertyException { 75 if (p instanceof ColorProperty) { 76 return p; 77 } 78 FObj fobj = (fo == null ? propertyList.getFObj() : fo); 79 FOUserAgent ua = (fobj == null ? null : fobj.getUserAgent()); 80 Color val = p.getColor(ua); 81 if (val != null) { 82 return new ColorProperty(val); 83 } 84 return convertPropertyDatatype(p, propertyList, fo); 85 } 86 87 } 88 89 98 public ColorProperty(FOUserAgent foUserAgent, String value) throws PropertyException { 99 this.color = ColorUtil.parseColorString(foUserAgent, value); 100 } 101 102 107 public ColorProperty(Color value) { 108 this.color = value; 109 } 110 111 116 public Color getColor(FOUserAgent foUserAgent) { 117 return color; 118 } 119 120 123 public String toString() { 124 return ColorUtil.colorToString(color); 125 } 126 127 131 public ColorProperty getColorProperty() { 132 return this; 133 } 134 135 138 public Object getObject() { 139 return this; 140 } 141 } 142 143 | Popular Tags |