diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-12-20 12:53:50 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-12-20 12:53:50 +0000 |
commit | 16890a0b27db4e7f9f712b9fb18fbf7b27f7931c (patch) | |
tree | b07fc45607fb4de91b778866487909336422ca46 /src/java/org/apache/fop/area/Trait.java | |
parent | 6e70a0073ae05ec5e71e81e4290c86a39d2e4afe (diff) | |
download | xmlgraphics-fop-16890a0b27db4e7f9f712b9fb18fbf7b27f7931c.tar.gz xmlgraphics-fop-16890a0b27db4e7f9f712b9fb18fbf7b27f7931c.zip |
First step towards reactivating CachedRenderPagesModel (helps preparing for the intermediate format).
Fix some serialization problems in the area tree.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@357982 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/area/Trait.java')
-rw-r--r-- | src/java/org/apache/fop/area/Trait.java | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java index 249b170cf..a576ede6e 100644 --- a/src/java/org/apache/fop/area/Trait.java +++ b/src/java/org/apache/fop/area/Trait.java @@ -423,6 +423,79 @@ public class Trait implements Serializable { } /** + * 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 instanceof Serializable) { + return col; + } else { + return new Color(col); + } + } + + } + + /** * Background trait structure. * Used for storing back trait information which are related. */ @@ -499,7 +572,7 @@ public class Trait implements Serializable { * @param color The color to set */ public void setColor(ColorType color) { - this.color = color; + this.color = Color.makeSerializable(color); } /** |