import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.datatypes.ColorType;
import org.apache.fop.traits.BorderProps;
import org.apache.fop.util.QName;
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);
}
/**
package org.apache.fop.area;
+import java.awt.Color;
import java.awt.geom.Rectangle2D;
import java.util.List;
import java.util.Map;
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;
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;
if (value != null) {
Class cl = Trait.getTraitClass(trait);
if (cl == Integer.class) {
- //if (value != null) {
- area.addTrait(trait, new Integer(value));
- //}
+ area.addTrait(trait, new Integer(value));
} else if (cl == Boolean.class) {
- //String value = attributes.getValue(Trait.getTraitName(trait));
- //if (value != null) {
- area.addTrait(trait, Boolean.valueOf(value));
- //}
+ area.addTrait(trait, Boolean.valueOf(value));
} else if (cl == String.class) {
- //String value = attributes.getValue(Trait.getTraitName(trait));
- //if (value != null) {
- area.addTrait(trait, value);
- //}
+ area.addTrait(trait, value);
} 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) {
+ throw new IllegalArgumentException(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) {
- bkg.setURL(url);
-
- ImageFactory fact = userAgent.getFactory().getImageFactory();
- FopImage img = fact.getImage(url, userAgent);
- if (img == null) {
- log.error("Background image not available: " + url);
- } else {
- // load dimensions
- if (!img.load(FopImage.DIMENSIONS)) {
- log.error("Cannot read background image dimensions: "
- + url);
- }
+ Background bkg = new Background();
+ try {
+ Color col = ColorUtil
+ .parseColorString(attributes
+ .getValue("bkg-color"));
+ bkg.setColor(col);
+ } catch (PropertyException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ String url = attributes.getValue("bkg-img");
+ if (url != null) {
+ bkg.setURL(url);
+
+ ImageFactory fact = userAgent.getFactory().getImageFactory();
+ FopImage img = fact.getImage(url, userAgent);
+ if (img == null) {
+ log.error("Background image not available: " + url);
+ } else {
+ // load dimensions
+ if (!img.load(FopImage.DIMENSIONS)) {
+ log.error("Cannot read background image dimensions: "
+ + url);
}
- bkg.setFopImage(img);
-
- String repeat = attributes.getValue("bkg-repeat");
- if (repeat != null) {
- bkg.setRepeat(repeat);
- }
- bkg.setHoriz(getAttributeAsInteger(attributes,
- "bkg-horz-offset", 0));
- bkg.setVertical(getAttributeAsInteger(attributes,
- "bkg-vert-offset", 0));
}
- area.addTrait(trait, bkg);
- //}
+ bkg.setFopImage(img);
+
+ String repeat = attributes.getValue("bkg-repeat");
+ if (repeat != null) {
+ bkg.setRepeat(repeat);
+ }
+ bkg.setHoriz(getAttributeAsInteger(attributes,
+ "bkg-horz-offset", 0));
+ bkg.setVertical(getAttributeAsInteger(attributes,
+ "bkg-vert-offset", 0));
+ }
+ area.addTrait(trait, bkg);
} else if (cl == BorderProps.class) {
- //String value = attributes.getValue(Trait.getTraitName(trait));
- //if (value != null) {
- area.addTrait(trait, BorderProps.valueOf(value));
- //}
+ area.addTrait(trait, BorderProps.valueOf(value));
}
} else {
- //Class cl = Trait.getTraitClass(trait);
if (trait == Trait.FONT) {
String fontName = attributes.getValue("font-name");
if (fontName != null) {
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 java.io.Serializable;
+import org.apache.fop.util.ColorUtil;
// properties should be serialized by the holder
/**
public static final Integer FONT_SIZE = new Integer(4);
/**
- * The current colour.
+ * The current color.
*/
public static final Integer COLOR = new Integer(7);
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.
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;
* Returns the background color.
* @return background color, null if n/a
*/
- public ColorType getColor() {
+ public Color getColor() {
return color;
}
* 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;
}
/**
*/
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);
+++ /dev/null
-/*
- * 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();
-}
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;
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);
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);
}
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");
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");
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");
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");
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");
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");
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");
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");
PropertyMaker m;
// color
- m = new ColorTypeProperty.Maker(PR_COLOR);
+ m = new ColorProperty.Maker(PR_COLOR);
m.useGeneric(genericColor);
m.setInherited(true);
m.setDefault("black");
package org.apache.fop.fo;
// Java
+import java.awt.Color;
import java.util.NoSuchElementException;
// 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;
// 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 whiteSpaceTreatment;
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();
/**
* @return the "color" property.
*/
- public ColorType getColor() {
+ public Color getColor() {
return color;
}
/*
- * 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.
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
}
/**
- * 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;
+ }
}
/**
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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;
/**
return true;
}
- /**
- * Cast this as a Numeric.
- */
+ /** @see org.apache.fop.fo.properties.Property#getNumeric() */
public Numeric getNumeric() {
return this;
}
- /**
- * Cast this as a number.
- */
+ /** @see org.apache.fop.fo.properties.Property#getNumber() */
public Number getNumber() {
return new Double(value);
}
- /**
- * @see org.apache.fop.datatypes.Numeric#getValue()
- */
+ /** @see org.apache.fop.datatypes.Numeric#getValue() */
public int getValue() {
return (int) value;
}
- /**
- * @see org.apache.fop.datatypes.Numeric#getValue(PercentBaseContext)
- */
+ /** @see org.apache.fop.datatypes.Numeric#getValue(PercentBaseContext) */
public int getValue(PercentBaseContext context) {
return (int) value;
}
- /**
- * Cast this as a length. That is only possible when the dimension is
- * one.
- */
+ /** @see org.apache.fop.fo.properties.Property#getLength() */
public Length getLength() {
if (dim == 1) {
return this;
return null;
}
- /**
- * Cast this as a ColorTypeProperty.
- */
- public ColorTypeProperty getColorType() {
- // try converting to numeric number and then to color
+ /** @see org.apache.fop.fo.properties.Property#getColor() */
+ public Color getColor() {
+ // TODO: try converting to numeric number and then to color
return null;
}
- /**
- * Cast this as an Object.
- */
+ /** @see org.apache.fop.fo.properties.Property#getObject() */
public Object getObject() {
return this;
}
- /**
- * Return a string representation of this Numeric. It is only useable for
- * debugging.
- */
+ /** @see java.lang.Object#toString() */
public String toString() {
if (dim == 1) {
return (int) value + "mpt";
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;
break;
case TOK_COLORSPEC:
- prop = new ColorTypeProperty(currentTokenValue);
+ prop = new ColorProperty(currentTokenValue);
break;
case TOK_FUNCTION_LPAR:
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;
/**
/** @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] + ")");
}
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;
/**
/** @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] + ")");
}
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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.
private CommonAural commonAural;
private CommonFont commonFont;
private CommonRelativePosition commonRelativePosition;
- private ColorTypeProperty prColor;
+ private Color prColor;
// private ToBeImplementedProperty prDirection;
// private ToBeImplementedProperty prLetterSpacing;
private SpaceProperty lineHeight;
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();
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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 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.datatypes.Numeric;
import org.apache.fop.fo.CharIterator;
private CommonRelativePosition commonRelativePosition;
private int breakAfter;
private int breakBefore;
- private ColorType color;
+ private Color color;
private Length textDepth;
private Length textAltitude;
private int hyphenationKeep;
private int wrapOption;
// End of property values
- // this may be helpful on other FOs too
- private boolean anythingLaidOut = false;
-
/**
* @param parent FONode that is the parent of this object
*
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();
/**
* @return the "color" property.
*/
- public ColorType getColor() {
+ public Color getColor() {
return color;
}
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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;
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
private int alignmentBaseline;
private Length baselineShift;
private char character;
- private ColorType color;
+ private Color color;
private int dominantBaseline;
private Length textDepth;
private Length textAltitude;
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();
/**
* @return the "color" property.
*/
- public ColorType getColor() {
+ public Color getColor() {
return color;
}
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.apache.fop.fo.flow;
// XML
+import java.awt.Color;
+
import org.xml.sax.Locator;
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;
private CommonBorderPaddingBackground commonBorderPaddingBackground;
private CommonFont commonFont;
private CommonRelativePosition commonRelativePosition;
- private ColorTypeProperty color;
+ private Color color;
private String id;
// private ToBeImplementedProperty letterSpacing;
private SpaceProperty lineHeight;
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();
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;
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
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();
}
/**
* @return the "color" property.
*/
- public ColorType getColor() {
+ public Color getColor() {
return color;
}
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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;
// 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
wrapOption = pList.get(PR_WRAP_OPTION).getEnum();
// implicit properties
- color = pList.get(Constants.PR_COLOR).getColorType();
+ color = pList.get(Constants.PR_COLOR).getColor();
}
/**
}
/** @return the "color" property. */
- public ColorType getColor() {
+ public Color getColor() {
return color;
}
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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;
// 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
wrapOption = pList.get(PR_WRAP_OPTION).getEnum();
// implicit properties
- color = pList.get(Constants.PR_COLOR).getColorType();
+ color = pList.get(Constants.PR_COLOR).getColor();
}
/**
}
/** @return the "color" property. */
- public ColorType getColor() {
+ public Color getColor() {
return color;
}
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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 {
* @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;
--- /dev/null
+/*
+ * 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;
+ }
+}
+
+++ /dev/null
-/*
- * 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;
- }
-}
-
/*
- * Copyright 2004-2005 The Apache Software Foundation.
+ * Copyright 2004-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.apache.fop.fo.properties;
+import java.awt.Color;
+
import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.datatypes.ColorType;
import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.Constants;
/**
* The "background-color" property.
*/
- public ColorType backgroundColor;
+ public Color backgroundColor;
/**
* The "background-image" property.
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;
return this.mStyle;
}
- public ColorType getColor() {
+ public Color getColor() {
return this.mColor;
}
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;
}
if (style != Constants.EN_NONE) {
setBorderInfo(new BorderInfo(style,
pList.get(widthProp).getCondLength(),
- pList.get(colorProp).getColorType()), side);
+ pList.get(colorProp).getColor()), side);
}
}
}
}
- public ColorType getBorderColor(int side) {
+ public Color getBorderColor(int side) {
if (borderInfo[side] != null) {
return borderInfo[side].mColor;
} else {
* @return all the padding and border height.
*/
public int getBPPaddingAndBorder(boolean bDiscard, PercentBaseContext context) {
- return getPaddingBefore(bDiscard, context) + getPaddingAfter(bDiscard, context) +
- getBorderBeforeWidth(bDiscard) + getBorderAfterWidth(bDiscard);
+ return getPaddingBefore(bDiscard, context) + getPaddingAfter(bDiscard, context)
+ + getBorderBeforeWidth(bDiscard) + getBorderAfterWidth(bDiscard);
}
+ /** @see java.lang.Object#toString() */
public String toString() {
- return "CommonBordersAndPadding (Before, After, Start, End):\n" +
- "Borders: (" + getBorderBeforeWidth(false) + ", " + getBorderAfterWidth(false) + ", " +
- getBorderStartWidth(false) + ", " + getBorderEndWidth(false) + ")\n" +
- "Border Colors: (" + getBorderColor(BEFORE) + ", " + getBorderColor(AFTER) + ", " +
- getBorderColor(START) + ", " + getBorderColor(END) + ")\n" +
- "Padding: (" + getPaddingBefore(false, null) + ", " + getPaddingAfter(false, null) + ", " +
- getPaddingStart(false, null) + ", " + getPaddingEnd(false, null) + ")\n";
+ return "CommonBordersAndPadding (Before, After, Start, End):\n"
+ + "Borders: (" + getBorderBeforeWidth(false) + ", " + getBorderAfterWidth(false) + ", "
+ + getBorderStartWidth(false) + ", " + getBorderEndWidth(false) + ")\n"
+ + "Border Colors: (" + getBorderColor(BEFORE) + ", " + getBorderColor(AFTER) + ", "
+ + getBorderColor(START) + ", " + getBorderColor(END) + ")\n"
+ + "Padding: (" + getPaddingBefore(false, null) + ", " + getPaddingAfter(false, null)
+ + ", " + getPaddingStart(false, null) + ", " + getPaddingEnd(false, null) + ")\n";
}
/**
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;
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.
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) {
}
/** @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;
}
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.apache.fop.fo.properties;
-import org.apache.fop.datatypes.PercentBaseContext;
+import java.awt.Color;
+
import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
return getNumericValue();
}
+ /** @see org.apache.fop.datatypes.Numeric#getValue() */
public int getValue() {
return number.intValue();
}
}
/**
- * 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;
}
}
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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;
/**
* Base class for all property objects
- * @author unascribed
*/
public class Property {
/**
* Set the original value specified for the property attribute.
- * @param specVal The specified value.
+ * @param value The specified value.
*/
- public void setSpecifiedValue(String specVal) {
- this.specVal = specVal;
+ public void setSpecifiedValue(String value) {
+ this.specVal = value;
}
/**
* This method expects to be overridden by subclasses
* @return ColorType property value
*/
- public ColorTypeProperty getColorType() {
+ public Color getColor() {
return null;
}
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();
package org.apache.fop.render;
+import java.awt.Color;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.util.List;
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.InlineArea;
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;
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,
* @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.
* @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);
}
package org.apache.fop.render;
// Java
-import java.awt.Color;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import org.apache.fop.area.inline.WordArea;
import org.apache.fop.area.inline.SpaceArea;
import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.Constants;
import org.apache.fop.fonts.FontInfo;
import org.apache.commons.logging.Log;
return null;
}
- /**
- * 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());
- }
}
* @return the modified color
*/
public static 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;
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]);
}
}
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// 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;
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;
// saves the graphics state in a stack
state.push();
- ColorType ct = new ColorTypeProperty(0.7f, 0.7f, 0.7f);
- state.updateColor(ct);
+ Color col = new Color(0.7f, 0.7f, 0.7f);
+ state.updateColor(col);
state.updateStroke(0.4f, EN_SOLID);
state.getGraph().draw(
new Rectangle2D.Float(startx, starty, width, height));
/*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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;
}
}
- /**
- * Converts a ColorType to a java.awt.Color (sRGB).
- *
- * @param col the color as a org.apache.fop.datatypes.ColorType
- * @return the converted color as a java.awt.Color
- */
- public Color toColor(ColorType col) {
- return new Color(col.getRed(), col.getGreen(), col.getBlue());
- }
-
- /**
- * Update the current Color
- * @param col the ColorType
- */
- public void updateColor(ColorType col) {
- if (col == null) {
- return;
- }
- Color newCol = toColor(col);
- updateColor(newCol);
- }
-
/**
* @return the current java.awt.Color
*/
return update;
}
+ /** @return the currently active Stroke */
public BasicStroke getStroke() {
return (BasicStroke) currentGraphics.getStroke();
}
return getGraph().getTransform();
}
- /** a verbose description of the current state */
+ /** @see java.lang.Object#toString() */
public String toString() {
String s = "AWTGraphicsState " + currentGraphics.toString()
+ ", Stroke (width: " + currentStrokeWidth + " style: "
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.ForeignObject;
import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.Leader;
import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.Constants;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
* @see org.apache.fop.render.AbstractPathOrientedRenderer#updateColor(
* org.apache.fop.datatypes.ColorType, boolean)
*/
- protected void updateColor(ColorType col, boolean fill) {
- state.updateColor(toColor(col));
+ protected void updateColor(Color col, boolean fill) {
+ state.updateColor(col);
}
/**
* org.apache.fop.datatypes.ColorType)
*/
protected void drawBorderLine(float x1, float y1, float x2, float y2,
- boolean horz, boolean startOrBefore, int style, ColorType col) {
+ boolean horz, boolean startOrBefore, int style, Color col) {
Graphics2D g2d = state.getGraph();
drawBorderLine(new Rectangle2D.Float(x1, y1, x2 - x1, y2 - y1),
- horz, startOrBefore, style, toColor(col), g2d);
+ horz, startOrBefore, style, col, g2d);
}
/**
Font font = getFontFromArea(text);
state.updateFont(font.getFontName(), font.getFontSize(), null);
- ColorType ct = (ColorType) text.getTrait(Trait.COLOR);
- state.updateColor(ct);
+ Color col = (Color) text.getTrait(Trait.COLOR);
+ state.updateColor(col);
String s = text.getText();
state.getGraph().drawString(s, rx / 1000f, bl / 1000f);
float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
+ area.getIPD()) / 1000f;
- ColorType col = (ColorType) area.getTrait(Trait.COLOR);
+ Color col = (Color) area.getTrait(Trait.COLOR);
state.updateColor(col);
Line2D line = new Line2D.Float();
case EN_RIDGE:
float half = area.getRuleThickness() / 2000f;
- state.updateColor(lightenColor(toColor(col), 0.6f));
+ state.updateColor(lightenColor(col, 0.6f));
moveTo(startx, starty);
lineTo(endx, starty);
lineTo(endx, starty + 2 * half);
closePath();
state.getGraph().fill(currentPath);
currentPath = null;
- state.updateColor(toColor(col));
+ state.updateColor(col);
if (style == EN_GROOVE) {
moveTo(startx, starty);
lineTo(endx, starty);
/*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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.
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;
/** @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)) {
}
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);
}
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);
}
break;
case Constants.EN_DOUBLE:
- setColor(toColor(col), false, null);
+ setColor(col, false, null);
currentStream.add("[] 0 d ");
if (horz) {
float h3 = h / 3;
{
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);
{
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");
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");
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
* @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);
}
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:
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");
import org.apache.fop.area.inline.SpaceArea;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.WordArea;
-import org.apache.fop.datatypes.ColorType;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExtensionAttachment;
}
/** @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) {
}
}
- private void useColor(ColorType col) throws IOException {
- gen.useRGBColor(toColor(col));
+ private void useColor(Color col) throws IOException {
+ gen.useRGBColor(col);
}
/** @see org.apache.fop.render.AbstractPathOrientedRenderer#drawBackAndBorders(
/** @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;
case Constants.EN_RIDGE:
float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
gen.useDash(null);
- Color c = toColor(col);
if (horz) {
- Color uppercol = lightenColor(c, -colFactor);
- Color lowercol = lightenColor(c, colFactor);
+ Color uppercol = lightenColor(col, -colFactor);
+ Color lowercol = lightenColor(col, colFactor);
float h3 = h / 3;
gen.useLineWidth(h3);
float ym1 = y1 + (h3 / 2);
gen.useRGBColor(uppercol);
drawLine(x1, ym1, x2, ym1);
- gen.useRGBColor(c);
+ gen.useRGBColor(col);
drawLine(x1, ym1 + h3, x2, ym1 + h3);
gen.useRGBColor(lowercol);
drawLine(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3);
} else {
- Color leftcol = lightenColor(c, -colFactor);
- Color rightcol = lightenColor(c, colFactor);
+ Color leftcol = lightenColor(col, -colFactor);
+ Color rightcol = lightenColor(col, colFactor);
float w3 = w / 3;
gen.useLineWidth(w3);
float xm1 = x1 + (w3 / 2);
gen.useRGBColor(leftcol);
drawLine(xm1, y1, xm1, y2);
- gen.useRGBColor(c);
+ gen.useRGBColor(col);
drawLine(xm1 + w3, y1, xm1 + w3, y2);
gen.useRGBColor(rightcol);
drawLine(xm1 + w3 + w3, y1, xm1 + w3 + w3, y2);
case Constants.EN_OUTSET:
colFactor = (style == EN_OUTSET ? 0.4f : -0.4f);
gen.useDash(null);
- c = toColor(col);
if (horz) {
- c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
+ Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
gen.useLineWidth(h);
float ym1 = y1 + (h / 2);
gen.useRGBColor(c);
drawLine(x1, ym1, x2, ym1);
} else {
- c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
+ Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
gen.useLineWidth(w);
float xm1 = x1 + (w / 2);
gen.useRGBColor(c);
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);
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) {
case EN_RIDGE:
float half = area.getRuleThickness() / 2000f;
- gen.useRGBColor(lightenColor(toColor(col), 0.6f));
+ gen.useRGBColor(lightenColor(col, 0.6f));
moveTo(startx, starty);
lineTo(endx, starty);
lineTo(endx, starty + 2 * half);
lineTo(startx, starty + 2 * half);
closePath();
gen.writeln(" fill newpath");
- gen.useRGBColor(toColor(col));
+ gen.useRGBColor(col);
if (style == EN_GROOVE) {
moveTo(startx, starty);
lineTo(endx, starty);
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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;
* @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;
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.apache.fop.render.rtf;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.impl.SimpleLog;
+import java.awt.Color;
+
import org.apache.fop.apps.FOPException;
-import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.Table;
import org.apache.fop.fo.flow.TableBody;
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;
public final class TableAttributesConverter {
- private static Log log = new SimpleLog("FOP/RTF");
-
//////////////////////////////////////////////////
// @@ Construction
//////////////////////////////////////////////////
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.
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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;
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;
}
- 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
*/
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
* @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();
}
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.apache.fop.render.txt;
+import java.awt.Color;
import java.awt.Point;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
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;
* 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) {
* @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();
package org.apache.fop.render.xml;
// Java
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Iterator;
-import java.awt.geom.Rectangle2D;
import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.w3c.dom.Document;
+
import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.ContentHandler;
-// FOP
-import org.apache.fop.render.PrintRenderer;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.XMLHandler;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.fop.util.QName;
-import org.apache.fop.util.XMLizable;
-import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.Area;
import org.apache.fop.area.BeforeFloat;
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;
import org.apache.fop.area.inline.InlineParent;
import org.apache.fop.area.inline.Leader;
import org.apache.fop.area.inline.Space;
-import org.apache.fop.area.inline.Viewport;
-import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.SpaceArea;
+import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.inline.Viewport;
import org.apache.fop.area.inline.WordArea;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExtensionAttachment;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontSetup;
import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.render.PrintRenderer;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.XMLHandler;
+import org.apache.fop.util.ColorUtil;
+import org.apache.fop.util.XMLizable;
/**
* Renderer that renders areas to XML for debugging purposes.
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());
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.
/** 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) */
* @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;
}
* @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);
}
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");
}
sbuf.append('(');
sbuf.append(getStyleString());
sbuf.append(',');
- sbuf.append(color);
+ sbuf.append(ColorUtil.colorTOsRGBString(color));
sbuf.append(',');
sbuf.append(width);
if (mode != SEPARATE) {
--- /dev/null
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.util;
+
+import java.awt.Color;
+import java.util.Collections;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Generic Color helper class.
+ * <p>
+ * This class supports parsing string values into color values and creating
+ * color values for strings. It provides a list of standard color names.
+ * <p>
+ * TODO: Add support for color Profiles.
+ */
+public final class ColorUtil {
+
+ /**
+ * keeps all the predefined and parsed colors.
+ * <p>
+ * This map is used to predefine given colors, as well as speeding up
+ * parsing of already parsed colors.
+ */
+ private static Map colorMap = null;
+
+ static {
+ initializeColorMap();
+ }
+
+ /**
+ * Private constructor since this is an utility class.
+ */
+ private ColorUtil() {
+ }
+
+ /**
+ * Creates a color from a given string.
+ * <p>
+ * This function supports a wide variety of inputs.
+ * <ul>
+ * <li>#RGB (hex 0..f)</li>
+ * <li>#RGBA (hex 0..f)</li>
+ * <li>#RRGGBB (hex 00..ff)</li>
+ * <li>#RRGGBBAA (hex 00..ff)</li>
+ * <li>rgb(r,g,b) (0..255 or 0%..100%)</li>
+ * <li>java.awt.Color[r=r,g=g,b=b] (0..255)</li>
+ * <li>system-color(colorname)</li>
+ * <li>transparent</li>
+ * <li>colorname</li>
+ * </ul>
+ *
+ * @param value
+ * the string to parse.
+ * @return a Color representing the string if possible
+ * @throws PropertyException
+ * if the string is not parsable or does not follow any of the
+ * given formats.
+ */
+ public static Color parseColorString(String value) throws PropertyException {
+ if (value == null) {
+ return null;
+ }
+
+ Color parsedColor = (Color) colorMap.get(value.toLowerCase());
+
+ if (parsedColor == null) {
+ if (value.startsWith("#")) {
+ parsedColor = parseWithHash(value);
+ } else if (value.startsWith("rgb(")) {
+ parsedColor = parseAsRGB(value);
+ } else if (value.startsWith("url(")) {
+ throw new PropertyException(
+ "Colors starting with url( are not yet supported!");
+ } else if (value.startsWith("java.awt.Color")) {
+ parsedColor = parseAsJavaAWTColor(value);
+ } else if (value.startsWith("system-color(")) {
+ parsedColor = parseAsSystemColor(value);
+ }
+
+ if (parsedColor == null) {
+ throw new PropertyException("Unkown Color: " + value);
+ }
+
+ colorMap.put(value, parsedColor);
+ }
+
+ // TODO: Check if this is really necessary
+ return new Color(parsedColor.getRed(), parsedColor.getGreen(),
+ parsedColor.getBlue(), parsedColor.getAlpha());
+ }
+
+ /**
+ * Tries to parse a color given with the system-color() function.
+ *
+ * @param value
+ * the complete line
+ * @return a color if possible
+ * @throws PropertyException
+ * if the format is wrong.
+ */
+ private static Color parseAsSystemColor(String value)
+ throws PropertyException {
+ int poss = value.indexOf("(");
+ int pose = value.indexOf(")");
+ if (poss != -1 && pose != -1) {
+ value = value.substring(poss + 1, pose);
+ } else {
+ throw new PropertyException("Unknown color format: " + value
+ + ". Must be system-color(x)");
+ }
+ return (Color) colorMap.get(value);
+ }
+
+ /**
+ * Tries to parse the standard java.awt.Color toString output.
+ *
+ * @param value
+ * the complete line
+ * @return a color if possible
+ * @throws PropertyException
+ * if the format is wrong.
+ * @see java.awt.Color#toString()
+ */
+ private static Color parseAsJavaAWTColor(String value)
+ throws PropertyException {
+ float red = 0.0f, green = 0.0f, blue = 0.0f;
+ int poss = value.indexOf("[");
+ int pose = value.indexOf("]");
+ try {
+ if (poss != -1 && pose != -1) {
+ value = value.substring(poss + 1, pose);
+ StringTokenizer st = new StringTokenizer(value, ",");
+ if (st.hasMoreTokens()) {
+ String str = st.nextToken().trim();
+ red = Float.parseFloat(str.substring(2)) / 255f;
+ }
+ if (st.hasMoreTokens()) {
+ String str = st.nextToken().trim();
+ green = Float.parseFloat(str.substring(2)) / 255f;
+ }
+ if (st.hasMoreTokens()) {
+ String str = st.nextToken().trim();
+ blue = Float.parseFloat(str.substring(2)) / 255f;
+ } else {
+ throw new NumberFormatException();
+ }
+ if ((red < 0.0 || red > 1.0) || (green < 0.0 || green > 1.0)
+ || (blue < 0.0 || blue > 1.0)) {
+ throw new PropertyException("Color values out of range");
+ }
+ } else {
+ throw new NullPointerException();
+ }
+ } catch (Exception e) {
+ throw new PropertyException("Unknown color format: " + value);
+ }
+ return new Color(red, green, blue);
+ }
+
+ /**
+ * Parse a color given with the rgb() function.
+ *
+ * @param value
+ * the complete line
+ * @return a color if possible
+ * @throws PropertyException
+ * if the format is wrong.
+ */
+ private static Color parseAsRGB(String value) throws PropertyException {
+ Color parsedColor;
+ int poss = value.indexOf("(");
+ int pose = value.indexOf(")");
+ if (poss != -1 && pose != -1) {
+ value = value.substring(poss + 1, pose);
+ StringTokenizer st = new StringTokenizer(value, ",");
+ try {
+ float red = 0.0f, green = 0.0f, blue = 0.0f;
+ if (st.hasMoreTokens()) {
+ String str = st.nextToken().trim();
+ if (str.endsWith("%")) {
+ red = Float.parseFloat(str.substring(0,
+ str.length() - 1)) / 100.0f;
+ } else {
+ red = Float.parseFloat(str) / 255f;
+ }
+ }
+ if (st.hasMoreTokens()) {
+ String str = st.nextToken().trim();
+ if (str.endsWith("%")) {
+ green = Float.parseFloat(str.substring(0,
+ str.length() - 1)) / 100.0f;
+ } else {
+ green = Float.parseFloat(str) / 255f;
+ }
+ }
+ if (st.hasMoreTokens()) {
+ String str = st.nextToken().trim();
+ if (str.endsWith("%")) {
+ blue = Float.parseFloat(str.substring(0,
+ str.length() - 1)) / 100.0f;
+ } else {
+ blue = Float.parseFloat(str) / 255f;
+ }
+ }
+ if ((red < 0.0 || red > 1.0) || (green < 0.0 || green > 1.0)
+ || (blue < 0.0 || blue > 1.0)) {
+ throw new PropertyException("Color values out of range");
+ }
+ parsedColor = new Color(red, green, blue);
+ } catch (Exception e) {
+ throw new PropertyException(
+ "Arguments to rgb() must be [0..255] or [0%..100%]");
+ }
+ } else {
+ throw new PropertyException("Unknown color format: " + value
+ + ". Must be rgb(r,g,b)");
+ }
+ return parsedColor;
+ }
+
+ /**
+ * parse a color given in the #.... format.
+ *
+ * @param value
+ * the complete line
+ * @return a color if possible
+ * @throws PropertyException
+ * if the format is wrong.
+ */
+ private static Color parseWithHash(String value) throws PropertyException {
+ Color parsedColor = null;
+ try {
+ int len = value.length();
+ if ((len >= 4) && (len <= 5)) {
+ // note: divide by 15 so F = FF = 1 and so on
+ float red = Integer.parseInt(value.substring(1, 2), 16) / 15f;
+ float green = Integer.parseInt(value.substring(2, 3), 16) / 15f;
+ float blue = Integer.parseInt(value.substring(3, 4), 16) / 15f;
+ float alpha = 1.0f;
+ if (len == 5) {
+ alpha = Integer.parseInt(value.substring(4), 16) / 15f;
+ }
+ parsedColor = new Color(red, green, blue, alpha);
+ } else if ((len == 7) || (len == 9)) {
+ int red = Integer.parseInt(value.substring(1, 3), 16);
+ int green = Integer.parseInt(value.substring(3, 5), 16);
+ int blue = Integer.parseInt(value.substring(5, 7), 16);
+ int alpha = 255;
+ if (len == 9) {
+ alpha = Integer.parseInt(value.substring(7), 16);
+ }
+ parsedColor = new Color(red, green, blue, alpha);
+ } else {
+ throw new NumberFormatException();
+ }
+ } catch (NumberFormatException e) {
+ throw new PropertyException("Unknown color format: " + value
+ + ". Must be #RGB. #RGBA, #RRGGBB, or #RRGGBBAA");
+ }
+ return parsedColor;
+ }
+
+ /**
+ * Creates a re-parsable string representation of the given color.
+ * <p>
+ * First, the color will be converted into the sRGB colorspace. It will then
+ * be printed as #rrggbb, or as #rrrggbbaa if an alpha value is present.
+ *
+ * @param color
+ * the color to represent.
+ * @return a re-parsable string representadion.
+ */
+ public static String colorTOsRGBString(Color color) {
+ StringBuffer sbuf = new StringBuffer(10);
+ sbuf.append('#');
+ String s = Integer.toHexString(color.getRed());
+ if (s.length() == 1) {
+ sbuf.append('0');
+ }
+ sbuf.append(s);
+ s = Integer.toHexString(color.getGreen());
+ if (s.length() == 1) {
+ sbuf.append('0');
+ }
+ sbuf.append(s);
+ s = Integer.toHexString(color.getBlue());
+ if (s.length() == 1) {
+ sbuf.append('0');
+ }
+ sbuf.append(s);
+ if (color.getAlpha() != 255) {
+ s = Integer.toHexString(color.getAlpha());
+ if (s.length() == 1) {
+ sbuf.append('0');
+ }
+ sbuf.append(s);
+ }
+ return sbuf.toString();
+
+ }
+
+ /**
+ * Initializes the colorMap with some predefined values.
+ */
+ private static void initializeColorMap() {
+ colorMap = Collections.synchronizedMap(new java.util.HashMap());
+
+ colorMap.put("aliceblue", new Color(240, 248, 255));
+ colorMap.put("antiquewhite", new Color(250, 235, 215));
+ colorMap.put("aqua", new Color(0, 255, 255));
+ colorMap.put("aquamarine", new Color(127, 255, 212));
+ colorMap.put("azure", new Color(240, 255, 255));
+ colorMap.put("beige", new Color(245, 245, 220));
+ colorMap.put("bisque", new Color(255, 228, 196));
+ colorMap.put("black", new Color(0, 0, 0));
+ colorMap.put("blanchedalmond", new Color(255, 235, 205));
+ colorMap.put("blue", new Color(0, 0, 255));
+ colorMap.put("blueviolet", new Color(138, 43, 226));
+ colorMap.put("brown", new Color(165, 42, 42));
+ colorMap.put("burlywood", new Color(222, 184, 135));
+ colorMap.put("cadetblue", new Color(95, 158, 160));
+ colorMap.put("chartreuse", new Color(127, 255, 0));
+ colorMap.put("chocolate", new Color(210, 105, 30));
+ colorMap.put("coral", new Color(255, 127, 80));
+ colorMap.put("cornflowerblue", new Color(100, 149, 237));
+ colorMap.put("cornsilk", new Color(255, 248, 220));
+ colorMap.put("crimson", new Color(220, 20, 60));
+ colorMap.put("cyan", new Color(0, 255, 255));
+ colorMap.put("darkblue", new Color(0, 0, 139));
+ colorMap.put("darkcyan", new Color(0, 139, 139));
+ colorMap.put("darkgoldenrod", new Color(184, 134, 11));
+ colorMap.put("darkgray", new Color(169, 169, 169));
+ colorMap.put("darkgreen", new Color(0, 100, 0));
+ colorMap.put("darkgrey", new Color(169, 169, 169));
+ colorMap.put("darkkhaki", new Color(189, 183, 107));
+ colorMap.put("darkmagenta", new Color(139, 0, 139));
+ colorMap.put("darkolivegreen", new Color(85, 107, 47));
+ colorMap.put("darkorange", new Color(255, 140, 0));
+ colorMap.put("darkorchid", new Color(153, 50, 204));
+ colorMap.put("darkred", new Color(139, 0, 0));
+ colorMap.put("darksalmon", new Color(233, 150, 122));
+ colorMap.put("darkseagreen", new Color(143, 188, 143));
+ colorMap.put("darkslateblue", new Color(72, 61, 139));
+ colorMap.put("darkslategray", new Color(47, 79, 79));
+ colorMap.put("darkslategrey", new Color(47, 79, 79));
+ colorMap.put("darkturquoise", new Color(0, 206, 209));
+ colorMap.put("darkviolet", new Color(148, 0, 211));
+ colorMap.put("deeppink", new Color(255, 20, 147));
+ colorMap.put("deepskyblue", new Color(0, 191, 255));
+ colorMap.put("dimgray", new Color(105, 105, 105));
+ colorMap.put("dimgrey", new Color(105, 105, 105));
+ colorMap.put("dodgerblue", new Color(30, 144, 255));
+ colorMap.put("firebrick", new Color(178, 34, 34));
+ colorMap.put("floralwhite", new Color(255, 250, 240));
+ colorMap.put("forestgreen", new Color(34, 139, 34));
+ colorMap.put("fuchsia", new Color(255, 0, 255));
+ colorMap.put("gainsboro", new Color(220, 220, 220));
+ colorMap.put("ghostwhite", new Color(248, 248, 255));
+ colorMap.put("gold", new Color(255, 215, 0));
+ colorMap.put("goldenrod", new Color(218, 165, 32));
+ colorMap.put("gray", new Color(128, 128, 128));
+ colorMap.put("green", new Color(0, 128, 0));
+ colorMap.put("greenyellow", new Color(173, 255, 47));
+ colorMap.put("grey", new Color(128, 128, 128));
+ colorMap.put("honeydew", new Color(240, 255, 240));
+ colorMap.put("hotpink", new Color(255, 105, 180));
+ colorMap.put("indianred", new Color(205, 92, 92));
+ colorMap.put("indigo", new Color(75, 0, 130));
+ colorMap.put("ivory", new Color(255, 255, 240));
+ colorMap.put("khaki", new Color(240, 230, 140));
+ colorMap.put("lavender", new Color(230, 230, 250));
+ colorMap.put("lavenderblush", new Color(255, 240, 245));
+ colorMap.put("lawngreen", new Color(124, 252, 0));
+ colorMap.put("lemonchiffon", new Color(255, 250, 205));
+ colorMap.put("lightblue", new Color(173, 216, 230));
+ colorMap.put("lightcoral", new Color(240, 128, 128));
+ colorMap.put("lightcyan", new Color(224, 255, 255));
+ colorMap.put("lightgoldenrodyellow", new Color(250, 250, 210));
+ colorMap.put("lightgray", new Color(211, 211, 211));
+ colorMap.put("lightgreen", new Color(144, 238, 144));
+ colorMap.put("lightgrey", new Color(211, 211, 211));
+ colorMap.put("lightpink", new Color(255, 182, 193));
+ colorMap.put("lightsalmon", new Color(255, 160, 122));
+ colorMap.put("lightseagreen", new Color(32, 178, 170));
+ colorMap.put("lightskyblue", new Color(135, 206, 250));
+ colorMap.put("lightslategray", new Color(119, 136, 153));
+ colorMap.put("lightslategrey", new Color(119, 136, 153));
+ colorMap.put("lightsteelblue", new Color(176, 196, 222));
+ colorMap.put("lightyellow", new Color(255, 255, 224));
+ colorMap.put("lime", new Color(0, 255, 0));
+ colorMap.put("limegreen", new Color(50, 205, 50));
+ colorMap.put("linen", new Color(250, 240, 230));
+ colorMap.put("magenta", new Color(255, 0, 255));
+ colorMap.put("maroon", new Color(128, 0, 0));
+ colorMap.put("mediumaquamarine", new Color(102, 205, 170));
+ colorMap.put("mediumblue", new Color(0, 0, 205));
+ colorMap.put("mediumorchid", new Color(186, 85, 211));
+ colorMap.put("mediumpurple", new Color(147, 112, 219));
+ colorMap.put("mediumseagreen", new Color(60, 179, 113));
+ colorMap.put("mediumslateblue", new Color(123, 104, 238));
+ colorMap.put("mediumspringgreen", new Color(0, 250, 154));
+ colorMap.put("mediumturquoise", new Color(72, 209, 204));
+ colorMap.put("mediumvioletred", new Color(199, 21, 133));
+ colorMap.put("midnightblue", new Color(25, 25, 112));
+ colorMap.put("mintcream", new Color(245, 255, 250));
+ colorMap.put("mistyrose", new Color(255, 228, 225));
+ colorMap.put("moccasin", new Color(255, 228, 181));
+ colorMap.put("navajowhite", new Color(255, 222, 173));
+ colorMap.put("navy", new Color(0, 0, 128));
+ colorMap.put("oldlace", new Color(253, 245, 230));
+ colorMap.put("olive", new Color(128, 128, 0));
+ colorMap.put("olivedrab", new Color(107, 142, 35));
+ colorMap.put("orange", new Color(255, 165, 0));
+ colorMap.put("orangered", new Color(255, 69, 0));
+ colorMap.put("orchid", new Color(218, 112, 214));
+ colorMap.put("palegoldenrod", new Color(238, 232, 170));
+ colorMap.put("palegreen", new Color(152, 251, 152));
+ colorMap.put("paleturquoise", new Color(175, 238, 238));
+ colorMap.put("palevioletred", new Color(219, 112, 147));
+ colorMap.put("papayawhip", new Color(255, 239, 213));
+ colorMap.put("peachpuff", new Color(255, 218, 185));
+ colorMap.put("peru", new Color(205, 133, 63));
+ colorMap.put("pink", new Color(255, 192, 203));
+ colorMap.put("plum ", new Color(221, 160, 221));
+ colorMap.put("plum", new Color(221, 160, 221));
+ colorMap.put("powderblue", new Color(176, 224, 230));
+ colorMap.put("purple", new Color(128, 0, 128));
+ colorMap.put("red", new Color(255, 0, 0));
+ colorMap.put("rosybrown", new Color(188, 143, 143));
+ colorMap.put("royalblue", new Color(65, 105, 225));
+ colorMap.put("saddlebrown", new Color(139, 69, 19));
+ colorMap.put("salmon", new Color(250, 128, 114));
+ colorMap.put("sandybrown", new Color(244, 164, 96));
+ colorMap.put("seagreen", new Color(46, 139, 87));
+ colorMap.put("seashell", new Color(255, 245, 238));
+ colorMap.put("sienna", new Color(160, 82, 45));
+ colorMap.put("silver", new Color(192, 192, 192));
+ colorMap.put("skyblue", new Color(135, 206, 235));
+ colorMap.put("slateblue", new Color(106, 90, 205));
+ colorMap.put("slategray", new Color(112, 128, 144));
+ colorMap.put("slategrey", new Color(112, 128, 144));
+ colorMap.put("snow", new Color(255, 250, 250));
+ colorMap.put("springgreen", new Color(0, 255, 127));
+ colorMap.put("steelblue", new Color(70, 130, 180));
+ colorMap.put("tan", new Color(210, 180, 140));
+ colorMap.put("teal", new Color(0, 128, 128));
+ colorMap.put("thistle", new Color(216, 191, 216));
+ colorMap.put("tomato", new Color(255, 99, 71));
+ colorMap.put("turquoise", new Color(64, 224, 208));
+ colorMap.put("violet", new Color(238, 130, 238));
+ colorMap.put("wheat", new Color(245, 222, 179));
+ colorMap.put("white", new Color(255, 255, 255));
+ colorMap.put("whitesmoke", new Color(245, 245, 245));
+ colorMap.put("yellow", new Color(255, 255, 0));
+ colorMap.put("yellowgreen", new Color(154, 205, 50));
+
+ colorMap.put("transparent", new Color(0, 0, 0, 0));
+ }
+
+}
package org.apache.fop.render.afp;
import java.awt.Color;
-import org.apache.fop.datatypes.ColorType;
/**
* AFP only supports very basic colours and this object provides a simple
* bean for the colour attributes.
- *
+ * @todo Is this class really necessary? Should be replaced with java.awt.Color, if possible.
*/
public class AFPFontColor {
}
- /**
- * Constructor for the AFPColor Object
- * @param col the org.apache.fop.datatypes.ColorType object
- */
- public AFPFontColor(ColorType col) {
-
- _red = (int)(col.getRed() * 255);
- _green = (int)(col.getGreen() * 255);
- _blue = (int)(col.getBlue() * 255);
-
- }
-
/**
* Constructor for the AFPColor Object
* @param col The java.awt.Color object
import org.apache.fop.area.inline.SpaceArea;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.WordArea;
-import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExtensionAttachment;
import org.apache.fop.fonts.FontInfo;
/**
* Draw a border segment of an XSL-FO style border.
* @see org.apache.fop.render.AbstractRenderer#drawBorderLine(float, float, float, float,
- * boolean, boolean, int, ColorType)
+ * boolean, boolean, int, Color)
*/
public void drawBorderLine(float x1, float y1, float x2, float y2,
- boolean horz, boolean startOrBefore, int style, ColorType col) {
+ boolean horz, boolean startOrBefore, int style, Color col) {
float w = x2 - x1;
float h = y2 - y1;
if ((w < 0) || (h < 0)) {
case Constants.EN_RIDGE:
{
float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
- Color c = toColor(col);
if (horz) {
- Color uppercol = lightenColor(c, -colFactor);
- Color lowercol = lightenColor(c, colFactor);
+ Color uppercol = lightenColor(col, -colFactor);
+ Color lowercol = lightenColor(col, colFactor);
float h3 = h / 3;
float ym1 = y1;
_afpDataStream.createLine(
pts2units(x2),
pts2units(ym1 + h3),
pts2units(h3),
- new AFPFontColor(c)
+ new AFPFontColor(col)
);
_afpDataStream.createLine(
pts2units(x1),
new AFPFontColor(lowercol)
);
} else {
- Color leftcol = lightenColor(c, -colFactor);
- Color rightcol = lightenColor(c, colFactor);
+ Color leftcol = lightenColor(col, -colFactor);
+ Color rightcol = lightenColor(col, colFactor);
float w3 = w / 3;
float xm1 = x1 + (w3 / 2);
_afpDataStream.createLine(
pts2units(xm1 + w3),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(c)
+ new AFPFontColor(col)
);
_afpDataStream.createLine(
pts2units(xm1 + w3 + w3),
/**
* Establishes a new foreground or fill color.
- * @see org.apache.fop.render.AbstractRenderer#updateColor(ColorType, boolean)
+ * @see org.apache.fop.render.AbstractRenderer#updateColor(Color, boolean)
*/
- public void updateColor(ColorType col, boolean fill) {
+ public void updateColor(Color col, boolean fill) {
if (fill) {
_currentColor = new AFPFontColor(col);
}
AFPFont tf = (AFPFont) fontInfo.getFonts().get(name);
_currentFontFamily = name;
- ColorType ct = (ColorType) ch.getTrait(Trait.COLOR);
+ Color col = (Color) ch.getTrait(Trait.COLOR);
int vsci = mpts2units(tf.getWidth(' ', _currentFontSize) / 1000
+ ch.getTextWordSpaceAdjust()
afpFontAttributes.getFontReference(),
mpts2units(rx),
mpts2units(bl),
- new AFPFontColor(ct),
+ new AFPFontColor(col),
vsci,
mpts2units(ch.getTextLetterSpaceAdjust()),
worddata.getBytes(encoding));
_currentFontSize = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue();
AFPFont tf = (AFPFont) fontInfo.getFonts().get(name);
- ColorType ct = (ColorType) text.getTrait(Trait.COLOR);
+ Color col = (Color) text.getTrait(Trait.COLOR);
int vsci = mpts2units(tf.getWidth(' ', _currentFontSize) / 1000
+ text.getTextWordSpaceAdjust()
afpFontAttributes.getFontReference(),
mpts2units(rx),
mpts2units(bl),
- new AFPFontColor(ct),
+ new AFPFontColor(col),
vsci,
mpts2units(text.getTextLetterSpaceAdjust()),
worddata.getBytes(encoding));
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:
package org.apache.fop.render.pcl;
//Java
+import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import org.apache.fop.area.CTM;
import org.apache.fop.area.PageViewport;
import org.apache.fop.area.Trait;
-import org.apache.fop.area.Trait.Color;
import org.apache.fop.area.inline.AbstractTextArea;
import org.apache.fop.area.inline.ForeignObject;
import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.WordArea;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontSetup;
import org.apache.fop.image.EPSImage;
import org.apache.fop.image.FopImage;
import org.apache.fop.image.ImageFactory;
if (col != null) {
//useColor(ct);
gen.setPatternTransparencyMode(false);
- gen.selectCurrentPattern(gen.convertToPCLShade(col.getAWTColor()), 2);
+ gen.selectCurrentPattern(gen.convertToPCLShade(col), 2);
}
saveGraphicsState();
}
if (back.getColor() != null) {
- updateFillColor(back.getColor().getAWTColor());
+ updateFillColor(back.getColor());
fillRect(sx, sy, paddRectWidth, paddRectHeight);
}
float height = borderRect.height;
if (bpsBefore != null) {
int borderWidth = (int) Math.round((bpsBefore.width / 1000f));
- updateFillColor(bpsBefore.color.getAWTColor());
+ updateFillColor(bpsBefore.color);
fillRect((int) startx, (int) starty, (int) width,
borderWidth);
}
if (bpsAfter != null) {
int borderWidth = (int) Math.round((bpsAfter.width / 1000f));
- updateFillColor(bpsAfter.color.getAWTColor());
+ updateFillColor(bpsAfter.color);
fillRect((int) startx,
(int) (starty + height - borderWidth), (int) width,
borderWidth);
}
if (bpsStart != null) {
int borderWidth = (int) Math.round((bpsStart.width / 1000f));
- updateFillColor(bpsStart.color.getAWTColor());
+ updateFillColor(bpsStart.color);
fillRect((int) startx, (int) starty, borderWidth,
(int) height);
}
if (bpsEnd != null) {
int borderWidth = (int) Math.round((bpsEnd.width / 1000f));
- updateFillColor(bpsEnd.color.getAWTColor());
+ updateFillColor(bpsEnd.color);
fillRect((int) (startx + width - borderWidth),
(int) starty, borderWidth, (int) height);
}
Rectangle2D.Float lineRect = new Rectangle2D.Float(
sx1a, outery, ex1a - sx1a, innery - outery);
Java2DRenderer.drawBorderLine(lineRect, true, true,
- bpsBefore.style, toColor(bpsBefore.color), g);
+ bpsBefore.style, bpsBefore.color, g);
//restoreGraphicsState();
}
if (bpsEnd != null) {
Rectangle2D.Float lineRect = new Rectangle2D.Float(
innerx, sy1a, outerx - innerx, ey1a - sy1a);
Java2DRenderer.drawBorderLine(lineRect, false, false,
- bpsEnd.style, toColor(bpsEnd.color), g);
+ bpsEnd.style, bpsEnd.color, g);
//restoreGraphicsState();
}
if (bpsAfter != null) {
Rectangle2D.Float lineRect = new Rectangle2D.Float(
sx1a, innery, ex1a - sx1a, outery - innery);
Java2DRenderer.drawBorderLine(lineRect, true, false,
- bpsAfter.style, toColor(bpsAfter.color), g);
+ bpsAfter.style, bpsAfter.color, g);
//restoreGraphicsState();
}
if (bpsStart != null) {
Rectangle2D.Float lineRect = new Rectangle2D.Float(
outerx, sy1a, innerx - outerx, ey1a - sy1a);
Java2DRenderer.drawBorderLine(lineRect, false, false,
- bpsStart.style, toColor(bpsStart.color), g);
+ bpsStart.style, bpsStart.color, g);
//restoreGraphicsState();
}
}
<fo:block background-color="#0000ff">
Top Level Block: font-size="24pt" background-color="#0000ff"
<fo:block>
- <test:assert property="background-color" expected="#000000"/>
- Nested Block: background-color=default
+ <test:assert property="background-color" expected="#00000000"/>
+ Nested Block: background-color=default (transparent)
<fo:block background-color="from-nearest-specified-value()">
<test:assert property="background-color" expected="#0000ff"/>
Nested Block: background-color="from-nearest-specified-value()"
package org.apache.fop.traits;
-import org.apache.fop.area.Trait;
-import org.apache.fop.fo.Constants;
+import java.awt.Color;
import junit.framework.TestCase;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.util.ColorUtil;
+
/**
* Tests the BorderProps class.
*/
* @throws Exception if an error occurs
*/
public void testSerialization() throws Exception {
- Trait.Color col = new Trait.Color(1.0f, 1.0f, 0.5f, 1.0f);
+ Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f);
//Normalize: Avoid false alarms due to color conversion (rounding)
- col = Trait.Color.valueOf(col.toString());
+ col = ColorUtil.parseColorString(ColorUtil.colorTOsRGBString(col));
BorderProps b1 = new BorderProps(Constants.EN_DOUBLE, 1250,
col, BorderProps.COLLAPSE_OUTER);
package org.apache.fop.traits;
-import org.apache.fop.area.Trait;
+import java.awt.Color;
import junit.framework.TestCase;
+import org.apache.fop.util.ColorUtil;
+
/**
* Tests the Trait.Color class.
+ * TODO: This actually tests the ColorUtil class now.
*/
public class TraitColorTestCase extends TestCase {
* @throws Exception if an error occurs
*/
public void testSerialization() throws Exception {
- Trait.Color col = new Trait.Color(1.0f, 1.0f, 0.5f, 1.0f);
- String s = col.toString();
- assertEquals("#ffff7f", s);
+ Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f);
+ String s = ColorUtil.colorTOsRGBString(col);
+
+ //This is what the old color spit out. Now it is 80 due to rounding
+ //assertEquals("#ffff7f", s);
+ assertEquals("#ffff80", s);
- col = new Trait.Color(1.0f, 0.0f, 0.0f, 0.8f);
- s = col.toString();
+ col = new Color(1.0f, 0.0f, 0.0f, 0.8f);
+ s = ColorUtil.colorTOsRGBString(col);
assertEquals("#ff0000cc", s);
}
* @throws Exception if an error occurs
*/
public void testDeserialization() throws Exception {
- float tolerance = 0.5f / 255; //due to color value conversion
-
- Trait.Color col = Trait.Color.valueOf("#ffff7f");
- assertEquals(1.0f, col.getRed(), 0.0f);
- assertEquals(1.0f, col.getGreen(), 0.0f);
- assertEquals(0.5f, col.getBlue(), tolerance);
- assertEquals(1.0f, col.getAlpha(), 0.0f);
+ Color col = ColorUtil.parseColorString("#ffff7f");
+ assertEquals(255, col.getRed());
+ assertEquals(255, col.getGreen());
+ assertEquals(127, col.getBlue());
+ assertEquals(255, col.getAlpha());
- col = Trait.Color.valueOf("#ff0000cc");
- assertEquals(1.0f, col.getRed(), 0.0f);
- assertEquals(0.0f, col.getGreen(), 0.0f);
- assertEquals(0.0f, col.getBlue(), 0.0f);
- assertEquals(0.8f, col.getAlpha(), tolerance);
+ col = ColorUtil.parseColorString("#ff0000cc");
+ assertEquals(255, col.getRed());
+ assertEquals(0, col.getGreen());
+ assertEquals(0, col.getBlue());
+ assertEquals(204, col.getAlpha());
}
/**
* @throws Exception if an error occurs
*/
public void testEquals() throws Exception {
- Trait.Color col1 = Trait.Color.valueOf("#ff0000cc");
- Trait.Color col2 = Trait.Color.valueOf("#ff0000cc");
+ Color col1 = ColorUtil.parseColorString("#ff0000cc");
+ Color col2 = ColorUtil.parseColorString("#ff0000cc");
assertTrue(col1 != col2);
assertEquals(col1, col2);
}
</fo:root>
</fo>
<checks>
- <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=136960,vertical=136960" xpath="//regionViewport/@background"/>
- <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=56960" xpath="//flow/block[1]/@background"/>
- <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=-8640" xpath="//flow/block[1]/block[1]/block[1]/@background"/>
+ <eval expected="url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=136960,vertical=136960" xpath="//regionViewport/@background"/>
+ <eval expected="url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=56960" xpath="//flow/block[1]/@background"/>
+ <eval expected="url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=-8640" xpath="//flow/block[1]/block[1]/block[1]/@background"/>
</checks>
</testcase>