You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2006/05/03 09:21:16 UTC

svn commit: r399185 [2/2] - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/area/ src/java/org/apache/fop/datatypes/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/expr/ src/java/org/apache/fop/fo/flow/ src/java/org/apache/fop/fo/pagination/...

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java Wed May  3 00:21:02 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@
 import java.awt.geom.GeneralPath;
 import java.util.List;
 
-import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fonts.FontInfo;
 
@@ -131,28 +130,6 @@
     }
 
     /**
-     * Converts a ColorType to a java.awt.Color (sRGB).
-     *
-     * @param col the color as a org.apache.fop.datatypes.ColorType
-     * @return the converted color as a java.awt.Color
-     */
-    public Color toColor(ColorType col) {
-        return new Color(col.getRed(), col.getGreen(), col.getBlue());
-    }
-
-    /**
-     * Update the current Color
-     * @param col the ColorType
-     */
-    public void updateColor(ColorType col) {
-        if (col == null) {
-            return;
-        }
-        Color newCol = toColor(col);
-        updateColor(newCol);
-    }
-
-    /**
      * @return the current java.awt.Color
      */
     public java.awt.Color getColor() {
@@ -238,6 +215,7 @@
         return update;
     }
 
+    /** @return the currently active Stroke */
     public BasicStroke getStroke() {
         return (BasicStroke) currentGraphics.getStroke();
     }
@@ -322,7 +300,7 @@
         return getGraph().getTransform();
     }
 
-    /** a verbose description of the current state */
+    /** @see java.lang.Object#toString() */
     public String toString() {
         String s = "AWTGraphicsState " + currentGraphics.toString()
                 + ", Stroke (width: " + currentStrokeWidth + " style: "

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java Wed May  3 00:21:02 2006
@@ -55,10 +55,8 @@
 import org.apache.fop.area.Trait;
 import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
@@ -427,8 +425,8 @@
      * @see org.apache.fop.render.AbstractPathOrientedRenderer#updateColor(
      *          org.apache.fop.datatypes.ColorType, boolean)
      */
-    protected void updateColor(ColorType col, boolean fill) {
-        state.updateColor(toColor(col));
+    protected void updateColor(Color col, boolean fill) {
+        state.updateColor(col);
     }
 
     /**
@@ -489,10 +487,10 @@
      *          org.apache.fop.datatypes.ColorType)
      */
     protected void drawBorderLine(float x1, float y1, float x2, float y2, 
-            boolean horz, boolean startOrBefore, int style, ColorType col) {
+            boolean horz, boolean startOrBefore, int style, Color col) {
         Graphics2D g2d = state.getGraph();
         drawBorderLine(new Rectangle2D.Float(x1, y1, x2 - x1, y2 - y1), 
-                horz, startOrBefore, style, toColor(col), g2d);
+                horz, startOrBefore, style, col, g2d);
     }
 
     /**
@@ -668,8 +666,8 @@
         Font font = getFontFromArea(text);
         state.updateFont(font.getFontName(), font.getFontSize(), null);
 
-        ColorType ct = (ColorType) text.getTrait(Trait.COLOR);
-        state.updateColor(ct);
+        Color col = (Color) text.getTrait(Trait.COLOR);
+        state.updateColor(col);
 
         String s = text.getText();
         state.getGraph().drawString(s, rx / 1000f, bl / 1000f);
@@ -699,7 +697,7 @@
         float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() 
                 + area.getIPD()) / 1000f;
 
-        ColorType col = (ColorType) area.getTrait(Trait.COLOR);
+        Color col = (Color) area.getTrait(Trait.COLOR);
         state.updateColor(col);
 
         Line2D line = new Line2D.Float();
@@ -725,7 +723,7 @@
         case EN_RIDGE:
             float half = area.getRuleThickness() / 2000f;
 
-            state.updateColor(lightenColor(toColor(col), 0.6f));
+            state.updateColor(lightenColor(col, 0.6f));
             moveTo(startx, starty);
             lineTo(endx, starty);
             lineTo(endx, starty + 2 * half);
@@ -733,7 +731,7 @@
             closePath();
             state.getGraph().fill(currentPath);
             currentPath = null;
-            state.updateColor(toColor(col));
+            state.updateColor(col);
             if (style == EN_GROOVE) {
                 moveTo(startx, starty);
                 lineTo(endx, starty);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/RendererState.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/RendererState.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/RendererState.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/RendererState.java Wed May  3 00:21:02 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
 import java.awt.Shape;
 import java.awt.geom.AffineTransform;
 
-import org.apache.fop.datatypes.ColorType;
 
 /**
  * An interface for the classes which hold the state of the current graphics context.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java Wed May  3 00:21:02 2006
@@ -60,7 +60,6 @@
 import org.apache.fop.area.inline.InlineParent;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.area.inline.SpaceArea;
-import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.fonts.Typeface;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontSetup;
@@ -707,7 +706,7 @@
     
     /** @see org.apache.fop.render.AbstractPathOrientedRenderer */
     protected void drawBorderLine(float x1, float y1, float x2, float y2, 
-            boolean horz, boolean startOrBefore, int style, ColorType col) {
+            boolean horz, boolean startOrBefore, int style, Color col) {
         float w = x2 - x1;
         float h = y2 - y1;
         if ((w < 0) || (h < 0)) {
@@ -716,7 +715,7 @@
         }
         switch (style) {
             case Constants.EN_DASHED: 
-                setColor(toColor(col), false, null);
+                setColor(col, false, null);
                 if (horz) {
                     float unit = Math.abs(2 * h);
                     int rep = (int)(w / unit);
@@ -744,7 +743,7 @@
                 }
                 break;
             case Constants.EN_DOTTED:
-                setColor(toColor(col), false, null);
+                setColor(col, false, null);
                 currentStream.add("1 J ");
                 if (horz) {
                     float unit = Math.abs(2 * h);
@@ -773,7 +772,7 @@
                 }
                 break;
             case Constants.EN_DOUBLE:
-                setColor(toColor(col), false, null);
+                setColor(col, false, null);
                 currentStream.add("[] 0 d ");
                 if (horz) {
                     float h3 = h / 3;
@@ -800,32 +799,31 @@
             {
                 float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
                 currentStream.add("[] 0 d ");
-                Color c = toColor(col);
                 if (horz) {
-                    Color uppercol = lightenColor(c, -colFactor);
-                    Color lowercol = lightenColor(c, colFactor);
+                    Color uppercol = lightenColor(col, -colFactor);
+                    Color lowercol = lightenColor(col, colFactor);
                     float h3 = h / 3;
                     currentStream.add(format(h3) + " w\n");
                     float ym1 = y1 + (h3 / 2);
                     setColor(uppercol, false, null);
                     currentStream.add(format(x1) + " " + format(ym1) + " m " 
                             + format(x2) + " " + format(ym1) + " l S\n");
-                    setColor(c, false, null);
+                    setColor(col, false, null);
                     currentStream.add(format(x1) + " " + format(ym1 + h3) + " m " 
                                         + format(x2) + " " + format(ym1 + h3) + " l S\n");
                     setColor(lowercol, false, null);
                     currentStream.add(format(x1) + " " + format(ym1 + h3 + h3) + " m " 
                                         + format(x2) + " " + format(ym1 + h3 + h3) + " l S\n");
                 } else {
-                    Color leftcol = lightenColor(c, -colFactor);
-                    Color rightcol = lightenColor(c, colFactor);
+                    Color leftcol = lightenColor(col, -colFactor);
+                    Color rightcol = lightenColor(col, colFactor);
                     float w3 = w / 3;
                     currentStream.add(format(w3) + " w\n");
                     float xm1 = x1 + (w3 / 2);
                     setColor(leftcol, false, null);
                     currentStream.add(format(xm1) + " " + format(y1) + " m " 
                             + format(xm1) + " " + format(y2) + " l S\n");
-                    setColor(c, false, null);
+                    setColor(col, false, null);
                     currentStream.add(format(xm1 + w3) + " " + format(y1) + " m " 
                                         + format(xm1 + w3) + " " + format(y2) + " l S\n");
                     setColor(rightcol, false, null);
@@ -839,7 +837,7 @@
             {
                 float colFactor = (style == EN_OUTSET ? 0.4f : -0.4f);
                 currentStream.add("[] 0 d ");
-                Color c = toColor(col);
+                Color c = col;
                 if (horz) {
                     c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
                     currentStream.add(format(h) + " w\n");
@@ -860,7 +858,7 @@
             case Constants.EN_HIDDEN:
                 break;
             default:
-                setColor(toColor(col), false, null);
+                setColor(col, false, null);
                 currentStream.add("[] 0 d ");
                 if (horz) {
                     currentStream.add(format(h) + " w\n");
@@ -1082,7 +1080,7 @@
         boolean useMultiByte = tf.isMultiByte();
         
         updateFont(fontName, size, pdf);
-        ColorType ct = (ColorType) text.getTrait(Trait.COLOR);
+        Color ct = (Color) text.getTrait(Trait.COLOR);
         updateColor(ct, true, pdf);
 
         // word.getOffset() = only height of text itself
@@ -1282,25 +1280,24 @@
      * @param pdf StringBuffer to write the PDF code to, if null, the code is
      *     written to the current stream.
      */
-    private void updateColor(ColorType col, boolean fill, StringBuffer pdf) {
+    private void updateColor(Color col, boolean fill, StringBuffer pdf) {
         if (col == null) {
             return;
         }
-        Color newCol = toColor(col);
         boolean update = false;
         if (fill) {
-            update = currentState.setBackColor(newCol);
+            update = currentState.setBackColor(col);
         } else {
-            update = currentState.setColor(newCol);
+            update = currentState.setColor(col);
         }
 
         if (update) {
-            setColor(newCol, fill, pdf);
+            setColor(col, fill, pdf);
         }
     }
 
     /** @see org.apache.fop.render.AbstractPathOrientedRenderer */
-    protected  void updateColor(ColorType col, boolean fill) {
+    protected  void updateColor(Color col, boolean fill) {
         updateColor(col, fill, null);
     }
     
@@ -1492,7 +1489,7 @@
         float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() 
                         + area.getIPD()) / 1000f;
         float ruleThickness = area.getRuleThickness() / 1000f;
-        ColorType col = (ColorType)area.getTrait(Trait.COLOR);
+        Color col = (Color)area.getTrait(Trait.COLOR);
 
         switch (style) {
             case EN_SOLID:
@@ -1513,14 +1510,14 @@
             case EN_RIDGE:
                 float half = area.getRuleThickness() / 2000f;
 
-                setColor(lightenColor(toColor(col), 0.6f), true, null);
+                setColor(lightenColor(col, 0.6f), true, null);
                 currentStream.add(format(startx) + " " + format(starty) + " m\n");
                 currentStream.add(format(endx) + " " + format(starty) + " l\n");
                 currentStream.add(format(endx) + " " + format(starty + 2 * half) + " l\n");
                 currentStream.add(format(startx) + " " + format(starty + 2 * half) + " l\n");
                 currentStream.add("h\n");
                 currentStream.add("f\n");
-                setColor(toColor(col), true, null);
+                setColor(col, true, null);
                 if (style == EN_GROOVE) {
                     currentStream.add(format(startx) + " " + format(starty) + " m\n");
                     currentStream.add(format(endx) + " " + format(starty) + " l\n");

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java Wed May  3 00:21:02 2006
@@ -52,7 +52,6 @@
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.area.inline.WordArea;
-import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
@@ -273,7 +272,7 @@
     }
 
     /** @see org.apache.fop.render.AbstractPathOrientedRenderer */
-    protected void updateColor(ColorType col, boolean fill) {
+    protected void updateColor(Color col, boolean fill) {
         try {
             useColor(col);
         } catch (IOException ioe) {
@@ -419,8 +418,8 @@
         }
     }
 
-    private void useColor(ColorType col) throws IOException {
-        gen.useRGBColor(toColor(col));
+    private void useColor(Color col) throws IOException {
+        gen.useRGBColor(col);
     }
 
     /** @see org.apache.fop.render.AbstractPathOrientedRenderer#drawBackAndBorders(
@@ -441,7 +440,7 @@
     
     /** @see org.apache.fop.render.AbstractPathOrientedRenderer */
     protected void drawBorderLine(float x1, float y1, float x2, float y2, 
-            boolean horz, boolean startOrBefore, int style, ColorType col) {
+            boolean horz, boolean startOrBefore, int style, Color col) {
         try {
             float w = x2 - x1;
             float h = y2 - y1;
@@ -528,28 +527,27 @@
                 case Constants.EN_RIDGE:
                     float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
                     gen.useDash(null);
-                    Color c = toColor(col);
                     if (horz) {
-                        Color uppercol = lightenColor(c, -colFactor);
-                        Color lowercol = lightenColor(c, colFactor);
+                        Color uppercol = lightenColor(col, -colFactor);
+                        Color lowercol = lightenColor(col, colFactor);
                         float h3 = h / 3;
                         gen.useLineWidth(h3);
                         float ym1 = y1 + (h3 / 2);
                         gen.useRGBColor(uppercol);
                         drawLine(x1, ym1, x2, ym1);
-                        gen.useRGBColor(c);
+                        gen.useRGBColor(col);
                         drawLine(x1, ym1 + h3, x2, ym1 + h3);
                         gen.useRGBColor(lowercol);
                         drawLine(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3);
                     } else {
-                        Color leftcol = lightenColor(c, -colFactor);
-                        Color rightcol = lightenColor(c, colFactor);
+                        Color leftcol = lightenColor(col, -colFactor);
+                        Color rightcol = lightenColor(col, colFactor);
                         float w3 = w / 3;
                         gen.useLineWidth(w3);
                         float xm1 = x1 + (w3 / 2);
                         gen.useRGBColor(leftcol);
                         drawLine(xm1, y1, xm1, y2);
-                        gen.useRGBColor(c);
+                        gen.useRGBColor(col);
                         drawLine(xm1 + w3, y1, xm1 + w3, y2);
                         gen.useRGBColor(rightcol);
                         drawLine(xm1 + w3 + w3, y1, xm1 + w3 + w3, y2);
@@ -559,15 +557,14 @@
                 case Constants.EN_OUTSET:
                     colFactor = (style == EN_OUTSET ? 0.4f : -0.4f);
                     gen.useDash(null);
-                    c = toColor(col);
                     if (horz) {
-                        c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
+                        Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
                         gen.useLineWidth(h);
                         float ym1 = y1 + (h / 2);
                         gen.useRGBColor(c);
                         drawLine(x1, ym1, x2, ym1);
                     } else {
-                        c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
+                        Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
                         gen.useLineWidth(w);
                         float xm1 = x1 + (w / 2);
                         gen.useRGBColor(c);
@@ -856,7 +853,7 @@
         int bl = currentBPPosition + area.getOffset() + area.getBaselineOffset();
 
         useFont(fontname, fontsize);
-        ColorType ct = (ColorType)area.getTrait(Trait.COLOR);
+        Color ct = (Color)area.getTrait(Trait.COLOR);
         if (ct != null) {
             try {
                 useColor(ct);
@@ -1046,7 +1043,7 @@
         float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() 
                         + area.getIPD()) / 1000f;
         float ruleThickness = area.getRuleThickness() / 1000f;
-        ColorType col = (ColorType)area.getTrait(Trait.COLOR);
+        Color col = (Color)area.getTrait(Trait.COLOR);
 
         try {
             switch (style) {
@@ -1068,14 +1065,14 @@
                 case EN_RIDGE:
                     float half = area.getRuleThickness() / 2000f;
     
-                    gen.useRGBColor(lightenColor(toColor(col), 0.6f));
+                    gen.useRGBColor(lightenColor(col, 0.6f));
                     moveTo(startx, starty);
                     lineTo(endx, starty);
                     lineTo(endx, starty + 2 * half);
                     lineTo(startx, starty + 2 * half);
                     closePath();
                     gen.writeln(" fill newpath");
-                    gen.useRGBColor(toColor(col));
+                    gen.useRGBColor(col);
                     if (style == EN_GROOVE) {
                         moveTo(startx, starty);
                         lineTo(endx, starty);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java Wed May  3 00:21:02 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,9 +18,8 @@
 
 package org.apache.fop.render.rtf;
 
-import org.apache.fop.datatypes.ColorType;
+import java.awt.Color;
 import org.apache.fop.datatypes.Length;
-import org.apache.fop.fo.properties.ColorTypeProperty;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable;
 
@@ -69,10 +68,11 @@
      * @param color value of attribute
      * @return this (which now contains the new entry)
      */
-    public RtfAttributes set(String name, ColorType color) {
-        int redComponent = ColorTypeProperty.convertChannelToInteger (color.getRed());
-        int greenComponent = ColorTypeProperty.convertChannelToInteger (color.getGreen());
-        int blueComponent = ColorTypeProperty.convertChannelToInteger (color.getBlue());
+    public RtfAttributes set(String name, Color color) {
+        // TODO: This code is duplicated in TextAttributesConverter
+        int redComponent = color.getRed();
+        int greenComponent = color.getGreen();
+        int blueComponent = color.getBlue();
         set(name, RtfColorTable.getInstance().getColorNumber(
                 redComponent, greenComponent, blueComponent).intValue());
         return this;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java Wed May  3 00:21:02 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,10 +18,9 @@
 
 package org.apache.fop.render.rtf;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.impl.SimpleLog;
+import java.awt.Color;
+
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.Table;
 import org.apache.fop.fo.flow.TableBody;
@@ -29,7 +28,6 @@
 import org.apache.fop.fo.flow.TableHeader;
 import org.apache.fop.fo.flow.TableRow;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.render.rtf.BorderAttributesConverter;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableAttributes;
 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
 
@@ -50,8 +48,6 @@
 
 public final class TableAttributesConverter {
 
-    private static Log log = new SimpleLog("FOP/RTF");
-
     //////////////////////////////////////////////////
     // @@ Construction
     //////////////////////////////////////////////////
@@ -119,7 +115,7 @@
         CommonBorderPaddingBackground border = fobj.getCommonBorderPaddingBackground();
 
         // Cell background color
-        ColorType color = border.backgroundColor;
+        Color color = border.backgroundColor;
         if (color == null) {
             //If there is no background-color specified for the cell,
             //then try to read it from table-row or table-header.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Wed May  3 00:21:02 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,9 +18,10 @@
 
 package org.apache.fop.render.rtf;
 
+import java.awt.Color;
+
 //FOP
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
@@ -29,7 +30,6 @@
 import org.apache.fop.fo.flow.BlockContainer;
 import org.apache.fop.fo.flow.Inline;
 import org.apache.fop.fo.flow.PageNumber;
-import org.apache.fop.fo.properties.ColorTypeProperty;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonFont;
 import org.apache.fop.fo.properties.CommonMarginBlock;
@@ -160,7 +160,7 @@
     }
 
 
-    private static void attrFontColor(ColorType colorType, RtfAttributes rtfAttr) {
+    private static void attrFontColor(Color colorType, RtfAttributes rtfAttr) {
         // Cell background color
         if (colorType != null) {
            if (colorType.getAlpha() != 0
@@ -312,7 +312,7 @@
      */
     private static void attrBackgroundColor(CommonBorderPaddingBackground bpb, 
                 RtfAttributes rtfAttr) {
-        ColorType fopValue = bpb.backgroundColor;
+        Color fopValue = bpb.backgroundColor;
         int rtfColor = 0;
         /* FOP uses a default background color of "transparent", which is
            actually a transparent black, which is generally not suitable as a
@@ -348,10 +348,11 @@
     * @param fopColor the ColorType object to be converted
     * @return integer pointing into the RTF color table
     */
-   public static int convertFOPColorToRTF(ColorType fopColor) {
-       int redComponent = ColorTypeProperty.convertChannelToInteger (fopColor.getRed());
-       int greenComponent = ColorTypeProperty.convertChannelToInteger (fopColor.getGreen());
-       int blueComponent = ColorTypeProperty.convertChannelToInteger (fopColor.getBlue());
+   public static int convertFOPColorToRTF(Color fopColor) {
+       // TODO: This code is duplicated in FOPRtfAttributesConverter
+       int redComponent = fopColor.getRed();
+       int greenComponent = fopColor.getGreen();
+       int blueComponent = fopColor.getBlue();
        return RtfColorTable.getInstance().getColorNumber(redComponent,
                greenComponent, blueComponent).intValue();
    }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java Wed May  3 00:21:02 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
  
 package org.apache.fop.render.txt;
 
+import java.awt.Color;
 import java.awt.Point;
 import java.awt.geom.Rectangle2D;
 import java.io.IOException;
@@ -32,7 +33,6 @@
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.area.inline.Image;
 import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.render.AbstractPathOrientedRenderer;
 import org.apache.fop.render.txt.border.AbstractBorderElement;
 import org.apache.fop.render.txt.border.BorderManager;
@@ -418,14 +418,17 @@
      * Changes current filling char.
      * @see org.apache.fop.render.AbstractPathOrientedRenderer
      */
-    protected void updateColor(ColorType col, boolean fill) {
+    protected void updateColor(Color col, boolean fill) {
         if (col == null) {
             return;
         }
-        // fillShade evaluation was taken from fop-0.20.5 
-        double fillShade = 0.30f * col.getRed() 
-                         + 0.59f * col.getGreen() 
-                         + 0.11f * col.getBlue();
+        // fillShade evaluation was taken from fop-0.20.5
+        // TODO: This fillShase is catually the luminance component of the color
+        // transformed to the YUV (YPrBb) Colorspace. It should use standard
+        // Java methods for its conversion instead of the formula given here.
+        double fillShade = 0.30f / 255f * col.getRed() 
+                         + 0.59f / 255f * col.getGreen() 
+                         + 0.11f / 255f * col.getBlue();
         fillShade = 1 - fillShade;
         
         if (fillShade > 0.8f) {
@@ -494,7 +497,7 @@
      * @see org.apache.fop.render.AbstractPathOrientedRenderer
      */
     protected void drawBorderLine(float x1, float y1, float x2, float y2,
-            boolean horz, boolean startOrBefore, int style, ColorType col) {
+            boolean horz, boolean startOrBefore, int style, Color col) {
 
         int borderHeight = bm.getHeight();
         int borderWidth = bm.getWidth();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java Wed May  3 00:21:02 2006
@@ -19,36 +19,32 @@
 package org.apache.fop.render.xml;
 
 // Java
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Iterator;
-import java.awt.geom.Rectangle2D;
 
 import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
 
 import org.w3c.dom.Document;
+
 import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.ext.LexicalHandler;
 import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.ContentHandler;
 
-// FOP
-import org.apache.fop.render.PrintRenderer;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.XMLHandler;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.fop.util.QName;
-import org.apache.fop.util.XMLizable;
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.BeforeFloat;
@@ -56,10 +52,10 @@
 import org.apache.fop.area.BlockViewport;
 import org.apache.fop.area.BodyRegion;
 import org.apache.fop.area.CTM;
-import org.apache.fop.area.NormalFlow;
 import org.apache.fop.area.Footnote;
 import org.apache.fop.area.LineArea;
 import org.apache.fop.area.MainReference;
+import org.apache.fop.area.NormalFlow;
 import org.apache.fop.area.OffDocumentExtensionAttachment;
 import org.apache.fop.area.OffDocumentItem;
 import org.apache.fop.area.PageViewport;
@@ -76,15 +72,21 @@
 import org.apache.fop.area.inline.InlineParent;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.Space;
-import org.apache.fop.area.inline.Viewport;
-import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.area.inline.SpaceArea;
+import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.inline.Viewport;
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.render.PrintRenderer;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.XMLHandler;
+import org.apache.fop.util.ColorUtil;
+import org.apache.fop.util.XMLizable;
 
 /**
  * Renderer that renders areas to XML for debugging purposes.
@@ -378,6 +380,9 @@
                         addAttribute("bkg-horz-offset", bkg.getHoriz());
                         addAttribute("bkg-vert-offset", bkg.getVertical());
                     }
+                } else if (clazz.equals(Color.class)) {
+                    Color c = (Color)value;
+                    addAttribute(name, ColorUtil.colorTOsRGBString(c));
                 } else if (key == Trait.START_INDENT || key == Trait.END_INDENT) {
                     if (((Integer)value).intValue() != 0) {
                         addAttribute(name, value.toString());

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/BorderProps.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/BorderProps.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/BorderProps.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/BorderProps.java Wed May  3 00:21:02 2006
@@ -18,14 +18,14 @@
  
 package org.apache.fop.traits;
 
-import org.apache.fop.area.Trait;
-import org.apache.fop.datatypes.ColorType;
-import org.apache.fop.fo.Constants;
-import org.apache.fop.fonts.FontTriplet;
-
+import java.awt.Color;
 import java.io.Serializable;
 import java.util.StringTokenizer;
 
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.util.ColorUtil;
+
 /**
  * Border properties.
  * Class to store border trait propties for the area tree.
@@ -42,7 +42,7 @@
     /** Border style (one of EN_*) */
     public int style; // Enum for border style
     /** Border color */
-    public ColorType color;
+    public Color color;
     /** Border width */
     public int width;
     /** Border mode (one of SEPARATE, COLLAPSE_INNER and COLLAPSE_OUTER) */
@@ -55,10 +55,10 @@
      * @param color border color
      * @param mode border mode ((one of SEPARATE, COLLAPSE_INNER and COLLAPSE_OUTER)
      */
-    public BorderProps(int style, int width, ColorType color, int mode) {
+    public BorderProps(int style, int width, Color color, int mode) {
         this.style = style;
         this.width = width;
-        this.color = Trait.Color.makeSerializable(color);
+        this.color = color;
         this.mode = mode;
     }
 
@@ -69,7 +69,7 @@
      * @param color border color
      * @param mode border mode ((one of SEPARATE, COLLAPSE_INNER and COLLAPSE_OUTER)
      */
-    public BorderProps(String style, int width, ColorType color, int mode) {
+    public BorderProps(String style, int width, Color color, int mode) {
         this(getConstantForStyle(style), width, color, mode);
     }
 
@@ -172,7 +172,14 @@
                     mode = COLLAPSE_OUTER;
                 }
             }
-            return new BorderProps(style, width, Trait.Color.valueOf(color), mode);
+            Color c;
+            try {
+                c = ColorUtil.parseColorString(color);
+            } catch (PropertyException e) {
+                throw new IllegalArgumentException(e.getMessage());
+            } 
+            
+            return new BorderProps(style, width, c, mode);
         } else {
             throw new IllegalArgumentException("BorderProps must be surrounded by parentheses");
         }
@@ -184,7 +191,7 @@
         sbuf.append('(');
         sbuf.append(getStyleString());
         sbuf.append(',');
-        sbuf.append(color);
+        sbuf.append(ColorUtil.colorTOsRGBString(color));
         sbuf.append(',');
         sbuf.append(width);
         if (mode != SEPARATE) {

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorUtil.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorUtil.java?rev=399185&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorUtil.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorUtil.java Wed May  3 00:21:02 2006
@@ -0,0 +1,480 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * 
+ * Licensed 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;
+import java.util.Collections;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Generic Color helper class.
+ * <p>
+ * This class supports parsing string values into color values and creating
+ * color values for strings. It provides a list of standard color names.
+ * <p>
+ * TODO: Add support for color Profiles.
+ */
+public final class ColorUtil {
+
+    /**
+     * keeps all the predefined and parsed colors.
+     * <p>
+     * This map is used to predefine given colors, as well as speeding up
+     * parsing of already parsed colors.
+     */
+    private static Map colorMap = null;
+
+    static {
+        initializeColorMap();
+    }
+    
+    /**
+     * Private constructor since this is an utility class.
+     */
+    private ColorUtil() {
+    }
+
+    /**
+     * Creates a color from a given string.
+     * <p>
+     * This function supports a wide variety of inputs.
+     * <ul>
+     * <li>#RGB (hex 0..f)</li>
+     * <li>#RGBA (hex 0..f)</li>
+     * <li>#RRGGBB (hex 00..ff)</li>
+     * <li>#RRGGBBAA (hex 00..ff)</li>
+     * <li>rgb(r,g,b) (0..255 or 0%..100%)</li>
+     * <li>java.awt.Color[r=r,g=g,b=b] (0..255)</li>
+     * <li>system-color(colorname)</li>
+     * <li>transparent</li>
+     * <li>colorname</li>
+     * </ul>
+     * 
+     * @param value
+     *            the string to parse.
+     * @return a Color representing the string if possible
+     * @throws PropertyException
+     *             if the string is not parsable or does not follow any of the
+     *             given formats.
+     */
+    public static Color parseColorString(String value) throws PropertyException {
+        if (value == null) {
+            return null;
+        }
+
+        Color parsedColor = (Color) colorMap.get(value.toLowerCase());
+
+        if (parsedColor == null) {
+            if (value.startsWith("#")) {
+                parsedColor = parseWithHash(value);
+            } else if (value.startsWith("rgb(")) {
+                parsedColor = parseAsRGB(value);
+            } else if (value.startsWith("url(")) {
+                throw new PropertyException(
+                        "Colors starting with url( are not yet supported!");
+            } else if (value.startsWith("java.awt.Color")) {
+                parsedColor = parseAsJavaAWTColor(value);
+            } else if (value.startsWith("system-color(")) {
+                parsedColor = parseAsSystemColor(value);
+            }
+
+            if (parsedColor == null) {
+                throw new PropertyException("Unkown Color: " + value);
+            }
+            
+            colorMap.put(value, parsedColor);
+        }
+
+        // TODO: Check if this is really necessary
+        return new Color(parsedColor.getRed(), parsedColor.getGreen(),
+                parsedColor.getBlue(), parsedColor.getAlpha());
+    }
+
+    /**
+     * Tries to parse a color given with the system-color() function.
+     * 
+     * @param value
+     *            the complete line
+     * @return a color if possible
+     * @throws PropertyException
+     *             if the format is wrong.
+     */
+    private static Color parseAsSystemColor(String value)
+            throws PropertyException {
+        int poss = value.indexOf("(");
+        int pose = value.indexOf(")");
+        if (poss != -1 && pose != -1) {
+            value = value.substring(poss + 1, pose);
+        } else {
+            throw new PropertyException("Unknown color format: " + value
+                    + ". Must be system-color(x)");
+        }
+        return (Color) colorMap.get(value);
+    }
+
+    /**
+     * Tries to parse the standard java.awt.Color toString output.
+     * 
+     * @param value
+     *            the complete line
+     * @return a color if possible
+     * @throws PropertyException
+     *             if the format is wrong.
+     * @see java.awt.Color#toString()
+     */
+    private static Color parseAsJavaAWTColor(String value)
+            throws PropertyException {
+        float red = 0.0f, green = 0.0f, blue = 0.0f;
+        int poss = value.indexOf("[");
+        int pose = value.indexOf("]");
+        try {
+            if (poss != -1 && pose != -1) {
+                value = value.substring(poss + 1, pose);
+                StringTokenizer st = new StringTokenizer(value, ",");
+                if (st.hasMoreTokens()) {
+                    String str = st.nextToken().trim();
+                    red = Float.parseFloat(str.substring(2)) / 255f;
+                }
+                if (st.hasMoreTokens()) {
+                    String str = st.nextToken().trim();
+                    green = Float.parseFloat(str.substring(2)) / 255f;
+                }
+                if (st.hasMoreTokens()) {
+                    String str = st.nextToken().trim();
+                    blue = Float.parseFloat(str.substring(2)) / 255f;
+                } else {
+                    throw new NumberFormatException();
+                }
+                if ((red < 0.0 || red > 1.0) || (green < 0.0 || green > 1.0)
+                        || (blue < 0.0 || blue > 1.0)) {
+                    throw new PropertyException("Color values out of range");
+                }
+            } else {
+                throw new NullPointerException();
+            }
+        } catch (Exception e) {
+            throw new PropertyException("Unknown color format: " + value);
+        }
+        return new Color(red, green, blue);
+    }
+
+    /**
+     * Parse a color given with the rgb() function.
+     * 
+     * @param value
+     *            the complete line
+     * @return a color if possible
+     * @throws PropertyException
+     *             if the format is wrong.
+     */
+    private static Color parseAsRGB(String value) throws PropertyException {
+        Color parsedColor;
+        int poss = value.indexOf("(");
+        int pose = value.indexOf(")");
+        if (poss != -1 && pose != -1) {
+            value = value.substring(poss + 1, pose);
+            StringTokenizer st = new StringTokenizer(value, ",");
+            try {
+                float red = 0.0f, green = 0.0f, blue = 0.0f;
+                if (st.hasMoreTokens()) {
+                    String str = st.nextToken().trim();
+                    if (str.endsWith("%")) {
+                        red = Float.parseFloat(str.substring(0,
+                                str.length() - 1)) / 100.0f;
+                    } else {
+                        red = Float.parseFloat(str) / 255f;
+                    }
+                }
+                if (st.hasMoreTokens()) {
+                    String str = st.nextToken().trim();
+                    if (str.endsWith("%")) {
+                        green = Float.parseFloat(str.substring(0,
+                                str.length() - 1)) / 100.0f;
+                    } else {
+                        green = Float.parseFloat(str) / 255f;
+                    }
+                }
+                if (st.hasMoreTokens()) {
+                    String str = st.nextToken().trim();
+                    if (str.endsWith("%")) {
+                        blue = Float.parseFloat(str.substring(0,
+                                str.length() - 1)) / 100.0f;
+                    } else {
+                        blue = Float.parseFloat(str) / 255f;
+                    }
+                }
+                if ((red < 0.0 || red > 1.0) || (green < 0.0 || green > 1.0)
+                        || (blue < 0.0 || blue > 1.0)) {
+                    throw new PropertyException("Color values out of range");
+                }
+                parsedColor = new Color(red, green, blue);
+            } catch (Exception e) {
+                throw new PropertyException(
+                        "Arguments to rgb() must be [0..255] or [0%..100%]");
+            }
+        } else {
+            throw new PropertyException("Unknown color format: " + value
+                    + ". Must be rgb(r,g,b)");
+        }
+        return parsedColor;
+    }
+
+    /**
+     * parse a color given in the #.... format.
+     * 
+     * @param value
+     *            the complete line
+     * @return a color if possible
+     * @throws PropertyException
+     *             if the format is wrong.
+     */
+    private static Color parseWithHash(String value) throws PropertyException {
+        Color parsedColor = null;
+        try {
+            int len = value.length();
+            if ((len >= 4) && (len <= 5)) {
+                // note: divide by 15 so F = FF = 1 and so on
+                float red = Integer.parseInt(value.substring(1, 2), 16) / 15f;
+                float green = Integer.parseInt(value.substring(2, 3), 16) / 15f;
+                float blue = Integer.parseInt(value.substring(3, 4), 16) / 15f;
+                float alpha = 1.0f;
+                if (len == 5) {
+                    alpha = Integer.parseInt(value.substring(4), 16) / 15f;
+                }
+                parsedColor = new Color(red, green, blue, alpha);
+            } else if ((len == 7) || (len == 9)) {
+                int red = Integer.parseInt(value.substring(1, 3), 16);
+                int green = Integer.parseInt(value.substring(3, 5), 16);
+                int blue = Integer.parseInt(value.substring(5, 7), 16);
+                int alpha = 255;
+                if (len == 9) {
+                    alpha = Integer.parseInt(value.substring(7), 16);
+                }
+                parsedColor = new Color(red, green, blue, alpha);
+            } else {
+                throw new NumberFormatException();
+            }
+        } catch (NumberFormatException e) {
+            throw new PropertyException("Unknown color format: " + value
+                    + ". Must be #RGB. #RGBA, #RRGGBB, or #RRGGBBAA");
+        }
+        return parsedColor;
+    }
+
+    /**
+     * Creates a re-parsable string representation of the given color.
+     * <p>
+     * First, the color will be converted into the sRGB colorspace. It will then
+     * be printed as #rrggbb, or as #rrrggbbaa if an alpha value is present.
+     * 
+     * @param color
+     *            the color to represent.
+     * @return a re-parsable string representadion.
+     */
+    public static String colorTOsRGBString(Color color) {
+        StringBuffer sbuf = new StringBuffer(10);
+        sbuf.append('#');
+        String s = Integer.toHexString(color.getRed());
+        if (s.length() == 1) {
+            sbuf.append('0');
+        }
+        sbuf.append(s);
+        s = Integer.toHexString(color.getGreen());
+        if (s.length() == 1) {
+            sbuf.append('0');
+        }
+        sbuf.append(s);
+        s = Integer.toHexString(color.getBlue());
+        if (s.length() == 1) {
+            sbuf.append('0');
+        }
+        sbuf.append(s);
+        if (color.getAlpha() != 255) {
+            s = Integer.toHexString(color.getAlpha());
+            if (s.length() == 1) {
+                sbuf.append('0');
+            }
+            sbuf.append(s);
+        }
+        return sbuf.toString();
+
+    }
+
+    /**
+     * Initializes the colorMap with some predefined values.
+     */
+    private static void initializeColorMap() {
+        colorMap = Collections.synchronizedMap(new java.util.HashMap());
+
+        colorMap.put("aliceblue", new Color(240, 248, 255));
+        colorMap.put("antiquewhite", new Color(250, 235, 215));
+        colorMap.put("aqua", new Color(0, 255, 255));
+        colorMap.put("aquamarine", new Color(127, 255, 212));
+        colorMap.put("azure", new Color(240, 255, 255));
+        colorMap.put("beige", new Color(245, 245, 220));
+        colorMap.put("bisque", new Color(255, 228, 196));
+        colorMap.put("black", new Color(0, 0, 0));
+        colorMap.put("blanchedalmond", new Color(255, 235, 205));
+        colorMap.put("blue", new Color(0, 0, 255));
+        colorMap.put("blueviolet", new Color(138, 43, 226));
+        colorMap.put("brown", new Color(165, 42, 42));
+        colorMap.put("burlywood", new Color(222, 184, 135));
+        colorMap.put("cadetblue", new Color(95, 158, 160));
+        colorMap.put("chartreuse", new Color(127, 255, 0));
+        colorMap.put("chocolate", new Color(210, 105, 30));
+        colorMap.put("coral", new Color(255, 127, 80));
+        colorMap.put("cornflowerblue", new Color(100, 149, 237));
+        colorMap.put("cornsilk", new Color(255, 248, 220));
+        colorMap.put("crimson", new Color(220, 20, 60));
+        colorMap.put("cyan", new Color(0, 255, 255));
+        colorMap.put("darkblue", new Color(0, 0, 139));
+        colorMap.put("darkcyan", new Color(0, 139, 139));
+        colorMap.put("darkgoldenrod", new Color(184, 134, 11));
+        colorMap.put("darkgray", new Color(169, 169, 169));
+        colorMap.put("darkgreen", new Color(0, 100, 0));
+        colorMap.put("darkgrey", new Color(169, 169, 169));
+        colorMap.put("darkkhaki", new Color(189, 183, 107));
+        colorMap.put("darkmagenta", new Color(139, 0, 139));
+        colorMap.put("darkolivegreen", new Color(85, 107, 47));
+        colorMap.put("darkorange", new Color(255, 140, 0));
+        colorMap.put("darkorchid", new Color(153, 50, 204));
+        colorMap.put("darkred", new Color(139, 0, 0));
+        colorMap.put("darksalmon", new Color(233, 150, 122));
+        colorMap.put("darkseagreen", new Color(143, 188, 143));
+        colorMap.put("darkslateblue", new Color(72, 61, 139));
+        colorMap.put("darkslategray", new Color(47, 79, 79));
+        colorMap.put("darkslategrey", new Color(47, 79, 79));
+        colorMap.put("darkturquoise", new Color(0, 206, 209));
+        colorMap.put("darkviolet", new Color(148, 0, 211));
+        colorMap.put("deeppink", new Color(255, 20, 147));
+        colorMap.put("deepskyblue", new Color(0, 191, 255));
+        colorMap.put("dimgray", new Color(105, 105, 105));
+        colorMap.put("dimgrey", new Color(105, 105, 105));
+        colorMap.put("dodgerblue", new Color(30, 144, 255));
+        colorMap.put("firebrick", new Color(178, 34, 34));
+        colorMap.put("floralwhite", new Color(255, 250, 240));
+        colorMap.put("forestgreen", new Color(34, 139, 34));
+        colorMap.put("fuchsia", new Color(255, 0, 255));
+        colorMap.put("gainsboro", new Color(220, 220, 220));
+        colorMap.put("ghostwhite", new Color(248, 248, 255));
+        colorMap.put("gold", new Color(255, 215, 0));
+        colorMap.put("goldenrod", new Color(218, 165, 32));
+        colorMap.put("gray", new Color(128, 128, 128));
+        colorMap.put("green", new Color(0, 128, 0));
+        colorMap.put("greenyellow", new Color(173, 255, 47));
+        colorMap.put("grey", new Color(128, 128, 128));
+        colorMap.put("honeydew", new Color(240, 255, 240));
+        colorMap.put("hotpink", new Color(255, 105, 180));
+        colorMap.put("indianred", new Color(205, 92, 92));
+        colorMap.put("indigo", new Color(75, 0, 130));
+        colorMap.put("ivory", new Color(255, 255, 240));
+        colorMap.put("khaki", new Color(240, 230, 140));
+        colorMap.put("lavender", new Color(230, 230, 250));
+        colorMap.put("lavenderblush", new Color(255, 240, 245));
+        colorMap.put("lawngreen", new Color(124, 252, 0));
+        colorMap.put("lemonchiffon", new Color(255, 250, 205));
+        colorMap.put("lightblue", new Color(173, 216, 230));
+        colorMap.put("lightcoral", new Color(240, 128, 128));
+        colorMap.put("lightcyan", new Color(224, 255, 255));
+        colorMap.put("lightgoldenrodyellow", new Color(250, 250, 210));
+        colorMap.put("lightgray", new Color(211, 211, 211));
+        colorMap.put("lightgreen", new Color(144, 238, 144));
+        colorMap.put("lightgrey", new Color(211, 211, 211));
+        colorMap.put("lightpink", new Color(255, 182, 193));
+        colorMap.put("lightsalmon", new Color(255, 160, 122));
+        colorMap.put("lightseagreen", new Color(32, 178, 170));
+        colorMap.put("lightskyblue", new Color(135, 206, 250));
+        colorMap.put("lightslategray", new Color(119, 136, 153));
+        colorMap.put("lightslategrey", new Color(119, 136, 153));
+        colorMap.put("lightsteelblue", new Color(176, 196, 222));
+        colorMap.put("lightyellow", new Color(255, 255, 224));
+        colorMap.put("lime", new Color(0, 255, 0));
+        colorMap.put("limegreen", new Color(50, 205, 50));
+        colorMap.put("linen", new Color(250, 240, 230));
+        colorMap.put("magenta", new Color(255, 0, 255));
+        colorMap.put("maroon", new Color(128, 0, 0));
+        colorMap.put("mediumaquamarine", new Color(102, 205, 170));
+        colorMap.put("mediumblue", new Color(0, 0, 205));
+        colorMap.put("mediumorchid", new Color(186, 85, 211));
+        colorMap.put("mediumpurple", new Color(147, 112, 219));
+        colorMap.put("mediumseagreen", new Color(60, 179, 113));
+        colorMap.put("mediumslateblue", new Color(123, 104, 238));
+        colorMap.put("mediumspringgreen", new Color(0, 250, 154));
+        colorMap.put("mediumturquoise", new Color(72, 209, 204));
+        colorMap.put("mediumvioletred", new Color(199, 21, 133));
+        colorMap.put("midnightblue", new Color(25, 25, 112));
+        colorMap.put("mintcream", new Color(245, 255, 250));
+        colorMap.put("mistyrose", new Color(255, 228, 225));
+        colorMap.put("moccasin", new Color(255, 228, 181));
+        colorMap.put("navajowhite", new Color(255, 222, 173));
+        colorMap.put("navy", new Color(0, 0, 128));
+        colorMap.put("oldlace", new Color(253, 245, 230));
+        colorMap.put("olive", new Color(128, 128, 0));
+        colorMap.put("olivedrab", new Color(107, 142, 35));
+        colorMap.put("orange", new Color(255, 165, 0));
+        colorMap.put("orangered", new Color(255, 69, 0));
+        colorMap.put("orchid", new Color(218, 112, 214));
+        colorMap.put("palegoldenrod", new Color(238, 232, 170));
+        colorMap.put("palegreen", new Color(152, 251, 152));
+        colorMap.put("paleturquoise", new Color(175, 238, 238));
+        colorMap.put("palevioletred", new Color(219, 112, 147));
+        colorMap.put("papayawhip", new Color(255, 239, 213));
+        colorMap.put("peachpuff", new Color(255, 218, 185));
+        colorMap.put("peru", new Color(205, 133, 63));
+        colorMap.put("pink", new Color(255, 192, 203));
+        colorMap.put("plum ", new Color(221, 160, 221));
+        colorMap.put("plum", new Color(221, 160, 221));
+        colorMap.put("powderblue", new Color(176, 224, 230));
+        colorMap.put("purple", new Color(128, 0, 128));
+        colorMap.put("red", new Color(255, 0, 0));
+        colorMap.put("rosybrown", new Color(188, 143, 143));
+        colorMap.put("royalblue", new Color(65, 105, 225));
+        colorMap.put("saddlebrown", new Color(139, 69, 19));
+        colorMap.put("salmon", new Color(250, 128, 114));
+        colorMap.put("sandybrown", new Color(244, 164, 96));
+        colorMap.put("seagreen", new Color(46, 139, 87));
+        colorMap.put("seashell", new Color(255, 245, 238));
+        colorMap.put("sienna", new Color(160, 82, 45));
+        colorMap.put("silver", new Color(192, 192, 192));
+        colorMap.put("skyblue", new Color(135, 206, 235));
+        colorMap.put("slateblue", new Color(106, 90, 205));
+        colorMap.put("slategray", new Color(112, 128, 144));
+        colorMap.put("slategrey", new Color(112, 128, 144));
+        colorMap.put("snow", new Color(255, 250, 250));
+        colorMap.put("springgreen", new Color(0, 255, 127));
+        colorMap.put("steelblue", new Color(70, 130, 180));
+        colorMap.put("tan", new Color(210, 180, 140));
+        colorMap.put("teal", new Color(0, 128, 128));
+        colorMap.put("thistle", new Color(216, 191, 216));
+        colorMap.put("tomato", new Color(255, 99, 71));
+        colorMap.put("turquoise", new Color(64, 224, 208));
+        colorMap.put("violet", new Color(238, 130, 238));
+        colorMap.put("wheat", new Color(245, 222, 179));
+        colorMap.put("white", new Color(255, 255, 255));
+        colorMap.put("whitesmoke", new Color(245, 245, 245));
+        colorMap.put("yellow", new Color(255, 255, 0));
+        colorMap.put("yellowgreen", new Color(154, 205, 50));
+
+        colorMap.put("transparent", new Color(0, 0, 0, 0));
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java (original)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java Wed May  3 00:21:02 2006
@@ -19,12 +19,11 @@
 package org.apache.fop.render.afp;
 
 import java.awt.Color;
-import org.apache.fop.datatypes.ColorType;
 
 /**
  * AFP only supports very basic colours and this object provides a simple
  * bean for the colour attributes.
- *
+ * @todo Is this class really necessary? Should be replaced with java.awt.Color, if possible.
  */
 public class AFPFontColor {
 
@@ -54,18 +53,6 @@
         _red = red;
         _green = green;
         _blue = blue;
-
-    }
-
-    /**
-     * Constructor for the AFPColor Object
-     * @param col the org.apache.fop.datatypes.ColorType object
-     */
-    public AFPFontColor(ColorType col) {
-
-        _red = (int)(col.getRed() * 255);
-        _green = (int)(col.getGreen() * 255);
-        _blue = (int)(col.getBlue() * 255);
 
     }
 

Modified: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java Wed May  3 00:21:02 2006
@@ -50,7 +50,6 @@
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.area.inline.WordArea;
-import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.fonts.FontInfo;
@@ -862,10 +861,10 @@
     /**
      * Draw a border segment of an XSL-FO style border.
      * @see org.apache.fop.render.AbstractRenderer#drawBorderLine(float, float, float, float,
-     *       boolean, boolean, int, ColorType)
+     *       boolean, boolean, int, Color)
      */
     public void drawBorderLine(float x1, float y1, float x2, float y2,
-            boolean horz, boolean startOrBefore, int style, ColorType col) {
+            boolean horz, boolean startOrBefore, int style, Color col) {
         float w = x2 - x1;
         float h = y2 - y1;
         if ((w < 0) || (h < 0)) {
@@ -976,10 +975,9 @@
             case Constants.EN_RIDGE:
             {
                 float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
-                Color c = toColor(col);
                 if (horz) {
-                    Color uppercol = lightenColor(c, -colFactor);
-                    Color lowercol = lightenColor(c, colFactor);
+                    Color uppercol = lightenColor(col, -colFactor);
+                    Color lowercol = lightenColor(col, colFactor);
                     float h3 = h / 3;
                     float ym1 = y1;
                     _afpDataStream.createLine(
@@ -996,7 +994,7 @@
                         pts2units(x2),
                         pts2units(ym1 + h3),
                         pts2units(h3),
-                        new AFPFontColor(c)
+                        new AFPFontColor(col)
                     );
                     _afpDataStream.createLine(
                         pts2units(x1),
@@ -1007,8 +1005,8 @@
                         new AFPFontColor(lowercol)
                     );
                 } else {
-                    Color leftcol = lightenColor(c, -colFactor);
-                    Color rightcol = lightenColor(c, colFactor);
+                    Color leftcol = lightenColor(col, -colFactor);
+                    Color rightcol = lightenColor(col, colFactor);
                     float w3 = w / 3;
                     float xm1 = x1 + (w3 / 2);
                     _afpDataStream.createLine(
@@ -1025,7 +1023,7 @@
                         pts2units(xm1 + w3),
                         pts2units(y2),
                         pts2units(w3),
-                        new AFPFontColor(c)
+                        new AFPFontColor(col)
                     );
                     _afpDataStream.createLine(
                         pts2units(xm1 + w3 + w3),
@@ -1192,9 +1190,9 @@
 
     /**
      * Establishes a new foreground or fill color.
-     * @see org.apache.fop.render.AbstractRenderer#updateColor(ColorType, boolean)
+     * @see org.apache.fop.render.AbstractRenderer#updateColor(Color, boolean)
      */
-    public void updateColor(ColorType col, boolean fill) {
+    public void updateColor(Color col, boolean fill) {
         if (fill) {
             _currentColor = new AFPFontColor(col);
         }
@@ -1255,7 +1253,7 @@
         AFPFont tf = (AFPFont) fontInfo.getFonts().get(name);
         _currentFontFamily = name;
 
-        ColorType ct = (ColorType) ch.getTrait(Trait.COLOR);
+        Color col = (Color) ch.getTrait(Trait.COLOR);
 
         int vsci = mpts2units(tf.getWidth(' ', _currentFontSize) / 1000
                                 + ch.getTextWordSpaceAdjust()
@@ -1309,7 +1307,7 @@
                 afpFontAttributes.getFontReference(),
                 mpts2units(rx),
                 mpts2units(bl),
-                new AFPFontColor(ct),
+                new AFPFontColor(col),
                 vsci,
                 mpts2units(ch.getTextLetterSpaceAdjust()),
                 worddata.getBytes(encoding));
@@ -1338,7 +1336,7 @@
         _currentFontSize = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue();
         AFPFont tf = (AFPFont) fontInfo.getFonts().get(name);
 
-        ColorType ct = (ColorType) text.getTrait(Trait.COLOR);
+        Color col = (Color) text.getTrait(Trait.COLOR);
 
         int vsci = mpts2units(tf.getWidth(' ', _currentFontSize) / 1000
                                 + text.getTextWordSpaceAdjust()
@@ -1392,7 +1390,7 @@
                 afpFontAttributes.getFontReference(),
                 mpts2units(rx),
                 mpts2units(bl),
-                new AFPFontColor(ct),
+                new AFPFontColor(col),
                 vsci,
                 mpts2units(text.getTextLetterSpaceAdjust()),
                 worddata.getBytes(encoding));
@@ -1452,7 +1450,7 @@
         float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
                         + area.getIPD()) / 1000f;
         float ruleThickness = area.getRuleThickness() / 1000f;
-        ColorType col = (ColorType)area.getTrait(Trait.COLOR);
+        Color col = (Color)area.getTrait(Trait.COLOR);
 
         switch (style) {
             case EN_SOLID:

Modified: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java Wed May  3 00:21:02 2006
@@ -19,6 +19,7 @@
 package org.apache.fop.render.pcl;
 
 //Java
+import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
@@ -58,7 +59,6 @@
 import org.apache.fop.area.CTM;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.area.Trait;
-import org.apache.fop.area.Trait.Color;
 import org.apache.fop.area.inline.AbstractTextArea;
 import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.area.inline.Image;
@@ -68,7 +68,6 @@
 import org.apache.fop.area.inline.WordArea;
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.image.EPSImage;
 import org.apache.fop.image.FopImage;
 import org.apache.fop.image.ImageFactory;
@@ -410,7 +409,7 @@
             if (col != null) {
                 //useColor(ct);
                 gen.setPatternTransparencyMode(false);
-                gen.selectCurrentPattern(gen.convertToPCLShade(col.getAWTColor()), 2);
+                gen.selectCurrentPattern(gen.convertToPCLShade(col), 2);
             }
             
             saveGraphicsState();
@@ -897,7 +896,7 @@
                 }
         
                 if (back.getColor() != null) {
-                    updateFillColor(back.getColor().getAWTColor());
+                    updateFillColor(back.getColor());
                     fillRect(sx, sy, paddRectWidth, paddRectHeight);
                 }
         
@@ -997,26 +996,26 @@
         float height = borderRect.height;
         if (bpsBefore != null) {
             int borderWidth = (int) Math.round((bpsBefore.width / 1000f));
-            updateFillColor(bpsBefore.color.getAWTColor());
+            updateFillColor(bpsBefore.color);
             fillRect((int) startx, (int) starty, (int) width,
                     borderWidth);
         }
         if (bpsAfter != null) {
             int borderWidth = (int) Math.round((bpsAfter.width / 1000f));
-            updateFillColor(bpsAfter.color.getAWTColor());
+            updateFillColor(bpsAfter.color);
             fillRect((int) startx,
                     (int) (starty + height - borderWidth), (int) width,
                     borderWidth);
         }
         if (bpsStart != null) {
             int borderWidth = (int) Math.round((bpsStart.width / 1000f));
-            updateFillColor(bpsStart.color.getAWTColor());
+            updateFillColor(bpsStart.color);
             fillRect((int) startx, (int) starty, borderWidth,
                     (int) height);
         }
         if (bpsEnd != null) {
             int borderWidth = (int) Math.round((bpsEnd.width / 1000f));
-            updateFillColor(bpsEnd.color.getAWTColor());
+            updateFillColor(bpsEnd.color);
             fillRect((int) (startx + width - borderWidth),
                     (int) starty, borderWidth, (int) height);
         }
@@ -1126,7 +1125,7 @@
                     Rectangle2D.Float lineRect = new Rectangle2D.Float(
                             sx1a, outery, ex1a - sx1a, innery - outery);
                     Java2DRenderer.drawBorderLine(lineRect, true, true, 
-                            bpsBefore.style, toColor(bpsBefore.color), g);
+                            bpsBefore.style, bpsBefore.color, g);
                     //restoreGraphicsState();
                 }
                 if (bpsEnd != null) {
@@ -1165,7 +1164,7 @@
                     Rectangle2D.Float lineRect = new Rectangle2D.Float(
                             innerx, sy1a, outerx - innerx, ey1a - sy1a);
                     Java2DRenderer.drawBorderLine(lineRect, false, false, 
-                            bpsEnd.style, toColor(bpsEnd.color), g);
+                            bpsEnd.style, bpsEnd.color, g);
                     //restoreGraphicsState();
                 }
                 if (bpsAfter != null) {
@@ -1204,7 +1203,7 @@
                     Rectangle2D.Float lineRect = new Rectangle2D.Float(
                             sx1a, innery, ex1a - sx1a, outery - innery);
                     Java2DRenderer.drawBorderLine(lineRect, true, false, 
-                            bpsAfter.style, toColor(bpsAfter.color), g);
+                            bpsAfter.style, bpsAfter.color, g);
                     //restoreGraphicsState();
                 }
                 if (bpsStart != null) {
@@ -1243,7 +1242,7 @@
                     Rectangle2D.Float lineRect = new Rectangle2D.Float(
                             outerx, sy1a, innerx - outerx, ey1a - sy1a);
                     Java2DRenderer.drawBorderLine(lineRect, false, false, 
-                            bpsStart.style, toColor(bpsStart.color), g);
+                            bpsStart.style, bpsStart.color, g);
                     //restoreGraphicsState();
                 }
             }

Modified: xmlgraphics/fop/trunk/test/fotree/testcases/properties_omitted_propertyname.fo
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/fotree/testcases/properties_omitted_propertyname.fo?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/fotree/testcases/properties_omitted_propertyname.fo (original)
+++ xmlgraphics/fop/trunk/test/fotree/testcases/properties_omitted_propertyname.fo Wed May  3 00:21:02 2006
@@ -53,8 +53,8 @@
       <fo:block background-color="#0000ff">
         Top Level Block: font-size="24pt" background-color="#0000ff"
         <fo:block>
-          <test:assert property="background-color" expected="#000000"/>
-          Nested Block: background-color=default
+          <test:assert property="background-color" expected="#00000000"/>
+          Nested Block: background-color=default (transparent)
           <fo:block background-color="from-nearest-specified-value()">
             <test:assert property="background-color" expected="#0000ff"/>
             Nested Block: background-color="from-nearest-specified-value()"

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/BorderPropsTestCase.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/BorderPropsTestCase.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/BorderPropsTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/BorderPropsTestCase.java Wed May  3 00:21:02 2006
@@ -18,11 +18,13 @@
 
 package org.apache.fop.traits;
 
-import org.apache.fop.area.Trait;
-import org.apache.fop.fo.Constants;
+import java.awt.Color;
 
 import junit.framework.TestCase;
 
+import org.apache.fop.fo.Constants;
+import org.apache.fop.util.ColorUtil;
+
 /**
  * Tests the BorderProps class.
  */
@@ -33,9 +35,9 @@
      * @throws Exception if an error occurs
      */
     public void testSerialization() throws Exception {
-        Trait.Color col = new Trait.Color(1.0f, 1.0f, 0.5f, 1.0f);
+        Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f);
         //Normalize: Avoid false alarms due to color conversion (rounding)
-        col = Trait.Color.valueOf(col.toString());
+        col = ColorUtil.parseColorString(ColorUtil.colorTOsRGBString(col));
         
         BorderProps b1 = new BorderProps(Constants.EN_DOUBLE, 1250, 
                 col, BorderProps.COLLAPSE_OUTER);

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/TraitColorTestCase.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/TraitColorTestCase.java?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/TraitColorTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/TraitColorTestCase.java Wed May  3 00:21:02 2006
@@ -18,12 +18,15 @@
 
 package org.apache.fop.traits;
 
-import org.apache.fop.area.Trait;
+import java.awt.Color;
 
 import junit.framework.TestCase;
 
+import org.apache.fop.util.ColorUtil;
+
 /**
  * Tests the Trait.Color class.
+ * TODO: This actually tests the ColorUtil class now.
  */
 public class TraitColorTestCase extends TestCase {
 
@@ -32,12 +35,15 @@
      * @throws Exception if an error occurs
      */
     public void testSerialization() throws Exception {
-        Trait.Color col = new Trait.Color(1.0f, 1.0f, 0.5f, 1.0f);
-        String s = col.toString();
-        assertEquals("#ffff7f", s);
+        Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f);
+        String s = ColorUtil.colorTOsRGBString(col);
+        
+        //This is what the old color spit out. Now it is 80 due to rounding 
+        //assertEquals("#ffff7f", s);
+        assertEquals("#ffff80", s);
         
-        col = new Trait.Color(1.0f, 0.0f, 0.0f, 0.8f);
-        s = col.toString();
+        col = new Color(1.0f, 0.0f, 0.0f, 0.8f);
+        s = ColorUtil.colorTOsRGBString(col);
         assertEquals("#ff0000cc", s);
     }
     
@@ -46,19 +52,17 @@
      * @throws Exception if an error occurs
      */
     public void testDeserialization() throws Exception {
-        float tolerance = 0.5f / 255; //due to color value conversion
-
-        Trait.Color col = Trait.Color.valueOf("#ffff7f");
-        assertEquals(1.0f, col.getRed(), 0.0f);
-        assertEquals(1.0f, col.getGreen(), 0.0f);
-        assertEquals(0.5f, col.getBlue(), tolerance);
-        assertEquals(1.0f, col.getAlpha(), 0.0f);
+        Color col = ColorUtil.parseColorString("#ffff7f");
+        assertEquals(255, col.getRed());
+        assertEquals(255, col.getGreen());
+        assertEquals(127, col.getBlue());
+        assertEquals(255, col.getAlpha());
 
-        col = Trait.Color.valueOf("#ff0000cc");
-        assertEquals(1.0f, col.getRed(), 0.0f);
-        assertEquals(0.0f, col.getGreen(), 0.0f);
-        assertEquals(0.0f, col.getBlue(), 0.0f);
-        assertEquals(0.8f, col.getAlpha(), tolerance);
+        col = ColorUtil.parseColorString("#ff0000cc");
+        assertEquals(255, col.getRed());
+        assertEquals(0, col.getGreen());
+        assertEquals(0, col.getBlue());
+        assertEquals(204, col.getAlpha());
     }
     
     /**
@@ -66,8 +70,8 @@
      * @throws Exception if an error occurs
      */
     public void testEquals() throws Exception {
-        Trait.Color col1 = Trait.Color.valueOf("#ff0000cc");
-        Trait.Color col2 = Trait.Color.valueOf("#ff0000cc");
+        Color col1 = ColorUtil.parseColorString("#ff0000cc");
+        Color col2 = ColorUtil.parseColorString("#ff0000cc");
         assertTrue(col1 != col2);
         assertEquals(col1, col2);
     }

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/region-body_background-image.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/region-body_background-image.xml?rev=399185&r1=399184&r2=399185&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/region-body_background-image.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/region-body_background-image.xml Wed May  3 00:21:02 2006
@@ -44,8 +44,8 @@
     </fo:root>
   </fo>
   <checks>
-    <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=136960,vertical=136960" xpath="//regionViewport/@background"/>
-    <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=56960" xpath="//flow/block[1]/@background"/>
-    <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=-8640" xpath="//flow/block[1]/block[1]/block[1]/@background"/>
+    <eval expected="url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=136960,vertical=136960" xpath="//regionViewport/@background"/>
+    <eval expected="url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=56960" xpath="//flow/block[1]/@background"/>
+    <eval expected="url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=-8640" xpath="//flow/block[1]/block[1]/block[1]/@background"/>
   </checks>
 </testcase>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org