keiron 01/10/11 23:40:13
Modified: src/org/apache/fop/image/analyser SVGReader.java
src/org/apache/fop/layout LineArea.java
src/org/apache/fop/render/svg SVGRenderer.java
src/org/apache/fop/svg PDFGraphics2D.java
PDFTextPainter.java PDFTranscoder.java
SVGUserAgent.java
Added: src/org/apache/fop/svg PDFImageElementBridge.java
Log:
changed api associated with batik to current batik
added a half implemented bridge for jpg images
Revision Changes Path
1.12 +6 -1 xml-fop/src/org/apache/fop/image/analyser/SVGReader.java
Index: SVGReader.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/analyser/SVGReader.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SVGReader.java 2001/09/25 12:32:36 1.11
+++ SVGReader.java 2001/10/12 06:40:12 1.12
@@ -1,5 +1,5 @@
/*
- * $Id: SVGReader.java,v 1.11 2001/09/25 12:32:36 keiron Exp $
+ * $Id: SVGReader.java,v 1.12 2001/10/12 06:40:12 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -155,6 +155,11 @@
public String getLanguages() {
return "en"; // userLanguages;
}
+
+ public String getMedia() {
+ return "";
+ }
+
/**
* Returns the user stylesheet uri.
1.53 +2 -2 xml-fop/src/org/apache/fop/layout/LineArea.java
Index: LineArea.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/LineArea.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- LineArea.java 2001/10/05 11:20:04 1.52
+++ LineArea.java 2001/10/12 06:40:12 1.53
@@ -1,5 +1,5 @@
/*
- * $Id: LineArea.java,v 1.52 2001/10/05 11:20:04 keiron Exp $
+ * $Id: LineArea.java,v 1.53 2001/10/12 06:40:12 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -876,7 +876,7 @@
private String getHyphenationWord(char[] characters, int wordStart) {
boolean wordendFound = false;
int counter = 0;
- char[] newWord = new char[100]; // create a buffer
+ char[] newWord = new char[characters.length]; // create a buffer
while ((!wordendFound)
&& ((wordStart + counter) < characters.length)) {
char tk = characters[wordStart + counter];
1.2 +8 -11 xml-fop/src/org/apache/fop/render/svg/SVGRenderer.java
Index: SVGRenderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/svg/SVGRenderer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SVGRenderer.java 2001/10/05 09:49:21 1.1
+++ SVGRenderer.java 2001/10/12 06:40:12 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: SVGRenderer.java,v 1.1 2001/10/05 09:49:21 keiron Exp $
+ * $Id: SVGRenderer.java,v 1.2 2001/10/12 06:40:12 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -98,13 +98,6 @@
protected float currentBlue = 0;
/**
- * The parent component, used to set up the font.
- * This is needed as FontSetup needs a live AWT component
- * in order to generate valid font measures.
- */
- protected Component parent;
-
- /**
* options
*/
protected Hashtable options;
@@ -607,9 +600,13 @@
throws IOException {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
svgDocument = impl.createDocument(svgNS, "svg", null);
-
- svgRoot = svgDocument.getDocumentElement();
- }
+ ProcessingInstruction pi =
+ svgDocument.createProcessingInstruction(
+ "xml",
+ " version=\"1.0\" encoding=\"ISO-8859-1\"");
+ svgRoot = svgDocument.getDocumentElement();
+ svgDocument.insertBefore(pi, svgRoot);
+ }
public void stopRenderer(OutputStream outputStream)
throws IOException {
1.19 +36 -8 xml-fop/src/org/apache/fop/svg/PDFGraphics2D.java
Index: PDFGraphics2D.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/PDFGraphics2D.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- PDFGraphics2D.java 2001/09/07 09:26:16 1.18
+++ PDFGraphics2D.java 2001/10/12 06:40:13 1.19
@@ -1,5 +1,5 @@
/*
- * $Id: PDFGraphics2D.java,v 1.18 2001/09/07 09:26:16 keiron Exp $
+ * $Id: PDFGraphics2D.java,v 1.19 2001/10/12 06:40:13 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -43,7 +43,7 @@
* implementing a <tt>Graphic2D</tt> piece-meal.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Keiron Liddle</a>
- * @version $Id: PDFGraphics2D.java,v 1.18 2001/09/07 09:26:16 keiron Exp $
+ * @version $Id: PDFGraphics2D.java,v 1.19 2001/10/12 06:40:13 keiron Exp $
* @see org.apache.batik.ext.awt.g2d.AbstractGraphics2D
*/
public class PDFGraphics2D extends AbstractGraphics2D {
@@ -171,6 +171,26 @@
return currentAnnotList;
}
+ public void addJpegImage(JpegImage jpeg, float x, float y, float width, float
height) {
+ int xObjectNum = this.pdfDoc.addImage(jpeg);
+
+ AffineTransform at = getTransform();
+ double[] matrix = new double[6];
+ at.getMatrix(matrix);
+ currentStream.write("q\n");
+ Shape imclip = getClip();
+ writeClip(imclip);
+ currentStream.write("" + matrix[0] + " " + matrix[1] + " "
+ + matrix[2] + " " + matrix[3] + " "
+ + matrix[4] + " " + matrix[5] + " cm\n");
+
+ currentStream.write("" + width + " 0 0 "
+ + (-height) + " "
+ + x + " "
+ + (y + height) + " cm\n" + "/Im"
+ + xObjectNum + " Do\nQ\n");
+ }
+
/**
* Draws as much of the specified image as is currently available.
* The image is drawn with its top-left corner at
@@ -205,17 +225,17 @@
return false;
}
- Dimension size = new Dimension(width, height);
+ Dimension size = new Dimension(width * 3, height * 3);
BufferedImage buf = buildBufferedImage(size);
java.awt.Graphics2D g = buf.createGraphics();
g.setComposite(AlphaComposite.SrcOver);
g.setBackground(new Color(1, 1, 1, 0));
g.setPaint(new Color(1, 1, 1, 0));
- g.fillRect(0, 0, width, height);
+ g.fillRect(0, 0, width * 3, height * 3);
g.clip(new Rectangle(0, 0, buf.getWidth(), buf.getHeight()));
- if (!g.drawImage(img, 0, 0, observer)) {
+ if (!g.drawImage(img, 0, 0, buf.getWidth(), buf.getHeight(), observer)) {
return false;
}
g.dispose();
@@ -267,7 +287,7 @@
}
try {
- FopImage fopimg = new TempImage(width, height, result, mask);
+ FopImage fopimg = new TempImage(buf.getWidth(), buf.getHeight(),
result, mask);
int xObjectNum = this.pdfDoc.addImage(fopimg);
AffineTransform at = getTransform();
double[] matrix = new double[6];
@@ -477,10 +497,15 @@
*/
public void draw(Shape s) {
// System.out.println("draw(Shape)");
+ Color c;
+ c = getColor();
+ if(c.getAlpha() == 0) {
+ return;
+ }
+
currentStream.write("q\n");
Shape imclip = getClip();
writeClip(imclip);
- Color c = getColor();
applyColor(c, false);
applyPaint(getPaint(), false);
@@ -1169,6 +1194,7 @@
* but it should be fixed...).
*/
public Rectangle getBounds() {
+System.out.println("getting getBounds");
return null;
}
@@ -1193,6 +1219,7 @@
* The default transform (1:1).
*/
public AffineTransform getDefaultTransform() {
+System.out.println("getting getDefaultTransform");
return new AffineTransform();
}
@@ -1202,7 +1229,8 @@
* in the future).
*/
public AffineTransform getNormalizingTransform() {
- return new AffineTransform();
+System.out.println("getting getNormalizingTransform");
+ return new AffineTransform(2, 0, 0, 2, 0, 0);
}
/**
1.7 +12 -115 xml-fop/src/org/apache/fop/svg/PDFTextPainter.java
Index: PDFTextPainter.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/PDFTextPainter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PDFTextPainter.java 2001/09/24 07:31:52 1.6
+++ PDFTextPainter.java 2001/10/12 06:40:13 1.7
@@ -1,5 +1,5 @@
/*
- * $Id: PDFTextPainter.java,v 1.6 2001/09/24 07:31:52 keiron Exp $
+ * $Id: PDFTextPainter.java,v 1.7 2001/10/12 06:40:13 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -36,7 +36,7 @@
* Renders the attributed character iterator of a <tt>TextNode</tt>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Keiron Liddle</a>
- * @version $Id: PDFTextPainter.java,v 1.6 2001/09/24 07:31:52 keiron Exp $
+ * @version $Id: PDFTextPainter.java,v 1.7 2001/10/12 06:40:13 keiron Exp $
*/
public class PDFTextPainter implements TextPainter {
FontState fontState;
@@ -181,172 +181,69 @@
return wordWidth / 1000f;
}
- /**
- * Initiates a text selection on a particular AttributedCharacterIterator,
- * using the text/font metrics employed by this TextPainter instance.
- * @param x the x coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param y the y coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param aci the AttributedCharacterIterator describing the text
- * @return an instance of Mark which encapsulates the state necessary to
- * implement hit testing and text selection.
- */
- public Mark selectAt(double x, double y, AttributedCharacterIterator aci,
+ public Mark getMark(TextNode node, int pos, boolean all) {
+ System.out.println("PDFText getMark");
+ return null;
+ }
+
+ public Mark selectAt(double x, double y,
TextNode node) {
System.out.println("PDFText selectAt");
return null;
}
- /**
- * Continues a text selection on a particular AttributedCharacterIterator,
- * using the text/font metrics employed by this TextPainter instance.
- * @param x the x coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param y the y coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param aci the AttributedCharacterIterator describing the text
- * @return an instance of Mark which encapsulates the state necessary to
- * implement hit testing and text selection.
- */
- public Mark selectTo(double x, double y, Mark beginMark,
- AttributedCharacterIterator aci,
- TextNode node) {
+ public Mark selectTo(double x, double y, Mark beginMark) {
System.out.println("PDFText selectTo");
return null;
}
- /**
- * Select all of the text represented by an AttributedCharacterIterator,
- * using the text/font metrics employed by this TextPainter instance.
- * @param x the x coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param y the y coordinate, in the text layout's coordinate system,
- * of the selection event.
- * @param aci the AttributedCharacterIterator describing the text
- * @return an instance of Mark which encapsulates the state necessary to
- * implement hit testing and text selection.
- */
public Mark selectAll(double x, double y,
- AttributedCharacterIterator aci,
TextNode node) {
System.out.println("PDFText selectAll");
return null;
}
-
- /**
- * Selects the first glyph in the text node.
- */
- public Mark selectFirst(double x, double y,
- AttributedCharacterIterator aci,
- TextNode node) {
+ public Mark selectFirst(TextNode node) {
System.out.println("PDFText selectFirst");
return null;
}
-
- /**
- * Selects the last glyph in the text node.
- */
- public Mark selectLast(double x, double y,
- AttributedCharacterIterator aci,
- TextNode node) {
+ public Mark selectLast(TextNode node) {
System.out.println("PDFText selectLast");
return null;
}
- /*
- * Get an array of index pairs corresponding to the indices within an
- * AttributedCharacterIterator regions bounded by two Marks.
- * Note that the instances of Mark passed to this function
- * <em>must come</em>
- * from the same TextPainter that generated them via selectAt() and
- * selectTo(), since the TextPainter implementation may rely on hidden
- * implementation details of its own Mark implementation.
- */
- public int[] getSelected(AttributedCharacterIterator aci, Mark start,
+ public int[] getSelected(Mark start,
Mark finish) {
System.out.println("PDFText getSelected");
return null;
}
-
- /*
- * Get a Shape in userspace coords which encloses the textnode
- * glyphs bounded by two Marks.
- * Note that the instances of Mark passed to this function
- * <em>must come</em>
- * from the same TextPainter that generated them via selectAt() and
- * selectTo(), since the TextPainter implementation may rely on hidden
- * implementation details of its own Mark implementation.
- */
public Shape getHighlightShape(Mark beginMark, Mark endMark) {
System.out.println("PDFText getHighlightShape");
return null;
}
- /*
- * Get a Shape in userspace coords which defines the textnode glyph outlines.
- * @param node the TextNode to measure
- * @param frc the font rendering context.
- * @param includeDecoration whether to include text decoration
- * outlines.
- * @param includeStroke whether to create the "stroke shape outlines"
- * instead of glyph outlines.
- */
public Shape getShape(TextNode node) {
System.out.println("PDFText getShape");
return null;
}
- /*
- * Get a Shape in userspace coords which defines the textnode glyph outlines.
- * @param node the TextNode to measure
- * @param frc the font rendering context.
- * @param includeDecoration whether to include text decoration
- * outlines.
- * @param includeStroke whether to create the "stroke shape outlines"
- * instead of glyph outlines.
- */
public Shape getDecoratedShape(TextNode node) {
System.out.println("PDFText getDecoratedShape");
return new Rectangle(1, 1);
}
- /*
- * Get a Rectangle2D in userspace coords which encloses the textnode
- * glyphs composed from an AttributedCharacterIterator.
- * @param node the TextNode to measure
- * @param g2d the Graphics2D to use
- * @param context rendering context.
- */
public Rectangle2D getBounds(TextNode node) {
System.out.println("PDFText getBounds");
return null;
}
- /*
- * Get a Rectangle2D in userspace coords which encloses the textnode
- * glyphs composed from an AttributedCharacterIterator, inclusive of
- * glyph decoration (underline, overline, strikethrough).
- * @param node the TextNode to measure
- * @param g2d the Graphics2D to use
- * @param context rendering context.
- */
public Rectangle2D getDecoratedBounds(TextNode node) {
System.out.println("PDFText getDecoratedBounds");
return null;
}
- /*
- * Get a Rectangle2D in userspace coords which encloses the
- * textnode glyphs (as-painted, inclusive of decoration and stroke, but
- * exclusive of filters, etc.) composed from an AttributedCharacterIterator.
- * @param node the TextNode to measure
- * @param g2d the Graphics2D to use
- * @param context rendering context.
- */
public Rectangle2D getPaintedBounds(TextNode node) {
// System.out.println("PDFText getPaintedBounds");
return null;
1.11 +8 -2 xml-fop/src/org/apache/fop/svg/PDFTranscoder.java
Index: PDFTranscoder.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/PDFTranscoder.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- PDFTranscoder.java 2001/09/24 07:31:52 1.10
+++ PDFTranscoder.java 2001/10/12 06:40:13 1.11
@@ -1,5 +1,5 @@
/*
- * $Id: PDFTranscoder.java,v 1.10 2001/09/24 07:31:52 keiron Exp $
+ * $Id: PDFTranscoder.java,v 1.11 2001/10/12 06:40:13 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -123,7 +123,7 @@
* millimeter conversion factor.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Keiron Liddle</a>
- * @version $Id: PDFTranscoder.java,v 1.10 2001/09/24 07:31:52 keiron Exp $
+ * @version $Id: PDFTranscoder.java,v 1.11 2001/10/12 06:40:13 keiron Exp $
*/
public class PDFTranscoder extends XMLAbstractTranscoder {
@@ -186,6 +186,7 @@
AffineTransform currentTransform = new AffineTransform(1, 0, 0, 1, 0, 0);
pdfAElementBridge.setCurrentTransform(currentTransform);
ctx.putBridge(pdfAElementBridge);
+ ctx.putBridge(new PDFImageElementBridge());
GraphicsNode gvtRoot;
try {
gvtRoot = builder.build(ctx, svgDoc);
@@ -376,6 +377,11 @@
return "en";
}
}
+
+ public String getMedia() {
+ return "";
+ }
+
/**
* Returns the user stylesheet specified in the
1.2 +5 -1 xml-fop/src/org/apache/fop/svg/SVGUserAgent.java
Index: SVGUserAgent.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/SVGUserAgent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SVGUserAgent.java 2001/09/24 07:31:52 1.1
+++ SVGUserAgent.java 2001/10/12 06:40:13 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: SVGUserAgent.java,v 1.1 2001/09/24 07:31:52 keiron Exp $
+ * $Id: SVGUserAgent.java,v 1.2 2001/10/12 06:40:13 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -85,6 +85,10 @@
*/
public String getLanguages() {
return "en"; // userLanguages;
+ }
+
+ public String getMedia() {
+ return "";
}
/**
1.1 xml-fop/src/org/apache/fop/svg/PDFImageElementBridge.java
Index: PDFImageElementBridge.java
===================================================================
/*
* $Id: PDFImageElementBridge.java,v 1.1 2001/10/12 06:40:13 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.svg;
import java.awt.Cursor;
import java.awt.geom.AffineTransform;
import org.apache.batik.bridge.*;
import org.apache.batik.css.HiddenChildElementSupport;
import org.apache.batik.gvt.CompositeGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.fop.pdf.*;
import org.apache.fop.image.*;
import org.apache.fop.apps.*;
import org.w3c.dom.Element;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.svg.SVGAElement;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.Graphics2D;
import java.awt.color.ICC_Profile;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import org.apache.batik.dom.svg.SVGOMDocument;
import org.apache.batik.dom.util.XLinkSupport;
import org.apache.batik.ext.awt.color.ICCColorSpaceExt;
import org.apache.batik.ext.awt.image.renderable.ClipRable8Bit;
import org.apache.batik.ext.awt.image.renderable.Filter;
import org.apache.batik.ext.awt.image.spi.ImageTagRegistry;
import org.apache.batik.gvt.CompositeGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.gvt.ImageNode;
import org.apache.batik.gvt.RasterImageNode;
import org.apache.batik.gvt.AbstractGraphicsNode;
import org.apache.batik.gvt.filter.GraphicsNodeRable8Bit;
import org.apache.batik.util.ParsedURL;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.css.CSSPrimitiveValue;
import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGSVGElement;
/**
* Bridge class for the <image> element when jpeg images.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Keiron Liddle</a>
*/
public class PDFImageElementBridge extends SVGImageElementBridge {
/**
* Constructs a new bridge for the <image> element.
*/
public PDFImageElementBridge() {}
/*
protected GraphicsNode createRasterImageNode(BridgeContext ctx,
Element e, ParsedURL purl) {
try {
JpegImage jpeg = new JpegImage(new URL(purl.toString()));
PDFFilter filter = jpeg.getPDFFilter();
PDFJpegNode node = new PDFJpegNode(jpeg);
Rectangle2D bounds = node.getPrimitiveBounds();
float [] vb = new float[4];
vb[0] = 0; // x
vb[1] = 0; // y
vb[2] = (float) bounds.getWidth(); // width
vb[3] = (float) bounds.getHeight(); // height
// handles the 'preserveAspectRatio', 'overflow' and 'clip' and sets the
// appropriate AffineTransform to the image node
initializeViewport(ctx, e, node, vb, bounds);
return node;
} catch (Exception ex) {
}
return super.createRasterImageNode(ctx, e, purl);
}
*/
public static class PDFJpegNode extends AbstractGraphicsNode {
JpegImage jpeg;
public PDFJpegNode(JpegImage j) {
jpeg = j;
}
public Shape getOutline() {
return getPrimitiveBounds();
}
public void primitivePaint(Graphics2D g2d) {
if (g2d instanceof PDFGraphics2D) {
PDFGraphics2D pdfg = (PDFGraphics2D) g2d;
pdfg.setTransform(getTransform());
float x = 0;
float y = 0;
try {
float width = jpeg.getWidth();
float height = jpeg.getHeight();
pdfg.addJpegImage(jpeg, x, y, width, height);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public Rectangle2D getGeometryBounds() {
return getPrimitiveBounds();
}
public Rectangle2D getPrimitiveBounds() {
try {
return new Rectangle2D.Double(0, 0, jpeg.getWidth(),
jpeg.getHeight());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]