import org.apache.fop.dom.svg.*;
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:a pseudo flow object.
*
*/
-public class A extends FObj implements GraphicsCreator {
+public class A extends SVGObj {
/**
* inner class for making A objects.
this.name = "svg:a";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
String rf = this.properties.get("xlink:href").getString();
SVGAElementImpl graphic;
for (int i = 0; i < numChildren; i++) {
FONode child = (FONode) children.elementAt(i);
if(child instanceof GraphicsCreator) {
- GraphicImpl impl = ((GraphicsCreator)child).createGraphic();
+ SVGElement impl = ((GraphicsCreator)child).createGraphic();
graphic.appendChild((GraphicElement)impl);
} else if(child instanceof Defs) {
}
return graphic;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:a outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:altGlyph pseudo flow object.
*
*/
-public class AltGlyph extends FObj {
+public class AltGlyph extends SVGObj {
/**
* inner class for making AltGlyph objects.
super(parent, propertyList);
this.name = "svg:altGlyph";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
-// ((SVGArea) area).addGraphic(new AltGlyphGraphic(x1, y1, x2, y2));
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:altGlyph outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:Animate pseudo flow object.
*
*/
-public class Animate extends FObj {
+public class Animate extends SVGObj {
/**
* inner class for making Animate objects.
super(parent, propertyList);
this.name = "svg:animate";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
-// ((SVGArea) area).addGraphic(new AnimateGraphic(x1, y1, x2, y2));
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:animate outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:AnimateColor pseudo flow object.
*
*/
-public class AnimateColor extends FObj {
+public class AnimateColor extends SVGObj {
/**
* inner class for making AnimateColor objects.
super(parent, propertyList);
this.name = "svg:animateColor";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a AnimateColor to the SVGArea */
-// ((SVGArea) area).addGraphic(new AnimateColorGraphic(x1, y1, x2, y2));
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:animateColor outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:AnimateMotion pseudo flow object.
*
*/
-public class AnimateMotion extends FObj {
+public class AnimateMotion extends SVGObj {
/**
* inner class for making AnimateMotion objects.
super(parent, propertyList);
this.name = "svg:animateMotion";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a AnimateMotion to the SVGArea */
-// ((SVGArea) area).addGraphic(new AnimateMotionGraphic(x1, y1, x2, y2));
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:animateMotion outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:AnimateTransform pseudo flow object.
*
*/
-public class AnimateTransform extends FObj {
+public class AnimateTransform extends SVGObj {
/**
* inner class for making AnimateTransform objects.
super(parent, propertyList);
this.name = "svg:animateTransform";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
-// ((SVGArea) area).addGraphic(new AnimateTransformGraphic(x1, y1, x2, y2));
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:animateTransform outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.SVGArea;
import org.w3c.dom.svg.SVGLength;
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:Circle pseudo flow object.
*
*/
-public class Circle extends FObj implements GraphicsCreator {
+public class Circle extends SVGObj {
/**
* inner class for making Circle objects.
this.name = "svg:circle";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
/* retrieve properties */
SVGLength cx = ((SVGLengthProperty)this.properties.get("cx")).getSVGLength();
graph.setCy(new SVGAnimatedLengthImpl(cy));
graph.setR(new SVGAnimatedLengthImpl(r));
graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:circle outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:ClipPath pseudo flow object.
*
*/
-public class ClipPath extends FObj implements GraphicsCreator {
+public class ClipPath extends SVGObj {
/**
* inner class for making ClipPath objects.
super.addChild(child);
if(child instanceof GraphicsCreator) {
GraphicsCreator gc = (GraphicsCreator)child;
- GraphicImpl graph = gc.createGraphic();
+ SVGElement graph = gc.createGraphic();
clippath.addElement(graph);
- graph.setParent(clippath);
+// graph.setParent(clippath);
} else {
// error
}
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
clippath.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
clippath.setId(this.properties.get("id").getString());
return clippath;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:clipPath outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
/**
*
*/
-public class Cursor extends FObj {
+public class Cursor extends SVGObj {
/**
* inner class for making Cursor objects.
super(parent, propertyList);
this.name = "svg:cursor";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGCursorElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:cursor outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import java.util.*;
-import org.w3c.dom.svg.SVGElement;
+import org.w3c.dom.svg.*;
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
* class representing svg:Defs pseudo flow object.
*
*/
-public class Defs extends FObj {
+public class Defs extends SVGObj {
/**
* inner class for making Defs objects.
this.name = "svg:defs";
}
- Hashtable defs = new Hashtable();
+// Hashtable defs = new Hashtable();
- public Hashtable createDefs()
+ public SVGElement createGraphic()
{
+ SVGDefsElement defs = new SVGDefsElementImpl();
int numChildren = this.children.size();
for (int i = 0; i < numChildren; i++) {
FONode child = (FONode) children.elementAt(i);
if(child instanceof GraphicsCreator) {
- GraphicImpl gi = ((GraphicsCreator)child).createGraphic();
+ SVGElement gi = ((GraphicsCreator)child).createGraphic();
if(gi instanceof SVGElement) {
+ defs.appendChild((SVGElement)gi);
String id = ((SVGElement)gi).getId();
if(!id.equals("")) {
- defs.put(id, gi);
+// defs.put(id, gi);
} else {
// no id
System.err.println("WARNING No ID for defs element : " + gi);
}
return defs;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addDefs(createDefs());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:defs outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:Desc pseudo flow object.
*
*/
-public class Desc extends FObj {
+public class Desc extends SVGObj {
/**
* inner class for making Desc objects.
import org.apache.fop.dom.svg.SVGArea;
import org.w3c.dom.svg.SVGLength;
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:Ellipse pseudo flow object.
*
*/
-public class Ellipse extends FObj implements GraphicsCreator {
+public class Ellipse extends SVGObj {
/**
* inner class for making Ellipse objects.
this.name = "svg:ellipse";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
/* retrieve properties */
SVGLength cx = ((SVGLengthProperty)this.properties.get("cx")).getSVGLength();
graph.setRx(new SVGAnimatedLengthImpl(rx));
graph.setRy(new SVGAnimatedLengthImpl(ry));
graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:ellipse outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:Filter pseudo flow object.
*
*/
-public class Filter extends FObj {
+public class Filter extends SVGObj {
/**
* inner class for making Filter objects.
super(parent, propertyList);
this.name = "svg:filter";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGFilterElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:filter outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:Font pseudo flow object.
*
*/
-public class Font extends FObj {
+public class Font extends SVGObj {
/**
* inner class for making Font objects.
super(parent, propertyList);
this.name = "svg:font";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGFontElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:font outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:G pseudo flow object.
*
*/
-public class G extends FObj implements GraphicsCreator {
+public class G extends SVGObj {
/**
* inner class for making G objects.
SVGGElementImpl ggraphic = new SVGGElementImpl();
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
- ggraphic.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ ggraphic.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
ggraphic.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
ggraphic.setId(this.properties.get("id").getString());
int numChildren = this.children.size();
for (int i = 0; i < numChildren; i++) {
FONode child = (FONode) children.elementAt(i);
if(child instanceof GraphicsCreator) {
- GraphicImpl impl = ((GraphicsCreator)child).createGraphic();
- ggraphic.addGraphic(impl);
+ SVGElement impl = ((GraphicsCreator)child).createGraphic();
+ if(impl != null)
+ ggraphic.appendChild(impl);
} else if(child instanceof Defs) {
// System.out.println(child);
- ggraphic.addDefs(((Defs)child).createDefs());
+// ggraphic.addDefs(((Defs)child).createDefs());
}
}
return ggraphic;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException
- {
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a G to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:g outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:Glyph pseudo flow object.
*
*/
-public class Glyph extends FObj {
+public class Glyph extends SVGObj {
/**
* inner class for making Glyph objects.
super(parent, propertyList);
this.name = "svg:glyph";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGGlyphElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:glyph outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.*;
+import org.w3c.dom.svg.SVGElement;
+
/**
*
*/
public interface GraphicsCreator {
- public GraphicImpl createGraphic();
+ public SVGElement createGraphic();
}
/**
*
*/
-public class HKern extends FObj {
+public class HKern extends SVGObj {
/**
* inner class for making HKern objects.
super(parent, propertyList);
this.name = "svg:hkern";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGHKernElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:hkern outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:Image pseudo flow object.
*
*/
-public class Image extends FObj implements GraphicsCreator {
+public class Image extends SVGObj {
/**
* inner class for making Image objects.
this.name = "svg:image";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
String link = this.properties.get("xlink:href").getString();
float x = ((SVGLengthProperty)this.properties.get("x")).getSVGLength().getValue();
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a Image to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:image outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.w3c.dom.svg.SVGLength;
import org.apache.fop.dom.svg.*;
-//import org.apache.fop.dom.svg.Graphic;
import org.apache.fop.dom.svg.SVGLineElementImpl;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:line pseudo flow object.
*/
-public class Line extends FObj implements GraphicsCreator {
+public class Line extends SVGObj {
/**
* inner class for making Line objects.
this.name = "svg:line";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
/* retrieve properties */
SVGLength x1 = ((SVGLengthProperty)this.properties.get("x1")).getSVGLength();
graph.setX2(new SVGAnimatedLengthImpl(x2));
graph.setY2(new SVGAnimatedLengthImpl(y2));
graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- MessageHandler.errorln("WARNING: svg:line outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:LinearGradient pseudo flow object.
*
*/
-public class LinearGradient extends FObj implements GraphicsCreator {
+public class LinearGradient extends SVGObj {
/**
* inner class for making LinearGradient objects.
}
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
linear.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- linear.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ linear.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
linear.setId(this.properties.get("id").getString());
linear.setX1(new SVGAnimatedLengthImpl(((SVGLengthProperty)this.properties.get("x1")).getSVGLength()));
* class representing svg:Marker pseudo flow object.
*
*/
-public class Marker extends FObj {
+public class Marker extends SVGObj {
/**
* inner class for making Marker objects.
super(parent, propertyList);
this.name = "svg:marker";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGMarkerElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:marker outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.apps.FOPException;
import org.apache.fop.dom.svg.*;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:Mask pseudo flow object.
*
*/
-public class Mask extends FObj {
+public class Mask extends SVGObj {
/**
* inner class for making Mask objects.
super.addChild(child);
if(child instanceof GraphicsCreator) {
GraphicsCreator gc = (GraphicsCreator)child;
- GraphicImpl graph = gc.createGraphic();
- mask.addElement(graph);
- graph.setParent(mask);
+ SVGElement graph = gc.createGraphic();
+ if(graph != null) {
+ mask.addElement(graph);
+// graph.setParent(mask);
+ }
} else {
// error
}
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
mask.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
mask.setId(this.properties.get("id").getString());
return mask;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:mask outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
/**
*
*/
-public class MissingGlyph extends FObj {
+public class MissingGlyph extends SVGObj {
/**
* inner class for making MissingGlyph objects.
super(parent, propertyList);
this.name = "svg:missing-glyph";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGMissingGlyphElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:missing-glyph outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:Path pseudo flow object.
*
*/
-public class Path extends FObj implements GraphicsCreator {
+public class Path extends SVGObj {
/**
* inner class for making Path objects.
this.name = "svg:path";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
Vector pd = ((SVGD)this.properties.get("d")).getPath();
SVGPathElementImpl graph = new SVGPathElementImpl(pd);
graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a Path to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:path outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:Pattern pseudo flow object.
*
*/
-public class Pattern extends FObj {
+public class Pattern extends SVGObj {
/**
* inner class for making Pattern objects.
super(parent, propertyList);
this.name = "svg:pattern";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a Pattern to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGPatternElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:pattern outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
*
*/
-public class Polygon extends FObj implements GraphicsCreator {
+public class Polygon extends SVGObj {
/**
* inner class for making Polygon objects.
this.name = "svg:polygon";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
Vector points = ((SVGPoints)this.properties.get("points")).getPoints();
SVGPolygonElementImpl graph = new SVGPolygonElementImpl(points);
graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:polygon outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:Polyline pseudo flow object.
*
*/
-public class Polyline extends FObj implements GraphicsCreator {
+public class Polyline extends SVGObj {
/**
* inner class for making Polyline objects.
this.name = "svg:polyline";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
Vector points = ((SVGPoints)this.properties.get("points")).getPoints();
SVGPolylineElementImpl graph = new SVGPolylineElementImpl(points);
graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a Polyline to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:polyline outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:RadialGradient pseudo flow object.
*
*/
-public class RadialGradient extends FObj implements GraphicsCreator {
+public class RadialGradient extends SVGObj {
/**
* inner class for making RadialGradient objects.
}
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
radial.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- radial.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ radial.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
radial.setId(this.properties.get("id").getString());
radial.setCx(new SVGAnimatedLengthImpl(((SVGLengthProperty)this.properties.get("cx")).getSVGLength()));
radial.setFy(new SVGAnimatedLengthImpl(((SVGLengthProperty)this.properties.get("fy")).getSVGLength()));
return radial;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a RadialGradient to the SVGArea */
- ((SVGArea) area).addGraphic(radial);
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:radialGradient outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.SVGArea;
import org.w3c.dom.svg.SVGLength;
+import org.w3c.dom.svg.SVGElement;
/**
* class representing svg:rect pseudo flow object.
*/
-public class Rect extends FObj implements GraphicsCreator {
+public class Rect extends SVGObj {
/**
* inner class for making Rect objects.
this.name = "svg:rect";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
/* retrieve properties */
SVGLength width = ((SVGLengthProperty)this.properties.get("width")).getSVGLength();
graph.setWidth(new SVGAnimatedLengthImpl(width));
graph.setHeight(new SVGAnimatedLengthImpl(height));
graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a rectangle to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- MessageHandler.errorln("WARNING: svg:rect outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.apps.FOPException;
import org.apache.fop.dom.svg.*;
+import org.w3c.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
/**
this.name = "svg:svg";
}
-/* protected void addChild(FONode child) {
- super.addChild(child);
- if(svgArea != null) {
- Status status;
- try {
- if ((status = child.layout(svgArea)).isIncomplete()) {
- }
- } catch(FOPException fope) {
- fope.printStackTrace();
- }
- }
- }*/
-
- SVGArea svgArea = null;
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
- this.width = ((SVGLengthProperty)this.properties.get("width")).getSVGLength().getValue();
- this.height = ((SVGLengthProperty)this.properties.get("height")).getSVGLength().getValue();
- svgArea = new SVGArea(null, width, height);
+ SVGSVGElementImpl svgArea = null;
+ SVGLength w = ((SVGLengthProperty)this.properties.get("width")).getSVGLength();
+ SVGLength h = ((SVGLengthProperty)this.properties.get("height")).getSVGLength();
+ svgArea = new SVGSVGElementImpl();
+ SVGAnimatedLength sal;
+ sal = new SVGAnimatedLengthImpl(w);
+ sal.setBaseVal(w);
+ svgArea.setWidth(sal);
+ sal = new SVGAnimatedLengthImpl(h);
+ sal.setBaseVal(h);
+ svgArea.setHeight(sal);
svgArea.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- svgArea.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
-// svgArea.setId(this.properties.get("id").getString());
+ svgArea.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
+ svgArea.setId(this.properties.get("id").getString());
int numChildren = this.children.size();
for (int i = 0; i < numChildren; i++) {
FONode fo = (FONode) children.elementAt(i);
if(fo instanceof GraphicsCreator) {
- GraphicImpl impl = ((GraphicsCreator)fo).createGraphic();
- svgArea.addGraphic(impl);
- } else if(fo instanceof Defs) {
- svgArea.addDefs(((Defs)fo).createDefs());
+ SVGElement impl = ((GraphicsCreator)fo).createGraphic();
+ svgArea.appendChild((org.w3c.dom.Node)impl);
+// } else if(fo instanceof Defs) {
+// svgArea.addDefs(((Defs)fo).createDefs());
}
Status status;
-/* try {
- if ((status = fo.layout(svgArea)).isIncomplete()) {
-// return null;
- }
- } catch(FOPException fope) {
- fope.printStackTrace();
- }*/
}
return svgArea;
}
*/
public Status layout(Area area) throws FOPException {
- if (area instanceof SVGArea) {
- ((SVGArea) area).addGraphic(createGraphic());
- return new Status(Status.OK);
- }
-
if (!(area instanceof ForeignObjectArea)) {
// this is an error
throw new FOPException("SVG not in fo:instream-foreign-object");
/* create an SVG area */
/* if width and height are zero, may want to get the bounds of the content. */
SVGArea svg = new SVGArea(fs, width, height);
- svg.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- svg.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ SVGDocument doc = new SVGDocumentImpl();
+ svg.setSVGDocument(doc);
svg.start();
/* add the SVG area to the containing area */
foa.setIntrinsicWidth(svg.getWidth());
foa.setIntrinsicHeight(svg.getHeight());
- /* iterate over the child formatting objects and lay them out
- into the SVG area */
- int numChildren = this.children.size();
- for (int i = 0; i < numChildren; i++) {
- FONode fo = (FONode) children.elementAt(i);
- Status status;
- if ((status = fo.layout(svg)).isIncomplete()) {
- return status;
- }
- }
+ doc.appendChild((SVGSVGElement)createGraphic());
/* finish off the SVG area */
svg.end();
--- /dev/null
+/*-- $Id$ --
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+ include the following acknowledgment: "This product includes software
+ developed by the Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowledgment may appear in the software itself, if
+ and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ endorse or promote products derived from this software without prior
+ written permission. For written permission, please contact
+ apache@apache.org.
+
+ 5. Products derived from this software may not be called "Apache", nor may
+ "Apache" appear in their name, without prior written permission of the
+ Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many individuals
+ on behalf of the Apache Software Foundation and was originally created by
+ James Tauber <jtauber@jtauber.com>. For more information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+
+package org.apache.fop.svg;
+
+// FOP
+import org.apache.fop.fo.*;
+import org.apache.fop.apps.*;
+import org.apache.fop.dom.svg.*;
+import org.apache.fop.fo.FOTreeBuilder;
+import org.apache.fop.fo.ElementMapping;
+import org.apache.fop.fo.PropertyListMapping;
+import org.apache.fop.layout.AreaTree;
+import org.apache.fop.layout.FontInfo;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.messaging.MessageHandler;
+
+// DOM
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Attr;
+
+// SAX
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.w3c.dom.svg.*;
+
+// Java
+import java.io.PrintWriter;
+import java.io.IOException;
+
+/**
+ * <P>Primary class that drives overall FOP process.
+ *
+ * <P>Once this class is instantiated, methods are called to set the
+ * Renderer to use, the (possibly multiple) ElementMapping(s) to
+ * use and the PrintWriter to use to output the results of the
+ * rendering (where applicable). In the case of the Renderer and
+ * ElementMapping(s), the Driver may be supplied either with the
+ * object itself, or the name of the class, in which case Driver will
+ * instantiate the class itself. The advantage of the latter is it
+ * enables runtime determination of Renderer and ElementMapping(s).
+ *
+ * <P>Once the Driver is set up, the buildFOTree method
+ * is called. Depending on whether DOM or SAX is being used, the
+ * invocation of the method is either buildFOTree(Document) or
+ * buildFOTree(Parser, InputSource) respectively.
+ *
+ * <P>A third possibility may be used to build the FO Tree, namely
+ * calling getDocumentHandler() and firing the SAX events yourself.
+ *
+ * <P>Once the FO Tree is built, the format() and render() methods may be
+ * called in that order.
+ *
+ * <P>Here is an example use of Driver from CommandLine.java:
+ *
+ * <PRE>
+ * Driver driver = new Driver();
+ * driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", version);
+ * driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
+ * driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
+ * driver.setWriter(new PrintWriter(new FileWriter(args[1])));
+ * driver.buildFOTree(parser, fileInputSource(args[0]));
+ * driver.format();
+ * driver.render();
+ * </PRE>
+ */
+public class SVGDriver {
+
+ /** the FO tree builder */
+ protected SVGTreeBuilder treeBuilder;
+
+ /** the PrintWriter to use to output the results of the renderer */
+ protected PrintWriter writer;
+
+ /** create a new Driver */
+ public SVGDriver() {
+ this.treeBuilder = new SVGTreeBuilder();
+ }
+
+ /**
+ * add the given element mapping.
+ *
+ * an element mapping maps element names to Java classes
+ */
+ public void addElementMapping(ElementMapping mapping) {
+ mapping.addToBuilder(this.treeBuilder);
+ }
+
+ /**
+ * add the element mapping with the given class name
+ */
+ public void addElementMapping(String mappingClassName) {
+ createElementMapping(mappingClassName).addToBuilder(this.treeBuilder);
+ }
+
+ /**
+ * protected method used by addElementMapping(String) to
+ * instantiate element mapping class
+ */
+ protected ElementMapping createElementMapping(String mappingClassName) {
+ MessageHandler.logln("using element mapping " + mappingClassName);
+
+ try {
+ return (ElementMapping)
+ Class.forName(mappingClassName).newInstance();
+ } catch (ClassNotFoundException e) {
+ MessageHandler.errorln("Could not find " + mappingClassName);
+ } catch (InstantiationException e) {
+ MessageHandler.errorln("Could not instantiate "
+ + mappingClassName);
+ } catch (IllegalAccessException e) {
+ MessageHandler.errorln("Could not access " + mappingClassName);
+ } catch (ClassCastException e) {
+ MessageHandler.errorln(mappingClassName + " is not an element mapping");
+ }
+ return null;
+ }
+
+ /**
+ * add the element mapping with the given class name
+ */
+ public void addPropertyList(String listClassName) {
+ createPropertyList(listClassName).addToBuilder(this.treeBuilder);
+ }
+
+ /**
+ * protected method used by addPropertyList(String) to
+ * instantiate list mapping class
+ */
+ protected PropertyListMapping createPropertyList(String listClassName) {
+ MessageHandler.logln("using property list mapping " + listClassName);
+
+ try {
+ return (PropertyListMapping)
+ Class.forName(listClassName).newInstance();
+ } catch (ClassNotFoundException e) {
+ MessageHandler.errorln("Could not find " + listClassName);
+ } catch (InstantiationException e) {
+ MessageHandler.errorln("Could not instantiate "
+ + listClassName);
+ } catch (IllegalAccessException e) {
+ MessageHandler.errorln("Could not access " + listClassName);
+ } catch (ClassCastException e) {
+ MessageHandler.errorln(listClassName + " is not an property list");
+ }
+ return null;
+ }
+
+ /**
+ * return the tree builder (a SAX DocumentHandler).
+ *
+ * used in situations where SAX is used but not via a FOP-invoked
+ * SAX parser. A good example is an XSLT engine that fires SAX
+ * events but isn't a SAX Parser itself.
+ */
+ public ContentHandler getContentHandler() {
+ return this.treeBuilder;
+ }
+
+ /**
+ * build the formatting object tree using the given SAX Parser and
+ * SAX InputSource
+ */
+ public void buildSVGTree(XMLReader parser, InputSource source)
+ throws FOPException {
+
+ parser.setContentHandler(this.treeBuilder);
+ try {
+ parser.parse(source);
+ } catch (SAXException e) {
+e.printStackTrace();
+ if (e.getException() instanceof FOPException)
+ throw (FOPException) e.getException();
+ else
+ throw new FOPException(e.getMessage());
+ } catch (IOException e) {
+ throw new FOPException(e.getMessage());
+ }
+ }
+
+ /**
+ * build the formatting object tree using the given DOM Document
+ */
+ public void buildSVGTree(Document document)
+ throws FOPException {
+
+ /* most of this code is modified from John Cowan's */
+
+ Node currentNode;
+ AttributesImpl currentAtts;
+
+ /* temporary array for making Strings into character arrays */
+ char[] array = null;
+
+ currentAtts = new AttributesImpl();
+
+ /* start at the document element */
+ currentNode = document;
+
+ try {
+ while (currentNode != null) {
+ switch (currentNode.getNodeType()) {
+ case Node.DOCUMENT_NODE:
+ this.treeBuilder.startDocument();
+ break;
+ case Node.CDATA_SECTION_NODE:
+ case Node.TEXT_NODE:
+ String data = currentNode.getNodeValue();
+ int datalen = data.length();
+ if (array == null || array.length < datalen) {
+ /* if the array isn't big enough, make a new
+ one */
+ array = new char[datalen];
+ }
+ data.getChars(0, datalen, array, 0);
+ this.treeBuilder.characters(array, 0, datalen);
+ break;
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ this.treeBuilder.processingInstruction(
+ currentNode.getNodeName(),
+ currentNode.getNodeValue());
+ break;
+ case Node.ELEMENT_NODE:
+ NamedNodeMap map = currentNode.getAttributes();
+ currentAtts.clear();
+ for (int i = map.getLength() - 1; i >= 0; i--) {
+ Attr att = (Attr)map.item(i);
+ currentAtts.addAttribute("",
+ att.getName(),
+ "",
+ "CDATA",
+ att.getValue());
+ }
+ this.treeBuilder.startElement(
+ "", currentNode.getNodeName(), "", currentAtts);
+ break;
+ }
+
+ Node nextNode = currentNode.getFirstChild();
+ if (nextNode != null) {
+ currentNode = nextNode;
+ continue;
+ }
+
+ while (currentNode != null) {
+ switch (currentNode.getNodeType()) {
+ case Node.DOCUMENT_NODE:
+ this.treeBuilder.endDocument();
+ break;
+ case Node.ELEMENT_NODE:
+ this.treeBuilder.endElement(
+ "", currentNode.getNodeName(), "" );
+ break;
+ }
+
+ nextNode = currentNode.getNextSibling();
+ if (nextNode != null) {
+ currentNode = nextNode;
+ break;
+ }
+
+ currentNode = currentNode.getParentNode();
+ }
+ }
+ } catch (SAXException e) {
+ throw new FOPException(e.getMessage());
+ }
+ }
+
+ public SVGDocument getSVGDocument()
+ {
+ return this.treeBuilder.getSVGDocument();
+ }
+
+ /**
+ * format the formatting object tree into an area tree
+ */
+ public void format()
+ throws FOPException {
+ FontInfo fontInfo = new FontInfo();
+ }
+}
*/
package org.apache.fop.svg;
+import org.apache.fop.fo.TreeBuilder;
import org.apache.fop.fo.FOTreeBuilder;
import org.apache.fop.fo.ElementMapping;
+import org.apache.fop.dom.svg.SVGDocumentImpl;
public class SVGElementMapping implements ElementMapping {
- public void addToBuilder(FOTreeBuilder builder) {
- String uri = "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd";
+ public void addToBuilder(TreeBuilder builder) {
+ String uri = SVGDocumentImpl.namespaceURI;
builder.addMapping(uri, "svg", SVG.maker());
builder.addMapping(uri, "rect", Rect.maker());
builder.addMapping(uri, "line", Line.maker());
* @param propertyList the property list the property is a member of
*/
public Property make(PropertyList propertyList) throws FOPException {
- return make(propertyList, "0pt");
+ return make(propertyList, "");
}
}
--- /dev/null
+/*-- $Id$ --
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+ include the following acknowledgment: "This product includes software
+ developed by the Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowledgment may appear in the software itself, if
+ and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "FOP" and "Apache Software Foundation" must not be used to
+ endorse or promote products derived from this software without prior
+ written permission. For written permission, please contact
+ apache@apache.org.
+
+ 5. Products derived from this software may not be called "Apache", nor may
+ "Apache" appear in their name, without prior written permission of the
+ Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many individuals
+ on behalf of the Apache Software Foundation and was originally created by
+ James Tauber <jtauber@jtauber.com>. For more information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
+
+ */
+
+package org.apache.fop.svg;
+
+// FOP
+import org.apache.fop.fo.*;
+import org.apache.fop.layout.Area;
+import org.apache.fop.layout.FontState;
+import org.apache.fop.apps.FOPException;
+
+import org.apache.fop.dom.svg.*;
+
+import org.w3c.dom.svg.SVGElement;
+
+/**
+ * Since SVG objects are not layed out then this class checks
+ * that this element is not being layed out inside some incorrect
+ * element.
+ */
+public abstract class SVGObj extends FObj implements GraphicsCreator {
+
+ /**
+ *
+ * @param parent the parent formatting object
+ * @param propertyList the explicit properties of this object
+ */
+ public SVGObj(FObj parent, PropertyList propertyList) {
+ super(parent, propertyList);
+ }
+
+ public SVGElement createGraphic()
+ {
+ return null;
+ }
+
+ /**
+ * layout this formatting object.
+ *
+ * @param area the area to layout the object into
+ * @return the status of the layout
+ */
+ public Status layout(Area area) throws FOPException
+ {
+ if (area instanceof SVGArea) {
+ } else {
+ /* otherwise generate a warning */
+ System.err.println("WARNING: " + this.name + " outside svg:svg");
+ }
+
+ /* return status */
+ return new Status(Status.OK);
+ }
+}
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
+import org.apache.fop.dom.svg.SVGDocumentImpl;
import java.util.Hashtable;
public class SVGPropertyListMapping implements PropertyListMapping {
- public void addToBuilder(FOTreeBuilder builder) {
+ public void addToBuilder(TreeBuilder builder) {
- String uri = "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd";
+ String uri = SVGDocumentImpl.namespaceURI;
Hashtable propertyTable = new Hashtable();
propertyTable.put("height",SVGLengthProperty.maker());
propertyTable.put("width",SVGLengthProperty.maker());
propertyTable.put("d",SVGD.maker());
propertyTable.put("points",SVGPoints.maker());
// propertyTable.put("viewBox",SVGBox.maker());
+ propertyTable.put("xml:space",XMLSpace.maker());
propertyTable.put("font-family",FontFamily.maker());
propertyTable.put("font-style",FontStyle.maker());
import java.util.*;
+import org.w3c.dom.css.CSSStyleDeclaration;
+
/**
*
*/
*
* @return the length as a Length object
*/
- public Hashtable getStyle()
+ public CSSStyleDeclaration getStyle()
{
return this.style.getStyle();
}
import org.apache.fop.datatypes.*;
import org.apache.fop.apps.FOPException;
+import org.w3c.dom.svg.SVGAnimatedTransformList;
+
import java.util.*;
/**
*
* @return the length as a Length object
*/
- public Vector oldgetTransform() {
- return this.trans.oldgetTransform();
+ public SVGAnimatedTransformList getTransform() {
+ return this.trans.getTransform();
}
}
* class representing svg:Set pseudo flow object.
*
*/
-public class Set extends FObj {
+public class Set extends SVGObj {
/**
* inner class for making Set objects.
super(parent, propertyList);
this.name = "svg:set";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a Set to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGSetElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:set outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
* class representing svg:Stop pseudo flow object.
*
*/
-public class Stop extends FObj {
+public class Stop extends SVGObj {
/**
* inner class for making Stop objects.
* class representing svg:Style pseudo flow object.
*
*/
-public class Style extends FObj {
+public class Style extends SVGObj {
/**
* inner class for making Style objects.
super(parent, propertyList);
this.name = "svg:style";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a Style to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGStyleElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:style outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
/**
*
*/
-public class Switch extends FObj implements GraphicsCreator {
+public class Switch extends SVGObj {
/**
* inner class for making Line objects.
this.name = "svg:switch";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
/*
* There are two options
for (int i = 0; i < numChildren; i++) {
FONode child = (FONode) children.elementAt(i);
if(child instanceof GraphicsCreator) {
- GraphicImpl impl = ((GraphicsCreator)child).createGraphic();
+ SVGElement impl = ((GraphicsCreator)child).createGraphic();
if(impl instanceof SVGTests) {
SVGTests testable = (SVGTests)impl;
rf = child.getProperty("requiredFeatures").getString();
return graphic;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:switch outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
/**
*
*/
-public class Symbol extends FObj {
+public class Symbol extends SVGObj {
/**
* inner class for making Symbol objects.
super(parent, propertyList);
this.name = "svg:symbol";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGSymbolElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:symbol outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
*
*/
-public class TRef extends FObj implements TextElement {
+public class TRef extends SVGObj implements TextElement {
/**
* inner class for making Line objects.
this.name = "svg:tref";
}
- public GraphicImpl createTextElement()
+ public SVGElement createTextElement()
{
SVGTRefElementImpl tref = new SVGTRefElementImpl();
tref.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
prop = this.properties.get("x");
// bit of a hack, but otherwise the svg:text x element could be
// returned which is not a list
- if(prop instanceof SVGLengthListProperty)
+// if(prop instanceof SVGLengthListProperty)
tref.xlist = ((SVGLengthListProperty)prop).getSVGLengthList();
prop = this.properties.get("y");
- if(prop instanceof SVGLengthListProperty)
+// if(prop instanceof SVGLengthListProperty)
tref.ylist = ((SVGLengthListProperty)prop).getSVGLengthList();
prop = this.properties.get("dx");
- if(prop instanceof SVGLengthListProperty)
+// if(prop instanceof SVGLengthListProperty)
tref.dxlist = ((SVGLengthListProperty)prop).getSVGLengthList();
prop = this.properties.get("dy");
- if(prop instanceof SVGLengthListProperty)
+// if(prop instanceof SVGLengthListProperty)
tref.dylist = ((SVGLengthListProperty)prop).getSVGLengthList();
// tref.dxlist = ((SVGLengthProperty)this.properties.get("dx")).getSVGLength().valueList();
tref.ref = this.properties.get("xlink:href").getString();
tref.setId(this.properties.get("id").getString());
return tref;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:tref outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:tspan pseudo flow object.
*
*/
-public class TSpan extends FObj implements TextElement {
+public class TSpan extends SVGObj implements TextElement {
/**
* inner class for making tspan objects.
protected void addCharacters(char data[], int start, int length)
{
this.text += new String(data, start, length - start);
- tspan.str = this.text.trim();
+ tspan.str = this.text;
}
/**
this.name = "svg:tspan";
}
- public GraphicImpl createTextElement()
+ public SVGElement createTextElement()
{
tspan.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
// tspan.dx = ((SVGLengthProperty)this.properties.get("dx")).getSVGLength().mvalue();
prop = this.properties.get("x");
// bit of a hack, but otherwise the svg:text x element coud be
// returned which is not a list
- if(prop instanceof SVGLengthListProperty)
+// if(prop instanceof SVGLengthListProperty)
tspan.xlist = ((SVGLengthListProperty)prop).getSVGLengthList();
prop = this.properties.get("y");
- if(prop instanceof SVGLengthListProperty)
+// if(prop instanceof SVGLengthListProperty)
tspan.ylist = ((SVGLengthListProperty)prop).getSVGLengthList();
prop = this.properties.get("dx");
- if(prop instanceof SVGLengthListProperty)
+// if(prop instanceof SVGLengthListProperty)
tspan.dxlist = ((SVGLengthListProperty)prop).getSVGLengthList();
prop = this.properties.get("dy");
- if(prop instanceof SVGLengthListProperty)
+// if(prop instanceof SVGLengthListProperty)
tspan.dylist = ((SVGLengthListProperty)prop).getSVGLengthList();
// tspan.xlist = ((SVGLengthListProperty)this.properties.get("x")).getSVGLengthList();
// tspan.dxlist = ((SVGLengthProperty)this.properties.get("dx")).getSVGLength().valueList();
tspan.setId(this.properties.get("id").getString());
return tspan;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:tspan outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
import org.apache.fop.layout.Area;
import org.apache.fop.layout.FontState;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.properties.XMLSpace;
import java.util.*;
import org.apache.fop.dom.svg.SVGTextElementImpl;
import org.apache.fop.dom.svg.SVGArea;
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:text pseudo flow object.
*
*/
-public class Text extends FObjMixed implements GraphicsCreator {
+public class Text extends SVGObj {
/**
* inner class for making SVG Text objects.
*/
protected void addCharacters(char data[], int start, int length)
{
- textList.addElement(new String(data, start, length - start).trim());
+ textList.addElement(new String(data, start, length - start));
}
+ /**
+ * The children need to be added in order so that the text data
+ * is also added in order.
+ */
protected void addChild(FONode child) {
super.addChild(child);
if(child instanceof TextElement) {
TextElement te = (TextElement)child;
- GraphicImpl graph = te.createTextElement();
+ SVGElement graph = te.createTextElement();
textList.addElement(graph);
- graph.setParent(textGraph);
} else {
// error
}
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
+ int numChildren = this.textList.size();
+ for (int i = 0; i < numChildren; i++) {
+ Object obj = textList.elementAt(i);
+ if(obj instanceof SVGElement) {
+ SVGElement child = (SVGElement)obj;
+ textGraph.appendChild(child);
+ } else if(obj instanceof String) {
+ String str = (String)obj;
+ // new CDATANode(str); ??
+ }
+// System.out.println(child);
+ }
/* retrieve properties */
textGraph.x = ((SVGLengthProperty)this.properties.get("x")).getSVGLength().getValue();
textGraph.y = ((SVGLengthProperty)this.properties.get("y")).getSVGLength().getValue();
textGraph.textList = textList;
textGraph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- textGraph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ textGraph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
textGraph.setId(this.properties.get("id").getString());
+ switch((this.properties.get("xml:space")).getEnum()) {
+ case XMLSpace.DEFAULT:
+ textGraph.setXMLspace("default");
+ break;
+ case XMLSpace.PRESERVE:
+ textGraph.setXMLspace("preserve");
+ break;
+ }
return textGraph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add the text to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- MessageHandler.errorln("WARNING: svg:text outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
package org.apache.fop.svg;
import org.apache.fop.dom.svg.*;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
*
*/
public interface TextElement {
- public GraphicImpl createTextElement();
+ public SVGElement createTextElement();
}
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
* class representing svg:TextPath pseudo flow object.
*
*/
-public class TextPath extends FObj implements TextElement {
+public class TextPath extends SVGObj implements TextElement {
/**
* inner class for making TextPath objects.
text += new String(data, start, length - start);
}
- public GraphicImpl createTextElement()
+ public SVGElement createTextElement()
{
SVGTextPathElementImpl graph = null;
String link = this.properties.get("xlink:href").getString();
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a TextPath to the SVGArea */
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:textPath outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
/**
*
*/
-public class Title extends FObj {
+public class Title extends SVGObj {
/**
* inner class for making Title objects.
import org.apache.fop.dom.svg.*;
import org.apache.fop.dom.svg.SVGArea;
+
+import org.w3c.dom.svg.SVGElement;
+
/**
*
*/
-public class Use extends FObj implements GraphicsCreator {
+public class Use extends SVGObj {
/**
* inner class for making Use objects.
this.name = "svg:use";
}
- public GraphicImpl createGraphic()
+ public SVGElement createGraphic()
{
String str = this.properties.get("xlink:href").getString();
SVGUseElementImpl graph = new SVGUseElementImpl(str);
graph.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
- graph.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
+ graph.setTransform(((SVGTransform)this.properties.get("transform")).getTransform());
graph.setId(this.properties.get("id").getString());
return graph;
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a line to the SVGArea */
- ((SVGArea) area).addGraphic(createGraphic());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:use outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}
/**
*
*/
-public class VKern extends FObj {
+public class VKern extends SVGObj {
/**
* inner class for making VKern objects.
super(parent, propertyList);
this.name = "svg:vkern";
}
-
- /**
- * layout this formatting object.
- *
- * @param area the area to layout the object into
- *
- * @return the status of the layout
- */
- public Status layout(Area area) throws FOPException {
-
- /* retrieve properties */
-
- /* if the area this is being put into is an SVGArea */
- if (area instanceof SVGArea) {
- /* add a VKern to the SVGArea */
- ((SVGArea) area).addGraphic(new SVGVKernElementImpl());
- } else {
- /* otherwise generate a warning */
- System.err.println("WARNING: svg:vkern outside svg:svg");
- }
-
- /* return status */
- return new Status(Status.OK);
- }
}