import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext;
+import org.apache.xmlgraphics.util.UnitConv;
import org.apache.fop.Version;
import org.apache.fop.accessibility.Accessibility;
* @see #getTargetResolution()
*/
public float getTargetPixelUnitToMillimeter() {
- return 25.4f / this.targetResolution;
+ return UnitConv.IN2MM / this.targetResolution;
}
/** @return the resolution for resolution-dependant output */
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.util.UnitConv;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.ElementMappingRegistry;
* @see #getSourceResolution()
*/
public float getSourcePixelUnitToMillimeter() {
- return 25.4f / getSourceResolution();
+ return UnitConv.IN2MM / getSourceResolution();
}
/**
* @see #getTargetResolution()
*/
public float getTargetPixelUnitToMillimeter() {
- return 25.4f / this.targetResolution;
+ return UnitConv.IN2MM / this.targetResolution;
}
/**
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry;
import org.apache.xmlgraphics.image.loader.util.Penalty;
public static final String DEFAULT_PAGE_HEIGHT = "11in";
/** Defines the default source resolution (72dpi) for FOP */
- public static final float DEFAULT_SOURCE_RESOLUTION = 72.0f; //dpi
+ public static final float DEFAULT_SOURCE_RESOLUTION = GraphicsConstants.DEFAULT_DPI; //dpi
/** Defines the default target resolution (72dpi) for FOP */
- public static final float DEFAULT_TARGET_RESOLUTION = 72.0f; //dpi
+ public static final float DEFAULT_TARGET_RESOLUTION = GraphicsConstants.DEFAULT_DPI; //dpi
private static final String PREFER_RENDERER = "prefer-renderer";
lang = hyphPatConfig[i].getAttribute("lang", null);
if (lang == null) {
- addError("The lang attribute of a hyphenation-pattern configuration"
+ addError("The lang attribute of a hyphenation-pattern configuration"
+ " element must exist (" + location + ")", error);
} else if (!lang.matches("[a-zA-Z]{2}")) {
addError("The lang attribute of a hyphenation-pattern configuration"
LogUtil.handleError(log, error.toString(), strict);
continue;
}
-
+
String llccKey = HyphenationTreeCache.constructLlccKey(lang, country);
hyphPatNames.put(llccKey, filename);
if (log.isDebugEnabled()) {
}
error.append(message);
}
-
+
private void configureImageLoading(Configuration parent, boolean strict) throws FOPException {
if (parent == null) {
return;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
}
//Prepare
- float pxToMillimeter = UnitConv.IN2MM / 72; //default: 72dpi
+ float pxToMillimeter = UnitConv.IN2MM / GraphicsConstants.DEFAULT_DPI;
Number ptm = (Number)hints.get(ImageProcessingHints.SOURCE_RESOLUTION);
if (ptm != null) {
pxToMillimeter = (float)(UnitConv.IN2MM / ptm.doubleValue());
// Java
import java.awt.Color;
import java.awt.Dimension;
-import java.awt.geom.Rectangle2D;
import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
import java.awt.print.PageFormat;
import java.awt.print.Pageable;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.io.IOException;
+import org.apache.xmlgraphics.util.UnitConv;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactoryConfigurator;
import org.apache.fop.render.awt.viewer.PreviewDialog;
import org.apache.fop.render.awt.viewer.Renderable;
import org.apache.fop.render.awt.viewer.StatusListener;
-import org.apache.fop.render.java2d.Java2DRenderer;
import org.apache.fop.render.extensions.prepress.PageScale;
+import org.apache.fop.render.java2d.Java2DRenderer;
/**
* The AWTRender outputs the pages generated by the layout engine to a Swing
pageWidth = (int) Math.round(bounds.getWidth() / 1000f);
pageHeight = (int) Math.round(bounds.getHeight() / 1000f);
double scaleX = scaleFactor
- * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+ * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
double scaleY = scaleFactor
- * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+ * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
if (getPageViewport(pageNum).getForeignAttributes() != null) {
String scale = (String) getPageViewport(pageNum).getForeignAttributes().get(
import java.awt.image.WritableRaster;
import java.io.IOException;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo;
//scaling because of image resolution
//float sourceResolution = java2dContext.getUserAgent().getSourceResolution();
//source resolution seems to be a bad idea, not sure why
- float sourceResolution = 72;
+ float sourceResolution = GraphicsConstants.DEFAULT_DPI;
sourceResolution *= 1000; //we're working in the millipoint area
sx *= sourceResolution / info.getSize().getDpiHorizontal();
sy *= sourceResolution / info.getSize().getDpiVertical();
import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.util.UnitConv;
import org.apache.fop.ResourceEventProducer;
import org.apache.fop.apps.FOPException;
}
scaleX = scaleX
- * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+ * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
scaleY = scaleY
- * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+ * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5);
int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5);
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.FixedLength;
+import org.apache.xmlgraphics.util.UnitConv;
/** Converts XSL-FO units to RTF units
public static final float POINT_TO_TWIPS = 20f;
/** millimeters and centimeters to twips: , one point is 1/72 of an inch, one inch is 25.4 mm */
- public static final float IN_TO_TWIPS = 72f * POINT_TO_TWIPS;
- public static final float MM_TO_TWIPS = IN_TO_TWIPS / 25.4f;
+ public static final float IN_TO_TWIPS = UnitConv.IN2PT * POINT_TO_TWIPS;
+ public static final float MM_TO_TWIPS = IN_TO_TWIPS / UnitConv.IN2MM;
public static final float CM_TO_TWIPS = 10 * MM_TO_TWIPS;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.DOMImplementation;
-
import org.xml.sax.EntityResolver;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* This is the common base class of all of FOP's transcoders.
if (hints.containsKey(KEY_DEVICE_RESOLUTION)) {
return ((Float)hints.get(KEY_DEVICE_RESOLUTION)).floatValue();
} else {
- return 72;
+ return GraphicsConstants.DEFAULT_DPI;
}
}
protected void setupImageInfrastructure(final String baseURI) {
final ImageContext imageContext = new ImageContext() {
public float getSourceResolution() {
- return 25.4f / userAgent.getPixelUnitToMillimeter();
+ return UnitConv.IN2MM / userAgent.getPixelUnitToMillimeter();
}
};
this.imageManager = new ImageManager(imageContext);
return ((Float)getTranscodingHints().get(key)).floatValue();
} else {
// return 0.3528f; // 72 dpi
- return 25.4f / 96; //96dpi = 0.2645833333333333333f;
+ return UnitConv.IN2MM / 96; //96dpi = 0.2645833333333333333f;
}
}
import java.io.OutputStream;
import java.io.StringWriter;
+import org.apache.xmlgraphics.image.GraphicsConstants;
+
import org.apache.fop.Version;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontSetup;
/** Normal PDF resolution (72dpi) */
public static final int NORMAL_PDF_RESOLUTION = 72;
/** Default device resolution (300dpi is a resonable quality for most purposes) */
- public static final int DEFAULT_NATIVE_DPI = 300;
+ public static final int DEFAULT_NATIVE_DPI = GraphicsConstants.DEFAULT_SAMPLE_DPI;
/**
* The device resolution may be different from the normal target resolution. See
import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.gvt.PatternPaint;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageSize;
import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
private PDFXObject addRenderedImage(String key, RenderedImage img) {
ImageInfo info = new ImageInfo(null, "image/unknown");
- ImageSize size = new ImageSize(img.getWidth(), img.getHeight(), 72);
+ ImageSize size = new ImageSize(img.getWidth(), img.getHeight(),
+ GraphicsConstants.DEFAULT_DPI);
info.setSize(size);
ImageRendered imgRend = new ImageRendered(info, img, null);
ImageRenderedAdapter adapter = new ImageRenderedAdapter(imgRend, key);
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Code" dev="VH" type="fix" fixes-bug="49695" due-to="Joshua Marquart">
+ Replaced magic numbers with constants from UnitConv and GraphicsConstants.
+ </action>
<action context="Renderers" dev="JM" type="add" fixes-bug="42600" due-to="Maximilian Aster">
Added some support for break-before/-after for RTF output.
</action>