diff options
author | Jeremias Maerki <jeremias@apache.org> | 2006-05-03 07:21:02 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2006-05-03 07:21:02 +0000 |
commit | 6e9e6775bd5c5d16550ba64b7666eda6ed382d44 (patch) | |
tree | b0ce141fdbd4d4499ea1ed4994fa9c5bb4b46bd2 /src/sandbox | |
parent | 3fd99265691afe51eeccd10ecf704148eaaca669 (diff) | |
download | xmlgraphics-fop-6e9e6775bd5c5d16550ba64b7666eda6ed382d44.tar.gz xmlgraphics-fop-6e9e6775bd5c5d16550ba64b7666eda6ed382d44.zip |
Bugzilla #38946:
First step for improved color handling. FOP's own ColorType was replaced with java.awt.Color throughout the codebase.
Submitted by: Max Berger <max.at.berger.name>
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@399185 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/sandbox')
3 files changed, 27 insertions, 43 deletions
diff --git a/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java b/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java index be3f678e3..d7cfad229 100644 --- a/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java +++ b/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java @@ -19,12 +19,11 @@ package org.apache.fop.render.afp; import java.awt.Color; -import org.apache.fop.datatypes.ColorType; /** * AFP only supports very basic colours and this object provides a simple * bean for the colour attributes. - * + * @todo Is this class really necessary? Should be replaced with java.awt.Color, if possible. */ public class AFPFontColor { @@ -59,18 +58,6 @@ 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 */ public AFPFontColor(Color col) { diff --git a/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java b/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java index 9cee8d121..b0839aa6d 100644 --- a/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java @@ -50,7 +50,6 @@ import org.apache.fop.area.inline.Image; import org.apache.fop.area.inline.SpaceArea; import org.apache.fop.area.inline.TextArea; import org.apache.fop.area.inline.WordArea; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.Constants; import org.apache.fop.fo.extensions.ExtensionAttachment; import org.apache.fop.fonts.FontInfo; @@ -862,10 +861,10 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** * Draw a border segment of an XSL-FO style border. * @see org.apache.fop.render.AbstractRenderer#drawBorderLine(float, float, float, float, - * boolean, boolean, int, ColorType) + * boolean, boolean, int, Color) */ public void drawBorderLine(float x1, float y1, float x2, float y2, - boolean horz, boolean startOrBefore, int style, ColorType col) { + boolean horz, boolean startOrBefore, int style, Color col) { float w = x2 - x1; float h = y2 - y1; if ((w < 0) || (h < 0)) { @@ -976,10 +975,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { case Constants.EN_RIDGE: { float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f); - Color c = toColor(col); if (horz) { - Color uppercol = lightenColor(c, -colFactor); - Color lowercol = lightenColor(c, colFactor); + Color uppercol = lightenColor(col, -colFactor); + Color lowercol = lightenColor(col, colFactor); float h3 = h / 3; float ym1 = y1; _afpDataStream.createLine( @@ -996,7 +994,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { pts2units(x2), pts2units(ym1 + h3), pts2units(h3), - new AFPFontColor(c) + new AFPFontColor(col) ); _afpDataStream.createLine( pts2units(x1), @@ -1007,8 +1005,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { new AFPFontColor(lowercol) ); } else { - Color leftcol = lightenColor(c, -colFactor); - Color rightcol = lightenColor(c, colFactor); + Color leftcol = lightenColor(col, -colFactor); + Color rightcol = lightenColor(col, colFactor); float w3 = w / 3; float xm1 = x1 + (w3 / 2); _afpDataStream.createLine( @@ -1025,7 +1023,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { pts2units(xm1 + w3), pts2units(y2), pts2units(w3), - new AFPFontColor(c) + new AFPFontColor(col) ); _afpDataStream.createLine( pts2units(xm1 + w3 + w3), @@ -1192,9 +1190,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** * Establishes a new foreground or fill color. - * @see org.apache.fop.render.AbstractRenderer#updateColor(ColorType, boolean) + * @see org.apache.fop.render.AbstractRenderer#updateColor(Color, boolean) */ - public void updateColor(ColorType col, boolean fill) { + public void updateColor(Color col, boolean fill) { if (fill) { _currentColor = new AFPFontColor(col); } @@ -1255,7 +1253,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { AFPFont tf = (AFPFont) fontInfo.getFonts().get(name); _currentFontFamily = name; - ColorType ct = (ColorType) ch.getTrait(Trait.COLOR); + Color col = (Color) ch.getTrait(Trait.COLOR); int vsci = mpts2units(tf.getWidth(' ', _currentFontSize) / 1000 + ch.getTextWordSpaceAdjust() @@ -1309,7 +1307,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { afpFontAttributes.getFontReference(), mpts2units(rx), mpts2units(bl), - new AFPFontColor(ct), + new AFPFontColor(col), vsci, mpts2units(ch.getTextLetterSpaceAdjust()), worddata.getBytes(encoding)); @@ -1338,7 +1336,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { _currentFontSize = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); AFPFont tf = (AFPFont) fontInfo.getFonts().get(name); - ColorType ct = (ColorType) text.getTrait(Trait.COLOR); + Color col = (Color) text.getTrait(Trait.COLOR); int vsci = mpts2units(tf.getWidth(' ', _currentFontSize) / 1000 + text.getTextWordSpaceAdjust() @@ -1392,7 +1390,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { afpFontAttributes.getFontReference(), mpts2units(rx), mpts2units(bl), - new AFPFontColor(ct), + new AFPFontColor(col), vsci, mpts2units(text.getTextLetterSpaceAdjust()), worddata.getBytes(encoding)); @@ -1452,7 +1450,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { 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: diff --git a/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java b/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java index 3cab4d63f..903d3eec7 100644 --- a/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/sandbox/org/apache/fop/render/pcl/PCLRenderer.java @@ -19,6 +19,7 @@ package org.apache.fop.render.pcl; //Java +import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Rectangle; @@ -58,7 +59,6 @@ import org.apache.fop.area.BlockViewport; import org.apache.fop.area.CTM; import org.apache.fop.area.PageViewport; import org.apache.fop.area.Trait; -import org.apache.fop.area.Trait.Color; import org.apache.fop.area.inline.AbstractTextArea; import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.Image; @@ -68,7 +68,6 @@ import org.apache.fop.area.inline.TextArea; import org.apache.fop.area.inline.WordArea; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontSetup; import org.apache.fop.image.EPSImage; import org.apache.fop.image.FopImage; import org.apache.fop.image.ImageFactory; @@ -410,7 +409,7 @@ public class PCLRenderer extends PrintRenderer { if (col != null) { //useColor(ct); gen.setPatternTransparencyMode(false); - gen.selectCurrentPattern(gen.convertToPCLShade(col.getAWTColor()), 2); + gen.selectCurrentPattern(gen.convertToPCLShade(col), 2); } saveGraphicsState(); @@ -897,7 +896,7 @@ public class PCLRenderer extends PrintRenderer { } if (back.getColor() != null) { - updateFillColor(back.getColor().getAWTColor()); + updateFillColor(back.getColor()); fillRect(sx, sy, paddRectWidth, paddRectHeight); } @@ -997,26 +996,26 @@ public class PCLRenderer extends PrintRenderer { float height = borderRect.height; if (bpsBefore != null) { int borderWidth = (int) Math.round((bpsBefore.width / 1000f)); - updateFillColor(bpsBefore.color.getAWTColor()); + updateFillColor(bpsBefore.color); fillRect((int) startx, (int) starty, (int) width, borderWidth); } if (bpsAfter != null) { int borderWidth = (int) Math.round((bpsAfter.width / 1000f)); - updateFillColor(bpsAfter.color.getAWTColor()); + updateFillColor(bpsAfter.color); fillRect((int) startx, (int) (starty + height - borderWidth), (int) width, borderWidth); } if (bpsStart != null) { int borderWidth = (int) Math.round((bpsStart.width / 1000f)); - updateFillColor(bpsStart.color.getAWTColor()); + updateFillColor(bpsStart.color); fillRect((int) startx, (int) starty, borderWidth, (int) height); } if (bpsEnd != null) { int borderWidth = (int) Math.round((bpsEnd.width / 1000f)); - updateFillColor(bpsEnd.color.getAWTColor()); + updateFillColor(bpsEnd.color); fillRect((int) (startx + width - borderWidth), (int) starty, borderWidth, (int) height); } @@ -1126,7 +1125,7 @@ public class PCLRenderer extends PrintRenderer { Rectangle2D.Float lineRect = new Rectangle2D.Float( sx1a, outery, ex1a - sx1a, innery - outery); Java2DRenderer.drawBorderLine(lineRect, true, true, - bpsBefore.style, toColor(bpsBefore.color), g); + bpsBefore.style, bpsBefore.color, g); //restoreGraphicsState(); } if (bpsEnd != null) { @@ -1165,7 +1164,7 @@ public class PCLRenderer extends PrintRenderer { Rectangle2D.Float lineRect = new Rectangle2D.Float( innerx, sy1a, outerx - innerx, ey1a - sy1a); Java2DRenderer.drawBorderLine(lineRect, false, false, - bpsEnd.style, toColor(bpsEnd.color), g); + bpsEnd.style, bpsEnd.color, g); //restoreGraphicsState(); } if (bpsAfter != null) { @@ -1204,7 +1203,7 @@ public class PCLRenderer extends PrintRenderer { Rectangle2D.Float lineRect = new Rectangle2D.Float( sx1a, innery, ex1a - sx1a, outery - innery); Java2DRenderer.drawBorderLine(lineRect, true, false, - bpsAfter.style, toColor(bpsAfter.color), g); + bpsAfter.style, bpsAfter.color, g); //restoreGraphicsState(); } if (bpsStart != null) { @@ -1243,7 +1242,7 @@ public class PCLRenderer extends PrintRenderer { 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(); } } |