From 887b2f5c3c425b4eeed4094dae38f0c4d53ac121 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Wed, 20 Aug 2008 13:00:43 +0000 Subject: [PATCH] Merged revisions 685918,687305 via svnmerge from https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r685918 | jeremias | 2008-08-14 15:32:28 +0100 (Thu, 14 Aug 2008) | 1 line Wasn't an NPE, but actually a division by zero. ........ r687305 | acumiskey | 2008-08-20 13:59:11 +0100 (Wed, 20 Aug 2008) | 2 lines Moved mptToPt() and ptToMpt() from AbstractRenderer to UnitConv. One less dependency to worry about. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@687307 13f79535-47bb-0310-9956-ffa450edef68 --- .../render/AbstractPathOrientedRenderer.java | 11 +++---- .../apache/fop/render/AbstractRenderer.java | 29 ------------------ .../apache/fop/render/pcl/PCLRenderer.java | 12 ++++---- .../apache/fop/render/txt/TXTRenderer.java | 3 +- src/java/org/apache/fop/util/UnitConv.java | 30 +++++++++++++++++++ status.xml | 2 +- 6 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index 7bd470915..f1ba11937 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -48,6 +48,7 @@ import org.apache.fop.fo.Constants; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fonts.FontMetrics; import org.apache.fop.traits.BorderProps; +import org.apache.fop.util.UnitConv; /** * Abstract base class for renderers like PDF and PostScript where many painting operations @@ -519,7 +520,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { saveGraphicsState(); //Viewport position - concatenateTransformationMatrix(mptToPt(positionTransform)); + concatenateTransformationMatrix(UnitConv.mptToPt(positionTransform)); //Background and borders float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f; @@ -529,7 +530,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { //Shift to content rectangle after border painting AffineTransform contentRectTransform = new AffineTransform(); contentRectTransform.translate(borderPaddingStart, borderPaddingBefore); - concatenateTransformationMatrix(mptToPt(contentRectTransform)); + concatenateTransformationMatrix(UnitConv.mptToPt(contentRectTransform)); //Clipping if (bv.getClip()) { @@ -539,7 +540,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { saveGraphicsState(); //Set up coordinate system for content rectangle AffineTransform contentTransform = ctm.toAffineTransform(); - concatenateTransformationMatrix(mptToPt(contentTransform)); + concatenateTransformationMatrix(UnitConv.mptToPt(contentTransform)); currentIPPosition = 0; currentBPPosition = 0; @@ -603,7 +604,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { if (!at.isIdentity()) { saveGraphicsState(); - concatenateTransformationMatrix(mptToPt(at)); + concatenateTransformationMatrix(UnitConv.mptToPt(at)); } currentIPPosition = 0; @@ -636,7 +637,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { if (!at.isIdentity()) { saveGraphicsState(); - concatenateTransformationMatrix(mptToPt(at)); + concatenateTransformationMatrix(UnitConv.mptToPt(at)); } currentIPPosition = 0; diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index e80775890..c29dbea15 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -21,7 +21,6 @@ package org.apache.fop.render; // Java import java.awt.Rectangle; -import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.OutputStream; @@ -836,32 +835,4 @@ public abstract class AbstractRenderer public String getMimeType() { return null; } - - /** - * Converts a millipoint-based transformation matrix to points. - * @param at a millipoint-based transformation matrix - * @return a point-based transformation matrix - */ - protected AffineTransform mptToPt(AffineTransform at) { - double[] matrix = new double[6]; - at.getMatrix(matrix); - //Convert to points - matrix[4] = matrix[4] / 1000; - matrix[5] = matrix[5] / 1000; - return new AffineTransform(matrix); - } - - /** - * Converts a point-based transformation matrix to millipoints. - * @param at a point-based transformation matrix - * @return a millipoint-based transformation matrix - */ - protected AffineTransform ptToMpt(AffineTransform at) { - double[] matrix = new double[6]; - at.getMatrix(matrix); - //Convert to millipoints - matrix[4] = matrix[4] * 1000; - matrix[5] = matrix[5] * 1000; - return new AffineTransform(matrix); - } } diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java index ff7a13ee8..4385ea1f2 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java @@ -968,7 +968,7 @@ public class PCLRenderer extends PrintRenderer { saveGraphicsState(); //Viewport position - concatenateTransformationMatrix(mptToPt(positionTransform)); + concatenateTransformationMatrix(UnitConv.mptToPt(positionTransform)); //Background and borders float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f; @@ -978,7 +978,7 @@ public class PCLRenderer extends PrintRenderer { //Shift to content rectangle after border painting AffineTransform contentRectTransform = new AffineTransform(); contentRectTransform.translate(borderPaddingStart, borderPaddingBefore); - concatenateTransformationMatrix(mptToPt(contentRectTransform)); + concatenateTransformationMatrix(UnitConv.mptToPt(contentRectTransform)); //Clipping if (bv.getClip()) { @@ -988,7 +988,7 @@ public class PCLRenderer extends PrintRenderer { saveGraphicsState(); //Set up coordinate system for content rectangle AffineTransform contentTransform = ctm.toAffineTransform(); - concatenateTransformationMatrix(mptToPt(contentTransform)); + concatenateTransformationMatrix(UnitConv.mptToPt(contentTransform)); currentIPPosition = 0; currentBPPosition = 0; @@ -1058,7 +1058,7 @@ public class PCLRenderer extends PrintRenderer { if (!at.isIdentity()) { saveGraphicsState(); - concatenateTransformationMatrix(mptToPt(at)); + concatenateTransformationMatrix(UnitConv.mptToPt(at)); } currentIPPosition = 0; @@ -1096,7 +1096,7 @@ public class PCLRenderer extends PrintRenderer { if (!at.isIdentity()) { saveGraphicsState(); - concatenateTransformationMatrix(mptToPt(at)); + concatenateTransformationMatrix(UnitConv.mptToPt(at)); } currentIPPosition = 0; @@ -1119,7 +1119,7 @@ public class PCLRenderer extends PrintRenderer { */ protected void concatenateTransformationMatrix(AffineTransform at) { if (!at.isIdentity()) { - graphicContext.transform(ptToMpt(at)); + graphicContext.transform(UnitConv.ptToMpt(at)); changePrintDirection(); } } diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java index 52c6912d4..29f1ef954 100644 --- a/src/java/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java @@ -37,6 +37,7 @@ import org.apache.fop.area.inline.TextArea; import org.apache.fop.render.AbstractPathOrientedRenderer; import org.apache.fop.render.txt.border.AbstractBorderElement; import org.apache.fop.render.txt.border.BorderManager; +import org.apache.fop.util.UnitConv; /** * Renderer that renders areas to plain text. @@ -570,7 +571,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ protected void concatenateTransformationMatrix(AffineTransform at) { - currentState.push(new CTM(ptToMpt(at))); + currentState.push(new CTM(UnitConv.ptToMpt(at))); } } diff --git a/src/java/org/apache/fop/util/UnitConv.java b/src/java/org/apache/fop/util/UnitConv.java index 8bf7274eb..475e3dcc0 100644 --- a/src/java/org/apache/fop/util/UnitConv.java +++ b/src/java/org/apache/fop/util/UnitConv.java @@ -19,6 +19,8 @@ package org.apache.fop.util; +import java.awt.geom.AffineTransform; + /** * Utility class for unit conversions. */ @@ -125,4 +127,32 @@ public final class UnitConv { return mpt2in(mpt) * resolution; } + /** + * Converts a millipoint-based transformation matrix to points. + * @param at a millipoint-based transformation matrix + * @return a point-based transformation matrix + */ + public static AffineTransform mptToPt(AffineTransform at) { + double[] matrix = new double[6]; + at.getMatrix(matrix); + //Convert to points + matrix[4] = matrix[4] / 1000; + matrix[5] = matrix[5] / 1000; + return new AffineTransform(matrix); + } + + /** + * Converts a point-based transformation matrix to millipoints. + * @param at a point-based transformation matrix + * @return a millipoint-based transformation matrix + */ + public static AffineTransform ptToMpt(AffineTransform at) { + double[] matrix = new double[6]; + at.getMatrix(matrix); + //Convert to millipoints + matrix[4] = matrix[4] * 1000; + matrix[5] = matrix[5] * 1000; + return new AffineTransform(matrix); + } + } diff --git a/status.xml b/status.xml index c134fadc2..1cde45913 100644 --- a/status.xml +++ b/status.xml @@ -54,7 +54,7 @@ - Fixed the source for a NullPointerException when the content of an fo:leader with + Fixed the source for a division by zero when the content of an fo:leader with leader-pattern="use-content" collapses to zero width during layout. -- 2.39.5