diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-08-20 12:59:11 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-08-20 12:59:11 +0000 |
commit | 39efd65d2f0607deb0bab109ab29ffd0528aead0 (patch) | |
tree | a20fc22eae82cdb3575ee04b25f309cc7ebdf9eb /src/java/org/apache | |
parent | 80fc2899d492745650c2916c24482bec0779303b (diff) | |
download | xmlgraphics-fop-39efd65d2f0607deb0bab109ab29ffd0528aead0.tar.gz xmlgraphics-fop-39efd65d2f0607deb0bab109ab29ffd0528aead0.zip |
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/trunk@687305 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
5 files changed, 44 insertions, 41 deletions
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index bf9f660be..0bfd7980b 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 @@ -514,7 +515,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; @@ -524,7 +525,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()) { @@ -534,7 +535,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; @@ -598,7 +599,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { if (!at.isIdentity()) { saveGraphicsState(); - concatenateTransformationMatrix(mptToPt(at)); + concatenateTransformationMatrix(UnitConv.mptToPt(at)); } currentIPPosition = 0; @@ -631,7 +632,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 11366f985..627e31b95 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); + } + } |