Index: src/java/org/apache/fop/area/Area.java =================================================================== --- src/java/org/apache/fop/area/Area.java (revision 386180) +++ src/java/org/apache/fop/area/Area.java (working copy) @@ -25,7 +25,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.traits.BorderProps; // If the area appears more than once in the output @@ -391,11 +390,7 @@ if (props == null) { props = new java.util.HashMap(20); } - if (prop instanceof ColorType) { - props.put(traitCode, Trait.Color.makeSerializable((ColorType)prop)); - } else { - props.put(traitCode, prop); - } + props.put(traitCode, prop); } /** Index: src/java/org/apache/fop/area/AreaTreeParser.java =================================================================== --- src/java/org/apache/fop/area/AreaTreeParser.java (revision 386180) +++ src/java/org/apache/fop/area/AreaTreeParser.java (working copy) @@ -18,6 +18,7 @@ package org.apache.fop.area; +import java.awt.Color; import java.awt.geom.Rectangle2D; import java.util.Map; import java.util.Stack; @@ -34,10 +35,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.fop.apps.FOUserAgent; import org.apache.fop.area.Trait.Background; -import org.apache.fop.area.Trait.Color; import org.apache.fop.area.inline.AbstractTextArea; import org.apache.fop.area.inline.Character; import org.apache.fop.area.inline.ForeignObject; @@ -52,16 +51,17 @@ import org.apache.fop.area.inline.WordArea; import org.apache.fop.fo.Constants; import org.apache.fop.fo.ElementMappingRegistry; +import org.apache.fop.fo.expr.PropertyException; import org.apache.fop.fo.extensions.ExtensionAttachment; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.image.FopImage; import org.apache.fop.image.ImageFactory; import org.apache.fop.traits.BorderProps; +import org.apache.fop.util.ColorUtil; import org.apache.fop.util.ContentHandlerFactory; import org.apache.fop.util.ContentHandlerFactoryRegistry; import org.apache.fop.util.DefaultErrorListener; - import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.xml.sax.Attributes; @@ -903,18 +903,26 @@ } else if (cl == Color.class) { //String value = attributes.getValue(Trait.getTraitName(trait)); //if (value != null) { - area.addTrait(trait, Color.valueOf(value)); + try { + area.addTrait(trait, ColorUtil.parseColorString(value)); + } catch (PropertyException e) { + log.error(e.getMessage()); + } //} } else if (cl == Background.class) { //String value = attributes.getValue(Trait.getTraitName(trait)); //if (value != null) { - Background bkg = new Background(); - Color col = Color.valueOf(attributes.getValue("bkg-color")); - if (col != null) { - bkg.setColor(col); - } - String url = attributes.getValue("bkg-img"); - if (url != null) { + Background bkg = new Background(); + try { + Color col = ColorUtil + .parseColorString(attributes + .getValue("bkg-color")); + bkg.setColor(col); + } catch (PropertyException e) { + log.error(e.getMessage()); + } + String url = attributes.getValue("bkg-img"); + if (url != null) { bkg.setURL(url); ImageFactory fact = ImageFactory.getInstance(); Index: src/java/org/apache/fop/area/Trait.java =================================================================== --- src/java/org/apache/fop/area/Trait.java (revision 386180) +++ src/java/org/apache/fop/area/Trait.java (working copy) @@ -18,14 +18,15 @@ package org.apache.fop.area; -import org.apache.fop.datatypes.ColorType; +import java.awt.Color; +import java.io.Serializable; + import org.apache.fop.fo.Constants; import org.apache.fop.fonts.FontTriplet; import org.apache.fop.image.FopImage; import org.apache.fop.traits.BorderProps; +import org.apache.fop.util.ColorUtil; -import java.io.Serializable; - // properties should be serialized by the holder /** * Area traits used for rendering. @@ -61,7 +62,7 @@ public static final Integer FONT_SIZE = new Integer(4); /** - * The current colour. + * The current color. */ public static final Integer COLOR = new Integer(7); @@ -409,154 +410,6 @@ return null; }*/ - /** - * Serializable ColorType implementation for the area tree. - * @TODO Think about switching to java.awt.Color entirely! - */ - public static class Color implements ColorType, Serializable { - - private float red; - private float green; - private float blue; - private float alpha; - - /** - * Creates a new Color instance - * @param r the red component - * @param g the green component - * @param b the blue component - * @param a the alpha component - */ - public Color(float r, float g, float b, float a) { - this.red = r; - this.green = g; - this.blue = b; - this.alpha = a; - } - - /** - * Copy constructor - * @param col the ColorType instance which shall be duplicated - */ - public Color(ColorType col) { - this(col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha()); - } - - /** @see org.apache.fop.datatypes.ColorType#getRed() */ - public float getRed() { - return this.red; - } - - /** @see org.apache.fop.datatypes.ColorType#getGreen() */ - public float getGreen() { - return this.green; - } - - /** @see org.apache.fop.datatypes.ColorType#getBlue() */ - public float getBlue() { - return this.blue; - } - - /** @see org.apache.fop.datatypes.ColorType#getAlpha() */ - public float getAlpha() { - return this.alpha; - } - - /** @see org.apache.fop.datatypes.ColorType#getAWTColor() */ - public java.awt.Color getAWTColor() { - return new java.awt.Color(red, green, blue, alpha); - } - - /** - * Converts a given color to a serializable instance if necessary. - * @param col the color - * @return the serializable color value. - */ - public static ColorType makeSerializable(ColorType col) { - if (col == null) { - return null; - } else if (col instanceof Serializable) { - return col; - } else { - return new Color(col); - } - } - - /** @see java.lang.Object#hashCode() */ - public int hashCode() { - return toString().hashCode(); - } - - /** @see java.lang.Object#equals(java.lang.Object) */ - public boolean equals(Object obj) { - if (obj == null) { - return false; - } else if (obj == this) { - return true; - } else { - if (obj instanceof ColorType) { - ColorType other = (ColorType)obj; - return getRed() == other.getRed() - && getGreen() == other.getGreen() - && getBlue() == other.getBlue() - && getAlpha() == other.getAlpha(); - } - } - return false; - } - - /** - * Returns a Color represtation of a string of the format "#RRGGBB". - * @param s the string - * @return the Color value - */ - public static Color valueOf(String s) { - if (s == null) { - return null; - } - if (!s.startsWith("#")) { - throw new IllegalArgumentException("Color must start with '#'"); - } - int r = Integer.parseInt(s.substring(1, 3), 16); - int g = Integer.parseInt(s.substring(3, 5), 16); - int b = Integer.parseInt(s.substring(5, 7), 16); - int a = 255; - if (s.length() > 7) { - a = Integer.parseInt(s.substring(7, 9), 16); - } - return new Color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); - } - - /** @see java.lang.Object#toString() */ - public String toString() { - StringBuffer sbuf = new StringBuffer(8); - sbuf.append('#'); - String s = Integer.toHexString((int)(red * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - s = Integer.toHexString((int)(green * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - s = Integer.toHexString((int)(blue * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - if (alpha != 1) { - s = Integer.toHexString((int)(alpha * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - } - return sbuf.toString(); - } - - } /** * Background trait structure. @@ -565,7 +418,7 @@ public static class Background implements Serializable { /** The background color if any. */ - private ColorType color = null; + private Color color = null; /** The background image url if any. */ private String url = null; @@ -586,7 +439,7 @@ * Returns the background color. * @return background color, null if n/a */ - public ColorType getColor() { + public Color getColor() { return color; } @@ -634,8 +487,8 @@ * Sets the color. * @param color The color to set */ - public void setColor(ColorType color) { - this.color = Color.makeSerializable(color); + public void setColor(Color color) { + this.color = color; } /** @@ -716,9 +569,12 @@ */ public String toString() { StringBuffer sb = new StringBuffer(); - sb.append("color=").append(color); + if (color!=null) + sb.append("color=").append(ColorUtil.colorTOsRGBString(color)); if (url != null) { - sb.append(",url=").append(url); + if (color!=null) + sb.append(","); + sb.append("url=").append(url); sb.append(",repeat=").append(getRepeatString()); sb.append(",horiz=").append(horiz); sb.append(",vertical=").append(vertical); Index: src/java/org/apache/fop/datatypes/ColorType.java =================================================================== --- src/java/org/apache/fop/datatypes/ColorType.java (revision 386180) +++ src/java/org/apache/fop/datatypes/ColorType.java (working copy) @@ -1,57 +0,0 @@ -/* - * Copyright 1999-2004 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.datatypes; - -import java.awt.Color; - -/** - * A colour quantity in XSL. - */ -public interface ColorType { - - /** - * Returns the blue component of the color. - * @return float a value between 0.0 and 1.0 - */ - float getBlue(); - - /** - * Returns the green component of the color. - * @return float a value between 0.0 and 1.0 - */ - float getGreen(); - - /** - * Returns the red component of the color. - * @return float a value between 0.0 and 1.0 - */ - float getRed(); - - /** - * Returns the alpha (degree of opaque-ness) component of the color. - * @return float a value between 0.0 (fully transparent) and 1.0 (fully opaque) - */ - float getAlpha(); - - /** - * Returns an AWT instance of this color - * @return float the AWT color represented by this ColorType instance - */ - Color getAWTColor(); -} Index: src/java/org/apache/fop/fo/expr/NCnameProperty.java =================================================================== --- src/java/org/apache/fop/fo/expr/NCnameProperty.java (revision 386193) +++ src/java/org/apache/fop/fo/expr/NCnameProperty.java (working copy) @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 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,8 +18,10 @@ package org.apache.fop.fo.expr; +import java.awt.Color; + import org.apache.fop.fo.properties.Property; -import org.apache.fop.datatypes.ColorType; +import org.apache.fop.util.ColorUtil; /** * Class for handling NC Name objects @@ -37,13 +39,17 @@ } /** - * If a system color, return the corresponding value (appears to be - * unimplemented) - * @return ColorType object corresponding to the NCName - * @throws PropertyException in all cases currently + * If a system color, return the corresponding value. + * + * @return Color object corresponding to the NCName */ - public ColorType getColor() throws PropertyException { - throw new PropertyException("Not a Color"); + public Color getColor() { + try { + return ColorUtil.parseColorString(ncName); + } catch (PropertyException e) { + //TODO: This should probably print an error message? + return null; + } } /** Index: src/java/org/apache/fop/fo/expr/NumericProperty.java =================================================================== --- src/java/org/apache/fop/fo/expr/NumericProperty.java (revision 386193) +++ src/java/org/apache/fop/fo/expr/NumericProperty.java (working copy) @@ -18,10 +18,10 @@ package org.apache.fop.fo.expr; +import java.awt.Color; import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.Numeric; -import org.apache.fop.fo.properties.ColorTypeProperty; import org.apache.fop.fo.properties.Property; /** @@ -118,8 +118,8 @@ /** * Cast this as a ColorTypeProperty. */ - public ColorTypeProperty getColorType() { - // try converting to numeric number and then to color + public Color getColor() { + // TODO: try converting to numeric number and then to color return null; } Index: src/java/org/apache/fop/fo/expr/PropertyParser.java =================================================================== --- src/java/org/apache/fop/fo/expr/PropertyParser.java (revision 386193) +++ src/java/org/apache/fop/fo/expr/PropertyParser.java (working copy) @@ -20,7 +20,7 @@ import org.apache.fop.datatypes.Numeric; import org.apache.fop.datatypes.PercentBase; -import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.ColorProperty; import org.apache.fop.fo.properties.FixedLength; import org.apache.fop.fo.properties.ListProperty; import org.apache.fop.fo.properties.NumberProperty; @@ -296,7 +296,7 @@ break; case TOK_COLORSPEC: - prop = new ColorTypeProperty(currentTokenValue); + prop = new ColorProperty(currentTokenValue); break; case TOK_FUNCTION_LPAR: Index: src/java/org/apache/fop/fo/expr/RGBColorFunction.java =================================================================== --- src/java/org/apache/fop/fo/expr/RGBColorFunction.java (revision 386193) +++ src/java/org/apache/fop/fo/expr/RGBColorFunction.java (working copy) @@ -20,7 +20,7 @@ import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.PercentBase; -import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.ColorProperty; import org.apache.fop.fo.properties.Property; /** @@ -45,7 +45,7 @@ /** @see org.apache.fop.fo.expr.Function */ public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { - return new ColorTypeProperty("rgb(" + args[0] + "," + args[1] + "," + args[2] + ")"); + return new ColorProperty("rgb(" + args[0] + "," + args[1] + "," + args[2] + ")"); } Index: src/java/org/apache/fop/fo/expr/SystemColorFunction.java =================================================================== --- src/java/org/apache/fop/fo/expr/SystemColorFunction.java (revision 386193) +++ src/java/org/apache/fop/fo/expr/SystemColorFunction.java (working copy) @@ -18,7 +18,7 @@ package org.apache.fop.fo.expr; -import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.ColorProperty; import org.apache.fop.fo.properties.Property; /** @@ -34,7 +34,7 @@ /** @see org.apache.fop.fo.expr.Function */ public Property eval(Property[] args, PropertyInfo pInfo) throws PropertyException { - return new ColorTypeProperty("system-color(" + args[0] + ")"); + return new ColorProperty("system-color(" + args[0] + ")"); } Index: src/java/org/apache/fop/fo/flow/BidiOverride.java =================================================================== --- src/java/org/apache/fop/fo/flow/BidiOverride.java (revision 386193) +++ src/java/org/apache/fop/fo/flow/BidiOverride.java (working copy) @@ -18,18 +18,18 @@ package org.apache.fop.fo.flow; -import org.xml.sax.Locator; +import java.awt.Color; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; -import org.apache.fop.fo.properties.ColorTypeProperty; import org.apache.fop.fo.properties.CommonAural; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fo.properties.SpaceProperty; +import org.xml.sax.Locator; /** * fo:bidi-override element. @@ -44,7 +44,7 @@ private CommonAural commonAural; private CommonFont commonFont; private CommonRelativePosition commonRelativePosition; - private ColorTypeProperty prColor; + private Color prColor; // private ToBeImplementedProperty prDirection; // private ToBeImplementedProperty prLetterSpacing; private SpaceProperty lineHeight; @@ -86,7 +86,7 @@ commonAural = pList.getAuralProps(); commonFont = pList.getFontProps(); commonRelativePosition = pList.getRelativePositionProps(); - prColor = pList.get(PR_COLOR).getColorType(); + prColor = pList.get(PR_COLOR).getColor(); // prDirection = pList.get(PR_DIRECTION); // prLetterSpacing = pList.get(PR_LETTER_SPACING); lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); Index: src/java/org/apache/fop/fo/flow/Block.java =================================================================== --- src/java/org/apache/fop/fo/flow/Block.java (revision 386193) +++ src/java/org/apache/fop/fo/flow/Block.java (working copy) @@ -14,14 +14,13 @@ * limitations under the License. */ -/* $Id: Block.java,v 1.14 2004/04/02 13:50:52 cbowditch Exp $ */ +/* $Id$ */ package org.apache.fop.fo.flow; -import org.xml.sax.Locator; +import java.awt.Color; import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.Numeric; import org.apache.fop.fo.CharIterator; @@ -39,6 +38,7 @@ import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.SpaceProperty; +import org.xml.sax.Locator; /* Modified by Mark Lillywhite mark-fop@inomial.com. The changes @@ -73,7 +73,7 @@ private CommonRelativePosition commonRelativePosition; private int breakAfter; private int breakBefore; - private ColorType color; + private Color color; private Length textDepth; private Length textAltitude; private int hyphenationKeep; @@ -125,7 +125,7 @@ breakAfter = pList.get(PR_BREAK_AFTER).getEnum(); breakBefore = pList.get(PR_BREAK_BEFORE).getEnum(); - color = pList.get(PR_COLOR).getColorType(); + color = pList.get(PR_COLOR).getColor(); textDepth = pList.get(PR_TEXT_DEPTH).getLength(); textAltitude = pList.get(PR_TEXT_ALTITUDE).getLength(); hyphenationKeep = pList.get(PR_HYPHENATION_KEEP).getEnum(); @@ -244,7 +244,7 @@ /** * @return the "color" property. */ - public ColorType getColor() { + public Color getColor() { return color; } Index: src/java/org/apache/fop/fo/flow/Character.java =================================================================== --- src/java/org/apache/fop/fo/flow/Character.java (revision 386193) +++ src/java/org/apache/fop/fo/flow/Character.java (working copy) @@ -18,8 +18,10 @@ package org.apache.fop.fo.flow; +import java.awt.Color; +import java.util.NoSuchElementException; + import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.CharIterator; import org.apache.fop.fo.FONode; @@ -37,11 +39,8 @@ import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.SpaceProperty; import org.apache.fop.util.CharUtilities; - import org.xml.sax.Locator; -import java.util.NoSuchElementException; - /** * This class represents the flow object 'fo:character'. Its use is defined by * the spec: "The fo:character flow object represents a character that is mapped to @@ -68,7 +67,7 @@ private int alignmentBaseline; private Length baselineShift; private char character; - private ColorType color; + private Color color; private int dominantBaseline; private Length textDepth; private Length textAltitude; @@ -117,7 +116,7 @@ alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); character = pList.get(PR_CHARACTER).getCharacter(); - color = pList.get(PR_COLOR).getColorType(); + color = pList.get(PR_COLOR).getColor(); dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); textDepth = pList.get(PR_TEXT_DEPTH).getLength(); textAltitude = pList.get(PR_TEXT_ALTITUDE).getLength(); @@ -192,7 +191,7 @@ /** * @return the "color" property. */ - public ColorType getColor() { + public Color getColor() { return color; } Index: src/java/org/apache/fop/fo/flow/InitialPropertySet.java =================================================================== --- src/java/org/apache/fop/fo/flow/InitialPropertySet.java (revision 386193) +++ src/java/org/apache/fop/fo/flow/InitialPropertySet.java (working copy) @@ -19,21 +19,20 @@ package org.apache.fop.fo.flow; // XML -import org.xml.sax.Locator; +import java.awt.Color; import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; -import org.apache.fop.fo.properties.ColorTypeProperty; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAural; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fo.properties.SpaceProperty; +import org.xml.sax.Locator; /** * Class modelling the fo:initial-property-set object. @@ -45,7 +44,7 @@ private CommonBorderPaddingBackground commonBorderPaddingBackground; private CommonFont commonFont; private CommonRelativePosition commonRelativePosition; - private ColorTypeProperty color; + private Color color; private String id; // private ToBeImplementedProperty letterSpacing; private SpaceProperty lineHeight; @@ -72,7 +71,7 @@ commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); commonFont = pList.getFontProps(); commonRelativePosition = pList.getRelativePositionProps(); - color = pList.get(PR_COLOR).getColorType(); + color = pList.get(PR_COLOR).getColor(); id = pList.get(PR_ID).getString(); // letterSpacing = pList.get(PR_LETTER_SPACING); lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); Index: src/java/org/apache/fop/fo/flow/InlineLevel.java =================================================================== --- src/java/org/apache/fop/fo/flow/InlineLevel.java (revision 386193) +++ src/java/org/apache/fop/fo/flow/InlineLevel.java (working copy) @@ -18,9 +18,9 @@ package org.apache.fop.fo.flow; +import java.awt.Color; + import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.ColorType; -import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.PropertyList; @@ -43,7 +43,7 @@ protected CommonMarginInline commonMarginInline; protected CommonAural commonAural; protected CommonFont commonFont; - protected ColorType color; + protected Color color; protected SpaceProperty lineHeight; protected int visibility; // End of property values @@ -64,7 +64,7 @@ commonMarginInline = pList.getMarginInlineProps(); commonAural = pList.getAuralProps(); commonFont = pList.getFontProps(); - color = pList.get(PR_COLOR).getColorType(); + color = pList.get(PR_COLOR).getColor(); lineHeight = pList.get(PR_LINE_HEIGHT).getSpace(); visibility = pList.get(PR_VISIBILITY).getEnum(); } @@ -93,7 +93,7 @@ /** * @return the "color" property. */ - public ColorType getColor() { + public Color getColor() { return color; } Index: src/java/org/apache/fop/fo/flow/PageNumber.java =================================================================== --- src/java/org/apache/fop/fo/flow/PageNumber.java (revision 386193) +++ src/java/org/apache/fop/fo/flow/PageNumber.java (working copy) @@ -18,10 +18,9 @@ package org.apache.fop.fo.flow; -import org.xml.sax.Locator; +import java.awt.Color; 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; @@ -37,6 +36,7 @@ import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.SpaceProperty; +import org.xml.sax.Locator; /** * Class modelling the fo:page-number object. @@ -71,7 +71,7 @@ // End of property values // Properties which are not explicitely listed but are still applicable - private ColorType color; + private Color color; /** * @param parent FONode that is the parent of this object @@ -110,7 +110,7 @@ wrapOption = pList.get(PR_WRAP_OPTION).getEnum(); // implicit properties - color = pList.get(Constants.PR_COLOR).getColorType(); + color = pList.get(Constants.PR_COLOR).getColor(); } /** @@ -143,7 +143,7 @@ } /** @return the "color" property. */ - public ColorType getColor() { + public Color getColor() { return color; } Index: src/java/org/apache/fop/fo/flow/PageNumberCitation.java =================================================================== --- src/java/org/apache/fop/fo/flow/PageNumberCitation.java (revision 386193) +++ src/java/org/apache/fop/fo/flow/PageNumberCitation.java (working copy) @@ -18,10 +18,11 @@ package org.apache.fop.fo.flow; +import java.awt.Color; + import org.xml.sax.Locator; 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; @@ -75,7 +76,7 @@ // End of property values // Properties which are not explicitely listed but are still applicable - private ColorType color; + private Color color; /** * @param parent FONode that is the parent of this object @@ -115,7 +116,7 @@ wrapOption = pList.get(PR_WRAP_OPTION).getEnum(); // implicit properties - color = pList.get(Constants.PR_COLOR).getColorType(); + color = pList.get(Constants.PR_COLOR).getColor(); } /** @@ -143,7 +144,7 @@ } /** @return the "color" property. */ - public ColorType getColor() { + public Color getColor() { return color; } Index: src/java/org/apache/fop/fo/FOPropertyMapping.java =================================================================== --- src/java/org/apache/fop/fo/FOPropertyMapping.java (revision 386193) +++ src/java/org/apache/fop/fo/FOPropertyMapping.java (working copy) @@ -28,7 +28,7 @@ import org.apache.fop.fo.properties.BorderWidthPropertyMaker; import org.apache.fop.fo.properties.BoxPropShorthandParser; import org.apache.fop.fo.properties.CharacterProperty; -import org.apache.fop.fo.properties.ColorTypeProperty; +import org.apache.fop.fo.properties.ColorProperty; import org.apache.fop.fo.properties.ColumnNumberPropertyMaker; import org.apache.fop.fo.properties.CondLengthProperty; import org.apache.fop.fo.properties.CorrespondingPropertyMaker; @@ -100,154 +100,7 @@ public void createGenerics() { PropertyMaker sub; - genericColor = new ColorTypeProperty.Maker(0); - genericColor.addKeyword("aliceblue", "#f0f8ff"); - genericColor.addKeyword("antiquewhite", "#faebd7"); - genericColor.addKeyword("aqua", "#00ffff"); - genericColor.addKeyword("aquamarine", "#7fffd4"); - genericColor.addKeyword("azure", "#f0ffff"); - genericColor.addKeyword("beige", "#f5f5dc"); - genericColor.addKeyword("bisque", "#ffe4c4"); - genericColor.addKeyword("black", "#000000"); - genericColor.addKeyword("blanchedalmond", "#ffebcd"); - genericColor.addKeyword("blue", "#0000ff"); - genericColor.addKeyword("blueviolet", "#8a2be2"); - genericColor.addKeyword("brown", "#a52a2a"); - genericColor.addKeyword("burlywood", "#deb887"); - genericColor.addKeyword("cadetblue", "#5f9ea0"); - genericColor.addKeyword("chartreuse", "#7fff00"); - genericColor.addKeyword("chocolate", "#d2691e"); - genericColor.addKeyword("coral", "#ff7f50"); - genericColor.addKeyword("cornflowerblue", "#6495ed"); - genericColor.addKeyword("cornsilk", "#fff8dc"); - genericColor.addKeyword("crimson", "#dc143c"); - genericColor.addKeyword("cyan", "#00ffff"); - genericColor.addKeyword("darkblue", "#00008b"); - genericColor.addKeyword("darkcyan", "#008b8b"); - genericColor.addKeyword("darkgoldenrod", "#b8860b"); - genericColor.addKeyword("darkgray", "#a9a9a9"); - genericColor.addKeyword("darkgreen", "#006400"); - genericColor.addKeyword("darkgrey", "#a9a9a9"); - genericColor.addKeyword("darkkhaki", "#bdb76b"); - genericColor.addKeyword("darkmagenta", "#8b008b"); - genericColor.addKeyword("darkolivegreen", "#556b2f"); - genericColor.addKeyword("darkorange", "#ff8c00"); - genericColor.addKeyword("darkorchid", "#9932cc"); - genericColor.addKeyword("darkred", "#8b0000"); - genericColor.addKeyword("darksalmon", "#e9967a"); - genericColor.addKeyword("darkseagreen", "#8fbc8f"); - genericColor.addKeyword("darkslateblue", "#483d8b"); - genericColor.addKeyword("darkslategray", "#2f4f4f"); - genericColor.addKeyword("darkslategrey", "#2f4f4f"); - genericColor.addKeyword("darkturquoise", "#00ced1"); - genericColor.addKeyword("darkviolet", "#9400d3"); - genericColor.addKeyword("deeppink", "#ff1493"); - genericColor.addKeyword("deepskyblue", "#00bfff"); - genericColor.addKeyword("dimgray", "#696969"); - genericColor.addKeyword("dimgrey", "#696969"); - genericColor.addKeyword("dodgerblue", "#1e90ff"); - genericColor.addKeyword("firebrick", "#b22222"); - genericColor.addKeyword("floralwhite", "#fffaf0"); - genericColor.addKeyword("forestgreen", "#228b22"); - genericColor.addKeyword("fuchsia", "#ff00ff"); - genericColor.addKeyword("gainsboro", "#dcdcdc"); - genericColor.addKeyword("lightpink", "#ffb6c1"); - genericColor.addKeyword("lightsalmon", "#ffa07a"); - genericColor.addKeyword("lightseagreen", "#20b2aa"); - genericColor.addKeyword("lightskyblue", "#87cefa"); - genericColor.addKeyword("lightslategray", "#778899"); - genericColor.addKeyword("lightslategrey", "#778899"); - genericColor.addKeyword("lightsteelblue", "#b0c4de"); - genericColor.addKeyword("lightyellow", "#ffffe0"); - genericColor.addKeyword("lime", "#00ff00"); - genericColor.addKeyword("limegreen", "#32cd32"); - genericColor.addKeyword("linen", "#faf0e6"); - genericColor.addKeyword("magenta", "#ff00ff"); - genericColor.addKeyword("maroon", "#800000"); - genericColor.addKeyword("mediumaquamarine", "#66cdaa"); - genericColor.addKeyword("mediumblue", "#0000cd"); - genericColor.addKeyword("mediumorchid", "#ba55d3"); - genericColor.addKeyword("mediumpurple", "#9370db"); - genericColor.addKeyword("mediumseagreen", "#3cb371"); - genericColor.addKeyword("mediumslateblue", "#7b68ee"); - genericColor.addKeyword("mediumspringgreen", "#00fa9a"); - genericColor.addKeyword("mediumturquoise", "#48d1cc"); - genericColor.addKeyword("mediumvioletred", "#c71585"); - genericColor.addKeyword("midnightblue", "#191970"); - genericColor.addKeyword("mintcream", "#f5fffa"); - genericColor.addKeyword("mistyrose", "#ffe4e1"); - genericColor.addKeyword("moccasin", "#ffe4b5"); - genericColor.addKeyword("navajowhite", "#ffdead"); - genericColor.addKeyword("navy", "#000080"); - genericColor.addKeyword("oldlace", "#fdf5e6"); - genericColor.addKeyword("olive", "#808000"); - genericColor.addKeyword("olivedrab", "#6b8e23"); - genericColor.addKeyword("orange", "#ffa500"); - genericColor.addKeyword("orangered", "#ff4500"); - genericColor.addKeyword("orchid", "#da70d6"); - genericColor.addKeyword("palegoldenrod", "#eee8aa"); - genericColor.addKeyword("palegreen", "#98fb98"); - genericColor.addKeyword("paleturquoise", "#afeeee"); - genericColor.addKeyword("palevioletred", "#db7093"); - genericColor.addKeyword("papayawhip", "#ffefd5"); - genericColor.addKeyword("peachpuff", "#ffdab9"); - genericColor.addKeyword("peru", "#cd853f"); - genericColor.addKeyword("pink", "#ffc0cb"); - genericColor.addKeyword("plum", "#dda0dd"); - genericColor.addKeyword("powderblue", "#b0e0e6"); - genericColor.addKeyword("purple", "#800080"); - genericColor.addKeyword("red", "#ff0000"); - genericColor.addKeyword("rosybrown", "#bc8f8f"); - genericColor.addKeyword("royalblue", "#4169e1"); - genericColor.addKeyword("saddlebrown", "#8b4513"); - genericColor.addKeyword("salmon", "#fa8072"); - genericColor.addKeyword("ghostwhite", "#f8f8ff"); - genericColor.addKeyword("gold", "#ffd700"); - genericColor.addKeyword("goldenrod", "#daa520"); - genericColor.addKeyword("gray", "#808080"); - genericColor.addKeyword("grey", "#808080"); - genericColor.addKeyword("green", "#008000"); - genericColor.addKeyword("greenyellow", "#adff2f"); - genericColor.addKeyword("honeydew", "#f0fff0"); - genericColor.addKeyword("hotpink", "#ff69b4"); - genericColor.addKeyword("indianred", "#cd5c5c"); - genericColor.addKeyword("indigo", "#4b0082"); - genericColor.addKeyword("ivory", "#fffff0"); - genericColor.addKeyword("khaki", "#f0e68c"); - genericColor.addKeyword("lavender", "#e6e6fa"); - genericColor.addKeyword("lavenderblush", "#fff0f5"); - genericColor.addKeyword("lawngreen", "#7cfc00"); - genericColor.addKeyword("lemonchiffon", "#fffacd"); - genericColor.addKeyword("lightblue", "#add8e6"); - genericColor.addKeyword("lightcoral", "#f08080"); - genericColor.addKeyword("lightcyan", "#e0ffff"); - genericColor.addKeyword("lightgoldenrodyellow", "#fafad2"); - genericColor.addKeyword("lightgray", "#d3d3d3"); - genericColor.addKeyword("lightgreen", "#90ee90"); - genericColor.addKeyword("lightgrey", "#d3d3d3"); - genericColor.addKeyword("sandybrown", "#f4a460"); - genericColor.addKeyword("seagreen", "#2e8b57"); - genericColor.addKeyword("seashell", "#fff5ee"); - genericColor.addKeyword("sienna", "#a0522d"); - genericColor.addKeyword("silver", "#c0c0c0"); - genericColor.addKeyword("skyblue", "#87ceeb"); - genericColor.addKeyword("slateblue", "#6a5acd"); - genericColor.addKeyword("slategray", "#708090"); - genericColor.addKeyword("slategrey", "#708090"); - genericColor.addKeyword("snow", "#fffafa"); - genericColor.addKeyword("springgreen", "#00ff7f"); - genericColor.addKeyword("steelblue", "#4682b4"); - genericColor.addKeyword("tan", "#d2b48c"); - genericColor.addKeyword("teal", "#008080"); - genericColor.addKeyword("thistle", "#d8bfd8"); - genericColor.addKeyword("tomato", "#ff6347"); - genericColor.addKeyword("turquoise", "#40e0d0"); - genericColor.addKeyword("violet", "#ee82ee"); - genericColor.addKeyword("wheat", "#f5deb3"); - genericColor.addKeyword("white", "#ffffff"); - genericColor.addKeyword("whitesmoke", "#f5f5f5"); - genericColor.addKeyword("yellow", "#ffff00"); - genericColor.addKeyword("yellowgreen", "#9acd32"); + genericColor = new ColorProperty.Maker(0); // GenericBoolean genericBoolean = new EnumProperty.Maker(0); @@ -689,12 +542,12 @@ addPropertyMaker("background-attachment", m); // background-color - m = new ColorTypeProperty.Maker(PR_BACKGROUND_COLOR) { + m = new ColorProperty.Maker(PR_BACKGROUND_COLOR) { protected Property convertPropertyDatatype( Property p, PropertyList propertyList, FObj fo) throws PropertyException { String nameval = p.getNCname(); if (nameval != null) { - return new ColorTypeProperty(nameval); + return new ColorProperty(nameval); } return super.convertPropertyDatatype(p, propertyList, fo); } @@ -743,7 +596,7 @@ addPropertyMaker("background-position-vertical", m); // border-before-color - m = new ColorTypeProperty.Maker(PR_BORDER_BEFORE_COLOR); + m = new ColorProperty.Maker(PR_BORDER_BEFORE_COLOR); m.useGeneric(genericColor); m.setInherited(false); m.setDefault("black"); @@ -773,7 +626,7 @@ addPropertyMaker("border-before-width", m); // border-after-color - m = new ColorTypeProperty.Maker(PR_BORDER_AFTER_COLOR); + m = new ColorProperty.Maker(PR_BORDER_AFTER_COLOR); m.useGeneric(genericColor); m.setInherited(false); m.setDefault("black"); @@ -803,7 +656,7 @@ addPropertyMaker("border-after-width", m); // border-start-color - m = new ColorTypeProperty.Maker(PR_BORDER_START_COLOR); + m = new ColorProperty.Maker(PR_BORDER_START_COLOR); m.useGeneric(genericColor); m.setInherited(false); m.setDefault("black"); @@ -833,7 +686,7 @@ addPropertyMaker("border-start-width", m); // border-end-color - m = new ColorTypeProperty.Maker(PR_BORDER_END_COLOR); + m = new ColorProperty.Maker(PR_BORDER_END_COLOR); m.useGeneric(genericColor); m.setInherited(false); m.setDefault("black"); @@ -863,7 +716,7 @@ addPropertyMaker("border-end-width", m); // border-top-color - m = new ColorTypeProperty.Maker(PR_BORDER_TOP_COLOR); + m = new ColorProperty.Maker(PR_BORDER_TOP_COLOR); m.useGeneric(genericColor); m.setInherited(false); m.setDefault("black"); @@ -899,7 +752,7 @@ addPropertyMaker("border-top-width", bwm); // border-bottom-color - m = new ColorTypeProperty.Maker(PR_BORDER_BOTTOM_COLOR); + m = new ColorProperty.Maker(PR_BORDER_BOTTOM_COLOR); m.useGeneric(genericColor); m.setInherited(false); m.setDefault("black"); @@ -935,7 +788,7 @@ addPropertyMaker("border-bottom-width", bwm); // border-left-color - m = new ColorTypeProperty.Maker(PR_BORDER_LEFT_COLOR); + m = new ColorProperty.Maker(PR_BORDER_LEFT_COLOR); m.useGeneric(genericColor); m.setInherited(false); m.setDefault("black"); @@ -971,7 +824,7 @@ addPropertyMaker("border-left-width", bwm); // border-right-color - m = new ColorTypeProperty.Maker(PR_BORDER_RIGHT_COLOR); + m = new ColorProperty.Maker(PR_BORDER_RIGHT_COLOR); m.useGeneric(genericColor); m.setInherited(false); m.setDefault("black"); @@ -1838,7 +1691,7 @@ PropertyMaker m; // color - m = new ColorTypeProperty.Maker(PR_COLOR); + m = new ColorProperty.Maker(PR_COLOR); m.useGeneric(genericColor); m.setInherited(true); m.setDefault("black"); Index: src/java/org/apache/fop/fo/FOText.java =================================================================== --- src/java/org/apache/fop/fo/FOText.java (revision 386193) +++ src/java/org/apache/fop/fo/FOText.java (working copy) @@ -20,10 +20,10 @@ // Java import java.util.NoSuchElementException; +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.flow.Block; import org.apache.fop.fo.pagination.Root; @@ -77,7 +77,7 @@ // The value of properties relevant for character. private CommonFont commonFont; private CommonHyphenation commonHyphenation; - private ColorType color; + private Color color; private Property letterSpacing; private SpaceProperty lineHeight; private int whiteSpaceCollapse; @@ -155,7 +155,7 @@ commonFont = pList.getFontProps(); commonHyphenation = pList.getHyphenationProps(); - color = pList.get(Constants.PR_COLOR).getColorType(); + color = pList.get(Constants.PR_COLOR).getColor(); lineHeight = pList.get(Constants.PR_LINE_HEIGHT).getSpace(); letterSpacing = pList.get(Constants.PR_LETTER_SPACING); whiteSpaceCollapse = pList.get(Constants.PR_WHITE_SPACE_COLLAPSE).getEnum(); @@ -559,7 +559,7 @@ /** * @return the "color" property. */ - public ColorType getColor() { + public Color getColor() { return color; } Index: src/java/org/apache/fop/fo/pagination/ColorProfile.java =================================================================== --- src/java/org/apache/fop/fo/pagination/ColorProfile.java (revision 386193) +++ src/java/org/apache/fop/fo/pagination/ColorProfile.java (working copy) @@ -19,23 +19,23 @@ package org.apache.fop.fo.pagination; // Java +import java.awt.Color; import java.awt.color.ICC_ColorSpace; import java.awt.color.ICC_Profile; import java.io.IOException; import java.io.InputStream; import java.net.URL; -import org.xml.sax.Locator; - import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; +import org.xml.sax.Locator; /** * The fo:color-profile formatting object. + * TODO: This needs to be implemented properly! * This loads the color profile when needed and resolves a requested color. */ public class ColorProfile extends FObj { @@ -89,7 +89,7 @@ * @param defB integer value for blue channel (0-255)? * @return the ColorType object corresponding to the input */ - public ColorType getColor(int[] colorVals, int defR, int defG, int defB) { + public Color getColor(int[] colorVals, int defR, int defG, int defB) { // float[] rgbvals = colorSpace.toRGB(colorVals); // return new ColorType(rgbvals); return null; Index: src/java/org/apache/fop/fo/properties/ColorProperty.java =================================================================== --- src/java/org/apache/fop/fo/properties/ColorProperty.java (revision 0) +++ src/java/org/apache/fop/fo/properties/ColorProperty.java (revision 0) @@ -0,0 +1,136 @@ +/* + * 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. + * 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: ColorTypeProperty.java 377045 2006-02-11 20:23:47Z jeremias $ */ + +package org.apache.fop.fo.properties; + +import java.awt.Color; + +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.util.ColorUtil; + +/** + * Superclass for properties that wrap Color values + */ +public class ColorProperty extends Property { + + /** + * The color represented by this property. + */ + protected final Color color; + + + /** + * Inner class for creating instances of ColorTypeProperty + */ + public static class Maker extends PropertyMaker { + + /** + * @param propId the id of the property for which a Maker should be created + */ + public Maker(int propId) { + super(propId); + } + + /** + * Return a ColorProperty object based on the passed Property object. + * This method is called if the Property object built by the parser + * isn't the right type for this property. + * + * @param p + * The Property object return by the expression parser + * @param propertyList + * The PropertyList object being built for this FO. + * @param fo + * The parent FO for the FO whose property is being made. + * @return A Property of the correct type or null if the parsed value + * can't be converted to the correct type. + * @throws PropertyException + * for invalid or inconsistent FO input + * @see org.apache.fop.fo.properties.PropertyMaker#convertProperty(org.apache.fop.fo.properties.Property, + * org.apache.fop.fo.PropertyList, org.apache.fop.fo.FObj) + */ + public Property convertProperty(Property p, + PropertyList propertyList, FObj fo) + throws PropertyException { + if (p instanceof ColorProperty) { + return p; + } + Color val = p.getColor(); + if (val != null) { + return new ColorProperty(val); + } + return convertPropertyDatatype(p, propertyList, fo); + } + + } + + + /** + * Set the color given a particular String. For a full List of supported + * values please see ColorUtil. + * + * @param value RGB value as String to be parsed + * @throws PropertyException if the value can't be parsed + * @see ColorUtil#parseColorString(String) + */ + public ColorProperty(String value) throws PropertyException { + this.color = ColorUtil.parseColorString(value); + } + + /** + * Create a new ColorProperty with a given color. + * + * @param value the color to use. + */ + public ColorProperty(Color value) { + this.color = value; + } + + /** + * Returns an AWT instance of this color + * @return float the AWT color represented by this ColorType instance + */ + public Color getColor() { + return color; + } + + /** + * @see java.lang.Object#toString() + */ + public String toString() { + return ColorUtil.colorTOsRGBString(color); + } + + /** + * Can't convert to any other types + * @return this.colorType + */ + public ColorProperty getColorProperty() { + return this; + } + + /** + * @return this.colorType cast as an Object + */ + public Object getObject() { + return this; + } +} + Index: src/java/org/apache/fop/fo/properties/ColorTypeProperty.java =================================================================== --- src/java/org/apache/fop/fo/properties/ColorTypeProperty.java (revision 386193) +++ src/java/org/apache/fop/fo/properties/ColorTypeProperty.java (working copy) @@ -1,789 +0,0 @@ -/* - * 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. - * 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.fo.properties; - -import java.awt.Color; -import java.util.StringTokenizer; - -import org.apache.fop.datatypes.ColorType; -import org.apache.fop.fo.FObj; -import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.expr.PropertyException; - -/** - * Superclass for properties that wrap ColorType values - */ -public class ColorTypeProperty extends Property implements ColorType { - /** - * the red component - */ - protected float red = 0f; - - /** - * the green component - */ - protected float green = 0f; - - /** - * the blue component - */ - protected float blue = 0f; - - /** - * the alpha component (indicator of opaque-ness) - * 0.0 - 1.0; 0.0 is completely transparent; 1.0 is completely opaque - * see definition at http://java.sun.com/j2se/1.3/docs/api/java/awt/Color.html - */ - protected float alpha = 1f; - - /** - * Inner class for creating instances of ColorTypeProperty - */ - public static class Maker extends PropertyMaker { - - /** - * @param propId the id of the property for which a Maker should be created - */ - public Maker(int propId) { - super(propId); - } - - /** @see org.apache.fop.fo.properties.PropertyMaker */ - public Property convertProperty(Property p, - PropertyList propertyList, FObj fo) - throws PropertyException { - if (p instanceof ColorTypeProperty) { - return p; - } - ColorTypeProperty val = p.getColorType(); - if (val != null) { - return val; - } - return convertPropertyDatatype(p, propertyList, fo); - } - - } - - /** - * Main constructor - * @param red red component - * @param green green component - * @param blue blue component - */ - public ColorTypeProperty(float red, float green, float blue) { - this.red = red; - this.green = green; - this.blue = blue; - } - - /** - * Set the colour given a particular String specifying either a - * colour name or #RGB or #RRGGBB - * @param value RGB value as String to be parsed - * @throws PropertyException if the value can't be parsed - */ - public ColorTypeProperty(String value) throws PropertyException { - if (value.startsWith("#")) { - try { - if (value.length() == 4) { - // note: divide by 15 so F = FF = 1 and so on - this.red = Integer.parseInt(value.substring(1, 2), 16) - / 15f; - this.green = Integer.parseInt(value.substring(2, 3), 16) - / 15f; - this.blue = Integer.parseInt(value.substring(3), 16) - / 15f; - } else if (value.length() == 7) { - // note: divide by 255 so FF = 1 - this.red = Integer.parseInt(value.substring(1, 3), 16) - / 255f; - this.green = Integer.parseInt(value.substring(3, 5), 16) - / 255f; - this.blue = Integer.parseInt(value.substring(5), 16) - / 255f; - } else { - throw new PropertyException("Unknown color format: " - + value + ". Must be #RGB or #RRGGBB"); - } - } catch (NumberFormatException e) { - throw new PropertyException("Unknown color format: " + value - + ". Must be #RGB or #RRGGBB"); - } - } else if (value.startsWith("rgb(")) { - 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 { - if (st.hasMoreTokens()) { - String str = st.nextToken().trim(); - if (str.endsWith("%")) { - this.red = Float.parseFloat(str.substring(0, str - .length() - 1)) / 100.0f; - } else { - this.red = Float.parseFloat(str) / 255f; - } - } - if (st.hasMoreTokens()) { - String str = st.nextToken().trim(); - if (str.endsWith("%")) { - this.green = Float.parseFloat(str.substring(0, str - .length() - 1)) / 100.0f; - } else { - this.green = Float.parseFloat(str) / 255f; - } - } - if (st.hasMoreTokens()) { - String str = st.nextToken().trim(); - if (str.endsWith("%")) { - this.blue = Float.parseFloat(str.substring(0, str - .length() - 1)) / 100.0f; - } else { - this.blue = Float.parseFloat(str) / 255f; - } - } - } 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)"); - } - } else if (value.startsWith("url(")) { - throw new PropertyException( - "Colors starting with url( are not yet supported!"); - } else { - if (value.startsWith("system-color(")) { - 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)"); - } - } - if (value.toLowerCase().equals("transparent")) { - this.red = 0; - this.green = 0; - this.blue = 0; - this.alpha = 0; - } else { - boolean found = false; - for (int count = 0; count < NAMES.length; count++) { - if (value.toLowerCase().equals(NAMES[count])) { - this.red = VALUES[count][0] / 255f; - this.green = VALUES[count][1] / 255f; - this.blue = VALUES[count][2] / 255f; - found = true; - break; - } - } - if (!found) { - throw new PropertyException("Unknown color name: " + value); - } - } - } - if ((this.red < 0.0 || this.red > 1.0) - || (this.green < 0.0 || this.green > 1.0) - || (this.blue < 0.0 || this.blue > 1.0) - || (this.alpha < 0.0 || this.alpha > 1.0)) { - throw new PropertyException("Color values out of range"); - } - } - - /** - * Returns the blue component of the color. - * @return float a value between 0.0 and 1.0 - */ - public float getBlue() { - return this.blue; - } - - /** - * Returns the green component of the color. - * @return float a value between 0.0 and 1.0 - */ - public float getGreen() { - return this.green; - } - - /** - * Returns the red component of the color. - * @return float a value between 0.0 and 1.0 - */ - public float getRed() { - return this.red; - } - - /** - * Returns the alpha (degree of opaque-ness) component of the color. - * @return float a value between 0.0 (fully transparent) and 1.0 (fully opaque) - */ - public float getAlpha() { - return this.alpha; - } - - /** - * Returns an AWT instance of this color - * @return float the AWT color represented by this ColorType instance - */ - public Color getAWTColor() { - return new Color(this.red, this.green, this.blue, this.alpha); - } - - /** - * @param floatValue value (between 0.0 and 1.0) of color channel - * @return integer equivalent (between 0 and 255) - */ - public static int convertChannelToInteger (float floatValue) { - if (floatValue > 1.0) { - floatValue = 1.0f; - } - if (floatValue < 0) { - floatValue = 0; - } - return (int) (floatValue * 255); - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuffer sbuf = new StringBuffer(8); - sbuf.append('#'); - String s = Integer.toHexString((int)(red * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - s = Integer.toHexString((int)(green * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - s = Integer.toHexString((int)(blue * 255.0)); - if (s.length() == 1) { - sbuf.append('0'); - } - sbuf.append(s); - return sbuf.toString(); - } - - /** The names of the predefined colors */ - protected static final String[] NAMES = { - "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", - "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", - "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", - "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", - "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", - "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", - "darkorchid", "darkred", "darksalmon", "darkseagreen", - "darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", - "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", - "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", - "gainsboro", "lightpink", "lightsalmon", "lightseagreen", - "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", - "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", - "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", - "mediumseagreen", "mediumslateblue", "mediumspringgreen", - "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", - "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", - "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", - "palegreen", "paleturquoise", "palevioletred", "papayawhip", - "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "red", - "rosybrown", "royalblue", "saddlebrown", "salmon", "ghostwhite", - "gold", "goldenrod", "gray", "grey", "green", "greenyellow", - "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", - "lavender", "lavenderblush", "lawngreen", "lemonchiffon", - "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", - "lightgray", "lightgreen", "lightgrey", "sandybrown", "seagreen", - "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", - "slategrey", "snow", "springgreen", "steelblue", "tan", "teal", - "thistle", "tomato", "turquoise", "violet", "wheat", "white", - "whitesmoke", "yellow", "yellowgreen" - }; - - /** The color values for the predefined colors */ - protected static final int[][] VALUES = { - { - 240, 248, 255 - }, { - 250, 235, 215 - }, { - 0, 255, 255 - }, { - 127, 255, 212 - }, { - 240, 255, 255 - }, { - 245, 245, 220 - }, { - 255, 228, 196 - }, { - 0, 0, 0 - }, { - 255, 235, 205 - }, { - 0, 0, 255 - }, { - 138, 43, 226 - }, { - 165, 42, 42 - }, { - 222, 184, 135 - }, { - 95, 158, 160 - }, { - 127, 255, 0 - }, { - 210, 105, 30 - }, { - 255, 127, 80 - }, { - 100, 149, 237 - }, { - 255, 248, 220 - }, { - 220, 20, 60 - }, { - 0, 255, 255 - }, { - 0, 0, 139 - }, { - 0, 139, 139 - }, { - 184, 134, 11 - }, { - 169, 169, 169 - }, { - 0, 100, 0 - }, { - 169, 169, 169 - }, { - 189, 183, 107 - }, { - 139, 0, 139 - }, { - 85, 107, 47 - }, { - 255, 140, 0 - }, { - 153, 50, 204 - }, { - 139, 0, 0 - }, { - 233, 150, 122 - }, { - 143, 188, 143 - }, { - 72, 61, 139 - }, { - 47, 79, 79 - }, { - 47, 79, 79 - }, { - 0, 206, 209 - }, { - 148, 0, 211 - }, { - 255, 20, 147 - }, { - 0, 191, 255 - }, { - 105, 105, 105 - }, { - 105, 105, 105 - }, { - 30, 144, 255 - }, { - 178, 34, 34 - }, { - 255, 250, 240 - }, { - 34, 139, 34 - }, { - 255, 0, 255 - }, { - 220, 220, 220 - }, { - 255, 182, 193 - }, { - 255, 160, 122 - }, { - 32, 178, 170 - }, { - 135, 206, 250 - }, { - 119, 136, 153 - }, { - 119, 136, 153 - }, { - 176, 196, 222 - }, { - 255, 255, 224 - }, { - 0, 255, 0 - }, { - 50, 205, 50 - }, { - 250, 240, 230 - }, { - 255, 0, 255 - }, { - 128, 0, 0 - }, { - 102, 205, 170 - }, { - 0, 0, 205 - }, { - 186, 85, 211 - }, { - 147, 112, 219 - }, { - 60, 179, 113 - }, { - 123, 104, 238 - }, { - 0, 250, 154 - }, { - 72, 209, 204 - }, { - 199, 21, 133 - }, { - 25, 25, 112 - }, { - 245, 255, 250 - }, { - 255, 228, 225 - }, { - 255, 228, 181 - }, { - 255, 222, 173 - }, { - 0, 0, 128 - }, { - 253, 245, 230 - }, { - 128, 128, 0 - }, { - 107, 142, 35 - }, { - 255, 165, 0 - }, { - 255, 69, 0 - }, { - 218, 112, 214 - }, { - 238, 232, 170 - }, { - 152, 251, 152 - }, { - 175, 238, 238 - }, { - 219, 112, 147 - }, { - 255, 239, 213 - }, { - 255, 218, 185 - }, { - 205, 133, 63 - }, { - 255, 192, 203 - }, { - 221, 160, 221 - }, { - 176, 224, 230 - }, { - 128, 0, 128 - }, { - 255, 0, 0 - }, { - 188, 143, 143 - }, { - 65, 105, 225 - }, { - 139, 69, 19 - }, { - 250, 128, 114 - }, { - 248, 248, 255 - }, { - 255, 215, 0 - }, { - 218, 165, 32 - }, { - 128, 128, 128 - }, { - 128, 128, 128 - }, { - 0, 128, 0 - }, { - 173, 255, 47 - }, { - 240, 255, 240 - }, { - 255, 105, 180 - }, { - 205, 92, 92 - }, { - 75, 0, 130 - }, { - 255, 255, 240 - }, { - 240, 230, 140 - }, { - 230, 230, 250 - }, { - 255, 240, 245 - }, { - 124, 252, 0 - }, { - 255, 250, 205 - }, { - 173, 216, 230 - }, { - 240, 128, 128 - }, { - 224, 255, 255 - }, { - 250, 250, 210 - }, { - 211, 211, 211 - }, { - 144, 238, 144 - }, { - 211, 211, 211 - }, { - 244, 164, 96 - }, { - 46, 139, 87 - }, { - 255, 245, 238 - }, { - 160, 82, 45 - }, { - 192, 192, 192 - }, { - 135, 206, 235 - }, { - 106, 90, 205 - }, { - 112, 128, 144 - }, { - 112, 128, 144 - }, { - 255, 250, 250 - }, { - 0, 255, 127 - }, { - 70, 130, 180 - }, { - 210, 180, 140 - }, { - 0, 128, 128 - }, { - 216, 191, 216 - }, { - 255, 99, 71 - }, { - 64, 224, 208 - }, { - 238, 130, 238 - }, { - 245, 222, 179 - }, { - 255, 255, 255 - }, { - 245, 245, 245 - }, { - 255, 255, 0 - }, { - 154, 205, 50 - } - }; - - /* - * aliceblue rgb(240, 248, 255) - * antiquewhite rgb(250, 235, 215) - * aqua rgb( 0, 255, 255) - * aquamarine rgb(127, 255, 212) - * azure rgb(240, 255, 255) - * beige rgb(245, 245, 220) - * bisque rgb(255, 228, 196) - * black rgb( 0, 0, 0) - * blanchedalmond rgb(255, 235, 205) - * blue rgb( 0, 0, 255) - * blueviolet rgb(138, 43, 226) - * brown rgb(165, 42, 42) - * burlywood rgb(222, 184, 135) - * cadetblue rgb( 95, 158, 160) - * chartreuse rgb(127, 255, 0) - * chocolate rgb(210, 105, 30) - * coral rgb(255, 127, 80) - * cornflowerblue rgb(100, 149, 237) - * cornsilk rgb(255, 248, 220) - * crimson rgb(220, 20, 60) - * cyan rgb( 0, 255, 255) - * darkblue rgb( 0, 0, 139) - * darkcyan rgb( 0, 139, 139) - * darkgoldenrod rgb(184, 134, 11) - * darkgray rgb(169, 169, 169) - * darkgreen rgb( 0, 100, 0) - * darkgrey rgb(169, 169, 169) - * darkkhaki rgb(189, 183, 107) - * darkmagenta rgb(139, 0, 139) - * darkolivegreen rgb( 85, 107, 47) - * darkorange rgb(255, 140, 0) - * darkorchid rgb(153, 50, 204) - * darkred rgb(139, 0, 0) - * darksalmon rgb(233, 150, 122) - * darkseagreen rgb(143, 188, 143) - * darkslateblue rgb( 72, 61, 139) - * darkslategray rgb( 47, 79, 79) - * darkslategrey rgb( 47, 79, 79) - * darkturquoise rgb( 0, 206, 209) - * darkviolet rgb(148, 0, 211) - * deeppink rgb(255, 20, 147) - * deepskyblue rgb( 0, 191, 255) - * dimgray rgb(105, 105, 105) - * dimgrey rgb(105, 105, 105) - * dodgerblue rgb( 30, 144, 255) - * firebrick rgb(178, 34, 34) - * floralwhite rgb(255, 250, 240) - * forestgreen rgb( 34, 139, 34) - * fuchsia rgb(255, 0, 255) - * gainsboro rgb(220, 220, 220) - * lightpink rgb(255, 182, 193) - * lightsalmon rgb(255, 160, 122) - * lightseagreen rgb( 32, 178, 170) - * lightskyblue rgb(135, 206, 250) - * lightslategray rgb(119, 136, 153) - * lightslategrey rgb(119, 136, 153) - * lightsteelblue rgb(176, 196, 222) - * lightyellow rgb(255, 255, 224) - * lime rgb( 0, 255, 0) - * limegreen rgb( 50, 205, 50) - * linen rgb(250, 240, 230) - * magenta rgb(255, 0, 255) - * maroon rgb(128, 0, 0) - * mediumaquamarine rgb(102, 205, 170) - * mediumblue rgb( 0, 0, 205) - * mediumorchid rgb(186, 85, 211) - * mediumpurple rgb(147, 112, 219) - * mediumseagreen rgb( 60, 179, 113) - * mediumslateblue rgb(123, 104, 238) - * mediumspringgreen rgb( 0, 250, 154) - * mediumturquoise rgb( 72, 209, 204) - * mediumvioletred rgb(199, 21, 133) - * midnightblue rgb( 25, 25, 112) - * mintcream rgb(245, 255, 250) - * mistyrose rgb(255, 228, 225) - * moccasin rgb(255, 228, 181) - * navajowhite rgb(255, 222, 173) - * navy rgb( 0, 0, 128) - * oldlace rgb(253, 245, 230) - * olive rgb(128, 128, 0) - * olivedrab rgb(107, 142, 35) - * orange rgb(255, 165, 0) - * orangered rgb(255, 69, 0) - * orchid rgb(218, 112, 214) - * palegoldenrod rgb(238, 232, 170) - * palegreen rgb(152, 251, 152) - * paleturquoise rgb(175, 238, 238) - * palevioletred rgb(219, 112, 147) - * papayawhip rgb(255, 239, 213) - * peachpuff rgb(255, 218, 185) - * peru rgb(205, 133, 63) - * pink rgb(255, 192, 203) - * plum rgb(221, 160, 221) - * powderblue rgb(176, 224, 230) - * purple rgb(128, 0, 128) - * red rgb(255, 0, 0) - * rosybrown rgb(188, 143, 143) - * royalblue rgb( 65, 105, 225) - * saddlebrown rgb(139, 69, 19) - * salmon rgb(250, 128, 114) - * ghostwhite rgb(248, 248, 255) - * gold rgb(255, 215, 0) - * goldenrod rgb(218, 165, 32) - * gray rgb(128, 128, 128) - * grey rgb(128, 128, 128) - * green rgb( 0, 128, 0) - * greenyellow rgb(173, 255, 47) - * honeydew rgb(240, 255, 240) - * hotpink rgb(255, 105, 180) - * indianred rgb(205, 92, 92) - * indigo rgb( 75, 0, 130) - * ivory rgb(255, 255, 240) - * khaki rgb(240, 230, 140) - * lavender rgb(230, 230, 250) - * lavenderblush rgb(255, 240, 245) - * lawngreen rgb(124, 252, 0) - * lemonchiffon rgb(255, 250, 205) - * lightblue rgb(173, 216, 230) - * lightcoral rgb(240, 128, 128) - * lightcyan rgb(224, 255, 255) - * lightgoldenrodyellow rgb(250, 250, 210) - * lightgray rgb(211, 211, 211) - * lightgreen rgb(144, 238, 144) - * lightgrey rgb(211, 211, 211) - * sandybrown rgb(244, 164, 96) - * seagreen rgb( 46, 139, 87) - * seashell rgb(255, 245, 238) - * sienna rgb(160, 82, 45) - * silver rgb(192, 192, 192) - * skyblue rgb(135, 206, 235) - * slateblue rgb(106, 90, 205) - * slategray rgb(112, 128, 144) - * slategrey rgb(112, 128, 144) - * snow rgb(255, 250, 250) - * springgreen rgb( 0, 255, 127) - * steelblue rgb( 70, 130, 180) - * tan rgb(210, 180, 140) - * teal rgb( 0, 128, 128) - * thistle rgb(216, 191, 216) - * tomato rgb(255, 99, 71) - * turquoise rgb( 64, 224, 208) - * violet rgb(238, 130, 238) - * wheat rgb(245, 222, 179) - * white rgb(255, 255, 255) - * whitesmoke rgb(245, 245, 245) - * yellow rgb(255, 255, 0) - * yellowgreen rgb(154, 205, 50) - */ - - /** - * Can't convert to any other types - * @return this.colorType - */ - public ColorTypeProperty getColorType() { - return this; - } - - /** - * @return this.colorType cast as an Object - */ - public Object getObject() { - return this; - } -} - Index: src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java =================================================================== --- src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java (revision 386193) +++ src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java (working copy) @@ -18,7 +18,7 @@ package org.apache.fop.fo.properties; -import org.apache.fop.datatypes.ColorType; +import java.awt.Color; import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; @@ -41,7 +41,7 @@ /** * The "background-color" property. */ - public ColorType backgroundColor; + public Color backgroundColor; /** * The "background-image" property. @@ -78,10 +78,10 @@ public static class BorderInfo implements Cloneable { private int mStyle; // Enum for border style - private ColorType mColor; // Border color + private Color mColor; // Border color private CondLengthProperty mWidth; - BorderInfo(int style, CondLengthProperty width, ColorType color) { + BorderInfo(int style, CondLengthProperty width, Color color) { mStyle = style; mWidth = width; mColor = color; @@ -91,7 +91,7 @@ return this.mStyle; } - public ColorType getColor() { + public Color getColor() { return this.mColor; } @@ -141,7 +141,7 @@ public CommonBorderPaddingBackground(PropertyList pList, FObj fobj) throws PropertyException { backgroundAttachment = pList.get(Constants.PR_BACKGROUND_ATTACHMENT).getEnum(); - backgroundColor = pList.get(Constants.PR_BACKGROUND_COLOR).getColorType(); + backgroundColor = pList.get(Constants.PR_BACKGROUND_COLOR).getColor(); if (backgroundColor.getAlpha() == 0) { backgroundColor = null; } @@ -204,7 +204,7 @@ if (style != Constants.EN_NONE) { setBorderInfo(new BorderInfo(style, pList.get(widthProp).getCondLength(), - pList.get(colorProp).getColorType()), side); + pList.get(colorProp).getColor()), side); } } @@ -284,7 +284,7 @@ } } - public ColorType getBorderColor(int side) { + public Color getBorderColor(int side) { if (borderInfo[side] != null) { return borderInfo[side].mColor; } else { Index: src/java/org/apache/fop/fo/properties/CommonTextDecoration.java =================================================================== --- src/java/org/apache/fop/fo/properties/CommonTextDecoration.java (revision 386193) +++ src/java/org/apache/fop/fo/properties/CommonTextDecoration.java (working copy) @@ -21,7 +21,7 @@ import java.util.Iterator; import java.util.List; -import org.apache.fop.datatypes.ColorType; +import java.awt.Color; import org.apache.fop.fo.Constants; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; @@ -38,9 +38,9 @@ private static final int BLINK = 8; private int decoration; - private ColorType underColor; - private ColorType overColor; - private ColorType throughColor; + private Color underColor; + private Color overColor; + private Color throughColor; /** * Creates a new CommonTextDecoration object with default values. @@ -85,33 +85,33 @@ deco = new CommonTextDecoration(); } deco.decoration |= UNDERLINE; - deco.underColor = pList.get(Constants.PR_COLOR).getColorType(); + deco.underColor = pList.get(Constants.PR_COLOR).getColor(); } else if (propEnum == Constants.EN_NO_UNDERLINE) { if (deco != null) { deco.decoration &= OVERLINE | LINE_THROUGH | BLINK; - deco.underColor = pList.get(Constants.PR_COLOR).getColorType(); + deco.underColor = pList.get(Constants.PR_COLOR).getColor(); } } else if (propEnum == Constants.EN_OVERLINE) { if (deco == null) { deco = new CommonTextDecoration(); } deco.decoration |= OVERLINE; - deco.overColor = pList.get(Constants.PR_COLOR).getColorType(); + deco.overColor = pList.get(Constants.PR_COLOR).getColor(); } else if (propEnum == Constants.EN_NO_OVERLINE) { if (deco != null) { deco.decoration &= UNDERLINE | LINE_THROUGH | BLINK; - deco.overColor = pList.get(Constants.PR_COLOR).getColorType(); + deco.overColor = pList.get(Constants.PR_COLOR).getColor(); } } else if (propEnum == Constants.EN_LINE_THROUGH) { if (deco == null) { deco = new CommonTextDecoration(); } deco.decoration |= LINE_THROUGH; - deco.throughColor = pList.get(Constants.PR_COLOR).getColorType(); + deco.throughColor = pList.get(Constants.PR_COLOR).getColor(); } else if (propEnum == Constants.EN_NO_LINE_THROUGH) { if (deco != null) { deco.decoration &= UNDERLINE | OVERLINE | BLINK; - deco.throughColor = pList.get(Constants.PR_COLOR).getColorType(); + deco.throughColor = pList.get(Constants.PR_COLOR).getColor(); } } else if (propEnum == Constants.EN_BLINK) { if (deco == null) { @@ -151,17 +151,17 @@ } /** @return the color of the underline mark */ - public ColorType getUnderlineColor() { + public Color getUnderlineColor() { return this.underColor; } /** @return the color of the overline mark */ - public ColorType getOverlineColor() { + public Color getOverlineColor() { return this.overColor; } /** @return the color of the line-through mark */ - public ColorType getLineThroughColor() { + public Color getLineThroughColor() { return this.throughColor; } Index: src/java/org/apache/fop/fo/properties/NumberProperty.java =================================================================== --- src/java/org/apache/fop/fo/properties/NumberProperty.java (revision 386193) +++ src/java/org/apache/fop/fo/properties/NumberProperty.java (working copy) @@ -18,8 +18,10 @@ package org.apache.fop.fo.properties; +import java.awt.Color; + +import org.apache.fop.datatypes.Numeric; import org.apache.fop.datatypes.PercentBaseContext; -import org.apache.fop.datatypes.Numeric; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; @@ -164,13 +166,14 @@ } /** - * Convert NumberProperty to a ColorType. Not sure why this is needed. - * @return ColorType that corresponds to black + * Convert NumberProperty to a Color. Not sure why this is needed. + * @return Color that corresponds to black */ - public ColorTypeProperty getColorType() { + public Color getColor() { + // TODO: Implement somehow // Convert numeric value to color ??? // Convert to hexadecimal and then try to make it into a color? - return new ColorTypeProperty((float)0.0, (float)0.0, (float)0.0); + return Color.BLACK; } } Index: src/java/org/apache/fop/fo/properties/Property.java =================================================================== --- src/java/org/apache/fop/fo/properties/Property.java (revision 386193) +++ src/java/org/apache/fop/fo/properties/Property.java (working copy) @@ -19,6 +19,7 @@ package org.apache.fop.fo.properties; import java.util.List; +import java.awt.Color; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -75,7 +76,7 @@ * This method expects to be overridden by subclasses * @return ColorType property value */ - public ColorTypeProperty getColorType() { + public Color getColor() { return null; } Index: src/java/org/apache/fop/image/JAIImage.java =================================================================== --- src/java/org/apache/fop/image/JAIImage.java (revision 386180) +++ src/java/org/apache/fop/image/JAIImage.java (working copy) @@ -86,6 +86,13 @@ ColorModel cm = imageOp.getColorModel(); //this.bitsPerPixel = 8; this.bitsPerPixel = cm.getPixelSize(); + + // TODO: the getRGB() function converts the image into the RGB + // colorspace. However, here we assume the image colorspace is kept. + // It should be either one of them, but not both. Unfortunately + // there are other hacks for images in the CMYK colorspace (e.g. in + // the PDF output) that would need to be changed as well. + //this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB); this.colorSpace = cm.getColorSpace(); Index: src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java =================================================================== --- src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (revision 386180) +++ src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (working copy) @@ -34,7 +34,6 @@ import org.apache.fop.area.inline.InlineParent; import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.Viewport; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.Constants; import org.apache.fop.fonts.FontMetrics; import org.apache.fop.image.FopImage; @@ -45,17 +44,8 @@ * follow similar patterns which makes it possible to share some code. */ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { - + /** - * Converts a ColorType to a java.awt.Color (sRGB). - * @param col the color - * @return the converted color - */ - protected Color toColor(ColorType col) { - return new Color(col.getRed(), col.getGreen(), col.getBlue()); - } - - /** * Handle block traits. * The block could be any sort of block with any positioning * so this should render the traits such as border and background @@ -599,21 +589,21 @@ float halfLineWidth = (descender / -8f) / 2f; float endx = (startx + inline.getIPD()) / 1000f; if (inline.hasUnderline()) { - ColorType ct = (ColorType) inline.getTrait(Trait.UNDERLINE_COLOR); + Color ct = (Color) inline.getTrait(Trait.UNDERLINE_COLOR); float y = baseline - descender / 2f; drawBorderLine(startx / 1000f, (y - halfLineWidth) / 1000f, endx, (y + halfLineWidth) / 1000f, true, true, Constants.EN_SOLID, ct); } if (inline.hasOverline()) { - ColorType ct = (ColorType) inline.getTrait(Trait.OVERLINE_COLOR); + Color ct = (Color) inline.getTrait(Trait.OVERLINE_COLOR); float y = (float)(baseline - (1.1 * capHeight)); drawBorderLine(startx / 1000f, (y - halfLineWidth) / 1000f, endx, (y + halfLineWidth) / 1000f, true, true, Constants.EN_SOLID, ct); } if (inline.hasLineThrough()) { - ColorType ct = (ColorType) inline.getTrait(Trait.LINETHROUGH_COLOR); + Color ct = (Color) inline.getTrait(Trait.LINETHROUGH_COLOR); float y = (float)(baseline - (0.45 * capHeight)); drawBorderLine(startx / 1000f, (y - halfLineWidth) / 1000f, endx, (y + halfLineWidth) / 1000f, @@ -669,7 +659,7 @@ * @param col the color to apply (null skips this operation) * @param fill true to set the fill color, false for the foreground color */ - protected abstract void updateColor(ColorType col, boolean fill); + protected abstract void updateColor(Color col, boolean fill); /** * Draw an image at the indicated location. @@ -691,6 +681,6 @@ * @param col the color for the border segment */ protected abstract 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); } Index: src/java/org/apache/fop/render/awt/AWTRenderer.java =================================================================== --- src/java/org/apache/fop/render/awt/AWTRenderer.java (revision 386180) +++ src/java/org/apache/fop/render/awt/AWTRenderer.java (working copy) @@ -26,11 +26,12 @@ */ // Java +import java.awt.Color; import java.awt.Dimension; -import java.awt.geom.Rectangle2D; import java.awt.Toolkit; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.geom.Rectangle2D; import java.awt.print.PageFormat; import java.awt.print.Pageable; import java.awt.print.Paper; @@ -42,8 +43,6 @@ import org.apache.fop.apps.MimeConstants; import org.apache.fop.area.Area; import org.apache.fop.area.PageViewport; -import org.apache.fop.datatypes.ColorType; -import org.apache.fop.fo.properties.ColorTypeProperty; import org.apache.fop.render.awt.viewer.PreviewDialog; import org.apache.fop.render.awt.viewer.Renderable; import org.apache.fop.render.awt.viewer.Translator; @@ -262,7 +261,7 @@ // saves the graphics state in a stack state.push(); - ColorType ct = new ColorTypeProperty(0.7f, 0.7f, 0.7f); + Color ct = new Color(0.7f, 0.7f, 0.7f); state.updateColor(ct, true, null); state.updateStroke(0.4f, EN_SOLID); state.getGraph().draw( Index: src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java =================================================================== --- src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java (revision 386180) +++ src/java/org/apache/fop/render/java2d/Java2DGraphicsState.java (working copy) @@ -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,40 +130,17 @@ } /** - * 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()); - } - - /** * @see org.apache.fop.render.java2d.RendererState#updateColor(org.apache.fop.datatypes.ColorType, * boolean, java.lang.StringBuffer) */ - public boolean updateColor(ColorType col, boolean fill, StringBuffer pdf) { + public boolean updateColor(Color col, boolean fill, StringBuffer pdf) { if (col == null) { return false; } - Color newCol = toColor(col); - return updateColor(newCol); + return updateColor(col); } /** - * 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() { Index: src/java/org/apache/fop/render/java2d/Java2DRenderer.java =================================================================== --- src/java/org/apache/fop/render/java2d/Java2DRenderer.java (revision 386180) +++ src/java/org/apache/fop/render/java2d/Java2DRenderer.java (working copy) @@ -65,7 +65,6 @@ import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.TextArea; import org.apache.fop.area.inline.Viewport; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.Constants; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; @@ -849,7 +848,7 @@ Font font = getFontFromArea(text); state.updateFont(font.getFontName(), font.getFontSize(), null); - ColorType ct = (ColorType) text.getTrait(Trait.COLOR); + Color ct = (Color) text.getTrait(Trait.COLOR); state.updateColor(ct, false, null); String s = text.getText(); @@ -877,7 +876,7 @@ Font font = getFontFromArea(ch); state.updateFont(font.getFontName(), font.getFontSize(), null); - ColorType ct = (ColorType) ch.getTrait(Trait.COLOR); + Color ct = (Color) ch.getTrait(Trait.COLOR); state.updateColor(ct, false, null); String s = ch.getChar(); @@ -911,7 +910,7 @@ Constants.EN_SOLID); float endIPD = startIPD + inline.getIPD(); if (inline.hasUnderline()) { - ColorType ct = (ColorType) inline + Color ct = (Color) inline .getTrait(Trait.UNDERLINE_COLOR); state.updateColor(ct, false, null); float y = baseline - fs.getDescender() / 2; @@ -920,7 +919,7 @@ state.getGraph().draw(line); } if (inline.hasOverline()) { - ColorType ct = (ColorType) inline + Color ct = (Color) inline .getTrait(Trait.OVERLINE_COLOR); state.updateColor(ct, false, null); float y = (float) (baseline - (1.1 * fs.getCapHeight())); @@ -929,7 +928,7 @@ state.getGraph().draw(line); } if (inline.hasLineThrough()) { - ColorType ct = (ColorType) inline + Color ct = (Color) inline .getTrait(Trait.LINETHROUGH_COLOR); state.updateColor(ct, false, null); float y = (float) (baseline - (0.45 * fs.getCapHeight())); @@ -957,7 +956,7 @@ float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + area.getIPD()) / 1000f; - ColorType ct = (ColorType) area.getTrait(Trait.COLOR); + Color ct = (Color) area.getTrait(Trait.COLOR); state.updateColor(ct, true, null); line.setLine(startx, starty, endx, starty); Index: src/java/org/apache/fop/render/java2d/RendererState.java =================================================================== --- src/java/org/apache/fop/render/java2d/RendererState.java (revision 386180) +++ src/java/org/apache/fop/render/java2d/RendererState.java (working copy) @@ -18,12 +18,12 @@ package org.apache.fop.render.java2d; +import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; 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. @@ -55,7 +55,7 @@ * @param pdf only used by the PDFRenderer, is set to null. * @return true if the new Color changes the current Color */ - public abstract boolean updateColor(ColorType col, boolean fill, StringBuffer pdf); + public abstract boolean updateColor(Color col, boolean fill, StringBuffer pdf); /** * Set the current font name. Check if the font name will change and then Index: src/java/org/apache/fop/render/pdf/PDFRenderer.java =================================================================== --- src/java/org/apache/fop/render/pdf/PDFRenderer.java (revision 386180) +++ src/java/org/apache/fop/render/pdf/PDFRenderer.java (working copy) @@ -55,7 +55,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; @@ -571,7 +570,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)) { @@ -580,7 +579,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); @@ -608,7 +607,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); @@ -637,7 +636,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; @@ -664,32 +663,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); @@ -703,7 +701,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"); @@ -724,7 +722,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"); @@ -950,7 +948,7 @@ String endText = useMultiByte ? "> " : ") "; updateFont(font.getFontName(), font.getFontSize(), pdf); - ColorType ct = (ColorType) ch.getTrait(Trait.COLOR); + Color ct = (Color) ch.getTrait(Trait.COLOR); if (ct != null) { updateColor(ct, true, pdf); } @@ -1019,7 +1017,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 @@ -1225,25 +1223,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); } @@ -1430,7 +1427,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: @@ -1451,14 +1448,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"); Index: src/java/org/apache/fop/render/PrintRenderer.java =================================================================== --- src/java/org/apache/fop/render/PrintRenderer.java (revision 386180) +++ src/java/org/apache/fop/render/PrintRenderer.java (working copy) @@ -77,8 +77,10 @@ * @return the modified color */ protected Color lightenColor(Color col, float factor) { - float[] cols = new float[3]; - cols = col.getColorComponents(cols); + // TODO: This function converts the color into the sRGB namespace. + // This should be avoided if possible. + float[] cols = new float[4]; + cols = col.getRGBComponents(cols); if (factor > 0) { cols[0] += (1.0 - cols[0]) * factor; cols[1] += (1.0 - cols[1]) * factor; @@ -88,7 +90,7 @@ cols[1] -= cols[1] * -factor; cols[2] -= cols[2] * -factor; } - return new Color(cols[0], cols[1], cols[2]); + return new Color(cols[0], cols[1], cols[2], cols[3]); } } Index: src/java/org/apache/fop/render/ps/PSGenerator.java =================================================================== --- src/java/org/apache/fop/render/ps/PSGenerator.java (revision 386180) +++ src/java/org/apache/fop/render/ps/PSGenerator.java (working copy) @@ -476,16 +476,20 @@ } /** - * Establishes the specified color (RGB). + * Establishes the specified color in the sRGB colorspace. * @param col the color as defined by the setrgbcolor command. * @exception IOException In case of an I/O problem */ - public void useRGBColor(Color col) throws IOException { + public void useColor(Color col) throws IOException { + // TODO: This function should also handle other colorspaces. + // TODO: This function should handle alpha values + // TODO: Since Postscript is a print medium this should probably define + // colors as CMYK if (col == null) { - col = PSState.DEFAULT_RGB_COLOR; + col = PSState.DEFAULT_COLOR; } if (getCurrentState().useColor(col)) { - float[] comps = col.getColorComponents(null); + float[] comps = col.getRGBColorComponents(null); writeln(formatDouble(comps[0]) + " " + formatDouble(comps[1]) + " " + formatDouble(comps[2]) Index: src/java/org/apache/fop/render/ps/PSRenderer.java =================================================================== --- src/java/org/apache/fop/render/ps/PSRenderer.java (revision 386180) +++ src/java/org/apache/fop/render/ps/PSRenderer.java (working copy) @@ -51,7 +51,6 @@ import org.apache.fop.area.inline.InlineParent; import org.apache.fop.area.inline.Leader; import org.apache.fop.area.inline.TextArea; -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; @@ -256,7 +255,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) { @@ -400,8 +399,8 @@ } } - private void useColor(ColorType col) throws IOException { - gen.useRGBColor(toColor(col)); + private void useColor(Color col) throws IOException { + gen.useColor(col); } /** @see org.apache.fop.render.AbstractPathOrientedRenderer#drawBackAndBorders( @@ -422,7 +421,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; @@ -509,30 +508,29 @@ 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); + gen.useColor(uppercol); drawLine(x1, ym1, x2, ym1); - gen.useRGBColor(c); + gen.useColor(col); drawLine(x1, ym1 + h3, x2, ym1 + h3); - gen.useRGBColor(lowercol); + gen.useColor(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); + gen.useColor(leftcol); drawLine(xm1, y1, xm1, y2); - gen.useRGBColor(c); + gen.useColor(col); drawLine(xm1 + w3, y1, xm1 + w3, y2); - gen.useRGBColor(rightcol); + gen.useColor(rightcol); drawLine(xm1 + w3 + w3, y1, xm1 + w3 + w3, y2); } break; @@ -540,18 +538,17 @@ 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); + gen.useColor(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); + gen.useColor(c); drawLine(xm1, y1, xm1, y2); } break; @@ -852,7 +849,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); @@ -1016,7 +1013,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) { @@ -1038,14 +1035,14 @@ case EN_RIDGE: float half = area.getRuleThickness() / 2000f; - gen.useRGBColor(lightenColor(toColor(col), 0.6f)); + gen.useColor(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.useColor(col); if (style == EN_GROOVE) { moveTo(startx, starty); lineTo(endx, starty); Index: src/java/org/apache/fop/render/ps/PSState.java =================================================================== --- src/java/org/apache/fop/render/ps/PSState.java (revision 386180) +++ src/java/org/apache/fop/render/ps/PSState.java (working copy) @@ -35,7 +35,7 @@ /** Default for setdash */ public static final String DEFAULT_DASH = "[] 0"; /** Default color in PostScript */ - public static final Color DEFAULT_RGB_COLOR = Color.black; + public static final Color DEFAULT_COLOR = Color.black; private AffineTransform transform = new AffineTransform(); private List transformConcatList = new java.util.ArrayList(); @@ -43,7 +43,7 @@ private int linecap = 0; private double linewidth = 1.0f; private String dashpattern = DEFAULT_DASH; - private Color rgbColor = DEFAULT_RGB_COLOR; + private Color color = DEFAULT_COLOR; //Font state private String fontname; @@ -69,7 +69,7 @@ this.linecap = org.linecap; this.linewidth = org.linewidth; this.dashpattern = org.dashpattern; - this.rgbColor = org.rgbColor; + this.color = org.color; this.fontname = org.fontname; this.fontsize = org.fontsize; } @@ -152,8 +152,8 @@ * @return true if the color changed compared to the previous setting */ public boolean useColor(Color value) { - if (!rgbColor.equals(value)) { - rgbColor = value; + if (!color.equals(value)) { + color = value; return true; } else { return false; @@ -192,7 +192,7 @@ gen.useLineCap(linecap); gen.useLineWidth(linewidth); gen.useDash(dashpattern); - gen.useRGBColor(rgbColor); + gen.useColor(color); if (fontname != null) { gen.useFont(fontname, fontsize); } Index: src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java =================================================================== --- src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java (revision 386180) +++ src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java (working copy) @@ -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; Index: src/java/org/apache/fop/render/rtf/TableAttributesConverter.java =================================================================== --- src/java/org/apache/fop/render/rtf/TableAttributesConverter.java (revision 386180) +++ src/java/org/apache/fop/render/rtf/TableAttributesConverter.java (working copy) @@ -18,10 +18,11 @@ package org.apache.fop.render.rtf; +import java.awt.Color; + import org.apache.commons.logging.Log; import org.apache.commons.logging.impl.SimpleLog; 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 +30,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; @@ -119,7 +119,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. Index: src/java/org/apache/fop/render/rtf/TextAttributesConverter.java =================================================================== --- src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (revision 386180) +++ src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (working copy) @@ -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(); } Index: src/java/org/apache/fop/render/txt/TXTRenderer.java =================================================================== --- src/java/org/apache/fop/render/txt/TXTRenderer.java (revision 386180) +++ src/java/org/apache/fop/render/txt/TXTRenderer.java (working copy) @@ -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(); Index: src/java/org/apache/fop/render/xml/XMLRenderer.java =================================================================== --- src/java/org/apache/fop/render/xml/XMLRenderer.java (revision 386180) +++ src/java/org/apache/fop/render/xml/XMLRenderer.java (working copy) @@ -19,35 +19,23 @@ 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.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.sax.SAXTransformerFactory; 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.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.fop.util.XMLizable; +import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FOPException; import org.apache.fop.apps.MimeConstants; import org.apache.fop.area.Area; import org.apache.fop.area.BeforeFloat; @@ -55,10 +43,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; @@ -75,15 +63,27 @@ 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.SpaceArea; +import org.apache.fop.area.inline.TextArea; 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.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; +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; /** * Renderer that renders areas to XML for debugging purposes. @@ -357,6 +357,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()); Index: src/java/org/apache/fop/traits/BorderProps.java =================================================================== --- src/java/org/apache/fop/traits/BorderProps.java (revision 386180) +++ src/java/org/apache/fop/traits/BorderProps.java (working copy) @@ -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) { Index: src/java/org/apache/fop/util/ColorUtil.java =================================================================== --- src/java/org/apache/fop/util/ColorUtil.java (revision 0) +++ src/java/org/apache/fop/util/ColorUtil.java (revision 0) @@ -0,0 +1,478 @@ +/* + * 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. + * 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.HashMap; +import java.util.StringTokenizer; + +import org.apache.fop.fo.expr.PropertyException; + +/** + * Generic Color helper class. + *
+ * This class supports parsing string values into color values and creating + * color values for strings. It provides a list of standard color names. + *
+ * TODO: Add support for color Profiles. + */ +final public class ColorUtil { + + /** + * keeps all the predefined and parsed colors. + *
+ * This map is used to predefine given colors, as well as speeding up + * parsing of already parsed colors. + */ + static HashMap colorMap = null; + + /** + * Private constructor since this is an utility class. + */ + private ColorUtil() { + } + + /** + * Creates a color from a given string. + *
+ * This function supports a wide variety of inputs. + *
+ * 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 = new 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));
+ }
+
+}
Index: test/fotree/testcases/properties_omitted_propertyname.fo
===================================================================
--- test/fotree/testcases/properties_omitted_propertyname.fo (revision 386180)
+++ test/fotree/testcases/properties_omitted_propertyname.fo (working copy)
@@ -53,8 +53,8 @@