Index: test/java/org/apache/fop/traits/BorderPropsTestCase.java
===================================================================
--- test/java/org/apache/fop/traits/BorderPropsTestCase.java	(revision 891276)
+++ test/java/org/apache/fop/traits/BorderPropsTestCase.java	(working copy)
@@ -23,8 +23,9 @@
 
 import junit.framework.TestCase;
 
+import org.apache.xmlgraphics.java2d.CMYKColorSpace;
+
 import org.apache.fop.fo.Constants;
-import org.apache.fop.util.CMYKColorSpace;
 import org.apache.fop.util.ColorExt;
 import org.apache.fop.util.ColorUtil;
 
Index: test/java/org/apache/fop/util/ColorUtilTestCase.java
===================================================================
--- test/java/org/apache/fop/util/ColorUtilTestCase.java	(revision 891276)
+++ test/java/org/apache/fop/util/ColorUtilTestCase.java	(working copy)
@@ -24,6 +24,8 @@
 
 import junit.framework.TestCase;
 
+import org.apache.xmlgraphics.java2d.CMYKColorSpace;
+
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.FopFactory;
 
Index: src/java/org/apache/fop/afp/modca/GraphicsObject.java
===================================================================
--- src/java/org/apache/fop/afp/modca/GraphicsObject.java	(revision 891276)
+++ src/java/org/apache/fop/afp/modca/GraphicsObject.java	(working copy)
@@ -25,6 +25,8 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.xmlgraphics.java2d.ColorConverter;
+
 import org.apache.fop.afp.AFPDataObjectInfo;
 import org.apache.fop.afp.AFPObjectAreaInfo;
 import org.apache.fop.afp.Completable;
@@ -65,6 +67,10 @@
     /** the graphics state */
     private final GraphicsState graphicsState = new GraphicsState();
 
+
+    /** color  converter  */
+    private ColorConverter colorConverter = null;
+
     /**
      * Default constructor
      *
@@ -140,12 +146,23 @@
      */
     public void setColor(Color color) {
         if (!color.equals(graphicsState.color)) {
-            addObject(new GraphicsSetProcessColor(color));
+            addObject(new GraphicsSetProcessColor(colorConverter.convert(color)));
             graphicsState.color = color;
         }
     }
 
+
     /**
+     * Sets the color converter
+     *
+     * @param colorConverter
+     */
+    public void setColorConverter(ColorConverter colorConverter) {
+       this.colorConverter = colorConverter;
+    }
+
+
+    /**
      * Sets the current position
      *
      * @param coords the x and y coordinates of the current position
Index: src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java
===================================================================
--- src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java	(revision 891276)
+++ src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java	(working copy)
@@ -29,6 +29,16 @@
  */
 public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder {
 
+    /*
+     * GOCA Color space support:
+     * X'01' RGB
+     * X'04' CMYK
+     * X'06' Highlight color space
+     * X'08' CIELAB
+     * X'40' Standard OCA color space
+     */
+    private static final byte RGB = 0x01, CMYK = 0x04;
+
     private final Color color;
 
     private final float[] colorComponents;
@@ -36,7 +46,8 @@
     /**
      * Main constructor
      *
-     * @param color the color to set
+     * @param color
+     *            the color to set
      */
     public GraphicsSetProcessColor(Color color) {
         this.color = color;
@@ -50,7 +61,7 @@
 
     /** {@inheritDoc} */
     byte getOrderCode() {
-        return (byte)0xB2;
+        return (byte) 0xB2;
     }
 
     /** {@inheritDoc} */
@@ -60,24 +71,24 @@
         byte colspace;
         int colSpaceType = color.getColorSpace().getType();
         if (colSpaceType == ColorSpace.TYPE_CMYK) {
-            colspace = 0x04;
+            colspace = CMYK;
         } else if (colSpaceType == ColorSpace.TYPE_RGB) {
-            colspace = 0x01;
+            colspace = RGB;
         } else {
             log.error("unsupported colorspace " + colSpaceType);
-            colspace = 0x01;
+            colspace = RGB;
         }
 
         // COLSIZE(S)
         byte[] colsizes = new byte[] {0x00, 0x00, 0x00, 0x00};
         for (int i = 0; i < colorComponents.length; i++) {
-            colsizes[i] = (byte)8;
+            colsizes[i] = (byte) 8;
         }
 
         int len = getDataLength();
         byte[] data = new byte[len];
         data[0] = getOrderCode(); // GSPCOL order code
-        data[1] = (byte)(len - 2); // LEN
+        data[1] = (byte) (len - 2); // LEN
         data[2] = 0x00; // reserved; must be zero
         data[3] = colspace; // COLSPCE
         data[4] = 0x00; // reserved; must be zero
@@ -91,7 +102,7 @@
 
         // COLVALUE(S)
         for (int i = 0; i < colorComponents.length; i++) {
-            data[i + 12] = (byte)(colorComponents[i] * 255);
+            data[i + 12] = (byte) (colorComponents[i] * 255);
         }
 
         os.write(data);
@@ -101,4 +112,4 @@
     public String toString() {
         return "GraphicsSetProcessColor(col=" + color + ")";
     }
-}
\ No newline at end of file
+}
Index: src/java/org/apache/fop/afp/AFPPaintingState.java
===================================================================
--- src/java/org/apache/fop/afp/AFPPaintingState.java	(revision 891276)
+++ src/java/org/apache/fop/afp/AFPPaintingState.java	(working copy)
@@ -24,14 +24,19 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.xmlgraphics.java2d.ColorConverter;
+
 import org.apache.fop.afp.fonts.AFPPageFonts;
 import org.apache.fop.util.AbstractPaintingState;
+import org.apache.fop.util.DefaultColorConverter;
+import org.apache.fop.util.GrayScaleColorConverter;
 
 /**
- * This keeps information about the current painting state when writing to an AFP datastream.
+ * This keeps information about the current painting state when writing to an
+ * AFP datastream.
  */
-public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
-implements Cloneable {
+public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState implements
+        Cloneable {
 
     private static final long serialVersionUID = 8206711712452344473L;
 
@@ -46,9 +51,18 @@
     /** color image support */
     private boolean colorImages = false;
 
-    /** true if certain image formats may be embedded unchanged in their native format. */
+    /** color image handler */
+    private ColorConverter colorConverter = GrayScaleColorConverter.getInstance();
+
+    /**
+     * true if certain image formats may be embedded unchanged in their native
+     * format.
+     */
     private boolean nativeImagesSupported = false;
-    /** true if CMYK images (requires IOCA FS45 suppport on the target platform) may be generated */
+    /**
+     * true if CMYK images (requires IOCA FS45 suppport on the target platform)
+     * may be generated
+     */
     private boolean cmykImagesSupported;
 
     /** default value for image depth */
@@ -60,13 +74,12 @@
     /** the current page */
     private transient AFPPagePaintingState pagePaintingState = new AFPPagePaintingState();
 
-//    /** reference orientation */
-//    private int orientation = 0;
+    // /** reference orientation */
+    // private int orientation = 0;
 
     /** a unit converter */
     private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this);
 
-
     /**
      * Sets the rotation to be used for portrait pages, valid values are 0
      * (default), 90, 180, 270.
@@ -75,13 +88,11 @@
      *            The rotation in degrees.
      */
     public void setPortraitRotation(int rotation) {
-        if (rotation == 0 || rotation == 90 || rotation == 180
-                || rotation == 270) {
+        if (rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270) {
             portraitRotation = rotation;
         } else {
-            throw new IllegalArgumentException(
-                    "The portrait rotation must be one"
-                            + " of the values 0, 90, 180, 270");
+            throw new IllegalArgumentException("The portrait rotation must be one"
+                    + " of the values 0, 90, 180, 270");
 
         }
     }
@@ -103,13 +114,11 @@
      *            The rotation in degrees.
      */
     public void setLandscapeRotation(int rotation) {
-        if (rotation == 0 || rotation == 90 || rotation == 180
-                || rotation == 270) {
+        if (rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270) {
             landscapeRotation = rotation;
         } else {
-            throw new IllegalArgumentException(
-                    "The landscape rotation must be one"
-                            + " of the values 0, 90, 180, 270");
+            throw new IllegalArgumentException("The landscape rotation must be one"
+                    + " of the values 0, 90, 180, 270");
         }
     }
 
@@ -152,13 +161,18 @@
     }
 
     /**
-     * Sets whether images are color or not
+     * Sets whether images are color or not and instantiates a ColorHandler
      *
      * @param colorImages
      *            color image output
      */
     public void setColorImages(boolean colorImages) {
         this.colorImages = colorImages;
+
+        if (colorImages) {
+            this.colorConverter = DefaultColorConverter.getInstance();
+        }
+
     }
 
     /**
@@ -171,9 +185,19 @@
     }
 
     /**
+     * Used to convert color in respect of the colorImages flag
+     *
+     * @return the color converter
+     */
+    public ColorConverter getColorConverter() {
+        return this.colorConverter;
+    }
+
+    /**
      * Sets whether images are natively supported or not in the AFP environment
      *
-     * @param nativeImagesSupported true if images are natively supported in this AFP environment
+     * @param nativeImagesSupported
+     *            true if images are natively supported in this AFP environment
      */
     public void setNativeImagesSupported(boolean nativeImagesSupported) {
         this.nativeImagesSupported = nativeImagesSupported;
@@ -189,10 +213,12 @@
     }
 
     /**
-     * Controls whether CMYK images (IOCA FS45) are enabled. By default, support is disabled
-     * for wider compatibility. When disabled, any CMYK image is converted to the selected
-     * color format.
-     * @param value true to enabled CMYK images
+     * Controls whether CMYK images (IOCA FS45) are enabled. By default, support
+     * is disabled for wider compatibility. When disabled, any CMYK image is
+     * converted to the selected color format.
+     *
+     * @param value
+     *            true to enabled CMYK images
      */
     public void setCMYKImagesSupported(boolean value) {
         this.cmykImagesSupported = value;
@@ -200,6 +226,7 @@
 
     /**
      * Indicates whether CMYK images (IOCA FS45) are enabled.
+     *
      * @return true if IOCA FS45 is enabled
      */
     public boolean isCMYKImagesSupported() {
@@ -259,7 +286,8 @@
     /**
      * Sets the page width
      *
-     * @param pageWidth the page width
+     * @param pageWidth
+     *            the page width
      */
     public void setPageWidth(int pageWidth) {
         pagePaintingState.setWidth(pageWidth);
@@ -277,7 +305,8 @@
     /**
      * Sets the page height
      *
-     * @param pageHeight the page height
+     * @param pageHeight
+     *            the page height
      */
     public void setPageHeight(int pageHeight) {
         pagePaintingState.setHeight(pageHeight);
@@ -304,10 +333,11 @@
     /**
      * Sets the uri of the current image
      *
-     * @param uri the uri of the current image
+     * @param uri
+     *            the uri of the current image
      */
     public void setImageUri(String uri) {
-        ((AFPData)getData()).imageUri = uri;
+        ((AFPData) getData()).imageUri = uri;
     }
 
     /**
@@ -316,7 +346,7 @@
      * @return the uri of the current image
      */
     public String getImageUri() {
-        return ((AFPData)getData()).imageUri;
+        return ((AFPData) getData()).imageUri;
     }
 
     /**
@@ -338,10 +368,13 @@
     }
 
     /**
-     * Returns a point on the current page, taking the current painting state into account.
+     * Returns a point on the current page, taking the current painting state
+     * into account.
      *
-     * @param x the X-coordinate
-     * @param y the Y-coordinate
+     * @param x
+     *            the X-coordinate
+     * @param y
+     *            the Y-coordinate
      * @return a point on the current page
      */
     public Point getPoint(int x, int y) {
@@ -370,12 +403,13 @@
 
     /** {@inheritDoc} */
     public Object clone() {
-        AFPPaintingState paintingState = (AFPPaintingState)super.clone();
-        paintingState.pagePaintingState = (AFPPagePaintingState)this.pagePaintingState.clone();
+        AFPPaintingState paintingState = (AFPPaintingState) super.clone();
+        paintingState.pagePaintingState = (AFPPagePaintingState) this.pagePaintingState.clone();
         paintingState.portraitRotation = this.portraitRotation;
         paintingState.landscapeRotation = this.landscapeRotation;
         paintingState.bitsPerPixel = this.bitsPerPixel;
         paintingState.colorImages = this.colorImages;
+        paintingState.colorConverter = this.colorConverter;
         paintingState.resolution = this.resolution;
         return paintingState;
     }
@@ -383,13 +417,9 @@
     /** {@inheritDoc} */
     public String toString() {
         return "AFPPaintingState{" + "portraitRotation=" + portraitRotation
-        + ", landscapeRotation=" + landscapeRotation
-        + ", colorImages=" + colorImages
-        + ", bitsPerPixel=" + bitsPerPixel
-        + ", resolution=" + resolution
-        + ", pageState=" + pagePaintingState
-        + super.toString()
-        + "}";
+                + ", landscapeRotation=" + landscapeRotation + ", colorImages=" + colorImages
+                + ", bitsPerPixel=" + bitsPerPixel + ", resolution=" + resolution + ", pageState="
+                + pagePaintingState + super.toString() + "}";
     }
 
     /**
@@ -423,7 +453,8 @@
         /**
          * Sets the page width
          *
-         * @param width the page width
+         * @param width
+         *            the page width
          */
         protected void setWidth(int width) {
             this.width = width;
@@ -441,7 +472,8 @@
         /**
          * Sets the page height
          *
-         * @param height the page height
+         * @param height
+         *            the page height
          */
         protected void setHeight(int height) {
             this.height = height;
@@ -459,7 +491,8 @@
         /**
          * Sets the current page fonts
          *
-         * @param fonts the current page fonts
+         * @param fonts
+         *            the current page fonts
          */
         protected void setFonts(AFPPageFonts fonts) {
             this.fonts = fonts;
@@ -486,7 +519,8 @@
         /**
          * Sets the current page orientation
          *
-         * @param orientation the current page orientation
+         * @param orientation
+         *            the current page orientation
          */
         protected void setOrientation(int orientation) {
             this.orientation = orientation;
@@ -505,12 +539,8 @@
 
         /** {@inheritDoc} */
         public String toString() {
-            return "AFPPagePaintingState{width=" + width
-            + ", height=" + height
-            + ", orientation=" + orientation
-            + ", fonts=" + fonts
-            + ", fontCount=" + fontCount
-            + "}";
+            return "AFPPagePaintingState{width=" + width + ", height=" + height + ", orientation="
+                    + orientation + ", fonts=" + fonts + ", fontCount=" + fontCount + "}";
         }
     }
 
@@ -527,7 +557,7 @@
 
         /** {@inheritDoc} */
         public Object clone() {
-            AFPData obj = (AFPData)super.clone();
+            AFPData obj = (AFPData) super.clone();
             obj.filled = this.filled;
             obj.imageUri = this.imageUri;
             return obj;
@@ -535,10 +565,8 @@
 
         /** {@inheritDoc} */
         public String toString() {
-            return "AFPData{" + super.toString()
-            + ", filled=" + filled
-            + ", imageUri=" + imageUri
-            + "}";
+            return "AFPData{" + super.toString() + ", filled=" + filled + ", imageUri=" + imageUri
+                    + "}";
         }
 
         /** {@inheritDoc} */
Index: src/java/org/apache/fop/afp/AFPDataObjectFactory.java
===================================================================
--- src/java/org/apache/fop/afp/AFPDataObjectFactory.java	(revision 891276)
+++ src/java/org/apache/fop/afp/AFPDataObjectFactory.java	(working copy)
@@ -165,6 +165,9 @@
         AFPGraphics2D g2d = graphicsObjectInfo.getGraphics2D();
         g2d.setGraphicsObject(graphicsObj);
 
+        //set color converter (i.e. an rgb to grayscale converter)
+        graphicsObj.setColorConverter(g2d.getPaintingState().getColorConverter());
+        
         // paint to graphics object
         Graphics2DImagePainter painter = graphicsObjectInfo.getPainter();
         Rectangle2D area = graphicsObjectInfo.getArea();
Index: src/java/org/apache/fop/pdf/PDFColor.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFColor.java	(revision 891276)
+++ src/java/org/apache/fop/pdf/PDFColor.java	(working copy)
@@ -26,7 +26,7 @@
 import java.util.List;
 import java.util.ArrayList;
 
-import org.apache.fop.util.CMYKColorSpace;
+import org.apache.xmlgraphics.java2d.CMYKColorSpace;
 import org.apache.fop.util.ColorExt;
 
 /**
Index: src/java/org/apache/fop/util/ColorUtil.java
===================================================================
--- src/java/org/apache/fop/util/ColorUtil.java	(revision 891276)
+++ src/java/org/apache/fop/util/ColorUtil.java	(working copy)
@@ -27,6 +27,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.xmlgraphics.java2d.CMYKColorSpace;
+
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.expr.PropertyException;
 
Index: src/java/org/apache/fop/util/CMYKColorSpace.java
===================================================================
--- src/java/org/apache/fop/util/CMYKColorSpace.java	(revision 891276)
+++ src/java/org/apache/fop/util/CMYKColorSpace.java	(working copy)
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.util;
-
-import java.awt.color.ColorSpace;
-
-/**
- * This class represents an uncalibrated CMYK color space. It is used by
- * the JpegImage class.
- */
-public class CMYKColorSpace extends ColorSpace {
-
-    private static CMYKColorSpace instance;
-
-    /**
-     * @see java.awt.color.ColorSpace#ColorSpace(int, int)
-     */
-    protected CMYKColorSpace(int type, int numcomponents) {
-        super(type, numcomponents);
-    }
-
-    /**
-     * Returns an instance of an uncalibrated CMYK color space.
-     * @return CMYKColorSpace the requested color space object
-     */
-    public static CMYKColorSpace getInstance() {
-        if (instance == null) {
-            instance = new CMYKColorSpace(TYPE_CMYK, 4);
-        }
-        return instance;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public float[] toRGB(float[] colorvalue) {
-        return new float [] {
-            (1 - colorvalue[0]) * (1 - colorvalue[3]),
-            (1 - colorvalue[1]) * (1 - colorvalue[3]),
-            (1 - colorvalue[2]) * (1 - colorvalue[3])};
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public float[] fromRGB(float[] rgbvalue) {
-        throw new UnsupportedOperationException("NYI");
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public float[] toCIEXYZ(float[] colorvalue) {
-        throw new UnsupportedOperationException("NYI");
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public float[] fromCIEXYZ(float[] colorvalue) {
-        throw new UnsupportedOperationException("NYI");
-    }
-
-}
