package org.apache.fop.fo;
// FOP
-import org.apache.fop.fo.*;
-import org.apache.fop.fo.flow.*;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.ColorType;
/**
* The fo:color-profile formatting object.
+ * This loads the color profile when needed and resolves a requested color.
*/
-public class ColorProfile extends ToBeImplementedElement {
+public class ColorProfile extends FObj {
+ int intent;
+ String src;
+ String profileName;
protected ColorProfile(FONode parent) {
super(parent);
+ }
+
+ public void end() {
+ src = this.properties.get("src").getString();
+ profileName = this.properties.get("color-profile-name").getString();
+ intent = this.properties.get("rendering-intent").getEnum();
+ this.properties = null;
+ }
- // this.properties.get("src");
- // this.properties.get("color-profile-name");
- // this.properties.get("rendering-intent");
+ /**
+ * Get the name of this color profile.
+ */
+ public String getProfileName() {
+ return profileName;
}
+ /**
+ * Get the color specified with the color values from the color profile.
+ * The default values are used if the profile could not be loaded
+ * or the value is not found.
+ */
+ public ColorType getColor(int[] colorVals, int defR, int defG, int defB) {
+ return null;
+ }
+
+ /**
+ * Load the color profile.
+ */
+ private void load() {
+
+ }
}
package org.apache.fop.fo;
// FOP
-import org.apache.fop.fo.*;
import org.apache.fop.fo.flow.*;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.layout.AreaTree;
import org.apache.fop.apps.FOPException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
/**
+ * Declarations formatting object.
+ * A declarations formatting object holds a set of color-profiles
+ * and optionally additional non-XSL namespace elements.
+ * The color-profiles are held in a hashmap for use with color-profile
+ * references.
*/
-public class Declarations extends ToBeImplementedElement {
+public class Declarations extends FObj {
+ HashMap colorProfiles = null;
+ ArrayList external = null;
protected Declarations(FONode parent) {
super(parent);
}
+ /**
+ * At then end of this element sort out the child into
+ * a hashmap of color profiles and a list of external xml.
+ */
+ public void end() {
+ for(Iterator iter = children.iterator(); iter.hasNext(); ) {
+ FONode node = (FONode)iter.next();
+ if(node.getName().equals("fo:color-profile")) {
+ ColorProfile cp = (ColorProfile)node;
+ if(!"".equals(cp.getProfileName())) {
+ if(colorProfiles == null) {
+ colorProfiles = new HashMap();
+ }
+ if(colorProfiles.get(cp.getProfileName()) != null) {
+ // duplicate names
+ log.warn("Duplicate fo:color-profile profile name : " + cp.getProfileName());
+ }
+ colorProfiles.put(cp.getProfileName(), cp);
+ } else {
+ log.warn("color-profile-name required for color profile");
+ }
+ } else if(node instanceof XMLObj) {
+ if(external == null) {
+ external = new ArrayList();
+ }
+ external.add(node);
+ } else {
+ log.warn("invalid element " + node.getName() + "inside declarations");
+ }
+ }
+ children = null;
+ }
}