Przeglądaj źródła

Merged revisions 706272,706276 via svnmerge from

https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk

........
  r706272 | jeremias | 2008-10-20 14:14:03 +0100 (Mon, 20 Oct 2008) | 1 line
  
  Visually separated retroweaver part from hyphenation part.
........
  r706276 | jeremias | 2008-10-20 14:20:26 +0100 (Mon, 20 Oct 2008) | 3 lines
  
  Fixed size of images when vector graphic images are painted using fox:conversion-mode="bitmap" (for PDF output).
  Added support for fox:conversion-mode="bitmap" for PS output.
  Avoid "unsupported target ImageFlavor" error after the fix in XML Graphics Commons (rev 706270).
........


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@706282 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-1_0
Adrian Cumiskey 15 lat temu
rodzic
commit
d9e4553fcf

+ 3
- 0
build.xml Wyświetl plik

@@ -459,6 +459,9 @@ list of possible build targets.
</manifest>
</jar>
</target>
<!-- =================================================================== -->
<!-- Retroweaver -->
<!-- =================================================================== -->
<target name="retro-unavail" unless="java14.rt.lib">
<echo message="Please set the path to a JDK 1.4 installation in your build-local.properties" />
<echo message="to allow for verification!" />

+ 3
- 2
src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java Wyświetl plik

@@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.Map;

import org.apache.batik.dom.svg.SVGDOMImplementation;

import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
@@ -45,8 +46,8 @@ public class ImageLoaderSVG extends AbstractImageLoader {
* @param targetFlavor the target flavor
*/
public ImageLoaderSVG(ImageFlavor targetFlavor) {
if (!(XMLNamespaceEnabledImageFlavor.SVG_DOM.equals(targetFlavor))) {
throw new IllegalArgumentException("Unsupported target ImageFlavor: " + targetFlavor);
if (!(XMLNamespaceEnabledImageFlavor.SVG_DOM.isCompatible(targetFlavor))) {
throw new IllegalArgumentException("Incompatible target ImageFlavor: " + targetFlavor);
}
this.targetFlavor = targetFlavor;
}

+ 5
- 2
src/java/org/apache/fop/render/AbstractGenericSVGHandler.java Wyświetl plik

@@ -37,7 +37,9 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.xmlgraphics.util.QName;

import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.render.RendererContext.RendererContextWrapper;
import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
@@ -50,8 +52,9 @@ import org.apache.fop.svg.SVGUserAgent;
*/
public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererContextConstants {

/** logging instance */
protected static Log log = LogFactory.getLog(AbstractGenericSVGHandler.class);
/** Qualified name for the "conversion-mode" extension attribute. */
protected static final QName CONVERSION_MODE = new QName(
ExtensionElementMapping.URI, null, "conversion-mode");

/** {@inheritDoc} */
public void handleXML(RendererContext context,

+ 2
- 2
src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java Wyświetl plik

@@ -66,8 +66,8 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter {
float imw = (float)dim.getWidth() / 1000f;
float imh = (float)dim.getHeight() / 1000f;

float sx = fwidth / (float)imw;
float sy = fheight / (float)imh;
float sx = pdfInfo.paintAsBitmap ? 1.0f : (fwidth / (float)imw);
float sy = pdfInfo.paintAsBitmap ? 1.0f : (fheight / (float)imh);

renderer.saveGraphicsState();
renderer.setColor(Color.black, false, null);

+ 33
- 4
src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java Wyświetl plik

@@ -22,21 +22,32 @@ package org.apache.fop.render.ps;
import java.awt.Dimension;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Map;

import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.xmlgraphics.util.QName;

import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.render.AbstractGraphics2DAdapter;
import org.apache.fop.render.Graphics2DAdapter;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
import org.apache.fop.render.RendererContext.RendererContextWrapper;
import org.apache.fop.render.pdf.PDFRenderer;

/**
* Graphics2DAdapter implementation for PostScript.
*/
public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter {

/** Qualified name for the "conversion-mode" extension attribute. */
protected static final QName CONVERSION_MODE = new QName(
ExtensionElementMapping.URI, null, "conversion-mode");

private PSGenerator gen;
private boolean clip = true;

@@ -72,8 +83,15 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter {
float imw = (float)dim.getWidth() / 1000f;
float imh = (float)dim.getHeight() / 1000f;

float sx = fwidth / (float)imw;
float sy = fheight / (float)imh;
boolean paintAsBitmap = false;
if (context != null) {
Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
paintAsBitmap = (foreign != null
&& "bitmap".equalsIgnoreCase((String)foreign.get(CONVERSION_MODE)));
}

float sx = paintAsBitmap ? 1.0f : (fwidth / (float)imw);
float sy = paintAsBitmap ? 1.0f : (fheight / (float)imh);

gen.commentln("%FOPBeginGraphics2D");
gen.saveGraphicsState();
@@ -96,8 +114,19 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter {
// scale to viewbox
transform.translate(fx, fy);
gen.getCurrentState().concatMatrix(transform);
Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
painter.paint(graphics, area);
if (paintAsBitmap) {
//Fallback solution: Paint to a BufferedImage
int resolution = (int)Math.round(context.getUserAgent().getTargetResolution());
RendererContextWrapper ctx = RendererContext.wrapRendererContext(context);
BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false);

float scale = PDFRenderer.NORMAL_PDF_RESOLUTION
/ context.getUserAgent().getTargetResolution();
graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null);
} else {
Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
painter.paint(graphics, area);
}

gen.restoreGraphicsState();
gen.commentln("%FOPEndGraphics2D");

+ 31
- 29
src/java/org/apache/fop/render/ps/PSRenderer.java Wyświetl plik

@@ -40,6 +40,36 @@ import javax.xml.transform.Source;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
import org.apache.xmlgraphics.image.loader.impl.ImageRawEPS;
import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.image.loader.pipeline.ImageProviderPipeline;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
import org.apache.xmlgraphics.ps.DSCConstants;
import org.apache.xmlgraphics.ps.ImageEncoder;
import org.apache.xmlgraphics.ps.PSDictionary;
import org.apache.xmlgraphics.ps.PSDictionaryFormatException;
import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.xmlgraphics.ps.PSImageUtils;
import org.apache.xmlgraphics.ps.PSPageDeviceDictionary;
import org.apache.xmlgraphics.ps.PSProcSets;
import org.apache.xmlgraphics.ps.PSResource;
import org.apache.xmlgraphics.ps.PSState;
import org.apache.xmlgraphics.ps.dsc.DSCException;
import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.area.Area;
@@ -77,34 +107,6 @@ import org.apache.fop.render.ps.extensions.PSSetPageDevice;
import org.apache.fop.render.ps.extensions.PSSetupCode;
import org.apache.fop.util.CharUtilities;
import org.apache.fop.util.ColorUtil;
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
import org.apache.xmlgraphics.image.loader.impl.ImageRawEPS;
import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.image.loader.pipeline.ImageProviderPipeline;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
import org.apache.xmlgraphics.ps.DSCConstants;
import org.apache.xmlgraphics.ps.ImageEncoder;
import org.apache.xmlgraphics.ps.PSDictionary;
import org.apache.xmlgraphics.ps.PSDictionaryFormatException;
import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.xmlgraphics.ps.PSImageUtils;
import org.apache.xmlgraphics.ps.PSPageDeviceDictionary;
import org.apache.xmlgraphics.ps.PSProcSets;
import org.apache.xmlgraphics.ps.PSResource;
import org.apache.xmlgraphics.ps.PSState;
import org.apache.xmlgraphics.ps.dsc.DSCException;
import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;

/**
* Renderer that renders to PostScript.
@@ -1610,7 +1612,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
* {@inheritDoc}
*/
public void renderImage(Image image, Rectangle2D pos) {
drawImage(image.getURL(), pos);
drawImage(image.getURL(), pos, image.getForeignAttributes());
}

/**

+ 19
- 0
src/java/org/apache/fop/render/ps/PSSVGHandler.java Wyświetl plik

@@ -22,6 +22,7 @@ package org.apache.fop.render.ps;
// Java
import java.awt.geom.AffineTransform;
import java.io.IOException;
import java.util.Map;

import org.w3c.dom.Document;

@@ -39,6 +40,7 @@ import org.apache.fop.fonts.FontInfo;
import org.apache.fop.render.AbstractGenericSVGHandler;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;

@@ -226,6 +228,23 @@ public class PSSVGHandler extends AbstractGenericSVGHandler
int yOffset = psInfo.currentYPosition;
PSGenerator gen = psInfo.psGenerator;

boolean paintAsBitmap = false;
if (context != null) {
Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
paintAsBitmap = (foreign != null
&& "bitmap".equalsIgnoreCase((String)foreign.get(CONVERSION_MODE)));
}
if (paintAsBitmap) {
try {
super.renderSVGDocument(context, doc);
} catch (IOException ioe) {
SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
context.getUserAgent().getEventBroadcaster());
eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc));
}
return;
}

//Controls whether text painted by Batik is generated using text or path operations
boolean strokeText = false;
Configuration cfg = psInfo.getHandlerConfiguration();

Ładowanie…
Anuluj
Zapisz