aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdrian Cumiskey <acumiskey@apache.org>2008-08-20 15:13:56 +0000
committerAdrian Cumiskey <acumiskey@apache.org>2008-08-20 15:13:56 +0000
commite4a6a478b3506acb88943481ce1e1cb79419c831 (patch)
tree7c9b60f515f747d49137d6c15e072722d55a9231 /src
parent93cf2f0568fa528b79b511c53ff6f1a5a5e69439 (diff)
downloadxmlgraphics-fop-e4a6a478b3506acb88943481ce1e1cb79419c831.tar.gz
xmlgraphics-fop-e4a6a478b3506acb88943481ce1e1cb79419c831.zip
* Updated xmlgraphics-commons-14svn.jar to reflect UnitConv additions.
* Removed UnitConv and its unit test case (now resides in commons). * Updated all fop util package references fpr UnitConv to xmlgraphics commons util package. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@687369 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java2
-rw-r--r--src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java8
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLGenerator.java9
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLGraphics2D.java4
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java4
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLPageDefinition.java12
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLRenderer.java20
-rw-r--r--src/java/org/apache/fop/render/txt/TXTRenderer.java8
-rw-r--r--src/java/org/apache/fop/util/UnitConv.java158
9 files changed, 33 insertions, 192 deletions
diff --git a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
index 3f9135d2a..5861fb042 100644
--- a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
@@ -35,7 +35,7 @@ import java.awt.image.WritableRaster;
import java.io.IOException;
import org.apache.fop.render.RendererContext.RendererContextWrapper;
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Abstract base class for Graphics2DAdapter implementations.
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
index 0bfd7980b..65bb450f3 100644
--- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
@@ -48,7 +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;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Abstract base class for renderers like PDF and PostScript where many painting operations
@@ -485,8 +485,8 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore();
//This is the content-rect
- float width = (float)bv.getIPD() / 1000f;
- float height = (float)bv.getBPD() / 1000f;
+ float width = bv.getIPD() / 1000f;
+ float height = bv.getBPD() / 1000f;
if (bv.getPositioning() == Block.ABSOLUTE
|| bv.getPositioning() == Block.FIXED) {
@@ -581,7 +581,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
currentIPPosition = saveIP;
currentBPPosition = saveBP;
- currentBPPosition += (int)(bv.getAllocBPD());
+ currentBPPosition += (bv.getAllocBPD());
}
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLGenerator.java b/src/java/org/apache/fop/render/pcl/PCLGenerator.java
index d1b6f6578..45af4df89 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGenerator.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGenerator.java
@@ -45,8 +45,7 @@ import java.util.Locale;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.xmlgraphics.image.GraphicsUtil;
-
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* This class provides methods for generating PCL print files.
@@ -68,7 +67,7 @@ public class PCLGenerator {
private final DecimalFormat df2 = new DecimalFormat("0.##", symbols);
private final DecimalFormat df4 = new DecimalFormat("0.####", symbols);
- private OutputStream out;
+ private final OutputStream out;
private boolean currentSourceTransparency = true;
private boolean currentPatternTransparency = true;
@@ -79,7 +78,7 @@ public class PCLGenerator {
* true: Standard PCL shades are used (poor quality). false: user-defined pattern are used
* to create custom dither patterns for better grayscale quality.
*/
- private boolean usePCLShades = false;
+ private final boolean usePCLShades = false;
/**
* Main constructor.
@@ -400,7 +399,7 @@ public class PCLGenerator {
private static void setValueInMatrix(int[] dn, int half, int part, int idx, int value) {
int xoff = (part & 1) * half;
int yoff = (part & 2) * half * half;
- int matrixIndex = yoff + ((int)(idx / half) * half * 2) + (idx % half) + xoff;
+ int matrixIndex = yoff + ((idx / half) * half * 2) + (idx % half) + xoff;
dn[matrixIndex] = value;
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
index 3eef38b6b..ded87a057 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
@@ -42,9 +42,9 @@ import java.awt.image.renderable.RenderableImage;
import java.io.IOException;
import java.text.AttributedCharacterIterator;
-import org.apache.fop.util.UnitConv;
import org.apache.xmlgraphics.java2d.AbstractGraphics2D;
import org.apache.xmlgraphics.java2d.GraphicContext;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Graphics2D implementation implementing PCL and HP GL/2.
@@ -55,7 +55,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
/** The PCL generator */
protected PCLGenerator gen;
- private boolean failOnUnsupportedFeature = true;
+ private final boolean failOnUnsupportedFeature = true;
private boolean clippingDisabled = false;
/**
diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
index 3878a84fb..f8c9682e9 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
@@ -34,7 +34,7 @@ import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.fop.render.AbstractGraphics2DAdapter;
import org.apache.fop.render.RendererContext;
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Graphics2DAdapter implementation for PCL and HP GL/2.
@@ -111,7 +111,7 @@ public class PCLGraphics2DAdapter extends AbstractGraphics2DAdapter {
if (!painted) {
//Fallback solution: Paint to a BufferedImage
- int resolution = (int)Math.round(context.getUserAgent().getTargetResolution());
+ int resolution = Math.round(context.getUserAgent().getTargetResolution());
BufferedImage bi = paintToBufferedImage(painter, pclContext,
resolution, !pclContext.isColorCanvas(), false);
diff --git a/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java b/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
index e8c8814ab..e03a86b94 100644
--- a/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
+++ b/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
@@ -24,7 +24,7 @@ import java.awt.Rectangle;
import java.util.Iterator;
import java.util.List;
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* This class represents a page format with PCL-specific properties.
@@ -34,11 +34,11 @@ public class PCLPageDefinition {
private static List pageDefinitions;
private static PCLPageDefinition defaultPageDefinition;
- private String name;
- private int selector;
- private Dimension physicalPageSize;
- private Rectangle logicalPageRect;
- private boolean landscape;
+ private final String name;
+ private final int selector;
+ private final Dimension physicalPageSize;
+ private final Rectangle logicalPageRect;
+ private final boolean landscape;
static {
createPageDefinitions();
diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java
index 627e31b95..5896ad318 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java
@@ -97,7 +97,7 @@ import org.apache.fop.render.java2d.InstalledFontCollection;
import org.apache.fop.render.java2d.Java2DRenderer;
import org.apache.fop.render.pcl.extensions.PCLElementMapping;
import org.apache.fop.traits.BorderProps;
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/* Note:
* There are some commonalities with AbstractPathOrientedRenderer but it's not possible
@@ -128,7 +128,7 @@ public class PCLRenderer extends PrintRenderer {
protected PCLGenerator gen;
private boolean ioTrouble = false;
- private Stack graphicContextStack = new Stack();
+ private final Stack graphicContextStack = new Stack();
private GraphicContext graphicContext = new GraphicContext();
private PCLPageDefinition currentPageDefinition;
@@ -153,7 +153,7 @@ public class PCLRenderer extends PrintRenderer {
* This can be used to work around problems with Apache Batik, for example, but setting
* this to true will increase memory consumption.
*/
- private boolean useColorCanvas = false;
+ private final boolean useColorCanvas = false;
/**
* Controls whether the generation of PJL commands gets disabled.
@@ -245,7 +245,7 @@ public class PCLRenderer extends PrintRenderer {
/** @return the target resolution */
protected int getResolution() {
- int resolution = (int)Math.round(userAgent.getTargetResolution());
+ int resolution = Math.round(userAgent.getTargetResolution());
if (resolution <= 300) {
return 300;
} else {
@@ -945,8 +945,8 @@ public class PCLRenderer extends PrintRenderer {
int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore();
//This is the content-rect
- float width = (float)bv.getIPD() / 1000f;
- float height = (float)bv.getBPD() / 1000f;
+ float width = bv.getIPD() / 1000f;
+ float height = bv.getBPD() / 1000f;
if (bv.getPositioning() == Block.ABSOLUTE
@@ -1034,7 +1034,7 @@ public class PCLRenderer extends PrintRenderer {
currentIPPosition = saveIP;
currentBPPosition = saveBP;
- currentBPPosition += (int)(bv.getAllocBPD());
+ currentBPPosition += (bv.getAllocBPD());
}
//currentFontName = saveFontName;
}
@@ -1433,13 +1433,13 @@ public class PCLRenderer extends PrintRenderer {
borderRect.width,
borderRect.height);
final Rectangle paintRect = new Rectangle(
- (int)Math.round(borderRect.x * 1000f),
- (int)Math.round(borderRect.y * 1000f),
+ Math.round(borderRect.x * 1000f),
+ Math.round(borderRect.y * 1000f),
(int)Math.floor(borderRect.width * 1000f) + 1,
(int)Math.floor(borderRect.height * 1000f) + 1);
//Add one pixel wide safety margin around the paint area
int pixelWidth = (int)Math.round(UnitConv.in2mpt(1) / userAgent.getTargetResolution());
- final int xoffset = (int)Math.round(-effBorderRect.x * 1000f) + pixelWidth;
+ final int xoffset = Math.round(-effBorderRect.x * 1000f) + pixelWidth;
final int yoffset = pixelWidth;
paintRect.x += xoffset;
paintRect.y += yoffset;
diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java
index 29f1ef954..575f1232f 100644
--- a/src/java/org/apache/fop/render/txt/TXTRenderer.java
+++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java
@@ -37,7 +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;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Renderer that renders areas to plain text.
@@ -86,10 +86,10 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
* Every line except the last line on a page (which will end with
* pageEnding) will be terminated with this string.
*/
- private String lineEnding = "\r\n";
+ private final String lineEnding = "\r\n";
/** Every page except the last one will end with this string. */
- private String pageEnding = "\f";
+ private final String pageEnding = "\f";
/** Equals true, if current page is first. */
private boolean firstPage = false;
@@ -101,7 +101,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
private char fillChar;
/** Saves current coordinate transformation. */
- private TXTState currentState = new TXTState();
+ private final TXTState currentState = new TXTState();
private String encoding;
diff --git a/src/java/org/apache/fop/util/UnitConv.java b/src/java/org/apache/fop/util/UnitConv.java
deleted file mode 100644
index 475e3dcc0..000000000
--- a/src/java/org/apache/fop/util/UnitConv.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.util;
-
-import java.awt.geom.AffineTransform;
-
-/**
- * Utility class for unit conversions.
- */
-public final class UnitConv {
-
- /** conversion factory from millimeters to inches. */
- public static final float IN2MM = 25.4f;
-
- /** conversion factory from centimeters to inches. */
- public static final float IN2CM = 2.54f;
-
- /** conversion factory from inches to points. */
- public static final int IN2PT = 72;
-
- /**
- * Converts millimeters (mm) to points (pt)
- * @param mm the value in mm
- * @return the value in pt
- */
- public static double mm2pt(double mm) {
- return mm * IN2PT / IN2MM;
- }
-
- /**
- * Converts millimeters (mm) to millipoints (mpt)
- * @param mm the value in mm
- * @return the value in mpt
- */
- public static double mm2mpt(double mm) {
- return mm * 1000 * IN2PT / IN2MM;
- }
-
- /**
- * Converts points (pt) to millimeters (mm)
- * @param pt the value in pt
- * @return the value in mm
- */
- public static double pt2mm(double pt) {
- return pt * IN2MM / IN2PT;
- }
-
- /**
- * Converts millimeters (mm) to inches (in)
- * @param mm the value in mm
- * @return the value in inches
- */
- public static double mm2in(double mm) {
- return mm / IN2MM;
- }
-
- /**
- * Converts inches (in) to millimeters (mm)
- * @param in the value in inches
- * @return the value in mm
- */
- public static double in2mm(double in) {
- return in * IN2MM;
- }
-
- /**
- * Converts inches (in) to millipoints (mpt)
- * @param in the value in inches
- * @return the value in mpt
- */
- public static double in2mpt(double in) {
- return in * IN2PT * 1000;
- }
-
- /**
- * Converts inches (in) to points (pt)
- * @param in the value in inches
- * @return the value in pt
- */
- public static double in2pt(double in) {
- return in * IN2PT;
- }
-
- /**
- * Converts millipoints (mpt) to inches (in)
- * @param mpt the value in mpt
- * @return the value in inches
- */
- public static double mpt2in(double mpt) {
- return mpt / IN2PT / 1000;
- }
-
- /**
- * Converts millimeters (mm) to pixels (px)
- * @param mm the value in mm
- * @param resolution the resolution in dpi (dots per inch)
- * @return the value in pixels
- */
- public static double mm2px(double mm, int resolution) {
- return mm2in(mm) * resolution;
- }
-
- /**
- * Converts millipoints (mpt) to pixels (px)
- * @param mpt the value in mpt
- * @param resolution the resolution in dpi (dots per inch)
- * @return the value in pixels
- */
- public static double mpt2px(double mpt, int resolution) {
- 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);
- }
-
-}