*
*/
abstract public class FONode {
+ protected FOUserAgent userAgent;
protected FONode parent;
protected String name;
}
public void setUserAgent(FOUserAgent ua) {
+ userAgent = ua;
}
public void setStreamRenderer(StreamRenderer st) {
import javax.xml.parsers.DocumentBuilderFactory;
import java.util.*;
+import java.awt.geom.Point2D;
/**
* Generic XML object.
return doc;
}
+ public Point2D getDimension(Point2D view) {
+ return null;
+ }
+
public abstract String getNameSpace();
protected static HashMap ns = new HashMap();
int width;
String id;
- ImageArea imageArea;
-
public ExternalGraphic(FONode parent) {
super(parent);
}
}
protected InlineArea getInlineArea() {
+ if(url == null) {
+ return null;
+ }
url = ImageFactory.getURL(url);
// if we need to load this image to get its size
// FopImage fopimage = ImageFactory.getImage(url, userAgent);
import org.w3c.dom.Document;
+import java.awt.geom.Point2D;
+
public class InstreamForeignObject extends FObj {
int breakBefore;
// if auto then use the intrinsic size of the content scaled
// to the content-height and content-width
+ Point2D size = child.getDimension(new Point2D.Float(-1, -1));
+
Document doc = child.getDocument();
String ns = child.getNameSpace();
+++ /dev/null
-/*
- * $Id$
- * 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.image;
-
-import org.apache.fop.fo.properties.TextAlign;
-import org.apache.fop.layout.*;
-import org.apache.fop.layout.inline.*;
-
-import org.apache.fop.render.Renderer;
-
-public class ImageArea extends InlineArea {
-
- protected int xOffset = 0;
- protected int align;
- protected int valign;
- protected FopImage image;
-
-
- public ImageArea(FontState fontState, FopImage img,
- int AllocationWidth, int width, int height,
- int startIndent, int endIndent, int align) {
- super(fontState, width, 0, 0, 0);
- this.currentHeight = height;
- this.contentRectangleWidth = width;
- this.height = height;
- this.image = img;
- this.align = align;
-
- /*
- * switch (align) {
- * case TextAlign.START:
- * xOffset = startIndent;
- * break;
- * case TextAlign.END:
- * if (endIndent == 0)
- * endIndent = AllocationWidth;
- * xOffset = (endIndent - width);
- * break;
- * case TextAlign.JUSTIFY:
- * xOffset = startIndent;
- * break;
- * case TextAlign.CENTER:
- * if (endIndent == 0)
- * endIndent = AllocationWidth;
- * xOffset = startIndent + ((endIndent - startIndent) - width)/2;
- * break;
- * }
- */
- }
-
- public int getXOffset() {
- return this.xOffset;
- }
-
- public FopImage getImage() {
- return this.image;
- }
-
- public int getImageHeight() {
- return currentHeight;
- }
-
- public void setAlign(int align) {
- this.align = align;
- }
-
- public int getAlign() {
- return this.align;
- }
-
- public void setVerticalAlign(int align) {
- this.valign = align;
- }
-
- public int getVerticalAlign() {
- return this.valign;
- }
-
- public void setStartIndent(int startIndent) {
- xOffset = startIndent;
- }
-
-}
-
package org.apache.fop.render;
// FOP
-import org.apache.fop.image.ImageArea;
import org.apache.fop.apps.FOPException;
import org.apache.fop.area.*;
import org.apache.fop.area.Span;
// FOP
import org.apache.fop.pdf.PDFPathPaint;
import org.apache.fop.pdf.PDFColor;
-import org.apache.fop.image.ImageArea;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.*;
import org.apache.fop.datatypes.*;
package org.apache.fop.render;
// FOP
-import org.apache.fop.image.ImageArea;
import org.apache.fop.apps.FOPException;
import org.apache.fop.area.*;
import org.apache.fop.area.inline.*;
// FOP
import org.apache.fop.render.Renderer;
import org.apache.fop.render.AbstractRenderer;
-import org.apache.fop.image.ImageArea;
import org.apache.fop.image.FopImage;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.*;
// FOP
import org.apache.fop.render.PrintRenderer;
-import org.apache.fop.image.ImageArea;
import org.apache.fop.image.FopImage;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.inline.*;
import org.apache.fop.image.*;
-import org.apache.fop.svg.SVGArea;
import org.w3c.dom.svg.SVGSVGElement;
import org.w3c.dom.svg.SVGDocument;
// FOP
import org.apache.fop.render.PrintRenderer;
-import org.apache.fop.image.ImageArea;
import org.apache.fop.image.FopImage;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.*;
package org.apache.fop.render.ps;
// FOP
-import org.apache.fop.svg.SVGArea;
import org.apache.fop.render.AbstractRenderer;
import org.apache.fop.render.Renderer;
-import org.apache.fop.image.ImageArea;
import org.apache.fop.image.FopImage;
import org.apache.fop.layout.*;
import org.apache.fop.layout.inline.*;
import org.apache.fop.datatypes.IDReferences;
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.image.*;
-import org.apache.fop.svg.SVGArea;
import org.apache.fop.svg.SVGUtilities;
import org.apache.fop.layout.FontInfo;
import org.apache.fop.fo.FOUserAgent;
import org.apache.fop.pdf.PDFColor;
import org.apache.fop.image.*;
-import org.apache.fop.svg.SVGArea;
-
import org.w3c.dom.svg.SVGSVGElement;
import org.w3c.dom.svg.SVGDocument;
import org.apache.fop.render.AbstractRenderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.XMLHandler;
-import org.apache.fop.image.ImageArea;
import org.apache.fop.area.*;
import org.apache.fop.area.inline.*;
import org.apache.fop.pdf.*;
+++ /dev/null
-/*
- * $Id$
- * 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;
-
-// FOP
-import org.apache.fop.render.Renderer;
-import org.apache.fop.layout.FontState;
-import org.apache.fop.layout.Area;
-
-//import java.util.*;
-
-import org.w3c.dom.svg.*;
-import org.w3c.dom.*;
-
-/**
- * class representing an SVG area in which the SVG graphics sit
- */
-public class SVGArea extends Area {
- Document doc;
-
- /**
- * construct an SVG area
- *
- * @param fontState the font state
- * @param width the width of the area
- * @param height the height of the area
- */
- public SVGArea(FontState fontState, float width, float height) {
- super(fontState, (int)width * 1000, (int)height * 1000);
- currentHeight = (int)height * 1000;
- contentRectangleWidth = (int)width * 1000;
- }
-
- public void setSVGDocument(Document doc) {
- this.doc = doc;
- }
-
- public Document getSVGDocument() {
- return doc;
- }
-
- public int getWidth() {
- // return getSVGDocument().getRootElement().getWidth().getBaseVal().getValue();
- return contentRectangleWidth;
- }
-
-}
import java.util.ArrayList;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
+import java.awt.Dimension;
/**
* class representing svg:svg pseudo flow object.
*/
public class SVGElement extends SVGObj {
- FontState fs;
-
/**
* constructs an SVG object (called by Maker).
*
init();
}
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(final Area area) throws FOPException {
-
- if (!(area instanceof ForeignObjectArea)) {
- // this is an error
- throw new FOPException("SVG not in fo:instream-foreign-object");
- }
-
- this.fs = area.getFontState();
+ public Point2D getDimension(Point2D view) {
// TODO - change so doesn't hold onto fo,area tree
Element svgRoot = element;
/* if width and height are zero, get the bounds of the content. */
FOPSVGContext dc = new FOPSVGContext();
dc.svgRoot = element;
- ForeignObjectArea foa = (ForeignObjectArea)area;
- dc.cwauto = foa.isContentWidthAuto();
- dc.chauto = foa.isContentHeightAuto();
- dc.cwidth = foa.getContentWidth();
- dc.cheight = foa.getContentHeight();
+ 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 = Configuration.getStringValue("baseDir");
+ String baseDir = userAgent.getBaseDirectory();
if(baseDir != null) {
((SVGOMDocument)doc).setURLObject(new URL(baseDir));
}
e.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns", SVGDOMImplementation.SVG_NAMESPACE_URI);
//}
- Point2D p2d = getSize(this.fs, svgRoot);
-
- SVGArea svg = new SVGArea(fs, (float)p2d.getX(),
- (float)p2d.getY());
- svg.setSVGDocument(doc);
- svg.start();
-
- /* finish off the SVG area */
- svg.end();
-
- /* add the SVG area to the containing area */
- foa.setObject(svg);
- foa.setIntrinsicWidth(svg.getWidth());
- foa.setIntrinsicHeight(svg.getHeight());
+ Point2D p2d = getSize(12 /* font size */, svgRoot);
- /* return status */
- return new Status(Status.OK);
+ return p2d;
}
private void init() {
buildTopLevel(doc, element);
}
- public static Point2D getSize(FontState fs, Element svgRoot) {
+ public static Point2D getSize(int size, Element svgRoot) {
String str;
UnitProcessor.Context ctx;
- ctx = new PDFUnitContext(fs, svgRoot);
+ ctx = new PDFUnitContext(size, svgRoot);
str = svgRoot.getAttributeNS(null, SVGConstants.SVG_WIDTH_ATTRIBUTE);
if (str.length() == 0) str = "100%";
float width = UnitProcessor.svgHorizontalLengthToUserSpace
/** The element. */
protected Element e;
- protected FontState fs;
- public PDFUnitContext(FontState fs, Element e) {
+ protected int fontSize;
+ public PDFUnitContext(int size, Element e) {
this.e = e;
- this.fs = fs;
+ this.fontSize = size;
}
/**
public CSSPrimitiveValue getFontSize() {
return new CSSOMReadOnlyValue
(new ImmutableFloat(CSSPrimitiveValue.CSS_PT,
- fs.getFontSize()));
+ fontSize));
}
/**