aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-09-24 09:17:12 +0000
committerKeiron Liddle <keiron@apache.org>2001-09-24 09:17:12 +0000
commit3cf392b13f6cab2cf343a86c8e55942656cc9bb5 (patch)
tree61f07612c59f71a3728772876ce11dddfba6f812
parent5a9662ed5c350df04d0089c0b9fbba5354b4c772 (diff)
downloadxmlgraphics-fop-3cf392b13f6cab2cf343a86c8e55942656cc9bb5.tar.gz
xmlgraphics-fop-3cf392b13f6cab2cf343a86c8e55942656cc9bb5.zip
updated to use HashMap so that when using threads reading data
is not synchronized and therefore slower git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194480 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/codegen/propmap.xsl24
-rw-r--r--src/org/apache/fop/extensions/ExtensionElementMapping.java21
-rw-r--r--src/org/apache/fop/fo/DirectPropertyListBuilder.java2
-rw-r--r--src/org/apache/fop/fo/FOTreeBuilder.java25
-rw-r--r--src/org/apache/fop/fo/PropertyListBuilder.java36
-rw-r--r--src/org/apache/fop/fo/StandardElementMapping.java155
-rw-r--r--src/org/apache/fop/fo/TreeBuilder.java9
-rw-r--r--src/org/apache/fop/render/pdf/PDFRenderer.java4
-rw-r--r--src/org/apache/fop/svg/SVGElementMapping.java107
-rw-r--r--src/org/apache/fop/tools/TestConverter.java5
10 files changed, 203 insertions, 185 deletions
diff --git a/src/codegen/propmap.xsl b/src/codegen/propmap.xsl
index bd832a9d1..28074223e 100644
--- a/src/codegen/propmap.xsl
+++ b/src/codegen/propmap.xsl
@@ -35,29 +35,29 @@
<xsl:template match="property-list">
package org.apache.fop.fo.properties;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import org.apache.fop.svg.*;
+import java.util.HashMap;
+import java.util.Set;
+//import org.apache.fop.svg.*;
public class <xsl:value-of select="@family"/>PropertyMapping {
- private static Hashtable s_htGeneric = new Hashtable(200);
- private static Hashtable s_htElementLists = new Hashtable(10);
+ private static HashMap s_htGeneric = new HashMap();
+ private static HashMap s_htElementLists = new HashMap();
<xsl:for-each select="element-property-list">
- private static Hashtable s_ht<xsl:value-of select="localname[1]"/>;</xsl:for-each>
+ private static HashMap s_ht<xsl:value-of select="localname[1]"/>;</xsl:for-each>
<xsl:apply-templates/>
- public static Hashtable getGenericMappings() {
+ public static HashMap getGenericMappings() {
return s_htGeneric;
}
- public static Enumeration getElementMappings() {
- return s_htElementLists.keys();
+ public static Set getElementMappings() {
+ return s_htElementLists.keySet();
}
- public static Hashtable getElementMapping(String elemName) {
- return (Hashtable)s_htElementLists.get(elemName);
+ public static HashMap getElementMapping(String elemName) {
+ return (HashMap)s_htElementLists.get(elemName);
}
}
</xsl:template>
@@ -74,7 +74,7 @@ public class <xsl:value-of select="@family"/>PropertyMapping {
<xsl:template match="element-property-list">
<xsl:variable name="ename" select="localname[1]"/>
static {
- s_ht<xsl:value-of select="$ename"/> = new Hashtable();
+ s_ht<xsl:value-of select="$ename"/> = new HashMap();
<xsl:for-each select="localname">
s_htElementLists.put("<xsl:value-of select='.'/>", s_ht<xsl:value-of select='$ename'/>);
</xsl:for-each>
diff --git a/src/org/apache/fop/extensions/ExtensionElementMapping.java b/src/org/apache/fop/extensions/ExtensionElementMapping.java
index 02e5c4275..c6c8ae402 100644
--- a/src/org/apache/fop/extensions/ExtensionElementMapping.java
+++ b/src/org/apache/fop/extensions/ExtensionElementMapping.java
@@ -12,23 +12,30 @@ import org.apache.fop.fo.properties.ExtensionPropertyMapping;
import org.apache.fop.fo.TreeBuilder;
import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Iterator;
public class ExtensionElementMapping implements ElementMapping {
public static final String URI = "http://xml.apache.org/fop/extensions";
- public void addToBuilder(TreeBuilder builder) {
- builder.addMapping(URI, "outline", Outline.maker());
- builder.addMapping(URI, "label", Label.maker());
+ private static HashMap foObjs = null;
+
+ public synchronized void addToBuilder(TreeBuilder builder) {
+ if(foObjs == null) {
+ foObjs = new HashMap();
+ foObjs.put("outline", Outline.maker());
+ foObjs.put("label", Label.maker());
+ }
+ builder.addMapping(URI, foObjs);
builder.addPropertyList(ExtensionElementMapping.URI,
ExtensionPropertyMapping.getGenericMappings());
/* Add any element mappings */
- for (Enumeration e = ExtensionPropertyMapping.getElementMappings();
- e.hasMoreElements(); ) {
- String elem = (String)e.nextElement();
+ for (Iterator iter = ExtensionPropertyMapping.getElementMappings().iterator();
+ iter.hasNext(); ) {
+ String elem = (String)iter.next();
builder.addElementPropertyList(ExtensionElementMapping.URI, elem,
ExtensionPropertyMapping.getElementMapping(elem));
}
diff --git a/src/org/apache/fop/fo/DirectPropertyListBuilder.java b/src/org/apache/fop/fo/DirectPropertyListBuilder.java
index 7c6b6f6e4..d4f3fa02e 100644
--- a/src/org/apache/fop/fo/DirectPropertyListBuilder.java
+++ b/src/org/apache/fop/fo/DirectPropertyListBuilder.java
@@ -28,7 +28,7 @@ public class DirectPropertyListBuilder extends PropertyListBuilder {
public DirectPropertyListBuilder() {
}
- public PropertyList makeList(String elementName, Attributes attributes,
+ public PropertyList makeList(String uri, String elementName, Attributes attributes,
PropertyList parentPropertyList,
FObj parentFO) throws FOPException {
AttrPropertyList ret = new AttrPropertyList(attributes);
diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java
index ae67d2d91..6b7417e61 100644
--- a/src/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/org/apache/fop/fo/FOTreeBuilder.java
@@ -25,7 +25,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.Attributes;
// Java
-import java.util.Hashtable;
+import java.util.HashMap;
import java.util.Stack;
import java.util.Vector;
import java.io.IOException;
@@ -47,14 +47,14 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
* table mapping element names to the makers of objects
* representing formatting objects
*/
- protected Hashtable fobjTable = new Hashtable();
+ protected HashMap fobjTable = new HashMap();
protected Vector namespaces = new Vector();
/**
* class that builds a property list for each formatting object
*/
- protected Hashtable propertylistTable = new Hashtable();
+ protected HashMap propertylistTable = new HashMap();
/**
* current formatting object being handled
@@ -71,7 +71,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
/**
* set of names of formatting objects encountered but unknown
*/
- protected Hashtable unknownFOs = new Hashtable();
+ protected HashMap unknownFOs = new HashMap();
/**
*
@@ -99,9 +99,8 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
* @param localName local name of formatting object element
* @param maker Maker for class representing formatting object
*/
- public void addMapping(String namespaceURI, String localName,
- FObj.Maker maker) {
- this.fobjTable.put(namespaceURI + "^" + localName, maker);
+ public void addMapping(String namespaceURI, HashMap table) {
+ this.fobjTable.put(namespaceURI, table);
this.namespaces.addElement(namespaceURI.intern());
}
@@ -112,7 +111,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
* @param localName local name of formatting object element
* @param maker Maker for class representing formatting object
*/
- public void addPropertyList(String namespaceURI, Hashtable list) {
+ public void addPropertyList(String namespaceURI, HashMap list) {
PropertyListBuilder plb;
plb = (PropertyListBuilder)this.propertylistTable.get(namespaceURI);
if (plb == null) {
@@ -132,7 +131,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
* @param maker Maker for class representing formatting object
*/
public void addElementPropertyList(String namespaceURI, String localName,
- Hashtable list) {
+ HashMap list) {
PropertyListBuilder plb;
plb = (PropertyListBuilder)this.propertylistTable.get(namespaceURI);
if (plb == null) {
@@ -214,13 +213,15 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
FObj.Maker fobjMaker;
// String fullName = mapName(rawName);
- String fullName = uri + "^" + localName;
- fobjMaker = (FObj.Maker)fobjTable.get(fullName);
+ //String fullName = uri + "^" + localName;
+ HashMap table = (HashMap)fobjTable.get(uri);
+ fobjMaker = (FObj.Maker)table.get(localName);
PropertyListBuilder currentListBuilder =
(PropertyListBuilder)this.propertylistTable.get(uri);
boolean foreignXML = false;
if (fobjMaker == null) {
+ String fullName = uri + "^" + localName;
if (!this.unknownFOs.containsKey(fullName)) {
this.unknownFOs.put(fullName, "");
log.error("Unknown formatting object "
@@ -239,7 +240,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
PropertyList list = null;
if (currentListBuilder != null) {
list =
- currentListBuilder.makeList(fullName, attlist,
+ currentListBuilder.makeList(uri, localName, attlist,
(currentFObj == null) ? null
: currentFObj.properties, currentFObj);
} else if(foreignXML) {
diff --git a/src/org/apache/fop/fo/PropertyListBuilder.java b/src/org/apache/fop/fo/PropertyListBuilder.java
index f2bf0522c..19db4e7fd 100644
--- a/src/org/apache/fop/fo/PropertyListBuilder.java
+++ b/src/org/apache/fop/fo/PropertyListBuilder.java
@@ -16,7 +16,7 @@ import org.apache.fop.apps.FOPException;
import org.xml.sax.Attributes;
-import java.util.Hashtable;
+import java.util.HashMap;
public class PropertyListBuilder {
@@ -25,19 +25,19 @@ public class PropertyListBuilder {
*/
private static final String FONTSIZEATTR = "font-size";
- private Hashtable propertyListTable;
- private Hashtable elementTable;
+ private HashMap propertyListTable;
+ private HashMap elementTable;
public PropertyListBuilder() {
- this.propertyListTable = new Hashtable();
- this.elementTable = new Hashtable();
+ this.propertyListTable = new HashMap();
+ this.elementTable = new HashMap();
}
- public void addList(Hashtable list) {
- propertyListTable = list; // should add all
+ public void addList(HashMap list) {
+ propertyListTable.putAll(list);
}
- public void addElementList(String element, Hashtable list) {
+ public void addElementList(String element, HashMap list) {
elementTable.put(element, list);
}
@@ -78,13 +78,12 @@ public class PropertyListBuilder {
return b;
}
- public PropertyList makeList(String elementName, Attributes attributes,
+ public PropertyList makeList(String ns, String elementName, Attributes attributes,
PropertyList parentPropertyList,
FObj parentFO) throws FOPException {
- int index = elementName.indexOf("^");
String space = "http://www.w3.org/TR/1999/XSL/Format";
- if (index != -1) {
- space = elementName.substring(0, index);
+ if (ns != null) {
+ space = ns;
}
PropertyList par = null;
@@ -92,12 +91,11 @@ public class PropertyListBuilder {
&& space.equals(parentPropertyList.getNameSpace())) {
par = parentPropertyList;
}
- // System.out.println(elementName.substring(index + 1));
PropertyList p = new PropertyList(par, space,
- elementName.substring(index + 1));
+ elementName);
p.setBuilder(this);
- Hashtable table;
- table = (Hashtable)elementTable.get(elementName.substring(index + 1));
+ HashMap table;
+ table = (HashMap)elementTable.get(elementName);
/* Store names of properties already set. */
StringBuffer propsDone = new StringBuffer(256);
@@ -235,19 +233,19 @@ public class PropertyListBuilder {
protected Property.Maker findMaker(String space, String elementName,
String propertyName) {
- return findMaker((Hashtable)elementTable.get(elementName),
+ return findMaker((HashMap)elementTable.get(elementName),
propertyName);
}
/**
* Convenience function to return the Maker for a given property
- * given the Hashtable containing properties specific to this element.
+ * given the HashMap containing properties specific to this element.
* If table is non-null and
* @param elemTable Element-specific properties or null if none.
* @param propertyName Name of property.
* @return A Maker for this property.
*/
- private Property.Maker findMaker(Hashtable elemTable,
+ private Property.Maker findMaker(HashMap elemTable,
String propertyName) {
Property.Maker propertyMaker = null;
if (elemTable != null) {
diff --git a/src/org/apache/fop/fo/StandardElementMapping.java b/src/org/apache/fop/fo/StandardElementMapping.java
index 132963ca1..5938bf0fd 100644
--- a/src/org/apache/fop/fo/StandardElementMapping.java
+++ b/src/org/apache/fop/fo/StandardElementMapping.java
@@ -8,107 +8,114 @@
package org.apache.fop.fo;
import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Iterator;
import org.apache.fop.fo.properties.FOPropertyMapping;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.pagination.*;
public class StandardElementMapping implements ElementMapping {
+ private static HashMap foObjs = null;
- public void addToBuilder(TreeBuilder builder) {
+ public synchronized void addToBuilder(TreeBuilder builder) {
- String uri = "http://www.w3.org/1999/XSL/Format";
+ if(foObjs == null) {
+ foObjs = new HashMap();
- // Declarations and Pagination and Layout Formatting Objects
- builder.addMapping(uri, "root", Root.maker());
- builder.addMapping(uri, "declarations", Declarations.maker());
- builder.addMapping(uri, "color-profile", ColorProfile.maker());
- builder.addMapping(uri, "page-sequence", PageSequence.maker());
- builder.addMapping(uri, "layout-master-set", LayoutMasterSet.maker());
- builder.addMapping(uri, "page-sequence-master",
+ // Declarations and Pagination and Layout Formatting Objects
+ foObjs.put("root", Root.maker());
+ foObjs.put("declarations", Declarations.maker());
+ foObjs.put("color-profile", ColorProfile.maker());
+ foObjs.put("page-sequence", PageSequence.maker());
+ foObjs.put("layout-master-set", LayoutMasterSet.maker());
+ foObjs.put("page-sequence-master",
PageSequenceMaster.maker());
- builder.addMapping(uri, "single-page-master-reference",
+ foObjs.put("single-page-master-reference",
SinglePageMasterReference.maker());
- builder.addMapping(uri, "repeatable-page-master-reference",
+ foObjs.put("repeatable-page-master-reference",
RepeatablePageMasterReference.maker());
- builder.addMapping(uri, "repeatable-page-master-alternatives",
+ foObjs.put("repeatable-page-master-alternatives",
RepeatablePageMasterAlternatives.maker());
- builder.addMapping(uri, "conditional-page-master-reference",
+ foObjs.put("conditional-page-master-reference",
ConditionalPageMasterReference.maker());
- builder.addMapping(uri, "simple-page-master",
+ foObjs.put("simple-page-master",
SimplePageMaster.maker());
- builder.addMapping(uri, "region-body", RegionBody.maker());
- builder.addMapping(uri, "region-before", RegionBefore.maker());
- builder.addMapping(uri, "region-after", RegionAfter.maker());
- builder.addMapping(uri, "region-start", RegionStart.maker());
- builder.addMapping(uri, "region-end", RegionEnd.maker());
- builder.addMapping(uri, "flow", Flow.maker());
- builder.addMapping(uri, "static-content", StaticContent.maker());
- builder.addMapping(uri, "title", Title.maker());
-
- // Block-level Formatting Objects
- builder.addMapping(uri, "block", Block.maker());
- builder.addMapping(uri, "block-container", BlockContainer.maker());
-
- // Inline-level Formatting Objects
- builder.addMapping(uri, "bidi-override", BidiOverride.maker());
- builder.addMapping(uri, "character",
+ foObjs.put("region-body", RegionBody.maker());
+ foObjs.put("region-before", RegionBefore.maker());
+ foObjs.put("region-after", RegionAfter.maker());
+ foObjs.put("region-start", RegionStart.maker());
+ foObjs.put("region-end", RegionEnd.maker());
+ foObjs.put("flow", Flow.maker());
+ foObjs.put("static-content", StaticContent.maker());
+ foObjs.put("title", Title.maker());
+
+ // Block-level Formatting Objects
+ foObjs.put("block", Block.maker());
+ foObjs.put("block-container", BlockContainer.maker());
+
+ // Inline-level Formatting Objects
+ foObjs.put("bidi-override", BidiOverride.maker());
+ foObjs.put("character",
org.apache.fop.fo.flow.Character.maker());
- builder.addMapping(uri, "initial-property-set",
+ foObjs.put("initial-property-set",
InitialPropertySet.maker());
- builder.addMapping(uri, "external-graphic", ExternalGraphic.maker());
- builder.addMapping(uri, "instream-foreign-object",
+ foObjs.put("external-graphic", ExternalGraphic.maker());
+ foObjs.put("instream-foreign-object",
InstreamForeignObject.maker());
- builder.addMapping(uri, "inline", Inline.maker());
- builder.addMapping(uri, "inline-container", InlineContainer.maker());
- builder.addMapping(uri, "leader", Leader.maker());
- builder.addMapping(uri, "page-number", PageNumber.maker());
- builder.addMapping(uri, "page-number-citation",
+ foObjs.put("inline", Inline.maker());
+ foObjs.put("inline-container", InlineContainer.maker());
+ foObjs.put("leader", Leader.maker());
+ foObjs.put("page-number", PageNumber.maker());
+ foObjs.put("page-number-citation",
PageNumberCitation.maker());
- // Formatting Objects for Tables
- builder.addMapping(uri, "table-and-caption", TableAndCaption.maker());
- builder.addMapping(uri, "table", Table.maker());
- builder.addMapping(uri, "table-column", TableColumn.maker());
- builder.addMapping(uri, "table-caption", TableCaption.maker());
- builder.addMapping(uri, "table-header", TableHeader.maker());
- builder.addMapping(uri, "table-footer", TableFooter.maker());
- builder.addMapping(uri, "table-body", TableBody.maker());
- builder.addMapping(uri, "table-row", TableRow.maker());
- builder.addMapping(uri, "table-cell", TableCell.maker());
-
- // Formatting Objects for Lists
- builder.addMapping(uri, "list-block", ListBlock.maker());
- builder.addMapping(uri, "list-item", ListItem.maker());
- builder.addMapping(uri, "list-item-body", ListItemBody.maker());
- builder.addMapping(uri, "list-item-label", ListItemLabel.maker());
-
- // Dynamic Effects: Link and Multi Formatting Objects
- builder.addMapping(uri, "basic-link", BasicLink.maker());
- builder.addMapping(uri, "multi-switch", MultiSwitch.maker());
- builder.addMapping(uri, "multi-case", MultiCase.maker());
- builder.addMapping(uri, "multi-toggle", MultiToggle.maker());
- builder.addMapping(uri, "multi-properties", MultiProperties.maker());
- builder.addMapping(uri, "multi-property-set",
+ // Formatting Objects for Tables
+ foObjs.put("table-and-caption", TableAndCaption.maker());
+ foObjs.put("table", Table.maker());
+ foObjs.put("table-column", TableColumn.maker());
+ foObjs.put("table-caption", TableCaption.maker());
+ foObjs.put("table-header", TableHeader.maker());
+ foObjs.put("table-footer", TableFooter.maker());
+ foObjs.put("table-body", TableBody.maker());
+ foObjs.put("table-row", TableRow.maker());
+ foObjs.put("table-cell", TableCell.maker());
+
+ // Formatting Objects for Lists
+ foObjs.put("list-block", ListBlock.maker());
+ foObjs.put("list-item", ListItem.maker());
+ foObjs.put("list-item-body", ListItemBody.maker());
+ foObjs.put("list-item-label", ListItemLabel.maker());
+
+ // Dynamic Effects: Link and Multi Formatting Objects
+ foObjs.put("basic-link", BasicLink.maker());
+ foObjs.put("multi-switch", MultiSwitch.maker());
+ foObjs.put("multi-case", MultiCase.maker());
+ foObjs.put("multi-toggle", MultiToggle.maker());
+ foObjs.put("multi-properties", MultiProperties.maker());
+ foObjs.put("multi-property-set",
MultiPropertySet.maker());
- // Out-of-Line Formatting Objects
- builder.addMapping(uri, "float",
+ // Out-of-Line Formatting Objects
+ foObjs.put("float",
org.apache.fop.fo.flow.Float.maker());
- builder.addMapping(uri, "footnote", Footnote.maker());
- builder.addMapping(uri, "footnote-body", FootnoteBody.maker());
+ foObjs.put("footnote", Footnote.maker());
+ foObjs.put("footnote-body", FootnoteBody.maker());
+
+ // Other Formatting Objects
+ foObjs.put("wrapper", Wrapper.maker());
+ foObjs.put("marker", Marker.maker());
+ foObjs.put("retrieve-marker", RetrieveMarker.maker());
+ }
- // Other Formatting Objects
- builder.addMapping(uri, "wrapper", Wrapper.maker());
- builder.addMapping(uri, "marker", Marker.maker());
- builder.addMapping(uri, "retrieve-marker", RetrieveMarker.maker());
+ String uri = "http://www.w3.org/1999/XSL/Format";
+ builder.addMapping(uri, foObjs);
builder.addPropertyList(uri, FOPropertyMapping.getGenericMappings());
/* Add any element mappings */
- for (Enumeration e = FOPropertyMapping.getElementMappings();
- e.hasMoreElements(); ) {
- String elem = (String)e.nextElement();
+ for (Iterator iter = FOPropertyMapping.getElementMappings().iterator();
+ iter.hasNext(); ) {
+ String elem = (String)iter.next();
builder.addElementPropertyList(uri, elem,
FOPropertyMapping.getElementMapping(elem));
}
diff --git a/src/org/apache/fop/fo/TreeBuilder.java b/src/org/apache/fop/fo/TreeBuilder.java
index 5342dd54c..3076a2d6c 100644
--- a/src/org/apache/fop/fo/TreeBuilder.java
+++ b/src/org/apache/fop/fo/TreeBuilder.java
@@ -8,7 +8,7 @@
package org.apache.fop.fo;
// Java
-import java.util.Hashtable;
+import java.util.HashMap;
/**
*/
@@ -22,8 +22,7 @@ public interface TreeBuilder {
* @param localName local name of formatting object element
* @param maker Maker for class representing formatting object
*/
- public void addMapping(String namespaceURI, String localName,
- FObj.Maker maker);
+ public void addMapping(String namespaceURI, HashMap table);
/**
* add a mapping from element name to maker.
@@ -32,7 +31,7 @@ public interface TreeBuilder {
* @param localName local name of formatting object element
* @param maker Maker for class representing formatting object
*/
- public void addPropertyList(String namespaceURI, Hashtable list);
+ public void addPropertyList(String namespaceURI, HashMap list);
public void addPropertyListBuilder(String namespaceURI, PropertyListBuilder list);
@@ -44,6 +43,6 @@ public interface TreeBuilder {
* @param maker Maker for class representing formatting object
*/
public void addElementPropertyList(String namespaceURI, String localName,
- Hashtable list);
+ HashMap list);
}
diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java
index 3be7451ce..b7bdc61f5 100644
--- a/src/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/org/apache/fop/render/pdf/PDFRenderer.java
@@ -622,8 +622,6 @@ public class PDFRenderer extends PrintRenderer {
}
}
-
-
/**
* Convert a char to a multibyte hex representation
*/
@@ -657,7 +655,6 @@ public class PDFRenderer extends PrintRenderer {
}
-
/**
* Checks to see if we have some text rendering commands open
* still and writes out the TJ command to the stream if we do
@@ -813,7 +810,6 @@ public class PDFRenderer extends PrintRenderer {
}
}
}
-
}
private void renderOutline(Outline outline) {
diff --git a/src/org/apache/fop/svg/SVGElementMapping.java b/src/org/apache/fop/svg/SVGElementMapping.java
index 9069a7a0e..548693967 100644
--- a/src/org/apache/fop/svg/SVGElementMapping.java
+++ b/src/org/apache/fop/svg/SVGElementMapping.java
@@ -8,6 +8,7 @@
package org.apache.fop.svg;
import java.util.Enumeration;
+import java.util.HashMap;
import org.apache.fop.fo.DirectPropertyListBuilder;
import org.apache.fop.fo.TreeBuilder;
@@ -16,60 +17,68 @@ import org.apache.fop.fo.ElementMapping;
public class SVGElementMapping implements ElementMapping {
- public void addToBuilder(TreeBuilder builder) {
- String uri = "http://www.w3.org/2000/svg";
- builder.addMapping(uri, "svg", SVGElement.maker());
- builder.addMapping(uri, "rect", SVGObj.maker("rect"));
- builder.addMapping(uri, "line", SVGObj.maker("line"));
- builder.addMapping(uri, "text", SVGObj.maker("text"));
+ private static HashMap foObjs = null;
+
+ public synchronized void addToBuilder(TreeBuilder builder) {
+
+ if(foObjs == null) {
+ foObjs = new HashMap();
+ foObjs.put("svg", SVGElement.maker());
+ foObjs.put("rect", SVGObj.maker("rect"));
+ foObjs.put("line", SVGObj.maker("line"));
+ foObjs.put("text", SVGObj.maker("text"));
- builder.addMapping(uri, "desc", SVGObj.maker("desc"));
- builder.addMapping(uri, "title", SVGObj.maker("title"));
- builder.addMapping(uri, "circle", SVGObj.maker("circle"));
- builder.addMapping(uri, "ellipse", SVGObj.maker("ellipse"));
- builder.addMapping(uri, "g", SVGObj.maker("g"));
- builder.addMapping(uri, "polyline", SVGObj.maker("polyline"));
- builder.addMapping(uri, "polygon", SVGObj.maker("polygon"));
- builder.addMapping(uri, "defs", SVGObj.maker("defs"));
- builder.addMapping(uri, "path", SVGObj.maker("path"));
- builder.addMapping(uri, "use", SVGObj.maker("use"));
- builder.addMapping(uri, "tspan", SVGObj.maker("tspan"));
- builder.addMapping(uri, "tref", SVGObj.maker("tref"));
- builder.addMapping(uri, "image", SVGObj.maker("image"));
- builder.addMapping(uri, "style", SVGObj.maker("style"));
+ foObjs.put("desc", SVGObj.maker("desc"));
+ foObjs.put("title", SVGObj.maker("title"));
+ foObjs.put("circle", SVGObj.maker("circle"));
+ foObjs.put("ellipse", SVGObj.maker("ellipse"));
+ foObjs.put("g", SVGObj.maker("g"));
+ foObjs.put("polyline", SVGObj.maker("polyline"));
+ foObjs.put("polygon", SVGObj.maker("polygon"));
+ foObjs.put("defs", SVGObj.maker("defs"));
+ foObjs.put("path", SVGObj.maker("path"));
+ foObjs.put("use", SVGObj.maker("use"));
+ foObjs.put("tspan", SVGObj.maker("tspan"));
+ foObjs.put("tref", SVGObj.maker("tref"));
+ foObjs.put("image", SVGObj.maker("image"));
+ foObjs.put("style", SVGObj.maker("style"));
- builder.addMapping(uri, "textPath", SVGObj.maker("textPath"));
- builder.addMapping(uri, "clipPath", SVGObj.maker("clipPath"));
- builder.addMapping(uri, "mask", SVGObj.maker("mask"));
- builder.addMapping(uri, "linearGradient", SVGObj.maker("linearGradient"));
- builder.addMapping(uri, "radialGradient", SVGObj.maker("radialGradient"));
- builder.addMapping(uri, "stop", SVGObj.maker("stop"));
- builder.addMapping(uri, "a", SVGObj.maker("a"));
- builder.addMapping(uri, "switch", SVGObj.maker("switch"));
- builder.addMapping(uri, "symbol", SVGObj.maker("symbol"));
+ foObjs.put("textPath", SVGObj.maker("textPath"));
+ foObjs.put("clipPath", SVGObj.maker("clipPath"));
+ foObjs.put("mask", SVGObj.maker("mask"));
+ foObjs.put("linearGradient", SVGObj.maker("linearGradient"));
+ foObjs.put("radialGradient", SVGObj.maker("radialGradient"));
+ foObjs.put("stop", SVGObj.maker("stop"));
+ foObjs.put("a", SVGObj.maker("a"));
+ foObjs.put("switch", SVGObj.maker("switch"));
+ foObjs.put("symbol", SVGObj.maker("symbol"));
- builder.addMapping(uri, "pattern", SVGObj.maker("pattern"));
+ foObjs.put("pattern", SVGObj.maker("pattern"));
- builder.addMapping(uri, "marker", SVGObj.maker("marker"));
- builder.addMapping(uri, "animate", SVGObj.maker("animate"));
- builder.addMapping(uri, "altGlyph", SVGObj.maker("altGlyph"));
- builder.addMapping(uri, "font", SVGObj.maker("font"));
- builder.addMapping(uri, "glyph", SVGObj.maker("glyph"));
- builder.addMapping(uri, "missing-glyph", SVGObj.maker("missing-glyph"));
- builder.addMapping(uri, "hkern", SVGObj.maker("hkern"));
- builder.addMapping(uri, "vkern", SVGObj.maker("vkern"));
- builder.addMapping(uri, "set", SVGObj.maker("set"));
- builder.addMapping(uri, "animateMotion", SVGObj.maker("animateMotion"));
- builder.addMapping(uri, "animateColor", SVGObj.maker("animateColor"));
- builder.addMapping(uri, "animateTransform", SVGObj.maker("animateTransform"));
- builder.addMapping(uri, "cursor", SVGObj.maker("cursor"));
- builder.addMapping(uri, "filter", SVGObj.maker("filter"));
+ foObjs.put("marker", SVGObj.maker("marker"));
+ foObjs.put("animate", SVGObj.maker("animate"));
+ foObjs.put("altGlyph", SVGObj.maker("altGlyph"));
+ foObjs.put("font", SVGObj.maker("font"));
+ foObjs.put("glyph", SVGObj.maker("glyph"));
+ foObjs.put("missing-glyph", SVGObj.maker("missing-glyph"));
+ foObjs.put("hkern", SVGObj.maker("hkern"));
+ foObjs.put("vkern", SVGObj.maker("vkern"));
+ foObjs.put("set", SVGObj.maker("set"));
+ foObjs.put("animateMotion", SVGObj.maker("animateMotion"));
+ foObjs.put("animateColor", SVGObj.maker("animateColor"));
+ foObjs.put("animateTransform", SVGObj.maker("animateTransform"));
+ foObjs.put("cursor", SVGObj.maker("cursor"));
+ foObjs.put("filter", SVGObj.maker("filter"));
- builder.addMapping(uri, "feFlood", SVGObj.maker("feFlood"));
- builder.addMapping(uri, "feGaussianBlur", SVGObj.maker("feGaussianBlur"));
- builder.addMapping(uri, "feOffset", SVGObj.maker("feOffset"));
- builder.addMapping(uri, "feMerge", SVGObj.maker("feMerge"));
- builder.addMapping(uri, "feMergeNode", SVGObj.maker("feMergeNode"));
+ foObjs.put("feFlood", SVGObj.maker("feFlood"));
+ foObjs.put("feGaussianBlur", SVGObj.maker("feGaussianBlur"));
+ foObjs.put("feOffset", SVGObj.maker("feOffset"));
+ foObjs.put("feMerge", SVGObj.maker("feMerge"));
+ foObjs.put("feMergeNode", SVGObj.maker("feMergeNode"));
+ }
+
+ String uri = "http://www.w3.org/2000/svg";
+ builder.addMapping(uri, foObjs);
builder.addPropertyListBuilder(uri, new DirectPropertyListBuilder());
}
diff --git a/src/org/apache/fop/tools/TestConverter.java b/src/org/apache/fop/tools/TestConverter.java
index 20be1ff9a..b972198ff 100644
--- a/src/org/apache/fop/tools/TestConverter.java
+++ b/src/org/apache/fop/tools/TestConverter.java
@@ -256,8 +256,9 @@ public class TestConverter {
if (outname.endsWith(".xml")) {
outname = outname.substring(0, outname.length() - 4);
}
- driver.setOutputStream(new FileOutputStream(new File(destdir,
- outname + (outputPDF ? ".pdf" : ".at.xml"))));
+ driver.setOutputStream(new BufferedOutputStream(
+ new FileOutputStream(new File(destdir,
+ outname + (outputPDF ? ".pdf" : ".at.xml")))));
log.debug("ddir:" + destdir + " on:" + outname + ".pdf");
driver.render(parser, inputHandler.getInputSource());