[prev in list] [next in list] [prev in thread] [next in thread]
List: fop-cvs
Subject: cvs commit: xml-fop/src/org/apache/fop/svg PDFDocumentGraphics2D.java PDFTranscoder.java SVGElement.
From: keiron () apache ! org
Date: 2001-11-15 8:12:38
[Download RAW message or body]
keiron 01/11/15 00:12:37
Modified: src/org/apache/fop/fo XMLObj.java
src/org/apache/fop/image/analyser SVGReader.java
src/org/apache/fop/layout FontInfo.java
src/org/apache/fop/pdf PDFDocument.java
src/org/apache/fop/svg PDFDocumentGraphics2D.java
PDFTranscoder.java SVGElement.java
SVGUserAgent.java SVGUtilities.java
Log:
made the batik pdf transcoder work again
some improvements to svg handling
Submitted by: Thomas E Deweese <thomas.deweese@kodak.com>
Revision Changes Path
1.6 +30 -29 xml-fop/src/org/apache/fop/fo/XMLObj.java
Index: XMLObj.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/XMLObj.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLObj.java 2001/11/09 11:32:37 1.5
+++ XMLObj.java 2001/11/15 08:12:33 1.6
@@ -1,5 +1,5 @@
/*
- * $Id: XMLObj.java,v 1.5 2001/11/09 11:32:37 keiron Exp $
+ * $Id: XMLObj.java,v 1.6 2001/11/15 08:12:33 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.
@@ -53,51 +53,52 @@
public abstract String getNameSpace();
protected static HashMap ns = new HashMap();
+ static {
+ ns.put("xlink", "http://www.w3.org/1999/xlink");
+ }
public void addElement(Document doc, Element parent) {
this.doc = doc;
element = doc.createElementNS(getNameSpace(), name);
- for (int count = 0; count < attr.getLength(); count++) {
- String rf = attr.getValue(count);
- String qname = attr.getQName(count);
- if (qname.indexOf(":") == -1) {
- element.setAttribute(qname, rf);
+ for (int count = 0; count < attr.getLength(); count++) {
+ String rf = attr.getValue(count);
+ String qname = attr.getQName(count);
+ int idx = qname.indexOf(":");
+ if (idx == -1) {
+ element.setAttribute(qname, rf);
+ } else {
+ String pref = qname.substring(0, idx);
+ String tail = qname.substring(idx + 1);
+ if (pref.equals("xmlns")) {
+ ns.put(tail, rf);
} else {
- String pref =
- qname.substring(0, qname.indexOf(":"));
- if (pref.equals("xmlns")) {
- ns.put(qname.substring(qname.indexOf(":")
- + 1), rf);
- }
- ns.put("xlink", "http://www.w3.org/1999/xlink");
- element.setAttributeNS((String)ns.get(pref),
- qname, rf);
+ element.setAttributeNS((String)ns.get(pref), tail, rf);
}
}
+ }
attr = null;
parent.appendChild(element);
}
public void buildTopLevel(Document doc, Element svgRoot) {
// build up the info for the top level element
- for (int count = 0; count < attr.getLength(); count++) {
- String rf = attr.getValue(count);
- String qname = attr.getQName(count);
- if (qname.indexOf(":") == -1) {
- element.setAttribute(qname, rf);
+ for (int count = 0; count < attr.getLength(); count++) {
+ String rf = attr.getValue(count);
+ String qname = attr.getQName(count);
+ int idx = qname.indexOf(":");
+ if (idx == -1) {
+ element.setAttribute(qname, rf);
+ } else {
+ String pref = qname.substring(0, idx);
+ String tail = qname.substring(idx + 1);
+ if (pref.equals("xmlns")) {
+ ns.put(tail, rf);
} else {
- String pref =
- qname.substring(0, qname.indexOf(":"));
- if (pref.equals("xmlns")) {
- ns.put(qname.substring(qname.indexOf(":")
- + 1), rf);
- }
- ns.put("xlink", "http://www.w3.org/1999/xlink");
- element.setAttributeNS((String)ns.get(pref),
- qname, rf);
+ element.setAttributeNS((String)ns.get(pref), tail, rf);
}
}
+ }
}
public Document createBasicDocument() {
1.14 +2 -2 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- SVGReader.java 2001/10/30 07:04:10 1.13
+++ SVGReader.java 2001/11/15 08:12:34 1.14
@@ -1,5 +1,5 @@
/*
- * $Id: SVGReader.java,v 1.13 2001/10/30 07:04:10 keiron Exp $
+ * $Id: SVGReader.java,v 1.14 2001/11/15 08:12:34 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.
@@ -157,7 +157,7 @@
}
public String getMedia() {
- return "";
+ return "print";
}
/**
1.14 +4 -5 xml-fop/src/org/apache/fop/layout/FontInfo.java
Index: FontInfo.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/FontInfo.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FontInfo.java 2001/11/02 11:06:07 1.13
+++ FontInfo.java 2001/11/15 08:12:35 1.14
@@ -1,5 +1,5 @@
/*
- * $Id: FontInfo.java,v 1.13 2001/11/02 11:06:07 keiron Exp $
+ * $Id: FontInfo.java,v 1.14 2001/11/15 08:12:35 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.
@@ -8,7 +8,6 @@
package org.apache.fop.layout;
import java.util.HashMap;
-import org.apache.fop.messaging.MessageHandler;
import java.util.Enumeration;
import org.apache.fop.apps.FOPException;
@@ -58,10 +57,10 @@
if (f == null) {
throw new FOPException("no default font defined by \
OutputConverter"); }
- MessageHandler.errorln("defaulted font to any,normal,normal");
+ //MessageHandler.errorln("defaulted font to any,normal,normal");
}
- MessageHandler.errorln("unknown font " + key
- + " so defaulted font to any");
+ //MessageHandler.errorln("unknown font " + key
+ // + " so defaulted font to any");
}
usedFonts.put(f, fonts.get(f));
1.34 +2 -2 xml-fop/src/org/apache/fop/pdf/PDFDocument.java
Index: PDFDocument.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFDocument.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- PDFDocument.java 2001/11/12 13:10:11 1.33
+++ PDFDocument.java 2001/11/15 08:12:35 1.34
@@ -1,5 +1,5 @@
/*
- * $Id: PDFDocument.java,v 1.33 2001/11/12 13:10:11 keiron Exp $
+ * $Id: PDFDocument.java,v 1.34 2001/11/15 08:12:35 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.
@@ -946,7 +946,7 @@
/* add it to the list of objects */
this.objects.add(page);
-
+ pages.addPage(page);
return page;
}
1.15 +6 -10 xml-fop/src/org/apache/fop/svg/PDFDocumentGraphics2D.java
Index: PDFDocumentGraphics2D.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/PDFDocumentGraphics2D.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- PDFDocumentGraphics2D.java 2001/11/12 13:10:12 1.14
+++ PDFDocumentGraphics2D.java 2001/11/15 08:12:35 1.15
@@ -1,5 +1,5 @@
/*
- * $Id: PDFDocumentGraphics2D.java,v 1.14 2001/11/12 13:10:12 keiron Exp $
+ * $Id: PDFDocumentGraphics2D.java,v 1.15 2001/11/15 08:12:35 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.
@@ -31,7 +31,7 @@
* <tt>PDFGraphics2D</tt>.
*
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
- * @version $Id: PDFDocumentGraphics2D.java,v 1.14 2001/11/12 13:10:12 keiron Exp \
$ + * @version $Id: PDFDocumentGraphics2D.java,v 1.15 2001/11/15 08:12:35 keiron Exp \
$
* @see org.apache.fop.svg.PDFGraphics2D
*/
public class PDFDocumentGraphics2D extends PDFGraphics2D {
@@ -78,16 +78,16 @@
currentFontSize = 0;
currentYPosition = 0;
currentXPosition = 0;
-
- PDFResources pdfResources = this.pdfDoc.getResources();
- currentPage = this.pdfDoc.makePage(pdfResources,
- width, height);
}
void setupDocument(OutputStream stream, int width, int height) {
this.width = width;
this.height = height;
this.stream = stream;
+
+ PDFResources pdfResources = this.pdfDoc.getResources();
+ currentPage = this.pdfDoc.makePage(pdfResources,
+ width, height);
currentStream.write("1 0 0 -1 0 " + height + " cm\n");
}
@@ -165,10 +165,6 @@
pdfDoc.outputHeader(stream);
this.pdfDoc.output(stream);
pdfDoc.outputTrailer(stream);
- }
-
- public void setGraphicContext(GraphicContext c) {
- gc = c;
}
/**
1.14 +3 -3 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- PDFTranscoder.java 2001/11/09 11:32:42 1.13
+++ PDFTranscoder.java 2001/11/15 08:12:36 1.14
@@ -1,5 +1,5 @@
/*
- * $Id: PDFTranscoder.java,v 1.13 2001/11/09 11:32:42 keiron Exp $
+ * $Id: PDFTranscoder.java,v 1.14 2001/11/15 08:12:36 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:keiron@aftexsw.com">Keiron Liddle</a>
- * @version $Id: PDFTranscoder.java,v 1.13 2001/11/09 11:32:42 keiron Exp $
+ * @version $Id: PDFTranscoder.java,v 1.14 2001/11/15 08:12:36 keiron Exp $
*/
public class PDFTranscoder extends XMLAbstractTranscoder {
@@ -382,7 +382,7 @@
}
public String getMedia() {
- return "";
+ return "print";
}
/**
1.19 +103 -23 xml-fop/src/org/apache/fop/svg/SVGElement.java
Index: SVGElement.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/SVGElement.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- SVGElement.java 2001/11/09 11:32:42 1.18
+++ SVGElement.java 2001/11/15 08:12:37 1.19
@@ -1,5 +1,5 @@
/*
- * $Id: SVGElement.java,v 1.18 2001/11/09 11:32:42 keiron Exp $
+ * $Id: SVGElement.java,v 1.19 2001/11/15 08:12:37 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.
@@ -29,8 +29,14 @@
import org.apache.batik.gvt.renderer.*;
import org.apache.batik.gvt.filter.*;
import org.apache.batik.gvt.event.*;
+import org.apache.batik.bridge.UnitProcessor;
+import org.apache.batik.css.value.ImmutableFloat;
+import org.apache.batik.css.CSSOMReadOnlyValue;
+import org.apache.batik.util.SVGConstants;
import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.css.CSSPrimitiveValue;
+
import org.apache.batik.dom.svg.SVGDOMImplementation;
import java.io.File;
@@ -38,6 +44,7 @@
import java.util.List;
import java.util.ArrayList;
import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
/**
* class representing svg:svg pseudo flow object.
@@ -126,30 +133,11 @@
//if(!e.hasAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns")) {
e.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns", \
SVGDOMImplementation.SVG_NAMESPACE_URI); //}
-
- String s;
- SVGUserAgent userAgent = new SVGUserAgent(new AffineTransform());
- userAgent.setLogger(log);
- BridgeContext ctx = new BridgeContext(userAgent);
- UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
-
- // 'width' attribute - default is 100%
- s = e.getAttributeNS(null, SVGOMDocument.SVG_WIDTH_ATTRIBUTE);
- if (s.length() == 0) {
- s = SVGOMDocument.SVG_SVG_WIDTH_DEFAULT_VALUE;
- }
- float width = UnitProcessor.svgHorizontalLengthToUserSpace
- (s, SVGOMDocument.SVG_WIDTH_ATTRIBUTE, uctx);
- // 'height' attribute - default is 100%
- s = e.getAttributeNS(null, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE);
- if (s.length() == 0) {
- s = SVGOMDocument.SVG_SVG_HEIGHT_DEFAULT_VALUE;
- }
- float height = UnitProcessor.svgVerticalLengthToUserSpace
- (s, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx);
+ Point2D p2d = getSize(this.fs, svgRoot);
- SVGArea svg = new SVGArea(fs, width, height);
+ SVGArea svg = new SVGArea(fs, (float)p2d.getX(),
+ (float)p2d.getY());
svg.setSVGDocument(doc);
svg.start();
@@ -186,4 +174,96 @@
FONT_FAMILY.add("serif");
}
+ public static Point2D getSize(FontState fs, Element svgRoot) {
+ String str;
+ UnitProcessor.Context ctx;
+ ctx = new PDFUnitContext(fs, svgRoot);
+ str = svgRoot.getAttributeNS(null, SVGConstants.SVG_WIDTH_ATTRIBUTE);
+ if (str.length() == 0) str = "100%";
+ float width = UnitProcessor.svgHorizontalLengthToUserSpace
+ (str, SVGConstants.SVG_WIDTH_ATTRIBUTE, ctx);
+
+ str = svgRoot.getAttributeNS(null, SVGConstants.SVG_HEIGHT_ATTRIBUTE);
+ if (str.length() == 0) str = "100%";
+ float height = UnitProcessor.svgVerticalLengthToUserSpace
+ (str, SVGConstants.SVG_HEIGHT_ATTRIBUTE, ctx);
+ return new Point2D.Float(width, height);
+ }
+ /**
+ * This class is the default context for a particular
+ * element. Informations not available on the element are get from
+ * the bridge context (such as the viewport or the pixel to
+ * millimeter factor.
+ */
+ public static class PDFUnitContext implements UnitProcessor.Context {
+
+ /** The element. */
+ protected Element e;
+ protected FontState fs;
+ public PDFUnitContext(FontState fs, Element e) {
+ this.e = e;
+ this.fs = fs;
+ }
+
+ /**
+ * Returns the element.
+ */
+ public Element getElement() {
+ return e;
+ }
+
+ /**
+ * Returns the context of the parent element of this context.
+ * Since this is always for the root SVG element there never
+ * should be one...
+ */
+ public UnitProcessor.Context getParentElementContext() {
+ return null;
+ }
+
+ /**
+ * Returns the pixel to mm factor.
+ */
+ public float getPixelToMM() {
+ return 0.264583333333333333333f;
+ // 72 dpi
+ }
+
+ /**
+ * Returns the font-size medium value in pt.
+ */
+ public float getMediumFontSize() {
+ return 9f;
+ }
+
+ /**
+ * Returns the font-size value.
+ */
+ public CSSPrimitiveValue getFontSize() {
+ return new CSSOMReadOnlyValue
+ (new ImmutableFloat(CSSPrimitiveValue.CSS_PT,
+ fs.getFontSize()));
+ }
+
+ /**
+ * Returns the x-height value.
+ */
+ public float getXHeight() {
+ return 0.5f;
+ }
+
+ /**
+ * Returns the viewport width used to compute units.
+ */
+ public float getViewportWidth() {
+ return 100;
+ }
+
+ /**
+ * Returns the viewport height used to compute units.
+ */
+ public float getViewportHeight() {
+ return 100;
+ }
+ }
}
1.6 +2 -2 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SVGUserAgent.java 2001/11/09 11:32:42 1.5
+++ SVGUserAgent.java 2001/11/15 08:12:37 1.6
@@ -1,5 +1,5 @@
/*
- * $Id: SVGUserAgent.java,v 1.5 2001/11/09 11:32:42 keiron Exp $
+ * $Id: SVGUserAgent.java,v 1.6 2001/11/15 08:12:37 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,7 +85,7 @@
}
public String getMedia() {
- return "";
+ return "print";
}
/**
1.3 +2 -2 xml-fop/src/org/apache/fop/svg/SVGUtilities.java
Index: SVGUtilities.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/SVGUtilities.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SVGUtilities.java 2001/07/30 20:29:34 1.2
+++ SVGUtilities.java 2001/11/15 08:12:37 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: SVGUtilities.java,v 1.2 2001/07/30 20:29:34 tore Exp $
+ * $Id: SVGUtilities.java,v 1.3 2001/11/15 08:12:37 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.
@@ -161,7 +161,7 @@
public static final Element createImage(Document doc, String ref,
float width, float height) {
Element border = doc.createElementNS(svgNS, "image");
- border.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href",
+ border.setAttributeNS("http://www.w3.org/1999/xlink", "href",
ref);
border.setAttributeNS(null, "width", "" + width);
border.setAttributeNS(null, "height", "" + height);
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic