From: Keiron Liddle Date: Fri, 2 Nov 2001 11:06:09 +0000 (+0000) Subject: updated a few hashtables and vectors X-Git-Tag: fop-0_20_4-doc~228 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cfc0da75fcc187e6dd7596e7480c4941e278b9d5;p=xmlgraphics-fop.git updated a few hashtables and vectors git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194535 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/configuration/Configuration.java b/src/org/apache/fop/configuration/Configuration.java index ad9deedae..298a10e2a 100644 --- a/src/org/apache/fop/configuration/Configuration.java +++ b/src/org/apache/fop/configuration/Configuration.java @@ -7,9 +7,9 @@ package org.apache.fop.configuration; -import java.util.Vector; -import java.util.Hashtable; -import java.util.Enumeration; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; import org.apache.fop.messaging.MessageHandler; /** @@ -31,18 +31,17 @@ public class Configuration { /** * stores the configuration information */ - private static Hashtable standardConfiguration = new Hashtable(30); - ; - private static Hashtable pdfConfiguration = new Hashtable(20); - private static Hashtable awtConfiguration = new Hashtable(20); + private static HashMap standardConfiguration = new HashMap(30); + private static HashMap pdfConfiguration = new HashMap(20); + private static HashMap awtConfiguration = new HashMap(20); /** - * contains a Hashtable of existing Hashtables + * contains a HashMap of existing HashMaps */ - private static Hashtable configuration = new Hashtable(3); + private static HashMap configuration = new HashMap(3); /** - * loads the configuration types into the configuration Hashtable + * loads the configuration types into the configuration HashMap */ static { configuration.put("standard", standardConfiguration); @@ -50,7 +49,7 @@ public class Configuration { configuration.put("awt", awtConfiguration); } - public static Hashtable getConfiguration() { + public static HashMap getConfiguration() { return configuration; } @@ -76,8 +75,6 @@ public class Configuration { } } - ; - /** * convenience methods to access strings values in the configuration * @param key a string containing the key value for the configuration value @@ -94,8 +91,6 @@ public class Configuration { } } - ; - /** * convenience methods to access int values in the configuration * @param key a string containing the key value for the configuration value @@ -112,8 +107,6 @@ public class Configuration { } } - ; - /** * convenience methods to access boolean values in the configuration * @param key a string containing the key value for the configuration value @@ -132,45 +125,38 @@ public class Configuration { } } - ; - /** * convenience methods to access list values in the configuration * @param key a string containing the key value for the configuration value * role detemines the configuration target - * @return Vector a Vector containing the values + * @return ArrayList a ArrayList containing the values * null if the key is not defined. */ - public static Vector getListValue(String key, int role) { + public static ArrayList getListValue(String key, int role) { Object obj = Configuration.getValue(key, role); - if (obj instanceof Vector) { - return (Vector)obj; + if (obj instanceof ArrayList) { + return (ArrayList)obj; } else { return null; } } - ; - /** - * convenience methods to access map/hashtable values in the configuration + * convenience methods to access hashmap values in the configuration * @param key a string containing the key value for the configuration value * role detemines the configuration target - * @return Hashtable a Hashtable containing the values + * @return HashMap a HashMap containing the values * null if the key is not defined. */ - public static Hashtable getHashtableValue(String key, int role) { + public static HashMap getHashMapValue(String key, int role) { Object obj = Configuration.getValue(key, role); - if (obj instanceof Hashtable) { - return (Hashtable)obj; + if (obj instanceof HashMap) { + return (HashMap)obj; } else { return null; } } - ; - - /** * convenience method which retrieves some configuration information * from the standard configuration @@ -221,22 +207,22 @@ public class Configuration { * convenience methods to access list values in the standard configuration * * @param key a string containing the key value for the configuration value - * @return Vector a Vector containing the values + * @return ArrayList a ArrayList containing the values * null if the key is not defined. */ - public static Vector getListValue(String key) { + public static ArrayList getListValue(String key) { return Configuration.getListValue(key, Configuration.STANDARD); } /** - * convenience methods to access map/hashtable values in the standard configuration + * convenience methods to access hashmap values in the standard configuration * * @param key a string containing the key value for the configuration value - * @return Hashtable a Hashtable containing the values + * @return HashMap a HashMap containing the values * null if the key is not defined. */ - public static Hashtable getHashtableValue(String key) { - return Configuration.getHashtableValue(key, Configuration.STANDARD); + public static HashMap getHashMapValue(String key) { + return Configuration.getHashMapValue(key, Configuration.STANDARD); } @@ -244,11 +230,11 @@ public class Configuration { * method to access fonts values in the standard configuration * * @param key a string containing the key value for the configuration value - * @return Hashtable a Hashtable containing the values + * @return HashMap a HashMap containing the values * null if the key is not defined. */ - public static Vector getFonts() { - return (Vector)Configuration.getValue("fonts", + public static ArrayList getFonts() { + return (ArrayList)Configuration.getValue("fonts", Configuration.STANDARD); } @@ -256,7 +242,7 @@ public class Configuration { * initializes this configuration * @param config contains the configuration information */ - public static void setup(int role, Hashtable config) { + public static void setup(int role, HashMap config) { switch (role) { case Configuration.STANDARD: standardConfiguration = config; @@ -273,11 +259,11 @@ public class Configuration { } /** - * adds information to the configuration map/hashtable in key,value form + * adds information to the configuration hashmap in key,value form * @param key a string containing the key value for the configuration value * value the configuration information * role detemines the configuration target - * @param value an Object containing the value; can be a String, a Vector or a Hashtable + * @param value an Object containing the value; can be a String, a ArrayList or a HashMap */ public static void put(String key, Object value, int role) { switch (role) { @@ -301,11 +287,11 @@ public class Configuration { ; /** - * adds information to the standard configuration map/hashtable in key,value form + * adds information to the standard configuration hashmap in key,value form * @param key a string containing the key value for the configuration value * value the configuration information * role detemines the configuration target - * @param value an Object containing the value; can be a String, a Vector or a Hashtable + * @param value an Object containing the value; can be a String, a ArrayList or a HashMap */ public static void put(String key, Object value) { @@ -318,38 +304,36 @@ public class Configuration { public static void dumpConfiguration() { String key; Object value; - Vector list; - Hashtable map, configuration; - Enumeration enum; + ArrayList list; + HashMap map, configuration; String tmp; System.out.println("Dumping configuration: "); - Hashtable[] configs = { + HashMap[] configs = { standardConfiguration, pdfConfiguration, awtConfiguration }; for (int i = 0; i < configs.length; i++) { MessageHandler.logln("----------------------"); configuration = configs[i]; - Enumeration enumeration = configuration.keys(); - while (enumeration.hasMoreElements()) { - key = (String)enumeration.nextElement(); + Iterator iterator = configuration.keySet().iterator(); + while (iterator.hasNext()) { + key = (String)iterator.next(); MessageHandler.logln("key: " + key); value = configuration.get(key); if (value instanceof String) { MessageHandler.logln(" value: " + value); - } else if (value instanceof Vector) { - list = (Vector)value; - enum = list.elements(); + } else if (value instanceof ArrayList) { + list = (ArrayList)value; MessageHandler.log(" values: "); - while (enum.hasMoreElements()) { - MessageHandler.log(enum.nextElement() + " - "); + for (int count = 0; count < list.size(); count++) { + MessageHandler.log(list.get(count) + " - "); } MessageHandler.logln(""); - } else if (value instanceof Hashtable) { - map = (Hashtable)value; - enum = map.keys(); + } else if (value instanceof HashMap) { + map = (HashMap)value; + Iterator iter = map.keySet().iterator(); MessageHandler.log(" values: "); - while (enum.hasMoreElements()) { - tmp = (String)enum.nextElement(); + while (iter.hasNext()) { + tmp = (String)iter.next(); MessageHandler.log(" " + tmp + ":" + map.get(tmp)); } MessageHandler.logln(""); diff --git a/src/org/apache/fop/configuration/ConfigurationParser.java b/src/org/apache/fop/configuration/ConfigurationParser.java index 3cce731aa..f314da14a 100644 --- a/src/org/apache/fop/configuration/ConfigurationParser.java +++ b/src/org/apache/fop/configuration/ConfigurationParser.java @@ -14,13 +14,12 @@ import org.xml.sax.Attributes; import org.xml.sax.Locator; // java -import java.util.Hashtable; -import java.util.Vector; +import java.util.HashMap; +import java.util.ArrayList; // fop import org.apache.fop.messaging.MessageHandler; - /** * SAX2 Handler which retrieves the configuration information and stores them in Configuration. * Normally this class doesn't need to be accessed directly. @@ -45,12 +44,12 @@ public class ConfigurationParser extends DefaultHandler { private int datatype = -1; // store the result configuration - private static Hashtable configuration; - private static Hashtable activeConfiguration; + private static HashMap configuration; + private static HashMap activeConfiguration; // stores key for new config entry private String key = ""; - private Vector keyStack = new Vector(); + private ArrayList keyStack = new ArrayList(); // stores string value private String value = ""; @@ -59,10 +58,10 @@ public class ConfigurationParser extends DefaultHandler { private String subkey = ""; // stores list value - private Vector list = new Vector(15); + private ArrayList list = new ArrayList(15); // stores hashtable value - private Hashtable map = new Hashtable(15); + private HashMap map = new HashMap(15); /** * locator for line number information @@ -75,7 +74,7 @@ public class ConfigurationParser extends DefaultHandler { private String role = "standard"; // stores fonts - private Vector fontList = null; + private ArrayList fontList = null; // stores information on one font private FontInfo fontInfo = null; @@ -86,7 +85,7 @@ public class ConfigurationParser extends DefaultHandler { // information on a font private String fontName, metricsFile, embedFile, kerningAsString; private boolean kerning; - private Vector fontTriplets; + private ArrayList fontTriplets; // information on a font triplet private String fontTripletName, weight, style; @@ -125,7 +124,7 @@ public class ConfigurationParser extends DefaultHandler { } } else if (localName.equals("configuration")) {} else if (localName.equals("fonts")) { // list of fonts starts - fontList = new Vector(10); + fontList = new ArrayList(10); } else if (localName.equals("font")) { kerningAsString = attributes.getValue("kerning"); if (kerningAsString.equalsIgnoreCase("yes")) { @@ -136,13 +135,13 @@ public class ConfigurationParser extends DefaultHandler { metricsFile = attributes.getValue("metrics-file"); embedFile = attributes.getValue("embed-file"); fontName = attributes.getValue("name"); - fontTriplets = new Vector(5); + fontTriplets = new ArrayList(5); } else if (localName.equals("font-triplet")) { fontTripletName = attributes.getValue("name"); weight = attributes.getValue("weight"); style = attributes.getValue("style"); fontTriplet = new FontTriplet(fontTripletName, weight, style); - fontTriplets.addElement(fontTriplet); + fontTriplets.add(fontTriplet); } else { // to make sure that user knows about false tag MessageHandler.errorln("Unknown tag in configuration file: " @@ -168,10 +167,10 @@ public class ConfigurationParser extends DefaultHandler { status = OUT; role = "standard"; if (keyStack.size() > 0) { - keyStack.removeElementAt(keyStack.size() - 1); + keyStack.remove(keyStack.size() - 1); } if (keyStack.size() > 0) { - key = (String)keyStack.elementAt(keyStack.size() - 1); + key = (String)keyStack.get(keyStack.size() - 1); } else { key = ""; } @@ -180,17 +179,17 @@ public class ConfigurationParser extends DefaultHandler { map.put(subkey, value); status -= IN_SUBENTRY; if (keyStack.size() > 0) { - keyStack.removeElementAt(keyStack.size() - 1); + keyStack.remove(keyStack.size() - 1); } if (keyStack.size() > 0) { - key = (String)keyStack.elementAt(keyStack.size() - 1); + key = (String)keyStack.get(keyStack.size() - 1); } else { key = ""; } value = ""; } else if (localName.equals("key")) { status -= IN_KEY; - keyStack.addElement(key); + keyStack.add(key); } else if (localName.equals("list")) { status -= IN_LIST; value = ""; @@ -201,7 +200,7 @@ public class ConfigurationParser extends DefaultHandler { } else if (localName.equals("font")) { fontInfo = new FontInfo(fontName, metricsFile, kerning, fontTriplets, embedFile); - fontList.addElement(fontInfo); + fontList.add(fontInfo); fontTriplets = null; metricsFile = null; embedFile = null; @@ -230,7 +229,7 @@ public class ConfigurationParser extends DefaultHandler { datatype = STRING; break; case IN_LIST + IN_VALUE: - list.addElement(text); + list.add(text); datatype = LIST; break; case IN_LIST + IN_SUBENTRY + IN_VALUE: @@ -248,7 +247,7 @@ public class ConfigurationParser extends DefaultHandler { * @param value a string containing the value for the configuration */ private void store(String role, String key, Object value) { - activeConfiguration = (Hashtable)configuration.get(role); + activeConfiguration = (HashMap)configuration.get(role); if (activeConfiguration != null) { activeConfiguration.put(key, value); } else { diff --git a/src/org/apache/fop/configuration/FontInfo.java b/src/org/apache/fop/configuration/FontInfo.java index e552e0cd4..db0c96c38 100644 --- a/src/org/apache/fop/configuration/FontInfo.java +++ b/src/org/apache/fop/configuration/FontInfo.java @@ -8,7 +8,7 @@ package org.apache.fop.configuration; -import java.util.Vector; +import java.util.ArrayList; /** * FontInfo contains meta information on fonts (where is the metrics file etc.) @@ -17,10 +17,10 @@ import java.util.Vector; public class FontInfo { private String metricsFile, embedFile, name; private boolean kerning; - private Vector fontTriplets; + private ArrayList fontTriplets; public FontInfo(String name, String metricsFile, boolean kerning, - Vector fontTriplets, String embedFile) { + ArrayList fontTriplets, String embedFile) { this.name = name; this.metricsFile = metricsFile; this.embedFile = embedFile; @@ -40,7 +40,7 @@ public class FontInfo { return kerning; } - public Vector getFontTriplets() { + public ArrayList getFontTriplets() { return fontTriplets; } diff --git a/src/org/apache/fop/fo/XMLObj.java b/src/org/apache/fop/fo/XMLObj.java index c7631efac..bc56718aa 100644 --- a/src/org/apache/fop/fo/XMLObj.java +++ b/src/org/apache/fop/fo/XMLObj.java @@ -17,6 +17,7 @@ import org.apache.fop.datatypes.IDReferences; import org.w3c.dom.*; import org.xml.sax.Attributes; +import javax.xml.parsers.DocumentBuilderFactory; import java.util.*; @@ -105,12 +106,10 @@ public abstract class XMLObj extends FObj { element = null; try { - // DOMImplementation impl = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation(); - // String ns = GraphElementMapping.URI; - // doc = impl.createDocument(ns, "graph", null); - doc = - javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); - Element el = doc.createElement("graph"); + DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); + fact.setNamespaceAware(true); + doc = fact.newDocumentBuilder().newDocument(); + Element el = doc.createElement(tagName); doc.appendChild(el); element = doc.getDocumentElement(); diff --git a/src/org/apache/fop/layout/FontInfo.java b/src/org/apache/fop/layout/FontInfo.java index 4e8258fb1..4f145e3ea 100644 --- a/src/org/apache/fop/layout/FontInfo.java +++ b/src/org/apache/fop/layout/FontInfo.java @@ -7,21 +7,21 @@ package org.apache.fop.layout; -import java.util.Hashtable; +import java.util.HashMap; import org.apache.fop.messaging.MessageHandler; import java.util.Enumeration; import org.apache.fop.apps.FOPException; public class FontInfo { - Hashtable usedFonts; - Hashtable triplets; // look up a font-triplet to find a font-name - Hashtable fonts; // look up a font-name to get a font (that implements FontMetric at least) + HashMap usedFonts; + HashMap triplets; // look up a font-triplet to find a font-name + HashMap fonts; // look up a font-name to get a font (that implements FontMetric at least) public FontInfo() { - this.triplets = new Hashtable(); - this.fonts = new Hashtable(); - this.usedFonts = new Hashtable(); + this.triplets = new HashMap(); + this.fonts = new HashMap(); + this.usedFonts = new HashMap(); } public void addFontProperties(String name, String family, String style, @@ -94,11 +94,11 @@ public class FontInfo { return family + "," + style + "," + weight; } - public Hashtable getFonts() { + public HashMap getFonts() { return this.fonts; } - public Hashtable getUsedFonts() { + public HashMap getUsedFonts() { return this.usedFonts; } diff --git a/src/org/apache/fop/pdf/PDFColor.java b/src/org/apache/fop/pdf/PDFColor.java index 45279a852..443716b3a 100644 --- a/src/org/apache/fop/pdf/PDFColor.java +++ b/src/org/apache/fop/pdf/PDFColor.java @@ -8,7 +8,7 @@ package org.apache.fop.pdf; // Java -import java.util.Vector; +import java.util.ArrayList; import java.io.IOException; import java.io.PrintWriter; @@ -65,21 +65,21 @@ public class PDFColor extends PDFPathPaint { } - public Vector getVector() { // return a vector representation of the color + public ArrayList getVector() { // return a vector representation of the color // in the appropriate colorspace. - Vector theColorVector = new Vector(); + ArrayList theColorVector = new ArrayList(); if (this.colorSpace.getColorSpace() == ColorSpace.DEVICE_RGB) { // RGB - theColorVector.addElement(new Double(this.red)); - theColorVector.addElement(new Double(this.green)); - theColorVector.addElement(new Double(this.blue)); + theColorVector.add(new Double(this.red)); + theColorVector.add(new Double(this.green)); + theColorVector.add(new Double(this.blue)); } else if (this.colorSpace.getColorSpace() == ColorSpace.DEVICE_CMYK) { // CMYK - theColorVector.addElement(new Double(this.cyan)); - theColorVector.addElement(new Double(this.magenta)); - theColorVector.addElement(new Double(this.yellow)); - theColorVector.addElement(new Double(this.black)); + theColorVector.add(new Double(this.cyan)); + theColorVector.add(new Double(this.magenta)); + theColorVector.add(new Double(this.yellow)); + theColorVector.add(new Double(this.black)); } else { // GRAY - theColorVector.addElement(new Double(this.black)); + theColorVector.add(new Double(this.black)); } return (theColorVector); } diff --git a/src/org/apache/fop/pdf/PDFDocument.java b/src/org/apache/fop/pdf/PDFDocument.java index 09dcfd277..d24a2129b 100644 --- a/src/org/apache/fop/pdf/PDFDocument.java +++ b/src/org/apache/fop/pdf/PDFDocument.java @@ -27,7 +27,7 @@ import org.apache.fop.layout.FontDescriptor; // Java import java.io.IOException; import java.io.OutputStream; -import java.util.Vector; +import java.util.ArrayList; import java.util.Hashtable; import java.util.Enumeration; import java.awt.Rectangle; @@ -71,10 +71,10 @@ public class PDFDocument { /** * the character position of each object */ - protected Vector location = new Vector(); + protected ArrayList location = new ArrayList(); /** List of objects to write in the trailer */ - private Vector trailerObjects = new Vector(); + private ArrayList trailerObjects = new ArrayList(); /** * the counter for object numbering @@ -84,7 +84,7 @@ public class PDFDocument { /** * the objects themselves */ - protected Vector objects = new Vector(); + protected ArrayList objects = new ArrayList(); /** * character position of xref table @@ -141,7 +141,7 @@ public class PDFDocument { /** * the XObjects */ - protected Vector xObjects = new Vector(); + protected ArrayList xObjects = new ArrayList(); /** * the XObjects Map. @@ -152,7 +152,7 @@ public class PDFDocument { /** * the objects themselves */ - protected Vector pendingLinks = null; + protected ArrayList pendingLinks = null; /** * creates an empty PDF document

@@ -238,20 +238,20 @@ public class PDFDocument { PDFInfo pdfInfo = new PDFInfo(++this.objectcount); // set the default producer pdfInfo.setProducer(org.apache.fop.apps.Version.getVersion()); - this.objects.addElement(pdfInfo); + this.objects.add(pdfInfo); return pdfInfo; } /** * Make a Type 0 sampled function * - * @param theDomain Vector objects of Double objects. + * @param theDomain ArrayList objects of Double objects. * This is the domain of the function. * See page 264 of the PDF 1.3 Spec. - * @param theRange Vector objects of Double objects. + * @param theRange ArrayList objects of Double objects. * This is the Range of the function. * See page 264 of the PDF 1.3 Spec. - * @param theSize A Vector object of Integer objects. + * @param theSize A ArrayList object of Integer objects. * This is the number of samples in each input dimension. * I can't imagine there being more or less than two input dimensions, * so maybe this should be an array of length 2. @@ -266,14 +266,14 @@ public class PDFDocument { * This attribute is optional. * * See page 265 in the PDF 1.3 spec. - * @param theEncode Vector objects of Double objects. + * @param theEncode ArrayList objects of Double objects. * This is the linear mapping of input values intop the domain * of the function's sample table. Default is hard to represent in * ascii, but basically [0 (Size0 1) 0 (Size1 1)...]. * This attribute is optional. * * See page 265 in the PDF 1.3 spec. - * @param theDecode Vector objects of Double objects. + * @param theDecode ArrayList objects of Double objects. * This is a linear mapping of sample values into the range. * The default is just the range. * @@ -295,12 +295,12 @@ public class PDFDocument { * @param theFunctionType This is the type of function (0,2,3, or 4). * It should be 0 as this is the constructor for sampled functions. */ - public PDFFunction makeFunction(int theFunctionType, Vector theDomain, - Vector theRange, Vector theSize, + public PDFFunction makeFunction(int theFunctionType, ArrayList theDomain, + ArrayList theRange, ArrayList theSize, int theBitsPerSample, int theOrder, - Vector theEncode, Vector theDecode, + ArrayList theEncode, ArrayList theDecode, StringBuffer theFunctionDataStream, - Vector theFilter) { // Type 0 function + ArrayList theFilter) { // Type 0 function PDFFunction function = new PDFFunction(++this.objectcount, theFunctionType, theDomain, theRange, theSize, @@ -309,7 +309,7 @@ public class PDFDocument { theFunctionDataStream, theFilter); - this.objects.addElement(function); + this.objects.add(function); return (function); } @@ -317,10 +317,10 @@ public class PDFDocument { * make a type Exponential interpolation function * (for shading usually) * - * @param theDomain Vector objects of Double objects. + * @param theDomain ArrayList objects of Double objects. * This is the domain of the function. * See page 264 of the PDF 1.3 Spec. - * @param theRange Vector of Doubles that is the Range of the function. + * @param theRange ArrayList of Doubles that is the Range of the function. * See page 264 of the PDF 1.3 Spec. * @param theCZero This is a vector of Double objects which defines the function result * when x=0. @@ -338,29 +338,29 @@ public class PDFDocument { * PDF Spec page 268 * @param theFunctionType The type of the function, which should be 2. */ - public PDFFunction makeFunction(int theFunctionType, Vector theDomain, - Vector theRange, Vector theCZero, - Vector theCOne, + public PDFFunction makeFunction(int theFunctionType, ArrayList theDomain, + ArrayList theRange, ArrayList theCZero, + ArrayList theCOne, double theInterpolationExponentN) { // type 2 PDFFunction function = new PDFFunction(++this.objectcount, theFunctionType, theDomain, theRange, theCZero, theCOne, theInterpolationExponentN); - this.objects.addElement(function); + this.objects.add(function); return (function); } /** * Make a Type 3 Stitching function * - * @param theDomain Vector objects of Double objects. + * @param theDomain ArrayList objects of Double objects. * This is the domain of the function. * See page 264 of the PDF 1.3 Spec. - * @param theRange Vector objects of Double objects. + * @param theRange ArrayList objects of Double objects. * This is the Range of the function. * See page 264 of the PDF 1.3 Spec. - * @param theFunctions A Vector of the PDFFunction objects that the stitching function stitches. + * @param theFunctions A ArrayList of the PDFFunction objects that the stitching function stitches. * * This attributed is required. * It is described on page 269 of the PDF spec. @@ -373,7 +373,7 @@ public class PDFDocument { * * This attributed is required. * It's described on page 269 of the PDF 1.3 spec. - * @param theEncode Vector objects of Double objects. + * @param theEncode ArrayList objects of Double objects. * This is the linear mapping of input values intop the domain * of the function's sample table. Default is hard to represent in * ascii, but basically [0 (Size0 1) 0 (Size1 1)...]. @@ -383,17 +383,17 @@ public class PDFDocument { * @param theFunctionType This is the function type. It should be 3, * for a stitching function. */ - public PDFFunction makeFunction(int theFunctionType, Vector theDomain, - Vector theRange, Vector theFunctions, - Vector theBounds, - Vector theEncode) { // Type 3 + public PDFFunction makeFunction(int theFunctionType, ArrayList theDomain, + ArrayList theRange, ArrayList theFunctions, + ArrayList theBounds, + ArrayList theEncode) { // Type 3 PDFFunction function = new PDFFunction(++this.objectcount, theFunctionType, theDomain, theRange, theFunctions, theBounds, theEncode); - this.objects.addElement(function); + this.objects.add(function); return (function); } @@ -407,14 +407,14 @@ public class PDFDocument { * @param theFunctionDataStream */ public PDFFunction makeFunction(int theNumber, int theFunctionType, - Vector theDomain, Vector theRange, + ArrayList theDomain, ArrayList theRange, StringBuffer theFunctionDataStream) { // Type 4 PDFFunction function = new PDFFunction(++this.objectcount, theFunctionType, theDomain, theRange, theFunctionDataStream); - this.objects.addElement(function); + this.objects.add(function); return (function); } @@ -428,13 +428,13 @@ public class PDFDocument { * @param theBackground An array of color components appropriate to the * colorspace key specifying a single color value. * This key is used by the f operator buy ignored by the sh operator. - * @param theBBox Vector of double's representing a rectangle + * @param theBBox ArrayList of double's representing a rectangle * in the coordinate space that is current at the * time of shading is imaged. Temporary clipping * boundary. * @param theAntiAlias Whether or not to anti-alias. * @param theDomain Optional vector of Doubles specifying the domain. - * @param theMatrix Vector of Doubles specifying the matrix. + * @param theMatrix ArrayList of Doubles specifying the matrix. * If it's a pattern, then the matrix maps it to pattern space. * If it's a shading, then it maps it to current user space. * It's optional, the default is the identity matrix @@ -442,9 +442,9 @@ public class PDFDocument { */ public PDFShading makeShading(int theShadingType, ColorSpace theColorSpace, - Vector theBackground, Vector theBBox, - boolean theAntiAlias, Vector theDomain, - Vector theMatrix, + ArrayList theBackground, ArrayList theBBox, + boolean theAntiAlias, ArrayList theDomain, + ArrayList theMatrix, PDFFunction theFunction) { // make Shading of Type 1 String theShadingName = new String("Sh" + (++this.shadingCount)); @@ -453,7 +453,7 @@ public class PDFDocument { theColorSpace, theBackground, theBBox, theAntiAlias, theDomain, theMatrix, theFunction); - this.objects.addElement(shading); + this.objects.add(shading); // add this shading to resources this.resources.addShading(shading); @@ -469,23 +469,23 @@ public class PDFDocument { * @param theBackground theBackground An array of color components appropriate to the * colorspace key specifying a single color value. * This key is used by the f operator buy ignored by the sh operator. - * @param theBBox Vector of double's representing a rectangle + * @param theBBox ArrayList of double's representing a rectangle * in the coordinate space that is current at the * time of shading is imaged. Temporary clipping * boundary. * @param theAntiAlias Default is false - * @param theCoords Vector of four (type 2) or 6 (type 3) Double - * @param theDomain Vector of Doubles specifying the domain + * @param theCoords ArrayList of four (type 2) or 6 (type 3) Double + * @param theDomain ArrayList of Doubles specifying the domain * @param theFunction the Stitching (PDFfunction type 3) function, even if it's stitching a single function - * @param theExtend Vector of Booleans of whether to extend teh start and end colors past the start and end points + * @param theExtend ArrayList of Booleans of whether to extend teh start and end colors past the start and end points * The default is [false, false] */ public PDFShading makeShading(int theShadingType, ColorSpace theColorSpace, - Vector theBackground, Vector theBBox, - boolean theAntiAlias, Vector theCoords, - Vector theDomain, PDFFunction theFunction, - Vector theExtend) { // make Shading of Type 2 or 3 + ArrayList theBackground, ArrayList theBBox, + boolean theAntiAlias, ArrayList theCoords, + ArrayList theDomain, PDFFunction theFunction, + ArrayList theExtend) { // make Shading of Type 2 or 3 String theShadingName = new String("Sh" + (++this.shadingCount)); PDFShading shading = new PDFShading(++this.objectcount, @@ -497,7 +497,7 @@ public class PDFDocument { this.resources.addShading(shading); - this.objects.addElement(shading); + this.objects.add(shading); return (shading); } @@ -512,7 +512,7 @@ public class PDFDocument { * @param theBackground theBackground An array of color components appropriate to the * colorspace key specifying a single color value. * This key is used by the f operator buy ignored by the sh operator. - * @param theBBox Vector of double's representing a rectangle + * @param theBBox ArrayList of double's representing a rectangle * in the coordinate space that is current at the * time of shading is imaged. Temporary clipping * boundary. @@ -520,16 +520,16 @@ public class PDFDocument { * @param theBitsPerCoordinate 1,2,4,8,12,16,24 or 32. * @param theBitsPerComponent 1,2,4,8,12, and 16 * @param theBitsPerFlag 2,4,8. - * @param theDecode Vector of Doubles see PDF 1.3 spec pages 303 to 312. + * @param theDecode ArrayList of Doubles see PDF 1.3 spec pages 303 to 312. * @param theFunction the PDFFunction */ public PDFShading makeShading(int theShadingType, ColorSpace theColorSpace, - Vector theBackground, Vector theBBox, + ArrayList theBackground, ArrayList theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, - int theBitsPerFlag, Vector theDecode, + int theBitsPerFlag, ArrayList theDecode, PDFFunction theFunction) { // make Shading of type 4,6 or 7 String theShadingName = new String("Sh" + (++this.shadingCount)); @@ -544,7 +544,7 @@ public class PDFDocument { this.resources.addShading(shading); - this.objects.addElement(shading); + this.objects.add(shading); return (shading); } @@ -557,23 +557,23 @@ public class PDFDocument { * @param theBackground theBackground An array of color components appropriate to the * colorspace key specifying a single color value. * This key is used by the f operator buy ignored by the sh operator. - * @param theBBox Vector of double's representing a rectangle + * @param theBBox ArrayList of double's representing a rectangle * in the coordinate space that is current at the * time of shading is imaged. Temporary clipping * boundary. * @param theAntiAlias Default is false * @param theBitsPerCoordinate 1,2,4,8,12,16, 24, or 32 * @param theBitsPerComponent 1,2,4,8,12,24,32 - * @param theDecode Vector of Doubles. See page 305 in PDF 1.3 spec. + * @param theDecode ArrayList of Doubles. See page 305 in PDF 1.3 spec. * @param theVerticesPerRow number of vertices in each "row" of the lattice. * @param theFunction The PDFFunction that's mapped on to this shape */ public PDFShading makeShading(int theShadingType, ColorSpace theColorSpace, - Vector theBackground, Vector theBBox, + ArrayList theBackground, ArrayList theBBox, boolean theAntiAlias, int theBitsPerCoordinate, - int theBitsPerComponent, Vector theDecode, + int theBitsPerComponent, ArrayList theDecode, int theVerticesPerRow, PDFFunction theFunction) { // make shading of Type 5 String theShadingName = new String("Sh" + (++this.shadingCount)); @@ -588,7 +588,7 @@ public class PDFDocument { this.resources.addShading(shading); - this.objects.addElement(shading); + this.objects.add(shading); return (shading); } @@ -600,17 +600,17 @@ public class PDFDocument { * @param theResources the resources associated with this pattern * @param thePaintType 1 or 2, colored or uncolored. * @param theTilingType 1, 2, or 3, constant spacing, no distortion, or faster tiling - * @param theBBox Vector of Doubles: The pattern cell bounding box + * @param theBBox ArrayList of Doubles: The pattern cell bounding box * @param theXStep horizontal spacing * @param theYStep vertical spacing - * @param theMatrix Optional Vector of Doubles transformation matrix + * @param theMatrix Optional ArrayList of Doubles transformation matrix * @param theXUID Optional vector of Integers that uniquely identify the pattern * @param thePatternDataStream The stream of pattern data to be tiled. */ public PDFPattern makePattern(int thePatternType, // 1 PDFResources theResources, int thePaintType, int theTilingType, - Vector theBBox, double theXStep, double theYStep, Vector theMatrix, - Vector theXUID, StringBuffer thePatternDataStream) { + ArrayList theBBox, double theXStep, double theYStep, ArrayList theMatrix, + ArrayList theXUID, StringBuffer thePatternDataStream) { String thePatternName = new String("Pa" + (++this.patternCount)); // int theNumber, String thePatternName, // PDFResources theResources @@ -622,7 +622,7 @@ public class PDFDocument { thePatternDataStream); this.resources.addPattern(pattern); - this.objects.addElement(pattern); + this.objects.add(pattern); return (pattern); } @@ -634,11 +634,11 @@ public class PDFDocument { * @param theShading the PDF Shading object that comprises this pattern * @param theXUID optional:the extended unique Identifier if used. * @param theExtGState optional: the extended graphics state, if used. - * @param theMatrix Optional:Vector of Doubles that specify the matrix. + * @param theMatrix Optional:ArrayList of Doubles that specify the matrix. */ public PDFPattern makePattern(int thePatternType, PDFShading theShading, - Vector theXUID, StringBuffer theExtGState, - Vector theMatrix) { + ArrayList theXUID, StringBuffer theExtGState, + ArrayList theMatrix) { String thePatternName = new String("Pa" + (++this.patternCount)); PDFPattern pattern = new PDFPattern(++this.objectcount, @@ -646,7 +646,7 @@ public class PDFDocument { theXUID, theExtGState, theMatrix); this.resources.addPattern(pattern); - this.objects.addElement(pattern); + this.objects.add(pattern); return (pattern); } @@ -662,17 +662,17 @@ public class PDFDocument { public PDFPattern createGradient(boolean radial, ColorSpace theColorspace, - Vector theColors, Vector theBounds, - Vector theCoords) { + ArrayList theColors, ArrayList theBounds, + ArrayList theCoords) { PDFShading myShad; PDFFunction myfunky; PDFFunction myfunc; - Vector theCzero; - Vector theCone; + ArrayList theCzero; + ArrayList theCone; PDFPattern myPattern; ColorSpace theColorSpace; double interpolation = (double)1.000; - Vector theFunctions = new Vector(); + ArrayList theFunctions = new ArrayList(); int currentPosition; int lastPosition = theColors.size() - 1; @@ -685,8 +685,8 @@ public class PDFDocument { for (currentPosition = 0; currentPosition < lastPosition; currentPosition++) { // for every consecutive color pair PDFColor currentColor = - (PDFColor)theColors.elementAt(currentPosition); - PDFColor nextColor = (PDFColor)theColors.elementAt(currentPosition + (PDFColor)theColors.get(currentPosition); + PDFColor nextColor = (PDFColor)theColors.get(currentPosition + 1); // colorspace must be consistant if (this.colorspace.getColorSpace() @@ -702,7 +702,7 @@ public class PDFDocument { myfunc = this.makeFunction(2, null, null, theCzero, theCone, interpolation); - theFunctions.addElement(myfunc); + theFunctions.add(myfunc); } // end of for every consecutive color pair @@ -717,13 +717,13 @@ public class PDFDocument { } else { // if the center x, center y, and radius specifiy // the gradient, then assume the same center x, center y, // and radius of zero for the other necessary component - Vector newCoords = new Vector(); - newCoords.addElement(theCoords.elementAt(0)); - newCoords.addElement(theCoords.elementAt(1)); - newCoords.addElement(theCoords.elementAt(2)); - newCoords.addElement(theCoords.elementAt(0)); - newCoords.addElement(theCoords.elementAt(1)); - newCoords.addElement(new Double(0.0)); + ArrayList newCoords = new ArrayList(); + newCoords.add(theCoords.get(0)); + newCoords.add(theCoords.get(1)); + newCoords.add(theCoords.get(2)); + newCoords.add(theCoords.get(0)); + newCoords.add(theCoords.get(1)); + newCoords.add(new Double(0.0)); myShad = this.makeShading(3, this.colorspace, null, null, false, newCoords, null, myfunky, @@ -756,7 +756,7 @@ public class PDFDocument { */ PDFEncoding encoding = new PDFEncoding(++this.objectcount, encodingName); - this.objects.addElement(encoding); + this.objects.add(encoding); return encoding; } @@ -782,7 +782,7 @@ public class PDFDocument { if (descriptor == null) { PDFFont font = new PDFFont(++this.objectcount, fontname, PDFFont.TYPE1, basefont, encoding); - this.objects.addElement(font); + this.objects.add(font); return font; } else { byte subtype = PDFFont.TYPE1; @@ -804,7 +804,7 @@ public class PDFDocument { * "Identity", * 0)); * cmap.addContents(); - * this.objects.addElement(cmap); + * this.objects.add(cmap); */ font = (PDFFontNonBase14)PDFFont.createFont(++this.objectcount, @@ -818,7 +818,7 @@ public class PDFDocument { fontname, subtype, basefont, encoding); } - this.objects.addElement(font); + this.objects.add(font); font.setDescriptor(pdfdesc); @@ -839,7 +839,7 @@ public class PDFDocument { cidMetrics.getDefaultWidth(), cidMetrics.getWidths(), sysInfo, (PDFCIDFontDescriptor)pdfdesc); - this.objects.addElement(cidFont); + this.objects.add(cidFont); // ((PDFFontType0)font).setCMAP(cmap); @@ -885,7 +885,7 @@ public class PDFDocument { desc.getStemV(), desc.getItalicAngle()); } - this.objects.addElement(font); + this.objects.add(font); // Check if the font is embeddable if (desc.isEmbeddable()) { @@ -893,7 +893,7 @@ public class PDFDocument { if (stream != null) { this.objectcount++; font.setFontFile(desc.getSubType(), stream); - this.objects.addElement(stream); + this.objects.add(stream); } } return font; @@ -906,7 +906,7 @@ public class PDFDocument { public PDFArray makeArray(int[] values) { PDFArray array = new PDFArray(++this.objectcount, values); - this.objects.addElement(array); + this.objects.add(array); return array; } @@ -920,8 +920,8 @@ public class PDFDocument { // else, create a new one xObject = new PDFXObject(++this.objectcount, ++this.xObjectCount, img); - this.objects.addElement(xObject); - this.xObjects.addElement(xObject); + this.objects.add(xObject); + this.xObjects.add(xObject); this.xObjectsMap.put(url, xObject); return xObjectCount; } @@ -947,8 +947,8 @@ public class PDFDocument { pagewidth, pageheight); if(pendingLinks != null) { - for(Enumeration e = pendingLinks.elements(); e.hasMoreElements(); ) { - PendingLink pl = (PendingLink)e.nextElement(); + for(int count = 0; count < pendingLinks.size(); count++) { + PendingLink pl = (PendingLink)pendingLinks.get(count); PDFGoTo gt = new PDFGoTo(++this.objectcount, page.referencePDF()); gt.setDestination(pl.dest); @@ -970,7 +970,7 @@ public class PDFDocument { } */ /* add it to the list of objects */ - this.objects.addElement(page); + this.objects.add(page); /* add the page to the Root */ this.root.addPage(page); @@ -993,16 +993,16 @@ public class PDFDocument { PDFAction action; PDFLink link = new PDFLink(++this.objectcount, rect); - this.objects.addElement(link); + this.objects.add(link); if (linkType == LinkSet.EXTERNAL) { // check destination if (destination.endsWith(".pdf")) { // FileSpec PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount, destination); - this.objects.addElement(fileSpec); + this.objects.add(fileSpec); action = new PDFGoToRemote(++this.objectcount, fileSpec); - this.objects.addElement(action); + this.objects.add(action); link.setAction(action); } else { // URI PDFUri uri = new PDFUri(destination); @@ -1044,7 +1044,7 @@ public class PDFDocument { } public void addTrailerObject(PDFObject object) { - this.trailerObjects.addElement(object); + this.trailerObjects.add(object); } class PendingLink { @@ -1054,21 +1054,21 @@ public class PDFDocument { public PDFLink makeLinkCurrentPage(Rectangle rect, String dest) { PDFLink link = new PDFLink(++this.objectcount, rect); - this.objects.addElement(link); + this.objects.add(link); PendingLink pl = new PendingLink(); pl.link = link; pl.dest = dest; if(pendingLinks == null) { - pendingLinks = new Vector(); + pendingLinks = new ArrayList(); } - pendingLinks.addElement(pl); + pendingLinks.add(pl); return link; } public PDFLink makeLink(Rectangle rect, String page, String dest) { PDFLink link = new PDFLink(++this.objectcount, rect); - this.objects.addElement(link); + this.objects.add(link); PDFGoTo gt = new PDFGoTo(++this.objectcount, page); gt.setDestination(dest); @@ -1085,7 +1085,7 @@ public class PDFDocument { */ private void prepareLocations() { while(location.size() < objectcount) - location.addElement(locationPlaceholder); + location.add(locationPlaceholder); } /** @@ -1103,7 +1103,7 @@ public class PDFDocument { PDFStream obj = new PDFStream(++this.objectcount); obj.addDefaultFilters(); - this.objects.addElement(obj); + this.objects.add(obj); return obj; } @@ -1120,7 +1120,7 @@ public class PDFDocument { * to the list of objects */ PDFAnnotList obj = new PDFAnnotList(++this.objectcount); - this.objects.addElement(obj); + this.objects.add(obj); return obj; } @@ -1155,7 +1155,7 @@ public class PDFDocument { if (parent != null) { parent.addOutline(obj); } - this.objects.addElement(obj); + this.objects.add(obj); return obj; } @@ -1178,17 +1178,16 @@ public class PDFDocument { prepareLocations(); - Enumeration en = this.objects.elements(); - while (en.hasMoreElements()) { + for (int count = 0; count < this.objects.size(); count++) { /* retrieve the object with the current number */ - PDFObject object = (PDFObject)en.nextElement(); + PDFObject object = (PDFObject)this.objects.get(count); /* * add the position of this object to the list of object * locations */ - location.setElementAt( - new Integer(this.position),object.getNumber() - 1); + location.set(object.getNumber() - 1, + new Integer(this.position)); /* * output the object and increment the character position @@ -1236,11 +1235,10 @@ public class PDFDocument { public void outputTrailer(OutputStream stream) throws IOException { output(stream); - Enumeration e = trailerObjects.elements(); - while(e.hasMoreElements()) { - PDFObject o = (PDFObject) e.nextElement(); - this.location.setElementAt( - new Integer(this.position), o.getNumber() - 1); + for(int count = 0; count < trailerObjects.size(); count++) { + PDFObject o = (PDFObject) trailerObjects.get(count); + this.location.set(o.getNumber() - 1, + new Integer(this.position)); this.position += o.output(stream); } /* output the xref table and increment the character position @@ -1279,9 +1277,8 @@ public class PDFDocument { + (this.objectcount + 1) + "\n0000000000 65535 f \n"); - Enumeration en = this.location.elements(); - while (en.hasMoreElements()) { - String x = en.nextElement().toString(); + for (int count = 0; count < this.location.size(); count++) { + String x = this.location.get(count).toString(); /* contruct xref entry for object */ String padding = "0000000000"; diff --git a/src/org/apache/fop/pdf/PDFEncoding.java b/src/org/apache/fop/pdf/PDFEncoding.java index 68151bdfd..411a8d97f 100644 --- a/src/org/apache/fop/pdf/PDFEncoding.java +++ b/src/org/apache/fop/pdf/PDFEncoding.java @@ -8,9 +8,9 @@ package org.apache.fop.pdf; // Java -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; +import java.util.Iterator; +import java.util.HashMap; +import java.util.ArrayList; /** * class representing an /Encoding object. @@ -49,7 +49,7 @@ public class PDFEncoding extends PDFObject { /** * the differences from the base encoding */ - protected Hashtable differences; + protected HashMap differences; /** * create the /Encoding object @@ -64,7 +64,7 @@ public class PDFEncoding extends PDFObject { /* set fields using paramaters */ this.basename = basename; - this.differences = new Hashtable(); + this.differences = new HashMap(); } /** @@ -73,7 +73,7 @@ public class PDFEncoding extends PDFObject { * @param code the first index of the sequence to be changed * @param sequence the sequence of glyph names (as String) */ - public void addDifferences(int code, Vector sequence) { + public void addDifferences(int code, ArrayList sequence) { differences.put(new Integer(code), sequence); } @@ -92,15 +92,15 @@ public class PDFEncoding extends PDFObject { if (!differences.isEmpty()) { p.append("\n/Differences [ "); Object code; - Enumeration codes = differences.keys(); - while (codes.hasMoreElements()) { - code = codes.nextElement(); + Iterator codes = differences.keySet().iterator(); + while (codes.hasNext()) { + code = codes.next(); p.append(" "); p.append(code); - Vector sequence = (Vector)differences.get(code); + ArrayList sequence = (ArrayList)differences.get(code); for (int i = 0; i < sequence.size(); i++) { p.append(" /"); - p.append((String)sequence.elementAt(i)); + p.append((String)sequence.get(i)); } } p.append(" ]"); diff --git a/src/org/apache/fop/pdf/PDFFunction.java b/src/org/apache/fop/pdf/PDFFunction.java index 185addc9e..3f57df16b 100644 --- a/src/org/apache/fop/pdf/PDFFunction.java +++ b/src/org/apache/fop/pdf/PDFFunction.java @@ -8,7 +8,7 @@ package org.apache.fop.pdf; // Java... -import java.util.Vector; +import java.util.ArrayList; /** * class representing a PDF Function. @@ -31,12 +31,12 @@ public class PDFFunction extends PDFObject { /** * Required: 2 * m Array of Double numbers which are possible inputs to the function */ - protected Vector domain = null; + protected ArrayList domain = null; /** * Required: 2 * n Array of Double numbers which are possible outputs to the function */ - protected Vector range = null; + protected ArrayList range = null; /* ********************TYPE 0***************************** */ // FunctionType 0 specific function guts @@ -46,7 +46,7 @@ public class PDFFunction extends PDFObject { * Note: This is really more like two seperate integers, sizeDomain, and sizeRange, * but since they're expressed as an array in PDF, my implementation reflects that. */ - protected Vector size = null; + protected ArrayList size = null; /** * Required for Type 0: Number of Bits used to represent each sample value. Limited to 1,2,4,8,12,16,24, or 32 @@ -64,12 +64,12 @@ public class PDFFunction extends PDFObject { * Required for Type 3: A 2 * k array of Doubles that, taken in pairs, map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function. * Should be two values per function, usually (0,1), as in [0 1 0 1] for 2 functions. */ - protected Vector encode = null; + protected ArrayList encode = null; /** * Optinoal for Type 0: A 2 * n array of Doubles which provides a linear mapping of sample values to the range. Defaults to Range. */ - protected Vector decode = null; + protected ArrayList decode = null; /** * Optional For Type 0: A stream of sample values @@ -84,18 +84,18 @@ public class PDFFunction extends PDFObject { * Required (?) For Type 0: A vector of Strings for the various filters to be used to decode the stream. * These are how the string is compressed. Flate, LZW, etc. */ - protected Vector filter = null; + protected ArrayList filter = null; /* *************************TYPE 2************************** */ /** * Required For Type 2: An Array of n Doubles defining the function result when x=0. Default is [0]. */ - protected Vector cZero = null; + protected ArrayList cZero = null; /** * Required For Type 2: An Array of n Doubles defining the function result when x=1. Default is [1]. */ - protected Vector cOne = null; + protected ArrayList cOne = null; /** * Required for Type 2: The interpolation exponent. @@ -109,7 +109,7 @@ public class PDFFunction extends PDFObject { /** * Required for Type 3: An vector of PDFFunctions which form an array of k single input functions making up the stitching function. */ - protected Vector functions = null; + protected ArrayList functions = null; /** * Optional for Type 3: An array of (k-1) Doubles that, in combination with Domain, define the intervals to which each function from the Functions array apply. Bounds elements must be in order of increasing magnitude, and each value must be within the value of Domain. @@ -118,7 +118,7 @@ public class PDFFunction extends PDFObject { * This makes each function responsible for an equal amount of the stitching function. * It makes the gradient even. */ - protected Vector bounds = null; + protected ArrayList bounds = null; // See encode above, as it's also part of Type 3 Functions. /* *************************TYPE 4************************** */ @@ -130,13 +130,13 @@ public class PDFFunction extends PDFObject { * Use null for an optional object parameter if you choose not to use it. * For optional int parameters, pass the default. * - * @param theDomain Vector objects of Double objects. + * @param theDomain ArrayList objects of Double objects. * This is the domain of the function. * See page 264 of the PDF 1.3 Spec. - * @param theRange Vector objects of Double objects. + * @param theRange ArrayList objects of Double objects. * This is the Range of the function. * See page 264 of the PDF 1.3 Spec. - * @param theSize A Vector object of Integer objects. + * @param theSize A ArrayList object of Integer objects. * This is the number of samples in each input dimension. * I can't imagine there being more or less than two input dimensions, * so maybe this should be an array of length 2. @@ -151,14 +151,14 @@ public class PDFFunction extends PDFObject { * This attribute is optional. * * See page 265 in the PDF 1.3 spec. - * @param theEncode Vector objects of Double objects. + * @param theEncode ArrayList objects of Double objects. * This is the linear mapping of input values intop the domain * of the function's sample table. Default is hard to represent in * ascii, but basically [0 (Size0 1) 0 (Size1 1)...]. * This attribute is optional. * * See page 265 in the PDF 1.3 spec. - * @param theDecode Vector objects of Double objects. + * @param theDecode ArrayList objects of Double objects. * This is a linear mapping of sample values into the range. * The default is just the range. * @@ -180,10 +180,10 @@ public class PDFFunction extends PDFObject { * @param theFunctionType This is the type of function (0,2,3, or 4). * It should be 0 as this is the constructor for sampled functions. */ - public PDFFunction(int theNumber, int theFunctionType, Vector theDomain, - Vector theRange, Vector theSize, int theBitsPerSample, - int theOrder, Vector theEncode, Vector theDecode, - StringBuffer theFunctionDataStream, Vector theFilter) { + public PDFFunction(int theNumber, int theFunctionType, ArrayList theDomain, + ArrayList theRange, ArrayList theSize, int theBitsPerSample, + int theOrder, ArrayList theEncode, ArrayList theDecode, + StringBuffer theFunctionDataStream, ArrayList theFilter) { super(theNumber); this.functionType = 0; // dang well better be 0; @@ -209,10 +209,10 @@ public class PDFFunction extends PDFObject { * For optional int parameters, pass the default. * * @param theNumber the object's number - * @param theDomain Vector objects of Double objects. + * @param theDomain ArrayList objects of Double objects. * This is the domain of the function. * See page 264 of the PDF 1.3 Spec. - * @param theRange Vector of Doubles that is the Range of the function. + * @param theRange ArrayList of Doubles that is the Range of the function. * See page 264 of the PDF 1.3 Spec. * @param theCZero This is a vector of Double objects which defines the function result * when x=0. @@ -230,8 +230,8 @@ public class PDFFunction extends PDFObject { * PDF Spec page 268 * @param theFunctionType The type of the function, which should be 2. */ - public PDFFunction(int theNumber, int theFunctionType, Vector theDomain, - Vector theRange, Vector theCZero, Vector theCOne, + public PDFFunction(int theNumber, int theFunctionType, ArrayList theDomain, + ArrayList theRange, ArrayList theCZero, ArrayList theCOne, double theInterpolationExponentN) { super(theNumber); @@ -254,13 +254,13 @@ public class PDFFunction extends PDFObject { * For optional int parameters, pass the default. * * @param theNumber the object's number - * @param theDomain Vector objects of Double objects. + * @param theDomain ArrayList objects of Double objects. * This is the domain of the function. * See page 264 of the PDF 1.3 Spec. - * @param theRange Vector objects of Double objects. + * @param theRange ArrayList objects of Double objects. * This is the Range of the function. * See page 264 of the PDF 1.3 Spec. - * @param theFunctions A Vector of the PDFFunction objects that the stitching function stitches. + * @param theFunctions A ArrayList of the PDFFunction objects that the stitching function stitches. * * This attributed is required. * It is described on page 269 of the PDF spec. @@ -273,7 +273,7 @@ public class PDFFunction extends PDFObject { * * This attributed is required. * It's described on page 269 of the PDF 1.3 spec. - * @param theEncode Vector objects of Double objects. + * @param theEncode ArrayList objects of Double objects. * This is the linear mapping of input values intop the domain * of the function's sample table. Default is hard to represent in * ascii, but basically [0 (Size0 1) 0 (Size1 1)...]. @@ -283,9 +283,9 @@ public class PDFFunction extends PDFObject { * @param theFunctionType This is the function type. It should be 3, * for a stitching function. */ - public PDFFunction(int theNumber, int theFunctionType, Vector theDomain, - Vector theRange, Vector theFunctions, - Vector theBounds, Vector theEncode) { + public PDFFunction(int theNumber, int theFunctionType, ArrayList theDomain, + ArrayList theRange, ArrayList theFunctions, + ArrayList theBounds, ArrayList theEncode) { super(theNumber); this.functionType = 3; // dang well better be 3; @@ -304,10 +304,10 @@ public class PDFFunction extends PDFObject { * Use null for an optional object parameter if you choose not to use it. * For optional int parameters, pass the default. * - * @param theDomain Vector object of Double objects. + * @param theDomain ArrayList object of Double objects. * This is the domain of the function. * See page 264 of the PDF 1.3 Spec. - * @param theRange Vector object of Double objects. + * @param theRange ArrayList object of Double objects. * This is the Range of the function. * See page 264 of the PDF 1.3 Spec. * @param theFunctionDataStream This is a stream of arithmetic, boolean, and stack operators and boolean constants. @@ -320,8 +320,8 @@ public class PDFFunction extends PDFObject { * @param theFunctionType The type of function which should be 4, as this is * a Postscript calculator function */ - public PDFFunction(int theNumber, int theFunctionType, Vector theDomain, - Vector theRange, StringBuffer theFunctionDataStream) { + public PDFFunction(int theNumber, int theFunctionType, ArrayList theDomain, + ArrayList theRange, StringBuffer theFunctionDataStream) { super(theNumber); this.functionType = 4; // dang well better be 4; @@ -360,7 +360,7 @@ public class PDFFunction extends PDFObject { p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.domain.get(tempInt)) + " "); } @@ -374,7 +374,7 @@ public class PDFFunction extends PDFObject { p.append("/Size [ "); vectorSize = this.size.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.size.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.size.get(tempInt)) + " "); } p.append("] \n"); @@ -384,7 +384,7 @@ public class PDFFunction extends PDFObject { p.append("/Encode [ "); vectorSize = this.encode.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.encode.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.encode.get(tempInt)) + " "); } p.append("] \n"); @@ -411,7 +411,7 @@ public class PDFFunction extends PDFObject { p.append("/Range [ "); vectorSize = this.range.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.range.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.range.get(tempInt)) + " "); } @@ -423,7 +423,7 @@ public class PDFFunction extends PDFObject { p.append("/Decode [ "); vectorSize = this.decode.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.decode.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.decode.get(tempInt)) + " "); } @@ -441,12 +441,12 @@ public class PDFFunction extends PDFObject { vectorSize = this.filter.size(); p.append("/Filter "); if (vectorSize == 1) { - p.append("/" + ((String)this.filter.elementAt(0)) + p.append("/" + ((String)this.filter.get(0)) + " \n"); } else { p.append("[ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append("/" + ((String)this.filter.elementAt(0)) + p.append("/" + ((String)this.filter.get(0)) + " "); } p.append("] \n"); @@ -469,7 +469,7 @@ public class PDFFunction extends PDFObject { p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.domain.get(tempInt)) + " "); } @@ -484,7 +484,7 @@ public class PDFFunction extends PDFObject { p.append("/Range [ "); vectorSize = this.range.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.range.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.range.get(tempInt)) + " "); } @@ -498,7 +498,7 @@ public class PDFFunction extends PDFObject { p.append("/C0 [ "); vectorSize = this.cZero.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.cZero.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.cZero.get(tempInt)) + " "); } p.append("] \n"); @@ -509,7 +509,7 @@ public class PDFFunction extends PDFObject { p.append("/C1 [ "); vectorSize = this.cOne.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.cOne.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.cOne.get(tempInt)) + " "); } p.append("] \n"); @@ -529,7 +529,7 @@ public class PDFFunction extends PDFObject { p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.domain.get(tempInt)) + " "); } p.append("] \n"); @@ -542,7 +542,7 @@ public class PDFFunction extends PDFObject { p.append("/Range [ "); vectorSize = this.range.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.range.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.range.get(tempInt)) + " "); } @@ -554,7 +554,7 @@ public class PDFFunction extends PDFObject { p.append("/Functions [ "); numberOfFunctions = this.functions.size(); for (tempInt = 0; tempInt < numberOfFunctions; tempInt++) { - p.append(((PDFFunction)this.functions.elementAt(tempInt)).referencePDF() + p.append(((PDFFunction)this.functions.get(tempInt)).referencePDF() + " "); } @@ -567,7 +567,7 @@ public class PDFFunction extends PDFObject { p.append("/Encode [ "); vectorSize = this.encode.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.encode.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.encode.get(tempInt)) + " "); } @@ -589,7 +589,7 @@ public class PDFFunction extends PDFObject { vectorSize = this.bounds.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.bounds.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.bounds.get(tempInt)) + " "); } @@ -624,7 +624,7 @@ public class PDFFunction extends PDFObject { p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.domain.get(tempInt)) + " "); } @@ -638,7 +638,7 @@ public class PDFFunction extends PDFObject { p.append("/Range [ "); vectorSize = this.range.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.range.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.range.get(tempInt)) + " "); } diff --git a/src/org/apache/fop/pdf/PDFPattern.java b/src/org/apache/fop/pdf/PDFPattern.java index 3fa15d59b..a6342525d 100644 --- a/src/org/apache/fop/pdf/PDFPattern.java +++ b/src/org/apache/fop/pdf/PDFPattern.java @@ -8,7 +8,7 @@ package org.apache.fop.pdf; // Java... -import java.util.Vector; +import java.util.ArrayList; // FOP... import org.apache.fop.datatypes.ColorSpace; @@ -53,9 +53,9 @@ public class PDFPattern extends PDFPathPaint { protected int tilingType = 1; /** - * Vector of Doubles representing the Bounding box rectangle + * ArrayList of Doubles representing the Bounding box rectangle */ - protected Vector bBox = null; + protected ArrayList bBox = null; /** * Horizontal spacing @@ -73,9 +73,9 @@ public class PDFPattern extends PDFPathPaint { protected PDFShading shading = null; /** - * Vector of Integers represetning the Extended unique Identifier + * ArrayList of Integers represetning the Extended unique Identifier */ - protected Vector xUID = null; + protected ArrayList xUID = null; /** * String representing the extended Graphics state. @@ -85,9 +85,9 @@ public class PDFPattern extends PDFPathPaint { null; // eventually, need a PDFExtGSState object... but not now. /** - * Vector of Doubles representing the Transformation matrix. + * ArrayList of Doubles representing the Transformation matrix. */ - protected Vector matrix = null; + protected ArrayList matrix = null; /** * The stream of a pattern @@ -104,17 +104,17 @@ public class PDFPattern extends PDFPathPaint { * @param thePatternType the type of pattern, which is 1 for tiling. * @param thePaintType 1 or 2, colored or uncolored. * @param theTilingType 1, 2, or 3, constant spacing, no distortion, or faster tiling - * @param theBBox Vector of Doubles: The pattern cell bounding box + * @param theBBox ArrayList of Doubles: The pattern cell bounding box * @param theXStep horizontal spacing * @param theYStep vertical spacing - * @param theMatrix Optional Vector of Doubles transformation matrix + * @param theMatrix Optional ArrayList of Doubles transformation matrix * @param theXUID Optional vector of Integers that uniquely identify the pattern * @param thePatternDataStream The stream of pattern data to be tiled. */ public PDFPattern(int theNumber, String thePatternName, PDFResources theResources, int thePatternType, // 1 - int thePaintType, int theTilingType, Vector theBBox, double theXStep, - double theYStep, Vector theMatrix, Vector theXUID, + int thePaintType, int theTilingType, ArrayList theBBox, double theXStep, + double theYStep, ArrayList theMatrix, ArrayList theXUID, StringBuffer thePatternDataStream) { super(theNumber); this.patternName = thePatternName; @@ -143,12 +143,12 @@ public class PDFPattern extends PDFPathPaint { * @param theShading the PDF Shading object that comprises this pattern * @param theXUID optional:the extended unique Identifier if used. * @param theExtGState optional: the extended graphics state, if used. - * @param theMatrix Optional:Vector of Doubles that specify the matrix. + * @param theMatrix Optional:ArrayList of Doubles that specify the matrix. */ public PDFPattern(int theNumber, String thePatternName, int thePatternType, PDFShading theShading, - Vector theXUID, StringBuffer theExtGState, - Vector theMatrix) { + ArrayList theXUID, StringBuffer theExtGState, + ArrayList theMatrix) { super(theNumber); this.patternName = thePatternName; @@ -214,7 +214,7 @@ public class PDFPattern extends PDFPathPaint { vectorSize = this.bBox.size(); p.append("/BBox [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.bBox.elementAt(tempInt))); + p.append(PDFNumber.doubleOut((Double)this.bBox.get(tempInt))); p.append(" "); } p.append("] \n"); @@ -228,7 +228,7 @@ public class PDFPattern extends PDFPathPaint { vectorSize = this.matrix.size(); p.append("/Matrix [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.matrix.elementAt(tempInt))); + p.append(PDFNumber.doubleOut((Double)this.matrix.get(tempInt))); p.append(" "); } p.append("] \n"); @@ -238,7 +238,7 @@ public class PDFPattern extends PDFPathPaint { vectorSize = this.xUID.size(); p.append("/XUID [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(((Integer)this.xUID.elementAt(tempInt)) + " "); + p.append(((Integer)this.xUID.get(tempInt)) + " "); } p.append("] \n"); } @@ -258,7 +258,7 @@ public class PDFPattern extends PDFPathPaint { vectorSize = this.xUID.size(); p.append("/XUID [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(((Integer)this.xUID.elementAt(tempInt)) + " "); + p.append(((Integer)this.xUID.get(tempInt)) + " "); } p.append("] \n"); } @@ -272,7 +272,7 @@ public class PDFPattern extends PDFPathPaint { vectorSize = this.matrix.size(); p.append("/Matrix [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.matrix.elementAt(tempInt))); + p.append(PDFNumber.doubleOut((Double)this.matrix.get(tempInt))); p.append(" "); } p.append("] \n"); diff --git a/src/org/apache/fop/pdf/PDFResources.java b/src/org/apache/fop/pdf/PDFResources.java index d51b716e4..0b4a19cae 100644 --- a/src/org/apache/fop/pdf/PDFResources.java +++ b/src/org/apache/fop/pdf/PDFResources.java @@ -9,9 +9,9 @@ package org.apache.fop.pdf; // Java import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.Vector; -import java.util.Hashtable; +import java.util.Iterator; +import java.util.ArrayList; +import java.util.HashMap; /** * class representing a /Resources object. @@ -24,11 +24,11 @@ public class PDFResources extends PDFObject { /** * /Font objects keyed by their internal name */ - protected Hashtable fonts = new Hashtable(); + protected HashMap fonts = new HashMap(); - protected Vector xObjects = null; - protected Vector patterns = new Vector(); - protected Vector shadings = new Vector(); + protected ArrayList xObjects = null; + protected ArrayList patterns = new ArrayList(); + protected ArrayList shadings = new ArrayList(); /** * create a /Resources object. @@ -52,14 +52,14 @@ public class PDFResources extends PDFObject { } public void addShading(PDFShading theShading) { - this.shadings.addElement(theShading); + this.shadings.add(theShading); } public void addPattern(PDFPattern thePattern) { - this.patterns.addElement(thePattern); + this.patterns.add(thePattern); } - public void setXObjects(Vector xObjects) { + public void setXObjects(ArrayList xObjects) { this.xObjects = xObjects; } @@ -75,9 +75,9 @@ public class PDFResources extends PDFObject { p.append("/Font << "); /* construct PDF dictionary of font object references */ - Enumeration fontEnumeration = this.fonts.keys(); - while (fontEnumeration.hasMoreElements()) { - String fontName = (String)fontEnumeration.nextElement(); + Iterator fontIterator = this.fonts.keySet().iterator(); + while (fontIterator.hasNext()) { + String fontName = (String)fontIterator.next(); p.append("/" + fontName + " " + ((PDFFont)this.fonts.get(fontName)).referencePDF() + " "); @@ -94,7 +94,7 @@ public class PDFResources extends PDFObject { currentShadingNumber < this.shadings.size(); currentShadingNumber++) { currentShading = - ((PDFShading)this.shadings.elementAt(currentShadingNumber)); + ((PDFShading)this.shadings.get(currentShadingNumber)); p.append("/" + currentShading.getName() + " " + currentShading.referencePDF() + " "); // \n ?????? @@ -113,7 +113,7 @@ public class PDFResources extends PDFObject { currentPatternNumber < this.patterns.size(); currentPatternNumber++) { currentPattern = - ((PDFPattern)this.patterns.elementAt(currentPatternNumber)); + ((PDFPattern)this.patterns.get(currentPatternNumber)); p.append("/" + currentPattern.getName() + " " + currentPattern.referencePDF() + " "); @@ -130,7 +130,7 @@ public class PDFResources extends PDFObject { p = p.append("/XObject <<"); for (int i = 1; i <= this.xObjects.size(); i++) { p = p.append("/Im" + i + " " - + ((PDFXObject)this.xObjects.elementAt(i - 1)).referencePDF() + + ((PDFXObject)this.xObjects.get(i - 1)).referencePDF() + " \n"); } p = p.append(" >>\n"); diff --git a/src/org/apache/fop/pdf/PDFShading.java b/src/org/apache/fop/pdf/PDFShading.java index a1a1a9be0..3bb284675 100644 --- a/src/org/apache/fop/pdf/PDFShading.java +++ b/src/org/apache/fop/pdf/PDFShading.java @@ -8,7 +8,7 @@ package org.apache.fop.pdf; // Java... -import java.util.Vector; +import java.util.ArrayList; // FOP import org.apache.fop.datatypes.ColorSpace; @@ -46,12 +46,12 @@ public class PDFShading extends PDFObject { * The background color. Since shading is opaque, * this is very rarely used. */ - protected Vector background = null; + protected ArrayList background = null; /** - * Optional: A Vector specifying the clipping rectangle + * Optional: A ArrayList specifying the clipping rectangle */ - protected Vector bBox = null; + protected ArrayList bBox = null; /** * Optional: A flag whether or not to filter the shading function @@ -65,12 +65,12 @@ public class PDFShading extends PDFObject { * Optional for Type 3: An array of two numbers between which the blend varies between start and end points. Default is 0, 1. */ - protected Vector domain = null; + protected ArrayList domain = null; /** * Optional for Type 1: A transformation matrix */ - protected Vector matrix = null; + protected ArrayList matrix = null; /** * Required for Type 1, 2, and 3: @@ -84,14 +84,14 @@ public class PDFShading extends PDFObject { * Required for Type 3: An Array of six numbers [x0,y0,r0,x1,y1,r1] specifying the centers and radii of * the starting and ending circles. */ - protected Vector coords = null; + protected ArrayList coords = null; /** * Required for Type 2+3: An Array of two boolean values specifying whether to extend the * start and end colors past the start and end points, * respectively. Default is false, false. */ - protected Vector extend = null; + protected ArrayList extend = null; /** * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each vertex coordinate. @@ -110,7 +110,7 @@ public class PDFShading extends PDFObject { * Each type has a differing number of decode array members, so check the spec. * Page 303 in PDF Spec 1.3 */ - protected Vector decode = null; + protected ArrayList decode = null; /** * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each color coordinate. @@ -135,13 +135,13 @@ public class PDFShading extends PDFObject { * @param theBackground An array of color components appropriate to the * colorspace key specifying a single color value. * This key is used by the f operator buy ignored by the sh operator. - * @param theBBox Vector of double's representing a rectangle + * @param theBBox ArrayList of double's representing a rectangle * in the coordinate space that is current at the * time of shading is imaged. Temporary clipping * boundary. * @param theAntiAlias Whether or not to anti-alias. * @param theDomain Optional vector of Doubles specifying the domain. - * @param theMatrix Vector of Doubles specifying the matrix. + * @param theMatrix ArrayList of Doubles specifying the matrix. * If it's a pattern, then the matrix maps it to pattern space. * If it's a shading, then it maps it to current user space. * It's optional, the default is the identity matrix @@ -149,9 +149,9 @@ public class PDFShading extends PDFObject { */ public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace, - Vector theBackground, Vector theBBox, - boolean theAntiAlias, Vector theDomain, - Vector theMatrix, PDFFunction theFunction) { + ArrayList theBackground, ArrayList theBBox, + boolean theAntiAlias, ArrayList theDomain, + ArrayList theMatrix, PDFFunction theFunction) { super(theNumber); this.shadingName = theShadingName; this.shadingType = theShadingType; // 1 @@ -177,23 +177,23 @@ public class PDFShading extends PDFObject { * @param theBackground theBackground An array of color components appropriate to the * colorspace key specifying a single color value. * This key is used by the f operator buy ignored by the sh operator. - * @param theBBox Vector of double's representing a rectangle + * @param theBBox ArrayList of double's representing a rectangle * in the coordinate space that is current at the * time of shading is imaged. Temporary clipping * boundary. * @param theAntiAlias Default is false - * @param theCoords Vector of four (type 2) or 6 (type 3) Double - * @param theDomain Vector of Doubles specifying the domain + * @param theCoords ArrayList of four (type 2) or 6 (type 3) Double + * @param theDomain ArrayList of Doubles specifying the domain * @param theFunction the Stitching (PDFfunction type 3) function, even if it's stitching a single function - * @param theExtend Vector of Booleans of whether to extend teh start and end colors past the start and end points + * @param theExtend ArrayList of Booleans of whether to extend teh start and end colors past the start and end points * The default is [false, false] */ public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace, - Vector theBackground, Vector theBBox, - boolean theAntiAlias, Vector theCoords, - Vector theDomain, PDFFunction theFunction, - Vector theExtend) { + ArrayList theBackground, ArrayList theBBox, + boolean theAntiAlias, ArrayList theCoords, + ArrayList theDomain, PDFFunction theFunction, + ArrayList theExtend) { super(theNumber); this.shadingName = theShadingName; this.shadingType = theShadingType; // 2 or 3 @@ -222,7 +222,7 @@ public class PDFShading extends PDFObject { * @param theBackground theBackground An array of color components appropriate to the * colorspace key specifying a single color value. * This key is used by the f operator buy ignored by the sh operator. - * @param theBBox Vector of double's representing a rectangle + * @param theBBox ArrayList of double's representing a rectangle * in the coordinate space that is current at the * time of shading is imaged. Temporary clipping * boundary. @@ -230,15 +230,15 @@ public class PDFShading extends PDFObject { * @param theBitsPerCoordinate 1,2,4,8,12,16,24 or 32. * @param theBitsPerComponent 1,2,4,8,12, and 16 * @param theBitsPerFlag 2,4,8. - * @param theDecode Vector of Doubles see PDF 1.3 spec pages 303 to 312. + * @param theDecode ArrayList of Doubles see PDF 1.3 spec pages 303 to 312. * @param theFunction the PDFFunction */ public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace, - Vector theBackground, Vector theBBox, + ArrayList theBackground, ArrayList theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, int theBitsPerFlag, - Vector theDecode, PDFFunction theFunction) { + ArrayList theDecode, PDFFunction theFunction) { super(theNumber); this.shadingType = theShadingType; // 4,6 or 7 @@ -264,23 +264,23 @@ public class PDFShading extends PDFObject { * @param theBackground theBackground An array of color components appropriate to the * colorspace key specifying a single color value. * This key is used by the f operator buy ignored by the sh operator. - * @param theBBox Vector of double's representing a rectangle + * @param theBBox ArrayList of double's representing a rectangle * in the coordinate space that is current at the * time of shading is imaged. Temporary clipping * boundary. * @param theAntiAlias Default is false * @param theBitsPerCoordinate 1,2,4,8,12,16, 24, or 32 * @param theBitsPerComponent 1,2,4,8,12,24,32 - * @param theDecode Vector of Doubles. See page 305 in PDF 1.3 spec. + * @param theDecode ArrayList of Doubles. See page 305 in PDF 1.3 spec. * @param theVerticesPerRow number of vertices in each "row" of the lattice. * @param theFunction The PDFFunction that's mapped on to this shape * @param theNumber the object number of this PDF object. */ public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace, - Vector theBackground, Vector theBBox, + ArrayList theBackground, ArrayList theBBox, boolean theAntiAlias, int theBitsPerCoordinate, - int theBitsPerComponent, Vector theDecode, + int theBitsPerComponent, ArrayList theDecode, int theVerticesPerRow, PDFFunction theFunction) { super(theNumber); this.shadingName = theShadingName; @@ -328,7 +328,7 @@ public class PDFShading extends PDFObject { p.append("/Background [ "); vectorSize = this.background.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.background.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.background.get(tempInt)) + " "); } p.append("] \n"); @@ -339,7 +339,7 @@ public class PDFShading extends PDFObject { p.append("/BBox [ "); vectorSize = this.bBox.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.bBox.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.bBox.get(tempInt)) + " "); } p.append("] \n"); @@ -355,7 +355,7 @@ public class PDFShading extends PDFObject { p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.domain.get(tempInt)) + " "); } p.append("] \n"); @@ -367,7 +367,7 @@ public class PDFShading extends PDFObject { p.append("/Matrix [ "); vectorSize = this.matrix.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.matrix.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.matrix.get(tempInt)) + " "); } p.append("] \n"); @@ -385,7 +385,7 @@ public class PDFShading extends PDFObject { p.append("/Coords [ "); vectorSize = this.coords.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.coords.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.coords.get(tempInt)) + " "); } p.append("] \n"); @@ -396,7 +396,7 @@ public class PDFShading extends PDFObject { p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt)) + p.append(PDFNumber.doubleOut((Double)this.domain.get(tempInt)) + " "); } p.append("] \n"); @@ -408,7 +408,7 @@ public class PDFShading extends PDFObject { p.append("/Extend [ "); vectorSize = this.extend.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(((Boolean)this.extend.elementAt(tempInt)) + " "); + p.append(((Boolean)this.extend.get(tempInt)) + " "); } p.append("] \n"); @@ -452,7 +452,7 @@ public class PDFShading extends PDFObject { p.append("/Decode [ "); vectorSize = this.decode.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(((Boolean)this.decode.elementAt(tempInt)) + " "); + p.append(((Boolean)this.decode.get(tempInt)) + " "); } p.append("] \n"); @@ -484,7 +484,7 @@ public class PDFShading extends PDFObject { p.append("/Decode [ "); vectorSize = this.decode.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(((Boolean)this.decode.elementAt(tempInt)) + " "); + p.append(((Boolean)this.decode.get(tempInt)) + " "); } p.append("] \n"); diff --git a/src/org/apache/fop/pdf/PDFStream.java b/src/org/apache/fop/pdf/PDFStream.java index 01b87b9d6..ce0f98fd6 100644 --- a/src/org/apache/fop/pdf/PDFStream.java +++ b/src/org/apache/fop/pdf/PDFStream.java @@ -10,7 +10,7 @@ package org.apache.fop.pdf; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.IOException; -import java.util.Vector; +import java.util.ArrayList; import java.util.Enumeration; import org.apache.fop.configuration.Configuration; import org.apache.fop.messaging.MessageHandler; @@ -33,7 +33,7 @@ public class PDFStream extends PDFObject { /** * the filters that should be applied */ - private Vector _filters; + private ArrayList _filters; /** * create an empty stream object @@ -43,7 +43,7 @@ public class PDFStream extends PDFObject { public PDFStream(int number) { super(number); _data = new ByteArrayOutputStream(); - _filters = new Vector(); + _filters = new ArrayList(); } /** @@ -69,7 +69,7 @@ public class PDFStream extends PDFObject { */ public void addFilter(PDFFilter filter) { if (filter != null) { - _filters.addElement(filter); + _filters.add(filter); } } @@ -94,7 +94,7 @@ public class PDFStream extends PDFObject { protected void addDefaultFilters() { - Vector filters = Configuration.getListValue("stream-filter-list", + ArrayList filters = Configuration.getListValue("stream-filter-list", Configuration.PDF); if (filters == null) { // try getting it as a String @@ -108,7 +108,7 @@ public class PDFStream extends PDFObject { } } else { for (int i = 0; i < filters.size(); i++) { - String v = (String)filters.elementAt(i); + String v = (String)filters.get(i); addFilter(v); } } @@ -236,13 +236,12 @@ public class PDFStream extends PDFObject { */ protected String applyFilters() throws IOException { if (_filters.size() > 0) { - Vector names = new Vector(); - Vector parms = new Vector(); + ArrayList names = new ArrayList(); + ArrayList parms = new ArrayList(); // run the filters - Enumeration e = _filters.elements(); - while (e.hasMoreElements()) { - PDFFilter filter = (PDFFilter)e.nextElement(); + for (int count = 0; count < _filters.size(); count++) { + PDFFilter filter = (PDFFilter)_filters.get(count); // apply the filter encoding if neccessary if (!filter.isApplied()) { byte[] tmp = filter.encode(_data.toByteArray()); @@ -251,8 +250,8 @@ public class PDFStream extends PDFObject { filter.setApplied(true); } // place the names in our local vector in reverse order - names.insertElementAt(filter.getName(), 0); - parms.insertElementAt(filter.getDecodeParms(), 0); + names.add(0, filter.getName()); + parms.add(0, filter.getDecodeParms()); } // now build up the filter entries for the dictionary @@ -262,15 +261,14 @@ public class PDFStream extends PDFObject { } - private String buildFilterEntries(Vector names) { + private String buildFilterEntries(ArrayList names) { StringBuffer sb = new StringBuffer(); sb.append("/Filter "); if (names.size() > 1) { sb.append("[ "); } - Enumeration e = names.elements(); - while (e.hasMoreElements()) { - sb.append((String)e.nextElement()); + for (int count = 0; count < names.size(); count++) { + sb.append((String)names.get(count)); sb.append(" "); } if (names.size() > 1) { @@ -280,7 +278,7 @@ public class PDFStream extends PDFObject { return sb.toString(); } - private String buildDecodeParms(Vector parms) { + private String buildDecodeParms(ArrayList parms) { StringBuffer sb = new StringBuffer(); boolean needParmsEntry = false; sb.append("/DecodeParms "); @@ -288,9 +286,8 @@ public class PDFStream extends PDFObject { if (parms.size() > 1) { sb.append("[ "); } - Enumeration e = parms.elements(); - while (e.hasMoreElements()) { - String s = (String)e.nextElement(); + for (int count = 0; count < parms.size(); count++) { + String s = (String)parms.get(count); if (s != null) { sb.append(s); needParmsEntry = true; diff --git a/src/org/apache/fop/pdf/PDFWArray.java b/src/org/apache/fop/pdf/PDFWArray.java index a391f45f3..cef0a0e48 100644 --- a/src/org/apache/fop/pdf/PDFWArray.java +++ b/src/org/apache/fop/pdf/PDFWArray.java @@ -7,7 +7,7 @@ package org.apache.fop.pdf; -import java.util.Vector; +import java.util.ArrayList; /** * class representing a W array for CID fonts. @@ -17,10 +17,10 @@ public class PDFWArray { /** * the metrics */ - private Vector entries; + private ArrayList entries; public PDFWArray() { - entries = new Vector(); + entries = new ArrayList(); } /** @@ -31,7 +31,7 @@ public class PDFWArray { * @param metrics the metrics array. */ public void addEntry(int start, int[] metrics) { - entries.addElement(new Entry(start, metrics)); + entries.add(new Entry(start, metrics)); } /** @@ -42,7 +42,7 @@ public class PDFWArray { * @param width the width for all CIDs in the range */ public void addEntry(int first, int last, int width) { - entries.addElement(new int[] { + entries.add(new int[] { first, last, width }); } @@ -57,7 +57,7 @@ public class PDFWArray { * @param posY the y component for the vertical position vector */ public void addEntry(int first, int last, int width, int posX, int posY) { - entries.addElement(new int[] { + entries.add(new int[] { first, last, width, posX, posY }); } @@ -71,7 +71,7 @@ public class PDFWArray { p.append("[ "); int len = entries.size(); for (int i = 0; i < len; i++) { - Object entry = entries.elementAt(i); + Object entry = entries.get(i); if (entry instanceof int[]) { int[] line = (int[])entry; for (int j = 0; j < line.length; j++) { diff --git a/src/org/apache/fop/render/mif/FontSetup.java b/src/org/apache/fop/render/mif/FontSetup.java index 4691751d9..39c9b32d1 100644 --- a/src/org/apache/fop/render/mif/FontSetup.java +++ b/src/org/apache/fop/render/mif/FontSetup.java @@ -16,8 +16,8 @@ import org.apache.fop.mif.MIFDocument; // import org.apache.fop.pdf.PDFResources; // Java -import java.util.Enumeration; -import java.util.Hashtable; +import java.util.Iterator; +import java.util.HashMap; /** * sets up the PDF fonts. @@ -137,10 +137,10 @@ public class FontSetup { public static void addToFontFormat(MIFDocument mifDoc, FontInfo fontInfo) { - Hashtable fonts = fontInfo.getFonts(); - Enumeration e = fonts.keys(); - while (e.hasMoreElements()) { - String f = (String)e.nextElement(); + HashMap fonts = fontInfo.getFonts(); + Iterator e = fonts.keySet().iterator(); + while (e.hasNext()) { + String f = (String)e.next(); Font font = (Font)fonts.get(f); FontDescriptor desc = null; if (font instanceof FontDescriptor) { diff --git a/src/org/apache/fop/render/pdf/FontReader.java b/src/org/apache/fop/render/pdf/FontReader.java index 132030d92..31cfdb2e9 100644 --- a/src/org/apache/fop/render/pdf/FontReader.java +++ b/src/org/apache/fop/render/pdf/FontReader.java @@ -15,7 +15,7 @@ import org.xml.sax.Locator; import org.xml.sax.Attributes; import java.io.IOException; import java.util.Enumeration; -import java.util.Vector; +import java.util.ArrayList; import java.util.Hashtable; import org.apache.fop.pdf.PDFWArray; import org.apache.fop.pdf.PDFCIDFont; @@ -41,12 +41,12 @@ public class FontReader extends DefaultHandler { // private SingleByteFont singleFont = null; private String text = null; - private Vector cidWidths = null; + private ArrayList cidWidths = null; private int cidWidthIndex = 0; private Hashtable currentKerning = null; - private Vector bfranges = null; + private ArrayList bfranges = null; private void createFont(String path) throws FOPException { XMLReader parser = ConfigurationReader.createParser(); @@ -145,7 +145,7 @@ public class FontReader extends DefaultHandler { } } else if ("cid-widths".equals(localName)) { cidWidthIndex = getInt(attributes.getValue("start-index")); - cidWidths = new Vector(); + cidWidths = new ArrayList(); } else if ("kerning".equals(localName)) { currentKerning = new Hashtable(); if (isCID) @@ -155,15 +155,15 @@ public class FontReader extends DefaultHandler { singleFont.kerning.put(new Integer(attributes.getValue("kpx1")), currentKerning); } else if ("bfranges".equals(localName)) { - bfranges = new Vector(); + bfranges = new ArrayList(); } else if ("bf".equals(localName)) { BFEntry entry = new BFEntry(); entry.unicodeStart = getInt(attributes.getValue("us")); entry.unicodeEnd = getInt(attributes.getValue("ue")); entry.glyphStartIndex = getInt(attributes.getValue("gi")); - bfranges.addElement(entry); + bfranges.add(entry); } else if ("wx".equals(localName)) { - cidWidths.addElement(new Integer(attributes.getValue("w"))); + cidWidths.add(new Integer(attributes.getValue("w"))); } else if ("widths".equals(localName)) { singleFont.width = new int[256]; } else if ("char".equals(localName)) { @@ -268,9 +268,8 @@ public class FontReader extends DefaultHandler { } else if ("cid-widths".equals(localName)) { int[] wds = new int[cidWidths.size()]; int j = 0; - for (Enumeration e = cidWidths.elements(); - e.hasMoreElements(); ) { - Integer i = (Integer)e.nextElement(); + for (int count = 0; count < cidWidths.size(); count++) { + Integer i = (Integer)cidWidths.get(count); wds[j++] = i.intValue(); } @@ -278,9 +277,7 @@ public class FontReader extends DefaultHandler { multiFont.width = wds; } else if ("bfranges".equals(localName)) { - BFEntry[] entries = new BFEntry[bfranges.size()]; - bfranges.copyInto(entries); - multiFont.bfentries = entries; + multiFont.bfentries = (BFEntry[])bfranges.toArray(new BFEntry[0]); } } diff --git a/src/org/apache/fop/render/pdf/FontSetup.java b/src/org/apache/fop/render/pdf/FontSetup.java index 00a415230..33d7ffe7e 100644 --- a/src/org/apache/fop/render/pdf/FontSetup.java +++ b/src/org/apache/fop/render/pdf/FontSetup.java @@ -18,9 +18,9 @@ import org.apache.fop.configuration.Configuration; import org.apache.fop.configuration.FontTriplet; // Java -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; +import java.util.HashMap; +import java.util.Iterator; +import java.util.ArrayList; /** * sets up the PDF fonts. @@ -143,13 +143,13 @@ public class FontSetup { String internalName = null; FontReader reader = null; - Vector fontInfos = Configuration.getFonts(); + ArrayList fontInfos = Configuration.getFonts(); if (fontInfos == null) return; - for (Enumeration e = fontInfos.elements(); e.hasMoreElements(); ) { + for (int count = 0; count < fontInfos.size(); count++) { org.apache.fop.configuration.FontInfo configFontInfo = - (org.apache.fop.configuration.FontInfo)e.nextElement(); + (org.apache.fop.configuration.FontInfo)fontInfos.get(count); try { String metricsFile = configFontInfo.getMetricsFile(); @@ -167,10 +167,9 @@ public class FontSetup { configFontInfo.getKerning()); fontInfo.addMetrics(internalName, font); - Vector triplets = configFontInfo.getFontTriplets(); - for (Enumeration t = triplets.elements(); - t.hasMoreElements(); ) { - FontTriplet triplet = (FontTriplet)t.nextElement(); + ArrayList triplets = configFontInfo.getFontTriplets(); + for (int c = 0; c < triplets.size(); c++) { + FontTriplet triplet = (FontTriplet)triplets.get(c); fontInfo.addFontProperties(internalName, triplet.getName(), @@ -193,11 +192,11 @@ public class FontSetup { * @param fontInfo font info object to get font information from */ public static void addToResources(PDFDocument doc, FontInfo fontInfo) { - Hashtable fonts = fontInfo.getUsedFonts(); - Enumeration e = fonts.keys(); + HashMap fonts = fontInfo.getUsedFonts(); + Iterator e = fonts.keySet().iterator(); PDFResources resources = doc.getResources(); - while (e.hasMoreElements()) { - String f = (String)e.nextElement(); + while (e.hasNext()) { + String f = (String)e.next(); Font font = (Font)fonts.get(f); FontDescriptor desc = null; if (font instanceof FontDescriptor) { diff --git a/src/org/apache/fop/render/ps/PSGraphics2D.java b/src/org/apache/fop/render/ps/PSGraphics2D.java index ab9a976fc..0ab552695 100644 --- a/src/org/apache/fop/render/ps/PSGraphics2D.java +++ b/src/org/apache/fop/render/ps/PSGraphics2D.java @@ -28,7 +28,7 @@ import java.awt.image.renderable.*; import java.io.*; import java.util.Map; -import java.util.Vector; +import java.util.ArrayList; /** * This concrete implementation of AbstractGraphics2D is a @@ -515,40 +515,40 @@ public class PSGraphics2D extends AbstractGraphics2D { Point2D p2 = gp.getPoint2(); boolean cyclic = gp.isCyclic(); - Vector theCoords = new Vector(); - theCoords.addElement(new Double(p1.getX())); - theCoords.addElement(new Double(p1.getY())); - theCoords.addElement(new Double(p2.getX())); - theCoords.addElement(new Double(p2.getY())); + ArrayList theCoords = new ArrayList(); + theCoords.add(new Double(p1.getX())); + theCoords.add(new Double(p1.getY())); + theCoords.add(new Double(p2.getX())); + theCoords.add(new Double(p2.getY())); - Vector theExtend = new Vector(); - theExtend.addElement(new Boolean(true)); - theExtend.addElement(new Boolean(true)); + ArrayList theExtend = new ArrayList(); + theExtend.add(new Boolean(true)); + theExtend.add(new Boolean(true)); - Vector theDomain = new Vector(); - theDomain.addElement(new Double(0)); - theDomain.addElement(new Double(1)); + ArrayList theDomain = new ArrayList(); + theDomain.add(new Double(0)); + theDomain.add(new Double(1)); - Vector theEncode = new Vector(); - theEncode.addElement(new Double(0)); - theEncode.addElement(new Double(1)); - theEncode.addElement(new Double(0)); - theEncode.addElement(new Double(1)); + ArrayList theEncode = new ArrayList(); + theEncode.add(new Double(0)); + theEncode.add(new Double(1)); + theEncode.add(new Double(0)); + theEncode.add(new Double(1)); - Vector theBounds = new Vector(); - theBounds.addElement(new Double(0)); - theBounds.addElement(new Double(1)); + ArrayList theBounds = new ArrayList(); + theBounds.add(new Double(0)); + theBounds.add(new Double(1)); - Vector theFunctions = new Vector(); + ArrayList theFunctions = new ArrayList(); - Vector someColors = new Vector(); + ArrayList someColors = new ArrayList(); PDFColor color1 = new PDFColor(c1.getRed(), c1.getGreen(), c1.getBlue()); - someColors.addElement(color1); + someColors.add(color1); PDFColor color2 = new PDFColor(c2.getRed(), c2.getGreen(), c2.getBlue()); - someColors.addElement(color2); + someColors.add(color2); ColorSpace aColorSpace = new ColorSpace(ColorSpace.DEVICE_RGB); } else if (paint instanceof TexturePaint) {} diff --git a/src/org/apache/fop/render/ps/PSRenderer.java b/src/org/apache/fop/render/ps/PSRenderer.java index 31d2b73fe..08f17b3f9 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -42,9 +42,8 @@ import java.io.*; import java.util.*; import java.io.IOException; import java.io.OutputStream; -import java.util.Enumeration; -import java.util.Vector; -import java.util.Hashtable; +import java.util.Iterator; +import java.util.HashMap; import java.awt.geom.AffineTransform; import java.awt.geom.Dimension2D; import java.awt.Point; @@ -204,18 +203,18 @@ public class PSRenderer extends AbstractRenderer { // write("/gfF1{/Helvetica findfont} bd"); // write("/gfF3{/Helvetica-Bold findfont} bd"); - Hashtable fonts = fontInfo.getFonts(); - Enumeration enum = fonts.keys(); - while (enum.hasMoreElements()) { - String key = (String)enum.nextElement(); + HashMap fonts = fontInfo.getFonts(); + Iterator enum = fonts.keySet().iterator(); + while (enum.hasNext()) { + String key = (String)enum.next(); Font fm = (Font)fonts.get(key); write("/" + key + " /" + fm.fontName() + " def"); } write("end def"); write("%%EndResource"); - enum = fonts.keys(); - while (enum.hasMoreElements()) { - String key = (String)enum.nextElement(); + enum = fonts.keySet().iterator(); + while (enum.hasNext()) { + String key = (String)enum.next(); Font fm = (Font)fonts.get(key); write("/" + fm.fontName() + " findfont"); write("dup length dict begin"); diff --git a/src/org/apache/fop/render/txt/TXTRenderer.java b/src/org/apache/fop/render/txt/TXTRenderer.java index fcc26a743..00a1ef686 100755 --- a/src/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/org/apache/fop/render/txt/TXTRenderer.java @@ -28,9 +28,6 @@ import org.w3c.dom.svg.SVGDocument; // Java import java.io.IOException; import java.io.OutputStream; -import java.util.Enumeration; -import java.util.Vector; -import java.util.Hashtable; /** * Renderer that renders areas to plain text diff --git a/src/org/apache/fop/svg/PDFGraphics2D.java b/src/org/apache/fop/svg/PDFGraphics2D.java index 63493cacc..a48c4e7d6 100644 --- a/src/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/org/apache/fop/svg/PDFGraphics2D.java @@ -31,7 +31,7 @@ import java.awt.image.renderable.*; import java.io.*; import java.util.Map; -import java.util.Vector; +import java.util.ArrayList; import java.util.Hashtable; /** @@ -645,40 +645,40 @@ public class PDFGraphics2D extends AbstractGraphics2D { Point2D p2 = gp.getPoint2(); boolean cyclic = gp.isCyclic(); - Vector theCoords = new Vector(); - theCoords.addElement(new Double(p1.getX())); - theCoords.addElement(new Double(p1.getY())); - theCoords.addElement(new Double(p2.getX())); - theCoords.addElement(new Double(p2.getY())); + ArrayList theCoords = new ArrayList(); + theCoords.add(new Double(p1.getX())); + theCoords.add(new Double(p1.getY())); + theCoords.add(new Double(p2.getX())); + theCoords.add(new Double(p2.getY())); - Vector theExtend = new Vector(); - theExtend.addElement(new Boolean(true)); - theExtend.addElement(new Boolean(true)); + ArrayList theExtend = new ArrayList(); + theExtend.add(new Boolean(true)); + theExtend.add(new Boolean(true)); - Vector theDomain = new Vector(); - theDomain.addElement(new Double(0)); - theDomain.addElement(new Double(1)); + ArrayList theDomain = new ArrayList(); + theDomain.add(new Double(0)); + theDomain.add(new Double(1)); - Vector theEncode = new Vector(); - theEncode.addElement(new Double(0)); - theEncode.addElement(new Double(1)); - theEncode.addElement(new Double(0)); - theEncode.addElement(new Double(1)); + ArrayList theEncode = new ArrayList(); + theEncode.add(new Double(0)); + theEncode.add(new Double(1)); + theEncode.add(new Double(0)); + theEncode.add(new Double(1)); - Vector theBounds = new Vector(); - theBounds.addElement(new Double(0)); - theBounds.addElement(new Double(1)); + ArrayList theBounds = new ArrayList(); + theBounds.add(new Double(0)); + theBounds.add(new Double(1)); - Vector theFunctions = new Vector(); + ArrayList theFunctions = new ArrayList(); - Vector someColors = new Vector(); + ArrayList someColors = new ArrayList(); PDFColor color1 = new PDFColor(c1.getRed(), c1.getGreen(), c1.getBlue()); - someColors.addElement(color1); + someColors.add(color1); PDFColor color2 = new PDFColor(c2.getRed(), c2.getGreen(), c2.getBlue()); - someColors.addElement(color2); + someColors.add(color2); PDFFunction myfunc = this.pdfDoc.makeFunction(2, theDomain, null, color1.getVector(), color2.getVector(), 1.0); diff --git a/src/org/apache/fop/svg/SVGUserAgent.java b/src/org/apache/fop/svg/SVGUserAgent.java index 93147bf45..7766a1ea4 100644 --- a/src/org/apache/fop/svg/SVGUserAgent.java +++ b/src/org/apache/fop/svg/SVGUserAgent.java @@ -25,9 +25,6 @@ import org.w3c.dom.svg.SVGLength; // Java import java.io.IOException; import java.io.OutputStream; -import java.util.Enumeration; -import java.util.Vector; -import java.util.Hashtable; import java.awt.geom.AffineTransform; import java.awt.geom.Dimension2D; import java.awt.Point; diff --git a/src/org/apache/fop/tools/anttasks/Compare.java b/src/org/apache/fop/tools/anttasks/Compare.java index 20e401ea8..78908b04f 100644 --- a/src/org/apache/fop/tools/anttasks/Compare.java +++ b/src/org/apache/fop/tools/anttasks/Compare.java @@ -48,12 +48,12 @@ public class Compare { public void setFilenames(String filenames) { StringTokenizer tokens = new StringTokenizer(filenames, ","); - Vector filenameListTmp = new Vector(20); + ArrayList filenameListTmp = new ArrayList(20); while (tokens.hasMoreTokens()) { - filenameListTmp.addElement(tokens.nextToken()); + filenameListTmp.add(tokens.nextToken()); } filenameList = new String[filenameListTmp.size()]; - filenameListTmp.copyInto((String[])filenameList); + filenameList = (String[])filenameListTmp.toArray(new String[0]); } private boolean compareBytes(File oldFile, File newFile) { diff --git a/src/org/apache/fop/tools/anttasks/CompileXMLFiles.java b/src/org/apache/fop/tools/anttasks/CompileXMLFiles.java index 15568d03f..7342c2883 100644 --- a/src/org/apache/fop/tools/anttasks/CompileXMLFiles.java +++ b/src/org/apache/fop/tools/anttasks/CompileXMLFiles.java @@ -39,7 +39,7 @@ public class CompileXMLFiles extends Task private String configFile, outFile; private String[] filenameList; private String filenames; - private Vector files = new Vector(); + private ArrayList files = new ArrayList(); // sets name of configuration file, which must // be an xml file conforming to the book.dtd used by xml-site @@ -110,15 +110,14 @@ public class CompileXMLFiles extends Task public void endDocument() throws SAXException { String line, filename; BufferedReader in; - Enumeration iterator = files.elements(); try { BufferedWriter out = new BufferedWriter(new FileWriter("compileXMLFiles-tmp.xml")); out.write("\n" + "\n" + "]>\n"); - while (iterator.hasMoreElements()) { - filename = (String)iterator.nextElement(); + for(int count = 0; count < files.size(); count++) { + filename = (String)files.get(count); in = new BufferedReader(new FileReader(filename)); while ((line = in.readLine()) != null) { // kill the lines pointing to the sbk protocol and the xml declaration @@ -143,7 +142,7 @@ public class CompileXMLFiles extends Task String id, label, source; if (name.equals("document") || name.equals("entry")) { source = atts.getValue("source"); - files.addElement(source); + files.add(source); } } diff --git a/src/org/apache/fop/tools/anttasks/Fop.java b/src/org/apache/fop/tools/anttasks/Fop.java index 525d34d8e..4e9753211 100644 --- a/src/org/apache/fop/tools/anttasks/Fop.java +++ b/src/org/apache/fop/tools/anttasks/Fop.java @@ -50,7 +50,7 @@ import org.apache.fop.configuration.Configuration; */ public class Fop extends Task { File foFile; - Vector filesets = new Vector(); + ArrayList filesets = new ArrayList(); File outFile; File outDir; String format; //MIME type @@ -85,7 +85,7 @@ public class Fop extends Task { * Adds a set of fo files (nested fileset attribute). */ public void addFileset(FileSet set) { - filesets.addElement(set); + filesets.add(set); } /** @@ -315,7 +315,7 @@ class FOPTaskStarter extends Starter { // deal with the filesets for (int i = 0; i < task.filesets.size(); i++) { - FileSet fs = (FileSet) task.filesets.elementAt(i); + FileSet fs = (FileSet) task.filesets.get(i); DirectoryScanner ds = fs.getDirectoryScanner(task.getProject()); String[] files = ds.getIncludedFiles(); diff --git a/src/org/apache/fop/viewer/PreviewDialog.java b/src/org/apache/fop/viewer/PreviewDialog.java index 4bf40fbe5..a421777c6 100644 --- a/src/org/apache/fop/viewer/PreviewDialog.java +++ b/src/org/apache/fop/viewer/PreviewDialog.java @@ -26,7 +26,7 @@ import java.awt.print.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.util.StringTokenizer; -import java.util.Vector; +import java.util.ArrayList; import javax.swing.*; @@ -592,7 +592,7 @@ public class PreviewDialog extends JFrame implements ProgressListener, showIt = new showProgress(error, true); } else { StringTokenizer tok = new StringTokenizer(error, " "); - Vector labels = new Vector(); + ArrayList labels = new ArrayList(); StringBuffer buffer = new StringBuffer(); String tmp, list[]; @@ -609,7 +609,7 @@ public class PreviewDialog extends JFrame implements ProgressListener, labels.add(buffer.toString()); list = new String[labels.size()]; for (int i = 0; i < labels.size(); i++) { - list[i] = labels.elementAt(i).toString(); + list[i] = labels.get(i).toString(); } showIt = new showProgress(list, true); }