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
saveGraphicsState();
//Viewport position
- concatenateTransformationMatrix(mptToPt(positionTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(positionTransform));
//Background and borders
float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
//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()) {
saveGraphicsState();
//Set up coordinate system for content rectangle
AffineTransform contentTransform = ctm.toAffineTransform();
- concatenateTransformationMatrix(mptToPt(contentTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(contentTransform));
currentIPPosition = 0;
currentBPPosition = 0;
if (!at.isIdentity()) {
saveGraphicsState();
- concatenateTransformationMatrix(mptToPt(at));
+ concatenateTransformationMatrix(UnitConv.mptToPt(at));
}
currentIPPosition = 0;
if (!at.isIdentity()) {
saveGraphicsState();
- concatenateTransformationMatrix(mptToPt(at));
+ concatenateTransformationMatrix(UnitConv.mptToPt(at));
}
currentIPPosition = 0;
// Java
import java.awt.Rectangle;
-import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.OutputStream;
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);
- }
}
saveGraphicsState();
//Viewport position
- concatenateTransformationMatrix(mptToPt(positionTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(positionTransform));
//Background and borders
float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
//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()) {
saveGraphicsState();
//Set up coordinate system for content rectangle
AffineTransform contentTransform = ctm.toAffineTransform();
- concatenateTransformationMatrix(mptToPt(contentTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(contentTransform));
currentIPPosition = 0;
currentBPPosition = 0;
if (!at.isIdentity()) {
saveGraphicsState();
- concatenateTransformationMatrix(mptToPt(at));
+ concatenateTransformationMatrix(UnitConv.mptToPt(at));
}
currentIPPosition = 0;
if (!at.isIdentity()) {
saveGraphicsState();
- concatenateTransformationMatrix(mptToPt(at));
+ concatenateTransformationMatrix(UnitConv.mptToPt(at));
}
currentIPPosition = 0;
*/
protected void concatenateTransformationMatrix(AffineTransform at) {
if (!at.isIdentity()) {
- graphicContext.transform(ptToMpt(at));
+ graphicContext.transform(UnitConv.ptToMpt(at));
changePrintDirection();
}
}
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.
/** {@inheritDoc} */
protected void concatenateTransformationMatrix(AffineTransform at) {
- currentState.push(new CTM(ptToMpt(at)));
+ currentState.push(new CTM(UnitConv.ptToMpt(at)));
}
}
package org.apache.fop.util;
+import java.awt.geom.AffineTransform;
+
/**
* Utility class for unit conversions.
*/
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);
+ }
+
}