You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2002/03/21 10:28:44 UTC
cvs commit: xml-fop/src/org/apache/fop/svg PDFAElementBridge.java PDFImageElementBridge.java PDFTextElementBridge.java PDFTranscoder.java SVGElement.java SVGUserAgent.java
keiron 02/03/21 01:28:44
Modified: src/org/apache/fop/svg PDFAElementBridge.java
PDFImageElementBridge.java
PDFTextElementBridge.java PDFTranscoder.java
SVGElement.java SVGUserAgent.java
Log:
updated to changes in batik api
Revision Changes Path
1.4 +1 -2 xml-fop/src/org/apache/fop/svg/PDFAElementBridge.java
Index: PDFAElementBridge.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/PDFAElementBridge.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PDFAElementBridge.java 14 Aug 2001 14:50:30 -0000 1.3
+++ PDFAElementBridge.java 21 Mar 2002 09:28:43 -0000 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: PDFAElementBridge.java,v 1.3 2001/08/14 14:50:30 keiron Exp $
+ * $Id: PDFAElementBridge.java,v 1.4 2002/03/21 09:28:43 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.
@@ -12,7 +12,6 @@
import org.apache.batik.bridge.*;
-import org.apache.batik.css.HiddenChildElementSupport;
import org.apache.batik.gvt.CompositeGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
1.2 +1 -2 xml-fop/src/org/apache/fop/svg/PDFImageElementBridge.java
Index: PDFImageElementBridge.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/PDFImageElementBridge.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFImageElementBridge.java 12 Oct 2001 06:40:13 -0000 1.1
+++ PDFImageElementBridge.java 21 Mar 2002 09:28:43 -0000 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: PDFImageElementBridge.java,v 1.1 2001/10/12 06:40:13 keiron Exp $
+ * $Id: PDFImageElementBridge.java,v 1.2 2002/03/21 09:28:43 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.
@@ -12,7 +12,6 @@
import org.apache.batik.bridge.*;
-import org.apache.batik.css.HiddenChildElementSupport;
import org.apache.batik.gvt.CompositeGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
1.3 +2 -7 xml-fop/src/org/apache/fop/svg/PDFTextElementBridge.java
Index: PDFTextElementBridge.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/PDFTextElementBridge.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PDFTextElementBridge.java 19 Feb 2002 13:03:15 -0000 1.2
+++ PDFTextElementBridge.java 21 Mar 2002 09:28:43 -0000 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: PDFTextElementBridge.java,v 1.2 2002/02/19 13:03:15 keiron Exp $
+ * $Id: PDFTextElementBridge.java,v 1.3 2002/03/21 09:28:43 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.
@@ -10,7 +10,6 @@
import org.apache.batik.gvt.TextNode;
import org.apache.batik.bridge.*;
-import org.apache.batik.css.CSSOMReadOnlyStyleDeclaration;
import org.apache.batik.gvt.CompositeGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
@@ -59,12 +58,8 @@
* applied to the text.
*/
private boolean isSimple(BridgeContext ctx, Element element, GraphicsNode node) {
- CSSOMReadOnlyStyleDeclaration cssDecl
- = CSSUtilities.getComputedStyle(element);
- UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element);
-
// Font size, in user space units.
- float fs = TextUtilities.convertFontSize(element, ctx, cssDecl, uctx);
+ float fs = TextUtilities.convertFontSize(element).floatValue();
if(((int)fs) != fs) {
return false;
}
1.17 +3 -6 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- PDFTranscoder.java 11 Mar 2002 12:57:18 -0000 1.16
+++ PDFTranscoder.java 21 Mar 2002 09:28:43 -0000 1.17
@@ -1,5 +1,5 @@
/*
- * $Id: PDFTranscoder.java,v 1.16 2002/03/11 12:57:18 keiron Exp $
+ * $Id: PDFTranscoder.java,v 1.17 2002/03/21 09:28:43 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.
@@ -41,10 +41,10 @@
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.batik.bridge.ViewBox;
-import org.apache.batik.dom.svg.DefaultSVGContext;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.dom.svg.SVGOMDocument;
+import org.apache.batik.dom.svg.SVGContext;
import org.apache.batik.dom.util.DocumentFactory;
import org.apache.batik.ext.awt.image.GraphicsUtil;
@@ -121,7 +121,7 @@
* millimeter conversion factor.
*
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
- * @version $Id: PDFTranscoder.java,v 1.16 2002/03/11 12:57:18 keiron Exp $
+ * @version $Id: PDFTranscoder.java,v 1.17 2002/03/21 09:28:43 keiron Exp $
*/
public class PDFTranscoder extends XMLAbstractTranscoder {
@@ -163,9 +163,6 @@
SVGSVGElement root = svgDoc.getRootElement();
// initialize the SVG document with the appropriate context
String parserClassname = (String)hints.get(KEY_XML_PARSER_CLASSNAME);
- DefaultSVGContext svgCtx = new DefaultSVGContext();
- svgCtx.setPixelToMM(userAgent.getPixelToMM());
- ((SVGOMDocument)document).setSVGContext(svgCtx);
/*boolean stroke = true;
if (hints.containsKey(KEY_STROKE_TEXT)) {
1.22 +29 -67 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.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- SVGElement.java 26 Feb 2002 12:43:10 -0000 1.21
+++ SVGElement.java 21 Mar 2002 09:28:43 -0000 1.22
@@ -1,5 +1,5 @@
/*
- * $Id: SVGElement.java,v 1.21 2002/02/26 12:43:10 keiron Exp $
+ * $Id: SVGElement.java,v 1.22 2002/03/21 09:28:43 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.
@@ -30,8 +30,6 @@
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;
@@ -45,6 +43,7 @@
import java.util.ArrayList;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
import java.awt.Dimension;
/**
@@ -67,22 +66,15 @@
init();
}
- public Point2D getDimension(Point2D view) {
+ public Point2D getDimension(final Point2D view) {
// TODO - change so doesn't hold onto fo,area tree
Element svgRoot = element;
/* create an SVG area */
/* if width and height are zero, get the bounds of the content. */
- FOPSVGContext dc = new FOPSVGContext();
- dc.svgRoot = element;
- dc.cwauto = (view.getX() == -1);
- dc.chauto = (view.getY() == -1);
- dc.cwidth = (float)view.getX();
- dc.cheight = (float)view.getY();
- ((SVGOMDocument)doc).setSVGContext(dc);
try {
- String baseDir = userAgent.getBaseDirectory();
+ String baseDir = userAgent.getBaseURL();
if(baseDir != null) {
((SVGOMDocument)doc).setURLObject(new URL(baseDir));
}
@@ -91,12 +83,28 @@
}
Element e = ((SVGDocument)doc).getRootElement();
+ final float ptmm = userAgent.getPixelToMM();
+ SVGContext dc = new SVGContext() {
+ public float getPixelToMM() {
+ return ptmm;
+ }
+
+ public Rectangle2D getBBox() {
+ return new Rectangle2D.Double(0, 0, view.getX(), view.getY());
+ }
+
+ public AffineTransform getCTM() {
+ return new AffineTransform();
+ }
+ };
+ ((SVGOMElement)e).setSVGContext(dc);
//if(!e.hasAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns")) {
e.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns", SVGDOMImplementation.SVG_NAMESPACE_URI);
//}
- Point2D p2d = getSize(12 /* font size */, svgRoot);
+ Point2D p2d = getSize(12 /* font size */, svgRoot, userAgent.getPixelToMM());
+ ((SVGOMElement)e).setSVGContext(null);
return p2d;
}
@@ -111,10 +119,10 @@
buildTopLevel(doc, element);
}
- public static Point2D getSize(int size, Element svgRoot) {
+ public static Point2D getSize(int size, Element svgRoot, float ptmm) {
String str;
UnitProcessor.Context ctx;
- ctx = new PDFUnitContext(size, svgRoot);
+ ctx = new PDFUnitContext(size, svgRoot, ptmm);
str = svgRoot.getAttributeNS(null, SVGConstants.SVG_WIDTH_ATTRIBUTE);
if (str.length() == 0) str = "100%";
float width = UnitProcessor.svgHorizontalLengthToUserSpace
@@ -137,7 +145,9 @@
/** The element. */
protected Element e;
protected int fontSize;
- public PDFUnitContext(int size, Element e) {
+ float pixeltoMM;
+
+ public PDFUnitContext(int size, Element e, float ptmm) {
this.e = e;
this.fontSize = size;
}
@@ -162,8 +172,7 @@
* Returns the pixel to mm factor.
*/
public float getPixelToMM() {
- return 0.264583333333333333333f;
- // 72 dpi
+ return pixeltoMM;
}
/**
@@ -176,10 +185,8 @@
/**
* Returns the font-size value.
*/
- public CSSPrimitiveValue getFontSize() {
- return new CSSOMReadOnlyValue
- (new ImmutableFloat(CSSPrimitiveValue.CSS_PT,
- fontSize));
+ public float getFontSize() {
+ return fontSize;
}
/**
@@ -202,51 +209,6 @@
public float getViewportHeight() {
return 100;
}
- }
-}
-
-class FOPSVGContext extends DefaultSVGContext {
- public boolean cwauto;
- public boolean chauto;
- public float cwidth;
- public float cheight;
- public Element svgRoot;
-
- public float getPixelToMM() {
- // 72 dpi
- return 0.35277777777777777778f;
- }
-
- public float getViewportWidth(Element e) throws IllegalStateException {
- if(e == svgRoot) {
- if(!cwauto) {
- return cwidth;
- }
- }
- return super.getViewportWidth(e);
- }
-
- public float getViewportHeight(Element e) throws IllegalStateException {
- if(e == svgRoot) {
- if(!chauto) {
- return cheight;
- }
- }
- return super.getViewportHeight(e);
- }
-
- public List getDefaultFontFamilyValue() {
- return FONT_FAMILY;
- }
-
- public final static List FONT_FAMILY;
- static {
- FONT_FAMILY = new ArrayList();
- FONT_FAMILY.add("Helvetica");
- FONT_FAMILY.add("Times");
- FONT_FAMILY.add("Courier");
- FONT_FAMILY.add("sans-serif");
- FONT_FAMILY.add("serif");
}
}
1.8 +8 -9 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SVGUserAgent.java 11 Mar 2002 12:57:18 -0000 1.7
+++ SVGUserAgent.java 21 Mar 2002 09:28:43 -0000 1.8
@@ -1,5 +1,5 @@
/*
- * $Id: SVGUserAgent.java,v 1.7 2002/03/11 12:57:18 keiron Exp $
+ * $Id: SVGUserAgent.java,v 1.8 2002/03/21 09:28:43 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.
@@ -7,6 +7,8 @@
package org.apache.fop.svg;
+import org.apache.fop.fo.FOUserAgent;
+
import org.apache.log.Logger;
import org.apache.batik.bridge.*;
@@ -34,16 +36,15 @@
public class SVGUserAgent extends UserAgentAdapter {
AffineTransform currentTransform = null;
Logger log;
+ FOUserAgent userAgent;
/**
* Creates a new SVGUserAgent.
*/
- public SVGUserAgent(AffineTransform at) {
+ public SVGUserAgent(FOUserAgent ua, AffineTransform at) {
currentTransform = at;
- }
-
- public void setLogger(Logger logger) {
- log = logger;
+ userAgent = ua;
+ log = userAgent.getLogger();
}
/**
@@ -79,9 +80,7 @@
* Returns a customized the pixel to mm factor.
*/
public float getPixelToMM() {
- // this is set to 72dpi as the values in fo are 72dpi
- return 0.35277777777777777778f; // 72 dpi
- // return 0.26458333333333333333333333333333f; // 96dpi
+ return userAgent.getPixelToMM();
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org