From 1dc853b7c8fe7ab0bbddc669837659cf10f84a7e Mon Sep 17 00:00:00 2001 From: Joerg Pietschmann Date: Fri, 2 Aug 2002 20:28:59 +0000 Subject: [PATCH] Replaced Java 1.0 containers by Java 1.2 containers. Generally use index instead of enumerato to iterate over ArrayLists. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@195054 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/apps/CommandLineOptions.java | 13 +- src/org/apache/fop/apps/Driver.java | 25 +- src/org/apache/fop/apps/PrintStarter.java | 15 +- src/org/apache/fop/apps/StreamRenderer.java | 51 ++-- .../fop/configuration/Configuration.java | 99 ++++--- .../configuration/ConfigurationParser.java | 44 +-- .../apache/fop/configuration/FontInfo.java | 8 +- .../apache/fop/datatypes/IDReferences.java | 39 ++- .../datatypes/LinearCombinationLength.java | 18 +- src/org/apache/fop/datatypes/MixedLength.java | 35 +-- .../extensions/ExtensionElementMapping.java | 1 - src/org/apache/fop/extensions/Outline.java | 6 +- src/org/apache/fop/fo/FONode.java | 43 ++- src/org/apache/fop/fo/FOTreeBuilder.java | 7 +- src/org/apache/fop/fo/FObj.java | 15 +- src/org/apache/fop/fo/FObjMixed.java | 2 +- .../apache/fop/fo/GenericShorthandParser.java | 22 +- src/org/apache/fop/fo/ListProperty.java | 12 +- .../apache/fop/fo/MarginShorthandParser.java | 15 +- src/org/apache/fop/fo/Property.java | 4 +- src/org/apache/fop/fo/PropertyList.java | 7 +- .../apache/fop/fo/StandardElementMapping.java | 1 - src/org/apache/fop/fo/XMLObj.java | 9 +- src/org/apache/fop/fo/expr/Numeric.java | 8 +- .../apache/fop/fo/expr/PropertyParser.java | 6 +- src/org/apache/fop/fo/flow/AbstractFlow.java | 16 +- .../apache/fop/fo/flow/AbstractTableBody.java | 22 +- src/org/apache/fop/fo/flow/BasicLink.java | 3 +- src/org/apache/fop/fo/flow/Block.java | 2 +- .../apache/fop/fo/flow/BlockContainer.java | 8 +- .../apache/fop/fo/flow/ExternalGraphic.java | 2 - src/org/apache/fop/fo/flow/Footnote.java | 11 +- src/org/apache/fop/fo/flow/FootnoteBody.java | 5 +- src/org/apache/fop/fo/flow/Inline.java | 3 - .../fop/fo/flow/InstreamForeignObject.java | 5 +- src/org/apache/fop/fo/flow/ListBlock.java | 7 +- src/org/apache/fop/fo/flow/ListItem.java | 7 +- src/org/apache/fop/fo/flow/ListItemBody.java | 5 +- src/org/apache/fop/fo/flow/ListItemLabel.java | 5 +- src/org/apache/fop/fo/flow/Marker.java | 2 +- src/org/apache/fop/fo/flow/PageNumber.java | 3 - .../apache/fop/fo/flow/RetrieveMarker.java | 20 +- src/org/apache/fop/fo/flow/RowSpanMgr.java | 1 - src/org/apache/fop/fo/flow/StaticContent.java | 2 +- src/org/apache/fop/fo/flow/Table.java | 57 ++-- src/org/apache/fop/fo/flow/TableBody.java | 5 - src/org/apache/fop/fo/flow/TableCell.java | 2 +- src/org/apache/fop/fo/flow/TableFooter.java | 4 - src/org/apache/fop/fo/flow/TableHeader.java | 5 - src/org/apache/fop/fo/flow/TableRow.java | 60 +--- .../fop/fo/pagination/LayoutMasterSet.java | 49 ++-- .../fop/fo/pagination/PageSequence.java | 10 +- .../fop/fo/pagination/PageSequenceMaster.java | 29 +- .../RepeatablePageMasterAlternatives.java | 11 +- src/org/apache/fop/fo/pagination/Root.java | 4 - .../fop/fo/pagination/SimplePageMaster.java | 15 +- src/org/apache/fop/fonts/PFMFile.java | 18 +- src/org/apache/fop/fonts/TTFFile.java | 132 +++++---- src/org/apache/fop/fonts/TTFMtxEntry.java | 6 +- src/org/apache/fop/fonts/TTFSubSetFile.java | 72 +++-- src/org/apache/fop/fonts/apps/PFMReader.java | 29 +- src/org/apache/fop/fonts/apps/TTFReader.java | 44 +-- .../apache/fop/image/AbstractFopImage.java | 7 +- .../apache/fop/image/FopImageConsumer.java | 8 +- src/org/apache/fop/image/FopImageFactory.java | 20 +- src/org/apache/fop/image/ImageArea.java | 3 - .../image/analyser/ImageReaderFactory.java | 26 +- src/org/apache/fop/layout/Area.java | 34 +-- src/org/apache/fop/layout/AreaContainer.java | 3 - src/org/apache/fop/layout/AreaTree.java | 14 +- src/org/apache/fop/layout/BlockArea.java | 16 +- .../apache/fop/layout/BodyAreaContainer.java | 44 ++- src/org/apache/fop/layout/ColumnArea.java | 4 - src/org/apache/fop/layout/FontDescriptor.java | 2 +- src/org/apache/fop/layout/FontInfo.java | 21 +- src/org/apache/fop/layout/FontState.java | 14 +- src/org/apache/fop/layout/LineArea.java | 177 ++++++------ src/org/apache/fop/layout/LinkSet.java | 42 +-- src/org/apache/fop/layout/Page.java | 44 ++- src/org/apache/fop/layout/SpanArea.java | 20 +- .../fop/layout/hyphenation/Hyphenation.java | 2 - .../layout/hyphenation/HyphenationTree.java | 16 +- .../fop/layout/hyphenation/Hyphenator.java | 4 +- .../layout/hyphenation/PatternConsumer.java | 6 +- .../fop/layout/hyphenation/PatternParser.java | 44 +-- .../fop/layout/inline/ForeignObjectArea.java | 4 - .../apache/fop/layout/inline/LeaderArea.java | 3 - .../apache/fop/messaging/MessageHandler.java | 2 +- src/org/apache/fop/mif/MIFDocument.java | 249 ++++++----------- src/org/apache/fop/pdf/PDFAnnotList.java | 8 +- src/org/apache/fop/pdf/PDFCharProcs.java | 6 +- src/org/apache/fop/pdf/PDFColor.java | 22 +- src/org/apache/fop/pdf/PDFDocument.java | 260 +++++++++--------- src/org/apache/fop/pdf/PDFEncoding.java | 22 +- src/org/apache/fop/pdf/PDFFunction.java | 124 ++++----- src/org/apache/fop/pdf/PDFOutline.java | 10 +- src/org/apache/fop/pdf/PDFPages.java | 13 +- src/org/apache/fop/pdf/PDFPattern.java | 46 ++-- src/org/apache/fop/pdf/PDFResources.java | 32 +-- src/org/apache/fop/pdf/PDFShading.java | 80 +++--- src/org/apache/fop/pdf/PDFStream.java | 49 ++-- src/org/apache/fop/pdf/PDFWArray.java | 14 +- .../apache/fop/render/AbstractRenderer.java | 43 ++- src/org/apache/fop/render/PrintRenderer.java | 1 - .../apache/fop/render/awt/AWTFontMetrics.java | 11 +- .../apache/fop/render/awt/AWTRenderer.java | 43 ++- .../fop/render/awt/FontMetricsMapper.java | 2 - src/org/apache/fop/render/awt/FontSetup.java | 17 +- src/org/apache/fop/render/mif/FontSetup.java | 12 +- .../apache/fop/render/mif/MIFRenderer.java | 3 - .../apache/fop/render/pcl/PCLRenderer.java | 1 - src/org/apache/fop/render/pdf/FontReader.java | 30 +- src/org/apache/fop/render/pdf/FontSetup.java | 27 +- .../apache/fop/render/pdf/PDFRenderer.java | 43 ++- .../apache/fop/render/pdf/fonts/LazyFont.java | 4 +- .../fop/render/pdf/fonts/MultiByteFont.java | 25 +- .../fop/render/pdf/fonts/SingleByteFont.java | 19 +- .../apache/fop/render/ps/PSGraphics2D.java | 48 ++-- src/org/apache/fop/render/ps/PSRenderer.java | 26 +- .../apache/fop/render/svg/SVGRenderer.java | 6 +- .../apache/fop/render/txt/TXTRenderer.java | 24 +- .../apache/fop/render/xml/XMLRenderer.java | 51 ++-- src/org/apache/fop/svg/PDFGraphics2D.java | 74 +++-- src/org/apache/fop/svg/SVGElementMapping.java | 5 +- src/org/apache/fop/svg/SVGUserAgent.java | 3 - .../apache/fop/tools/anttasks/Compare.java | 14 +- src/org/apache/fop/tools/anttasks/Fop.java | 6 +- .../apache/fop/tools/anttasks/RunTest.java | 13 +- .../apache/fop/tools/xslt/TraxTransform.java | 4 +- .../apache/fop/viewer/LoadableProperties.java | 3 +- src/org/apache/fop/viewer/PreviewDialog.java | 2 +- 131 files changed, 1466 insertions(+), 1795 deletions(-) diff --git a/src/org/apache/fop/apps/CommandLineOptions.java b/src/org/apache/fop/apps/CommandLineOptions.java index ddf435f99..8517b1211 100644 --- a/src/org/apache/fop/apps/CommandLineOptions.java +++ b/src/org/apache/fop/apps/CommandLineOptions.java @@ -7,22 +7,19 @@ package org.apache.fop.apps; -// java -import java.util.Vector; -import java.io.File; -import java.io.FileNotFoundException; - // FOP -import org.apache.fop.configuration.Configuration; + import org.apache.fop.apps.FOPException; +import org.apache.fop.configuration.Configuration; import org.apache.fop.messaging.MessageHandler; import org.apache.fop.render.txt.TXTRenderer; - // Avalon import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.avalon.framework.logger.Logger; -import java.io.*; +// java +import java.io.File; +import java.io.FileNotFoundException; /** * Options parses the commandline arguments diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java index 30cd40879..0030da717 100644 --- a/src/org/apache/fop/apps/Driver.java +++ b/src/org/apache/fop/apps/Driver.java @@ -8,16 +8,15 @@ package org.apache.fop.apps; // FOP -import org.apache.fop.fo.FOTreeBuilder; +import org.apache.fop.configuration.Configuration; +import org.apache.fop.configuration.ConfigurationReader; import org.apache.fop.fo.ElementMapping; +import org.apache.fop.fo.FOTreeBuilder; import org.apache.fop.render.Renderer; -import org.apache.fop.configuration.ConfigurationReader; -import org.apache.fop.configuration.Configuration; +import org.apache.fop.render.pdf.PDFRenderer; import org.apache.fop.tools.DocumentInputSource; import org.apache.fop.tools.DocumentReader; -import org.apache.fop.render.pdf.PDFRenderer; - // Avalon import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.avalon.framework.logger.Logger; @@ -28,12 +27,18 @@ import org.w3c.dom.Document; // SAX import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; // Java -import java.io.*; -import java.util.*; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.InputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Vector; /** * Primary class that drives overall FOP process. @@ -526,7 +531,7 @@ public class Driver { */ class Service { - static Hashtable providerMap = new Hashtable(); + static HashMap providerMap = new HashMap(); public static synchronized Enumeration providers(Class cls) { ClassLoader cl = cls.getClassLoader(); @@ -554,7 +559,7 @@ class Service { // System.out.println("URL: " + u); InputStream is = u.openStream(); - Reader r = new InputStreamReader(is, "UTF-8"); + InputStreamReader r = new InputStreamReader(is, "UTF-8"); BufferedReader br = new BufferedReader(r); String line = br.readLine(); diff --git a/src/org/apache/fop/apps/PrintStarter.java b/src/org/apache/fop/apps/PrintStarter.java index 96408e5d1..6f8820e66 100644 --- a/src/org/apache/fop/apps/PrintStarter.java +++ b/src/org/apache/fop/apps/PrintStarter.java @@ -28,7 +28,7 @@ import java.awt.Graphics; import java.awt.print.*; import java.io.OutputStream; import java.io.IOException; -import java.util.Vector; +import java.util.ArrayList; import org.apache.fop.render.awt.AWTRenderer; import org.apache.fop.layout.AreaTree; @@ -132,8 +132,6 @@ public class PrintStarter extends CommandLineStarter { } - - public void stopRenderer(OutputStream outputStream) throws IOException { super.stopRenderer(outputStream); @@ -141,9 +139,9 @@ public class PrintStarter extends CommandLineStarter { if(endNumber == -1) endNumber = getPageCount(); - Vector numbers = getInvalidPageNumbers(); + ArrayList numbers = getInvalidPageNumbers(); for (int i = numbers.size() - 1; i > -1; i--) - removePage(Integer.parseInt((String)numbers.elementAt(i))); + removePage(Integer.parseInt((String)numbers.get(i))); try { printerJob.print(); @@ -162,9 +160,8 @@ public class PrintStarter extends CommandLineStarter { } - private Vector getInvalidPageNumbers() { - - Vector vec = new Vector(); + private ArrayList getInvalidPageNumbers() { + ArrayList vec = new ArrayList(); int max = getPageCount(); boolean isValid; for (int i = 0; i < max; i++) { @@ -188,7 +185,7 @@ public class PrintStarter extends CommandLineStarter { /* TODO: I'm totally not sure that this is necessary -Mark void setCopies(int val) { copies = val; - Vector copie = tree.getPages(); + ArrayList copie = tree.getPages(); for (int i = 1; i < copies; i++) { tree.getPages().addAll(copie); } diff --git a/src/org/apache/fop/apps/StreamRenderer.java b/src/org/apache/fop/apps/StreamRenderer.java index d56bb932a..64b71e000 100644 --- a/src/org/apache/fop/apps/StreamRenderer.java +++ b/src/org/apache/fop/apps/StreamRenderer.java @@ -8,8 +8,8 @@ package org.apache.fop.apps; import java.io.OutputStream; import java.io.IOException; -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; +import java.util.Iterator; import org.xml.sax.SAXException; @@ -84,7 +84,7 @@ public class StreamRenderer { /** The list of pages waiting to be renderered. */ - private Vector renderQueue = new Vector(); + private ArrayList renderQueue = new ArrayList(); /** The current set of IDReferences, passed to the @@ -96,7 +96,7 @@ public class StreamRenderer { /** * The list of extensions. */ - private Vector extensions = new Vector(); + private ArrayList extensions = new ArrayList(); private Logger log; @@ -118,7 +118,7 @@ public class StreamRenderer { } public void addExtension(ExtensionObj ext) { - extensions.addElement(ext); + extensions.add(ext); } public void startRenderer() @@ -197,8 +197,8 @@ public class StreamRenderer { AreaTree a = new AreaTree(this); a.setFontInfo(fontInfo); - for(Enumeration e = extensions.elements(); e.hasMoreElements(); ) { - ExtensionObj ext = (ExtensionObj)e.nextElement(); + for(int i = 0; i < extensions.size(); i++ ) { + ExtensionObj ext = (ExtensionObj)extensions.get(i); try { ext.format(a); } catch (FOPException fope) { @@ -234,7 +234,7 @@ public class StreamRenderer { private synchronized void addToRenderQueue(Page page) throws FOPException, IOException { RenderQueueEntry entry = new RenderQueueEntry(page); - renderQueue.addElement(entry); + renderQueue.add(entry); /* The just-added entry could (possibly) resolve the @@ -252,20 +252,12 @@ public class StreamRenderer { private synchronized void processQueue(boolean force) throws FOPException, IOException { while (renderQueue.size() > 0) { - RenderQueueEntry entry = (RenderQueueEntry) renderQueue.elementAt(0); + RenderQueueEntry entry = (RenderQueueEntry) renderQueue.get(0); if ((!force) && (!entry.isResolved())) break; renderer.render(entry.getPage(), outputStream); - - /* TODO - Enumeration rootEnumeration = - entry.getAreaTree().getExtensions().elements(); - while (rootEnumeration.hasMoreElements()) - renderTree.addExtension((ExtensionObj) rootEnumeration.nextElement()); - */ - - renderQueue.removeElementAt(0); + renderQueue.remove(0); } } @@ -283,14 +275,14 @@ public class StreamRenderer { /* A list of ID references (names). */ - private Vector unresolvedIdReferences = new Vector(); + private ArrayList unresolvedIdReferences = new ArrayList(); public RenderQueueEntry(Page page) { this.page = page; - Enumeration e = idReferences.getInvalidElements(); - while (e.hasMoreElements()) - unresolvedIdReferences.addElement(e.nextElement()); + Iterator e = idReferences.getInvalidElements(); + while (e.hasNext()) + unresolvedIdReferences.add(e.next()); } public Page getPage() { @@ -308,12 +300,11 @@ public class StreamRenderer { // // See if any of the unresolved references are still unresolved. // - Enumeration e = unresolvedIdReferences.elements(); - while (e.hasMoreElements()) - if (!idReferences.doesIDExist((String) e.nextElement())) + for (int i = 0; i< unresolvedIdReferences.size(); i++) + if (!idReferences.doesIDExist((String)unresolvedIdReferences.get(i))) return false; - unresolvedIdReferences.removeAllElements(); + unresolvedIdReferences.clear(); return true; } } @@ -329,7 +320,7 @@ public class StreamRenderer { // pageIndex = renderQueue.indexOf(current); // if ((pageIndex + 1) < renderQueue.size()) { // nextPage = ((RenderQueueEntry)renderQueue -// .elementAt(pageIndex + 1)).getPage(); +// .get(pageIndex + 1)).getPage(); // if (isWithinPageSequence // &&!nextPage.getPageSequence().equals(current.getPageSequence())) { // nextPage = null; @@ -344,7 +335,7 @@ public class StreamRenderer { int pageIndex = renderQueue.size(); if (pageIndex > 0) { Page previousPage = ((RenderQueueEntry)renderQueue - .elementAt(pageIndex - 1)).getPage(); + .get(pageIndex - 1)).getPage(); PageSequence currentPS = current.getPageSequence(); PageSequence previousPS = previousPage.getPageSequence(); if (!isWithinPageSequence || previousPS.equals(currentPS)) { @@ -354,10 +345,10 @@ public class StreamRenderer { } else { for (int pageIndex=renderQueue.size()-1;pageIndex>0;pageIndex--) { Page page = ((RenderQueueEntry)renderQueue - .elementAt(pageIndex)).getPage(); + .get(pageIndex)).getPage(); if (current.equals(page)) { Page previousPage = ((RenderQueueEntry)renderQueue - .elementAt(pageIndex - 1)).getPage(); + .get(pageIndex - 1)).getPage(); PageSequence currentPS = current.getPageSequence(); PageSequence previousPS = previousPage.getPageSequence(); if (!isWithinPageSequence || previousPS.equals(currentPS)) { diff --git a/src/org/apache/fop/configuration/Configuration.java b/src/org/apache/fop/configuration/Configuration.java index ad9deedae..40b85bd22 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; } @@ -138,13 +137,13 @@ 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; } @@ -153,16 +152,16 @@ public class Configuration { ; /** - * convenience methods to access map/hashtable values in the configuration + * convenience methods to access map/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; } @@ -221,22 +220,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 map/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 +243,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 +255,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 +272,11 @@ public class Configuration { } /** - * adds information to the configuration map/hashtable in key,value form + * adds information to the configuration map/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 +300,11 @@ public class Configuration { ; /** - * adds information to the standard configuration map/hashtable in key,value form + * adds information to the standard configuration map/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 +317,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 j = 0; j < list.size(); j++) { + MessageHandler.log(list.get(j) + " - "); } MessageHandler.logln(""); - } else if (value instanceof Hashtable) { - map = (Hashtable)value; - enum = map.keys(); + } else if (value instanceof HashMap) { + map = (HashMap)value; MessageHandler.log(" values: "); - while (enum.hasMoreElements()) { - tmp = (String)enum.nextElement(); + Iterator it2 = map.keySet().iterator(); + while (it2.hasNext()) { + tmp = (String)it2.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..afee679bc 100644 --- a/src/org/apache/fop/configuration/ConfigurationParser.java +++ b/src/org/apache/fop/configuration/ConfigurationParser.java @@ -14,8 +14,8 @@ 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; @@ -45,12 +45,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 +59,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); + // stores HashMap value + private HashMap map = new HashMap(15); /** * locator for line number information @@ -75,7 +75,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 +86,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 +125,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 +136,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 +168,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 +180,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 +201,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 +230,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: @@ -241,14 +241,14 @@ public class ConfigurationParser extends DefaultHandler { } // end characters /** - * stores configuration entry into configuration hashtable according to the role + * stores configuration entry into configuration HashMap according to the role * * @param role a string containing the role / target for this configuration information * @param key a string containing the key value for the configuration * @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 95e70f417..97cc17163 100644 --- a/src/org/apache/fop/configuration/FontInfo.java +++ b/src/org/apache/fop/configuration/FontInfo.java @@ -12,7 +12,7 @@ package org.apache.fop.configuration; import java.io.File; import java.net.URL; import java.net.MalformedURLException; -import java.util.Vector; +import java.util.ArrayList; // Fop import org.apache.fop.apps.FOPException; @@ -25,11 +25,11 @@ public class FontInfo { private String metricsFile, embedFile, name; private boolean kerning; - private Vector fontTriplets; + private ArrayList fontTriplets; private String baseDir; 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; @@ -75,7 +75,7 @@ public class FontInfo { return kerning; } - public Vector getFontTriplets() { + public ArrayList getFontTriplets() { return fontTriplets; } diff --git a/src/org/apache/fop/datatypes/IDReferences.java b/src/org/apache/fop/datatypes/IDReferences.java index 3701c6662..d3db78c78 100644 --- a/src/org/apache/fop/datatypes/IDReferences.java +++ b/src/org/apache/fop/datatypes/IDReferences.java @@ -8,16 +8,13 @@ package org.apache.fop.datatypes; import org.apache.fop.pdf.PDFGoTo; +import org.apache.fop.layout.Area; import org.apache.fop.layout.AreaContainer; - +import org.apache.fop.apps.FOPException; // Java -import java.util.Hashtable; -import java.util.Vector; -import java.util.Enumeration; -import java.util.NoSuchElementException; -import org.apache.fop.layout.Area; -import org.apache.fop.apps.FOPException; +import java.util.HashMap; +import java.util.Iterator; /** IDReferences contains a map of IDs and the objects to which @@ -25,7 +22,7 @@ import org.apache.fop.apps.FOPException; have yet to be encountered. Modified by Mark Lillywhite mark-fop@inomial.com. Added - getInvalidElements() so that StreamRenderer cna tell what + getInvalidElements() so that StreamRenderer can tell what hasn't been determined yet. Modified by lmckenzi@ca.ibm.com @@ -35,7 +32,7 @@ import org.apache.fop.apps.FOPException; */ public class IDReferences { - private Hashtable idReferences, idValidation, idUnvalidated; + private HashMap idReferences, idValidation, idUnvalidated; final static int ID_PADDING = 5000; // space to add before id y position @@ -43,9 +40,9 @@ public class IDReferences { * Constructor for IDReferences */ public IDReferences() { - idReferences = new Hashtable(); - idValidation = new Hashtable(); - idUnvalidated = new Hashtable(); + idReferences = new HashMap(); + idValidation = new HashMap(); + idUnvalidated = new HashMap(); } @@ -142,7 +139,7 @@ public class IDReferences { * @param area The area where the id was encountered */ public void configureID(String id, Area area) { - if (id != null &&!id.equals("")) { + if (id != null && !id.equals("")) { setPosition(id, area.getPage().getBody().getXPosition() + area.getTableCellXOffset() - ID_PADDING, @@ -154,10 +151,10 @@ public class IDReferences { } /** - * Adds id to validation list to be validated . This should be used if it is unsure whether the id is valid + * Adds id to validation list to be validated. This should be + * used if it is unsure whether the id is valid. * - * @param id id to be added - */ + * @param id id to be added */ public void addToIdValidationList(String id) { idValidation.put(id, ""); } @@ -203,9 +200,9 @@ public class IDReferences { */ public String getInvalidIds() { StringBuffer list = new StringBuffer(); - Enumeration enum = idValidation.keys(); - while (enum.hasMoreElements()) { - list.append("\n\"").append(enum.nextElement().toString()).append("\" "); + Iterator iterator = idValidation.keySet().iterator(); + while (iterator.hasNext()) { + list.append("\n\"").append(iterator.next().toString()).append("\" "); } return list.toString(); } @@ -345,7 +342,7 @@ public class IDReferences { node.setPosition(x, y); } - public Enumeration getInvalidElements() { - return idValidation.keys(); + public Iterator getInvalidElements() { + return idValidation.keySet().iterator(); } } diff --git a/src/org/apache/fop/datatypes/LinearCombinationLength.java b/src/org/apache/fop/datatypes/LinearCombinationLength.java index 88af67190..da474bb95 100644 --- a/src/org/apache/fop/datatypes/LinearCombinationLength.java +++ b/src/org/apache/fop/datatypes/LinearCombinationLength.java @@ -7,21 +7,21 @@ package org.apache.fop.datatypes; -import java.util.Vector; +import java.util.ArrayList; public class LinearCombinationLength extends Length { - protected Vector factors; - protected Vector lengths; + protected ArrayList factors; + protected ArrayList lengths; public LinearCombinationLength() { - factors = new Vector(); - lengths = new Vector(); + factors = new ArrayList(); + lengths = new ArrayList(); } public void addTerm(double factor, Length length) { - factors.addElement(new Double(factor)); - lengths.addElement(length); + factors.add(new Double(factor)); + lengths.add(length); } /** @@ -32,8 +32,8 @@ public class LinearCombinationLength extends Length { int numFactors = factors.size(); for (int i = 0; i < numFactors; ++i) { result += - (int)(((Double)factors.elementAt(i)).doubleValue() - * (double)((Length)lengths.elementAt(i)).mvalue()); + (int)(((Double)factors.get(i)).doubleValue() + * (double)((Length)lengths.get(i)).mvalue()); } setComputedValue(result); } diff --git a/src/org/apache/fop/datatypes/MixedLength.java b/src/org/apache/fop/datatypes/MixedLength.java index 0667d1597..e09bd8023 100644 --- a/src/org/apache/fop/datatypes/MixedLength.java +++ b/src/org/apache/fop/datatypes/MixedLength.java @@ -7,8 +7,7 @@ package org.apache.fop.datatypes; -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; import org.apache.fop.fo.expr.Numeric; import org.apache.fop.fo.expr.PropertyException; @@ -20,18 +19,17 @@ import org.apache.fop.fo.expr.PropertyException; */ public class MixedLength extends Length { - private Vector lengths ; + private ArrayList lengths ; - public MixedLength(Vector lengths) { + public MixedLength(ArrayList lengths) { this.lengths = lengths; } protected void computeValue() { int computedValue =0; boolean bAllComputed = true; - Enumeration e = lengths.elements(); - while (e.hasMoreElements()) { - Length l = (Length)e.nextElement(); + for (int i = 0; i < lengths.size(); i++) { + Length l = (Length)lengths.get(i); computedValue += l.mvalue(); if (! l.isComputed()) { bAllComputed = false; @@ -40,43 +38,38 @@ public class MixedLength extends Length { setComputedValue(computedValue, bAllComputed); } - public double getTableUnits() { double tableUnits = 0.0; - Enumeration e = lengths.elements(); - while (e.hasMoreElements()) { - tableUnits += ((Length)e.nextElement()).getTableUnits(); + for (int i = 0; i < lengths.size(); i++) { + tableUnits += ((Length)lengths.get(i)).getTableUnits(); } return tableUnits; } public void resolveTableUnit(double dTableUnit) { - Enumeration e = lengths.elements(); - while (e.hasMoreElements()) { - ((Length)e.nextElement()).resolveTableUnit(dTableUnit); + for (int i = 0; i < lengths.size(); i++) { + ((Length)lengths.get(i)).resolveTableUnit(dTableUnit); } } public String toString() { StringBuffer sbuf = new StringBuffer(); - Enumeration e = lengths.elements(); - while (e.hasMoreElements()) { + for (int i = 0; i < lengths.size(); i++) { if (sbuf.length()>0) { sbuf.append('+'); } - sbuf.append(e.nextElement().toString()); + sbuf.append(lengths.get(i).toString()); } return sbuf.toString(); } public Numeric asNumeric() { Numeric numeric = null; - for (Enumeration e = lengths.elements(); e.hasMoreElements();) { - Length l = (Length)e.nextElement(); + for (int i = 0; i < lengths.size(); i++) { + Length l = (Length)lengths.get(i); if (numeric == null) { numeric = l.asNumeric(); - } - else { + } else { try { Numeric sum = numeric.add(l.asNumeric()); numeric = sum; diff --git a/src/org/apache/fop/extensions/ExtensionElementMapping.java b/src/org/apache/fop/extensions/ExtensionElementMapping.java index 8f33af6b9..511b9fc03 100644 --- a/src/org/apache/fop/extensions/ExtensionElementMapping.java +++ b/src/org/apache/fop/extensions/ExtensionElementMapping.java @@ -11,7 +11,6 @@ import org.apache.fop.fo.*; import org.apache.fop.fo.properties.ExtensionPropertyMapping; import org.apache.fop.fo.TreeBuilder; -import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; diff --git a/src/org/apache/fop/extensions/Outline.java b/src/org/apache/fop/extensions/Outline.java index 9247bc35f..db1dd2084 100644 --- a/src/org/apache/fop/extensions/Outline.java +++ b/src/org/apache/fop/extensions/Outline.java @@ -17,7 +17,7 @@ import java.util.*; public class Outline extends ExtensionObj { private Label _label; - private Vector _outlines = new Vector(); + private ArrayList _outlines = new ArrayList(); private String _internalDestination; private String _externalDestination; @@ -73,7 +73,7 @@ public class Outline extends ExtensionObj { if (obj instanceof Label) { _label = (Label)obj; } else if (obj instanceof Outline) { - _outlines.addElement(obj); + _outlines.add(obj); } super.addChild(obj); } @@ -95,7 +95,7 @@ public class Outline extends ExtensionObj { return _label == null ? new Label(this, this.properties) : _label; } - public Vector getOutlines() { + public ArrayList getOutlines() { return _outlines; } diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index 796cf7b1b..78a6f8b22 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -18,16 +18,15 @@ import org.apache.fop.layout.LinkSet; import org.apache.avalon.framework.logger.Logger; // Java -import java.util.Vector; -import java.util.Hashtable; +import java.util.ArrayList; /** * base class for nodes in the formatting object tree * * Modified by Mark Lillywhite mark-fop@inomial.com. Made - * Vector a protected member. (/me things this should be + * ArrayList a protected member. (/me things this should be * a private member with an API for adding children; - * this woudl save a lot of memory because the Vector + * this woudl save a lot of memory because the ArrayList * would not have to be instantiated unless the node had * children). */ @@ -37,7 +36,7 @@ abstract public class FONode { protected String areaClass = AreaClass.UNASSIGNED; - protected Vector children = new Vector(); // made public for searching for id's + protected ArrayList children = new ArrayList(); // made public for searching for id's /** * value of marker before layout begins @@ -85,7 +84,7 @@ abstract public class FONode { this.isInTableCell = true; // made recursive by Eric Schaeffer for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode)this.children.elementAt(i); + FONode child = (FONode)this.children.get(i); child.setIsInTableCell(); } } @@ -94,7 +93,7 @@ abstract public class FONode { this.forcedStartOffset = offset; // made recursive by Eric Schaeffer for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode)this.children.elementAt(i); + FONode child = (FONode)this.children.get(i); child.forceStartOffset(offset); } } @@ -103,7 +102,7 @@ abstract public class FONode { this.forcedWidth = width; // made recursive by Eric Schaeffer for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode)this.children.elementAt(i); + FONode child = (FONode)this.children.get(i); child.forceWidth(width); } } @@ -112,7 +111,7 @@ abstract public class FONode { this.marker = START; int numChildren = this.children.size(); for (int i = 0; i < numChildren; i++) { - ((FONode)children.elementAt(i)).resetMarker(); + ((FONode)children.get(i)).resetMarker(); } } @@ -122,7 +121,7 @@ abstract public class FONode { protected void addChild(FONode child) { - children.addElement(child); + children.add(child); } public FObj getParent() { @@ -132,7 +131,7 @@ abstract public class FONode { public void setLinkSet(LinkSet linkSet) { this.linkSet = linkSet; for (int i = 0; i < this.children.size(); i++) { - FONode child = (FONode)this.children.elementAt(i); + FONode child = (FONode)this.children.get(i); child.setLinkSet(linkSet); } } @@ -158,11 +157,11 @@ abstract public class FONode { * At the start of a new span area layout may be partway through a * nested FO, and balancing requires rollback to this known point. * The snapshot records exactly where layout is at. - * @param snapshot a Vector of markers (Integer) - * @returns the updated Vector of markers (Integers) + * @param snapshot a ArrayList of markers (Integer) + * @returns the updated ArrayList of markers (Integers) */ - public Vector getMarkerSnapshot(Vector snapshot) { - snapshot.addElement(new Integer(this.marker)); + public ArrayList getMarkerSnapshot(ArrayList snapshot) { + snapshot.add(new Integer(this.marker)); // terminate if no kids or child not yet accessed if (this.marker < 0) @@ -170,18 +169,18 @@ abstract public class FONode { else if (children.isEmpty()) return snapshot; else - return ((FONode)children.elementAt(this.marker)).getMarkerSnapshot(snapshot); + return ((FONode)children.get(this.marker)).getMarkerSnapshot(snapshot); } /** * When balancing occurs, the flow layout() method restarts at the * point specified by the current marker snapshot, which is retrieved * and restored using this method. - * @param snapshot the Vector of saved markers (Integers) + * @param snapshot the ArrayList of saved markers (Integers) */ - public void rollback(Vector snapshot) { - this.marker = ((Integer)snapshot.elementAt(0)).intValue(); - snapshot.removeElementAt(0); + public void rollback(ArrayList snapshot) { + this.marker = ((Integer)snapshot.get(0)).intValue(); + snapshot.remove(0); if (this.marker == START) { // make sure all the children of this FO are also reset @@ -197,10 +196,10 @@ abstract public class FONode { } for (int i = this.marker + 1; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); + FONode fo = (FONode)children.get(i); fo.resetMarker(); } - ((FONode)children.elementAt(this.marker)).rollback(snapshot); + ((FONode)children.get(this.marker)).rollback(snapshot); } } diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java index e64883983..d3465fd91 100644 --- a/src/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/org/apache/fop/fo/FOTreeBuilder.java @@ -26,8 +26,7 @@ import org.xml.sax.Attributes; // Java import java.util.HashMap; -import java.util.Stack; -import java.util.Vector; +import java.util.ArrayList; import java.io.IOException; /** @@ -49,7 +48,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder { */ protected HashMap fobjTable = new HashMap(); - protected Vector namespaces = new Vector(); + protected ArrayList namespaces = new ArrayList(); /** * class that builds a property list for each formatting object @@ -102,7 +101,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder { */ public void addMapping(String namespaceURI, HashMap table) { this.fobjTable.put(namespaceURI, table); - this.namespaces.addElement(namespaceURI.intern()); + this.namespaces.add(namespaceURI.intern()); } /** diff --git a/src/org/apache/fop/fo/FObj.java b/src/org/apache/fop/fo/FObj.java index 6b36be5bc..86e15b479 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -14,9 +14,8 @@ import org.apache.fop.datatypes.IDReferences; import org.apache.fop.fo.flow.Marker; // Java -import java.util.Hashtable; -import java.util.Enumeration; -import java.util.Vector; +import java.util.HashMap; +import java.util.ArrayList; /** * base class for representation of formatting objects and their processing @@ -37,7 +36,7 @@ public abstract class FObj extends FONode { protected PropertyManager propMgr; // markers - private Hashtable markers; + private HashMap markers; // protected String name; @@ -131,7 +130,7 @@ public abstract class FObj extends FONode { idReferences.removeID(((FObj)this).properties.get("id").getString()); int numChildren = this.children.size(); for (int i = 0; i < numChildren; i++) { - FONode child = (FONode)children.elementAt(i); + FONode child = (FONode)children.get(i); if ((child instanceof FObj)) { ((FObj)child).removeID(idReferences); } @@ -165,7 +164,7 @@ public abstract class FObj extends FONode { + getName()); } if (markers==null) { - markers = new Hashtable(); + markers = new HashMap(); markers.put(mcname, marker); } else if (!markers.containsKey(mcname) ) { markers.put(mcname, marker); @@ -180,12 +179,12 @@ public abstract class FObj extends FONode { return markers!=null; } - public Vector getMarkers() { + public ArrayList getMarkers() { if (markers==null) { log.debug("GetMarkers failed (no markers). Should not happen."); return null; } else { - return new Vector(markers.values()); + return new ArrayList(markers.values()); } } } diff --git a/src/org/apache/fop/fo/FObjMixed.java b/src/org/apache/fop/fo/FObjMixed.java index f159b0ed1..1b45a88e9 100644 --- a/src/org/apache/fop/fo/FObjMixed.java +++ b/src/org/apache/fop/fo/FObjMixed.java @@ -85,7 +85,7 @@ public abstract class FObjMixed extends FObj { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); + FONode fo = (FONode)children.get(i); Status status; if ((status = fo.layout(area)).isIncomplete()) { this.marker = i; diff --git a/src/org/apache/fop/fo/GenericShorthandParser.java b/src/org/apache/fop/fo/GenericShorthandParser.java index 4237beb0f..5f7c90fd8 100644 --- a/src/org/apache/fop/fo/GenericShorthandParser.java +++ b/src/org/apache/fop/fo/GenericShorthandParser.java @@ -7,12 +7,11 @@ package org.apache.fop.fo; -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; public class GenericShorthandParser implements ShorthandParser { - protected Vector list; // Vector of Property objects + protected ArrayList list; // ArrayList of Property objects public GenericShorthandParser(ListProperty listprop) { this.list = listprop.getList(); @@ -20,7 +19,7 @@ public class GenericShorthandParser implements ShorthandParser { protected Property getElement(int index) { if (list.size() > index) - return (Property)list.elementAt(index); + return (Property)list.get(index); else return null; } @@ -37,7 +36,7 @@ public class GenericShorthandParser implements ShorthandParser { Property prop = null; // Check for keyword "inherit" if (count() == 1) { - String sval = ((Property)list.elementAt(0)).getString(); + String sval = ((Property)list.get(0)).getString(); if (sval != null && sval.equals("inherit")) { return propertyList.getFromParent(propName); } @@ -49,14 +48,15 @@ public class GenericShorthandParser implements ShorthandParser { protected Property convertValueForProperty(String propName, Property.Maker maker, PropertyList propertyList) { - Property prop = null; // Try each of the stored values in turn - Enumeration eprop = list.elements(); - while (eprop.hasMoreElements() && prop == null) { - Property p = (Property)eprop.nextElement(); - prop = maker.convertShorthandProperty(propertyList, p, null); + for (int i = 0; i < list.size(); i++) { + Property p = (Property)list.get(i); + Property prop = maker.convertShorthandProperty(propertyList, p, null); + if (prop!=null) { + return prop; + } } - return prop; + return null; } } diff --git a/src/org/apache/fop/fo/ListProperty.java b/src/org/apache/fop/fo/ListProperty.java index 9253283e3..60b38be29 100644 --- a/src/org/apache/fop/fo/ListProperty.java +++ b/src/org/apache/fop/fo/ListProperty.java @@ -7,7 +7,7 @@ package org.apache.fop.fo; -import java.util.Vector; +import java.util.ArrayList; public class ListProperty extends Property { @@ -27,18 +27,18 @@ public class ListProperty extends Property { } - protected Vector list; + protected ArrayList list; public ListProperty(Property prop) { - list = new Vector(); - list.addElement(prop); + list = new ArrayList(); + list.add(prop); } public void addProperty(Property prop) { - list.addElement(prop); + list.add(prop); } - public Vector getList() { + public ArrayList getList() { return list; } diff --git a/src/org/apache/fop/fo/MarginShorthandParser.java b/src/org/apache/fop/fo/MarginShorthandParser.java index dd96c777b..9b2cb98e8 100644 --- a/src/org/apache/fop/fo/MarginShorthandParser.java +++ b/src/org/apache/fop/fo/MarginShorthandParser.java @@ -7,12 +7,11 @@ package org.apache.fop.fo; -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; public class MarginShorthandParser implements ShorthandParser { - protected Vector list; // Vector of Property objects + protected ArrayList list; // ArrayList of Property objects public MarginShorthandParser(ListProperty listprop) { this.list = listprop.getList(); @@ -20,7 +19,7 @@ public class MarginShorthandParser implements ShorthandParser { protected Property getElement(int index) { if (list.size() > index) - return (Property)list.elementAt(index); + return (Property)list.get(index); else return null; } @@ -35,11 +34,9 @@ public class MarginShorthandParser implements ShorthandParser { PropertyList propertyList) { Property prop = null; // Check for keyword "inherit" - if (count() == 1) - { - String sval = ((Property)list.elementAt(0)).getString(); - if (sval != null && sval.equals("inherit")) - { + if (count() == 1) { + String sval = ((Property)list.get(0)).getString(); + if (sval != null && sval.equals("inherit")) { return propertyList.getFromParent(propName); } } diff --git a/src/org/apache/fop/fo/Property.java b/src/org/apache/fop/fo/Property.java index 9406f7625..3c9250f22 100644 --- a/src/org/apache/fop/fo/Property.java +++ b/src/org/apache/fop/fo/Property.java @@ -19,7 +19,7 @@ import org.apache.fop.apps.FOPException; import org.apache.avalon.framework.logger.Logger; // Java -import java.util.Vector; +import java.util.ArrayList; public class Property { @@ -424,7 +424,7 @@ public class Property { return 0; } - public Vector getList() { + public ArrayList getList() { return null; } // List of Property objects diff --git a/src/org/apache/fop/fo/PropertyList.java b/src/org/apache/fop/fo/PropertyList.java index f6cd8747f..660348a63 100644 --- a/src/org/apache/fop/fo/PropertyList.java +++ b/src/org/apache/fop/fo/PropertyList.java @@ -7,12 +7,13 @@ package org.apache.fop.fo; -import java.util.Hashtable; import org.apache.fop.messaging.MessageHandler; import org.apache.fop.fo.properties.WritingMode; import org.apache.fop.apps.FOPException; -public class PropertyList extends Hashtable { +import java.util.HashMap; + +public class PropertyList extends HashMap { private byte[] wmtable = null; // writing-mode values public static final int LEFT = 0; @@ -38,7 +39,7 @@ public class PropertyList extends Hashtable { "inline-progression-dimension" }; - static private final Hashtable wmtables = new Hashtable(4); + static private final HashMap wmtables = new HashMap(4); { wmtables.put(new Integer(WritingMode.LR_TB), /* lr-tb */ new byte[] { diff --git a/src/org/apache/fop/fo/StandardElementMapping.java b/src/org/apache/fop/fo/StandardElementMapping.java index 784604062..5ae302977 100644 --- a/src/org/apache/fop/fo/StandardElementMapping.java +++ b/src/org/apache/fop/fo/StandardElementMapping.java @@ -7,7 +7,6 @@ package org.apache.fop.fo; -import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; diff --git a/src/org/apache/fop/fo/XMLObj.java b/src/org/apache/fop/fo/XMLObj.java index 644d7b6c0..0449bb976 100644 --- a/src/org/apache/fop/fo/XMLObj.java +++ b/src/org/apache/fop/fo/XMLObj.java @@ -18,7 +18,8 @@ import org.apache.fop.datatypes.IDReferences; import org.w3c.dom.*; import org.xml.sax.Attributes; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; /** * Since SVG objects are not layed out then this class checks @@ -44,7 +45,7 @@ public abstract class XMLObj extends FObj { public abstract String getNameSpace(); - protected static Hashtable ns = new Hashtable(); + protected static HashMap ns = new HashMap(); public void addGraphic(Document doc, Element parent) { this.doc = doc; @@ -162,11 +163,11 @@ public abstract class XMLObj extends FObj { public void setLinkSet(LinkSet linkSet) {} - public Vector getMarkerSnapshot(Vector snapshot) { + public ArrayList getMarkerSnapshot(ArrayList snapshot) { return snapshot; } - public void rollback(Vector snapshot) {} + public void rollback(ArrayList snapshot) {} protected void setWritingMode() {} } diff --git a/src/org/apache/fop/fo/expr/Numeric.java b/src/org/apache/fop/fo/expr/Numeric.java index 68a8d15a7..3a598b378 100644 --- a/src/org/apache/fop/fo/expr/Numeric.java +++ b/src/org/apache/fop/fo/expr/Numeric.java @@ -7,8 +7,6 @@ package org.apache.fop.fo.expr; -import java.util.Vector; - import org.apache.fop.fo.Property; import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.FixedLength; @@ -18,6 +16,8 @@ import org.apache.fop.datatypes.MixedLength; import org.apache.fop.datatypes.TableColLength; import org.apache.fop.datatypes.PercentBase; +import java.util.ArrayList; + /** * Represents a "numeric" value as defined by the XSL FO Specification. * This consists of one or more kinds of value specifications, from @@ -123,7 +123,7 @@ public class Numeric { */ public Length asLength() { if (dim == 1) { - Vector len = new Vector(3); + ArrayList len = new ArrayList(3); if ((valType & ABS_LENGTH) != 0) { len.add(new FixedLength((int)absValue)); } @@ -134,7 +134,7 @@ public class Numeric { len.add(new TableColLength(tcolValue)); } if (len.size() == 1) { - return (Length)len.elementAt(0); + return (Length)len.get(0); } else { return new MixedLength(len); diff --git a/src/org/apache/fop/fo/expr/PropertyParser.java b/src/org/apache/fop/fo/expr/PropertyParser.java index 669ee6d8d..3215ee55c 100644 --- a/src/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/org/apache/fop/fo/expr/PropertyParser.java @@ -15,7 +15,7 @@ import org.apache.fop.fo.StringProperty; import org.apache.fop.fo.ColorTypeProperty; import org.apache.fop.datatypes.*; -import java.util.Hashtable; +import java.util.HashMap; /** * Class to parse XSL FO property expression. @@ -27,10 +27,10 @@ public class PropertyParser extends PropertyTokenizer { static private final String RELUNIT = "em"; static private final Numeric negOne = new Numeric(new Double(-1.0)); - static final private Hashtable functionTable = new Hashtable(); + static final private HashMap functionTable = new HashMap(); static { - // Initialize the Hashtable of XSL-defined functions + // Initialize the HashMap of XSL-defined functions functionTable.put("ceiling", new CeilingFunction()); functionTable.put("floor", new FloorFunction()); functionTable.put("round", new RoundFunction()); diff --git a/src/org/apache/fop/fo/flow/AbstractFlow.java b/src/org/apache/fop/fo/flow/AbstractFlow.java index d7756c6c9..fe52e6cf7 100644 --- a/src/org/apache/fop/fo/flow/AbstractFlow.java +++ b/src/org/apache/fop/fo/flow/AbstractFlow.java @@ -16,9 +16,7 @@ import org.apache.fop.layout.BodyAreaContainer; import org.apache.fop.apps.FOPException; // Java -import java.util.Hashtable; -import java.util.Enumeration; -import java.util.Vector; +import java.util.ArrayList; public abstract class AbstractFlow extends FObj { @@ -33,9 +31,9 @@ public abstract class AbstractFlow extends FObj { private Area area; /** - * Vector to store snapshot + * ArrayList to store snapshot */ - private Vector markerSnapshot; + private ArrayList markerSnapshot; /** * flow-name attribute @@ -80,14 +78,14 @@ public abstract class AbstractFlow extends FObj { BodyAreaContainer bac = (BodyAreaContainer)area; boolean prevChildMustKeepWithNext = false; - Vector pageMarker = this.getMarkerSnapshot(new Vector()); + ArrayList pageMarker = this.getMarkerSnapshot(new ArrayList()); int numChildren = this.children.size(); if (numChildren == 0) { throw new FOPException("fo:flow must contain block-level children"); } for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); + FObj fo = (FObj)children.get(i); if (bac.isBalancingRequired(fo)) { // reset the the just-done span area in preparation @@ -105,7 +103,7 @@ public abstract class AbstractFlow extends FObj { currentArea.setIDReferences(bac.getIDReferences()); if (bac.isNewSpanArea()) { this.marker = i; - markerSnapshot = this.getMarkerSnapshot(new Vector()); + markerSnapshot = this.getMarkerSnapshot(new ArrayList()); } // Set current content width for percent-based lengths in children setContentWidth(currentArea.getContentWidth()); @@ -125,7 +123,7 @@ public abstract class AbstractFlow extends FObj { if (_status.isIncomplete()) { if ((prevChildMustKeepWithNext) && (_status.laidOutNone())) { this.marker = i - 1; - FObj prevChild = (FObj)children.elementAt(this.marker); + FObj prevChild = (FObj)children.get(this.marker); prevChild.removeAreas(); prevChild.resetMarker(); prevChild.removeID(area.getIDReferences()); diff --git a/src/org/apache/fop/fo/flow/AbstractTableBody.java b/src/org/apache/fop/fo/flow/AbstractTableBody.java index c814730d5..0882c0daf 100644 --- a/src/org/apache/fop/fo/flow/AbstractTableBody.java +++ b/src/org/apache/fop/fo/flow/AbstractTableBody.java @@ -15,8 +15,7 @@ import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; // Java -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; public abstract class AbstractTableBody extends FObj { @@ -24,7 +23,7 @@ public abstract class AbstractTableBody extends FObj { int spaceAfter; String id; - Vector columns; + ArrayList columns; RowSpanMgr rowSpanMgr; // manage information about spanning rows AreaContainer areaContainer; @@ -38,7 +37,7 @@ public abstract class AbstractTableBody extends FObj { } } - public void setColumns(Vector columns) { + public void setColumns(ArrayList columns) { this.columns = columns; } @@ -132,12 +131,12 @@ public abstract class AbstractTableBody extends FObj { areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); areaContainer.setIDReferences(area.getIDReferences()); - Vector keepWith = new Vector(); + ArrayList keepWith = new ArrayList(); int numChildren = this.children.size(); TableRow lastRow = null; boolean endKeepGroup = true; for (int i = this.marker; i < numChildren; i++) { - Object child = children.elementAt(i); + Object child = children.get(i); if (!(child instanceof TableRow)) { throw new FOPException("Currently only Table Rows are supported in table body, header and footer"); } @@ -150,10 +149,10 @@ public abstract class AbstractTableBody extends FObj { != KeepValue.KEEP_WITH_AUTO && lastRow != null && keepWith.indexOf(lastRow) == -1) { - keepWith.addElement(lastRow); + keepWith.add(lastRow); } else { if (endKeepGroup && keepWith.size() > 0) { - keepWith = new Vector(); + keepWith = new ArrayList(); } } @@ -180,9 +179,8 @@ public abstract class AbstractTableBody extends FObj { // && status.getCode() == Status.AREA_FULL_NONE // FIXME!!! Handle rows spans!!! row.removeLayout(areaContainer); - for (Enumeration e = keepWith.elements(); - e.hasMoreElements(); ) { - TableRow tr = (TableRow)e.nextElement(); + for (int j = 0; j < keepWith.size(); j++) { + TableRow tr = (TableRow)keepWith.get(j); tr.removeLayout(areaContainer); i--; } @@ -213,7 +211,7 @@ public abstract class AbstractTableBody extends FObj { return status; } else if (status.getCode() == Status.KEEP_WITH_NEXT || rowSpanMgr.hasUnfinishedSpans()) { - keepWith.addElement(row); + keepWith.add(row); endKeepGroup = false; } else { endKeepGroup = true; diff --git a/src/org/apache/fop/fo/flow/BasicLink.java b/src/org/apache/fop/fo/flow/BasicLink.java index 08b82527d..749ba2c64 100644 --- a/src/org/apache/fop/fo/flow/BasicLink.java +++ b/src/org/apache/fop/fo/flow/BasicLink.java @@ -15,7 +15,6 @@ import org.apache.fop.layout.*; import org.apache.fop.datatypes.ColorType; // Java -import java.util.Enumeration; import java.awt.Rectangle; public class BasicLink extends Inline { @@ -108,7 +107,7 @@ public class BasicLink extends Inline { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); + FONode fo = (FONode)children.get(i); fo.setLinkSet(ls); Status status; diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index e012fcea9..95de87212 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -190,7 +190,7 @@ public class Block extends FObjMixed { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); + FONode fo = (FONode)children.get(i); Status status; if ((status = fo.layout(blockArea)).isIncomplete()) { this.marker = i; diff --git a/src/org/apache/fop/fo/flow/BlockContainer.java b/src/org/apache/fop/fo/flow/BlockContainer.java index 53c122826..8c1a96f94 100644 --- a/src/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/org/apache/fop/fo/flow/BlockContainer.java @@ -15,10 +15,6 @@ import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.*; -// Java -import java.util.Hashtable; -import java.util.Enumeration; - public class BlockContainer extends FObj { int position; @@ -127,13 +123,13 @@ public class BlockContainer extends FObj { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); + FObj fo = (FObj)children.get(i); Status status; if ((status = fo.layout(areaContainer)).isIncomplete()) { /* * if ((prevChildMustKeepWithNext) && (status.laidOutNone())) { * this.marker = i - 1; - * FObj prevChild = (FObj) children.elementAt(this.marker); + * FObj prevChild = (FObj) children.get(this.marker); * prevChild.removeAreas(); * prevChild.resetMarker(); * return new Status(Status.AREA_FULL_SOME); diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java index 469089865..b3420456d 100644 --- a/src/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java @@ -15,8 +15,6 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.image.*; // Java -import java.util.Enumeration; -import java.util.Hashtable; import java.net.URL; import java.net.MalformedURLException; diff --git a/src/org/apache/fop/fo/flow/Footnote.java b/src/org/apache/fop/fo/flow/Footnote.java index d22909e3c..b6eb8270b 100644 --- a/src/org/apache/fop/fo/flow/Footnote.java +++ b/src/org/apache/fop/fo/flow/Footnote.java @@ -15,8 +15,7 @@ import org.apache.fop.fo.properties.*; import org.apache.fop.messaging.*; // Java -import java.util.Enumeration; -import java.util.Vector; +import java.util.ArrayList; public class Footnote extends FObj { @@ -49,7 +48,7 @@ public class Footnote extends FObj { } int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); + FONode fo = (FONode)children.get(i); if (fo instanceof Inline) { inline = fo; Status status = fo.layout(area); @@ -113,9 +112,9 @@ public class Footnote extends FObj { protected static void decreaseMaxHeight(Area ar, int change) { ar.setMaxHeight(ar.getMaxHeight() - change); - Vector childs = ar.getChildren(); - for (Enumeration en = childs.elements(); en.hasMoreElements(); ) { - Object obj = en.nextElement(); + ArrayList children = ar.getChildren(); + for (int i = 0; i < children.size(); i++) { + Object obj = children.get(i); if (obj instanceof Area) { Area childArea = (Area)obj; decreaseMaxHeight(childArea, change); diff --git a/src/org/apache/fop/fo/flow/FootnoteBody.java b/src/org/apache/fop/fo/flow/FootnoteBody.java index ad6975147..f8a1afc2c 100644 --- a/src/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/org/apache/fop/fo/flow/FootnoteBody.java @@ -15,9 +15,6 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; -// Java -import java.util.Enumeration; - public class FootnoteBody extends FObj { int align; @@ -70,7 +67,7 @@ public class FootnoteBody extends FObj { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); + FONode fo = (FONode)children.get(i); Status status; if ((status = fo.layout(blockArea)).isIncomplete()) { this.resetMarker(); diff --git a/src/org/apache/fop/fo/flow/Inline.java b/src/org/apache/fop/fo/flow/Inline.java index fa67bdb67..1418ce863 100644 --- a/src/org/apache/fop/fo/flow/Inline.java +++ b/src/org/apache/fop/fo/flow/Inline.java @@ -13,9 +13,6 @@ import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.*; -// Java -import java.util.Enumeration; - public class Inline extends FObjMixed { public static class Maker extends FObj.Maker { diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java index 64776ad65..2c0025c82 100644 --- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -16,9 +16,6 @@ import org.apache.fop.layout.BlockArea; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; -// Java -import java.util.Enumeration; - public class InstreamForeignObject extends FObj { /** @@ -194,7 +191,7 @@ public class InstreamForeignObject extends FObj { } /* layout foreign object */ if (this.children.size() > 0) { - FONode fo = (FONode)children.elementAt(0); + FONode fo = (FONode)children.get(0); Status status; // currently FONode must be an SVG if ((status = diff --git a/src/org/apache/fop/fo/flow/ListBlock.java b/src/org/apache/fop/fo/flow/ListBlock.java index 58b5160a8..b4a66f87f 100644 --- a/src/org/apache/fop/fo/flow/ListBlock.java +++ b/src/org/apache/fop/fo/flow/ListBlock.java @@ -16,9 +16,6 @@ import org.apache.fop.layout.BlockArea; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; -// Java -import java.util.Enumeration; - public class ListBlock extends FObj { public static class Maker extends FObj.Maker { @@ -141,11 +138,11 @@ public class ListBlock extends FObj { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - if (!(children.elementAt(i) instanceof ListItem)) { + if (!(children.get(i) instanceof ListItem)) { log.error("children of list-blocks must be list-items"); return new Status(Status.OK); } - ListItem listItem = (ListItem)children.elementAt(i); + ListItem listItem = (ListItem)children.get(i); Status status; if ((status = listItem.layout(blockArea)).isIncomplete()) { if (status.getCode() == Status.AREA_FULL_NONE && i > 0) { diff --git a/src/org/apache/fop/fo/flow/ListItem.java b/src/org/apache/fop/fo/flow/ListItem.java index 320b0acd5..dc49dcd91 100644 --- a/src/org/apache/fop/fo/flow/ListItem.java +++ b/src/org/apache/fop/fo/flow/ListItem.java @@ -15,9 +15,6 @@ import org.apache.fop.layout.BlockArea; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; -// Java -import java.util.Enumeration; - public class ListItem extends FObj { public static class Maker extends FObj.Maker { @@ -128,8 +125,8 @@ public class ListItem extends FObj { if (numChildren != 2) { throw new FOPException("list-item must have exactly two children"); } - ListItemLabel label = (ListItemLabel)children.elementAt(0); - ListItemBody body = (ListItemBody)children.elementAt(1); + ListItemLabel label = (ListItemLabel)children.get(0); + ListItemBody body = (ListItemBody)children.get(1); Status status; diff --git a/src/org/apache/fop/fo/flow/ListItemBody.java b/src/org/apache/fop/fo/flow/ListItemBody.java index 0e4d7e7bc..fb4858926 100644 --- a/src/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/org/apache/fop/fo/flow/ListItemBody.java @@ -14,9 +14,6 @@ import org.apache.fop.layout.*; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; -// Java -import java.util.Enumeration; - public class ListItemBody extends FObj { public static class Maker extends FObj.Maker { @@ -63,7 +60,7 @@ public class ListItemBody extends FObj { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); + FObj fo = (FObj)children.get(i); Status status; if ((status = fo.layout(area)).isIncomplete()) { diff --git a/src/org/apache/fop/fo/flow/ListItemLabel.java b/src/org/apache/fop/fo/flow/ListItemLabel.java index 8f8a3ba23..8d4512f78 100644 --- a/src/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/org/apache/fop/fo/flow/ListItemLabel.java @@ -14,9 +14,6 @@ import org.apache.fop.layout.*; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; -// Java -import java.util.Enumeration; - public class ListItemLabel extends FObj { public static class Maker extends FObj.Maker { @@ -56,7 +53,7 @@ public class ListItemLabel extends FObj { String id = this.properties.get("id").getString(); area.getIDReferences().initializeID(id, area); - Block block = (Block)children.elementAt(0); + Block block = (Block)children.get(0); /* * For calculating the lineage - The fo:list-item-label formatting object diff --git a/src/org/apache/fop/fo/flow/Marker.java b/src/org/apache/fop/fo/flow/Marker.java index 309ba5118..0b3ffdcc9 100644 --- a/src/org/apache/fop/fo/flow/Marker.java +++ b/src/org/apache/fop/fo/flow/Marker.java @@ -69,7 +69,7 @@ public class Marker extends FObjMixed { int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); + FONode fo = (FONode)children.get(i); Status status; if ((status = fo.layout(area)).isIncomplete()) { diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java index c721e3942..36eb3d9ee 100644 --- a/src/org/apache/fop/fo/flow/PageNumber.java +++ b/src/org/apache/fop/fo/flow/PageNumber.java @@ -15,9 +15,6 @@ import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; -// Java -import java.util.Enumeration; - public class PageNumber extends FObj { public static class Maker extends FObj.Maker { diff --git a/src/org/apache/fop/fo/flow/RetrieveMarker.java b/src/org/apache/fop/fo/flow/RetrieveMarker.java index c63bbf85a..490410c1f 100644 --- a/src/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/org/apache/fop/fo/flow/RetrieveMarker.java @@ -15,7 +15,7 @@ import org.apache.fop.datatypes.*; import org.apache.fop.apps.FOPException; // Java -import java.util.Vector; +import java.util.ArrayList; public class RetrieveMarker extends FObj { @@ -92,7 +92,7 @@ public class RetrieveMarker extends FObj { private Marker searchPage(Page page, boolean isContainingPage) throws FOPException { - Vector pageMarkers = page.getMarkers(); + ArrayList pageMarkers = page.getMarkers(); if (pageMarkers.isEmpty()) { // System.out.println("No markers on page"); return null; @@ -102,7 +102,7 @@ public class RetrieveMarker extends FObj { // being processed), grab the last qualifying marker on this one if (!isContainingPage) { for (int c = pageMarkers.size(); c > 0; c--) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1); + Marker currentMarker = (Marker)pageMarkers.get(c - 1); if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { return currentMarker; } @@ -113,25 +113,23 @@ public class RetrieveMarker extends FObj { // 'first-including-carryover' if (retrievePosition == RetrievePosition.FIC) { for (int c = 0; c < pageMarkers.size(); c++) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c); + Marker currentMarker = (Marker)pageMarkers.get(c); if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { return currentMarker; } } - } else if (retrievePosition == RetrievePosition.FSWP) { - for (int c = 0; c < pageMarkers.size(); c++) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c); + for (int i = 0; i < pageMarkers.size(); i++) { + Marker currentMarker = (Marker)pageMarkers.get(i); if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { if (currentMarker.getRegistryArea().isFirst()) { return currentMarker; } } } - } else if (retrievePosition == RetrievePosition.LSWP) { - for (int c = pageMarkers.size(); c > 0; c--) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1); + for (int i = pageMarkers.size(); i > 0; i--) { + Marker currentMarker = (Marker)pageMarkers.get(i - 1); if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { if (currentMarker.getRegistryArea().isFirst()) { return currentMarker; @@ -141,7 +139,7 @@ public class RetrieveMarker extends FObj { } else if (retrievePosition == RetrievePosition.LEWP) { for (int c = pageMarkers.size(); c > 0; c--) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1); + Marker currentMarker = (Marker)pageMarkers.get(c - 1); if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { if (currentMarker.getRegistryArea().isLast()) { return currentMarker; diff --git a/src/org/apache/fop/fo/flow/RowSpanMgr.java b/src/org/apache/fop/fo/flow/RowSpanMgr.java index c98b054cc..7044fccbe 100644 --- a/src/org/apache/fop/fo/flow/RowSpanMgr.java +++ b/src/org/apache/fop/fo/flow/RowSpanMgr.java @@ -8,7 +8,6 @@ package org.apache.fop.fo.flow; import org.apache.fop.layout.Area; -import java.util.Enumeration; public class RowSpanMgr { class SpanInfo { diff --git a/src/org/apache/fop/fo/flow/StaticContent.java b/src/org/apache/fop/fo/flow/StaticContent.java index d91bb0f92..a670fe956 100644 --- a/src/org/apache/fop/fo/flow/StaticContent.java +++ b/src/org/apache/fop/fo/flow/StaticContent.java @@ -70,7 +70,7 @@ public class StaticContent extends AbstractFlow { setContentWidth(area.getContentWidth()); for (int i = 0; i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); + FObj fo = (FObj)children.get(i); Status status; if ((status = fo.layout(area)).isIncomplete()) { diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java index ee0bcb741..e7f7335c9 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -15,8 +15,7 @@ import org.apache.fop.datatypes.*; import org.apache.fop.apps.FOPException; // Java -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; public class Table extends FObj { @@ -45,7 +44,7 @@ public class Table extends FObj { boolean omitHeaderAtBreak = false; boolean omitFooterAtBreak = false; - Vector columns = new Vector(); + ArrayList columns = new ArrayList(); int bodyCount = 0; private boolean bAutoLayout=false; private int contentWidth = 0; // Sum of column widths @@ -184,7 +183,7 @@ public class Table extends FObj { boolean addedFooter = false; int numChildren = this.children.size(); - // Set up the column vector; + // Set up the column ArrayList; // calculate width of all columns and get total width if (columns.size()==0) { findColumns(areaContainer); @@ -199,7 +198,7 @@ public class Table extends FObj { layoutColumns(areaContainer); for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); + FONode fo = (FONode)children.get(i); if (fo instanceof TableHeader) { if (columns.size() == 0) { log.warn("current implementation of tables requires a table-column for each column, indicating column-width"); @@ -347,9 +346,8 @@ public class Table extends FObj { } protected void setupColumnHeights() { - Enumeration eCol = columns.elements(); - while (eCol.hasMoreElements()) { - TableColumn c = (TableColumn)eCol.nextElement(); + for (int i = 0; i < columns.size(); i++) { + TableColumn c = (TableColumn)columns.get(i); if ( c != null) { c.setHeight(areaContainer.getContentHeight()); } @@ -358,9 +356,8 @@ public class Table extends FObj { private void findColumns(Area areaContainer) throws FOPException { int nextColumnNumber = 1; - Enumeration e = children.elements(); - while (e.hasMoreElements()) { - FONode fo = (FONode)e.nextElement(); + for (int i = 0; i < children.size(); i++) { + FONode fo = (FONode)children.get(i); if (fo instanceof TableColumn) { TableColumn c = (TableColumn)fo; c.doSetup(areaContainer); @@ -369,17 +366,20 @@ public class Table extends FObj { if (currentColumnNumber == 0) { currentColumnNumber = nextColumnNumber; } - + if (currentColumnNumber + numColumnsRepeated > columns.size()) { + columns.ensureCapacity(currentColumnNumber + numColumnsRepeated); + } for (int j = 0; j < numColumnsRepeated; j++) { - if (currentColumnNumber > columns.size()) { - columns.setSize(currentColumnNumber); + if (currentColumnNumber <= columns.size()) { + if (columns.get(currentColumnNumber - 1) != null) { + log.warn("More than one column object assigned " + + "to column " + + currentColumnNumber); + } + columns.set(currentColumnNumber - 1, c); + } else { + columns.add(currentColumnNumber - 1, c); } - if (columns.elementAt(currentColumnNumber - 1) != null) { - log.warn("More than one column object assigned " + - "to column " + - currentColumnNumber); - } - columns.setElementAt(c, currentColumnNumber - 1); currentColumnNumber++; } nextColumnNumber = currentColumnNumber; @@ -397,9 +397,8 @@ public class Table extends FObj { double dWidthFactor = 0.0; double dUnitLength = 0.0; double tuMin = 100000.0 ; // Minimum number of proportional units - Enumeration eCol = columns.elements(); - while (eCol.hasMoreElements()) { - TableColumn c = (TableColumn)eCol.nextElement(); + for (int i = 0; i < columns.size(); i++) { + TableColumn c = (TableColumn)columns.get(i); if (c == null) { log.warn("No table-column specification for column " + nextColumnNumber); @@ -471,9 +470,8 @@ public class Table extends FObj { } // Now distribute the extra units onto each column and set offsets int offset = 0; - eCol = columns.elements(); - while (eCol.hasMoreElements()) { - TableColumn c = (TableColumn)eCol.nextElement(); + for (int i = 0; i < columns.size(); i++) { + TableColumn c = (TableColumn)columns.get(i); if (c != null) { c.setColumnOffset(offset); Length l = c.getColumnWidthAsLength(); @@ -497,9 +495,8 @@ public class Table extends FObj { } private void layoutColumns(Area tableArea) throws FOPException { - Enumeration eCol = columns.elements(); - while (eCol.hasMoreElements()) { - TableColumn c = (TableColumn)eCol.nextElement(); + for (int i = 0; i < columns.size(); i++) { + TableColumn c = (TableColumn)columns.get(i); if (c != null) { c.layout(tableArea); } @@ -604,7 +601,7 @@ public class Table extends FObj { // * ATTENTION: for now we assume columns are in order in the array! // */ // BorderInfo getColumnBorder(BorderInfo.Side side, int iColNumber) { - // TableColumn col = (TableColumn)columns.elementAt(iColNumber); + // TableColumn col = (TableColumn)columns.get(iColNumber); // return col.getBorderInfo(side); // } } diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index 7c889d126..1ad3dc509 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -11,13 +11,8 @@ package org.apache.fop.fo.flow; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.datatypes.*; -import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; -// Java -import java.util.Vector; -import java.util.Enumeration; - public class TableBody extends AbstractTableBody { public static class Maker extends FObj.Maker { diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index d462fa983..f71f5133a 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -261,7 +261,7 @@ public class TableCell extends FObj { int numChildren = this.children.size(); for (int i = this.marker; bDone==false && i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); + FObj fo = (FObj)children.get(i); fo.setIsInTableCell(); fo.forceWidth(width); // ??? diff --git a/src/org/apache/fop/fo/flow/TableFooter.java b/src/org/apache/fop/fo/flow/TableFooter.java index 15502dc75..815aa6a63 100644 --- a/src/org/apache/fop/fo/flow/TableFooter.java +++ b/src/org/apache/fop/fo/flow/TableFooter.java @@ -14,10 +14,6 @@ import org.apache.fop.datatypes.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; -// Java -import java.util.Vector; -import java.util.Enumeration; - public class TableFooter extends AbstractTableBody { public static class Maker extends FObj.Maker { diff --git a/src/org/apache/fop/fo/flow/TableHeader.java b/src/org/apache/fop/fo/flow/TableHeader.java index c91ac2c1c..58d3913e9 100644 --- a/src/org/apache/fop/fo/flow/TableHeader.java +++ b/src/org/apache/fop/fo/flow/TableHeader.java @@ -11,13 +11,8 @@ package org.apache.fop.fo.flow; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.datatypes.*; -import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; -// Java -import java.util.Vector; -import java.util.Enumeration; - public class TableHeader extends AbstractTableBody { public static class Maker extends FObj.Maker { diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index 12f76cc5d..32b712ebb 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -15,8 +15,7 @@ import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; // Java -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; public class TableRow extends FObj { @@ -44,7 +43,7 @@ public class TableRow extends FObj { int widthOfCellsSoFar = 0; int largestCellHeight = 0; int minHeight = 0; // force row height - Vector columns; + ArrayList columns; AreaContainer areaContainer; @@ -128,46 +127,6 @@ public class TableRow extends FObj { } return rslt; } - - // private class EnumCells implements Enumeration { - // private int iNextIndex=0; - // private Object nextCell = null; - // EnumCells() { - // findNextCell(); - // } - - // private void findNextCell() { - // for (; iNextIndex < cells.length; iNextIndex++) { - // if (states[iNextIndex] == CELLSTART) { - // nextCell = cells[iNextIndex]; - // return; - // } - // } - // nextCell = null; - // } - - // public boolean hasMoreElements() { - // return (nextCell != null); - // } - - // public Object nextElement() { - // if (nextCell != null) { - // Object cell = nextCell; - // findNextCell(); - // return cell; - // } - // else throw new java.util.NoSuchElementException("No more cells"); - // } - // } - - // /** - // * Return an enumeration over all cells in this row - // * Return each element in cells whose state is CELLSTART or EMPTY? - // * Skip spanning elements. - // */ - // Enumeration getCells() { - // return new EnumCells(); - // } } @@ -185,7 +144,7 @@ public class TableRow extends FObj { return "fo:table-row"; } - public void setColumns(Vector columns) { + public void setColumns(ArrayList columns) { this.columns = columns; } @@ -311,18 +270,16 @@ public class TableRow extends FObj { */ int offset = 0; // Offset of each cell from table start edge int iColIndex = 0; // 1-based column index - Enumeration eCols = columns.elements(); /* * Ideas: set offset on each column when they are initialized * no need to calculate for each row. * Pass column object to cell to get offset and width and border * info if borders are "collapsed". */ - - while (eCols.hasMoreElements()) { + for (int i = 0; i < columns.size(); i++) { TableCell cell; ++iColIndex; - TableColumn tcol = (TableColumn)eCols.nextElement(); + TableColumn tcol = (TableColumn)columns.get(i); int colWidth = tcol.getColumnWidth(); if (cellArray.getCellType(iColIndex) == CellArray.CELLSTART) { cell = cellArray.getCell(iColIndex); @@ -490,13 +447,12 @@ public class TableRow extends FObj { private void initCellArray() { cellArray = new CellArray(rowSpanMgr, columns.size()); int colNum = 1; - Enumeration eCells = children.elements(); - while (eCells.hasMoreElements()) { + for (int i = 0; i< children.size(); i++) { colNum = cellArray.getNextFreeCell(colNum); // If off the end, the rest of the cells had better be // explicitly positioned!!! (returns -1) - TableCell cell = (TableCell)eCells.nextElement(); + TableCell cell = (TableCell)children.get(i); int numCols = cell.getNumColumnsSpanned(); int numRows = cell.getNumRowsSpanned(); int cellColNum = cell.getColumnNumber(); @@ -541,7 +497,7 @@ public class TableRow extends FObj { private int getCellWidth(int startCol, int numCols) { int width = 0; for (int count = 0; count < numCols; count++) { - width += ((TableColumn)columns.elementAt(startCol + count + width += ((TableColumn)columns.get(startCol + count - 1)).getColumnWidth(); } return width; diff --git a/src/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/org/apache/fop/fo/pagination/LayoutMasterSet.java index 7953de2fa..6c5dcc5cb 100644 --- a/src/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -14,7 +14,8 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.layout.PageMaster; // Java -import java.util.*; +import java.util.HashMap; +import java.util.Iterator; public class LayoutMasterSet extends FObj { @@ -29,9 +30,9 @@ public class LayoutMasterSet extends FObj { return new LayoutMasterSet.Maker(); } - private Hashtable simplePageMasters; - private Hashtable pageSequenceMasters; - private Hashtable allRegions; + private HashMap simplePageMasters; + private HashMap pageSequenceMasters; + private HashMap allRegions; private Root root; @@ -39,8 +40,8 @@ public class LayoutMasterSet extends FObj { PropertyList propertyList) throws FOPException { super(parent, propertyList); - this.simplePageMasters = new Hashtable(); - this.pageSequenceMasters = new Hashtable(); + this.simplePageMasters = new HashMap(); + this.pageSequenceMasters = new HashMap(); if (parent.getName().equals("fo:root")) { this.root = (Root)parent; @@ -49,7 +50,7 @@ public class LayoutMasterSet extends FObj { throw new FOPException("fo:layout-master-set must be child of fo:root, not " + parent.getName()); } - allRegions = new Hashtable(); + allRegions = new HashMap(); } @@ -95,25 +96,17 @@ public class LayoutMasterSet extends FObj { return false; } - protected void resetPageMasters() { - for (Enumeration e = pageSequenceMasters.elements(); - e.hasMoreElements(); ) { - ((PageSequenceMaster)e.nextElement()).reset(); - } - - } - protected void checkRegionNames() throws FOPException { // Section 7.33.15 check to see that if a region-name is a // duplicate, that it maps to the same region-class. - for (Enumeration spm = simplePageMasters.elements(); - spm.hasMoreElements(); ) { + for (Iterator spm = simplePageMasters.values().iterator(); + spm.hasNext(); ) { SimplePageMaster simplePageMaster = - (SimplePageMaster)spm.nextElement(); - Hashtable spmRegions = simplePageMaster.getRegions(); - for (Enumeration e = spmRegions.elements(); - e.hasMoreElements(); ) { - Region region = (Region)e.nextElement(); + (SimplePageMaster)spm.next(); + HashMap spmRegions = simplePageMaster.getRegions(); + for (Iterator e = spmRegions.values().iterator(); + e.hasNext(); ) { + Region region = (Region)e.next(); if (allRegions.containsKey(region.getRegionName())) { String localClass = (String)allRegions.get(region.getRegionName()); @@ -138,16 +131,12 @@ public class LayoutMasterSet extends FObj { * @returns true when the region name specified has a region in this LayoutMasterSet */ protected boolean regionNameExists(String regionName) { - boolean result = false; - for (Enumeration e = simplePageMasters.elements(); - e.hasMoreElements(); ) { - result = - ((SimplePageMaster)e.nextElement()).regionNameExists(regionName); - if (result) { - return result; + for (Iterator i = simplePageMasters.values().iterator(); i.hasNext(); ) { + if (((SimplePageMaster)i.next()).regionNameExists(regionName)) { + return true; } } - return result; + return false; } } diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index 32e5990e6..18aef2e67 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -21,8 +21,8 @@ import org.apache.fop.layout.PageMaster; import org.apache.fop.apps.FOPException; // Java -import java.util.*; - +import java.util.HashMap; +import java.util.ArrayList; /** * This provides pagination of flows onto pages. Much of the logic for paginating @@ -71,7 +71,7 @@ public class PageSequence extends FObj { * Map of flows to their flow name (flow-name, Flow) * Does only contain flows for static content! */ - private Hashtable flowMap; + private HashMap flowMap; // according to communication from Paul Grosso (XSL-List, // 001228, Number 406), confusion in spec section 6.4.5 about @@ -124,7 +124,7 @@ public class PageSequence extends FObj { // best time to run some checks on LayoutMasterSet layoutMasterSet.checkRegionNames(); - flowMap = new Hashtable(); + flowMap = new HashMap(); String ipnValue = this.properties.get("initial-page-number").getString(); @@ -331,7 +331,7 @@ public class PageSequence extends FObj { Page newPage = this.currentSimplePageMaster.getPageMaster() .makePage(areaTree); if (currentPage != null) { - Vector foots = currentPage.getPendingFootnotes(); + ArrayList foots = currentPage.getPendingFootnotes(); newPage.setPendingFootnotes(foots); } newPage.setNumber(this.currentPageNumber); diff --git a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java index 2bb7c37c5..864129752 100644 --- a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -14,7 +14,7 @@ import org.apache.fop.layout.PageMaster; import org.apache.fop.apps.FOPException; // Java -import java.util.*; +import java.util.ArrayList; public class PageSequenceMaster extends FObj { @@ -30,11 +30,11 @@ public class PageSequenceMaster extends FObj { return new PageSequenceMaster.Maker(); } - LayoutMasterSet layoutMasterSet; - Vector subSequenceSpecifiers; + private LayoutMasterSet layoutMasterSet; + private ArrayList subSequenceSpecifiers; private SubSequenceSpecifier currentSubSequence; - int currentSubSequenceNumber; - String masterName; + private int currentSubSequenceNumber; + private String masterName; // The terminology may be confusing. A 'page-sequence-master' consists // of a sequence of what the XSL spec refers to as @@ -60,13 +60,13 @@ public class PageSequenceMaster extends FObj { + "of fo:layout-master-set, not " + parent.getName()); } - subSequenceSpecifiers = new Vector(); + subSequenceSpecifiers = new ArrayList(); currentSubSequenceNumber = -1; currentSubSequence = null; } protected void addSubsequenceSpecifier(SubSequenceSpecifier pageMasterReference) { - subSequenceSpecifiers.addElement(pageMasterReference); + subSequenceSpecifiers.add(pageMasterReference); } protected SubSequenceSpecifier getNextSubSequence() { @@ -74,7 +74,7 @@ public class PageSequenceMaster extends FObj { if (currentSubSequenceNumber >= 0 && currentSubSequenceNumber < subSequenceSpecifiers.size()) { return (SubSequenceSpecifier)subSequenceSpecifiers - .elementAt(currentSubSequenceNumber); + .get(currentSubSequenceNumber); } return null; } @@ -82,9 +82,8 @@ public class PageSequenceMaster extends FObj { public void reset() { currentSubSequenceNumber = -1; currentSubSequence = null; - for (Enumeration e = subSequenceSpecifiers.elements(); - e.hasMoreElements(); ) { - ((SubSequenceSpecifier)e.nextElement()).reset(); + for (int i = 0; i< subSequenceSpecifiers.size(); i++ ) { + ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset(); } } @@ -109,12 +108,12 @@ public class PageSequenceMaster extends FObj { if (nextSubSequence==null) { if (!canRecover) { throw new FOPException("subsequences exhausted in page-sequence-master '" - +masterName - +"', cannot recover"); + + masterName + + "', cannot recover"); } log.warn("subsequences exhausted in page-sequence-master '" - +masterName - +"', use previous subsequence"); + + masterName + + "', use previous subsequence"); currentSubSequence.reset(); canRecover = false; } else { diff --git a/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index f29add4c2..cd6d39399 100644 --- a/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java @@ -11,7 +11,7 @@ import org.apache.fop.fo.*; import org.apache.fop.apps.FOPException; // Java -import java.util.Vector; +import java.util.ArrayList; public class RepeatablePageMasterAlternatives extends FObj implements SubSequenceSpecifier { @@ -40,7 +40,7 @@ public class RepeatablePageMasterAlternatives extends FObj private int maximumRepeats; private int numberConsumed = 0; - private Vector conditionalPageMasterRefs; + private ArrayList conditionalPageMasterRefs; public RepeatablePageMasterAlternatives(FObj parent, PropertyList propertyList) throws FOPException { @@ -70,7 +70,7 @@ public class RepeatablePageMasterAlternatives extends FObj + "'maximum-repeats' property"); } } - conditionalPageMasterRefs = new Vector(); + conditionalPageMasterRefs = new ArrayList(); } public String getName() { @@ -78,7 +78,7 @@ public class RepeatablePageMasterAlternatives extends FObj } public void addConditionalPageMasterReference(ConditionalPageMasterReference cpmr) { - this.conditionalPageMasterRefs.addElement(cpmr); + this.conditionalPageMasterRefs.add(cpmr); } public String getNextPageMasterName(boolean isOddPage, @@ -94,8 +94,7 @@ public class RepeatablePageMasterAlternatives extends FObj for (int i = 0; i < conditionalPageMasterRefs.size(); i++) { ConditionalPageMasterReference cpmr = - (ConditionalPageMasterReference)conditionalPageMasterRefs - .elementAt(i); + (ConditionalPageMasterReference)conditionalPageMasterRefs.get(i); if (cpmr.isValid(isOddPage, isFirstPage, isEmptyPage)) { return cpmr.getMasterName(); } diff --git a/src/org/apache/fop/fo/pagination/Root.java b/src/org/apache/fop/fo/pagination/Root.java index 07c7434a6..bf8e1b7b0 100644 --- a/src/org/apache/fop/fo/pagination/Root.java +++ b/src/org/apache/fop/fo/pagination/Root.java @@ -15,10 +15,6 @@ import org.apache.fop.layout.AreaTree; import org.apache.fop.apps.FOPException; import org.apache.fop.extensions.ExtensionObj; -// Java -import java.util.Vector; -import java.util.Enumeration; - /** * The fo:root formatting object. Contains page masters, root extensions, * page-sequences. diff --git a/src/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/org/apache/fop/fo/pagination/SimplePageMaster.java index c6600d1f3..b5f34440a 100644 --- a/src/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -16,7 +16,8 @@ import org.apache.fop.layout.BodyRegionArea; import org.apache.fop.layout.MarginProps; import org.apache.fop.apps.FOPException; -import java.util.*; +import java.util.HashMap; +import java.util.Iterator; public class SimplePageMaster extends FObj { @@ -35,7 +36,7 @@ public class SimplePageMaster extends FObj { /** * Page regions (regionClass, Region) */ - private Hashtable _regions; + private HashMap _regions; LayoutMasterSet layoutMasterSet; @@ -65,7 +66,7 @@ public class SimplePageMaster extends FObj { + "of fo:layout-master-set, not " + parent.getName()); } - _regions = new Hashtable(); + _regions = new HashMap(); } @@ -169,20 +170,18 @@ public class SimplePageMaster extends FObj { return (Region)_regions.get(regionClass); } - protected Hashtable getRegions() { + protected HashMap getRegions() { return _regions; } protected boolean regionNameExists(String regionName) { - for (Enumeration regenum = _regions.elements(); - regenum.hasMoreElements(); ) { - Region r = (Region)regenum.nextElement(); + for (Iterator i = _regions.values().iterator(); i.hasNext(); ) { + Region r = (Region)i.next(); if (r.getRegionName().equals(regionName)) { return true; } } return false; - } } diff --git a/src/org/apache/fop/fonts/PFMFile.java b/src/org/apache/fop/fonts/PFMFile.java index cf1c7e8d7..4e438cb54 100644 --- a/src/org/apache/fop/fonts/PFMFile.java +++ b/src/org/apache/fop/fonts/PFMFile.java @@ -8,7 +8,7 @@ package org.apache.fop.fonts; import java.io.*; -import java.util.Hashtable; +import java.util.HashMap; /** * This class represents a PFM file (or parts of it) as a Java object. @@ -42,9 +42,9 @@ public class PFMFile { // Extent table private int[] extentTable; - private Hashtable kerningTab; + private HashMap kerningTab; public PFMFile() { - kerningTab = new Hashtable(); + kerningTab = new HashMap(); } /** @@ -160,9 +160,9 @@ public class PFMFile { String glyph1 = Glyphs.tex8r[g1]; String glyph2 = Glyphs.tex8r[g2]; - Hashtable adjTab = (Hashtable)kerningTab.get(new Integer(g1)); + HashMap adjTab = (HashMap)kerningTab.get(new Integer(g1)); if (adjTab == null) - adjTab = new Hashtable(); + adjTab = new HashMap(); adjTab.put(new Integer(g2), new Integer(adj)); kerningTab.put(new Integer(g1), adjTab); } @@ -208,11 +208,11 @@ public class PFMFile { } /** - * Return the kerning table. The kerning table is a hastable with - * strings with glyphnames as keys, containing hashtables as value. - * The value hashtable contain a glyph name string key and an Integer value + * Return the kerning table. The kerning table is a hashmap with + * strings with glyphnames as keys, containing hashmaps as value. + * The value hashmaps contain a glyph name string key and an Integer value */ - public Hashtable getKerning() { + public HashMap getKerning() { return kerningTab; } diff --git a/src/org/apache/fop/fonts/TTFFile.java b/src/org/apache/fop/fonts/TTFFile.java index b587da1a3..65dca5b5a 100644 --- a/src/org/apache/fop/fonts/TTFFile.java +++ b/src/org/apache/fop/fonts/TTFFile.java @@ -6,10 +6,11 @@ */ package org.apache.fop.fonts; + import java.io.*; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; /** * Reads a TrueType file or a TrueType Collection. @@ -26,11 +27,11 @@ public class TTFFile { short firstChar = 0; boolean is_embeddable = true; boolean hasSerifs = true; - Hashtable dirTabs; // Table directory - Hashtable kerningTab; // for CIDs - Hashtable ansiKerningTab; // For winAnsiEncoding - Vector cmaps; - Vector unicodeMapping; // + HashMap dirTabs; // Table directory + HashMap kerningTab; // for CIDs + HashMap ansiKerningTab; // For winAnsiEncoding + ArrayList cmaps; + ArrayList unicodeMapping; // int upem; // unitsPerEm from "head" table int nhmtx; // Number of horizontal metrics @@ -65,7 +66,7 @@ public class TTFFile { short lastChar = 0; int ansiWidth[]; - Hashtable ansiIndex; + HashMap ansiIndex; /** * Position inputstream to position indicated @@ -107,11 +108,11 @@ public class TTFFile { * return false if the table is not present or only unsupported * tables are present. Currently only unicode cmaps are supported. * Set the unicodeIndex in the TTFMtxEntries and fills in the - * cmaps vector. + * cmaps ArrayList. */ private boolean readCMAP(FontFileReader in) throws IOException { - unicodeMapping = new Vector(); + unicodeMapping = new ArrayList(); /** * Read CMAP table and correct mtx_tab.index @@ -193,7 +194,7 @@ public class TTFFile { int glyphIdArrayOffset = in.getCurrentPos(); // Insert the unicode id for the glyphs in mtx_tab - // and fill in the cmaps Vector + // and fill in the cmaps ArrayList for (int i = 0; i < cmap_startCounts.length; i++) { /* @@ -218,19 +219,14 @@ public class TTFFile { glyphIdx = (in.readTTFUShort() + cmap_deltas[i]) & 0xffff; - unicodeMapping.addElement(new UnicodeMapping(glyphIdx, - j)); - mtx_tab[glyphIdx].unicodeIndex.addElement(new Integer(j)); - - + unicodeMapping.add(new UnicodeMapping(glyphIdx, j)); + mtx_tab[glyphIdx].unicodeIndex.add(new Integer(j)); // Also add winAnsiWidth - Vector v = - (Vector)ansiIndex.get(new Integer(j)); + ArrayList v = + (ArrayList)ansiIndex.get(new Integer(j)); if (v != null) { - for (Enumeration e = v.elements(); - e.hasMoreElements(); ) { - Integer aIdx = - (Integer)e.nextElement(); + for (int k = 0; k < v.size(); k++ ) { + Integer aIdx = (Integer)v.get(k); ansiWidth[aIdx.intValue()] = mtx_tab[glyphIdx].wx; /* @@ -255,16 +251,16 @@ public class TTFFile { glyphIdx = (j + cmap_deltas[i]) & 0xffff; if (glyphIdx < mtx_tab.length) - mtx_tab[glyphIdx].unicodeIndex.addElement(new Integer(j)); + mtx_tab[glyphIdx].unicodeIndex.add(new Integer(j)); else System.out.println("Glyph " + glyphIdx + " out of range: " + mtx_tab.length); - unicodeMapping.addElement(new UnicodeMapping(glyphIdx, + unicodeMapping.add(new UnicodeMapping(glyphIdx, j)); if (glyphIdx < mtx_tab.length) - mtx_tab[glyphIdx].unicodeIndex.addElement(new Integer(j)); + mtx_tab[glyphIdx].unicodeIndex.add(new Integer(j)); else System.out.println("Glyph " + glyphIdx + " out of range: " @@ -273,13 +269,11 @@ public class TTFFile { // Also add winAnsiWidth - Vector v = - (Vector)ansiIndex.get(new Integer(j)); + ArrayList v = + (ArrayList)ansiIndex.get(new Integer(j)); if (v != null) { - for (Enumeration e = v.elements(); - e.hasMoreElements(); ) { - Integer aIdx = - (Integer)e.nextElement(); + for (int k = 0; k < v.size(); k++ ) { + Integer aIdx = (Integer)v.get(k); ansiWidth[aIdx.intValue()] = mtx_tab[glyphIdx].wx; } @@ -340,17 +334,17 @@ public class TTFFile { // Create an index hash to the ansiWidth // Can't just index the winAnsiEncoding when inserting widths // same char (eg bullet) is repeated more than one place - ansiIndex = new Hashtable(); + ansiIndex = new HashMap(); for (int i = 32; i < Glyphs.winAnsiEncoding.length; i++) { Integer ansi = new Integer(i); Integer uni = new Integer((int)Glyphs.winAnsiEncoding[i]); - Vector v = (Vector)ansiIndex.get(uni); + ArrayList v = (ArrayList)ansiIndex.get(uni); if (v == null) { - v = new Vector(); + v = new ArrayList(); ansiIndex.put(uni, v); } - v.addElement(ansi); + v.add(ansi); } } @@ -391,22 +385,21 @@ public class TTFFile { } private void createCMaps() { - cmaps = new Vector(); + cmaps = new ArrayList(); TTFCmapEntry tce = new TTFCmapEntry(); - Enumeration e = unicodeMapping.elements(); - UnicodeMapping um = (UnicodeMapping)e.nextElement(); + UnicodeMapping um = (UnicodeMapping)unicodeMapping.get(0); UnicodeMapping lastMapping = um; tce.unicodeStart = um.uIdx; tce.glyphStartIndex = um.gIdx; - while (e.hasMoreElements()) { - um = (UnicodeMapping)e.nextElement(); + for (int i = 1; i< unicodeMapping.size(); i++) { + um = (UnicodeMapping)unicodeMapping.get(i); if (((lastMapping.uIdx + 1) != um.uIdx) || ((lastMapping.gIdx + 1) != um.gIdx)) { tce.unicodeEnd = lastMapping.uIdx; - cmaps.addElement(tce); + cmaps.add(tce); tce = new TTFCmapEntry(); tce.unicodeStart = um.uIdx; @@ -416,7 +409,7 @@ public class TTFFile { } tce.unicodeEnd = um.uIdx; - cmaps.addElement(tce); + cmaps.add(tce); } public void printStuff() { @@ -556,11 +549,11 @@ public class TTFFile { return (int)get_ttf_funit(ansiWidth[idx]); } - public Hashtable getKerning() { + public HashMap getKerning() { return kerningTab; } - public Hashtable getAnsiKerning() { + public HashMap getAnsiKerning() { return ansiKerningTab; } @@ -571,7 +564,7 @@ public class TTFFile { /** * Read Table Directory from the current position in the - * FontFileReader and fill the global Hashtable dirTabs + * FontFileReader and fill the global HashMap dirTabs * with the table name (String) as key and a TTFDirTabEntry * as value. */ @@ -580,7 +573,7 @@ public class TTFFile { int ntabs = in.readTTFUShort(); in.skip(6); // 3xTTF_USHORT_SIZE - dirTabs = new Hashtable(); + dirTabs = new HashMap(); TTFDirTabEntry[] pd = new TTFDirTabEntry[ntabs]; // System.out.println("Reading " + ntabs + " dir tables"); for (int i = 0; i < ntabs; i++) { @@ -911,8 +904,8 @@ public class TTFFile { */ private final void readKerning(FontFileReader in) throws IOException { // Read kerning - kerningTab = new Hashtable(); - ansiKerningTab = new Hashtable(); + kerningTab = new HashMap(); + ansiKerningTab = new HashMap(); TTFDirTabEntry dirTab = (TTFDirTabEntry)dirTabs.get("kern"); if (dirTab != null) { seek_tab(in, "kern", 2); @@ -933,9 +926,9 @@ public class TTFFile { if (kpx != 0) { // CID table Integer iObj = new Integer(i); - Hashtable adjTab = (Hashtable)kerningTab.get(iObj); + HashMap adjTab = (HashMap)kerningTab.get(iObj); if (adjTab == null) - adjTab = new java.util.Hashtable(); + adjTab = new HashMap(); adjTab.put(new Integer(j), new Integer((int)get_ttf_funit(kpx))); kerningTab.put(iObj, adjTab); @@ -946,18 +939,18 @@ public class TTFFile { // Create winAnsiEncoded kerning table - for (Enumeration ae = kerningTab.keys(); ae.hasMoreElements(); ) { - Integer cidKey = (Integer)ae.nextElement(); - Hashtable akpx = new Hashtable(); - Hashtable ckpx = (Hashtable)kerningTab.get(cidKey); + for (Iterator ae = kerningTab.keySet().iterator(); ae.hasNext(); ) { + Integer cidKey = (Integer)ae.next(); + HashMap akpx = new HashMap(); + HashMap ckpx = (HashMap)kerningTab.get(cidKey); - for (Enumeration aee = ckpx.keys(); aee.hasMoreElements(); ) { - Integer cidKey2 = (Integer)aee.nextElement(); + for (Iterator aee = ckpx.keySet().iterator(); aee.hasNext(); ) { + Integer cidKey2 = (Integer)aee.next(); Integer kern = (Integer)ckpx.get(cidKey2); - for (Enumeration uniMap = mtx_tab[cidKey2.intValue()].unicodeIndex.elements(); - uniMap.hasMoreElements(); ) { - Integer unicodeKey = (Integer)uniMap.nextElement(); + ArrayList unicodeIndex = mtx_tab[cidKey2.intValue()].unicodeIndex; + for (int i = 0; i < unicodeIndex.size(); i++) { + Integer unicodeKey = (Integer)unicodeIndex.get(i); Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey.intValue()); for (int u = 0; u < ansiKeys.length; u++) { @@ -966,24 +959,25 @@ public class TTFFile { } } - if (akpx.size() > 0) - for (Enumeration uniMap = mtx_tab[cidKey.intValue()].unicodeIndex.elements(); - uniMap.hasMoreElements(); ) { - Integer unicodeKey = (Integer)uniMap.nextElement(); + if (akpx.size() > 0) { + ArrayList unicodeIndex = mtx_tab[cidKey.intValue()].unicodeIndex; + for (int i = 0; i< unicodeIndex.size(); i++) { + Integer unicodeKey = (Integer)unicodeIndex.get(i); Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey.intValue()); for (int u = 0; u < ansiKeys.length; u++) { ansiKerningTab.put(ansiKeys[u], akpx); } } + } } } } /** - * Return a vector with TTFCmapEntry + * Return a ArrayList with TTFCmapEntry */ - public Vector getCMaps() { + public ArrayList getCMaps() { return cmaps; } @@ -1060,12 +1054,12 @@ public class TTFFile { * doesn't matter... */ private Integer[] unicodeToWinAnsi(int unicode) { - Vector ret = new Vector(); + ArrayList ret = new ArrayList(); for (int i = 32; i < Glyphs.winAnsiEncoding.length; i++) if (unicode == Glyphs.winAnsiEncoding[i]) - ret.addElement(new Integer(i)); + ret.add(new Integer(i)); Integer[] itg = new Integer[ret.size()]; - ret.copyInto(itg); + ret.toArray(itg); return itg; } diff --git a/src/org/apache/fop/fonts/TTFMtxEntry.java b/src/org/apache/fop/fonts/TTFMtxEntry.java index 286593c04..67451d447 100644 --- a/src/org/apache/fop/fonts/TTFMtxEntry.java +++ b/src/org/apache/fop/fonts/TTFMtxEntry.java @@ -8,14 +8,14 @@ package org.apache.fop.fonts; import java.io.*; -import java.util.Vector; +import java.util.ArrayList; class TTFMtxEntry { int wx; int lsb; String name; int index; - Vector unicodeIndex; + ArrayList unicodeIndex; int[] bbox; long offset; byte found; @@ -23,7 +23,7 @@ class TTFMtxEntry { TTFMtxEntry() { name = ""; found = 0; - unicodeIndex = new Vector(); + unicodeIndex = new ArrayList(); bbox = new int[4]; } diff --git a/src/org/apache/fop/fonts/TTFSubSetFile.java b/src/org/apache/fop/fonts/TTFSubSetFile.java index 149f78290..20ed519e3 100644 --- a/src/org/apache/fop/fonts/TTFSubSetFile.java +++ b/src/org/apache/fop/fonts/TTFSubSetFile.java @@ -6,12 +6,14 @@ */ package org.apache.fop.fonts; -import java.io.*; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; + import org.apache.fop.messaging.MessageHandler; +import java.io.*; +import java.util.Iterator; +import java.util.HashMap; +import java.util.ArrayList; + /** * Reads a TrueType file and generates a subset * That can be used to embed a TrueType CID font @@ -300,7 +302,7 @@ public class TTFSubSetFile extends TTFFile { * Create the glyf table and fill in loca table */ private void createGlyf(FontFileReader in, - Hashtable glyphs) throws IOException { + HashMap glyphs) throws IOException { TTFDirTabEntry entry = (TTFDirTabEntry)dirTabs.get("glyf"); int size = 0; int start = 0; @@ -309,9 +311,9 @@ public class TTFSubSetFile extends TTFFile { pad4(); start = currentPos; - for (Enumeration e = glyphs.keys(); e.hasMoreElements(); ) { + for (Iterator e = glyphs.keySet().iterator(); e.hasNext(); ) { int glyphLength = 0; - Integer origIndex = (Integer)e.nextElement(); + Integer origIndex = (Integer)e.next(); Integer subsetIndex = (Integer)glyphs.get(origIndex); int nextOffset = 0; @@ -362,12 +364,12 @@ public class TTFSubSetFile extends TTFFile { /** * Create the hmtx table by copying metrics from original - * font to subset font. The glyphs hashtable contains an + * font to subset font. The glyphs HashMap contains an * Integer key and Integer value that maps the original * metric (key) to the subset metric (value) */ private void createHmtx(FontFileReader in, - Hashtable glyphs) throws IOException { + HashMap glyphs) throws IOException { TTFDirTabEntry entry = (TTFDirTabEntry)dirTabs.get("hmtx"); int longHorMetricSize = glyphs.size() * 2; @@ -377,8 +379,8 @@ public class TTFSubSetFile extends TTFFile { if (entry != null) { pad4(); int offset = (int)entry.offset; - for (Enumeration e = glyphs.keys(); e.hasMoreElements(); ) { - Integer origIndex = (Integer)e.nextElement(); + for (Iterator e = glyphs.keySet().iterator(); e.hasNext(); ) { + Integer origIndex = (Integer)e.next(); Integer subsetIndex = (Integer)glyphs.get(origIndex); writeUShort(currentPos + subsetIndex.intValue() * 4, @@ -399,13 +401,13 @@ public class TTFSubSetFile extends TTFFile { } /** - * Returns a Vector containing the glyph itself plus all glyphs + * Returns a ArrayList containing the glyph itself plus all glyphs * that this composite glyph uses */ - private Vector getIncludedGlyphs(FontFileReader in, int glyphOffset, + private ArrayList getIncludedGlyphs(FontFileReader in, int glyphOffset, Integer glyphIdx) throws IOException { - Vector ret = new Vector(); - ret.addElement(glyphIdx); + ArrayList ret = new ArrayList(); + ret.add(glyphIdx); int offset = glyphOffset + (int)mtx_tab[glyphIdx.intValue()].offset + 10; Integer compositeIdx = null; @@ -414,7 +416,7 @@ public class TTFSubSetFile extends TTFFile { while (moreComposites) { flags = in.readTTFUShort(offset); compositeIdx = new Integer(in.readTTFUShort(offset + 2)); - ret.addElement(compositeIdx); + ret.add(compositeIdx); offset += 4; if ((flags & 1) > 0) { @@ -445,7 +447,7 @@ public class TTFSubSetFile extends TTFFile { * Rewrite all compositepointers in glyphindex glyphIdx * */ - private void remapComposite(FontFileReader in, Hashtable glyphs, + private void remapComposite(FontFileReader in, HashMap glyphs, int glyphOffset, Integer glyphIdx) throws IOException { int offset = glyphOffset + (int)mtx_tab[glyphIdx.intValue()].offset @@ -503,38 +505,36 @@ public class TTFSubSetFile extends TTFFile { * mapping */ private void scanGlyphs(FontFileReader in, - Hashtable glyphs) throws IOException { + HashMap glyphs) throws IOException { TTFDirTabEntry entry = (TTFDirTabEntry)dirTabs.get("glyf"); - Hashtable newComposites = null; - Hashtable allComposites = new Hashtable(); + HashMap newComposites = null; + HashMap allComposites = new HashMap(); int newIndex = glyphs.size(); if (entry != null) { while (newComposites == null || newComposites.size() > 0) { // Inefficient to iterate through all glyphs - newComposites = new Hashtable(); + newComposites = new HashMap(); - for (Enumeration e = glyphs.keys(); e.hasMoreElements(); ) { - Integer origIndex = (Integer)e.nextElement(); + for (Iterator e = glyphs.keySet().iterator(); e.hasNext(); ) { + Integer origIndex = (Integer)e.next(); if (in.readTTFShort(entry.offset + mtx_tab[origIndex.intValue()].offset) < 0) { // origIndex is a composite glyph allComposites.put(origIndex, glyphs.get(origIndex)); - Vector composites = + ArrayList composites = getIncludedGlyphs(in, (int)entry.offset, origIndex); // Iterate through all composites pointed to // by this composite and check if they exists // in the glyphs map, add them if not. - for (Enumeration cps = composites.elements(); - cps.hasMoreElements(); ) { - - Integer cIdx = (Integer)cps.nextElement(); + for (int i = 0; i < composites.size(); i++ ) { + Integer cIdx = (Integer)composites.get(i); if (glyphs.get(cIdx) == null - && newComposites.get(cIdx) == null) { + && newComposites.get(cIdx) == null) { newComposites.put(cIdx, new Integer(newIndex)); newIndex++; @@ -544,23 +544,21 @@ public class TTFSubSetFile extends TTFFile { } // Add composites to glyphs - for (Enumeration m = newComposites.keys(); - m.hasMoreElements(); ) { - Integer im = (Integer)m.nextElement(); + for (Iterator m = newComposites.keySet().iterator(); m.hasNext(); ) { + Integer im = (Integer)m.next(); glyphs.put(im, newComposites.get(im)); } } // Iterate through all composites to remap their composite index - for (Enumeration ce = allComposites.keys(); - ce.hasMoreElements(); ) { + for (Iterator ce = allComposites.keySet().iterator(); ce.hasNext(); ) { remapComposite(in, glyphs, (int)entry.offset, - (Integer)ce.nextElement()); + (Integer)ce.next()); } } else { - throw new IOException("Can't find glyf table"); + throw new IOException("Can't find glyph table"); } } @@ -572,7 +570,7 @@ public class TTFSubSetFile extends TTFFile { */ public byte[] readFont(FontFileReader in, String name, - Hashtable glyphs) throws IOException { + HashMap glyphs) throws IOException { /* * Check if TrueType collection, and that the name diff --git a/src/org/apache/fop/fonts/apps/PFMReader.java b/src/org/apache/fop/fonts/apps/PFMReader.java index 8a7148e9c..1e3197b7e 100644 --- a/src/org/apache/fop/fonts/apps/PFMReader.java +++ b/src/org/apache/fop/fonts/apps/PFMReader.java @@ -9,9 +9,9 @@ package org.apache.fop.fonts.apps; import java.io.*; import org.w3c.dom.*; import org.apache.fop.fonts.*; -import java.util.Hashtable; -import java.util.Vector; -import java.util.Enumeration; +import java.util.HashMap; +import java.util.ArrayList; +import java.util.Iterator; /** * A tool which reads PFM files from Adobe Type 1 fonts and creates @@ -26,14 +26,14 @@ public class PFMReader { /** - * Parse commandline arguments. put options in the Hashtable and return + * Parse commandline arguments. put options in the HashMap and return * arguments in the String array * the arguments: -fn Perpetua,Bold -cn PerpetuaBold per.ttf Perpetua.xml * returns a String[] with the per.ttf and Perpetua.xml. The hash * will have the (key, value) pairs: (-fn, Perpetua) and (-cn, PerpetuaBold) */ - private static String[] parseArguments(Hashtable options, String[] args) { - Vector arguments = new Vector(); + private static String[] parseArguments(HashMap options, String[] args) { + ArrayList arguments = new ArrayList(); for (int i = 0; i < args.length; i++) { if (args[i].startsWith("-")) { if ((i + 1) < args.length &&!args[i + 1].startsWith("-")) { @@ -43,12 +43,12 @@ public class PFMReader { options.put(args[i], ""); } } else { - arguments.addElement(args[i]); + arguments.add(args[i]); } } String[] argStrings = new String[arguments.size()]; - arguments.copyInto(argStrings); + arguments.toArray(argStrings); return argStrings; } @@ -88,7 +88,7 @@ public class PFMReader { String className = null; String fontName = null; - Hashtable options = new Hashtable(); + HashMap options = new HashMap(); String[] arguments = parseArguments(options, args); PFMReader app = new PFMReader(); @@ -330,17 +330,16 @@ public class PFMReader { // Get kerning - for (Enumeration enum = pfm.getKerning().keys(); - enum.hasMoreElements(); ) { - Integer kpx1 = (Integer)enum.nextElement(); + for (Iterator enum = pfm.getKerning().keySet().iterator(); enum.hasNext(); ) { + Integer kpx1 = (Integer)enum.next(); el = doc.createElement("kerning"); el.setAttribute("kpx1", kpx1.toString()); root.appendChild(el); Element el2 = null; - Hashtable h2 = (Hashtable)pfm.getKerning().get(kpx1); - for (Enumeration enum2 = h2.keys(); enum2.hasMoreElements(); ) { - Integer kpx2 = (Integer)enum2.nextElement(); + HashMap h2 = (HashMap)pfm.getKerning().get(kpx1); + for (Iterator enum2 = h2.keySet().iterator(); enum2.hasNext(); ) { + Integer kpx2 = (Integer)enum2.next(); el2 = doc.createElement("pair"); el2.setAttribute("kpx2", kpx2.toString()); Integer val = (Integer)h2.get(kpx2); diff --git a/src/org/apache/fop/fonts/apps/TTFReader.java b/src/org/apache/fop/fonts/apps/TTFReader.java index 584f74c88..03b6f18a1 100644 --- a/src/org/apache/fop/fonts/apps/TTFReader.java +++ b/src/org/apache/fop/fonts/apps/TTFReader.java @@ -9,9 +9,9 @@ package org.apache.fop.fonts.apps; import java.io.*; import org.w3c.dom.*; import org.apache.fop.fonts.*; -import java.util.Hashtable; -import java.util.Vector; -import java.util.Enumeration; +import java.util.HashMap; +import java.util.ArrayList; +import java.util.Iterator; /** * A tool which reads TTF files and generates @@ -26,14 +26,14 @@ public class TTFReader { /** - * Parse commandline arguments. put options in the Hashtable and return + * Parse commandline arguments. put options in the HashMap and return * arguments in the String array * the arguments: -fn Perpetua,Bold -cn PerpetuaBold per.ttf Perpetua.xml * returns a String[] with the per.ttf and Perpetua.xml. The hash * will have the (key, value) pairs: (-fn, Perpetua) and (-cn, PerpetuaBold) */ - private static String[] parseArguments(Hashtable options, String[] args) { - Vector arguments = new Vector(); + private static String[] parseArguments(HashMap options, String[] args) { + ArrayList arguments = new ArrayList(); for (int i = 0; i < args.length; i++) { if (args[i].startsWith("-")) { if ((i + 1) < args.length &&!args[i + 1].startsWith("-")) { @@ -43,12 +43,12 @@ public class TTFReader { options.put(args[i], ""); } } else { - arguments.addElement(args[i]); + arguments.add(args[i]); } } String[] argStrings = new String[arguments.size()]; - arguments.copyInto(argStrings); + arguments.toArray(argStrings); return argStrings; } @@ -103,7 +103,7 @@ public class TTFReader { String ttcName = null; boolean isCid = true; - Hashtable options = new Hashtable(); + HashMap options = new HashMap(); String[] arguments = parseArguments(options, args); TTFReader app = new TTFReader(); @@ -328,9 +328,9 @@ public class TTFReader { el = doc.createElement("bfranges"); mel.appendChild(el); - for (Enumeration e = ttf.getCMaps().elements(); - e.hasMoreElements(); ) { - TTFCmapEntry ce = (TTFCmapEntry)e.nextElement(); + ArrayList cmaps = ttf.getCMaps(); + for (int i = 0;i < cmaps.size(); i++) { + TTFCmapEntry ce = (TTFCmapEntry)cmaps.get(i); Element el2 = doc.createElement("bf"); el.appendChild(el2); el2.setAttribute("us", String.valueOf(ce.unicodeStart)); @@ -379,28 +379,28 @@ public class TTFReader { } // Get kerning - Enumeration enum; + Iterator enum; if (isCid) - enum = ttf.getKerning().keys(); + enum = ttf.getKerning().keySet().iterator(); else - enum = ttf.getAnsiKerning().keys(); + enum = ttf.getAnsiKerning().keySet().iterator(); - while (enum.hasMoreElements()) { - Integer kpx1 = (Integer)enum.nextElement(); + while (enum.hasNext()) { + Integer kpx1 = (Integer)enum.next(); el = doc.createElement("kerning"); el.setAttribute("kpx1", kpx1.toString()); root.appendChild(el); Element el2 = null; - Hashtable h2; + HashMap h2; if (isCid) - h2 = (Hashtable)ttf.getKerning().get(kpx1); + h2 = (HashMap)ttf.getKerning().get(kpx1); else - h2 = (Hashtable)ttf.getAnsiKerning().get(kpx1); + h2 = (HashMap)ttf.getAnsiKerning().get(kpx1); - for (Enumeration enum2 = h2.keys(); enum2.hasMoreElements(); ) { - Integer kpx2 = (Integer)enum2.nextElement(); + for (Iterator enum2 = h2.keySet().iterator(); enum2.hasNext(); ) { + Integer kpx2 = (Integer)enum2.next(); if (isCid || kpx2.intValue() < 256) { el2 = doc.createElement("pair"); el2.setAttribute("kpx2", kpx2.toString()); diff --git a/src/org/apache/fop/image/AbstractFopImage.java b/src/org/apache/fop/image/AbstractFopImage.java index e37516287..fbabe05dc 100644 --- a/src/org/apache/fop/image/AbstractFopImage.java +++ b/src/org/apache/fop/image/AbstractFopImage.java @@ -7,10 +7,6 @@ package org.apache.fop.image; -// Java -import java.util.Hashtable; -import java.net.URL; - // FOP import org.apache.fop.datatypes.ColorSpace; import org.apache.fop.pdf.PDFColor; @@ -18,6 +14,9 @@ import org.apache.fop.pdf.PDFFilter; import org.apache.fop.image.analyser.ImageReaderFactory; import org.apache.fop.image.analyser.ImageReader; +// Java +import java.net.URL; + /** * Base class to implement the FopImage interface. * @author Eric SCHAEFFER diff --git a/src/org/apache/fop/image/FopImageConsumer.java b/src/org/apache/fop/image/FopImageConsumer.java index 972db183d..a92c20d8b 100644 --- a/src/org/apache/fop/image/FopImageConsumer.java +++ b/src/org/apache/fop/image/FopImageConsumer.java @@ -10,13 +10,13 @@ package org.apache.fop.image; -// Java -import java.util.Hashtable; import org.apache.fop.messaging.MessageHandler; -import java.awt.image.*; -import java.awt.*; +// Java +import java.awt.*; +import java.awt.image.*; import java.lang.reflect.Array; +import java.util.Hashtable; // CONSUMER CLASS public class FopImageConsumer implements ImageConsumer { diff --git a/src/org/apache/fop/image/FopImageFactory.java b/src/org/apache/fop/image/FopImageFactory.java index 305bc35d1..b2f105dc8 100644 --- a/src/org/apache/fop/image/FopImageFactory.java +++ b/src/org/apache/fop/image/FopImageFactory.java @@ -7,6 +7,11 @@ package org.apache.fop.image; +// FOP +import org.apache.fop.image.analyser.ImageReaderFactory; +import org.apache.fop.image.analyser.ImageReader; +import org.apache.fop.configuration.Configuration; + // Java import java.io.IOException; import java.io.InputStream; @@ -14,12 +19,7 @@ import java.io.File; import java.net.URL; import java.net.MalformedURLException; import java.lang.reflect.Constructor; -import java.util.Hashtable; - -// FOP -import org.apache.fop.image.analyser.ImageReaderFactory; -import org.apache.fop.image.analyser.ImageReader; -import org.apache.fop.configuration.Configuration; +import java.util.HashMap; /** * create FopImage objects (with a configuration file - not yet implemented). @@ -27,7 +27,7 @@ import org.apache.fop.configuration.Configuration; */ public class FopImageFactory { - private static Hashtable m_urlMap = new Hashtable(); + private static HashMap m_urlMap = new HashMap(); /** * create an FopImage objects. @@ -36,7 +36,7 @@ public class FopImageFactory { * @exception java.net.MalformedURLException bad URL * @exception FopImageException an error occured during construction */ - public static FopImage Make(String href) + public static synchronized FopImage Make(String href) throws MalformedURLException, FopImageException { /* @@ -84,7 +84,7 @@ public class FopImageFactory { URL context_url = null; String base = Configuration.getStringValue("baseDir"); - if(base == null) { + if (base == null) { throw new FopImageException("Error with image URL: " + e.getMessage() + " and no base directory is specified"); @@ -100,7 +100,7 @@ public class FopImageFactory { } } - // If not, check image type + // If not, check image type ImageReader imgReader = null; try { if (imgIS == null) { diff --git a/src/org/apache/fop/image/ImageArea.java b/src/org/apache/fop/image/ImageArea.java index 509ba92d4..dfc62fa81 100644 --- a/src/org/apache/fop/image/ImageArea.java +++ b/src/org/apache/fop/image/ImageArea.java @@ -13,9 +13,6 @@ import org.apache.fop.layout.inline.*; import org.apache.fop.render.Renderer; -import java.util.Vector; -import java.util.Enumeration; - public class ImageArea extends InlineArea { protected int xOffset = 0; diff --git a/src/org/apache/fop/image/analyser/ImageReaderFactory.java b/src/org/apache/fop/image/analyser/ImageReaderFactory.java index f2c2160b7..271f83a81 100644 --- a/src/org/apache/fop/image/analyser/ImageReaderFactory.java +++ b/src/org/apache/fop/image/analyser/ImageReaderFactory.java @@ -11,8 +11,7 @@ package org.apache.fop.image.analyser; import java.io.InputStream; import java.io.BufferedInputStream; import java.io.IOException; -import java.util.Enumeration; -import java.util.Vector; +import java.util.ArrayList; // FOP import org.apache.fop.image.FopImageException; @@ -23,7 +22,7 @@ import org.apache.fop.image.FopImageException; * @version 1.0 */ public class ImageReaderFactory { - static protected Vector formats = null; + static protected ArrayList formats = null; /** * ImageReader maker. @@ -36,22 +35,21 @@ public class ImageReaderFactory { InputStream in) throws FopImageException { // need to use a config file and remove static methods - formats = new Vector(); - formats.addElement(new JPEGReader()); - formats.addElement(new BMPReader()); - formats.addElement(new GIFReader()); - formats.addElement(new PNGReader()); - formats.addElement(new TIFFReader()); - formats.addElement(new EPSReader()); - formats.addElement(new SVGReader()); + formats = new ArrayList(); + formats.add(new JPEGReader()); + formats.add(new BMPReader()); + formats.add(new GIFReader()); + formats.add(new PNGReader()); + formats.add(new TIFFReader()); + formats.add(new EPSReader()); + formats.add(new SVGReader()); // ImageReader reader; BufferedInputStream bis = new BufferedInputStream(in); - Enumeration itr = formats.elements(); try { - while (itr.hasMoreElements()) { - reader = (ImageReader)itr.nextElement(); + for (int i = 0; i< formats.size(); i++) { + reader = (ImageReader)formats.get(i); if (reader.verifySignature(uri, bis)) { return reader; } diff --git a/src/org/apache/fop/layout/Area.java b/src/org/apache/fop/layout/Area.java index f4188e28f..6a0170a0f 100644 --- a/src/org/apache/fop/layout/Area.java +++ b/src/org/apache/fop/layout/Area.java @@ -13,8 +13,8 @@ import org.apache.fop.fo.flow.Marker; import org.apache.fop.layout.inline.InlineSpace; // Java -import java.util.Vector; -import java.util.Hashtable; +import java.util.ArrayList; +import java.util.HashMap; abstract public class Area extends Box { @@ -25,7 +25,7 @@ abstract public class Area extends Box { protected FontState fontState; protected BorderAndPadding bp = null; - protected Vector children = new Vector(); + protected ArrayList children = new ArrayList(); /* max size in line-progression-direction */ protected int maxHeight; @@ -52,11 +52,11 @@ abstract public class Area extends Box { private IDReferences idReferences; - protected Vector markers; + protected ArrayList markers; // as defined in Section 6.1.1 protected org.apache.fop.fo.FObj generatedBy; // corresponds to 'generated-by' trait - protected Hashtable returnedBy; + protected HashMap returnedBy; // as defined in Section 6.1.1 protected String areaClass; @@ -75,8 +75,8 @@ abstract public class Area extends Box { public Area(FontState fontState) { setFontState(fontState); - this.markers = new Vector(); - this.returnedBy = new Hashtable(); + this.markers = new ArrayList(); + this.returnedBy = new HashMap(); } /** @@ -93,8 +93,8 @@ abstract public class Area extends Box { this.allocationWidth = allocationWidth; this.contentRectangleWidth = allocationWidth; this.maxHeight = maxHeight; - this.markers = new Vector(); - this.returnedBy = new Hashtable(); + this.markers = new ArrayList(); + this.returnedBy = new HashMap(); } private void setFontState(FontState fontState) { @@ -103,12 +103,12 @@ abstract public class Area extends Box { } public void addChild(Box child) { - this.children.addElement(child); + this.children.add(child); child.parent = this; } public void addChildAtStart(Box child) { - this.children.insertElementAt(child, 0); + this.children.add(0, child); child.parent = this; } @@ -151,7 +151,7 @@ abstract public class Area extends Box { this.contentRectangleWidth = this.allocationWidth; } - public Vector getChildren() { + public ArrayList getChildren() { return this.children; } @@ -274,13 +274,13 @@ abstract public class Area extends Box { public void removeChild(Area area) { this.currentHeight -= area.getHeight(); this.absoluteHeight -= area.getHeight(); - this.children.removeElement(area); + this.children.remove(area); } public void removeChild(DisplaySpace spacer) { this.currentHeight -= spacer.getSize(); this.absoluteHeight -= spacer.getSize(); - this.children.removeElement(spacer); + this.children.remove(spacer); } public void remove() { @@ -372,10 +372,10 @@ abstract public class Area extends Box { } public void addMarker(Marker marker) { - markers.addElement(marker); + markers.add(marker); } - public void addMarkers(Vector markers) { + public void addMarkers(ArrayList markers) { markers.addAll(markers); } @@ -383,7 +383,7 @@ abstract public class Area extends Box { returnedBy.put(fo, new Integer(areaPosition)); } - public Vector getMarkers() { + public ArrayList getMarkers() { return markers; } diff --git a/src/org/apache/fop/layout/AreaContainer.java b/src/org/apache/fop/layout/AreaContainer.java index ce0d8a5c6..8d1c5e9bc 100644 --- a/src/org/apache/fop/layout/AreaContainer.java +++ b/src/org/apache/fop/layout/AreaContainer.java @@ -11,9 +11,6 @@ package org.apache.fop.layout; import org.apache.fop.render.Renderer; import org.apache.fop.fo.properties.*; -// Java -import java.util.Vector; -import java.util.Enumeration; public class AreaContainer extends Area { diff --git a/src/org/apache/fop/layout/AreaTree.java b/src/org/apache/fop/layout/AreaTree.java index d2f247c19..73a2a78d1 100644 --- a/src/org/apache/fop/layout/AreaTree.java +++ b/src/org/apache/fop/layout/AreaTree.java @@ -19,10 +19,7 @@ import org.apache.fop.fo.pagination.PageSequence; // Java import java.io.IOException; -import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.Stack; -import java.util.Vector; +import java.util.ArrayList; /* * Modified by Mark Lillywhite, mark-fop@inomial.com. No longer keeps @@ -47,7 +44,7 @@ public class AreaTree { /** * List of root extension objects */ - Vector rootExtensions = null; + ArrayList rootExtensions = null; private StreamRenderer streamRenderer; @@ -89,9 +86,10 @@ public class AreaTree { } public void addExtension(ExtensionObj obj) { - if(rootExtensions ==null) - rootExtensions = new Vector(); - rootExtensions.addElement(obj); + if(rootExtensions ==null) { + rootExtensions = new ArrayList(); + } + rootExtensions.add(obj); } } diff --git a/src/org/apache/fop/layout/BlockArea.java b/src/org/apache/fop/layout/BlockArea.java index fe73f6e99..cd390dd55 100644 --- a/src/org/apache/fop/layout/BlockArea.java +++ b/src/org/apache/fop/layout/BlockArea.java @@ -13,11 +13,10 @@ import org.apache.fop.fo.flow.*; import org.apache.fop.fo.*; import org.apache.fop.apps.*; import org.apache.fop.fo.properties.*; +import org.apache.fop.messaging.MessageHandler; // Java -import java.util.Vector; -import java.util.Enumeration; -import org.apache.fop.messaging.MessageHandler; +import java.util.ArrayList; /** * This class represents a Block Area. @@ -58,7 +57,7 @@ public class BlockArea extends Area { /* hyphenation */ protected HyphenationProps hyphProps; - protected Vector pendingFootnotes = null; + protected ArrayList pendingFootnotes = null; public BlockArea(FontState fontState, int allocationWidth, int maxHeight, int startIndent, int endIndent, int textIndent, @@ -101,9 +100,8 @@ public class BlockArea extends Area { } // add pending footnotes if (pendingFootnotes != null) { - for (Enumeration e = pendingFootnotes.elements(); - e.hasMoreElements(); ) { - FootnoteBody fb = (FootnoteBody)e.nextElement(); + for (int i = 0; i< pendingFootnotes.size(); i++) { + FootnoteBody fb = (FootnoteBody)pendingFootnotes.get(i); Page page = getPage(); if (!Footnote.layoutFootnote(page, fb, this)) { page.addPendingFootnote(fb); @@ -225,9 +223,9 @@ public class BlockArea extends Area { public void addFootnote(FootnoteBody fb) { if (pendingFootnotes == null) { - pendingFootnotes = new Vector(); + pendingFootnotes = new ArrayList(); } - pendingFootnotes.addElement(fb); + pendingFootnotes.add(fb); } } diff --git a/src/org/apache/fop/layout/BodyAreaContainer.java b/src/org/apache/fop/layout/BodyAreaContainer.java index 9fd6122af..23cbcb576 100644 --- a/src/org/apache/fop/layout/BodyAreaContainer.java +++ b/src/org/apache/fop/layout/BodyAreaContainer.java @@ -17,8 +17,7 @@ import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.BlockContainer; // Java -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; public class BodyAreaContainer extends Area { @@ -165,8 +164,8 @@ public class BodyAreaContainer extends Area { return addSpanArea(columnCount); } - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() + ArrayList spanAreas = this.mainReferenceArea.getChildren(); + SpanArea spanArea = (SpanArea)spanAreas.get(spanAreas.size() - 1); if ((span == Span.ALL) && (spanArea.getColumnCount() == 1)) { @@ -220,8 +219,8 @@ public class BodyAreaContainer extends Area { if (this.mainReferenceArea.getChildren().isEmpty()) return false; - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() + ArrayList spanAreas = this.mainReferenceArea.getChildren(); + SpanArea spanArea = (SpanArea)spanAreas.get(spanAreas.size() - 1); if (spanArea.isBalanced()) @@ -255,9 +254,8 @@ public class BodyAreaContainer extends Area { * one added with the computed max height. */ public void resetSpanArea() { - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() - - 1); + ArrayList spanAreas = this.mainReferenceArea.getChildren(); + SpanArea spanArea = (SpanArea)spanAreas.get(spanAreas.size() - 1); if (!spanArea.isBalanced()) { // span area maintains a record of the total height of @@ -299,9 +297,9 @@ public class BodyAreaContainer extends Area { */ private void resetHeights() { int totalHeight = 0; - for (Enumeration e = this.mainReferenceArea.getChildren().elements(); - e.hasMoreElements(); ) { - SpanArea spanArea = (SpanArea)e.nextElement(); + ArrayList children = this.mainReferenceArea.getChildren(); + for (int i = 0; i < children.size(); i++) { + SpanArea spanArea = (SpanArea)children.get(i); int spanContentHeight = spanArea.getMaxContentHeight(); int spanMaxHeight = spanArea.getMaxHeight(); @@ -316,9 +314,8 @@ public class BodyAreaContainer extends Area { * @returns boolean Is this the last column in this span? */ public boolean isLastColumn() { - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() - - 1); + ArrayList spanAreas = this.mainReferenceArea.getChildren(); + SpanArea spanArea = (SpanArea)spanAreas.get(spanAreas.size() - 1); return spanArea.isLastColumn(); } @@ -332,9 +329,8 @@ public class BodyAreaContainer extends Area { } public AreaContainer getCurrentColumnArea() { - Vector spanAreas = this.mainReferenceArea.getChildren(); - SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size() - - 1); + ArrayList spanAreas = this.mainReferenceArea.getChildren(); + SpanArea spanArea = (SpanArea)spanAreas.get(spanAreas.size() - 1); return spanArea.getCurrentColumnArea(); } @@ -366,9 +362,9 @@ public class BodyAreaContainer extends Area { footnoteYPosition = footnoteReferenceArea.getYPosition(); footnoteReferenceArea.setMaxHeight(footnoteReferenceArea.getHeight()); - Vector childs = footnoteReferenceArea.getChildren(); - for (Enumeration en = childs.elements(); en.hasMoreElements(); ) { - Object obj = en.nextElement(); + ArrayList children = footnoteReferenceArea.getChildren(); + for (int i = 0; i < children.size(); i++) { + Object obj = children.get(i); if (obj instanceof Area) { Area childArea = (Area)obj; footnoteReferenceArea.removeChild(childArea); @@ -381,9 +377,9 @@ public class BodyAreaContainer extends Area { protected static void resetMaxHeight(Area ar, int change) { ar.setMaxHeight(change); - Vector childs = ar.getChildren(); - for (Enumeration en = childs.elements(); en.hasMoreElements(); ) { - Object obj = en.nextElement(); + ArrayList childs = ar.getChildren(); + for (int i = 0; i < childs.size(); i++) { + Object obj = childs.get(i); if (obj instanceof Area) { Area childArea = (Area)obj; resetMaxHeight(childArea, change); diff --git a/src/org/apache/fop/layout/ColumnArea.java b/src/org/apache/fop/layout/ColumnArea.java index 771309f5a..187c07b26 100644 --- a/src/org/apache/fop/layout/ColumnArea.java +++ b/src/org/apache/fop/layout/ColumnArea.java @@ -12,10 +12,6 @@ import org.apache.fop.render.Renderer; import org.apache.fop.fo.properties.Position; import org.apache.fop.datatypes.IDReferences; -// Java -import java.util.Vector; -import java.util.Enumeration; - public class ColumnArea extends AreaContainer { private int columnIndex; diff --git a/src/org/apache/fop/layout/FontDescriptor.java b/src/org/apache/fop/layout/FontDescriptor.java index 513eaacd5..fb818631b 100644 --- a/src/org/apache/fop/layout/FontDescriptor.java +++ b/src/org/apache/fop/layout/FontDescriptor.java @@ -20,7 +20,7 @@ public interface FontDescriptor { public int getStemV(); public boolean hasKerningInfo(); - public java.util.Hashtable getKerningInfo(); + public java.util.HashMap getKerningInfo(); public boolean isEmbeddable(); public byte getSubType(); public org.apache.fop.pdf.PDFStream getFontFile(int objNum); diff --git a/src/org/apache/fop/layout/FontInfo.java b/src/org/apache/fop/layout/FontInfo.java index 2fd4100d1..d67030ff7 100644 --- a/src/org/apache/fop/layout/FontInfo.java +++ b/src/org/apache/fop/layout/FontInfo.java @@ -7,21 +7,20 @@ package org.apache.fop.layout; -import java.util.Hashtable; +import org.apache.fop.apps.FOPException; import org.apache.fop.messaging.MessageHandler; -import java.util.Enumeration; -import org.apache.fop.apps.FOPException; +import java.util.HashMap; 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, @@ -98,11 +97,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/layout/FontState.java b/src/org/apache/fop/layout/FontState.java index b8a746067..1c8305890 100644 --- a/src/org/apache/fop/layout/FontState.java +++ b/src/org/apache/fop/layout/FontState.java @@ -7,13 +7,13 @@ package org.apache.fop.layout; -import java.util.Hashtable; -import java.util.StringTokenizer; - import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.FontVariant; import org.apache.fop.render.pdf.CodePointMapping; +import java.util.HashMap; +import java.util.StringTokenizer; + public class FontState { private FontInfo _fontInfo; @@ -27,7 +27,7 @@ public class FontState { private FontMetric _metric; private int _letterSpacing; - private static Hashtable EMPTY_HASHTABLE = new Hashtable(); + private static HashMap EMPTY_HASHMAP = new HashMap(); public FontState(FontInfo fontInfo, String fontFamily, String fontStyle, @@ -146,13 +146,13 @@ public class FontState { return _metric.getXHeight(_fontSize) / 1000; } - public Hashtable getKerning() { + public HashMap getKerning() { if (_metric instanceof FontDescriptor) { - Hashtable ret = ((FontDescriptor)_metric).getKerningInfo(); + HashMap ret = ((FontDescriptor)_metric).getKerningInfo(); if (ret != null) return ret; } - return EMPTY_HASHTABLE; + return EMPTY_HASHMAP; } public int width(int charnum) { diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java index 8e0e5bcad..c0e4fc691 100644 --- a/src/org/apache/fop/layout/LineArea.java +++ b/src/org/apache/fop/layout/LineArea.java @@ -27,8 +27,7 @@ import org.apache.fop.layout.hyphenation.Hyphenator; import org.apache.fop.configuration.Configuration; // java -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; import java.util.StringTokenizer; import java.awt.Rectangle; @@ -90,7 +89,7 @@ public class LineArea extends Area { * because subsequent characters to come (in a different addText) * may be part of the same word */ - protected Vector pendingAreas = new Vector(); + protected ArrayList pendingAreas = new ArrayList(); /* the width of the pendingAreas */ protected int pendingWidth = 0; @@ -123,39 +122,30 @@ public class LineArea extends Area { this.endIndent = endIndent; if (prevLineArea != null) { - Enumeration e = prevLineArea.pendingAreas.elements(); - Box b = null; // There might be InlineSpaces at the beginning // that should not be there - eat them boolean eatMoreSpace = true; - int eatenWidth = 0; + pendingWidth = prevLineArea.pendingWidth; - while (eatMoreSpace) { - if (e.hasMoreElements()) { - b = (Box)e.nextElement(); + for (int i = 0; i < prevLineArea.pendingAreas.size(); i++) { + Object b = prevLineArea.pendingAreas.get(i); + if (eatMoreSpace) { if (b instanceof InlineSpace) { InlineSpace is = (InlineSpace)b; - if (is.isEatable()) - eatenWidth += is.getSize(); - else + if (is.isEatable()) { + pendingWidth -= is.getSize(); + } else { eatMoreSpace = false; + pendingAreas.add(b); + } } else { eatMoreSpace = false; + pendingAreas.add(b); } } else { - eatMoreSpace = false; - b = null; + pendingAreas.add(b); } } - - while (b != null) { - pendingAreas.addElement(b); - if (e.hasMoreElements()) - b = (Box)e.nextElement(); - else - b = null; - } - pendingWidth = prevLineArea.pendingWidth - eatenWidth; prevLineArea.pendingWidth=0; prevLineArea.pendingAreas=null; } @@ -182,7 +172,7 @@ public class LineArea extends Area { this.red, this.green, this.blue, refid, width); pia.setYOffset(placementOffset); - pendingAreas.addElement(pia); + pendingAreas.add(pia); pendingWidth += width; prev = TEXT; @@ -296,9 +286,8 @@ public class LineArea extends Area { // add any pending areas - Enumeration e = pendingAreas.elements(); - while (e.hasMoreElements()) { - Box box = (Box)e.nextElement(); + for (int j = 0; j < pendingAreas.size(); j++ ) { + Box box = (Box)pendingAreas.get(j); if (box instanceof InlineArea) { if (ls != null) { Rectangle lr = @@ -315,7 +304,7 @@ public class LineArea extends Area { // reset pending areas array pendingWidth = 0; - pendingAreas = new Vector(); + pendingAreas = new ArrayList(); // add the current word @@ -409,10 +398,10 @@ public class LineArea extends Area { wordStart = i; wordLength = 1; } else if (prev == TEXT || prev == MULTIBYTECHAR ) { - if ( prev == TEXT && curr == TEXT || ! canBreakMidWord()) { - wordLength++; + if ( prev == TEXT && curr == TEXT || ! canBreakMidWord()) { + wordLength++; wordWidth += charWidth; - } else { + } else { // if (spaceWidth > 0) { // for text-align="justify" InlineSpace is = new InlineSpace(spaceWidth); @@ -430,46 +419,45 @@ public class LineArea extends Area { spaceWidth = 0; // } - // add any pending areas - - Enumeration e = pendingAreas.elements(); - while (e.hasMoreElements()) { - Box box = (Box)e.nextElement(); - if (box instanceof InlineArea) { - if (ls != null) { - Rectangle lr = + // add any pending areas + + for (int j = 0; j < pendingAreas.size(); j++ ) { + Box box = (Box)pendingAreas.get(j); + if (box instanceof InlineArea) { + if (ls != null) { + Rectangle lr = new Rectangle(finalWidth, 0, ((InlineArea)box).getContentWidth(), fontState.getFontSize()); - ls.addRect(lr, this, (InlineArea)box); + ls.addRect(lr, this, (InlineArea)box); + } } + addChild(box); } - addChild(box); - } - finalWidth += pendingWidth; + finalWidth += pendingWidth; - // reset pending areas array - pendingWidth = 0; - pendingAreas = new Vector(); + // reset pending areas array + pendingWidth = 0; + pendingAreas = new ArrayList(); - // add the current word + // add the current word - if (wordLength > 0) { - // The word might contain nonbreaking - // spaces. Split the word and add InlineSpace - // as necessary. All spaces inside the word - // Have a fixed width. - addSpacedWord(new String(data, wordStart, wordLength), - ls, finalWidth, 0, textState, false); - finalWidth += wordWidth; - } - spaceWidth = 0; - wordStart = i; - wordLength = 1; - wordWidth = charWidth; - } - prev = curr; + if (wordLength > 0) { + // The word might contain nonbreaking + // spaces. Split the word and add InlineSpace + // as necessary. All spaces inside the word + // have a fixed width. + addSpacedWord(new String(data, wordStart, wordLength), + ls, finalWidth, 0, textState, false); + finalWidth += wordWidth; + } + spaceWidth = 0; + wordStart = i; + wordLength = 1; + wordWidth = charWidth; + } + prev = curr; } else { // nothing previous prev = curr; @@ -557,7 +545,7 @@ public class LineArea extends Area { if (prevLTState) { pis.setLineThrough(textState.getLineThrough()); } - pendingAreas.addElement(pis); + pendingAreas.add(pis); pendingWidth += spaceWidth; spaceWidth = 0; } @@ -618,7 +606,7 @@ public class LineArea extends Area { switch (leaderPattern) { case LeaderPattern.SPACE: InlineSpace spaceArea = new InlineSpace(leaderLength); - pendingAreas.addElement(spaceArea); + pendingAreas.add(spaceArea); break; case LeaderPattern.RULE: LeaderArea leaderArea = new LeaderArea(fontState, red, green, @@ -626,7 +614,7 @@ public class LineArea extends Area { leaderPattern, ruleThickness, ruleStyle); leaderArea.setYOffset(placementOffset); - pendingAreas.addElement(leaderArea); + pendingAreas.add(leaderArea); break; case LeaderPattern.DOTS: // if the width of a dot is larger than leader-pattern-width @@ -636,20 +624,20 @@ public class LineArea extends Area { } // if value of leader-pattern-width is 'use-font-metrics' (0) if (leaderPatternWidth == 0) { - pendingAreas.addElement(this.buildSimpleLeader(dot, - leaderLength)); + pendingAreas.add(this.buildSimpleLeader(dot, leaderLength)); } else { - // if leader-alignment is used, calculate space to insert before leader - // so that all dots will be parallel. + // if leader-alignment is used, calculate space to + // insert before leader so that all dots will be + // parallel. if (leaderAlignment == LeaderAlignment.REFERENCE_AREA) { int spaceBeforeLeader = this.getLeaderAlignIndent(leaderLength, leaderPatternWidth); - // appending indent space leader-alignment - // setting InlineSpace to false, so it is not used in line justification + // appending indent space leader-alignment setting + // InlineSpace to false, so it is not used in line + // justification if (spaceBeforeLeader != 0) { - pendingAreas.addElement(new InlineSpace(spaceBeforeLeader, - false)); + pendingAreas.add(new InlineSpace(spaceBeforeLeader, false)); pendingWidth += spaceBeforeLeader; // shorten leaderLength, otherwise - in case of // leaderLength=remaining length - it will cut off the end of @@ -674,11 +662,11 @@ public class LineArea extends Area { // add combination of dot + space to fill leader // is there a way to do this in a more effective way? for (int i = 0; i < dotsFactor; i++) { - pendingAreas.addElement(leaderPatternArea); - pendingAreas.addElement(spaceBetweenDots); + pendingAreas.add(leaderPatternArea); + pendingAreas.add(spaceBetweenDots); } // append at the end some space to fill up to leader length - pendingAreas.addElement(new InlineSpace(leaderLength + pendingAreas.add(new InlineSpace(leaderLength - dotsFactor * leaderPatternWidth)); } @@ -708,9 +696,8 @@ public class LineArea extends Area { spaceWidth = 0; } - Enumeration e = pendingAreas.elements(); - while (e.hasMoreElements()) { - Box box = (Box)e.nextElement(); + for (int i = 0; i < pendingAreas.size(); i++ ) { + Box box = (Box)pendingAreas.get(i); addChild(box); } @@ -718,7 +705,7 @@ public class LineArea extends Area { // reset pending areas array pendingWidth = 0; - pendingAreas = new Vector(); + pendingAreas = new ArrayList(); } /** @@ -727,7 +714,6 @@ public class LineArea extends Area { */ public void align(int type) { int padding = 0; - switch (type) { case TextAlign.START: // left padding = this.getContentWidth() - finalWidth; @@ -745,9 +731,8 @@ public class LineArea extends Area { case TextAlign.JUSTIFY: // justify // first pass - count the spaces int spaceCount = 0; - Enumeration e = children.elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + for (int i = 0; i < children.size(); i++ ) { + Box b = (Box)children.get(i); if (b instanceof InlineSpace) { InlineSpace space = (InlineSpace)b; if (space.getResizeable()) { @@ -762,9 +747,8 @@ public class LineArea extends Area { } // second pass - add additional space spaceCount = 0; - e = children.elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); if (b instanceof InlineSpace) { InlineSpace space = (InlineSpace)b; if (space.getResizeable()) { @@ -785,9 +769,8 @@ public class LineArea extends Area { public void verticalAlign() { int superHeight = -this.placementOffset; int maxHeight = this.allocationHeight; - Enumeration e = children.elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + for (int i = 0; i < children.size(); i++ ) { + Box b = (Box)children.get(i); if (b instanceof InlineArea) { InlineArea ia = (InlineArea)b; if (ia instanceof WordArea) { @@ -1103,7 +1086,7 @@ public class LineArea extends Area { width); ia.setYOffset(placementOffset); ia.setUnderlined(ul); - pendingAreas.addElement(ia); + pendingAreas.add(ia); if (Character.isSpaceChar(data)) { this.spaceWidth = +width; prev = LineArea.WHITESPACE; @@ -1141,9 +1124,8 @@ public class LineArea extends Area { // add any pending areas - Enumeration e = pendingAreas.elements(); - while (e.hasMoreElements()) { - Box box = (Box)e.nextElement(); + for (int i = 0; i < pendingAreas.size(); i++ ) { + Box box = (Box)pendingAreas.get(i); if (box instanceof InlineArea) { if (ls != null) { Rectangle lr = @@ -1160,7 +1142,7 @@ public class LineArea extends Area { // reset pending areas array pendingWidth = 0; - pendingAreas = new Vector(); + pendingAreas = new ArrayList(); String word = (wordBuf != null) ? wordBuf.toString() : ""; int wordWidth = this.getWordWidth(word); WordArea hia = new WordArea(currentFontState, @@ -1281,7 +1263,6 @@ public class LineArea extends Area { width = getCharWidth(' ') * 2; } } - return width; } @@ -1361,7 +1342,7 @@ public class LineArea extends Area { } if (addToPending) { - pendingAreas.addElement(is); + pendingAreas.add(is); pendingWidth += spaceWidth; } else { addChild(is); @@ -1383,7 +1364,7 @@ public class LineArea extends Area { ia.setVerticalAlign(vAlign); if (addToPending) { - pendingAreas.addElement(ia); + pendingAreas.add(ia); pendingWidth += wordWidth; } else { addChild(ia); diff --git a/src/org/apache/fop/layout/LinkSet.java b/src/org/apache/fop/layout/LinkSet.java index 30d58ca8d..e88015367 100644 --- a/src/org/apache/fop/layout/LinkSet.java +++ b/src/org/apache/fop/layout/LinkSet.java @@ -7,21 +7,11 @@ package org.apache.fop.layout; -// Java -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Rectangle; - import org.apache.fop.layout.inline.InlineArea; -import org.apache.fop.fo.properties.WrapOption; // for enumerated -// values -// import org.apache.fop.fo.properties.WhiteSpaceCollapse; // for -// enumerated values -import org.apache.fop.fo.properties.TextAlign; // for enumerated -// values -import org.apache.fop.fo.properties.TextAlignLast; // for enumerated -// values +// Java +import java.util.ArrayList; +import java.awt.Rectangle; /** * a set of rectangles on a page that are linked to a common @@ -37,7 +27,7 @@ public class LinkSet { /** * the set of rectangles */ - Vector rects = new Vector(); + ArrayList rects = new ArrayList(); private int xoffset = 0; private int yoffset = 0; @@ -72,7 +62,7 @@ public class LinkSet { if (this.yoffset > maxY) { maxY = this.yoffset; } - rects.addElement(linkedRectangle); + rects.add(linkedRectangle); } public void setYOffset(int y) { @@ -90,9 +80,8 @@ public class LinkSet { public void applyAreaContainerOffsets(AreaContainer ac, Area area) { int height = area.getAbsoluteHeight(); BlockArea ba = (BlockArea)area; - Enumeration re = rects.elements(); - while (re.hasMoreElements()) { - LinkedRectangle r = (LinkedRectangle)re.nextElement(); + for (int i = 0; i < rects.size(); i++ ) { + LinkedRectangle r = (LinkedRectangle)rects.get(i); r.setX(r.getX() + ac.getXPosition() + area.getTableCellXOffset()); r.setY(ac.getYPosition() - height + (maxY - r.getY()) - ba.getHalfLeading()); @@ -106,31 +95,30 @@ public class LinkSet { return; LinkedRectangle curRect = - new LinkedRectangle((LinkedRectangle)rects.elementAt(0)); - Vector nv = new Vector(); + new LinkedRectangle((LinkedRectangle)rects.get(0)); + ArrayList nv = new ArrayList(); for (int ri = 1; ri < numRects; ri++) { - LinkedRectangle r = (LinkedRectangle)rects.elementAt(ri); + LinkedRectangle r = (LinkedRectangle)rects.get(ri); // yes, I'm really happy with comparing refs... if (r.getLineArea() == curRect.getLineArea()) { curRect.setWidth(r.getX() + r.getWidth() - curRect.getX()); } else { - nv.addElement(curRect); + nv.add(curRect); curRect = new LinkedRectangle(r); } if (ri == numRects - 1) - nv.addElement(curRect); + nv.add(curRect); } rects = nv; } public void align() { - Enumeration re = rects.elements(); - while (re.hasMoreElements()) { - LinkedRectangle r = (LinkedRectangle)re.nextElement(); + for (int i = 0; i < rects.size(); i++ ) { + LinkedRectangle r = (LinkedRectangle)rects.get(i); r.setX(r.getX() + r.getLineArea().getStartIndent() + r.getInlineArea().getXOffset()); } @@ -140,7 +128,7 @@ public class LinkSet { return this.destination; } - public Vector getRects() { + public ArrayList getRects() { return this.rects; } diff --git a/src/org/apache/fop/layout/Page.java b/src/org/apache/fop/layout/Page.java index f543c6a0b..710112412 100644 --- a/src/org/apache/fop/layout/Page.java +++ b/src/org/apache/fop/layout/Page.java @@ -16,8 +16,7 @@ import org.apache.fop.datatypes.IDReferences; import org.apache.fop.fo.pagination.PageSequence; // Java -import java.util.Vector; -import java.util.Enumeration; +import java.util.ArrayList; /*Modified by Mark Lillywhite mark-fop@inomial.com. Added getIDReferences. This is just a convenience method for renderers who no longer have access @@ -37,26 +36,26 @@ public class Page { private AreaTree areaTree; - private Vector rootExtensions; + private ArrayList rootExtensions; private PageSequence pageSequence; protected int pageNumber = 0; protected String formattedPageNumber; - protected Vector linkSets = new Vector(); + protected ArrayList linkSets = new ArrayList(); - private Vector idList = new Vector(); + private ArrayList idList = new ArrayList(); - private Vector footnotes = null; + private ArrayList footnotes = null; - private Vector markers = null; + private ArrayList markers = null; Page(AreaTree areaTree, int height, int width) { this.areaTree = areaTree; this.height = height; this.width = width; - markers = new Vector(); + markers = new ArrayList(); } public IDReferences getIDReferences() { @@ -161,10 +160,10 @@ public class Page { } public void addLinkSet(LinkSet linkSet) { - this.linkSets.addElement(linkSet); + this.linkSets.add(linkSet); } - public Vector getLinkSets() { + public ArrayList getLinkSets() { return this.linkSets; } @@ -173,31 +172,30 @@ public class Page { } public void addToIDList(String id) { - idList.addElement(id); + idList.add(id); } - public Vector getIDList() { + public ArrayList getIDList() { return idList; } - public Vector getPendingFootnotes() { + public ArrayList getPendingFootnotes() { return footnotes; } - public Vector getExtensions() { + public ArrayList getExtensions() { return rootExtensions; } - public void setExtensions(Vector extensions) { + public void setExtensions(ArrayList extensions) { this.rootExtensions = extensions; } - public void setPendingFootnotes(Vector v) { + public void setPendingFootnotes(ArrayList v) { footnotes = v; if (footnotes != null) { - for (Enumeration e = footnotes.elements(); - e.hasMoreElements(); ) { - FootnoteBody fb = (FootnoteBody)e.nextElement(); + for (int i = 0; i < footnotes.size(); i++ ) { + FootnoteBody fb = (FootnoteBody)footnotes.get(i); if (!Footnote.layoutFootnote(this, fb, null)) { // footnotes are too large to fit on empty page } @@ -209,16 +207,16 @@ public class Page { public void addPendingFootnote(FootnoteBody fb) { if (footnotes == null) { - footnotes = new Vector(); + footnotes = new ArrayList(); } - footnotes.addElement(fb); + footnotes.add(fb); } public void registerMarker(Marker marker) { - markers.addElement(marker); + markers.add(marker); } - public Vector getMarkers() { + public ArrayList getMarkers() { return this.markers; } diff --git a/src/org/apache/fop/layout/SpanArea.java b/src/org/apache/fop/layout/SpanArea.java index 6ba58db1b..be191184e 100644 --- a/src/org/apache/fop/layout/SpanArea.java +++ b/src/org/apache/fop/layout/SpanArea.java @@ -13,8 +13,7 @@ import org.apache.fop.fo.properties.Position; import org.apache.fop.datatypes.IDReferences; // Java -import java.util.Vector; -import java.util.Enumeration; +import java.util.Iterator; public class SpanArea extends AreaContainer { @@ -77,7 +76,7 @@ public class SpanArea extends AreaContainer { } public AreaContainer getCurrentColumnArea() { - return (AreaContainer)getChildren().elementAt(currentColumn - 1); + return (AreaContainer)getChildren().get(currentColumn - 1); } public boolean isBalanced() { @@ -90,19 +89,17 @@ public class SpanArea extends AreaContainer { public int getTotalContentHeight() { int totalContentHeight = 0; - for (Enumeration e = getChildren().elements(); - e.hasMoreElements(); ) { + for (Iterator e = getChildren().iterator(); e.hasNext(); ) { totalContentHeight += - ((AreaContainer)e.nextElement()).getContentHeight(); + ((AreaContainer)e.next()).getContentHeight(); } return totalContentHeight; } public int getMaxContentHeight() { int maxContentHeight = 0; - for (Enumeration e = getChildren().elements(); - e.hasMoreElements(); ) { - AreaContainer nextElm = (AreaContainer)e.nextElement(); + for (Iterator e = getChildren().iterator(); e.hasNext(); ) { + AreaContainer nextElm = (AreaContainer)e.next(); if (nextElm.getContentHeight() > maxContentHeight) maxContentHeight = nextElm.getContentHeight(); } @@ -111,9 +108,8 @@ public class SpanArea extends AreaContainer { public void setPage(Page page) { this.page = page; - for (Enumeration e = getChildren().elements(); - e.hasMoreElements(); ) { - ((AreaContainer)e.nextElement()).setPage(page); + for (Iterator e = getChildren().iterator(); e.hasNext(); ) { + ((AreaContainer)e.next()).setPage(page); } } diff --git a/src/org/apache/fop/layout/hyphenation/Hyphenation.java b/src/org/apache/fop/layout/hyphenation/Hyphenation.java index 016091a4c..fa36de9b9 100644 --- a/src/org/apache/fop/layout/hyphenation/Hyphenation.java +++ b/src/org/apache/fop/layout/hyphenation/Hyphenation.java @@ -7,8 +7,6 @@ package org.apache.fop.layout.hyphenation; -import java.util.Vector; - /** * This class represents a hyphenated word. * diff --git a/src/org/apache/fop/layout/hyphenation/HyphenationTree.java b/src/org/apache/fop/layout/hyphenation/HyphenationTree.java index d2c0f16bf..90842e6df 100644 --- a/src/org/apache/fop/layout/hyphenation/HyphenationTree.java +++ b/src/org/apache/fop/layout/hyphenation/HyphenationTree.java @@ -8,8 +8,8 @@ package org.apache.fop.layout.hyphenation; import java.io.*; -import java.util.Vector; -import java.util.Hashtable; +import java.util.ArrayList; +import java.util.HashMap; /** * This tree structure stores the hyphenation patterns in an efficient @@ -29,7 +29,7 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, /** * This map stores hyphenation exceptions */ - protected Hashtable stoplist; + protected HashMap stoplist; /** * This map stores the character classes @@ -42,7 +42,7 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, private transient TernaryTree ivalues; public HyphenationTree() { - stoplist = new Hashtable(23); // usually a small table + stoplist = new HashMap(23); // usually a small table classmap = new TernaryTree(); vspace = new ByteVector(); vspace.alloc(1); // this reserves index 0, which we don't use @@ -282,10 +282,10 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, String sw = new String(word, 1, len); if (stoplist.containsKey(sw)) { // assume only simple hyphens (Hyphen.pre="-", Hyphen.post = Hyphen.no = null) - Vector hw = (Vector)stoplist.get(sw); + ArrayList hw = (ArrayList)stoplist.get(sw); int j = 0; for (i = 0; i < hw.size(); i++) { - Object o = hw.elementAt(i); + Object o = hw.get(i); if (o instanceof String) { j += ((String)o).length(); if (j >= remainCharCount && j < (len - pushCharCount)) @@ -351,10 +351,10 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer, * {@link PatternParser PatternParser} class as callback to * store the hyphenation exceptions. * @param word normalized word - * @param hyphenatedword a vector of alternating strings and + * @param hyphenatedword a ArrayList of alternating strings and * {@link Hyphen hyphen} objects. */ - public void addException(String word, Vector hyphenatedword) { + public void addException(String word, ArrayList hyphenatedword) { stoplist.put(word, hyphenatedword); } diff --git a/src/org/apache/fop/layout/hyphenation/Hyphenator.java b/src/org/apache/fop/layout/hyphenation/Hyphenator.java index 9d70dd72d..4476061a7 100644 --- a/src/org/apache/fop/layout/hyphenation/Hyphenator.java +++ b/src/org/apache/fop/layout/hyphenation/Hyphenator.java @@ -8,7 +8,7 @@ package org.apache.fop.layout.hyphenation; import java.io.*; -import java.util.Hashtable; +import java.util.HashMap; import org.apache.fop.configuration.*; import org.apache.fop.messaging.MessageHandler; @@ -19,7 +19,7 @@ import org.apache.fop.messaging.MessageHandler; * @author Carlos Villegas */ public class Hyphenator { - static Hashtable hyphenTrees = new Hashtable(); + static HashMap hyphenTrees = new HashMap(); private HyphenationTree hyphenTree = null; private int remainCharCount = 2; diff --git a/src/org/apache/fop/layout/hyphenation/PatternConsumer.java b/src/org/apache/fop/layout/hyphenation/PatternConsumer.java index 2eacd16a7..9a4974e1c 100644 --- a/src/org/apache/fop/layout/hyphenation/PatternConsumer.java +++ b/src/org/apache/fop/layout/hyphenation/PatternConsumer.java @@ -7,7 +7,7 @@ package org.apache.fop.layout.hyphenation; -import java.util.Vector; +import java.util.ArrayList; /** * This interface is used to connect the XML pattern file parser to @@ -29,10 +29,10 @@ public interface PatternConsumer { * Add a hyphenation exception. An exception replaces the * result obtained by the algorithm for cases for which this * fails or the user wants to provide his own hyphenation. - * A hyphenatedword is a vector of alternating String's and + * A hyphenatedword is a ArrayList of alternating String's and * {@link Hyphen Hyphen} instances */ - public void addException(String word, Vector hyphenatedword); + public void addException(String word, ArrayList hyphenatedword); /** * Add hyphenation patterns. diff --git a/src/org/apache/fop/layout/hyphenation/PatternParser.java b/src/org/apache/fop/layout/hyphenation/PatternParser.java index 76d0d36f7..a115d9c8d 100644 --- a/src/org/apache/fop/layout/hyphenation/PatternParser.java +++ b/src/org/apache/fop/layout/hyphenation/PatternParser.java @@ -22,7 +22,7 @@ import java.io.FileWriter; import java.io.PrintWriter; import java.io.IOException; import java.io.FileNotFoundException; -import java.util.Vector; +import java.util.ArrayList; import java.net.URL; /** @@ -37,7 +37,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { int currElement; PatternConsumer consumer; StringBuffer token; - Vector exception; + ArrayList exception; char hyphenChar; String errMsg; @@ -183,10 +183,10 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { return pat.toString(); } - protected Vector normalizeException(Vector ex) { - Vector res = new Vector(); + protected ArrayList normalizeException(ArrayList ex) { + ArrayList res = new ArrayList(); for (int i = 0; i < ex.size(); i++) { - Object item = ex.elementAt(i); + Object item = ex.get(i); if (item instanceof String) { String str = (String)item; StringBuffer buf = new StringBuffer(); @@ -195,27 +195,27 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { if (c != hyphenChar) buf.append(c); else { - res.addElement(buf.toString()); + res.add(buf.toString()); buf.setLength(0); char[] h = new char[1]; h[0] = hyphenChar; // we use here hyphenChar which is not necessarily // the one to be printed - res.addElement(new Hyphen(new String(h), null, null)); + res.add(new Hyphen(new String(h), null, null)); } } if (buf.length() > 0) - res.addElement(buf.toString()); + res.add(buf.toString()); } else - res.addElement(item); + res.add(item); } return res; } - protected String getExceptionWord(Vector ex) { + protected String getExceptionWord(ArrayList ex) { StringBuffer res = new StringBuffer(); for (int i = 0; i < ex.size(); i++) { - Object item = ex.elementAt(i); + Object item = ex.get(i); if (item instanceof String) res.append((String)item); else { @@ -260,14 +260,14 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { currElement = ELEM_PATTERNS; else if (local.equals("exceptions")) { currElement = ELEM_EXCEPTIONS; - exception = new Vector(); + exception = new ArrayList(); } else if (local.equals("hyphen")) { if (token.length() > 0) { - exception.addElement(token.toString()); + exception.add(token.toString()); } - exception.addElement(new Hyphen(attrs.getValue("pre"), - attrs.getValue("no"), - attrs.getValue("post"))); + exception.add(new Hyphen(attrs.getValue("pre"), + attrs.getValue("no"), + attrs.getValue("post"))); currElement = ELEM_HYPHEN; } token.setLength(0); @@ -282,10 +282,10 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { consumer.addClass(word); break; case ELEM_EXCEPTIONS: - exception.addElement(word); + exception.add(word); exception = normalizeException(exception); consumer.addException(getExceptionWord(exception), - (Vector)exception.clone()); + (ArrayList)exception.clone()); break; case ELEM_PATTERNS: consumer.addPattern(getPattern(word), @@ -319,11 +319,11 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { consumer.addClass(word); break; case ELEM_EXCEPTIONS: - exception.addElement(word); + exception.add(word); exception = normalizeException(exception); consumer.addException(getExceptionWord(exception), - (Vector)exception.clone()); - exception.removeAllElements(); + (ArrayList)exception.clone()); + exception.clear(); break; case ELEM_PATTERNS: consumer.addPattern(getPattern(word), @@ -391,7 +391,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { System.out.println("class: " + c); } - public void addException(String w, Vector e) { + public void addException(String w, ArrayList e) { System.out.println("exception: " + w + " : " + e.toString()); } diff --git a/src/org/apache/fop/layout/inline/ForeignObjectArea.java b/src/org/apache/fop/layout/inline/ForeignObjectArea.java index 535743499..ea23d5cf4 100644 --- a/src/org/apache/fop/layout/inline/ForeignObjectArea.java +++ b/src/org/apache/fop/layout/inline/ForeignObjectArea.java @@ -11,10 +11,6 @@ package org.apache.fop.layout.inline; import org.apache.fop.render.Renderer; import org.apache.fop.layout.*; -// Java -import java.util.Vector; -import java.util.Enumeration; - public class ForeignObjectArea extends InlineArea { protected int xOffset = 0; diff --git a/src/org/apache/fop/layout/inline/LeaderArea.java b/src/org/apache/fop/layout/inline/LeaderArea.java index 42632318f..47de304fe 100644 --- a/src/org/apache/fop/layout/inline/LeaderArea.java +++ b/src/org/apache/fop/layout/inline/LeaderArea.java @@ -10,9 +10,6 @@ package org.apache.fop.layout.inline; import org.apache.fop.render.Renderer; import org.apache.fop.layout.*; -import java.util.Vector; -import java.util.Enumeration; - public class LeaderArea extends InlineArea { int ruleThickness; diff --git a/src/org/apache/fop/messaging/MessageHandler.java b/src/org/apache/fop/messaging/MessageHandler.java index c6eecfd6c..a21ed2daf 100644 --- a/src/org/apache/fop/messaging/MessageHandler.java +++ b/src/org/apache/fop/messaging/MessageHandler.java @@ -189,7 +189,7 @@ public class MessageHandler { * @param MessageListener the listener to add */ public static void addListener(MessageListener listener) { - listeners.addElement(listener); + listeners.add(listener); } /** diff --git a/src/org/apache/fop/mif/MIFDocument.java b/src/org/apache/fop/mif/MIFDocument.java index 6a584aee3..5baaade68 100644 --- a/src/org/apache/fop/mif/MIFDocument.java +++ b/src/org/apache/fop/mif/MIFDocument.java @@ -201,7 +201,7 @@ public class MIFDocument { private int ID; private int x, y, w, h; - Vector content = new Vector(); + ArrayList content = new ArrayList(); public Frame(int x, int y, int w, int h) { this.ID = curIDCounter.getnewID(); @@ -214,7 +214,7 @@ public class MIFDocument { public void addContent(ImportObject obj) { - content.addElement(obj); + content.add(obj); } @@ -233,10 +233,8 @@ public class MIFDocument { stream.write(mif.getBytes()); - Enumeration e = content.elements(); - while (e.hasMoreElements()) { - - ((ImportObject)e.nextElement()).output(stream); + for (int i = 0; i < content.size(); i++) { + ((ImportObject)content.get(i)).output(stream); } mif = "\n> #End Frame"; stream.write(mif.getBytes()); @@ -322,20 +320,20 @@ public class MIFDocument { private String pageType; private String pageTag; private String pageBackground; - private Vector textRects; + private ArrayList textRects; public Page(String pageType, String pageTag, String pageBackground) { this.pageType = pageType; this.pageTag = pageTag; this.pageBackground = pageBackground; - this.textRects = new Vector(); + this.textRects = new ArrayList(); } public Page() { this.pageType = "BodyPage"; this.pageBackground = "Default"; - this.textRects = new Vector(); + this.textRects = new ArrayList(); } @@ -343,7 +341,7 @@ public class MIFDocument { public void addTextRect(int numCols) { TextRect textRect = new TextRect(numCols); - this.textRects.addElement(textRect); + this.textRects.add(textRect); } public TextRect curTextRect() { @@ -351,39 +349,25 @@ public class MIFDocument { //temporary fix for NoSuchElementException if (textRects.isEmpty()) { TextRect textRect = new TextRect(1); - this.textRects.addElement(textRect); + this.textRects.add(textRect); } - - return (TextRect)textRects.lastElement(); - + return (TextRect)textRects.get(textRects.size() - 1); } public void output(OutputStream stream) throws IOException { - - String mif = "\n" + "\n\t"; - byte buf[] = mif.getBytes(); - stream.write(buf); - - Enumeration e = textRects.elements(); - - while (e.hasMoreElements()) { - - ((TextRect)e.nextElement()).output(stream); - + for (int i = 0; i < textRects.size(); i++) { + ((TextRect)textRects.get(i)).output(stream); } mif = "\n> #End Page\n"; stream.write(mif.getBytes()); - } - - } abstract class Flow { @@ -397,7 +381,7 @@ public class MIFDocument { class TextFlow extends Flow { - Vector paras; + ArrayList paras; private int ID; // This ID is used within ParaLine, however it is // logical to keep it unique to a textflow @@ -409,7 +393,7 @@ public class MIFDocument { this.ID = ((bookComponent.curPage()).curTextRect()).getTextRectID(); - this.paras = new Vector(); + this.paras = new ArrayList(); } @@ -421,47 +405,42 @@ public class MIFDocument { } public Para curPara() { - - return (Para)paras.lastElement(); + return (Para)paras.get(paras.size() - 1); } public void startPara() { - - this.paras.addElement(new Para(ID)); + this.paras.add(new Para(ID)); } public void output(OutputStream stream) throws IOException { String mif = "\n"; - + } stream.write(mif.getBytes()); - Enumeration e = this.content.elements(); - while (e.hasMoreElements()) { - - Object elem = (Object)e.nextElement(); + for (int i = 0; i < content.size(); i++) { + Object elem = content.get(i); if (elem instanceof String) { - // Output newlines as char hard return - if (elem == "\n") { - mif = "\n"; } else { mif = "\n\t"; } stream.write(mif.getBytes()); - } else if (elem instanceof Frame) { - mif = "\n\t"; stream.write(mif.getBytes()); } else if (elem instanceof Tbl) { @@ -582,7 +551,7 @@ public class MIFDocument { class PgfCatalog { - Vector pgfs; // Paragraph formats + ArrayList pgfs; // Paragraph formats public PgfCatalog() {} public void output(OutputStream stream) throws IOException { @@ -634,12 +603,12 @@ public class MIFDocument { class RulingCatalog { // Contains multiple rulings - Vector ruling = new Vector(); + ArrayList ruling = new ArrayList(); public RulingCatalog() { // Add the defualt ruling to the catalog - ruling.addElement(new Ruling()); + ruling.add(new Ruling()); } @@ -647,9 +616,8 @@ public class MIFDocument { String mif = "\n 0) { outline._prev = - (PDFOutline)_subentries.elementAt(_subentries.size() - 1); + (PDFOutline)_subentries.get(_subentries.size() - 1); outline._prev._next = outline; } else { _first = outline; } - _subentries.addElement(outline); + _subentries.add(outline); outline._parent = this; incrementCount(); // note: count is not just the immediate children diff --git a/src/org/apache/fop/pdf/PDFPages.java b/src/org/apache/fop/pdf/PDFPages.java index 9274fdda6..6e55c9b4b 100644 --- a/src/org/apache/fop/pdf/PDFPages.java +++ b/src/org/apache/fop/pdf/PDFPages.java @@ -7,12 +7,13 @@ package org.apache.fop.pdf; +// Fop +import org.apache.fop.messaging.MessageHandler; + // Java import java.io.PrintWriter; import java.io.UnsupportedEncodingException; -import java.util.Vector; -// Fop -import org.apache.fop.messaging.MessageHandler; +import java.util.ArrayList; /** * class representing a /Pages object. @@ -26,7 +27,7 @@ public class PDFPages extends PDFObject { /** * the /Page objects */ - protected Vector kids = new Vector(); + protected ArrayList kids = new ArrayList(); /** * the number of /Page objects @@ -55,7 +56,7 @@ public class PDFPages extends PDFObject { * @param page the PDFPage to add. */ public void addPage(PDFPage page) { - this.kids.addElement(page.referencePDF()); + this.kids.add(page.referencePDF()); page.setParent(this); this.incrementCount(); } @@ -87,7 +88,7 @@ public class PDFPages extends PDFObject { + " obj\n<< /Type /Pages\n/Count " + this.getCount() + "\n/Kids ["); for (int i = 0; i < kids.size(); i++) { - p = p.append(kids.elementAt(i) + " "); + p = p.append(kids.get(i) + " "); } p = p.append("] >>\nendobj\n"); diff --git a/src/org/apache/fop/pdf/PDFPattern.java b/src/org/apache/fop/pdf/PDFPattern.java index cc1c5dbcf..6e7efd16c 100644 --- a/src/org/apache/fop/pdf/PDFPattern.java +++ b/src/org/apache/fop/pdf/PDFPattern.java @@ -7,13 +7,13 @@ package org.apache.fop.pdf; -// Java... -import java.io.UnsupportedEncodingException; -import java.util.Vector; - // FOP... import org.apache.fop.datatypes.ColorSpace; +// Java... +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; + /** * class representing a PDF Function. * @@ -54,9 +54,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 @@ -74,9 +74,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. @@ -86,9 +86,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 @@ -105,17 +105,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 theXUID Optional vector of Integers that uniquely identify the pattern + * @param theMatrix Optional ArrayList of Doubles transformation matrix + * @param theXUID Optional ArrayList 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; @@ -144,12 +144,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; @@ -215,7 +215,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"); @@ -229,7 +229,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"); @@ -239,7 +239,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"); } @@ -259,7 +259,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"); } @@ -273,7 +273,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 45602cb22..f08174397 100644 --- a/src/org/apache/fop/pdf/PDFResources.java +++ b/src/org/apache/fop/pdf/PDFResources.java @@ -10,9 +10,9 @@ package org.apache.fop.pdf; // Java import java.io.PrintWriter; import java.io.UnsupportedEncodingException; -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. @@ -25,11 +25,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. @@ -53,14 +53,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; } @@ -76,9 +76,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() + " "); @@ -95,7 +95,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 ?????? @@ -114,7 +114,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() + " "); @@ -131,7 +131,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 8d5b1f208..278411e3d 100644 --- a/src/org/apache/fop/pdf/PDFShading.java +++ b/src/org/apache/fop/pdf/PDFShading.java @@ -9,7 +9,7 @@ package org.apache.fop.pdf; // Java... import java.io.UnsupportedEncodingException; -import java.util.Vector; +import java.util.ArrayList; // FOP import org.apache.fop.datatypes.ColorSpace; @@ -47,12 +47,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 @@ -66,12 +66,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: @@ -85,14 +85,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. @@ -111,7 +111,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. @@ -136,13 +136,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 theDomain Optional ArrayList of Doubles specifying the domain. + * @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 @@ -150,9 +150,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 @@ -178,23 +178,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 @@ -223,7 +223,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. @@ -231,15 +231,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 @@ -265,23 +265,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; @@ -329,7 +329,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"); @@ -340,7 +340,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"); @@ -356,7 +356,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"); @@ -368,7 +368,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"); @@ -386,7 +386,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"); @@ -397,7 +397,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"); @@ -409,7 +409,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"); @@ -453,7 +453,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"); @@ -485,7 +485,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 56d1e3af5..297d8ccc9 100644 --- a/src/org/apache/fop/pdf/PDFStream.java +++ b/src/org/apache/fop/pdf/PDFStream.java @@ -7,16 +7,16 @@ package org.apache.fop.pdf; +// Fop +import org.apache.fop.configuration.Configuration; +import org.apache.fop.messaging.MessageHandler; + // Java import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; -import java.util.Vector; -import java.util.Enumeration; -// Fop -import org.apache.fop.configuration.Configuration; -import org.apache.fop.messaging.MessageHandler; +import java.util.ArrayList; /** * class representing a PDF stream. @@ -36,7 +36,7 @@ public class PDFStream extends PDFObject { /** * the filters that should be applied */ - private Vector _filters; + private ArrayList _filters; /** * create an empty stream object @@ -46,7 +46,7 @@ public class PDFStream extends PDFObject { public PDFStream(int number) { super(number); _data = new ByteArrayOutputStream(); - _filters = new Vector(); + _filters = new ArrayList(); } /** @@ -76,7 +76,7 @@ public class PDFStream extends PDFObject { */ public void addFilter(PDFFilter filter) { if (filter != null) { - _filters.addElement(filter); + _filters.add(filter); } } @@ -101,7 +101,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 @@ -115,7 +115,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); } } @@ -277,13 +277,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 i = 0; i < _filters.size(); i++) { + PDFFilter filter = (PDFFilter)_filters.get(i); // apply the filter encoding if neccessary if (!filter.isApplied()) { byte[] tmp = filter.encode(_data.toByteArray()); @@ -291,9 +290,9 @@ public class PDFStream extends PDFObject { _data.write(tmp); filter.setApplied(true); } - // place the names in our local vector in reverse order - names.insertElementAt(filter.getName(), 0); - parms.insertElementAt(filter.getDecodeParms(), 0); + // place the names in our local ArrayList in reverse order + names.add(0, filter.getName()); + parms.add(0, filter.getDecodeParms()); } // now build up the filter entries for the dictionary @@ -303,15 +302,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 i = 0; i < names.size(); i++) { + sb.append((String)names.get(i)); sb.append(" "); } if (names.size() > 1) { @@ -321,7 +319,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 "); @@ -329,9 +327,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 i = 0; i < parms.size(); i++) { + String s = (String)parms.get(i); 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 da86f7d48..ff26ab572 100644 --- a/src/org/apache/fop/pdf/PDFWArray.java +++ b/src/org/apache/fop/pdf/PDFWArray.java @@ -9,7 +9,7 @@ package org.apache.fop.pdf; // Java import java.io.UnsupportedEncodingException; -import java.util.Vector; +import java.util.ArrayList; /** * class representing a W array for CID fonts. @@ -19,10 +19,10 @@ public class PDFWArray { /** * the metrics */ - private Vector entries; + private ArrayList entries; public PDFWArray() { - entries = new Vector(); + entries = new ArrayList(); } /** @@ -33,7 +33,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)); } /** @@ -44,7 +44,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 }); } @@ -59,7 +59,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 }); } @@ -77,7 +77,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/AbstractRenderer.java b/src/org/apache/fop/render/AbstractRenderer.java index 519e9e866..9199b00ce 100644 --- a/src/org/apache/fop/render/AbstractRenderer.java +++ b/src/org/apache/fop/render/AbstractRenderer.java @@ -24,8 +24,7 @@ import org.apache.avalon.framework.logger.Logger; // Java import java.io.IOException; import java.io.OutputStream; -import java.util.Enumeration; - +import java.util.ArrayList; /** * Abstract base class for all renderers. * @@ -53,9 +52,9 @@ public abstract class AbstractRenderer implements Renderer { } public void renderSpanArea(SpanArea area) { - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); // column areas } @@ -322,18 +321,18 @@ public abstract class AbstractRenderer implements Renderer { renderAreaContainer(area.getFootnoteReferenceArea()); // main reference area - Enumeration e = area.getMainReferenceArea().getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getMainReferenceArea().getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); // span areas } - if (area.getPosition() != Position.STATIC) { this.currentYPosition = saveY; this.currentAreaContainerXPosition = saveX; - } else + } else { this.currentYPosition -= area.getHeight(); + } } @@ -363,9 +362,9 @@ public abstract class AbstractRenderer implements Renderer { doBackground(area, rx, ry, w, h); - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); // span areas } @@ -405,9 +404,9 @@ public abstract class AbstractRenderer implements Renderer { this.currentXPosition = this.currentAreaContainerXPosition; doFrame(area); - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); } // Restore previous origin @@ -439,9 +438,9 @@ public abstract class AbstractRenderer implements Renderer { this.currentYPosition -= (area.getPaddingTop() + area.getBorderTopWidth()); doFrame(area); - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); } this.currentYPosition -= (area.getPaddingBottom() @@ -464,9 +463,9 @@ public abstract class AbstractRenderer implements Renderer { int bl = this.currentYPosition; - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); if (b instanceof InlineArea) { InlineArea ia = (InlineArea)b; this.currentYPosition = ry - ia.getYOffset(); diff --git a/src/org/apache/fop/render/PrintRenderer.java b/src/org/apache/fop/render/PrintRenderer.java index f19220700..bf1de6aeb 100644 --- a/src/org/apache/fop/render/PrintRenderer.java +++ b/src/org/apache/fop/render/PrintRenderer.java @@ -26,7 +26,6 @@ import org.apache.fop.svg.SVGArea; // Java import java.io.IOException; import java.io.OutputStream; -import java.util.Enumeration; /** * Abstract base class of "Print" type renderers. diff --git a/src/org/apache/fop/render/awt/AWTFontMetrics.java b/src/org/apache/fop/render/awt/AWTFontMetrics.java index ee4ea7ab1..8ad69b2ce 100644 --- a/src/org/apache/fop/render/awt/AWTFontMetrics.java +++ b/src/org/apache/fop/render/awt/AWTFontMetrics.java @@ -14,8 +14,6 @@ import org.apache.fop.layout.FontDescriptor; import org.apache.fop.layout.FontState; // Java -import java.util.Enumeration; -import java.util.Hashtable; import java.io.FileInputStream; import java.awt.Component; import java.awt.Font; @@ -25,6 +23,7 @@ import java.awt.geom.Rectangle2D; import java.awt.FontMetrics; import java.awt.font.FontRenderContext; import java.awt.font.TextLayout; +import java.util.HashMap; /** * This is a FontMetrics to be used for AWT rendering. @@ -97,12 +96,12 @@ public class AWTFontMetrics { /** * Embed Font List. */ - private Hashtable embedFontList = null; + private HashMap embedFontList = null; /** * Physical Font Cash. */ - private Hashtable fontCash = null; + private HashMap fontCash = null; /** * Constructs a new Font-metrics. @@ -256,7 +255,7 @@ public class AWTFontMetrics { */ public void setEmbedFont(String family,int style,String fontPath) { if (embedFontList == null) - embedFontList = new Hashtable(); + embedFontList = new HashMap(); embedFontList.put(family+style,fontPath); } @@ -274,7 +273,7 @@ public class AWTFontMetrics { return new Font(family, style, size); // lazy instanciation for fontCash. if (fontCash == null) - fontCash = new Hashtable(); + fontCash = new HashMap(); Font cashedFont = (Font)fontCash.get(fontPath); if (cashedFont == null) { // Create specified TrueType Font. diff --git a/src/org/apache/fop/render/awt/AWTRenderer.java b/src/org/apache/fop/render/awt/AWTRenderer.java index b88ba2965..42c893ef7 100644 --- a/src/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/org/apache/fop/render/awt/AWTRenderer.java @@ -14,14 +14,15 @@ package org.apache.fop.render.awt; * Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com */ -import org.apache.fop.layout.*; -import org.apache.fop.layout.inline.*; +import org.apache.fop.apps.*; import org.apache.fop.datatypes.*; import org.apache.fop.image.*; -import org.apache.fop.svg.*; +import org.apache.fop.layout.*; +import org.apache.fop.layout.inline.*; +import org.apache.fop.render.AbstractRenderer; import org.apache.fop.render.pdf.*; +import org.apache.fop.svg.*; import org.apache.fop.viewer.*; -import org.apache.fop.apps.*; import org.w3c.dom.svg.*; import org.w3c.dom.Document; @@ -37,20 +38,18 @@ import org.apache.batik.gvt.event.*; import java.awt.*; import java.awt.Image; -import java.awt.image.*; -import java.awt.geom.*; import java.awt.font.*; -import java.util.*; -import java.net.URL; -import java.net.MalformedURLException; -import java.io.*; -import java.beans.*; -import javax.swing.*; -import java.awt.print.*; +import java.awt.geom.*; +import java.awt.image.*; import java.awt.image.BufferedImage; +import java.awt.print.*; +import java.beans.*; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; import java.text.*; - -import org.apache.fop.render.AbstractRenderer; +import java.util.*; +import javax.swing.*; /** Modified by Mark Lillywhite mark-fop@inomial.com. Did lots of @@ -68,8 +67,8 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable protected ProgressListener progressListener = null; protected Translator res = null; - protected Hashtable fontNames = new Hashtable(); - protected Hashtable fontStyles = new Hashtable(); + protected HashMap fontNames = new HashMap(); + protected HashMap fontStyles = new HashMap(); protected Color saveColor = null; protected IDReferences idReferences = null; @@ -344,7 +343,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable return; try { - render((Page) pageList.elementAt(aPageNumber)); + render((Page) pageList.get(aPageNumber)); } catch(IOException e) { e.printStackTrace(); // This exception can't occur because we are not dealing with @@ -355,7 +354,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable public void render(Page page, OutputStream stream) throws IOException { - pageList.addElement(page); + pageList.add(page); } public void render(Page page) @@ -859,7 +858,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable int oldPageNumber = pageNumber; graphics = (Graphics2D)g; - Page aPage = (Page)pageList.elementAt(pageIndex); + Page aPage = (Page)pageList.get(pageIndex); renderPage(aPage); graphics = oldGraphics; @@ -875,7 +874,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable if (pageIndex >= pageList.size()) return null; - Page page = (Page)pageList.elementAt(pageIndex); + Page page = (Page)pageList.get(pageIndex); PageFormat pageFormat = new PageFormat(); Paper paper = new Paper(); @@ -932,7 +931,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable * for (int i = 0; i < transform.size(); i++) { * org.w3c.dom.svg.SVGTransform t = * (org.w3c.dom.svg.SVGTransform) - * transform.elementAt(i); + * transform.get(i); * SVGMatrix matrix = t.getMatrix(); * aTransform = new AffineTransform(matrix.getA(), * matrix.getB(), matrix.getC(), matrix.getD(), diff --git a/src/org/apache/fop/render/awt/FontMetricsMapper.java b/src/org/apache/fop/render/awt/FontMetricsMapper.java index a8499a4d1..5db5dea71 100644 --- a/src/org/apache/fop/render/awt/FontMetricsMapper.java +++ b/src/org/apache/fop/render/awt/FontMetricsMapper.java @@ -14,8 +14,6 @@ import org.apache.fop.layout.FontDescriptor; import org.apache.fop.layout.FontState; // Java -import java.util.Enumeration; -import java.util.Hashtable; import java.awt.Graphics2D; import java.awt.Font; diff --git a/src/org/apache/fop/render/awt/FontSetup.java b/src/org/apache/fop/render/awt/FontSetup.java index 1b988869c..4fe1c1794 100644 --- a/src/org/apache/fop/render/awt/FontSetup.java +++ b/src/org/apache/fop/render/awt/FontSetup.java @@ -17,11 +17,9 @@ import org.apache.fop.apps.FOPException; // Java -import java.util.Enumeration; -import java.util.Hashtable; import java.awt.Font; import java.awt.Graphics2D; -import java.util.Vector; +import java.util.ArrayList; /** * sets up the AWT fonts. It is similar to @@ -197,13 +195,13 @@ public class FontSetup { FontMetricsMapper metric; String internalName = null; - Vector fontInfos = Configuration.getFonts(); + ArrayList fontInfos = Configuration.getFonts(); if (fontInfos == null) return; - for (Enumeration e = fontInfos.elements(); e.hasMoreElements(); ) { + for (int i = 0; i < fontInfos.size(); i++) { org.apache.fop.configuration.FontInfo configFontInfo = - (org.apache.fop.configuration.FontInfo)e.nextElement(); + (org.apache.fop.configuration.FontInfo)fontInfos.get(i); try { String metricsFile = configFontInfo.getMetricsFile(); @@ -211,10 +209,9 @@ public class FontSetup { internalName = "F" + num; num++; - Vector triplets = configFontInfo.getFontTriplets(); - for (Enumeration t = triplets.elements(); - t.hasMoreElements(); ) { - FontTriplet triplet = (FontTriplet)t.nextElement(); + ArrayList triplets = configFontInfo.getFontTriplets(); + for (int j = 0; j < triplets.size(); j++) { + FontTriplet triplet = (FontTriplet)triplets.get(j); boolean embed = configFontInfo.getEmbedFile() != null; // if embed font is not specified, use system "Dialog" // logical font name for each Locale. 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/mif/MIFRenderer.java b/src/org/apache/fop/render/mif/MIFRenderer.java index fc4dcda98..073c7542d 100644 --- a/src/org/apache/fop/render/mif/MIFRenderer.java +++ b/src/org/apache/fop/render/mif/MIFRenderer.java @@ -31,10 +31,7 @@ import org.w3c.dom.svg.SVGLength; // Java import java.io.IOException; import java.io.OutputStream; -import java.util.Enumeration; import java.awt.Rectangle; -import java.util.Vector; -import java.util.Hashtable; /** * Renderer that renders areas to MIF diff --git a/src/org/apache/fop/render/pcl/PCLRenderer.java b/src/org/apache/fop/render/pcl/PCLRenderer.java index fc395ab24..a0fe2bd67 100755 --- a/src/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/org/apache/fop/render/pcl/PCLRenderer.java @@ -26,7 +26,6 @@ import org.w3c.dom.svg.SVGDocument; // Java import java.io.IOException; import java.io.OutputStream; -import java.util.Enumeration; /** * Renderer that renders areas to PCL diff --git a/src/org/apache/fop/render/pdf/FontReader.java b/src/org/apache/fop/render/pdf/FontReader.java index 132030d92..8ed04813d 100644 --- a/src/org/apache/fop/render/pdf/FontReader.java +++ b/src/org/apache/fop/render/pdf/FontReader.java @@ -14,9 +14,8 @@ import org.xml.sax.InputSource; 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.Hashtable; +import java.util.ArrayList; +import java.util.HashMap; import org.apache.fop.pdf.PDFWArray; import org.apache.fop.pdf.PDFCIDFont; import org.apache.fop.configuration.ConfigurationReader; @@ -41,12 +40,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 HashMap currentKerning = null; - private Vector bfranges = null; + private ArrayList bfranges = null; private void createFont(String path) throws FOPException { XMLReader parser = ConfigurationReader.createParser(); @@ -145,9 +144,9 @@ 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(); + currentKerning = new HashMap(); if (isCID) multiFont.kerning.put(new Integer(attributes.getValue("kpx1")), currentKerning); @@ -155,15 +154,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)) { @@ -267,11 +266,8 @@ public class FontReader extends DefaultHandler { multiFont.defaultWidth = getInt(text); } 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(); - wds[j++] = i.intValue(); + for (int i = 0; i < cidWidths.size(); i++ ) { + wds[i] = ((Integer)cidWidths.get(i)).intValue(); } multiFont.warray.addEntry(cidWidthIndex, wds); @@ -279,7 +275,7 @@ public class FontReader extends DefaultHandler { } else if ("bfranges".equals(localName)) { BFEntry[] entries = new BFEntry[bfranges.size()]; - bfranges.copyInto(entries); + entries = (BFEntry[])bfranges.toArray(entries); multiFont.bfentries = entries; } diff --git a/src/org/apache/fop/render/pdf/FontSetup.java b/src/org/apache/fop/render/pdf/FontSetup.java index a767ad10d..5f4df68c0 100644 --- a/src/org/apache/fop/render/pdf/FontSetup.java +++ b/src/org/apache/fop/render/pdf/FontSetup.java @@ -19,9 +19,9 @@ import org.apache.fop.configuration.FontTriplet; import org.apache.fop.apps.FOPException; // 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; /** * sets up the PDF fonts. @@ -145,13 +145,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 i = 0; i < fontInfos.size(); i++) { org.apache.fop.configuration.FontInfo configFontInfo = - (org.apache.fop.configuration.FontInfo)e.nextElement(); + (org.apache.fop.configuration.FontInfo)fontInfos.get(i); try { String metricsFile = configFontInfo.getMetricsFile(); @@ -169,10 +169,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 j = 0; j < triplets.size(); j++) { + FontTriplet triplet = (FontTriplet)triplets.get(j); fontInfo.addFontProperties(internalName, triplet.getName(), @@ -195,11 +194,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/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index 764cae951..eaab64a22 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -38,9 +38,8 @@ 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.util.ArrayList; +import java.util.HashMap; import java.awt.geom.AffineTransform; import java.awt.geom.Dimension2D; import java.awt.Point; @@ -123,7 +122,7 @@ public class PDFRenderer extends PrintRenderer { */ protected java.util.HashMap options; - protected Vector extensions = null; + protected ArrayList extensions = null; /** * create the PDF renderer @@ -590,7 +589,7 @@ public class PDFRenderer extends PrintRenderer { StringBuffer pdf = _wordAreaPDF; pdf.setLength(0); - Hashtable kerning = null; + HashMap kerning = null; boolean kerningAvailable = false; kerning = area.getFontState().getKerning(); @@ -783,9 +782,9 @@ public class PDFRenderer extends PrintRenderer { } private void addKerning(StringBuffer buf, Integer ch1, Integer ch2, - Hashtable kerning, String startText, + HashMap kerning, String startText, String endText) { - Hashtable kernPair = (Hashtable) kerning.get(ch1); + HashMap kernPair = (HashMap) kerning.get(ch1); if (kernPair != null) { Integer width = (Integer) kernPair.get(ch2); @@ -813,7 +812,7 @@ public class PDFRenderer extends PrintRenderer { this.pdfDoc.setIDReferences(idReferences); this.renderPage(page); - Vector exts = page.getExtensions(); + ArrayList exts = page.getExtensions(); if (exts != null) { extensions = exts; } @@ -853,16 +852,16 @@ public class PDFRenderer extends PrintRenderer { } currentPage.setAnnotList(currentAnnotList); - Enumeration e = page.getLinkSets().elements(); - while (e.hasMoreElements()) { - LinkSet linkSet = (LinkSet) e.nextElement(); + ArrayList linkSets = page.getLinkSets(); + for (int i = 0; i < linkSets.size(); i++) { + LinkSet linkSet = (LinkSet)linkSets.get(i); linkSet.align(); String dest = linkSet.getDest(); int linkType = linkSet.getLinkType(); - Enumeration f = linkSet.getRects().elements(); - while (f.hasMoreElements()) { - LinkedRectangle lrect = (LinkedRectangle) f.nextElement(); + ArrayList linkRects = linkSet.getRects(); + for (int j = 0; j < linkRects.size(); j++) { + LinkedRectangle lrect = (LinkedRectangle)linkRects.get(j); currentAnnotList.addLink( this.pdfDoc.makeLink(lrect.getRectangle(), dest, linkType)); @@ -910,11 +909,10 @@ public class PDFRenderer extends PrintRenderer { * * @param exts the list of root extensions to process */ - protected void renderRootExtensions(Vector exts) { - if (exts != null) { - Enumeration e = exts.elements(); - while (e.hasMoreElements()) { - ExtensionObj ext = (ExtensionObj) e.nextElement(); + protected void renderRootExtensions(ArrayList extensions) { + if (extensions != null) { + for (int i = 0; i < extensions.size(); i++) { + ExtensionObj ext = (ExtensionObj) extensions.get(i); if (ext instanceof Outline) { renderOutline((Outline) ext); } @@ -947,10 +945,9 @@ public class PDFRenderer extends PrintRenderer { outline.setRendererObject(pdfOutline); // handle sub outlines - Vector v = outline.getOutlines(); - Enumeration e = v.elements(); - while (e.hasMoreElements()) { - renderOutline((Outline) e.nextElement()); + ArrayList v = outline.getOutlines(); + for (int i = 0; i < v.size(); i++) { + renderOutline((Outline) v.get(i)); } } diff --git a/src/org/apache/fop/render/pdf/fonts/LazyFont.java b/src/org/apache/fop/render/pdf/fonts/LazyFont.java index e9fc2caee..062d03f83 100644 --- a/src/org/apache/fop/render/pdf/fonts/LazyFont.java +++ b/src/org/apache/fop/render/pdf/fonts/LazyFont.java @@ -11,7 +11,7 @@ import org.apache.fop.render.pdf.Font; import org.apache.fop.layout.FontDescriptor; import org.apache.fop.pdf.PDFStream; import org.apache.fop.messaging.MessageHandler; -import java.util.Hashtable; +import java.util.HashMap; import org.apache.fop.render.pdf.FontReader; @@ -158,7 +158,7 @@ public class LazyFont extends Font implements FontDescriptor { return realFontDescriptor.hasKerningInfo(); } - public Hashtable getKerningInfo(){ + public HashMap getKerningInfo(){ load(); return realFontDescriptor.getKerningInfo(); } diff --git a/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java b/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java index 7a667d79b..9f6d27c70 100644 --- a/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java +++ b/src/org/apache/fop/render/pdf/fonts/MultiByteFont.java @@ -7,24 +7,25 @@ package org.apache.fop.render.pdf.fonts; -import org.apache.fop.render.pdf.Font; -import org.apache.fop.layout.FontDescriptor; +import org.apache.fop.fonts.FontFileReader; import org.apache.fop.fonts.Glyphs; import org.apache.fop.fonts.TTFSubSetFile; -import org.apache.fop.fonts.FontFileReader; +import org.apache.fop.layout.FontDescriptor; +import org.apache.fop.messaging.MessageHandler; +import org.apache.fop.pdf.PDFCIDFont; import org.apache.fop.pdf.PDFStream; +import org.apache.fop.pdf.PDFTTFStream; import org.apache.fop.pdf.PDFWArray; -import org.apache.fop.pdf.PDFCIDFont; import org.apache.fop.render.pdf.CIDFont; import org.apache.fop.render.pdf.CMap; -import org.apache.fop.pdf.PDFTTFStream; -import org.apache.fop.messaging.MessageHandler; +import org.apache.fop.render.pdf.Font; + import java.io.InputStream; import java.io.IOException; import java.io.FileInputStream; import java.io.File; import java.io.BufferedInputStream; -import java.util.Hashtable; +import java.util.HashMap; /** * Generic MultiByte (CID) font @@ -53,7 +54,7 @@ public class MultiByteFont extends CIDFont implements FontDescriptor { public int defaultWidth = 0; public byte cidType = PDFCIDFont.CID_TYPE2; - public Hashtable kerning = new Hashtable(); + public HashMap kerning = new HashMap(); public boolean useKerning = true; private String namePrefix = null; // Quasi unique prefix private static int uniqueCounter = 1; @@ -66,12 +67,12 @@ public class MultiByteFont extends CIDFont implements FontDescriptor { /** * usedGlyphs contains orginal, new glyph index */ - private Hashtable usedGlyphs = new Hashtable(); + private HashMap usedGlyphs = new HashMap(); /** * usedGlyphsIndex contains new glyph, original index */ - private Hashtable usedGlyphsIndex = new Hashtable(); + private HashMap usedGlyphsIndex = new HashMap(); int usedGlyphsCount = 0; public MultiByteFont() { @@ -99,11 +100,11 @@ public class MultiByteFont extends CIDFont implements FontDescriptor { return (useKerning & kerning.isEmpty()); } - public final java.util.Hashtable getKerningInfo() { + public final java.util.HashMap getKerningInfo() { if (useKerning) return kerning; else - return new Hashtable(); + return new HashMap(); } public byte getSubType() { diff --git a/src/org/apache/fop/render/pdf/fonts/SingleByteFont.java b/src/org/apache/fop/render/pdf/fonts/SingleByteFont.java index 1654882c2..f049d6c7c 100644 --- a/src/org/apache/fop/render/pdf/fonts/SingleByteFont.java +++ b/src/org/apache/fop/render/pdf/fonts/SingleByteFont.java @@ -7,17 +7,18 @@ package org.apache.fop.render.pdf.fonts; -import org.apache.fop.render.pdf.Font; -import org.apache.fop.render.pdf.CodePointMapping; -import org.apache.fop.layout.FontDescriptor; import org.apache.fop.fonts.Glyphs; +import org.apache.fop.layout.FontDescriptor; import org.apache.fop.pdf.PDFStream; -import org.apache.fop.pdf.PDFTTFStream; import org.apache.fop.pdf.PDFT1Stream; -import java.io.InputStream; +import org.apache.fop.pdf.PDFTTFStream; +import org.apache.fop.render.pdf.CodePointMapping; +import org.apache.fop.render.pdf.Font; + import java.io.FileInputStream; +import java.io.InputStream; import java.io.BufferedInputStream; -import java.util.Hashtable; +import java.util.HashMap; /** * Generic SingleByte font @@ -47,7 +48,7 @@ public class SingleByteFont extends Font implements FontDescriptor { public int italicAngle = 0; public int missingWidth = 0; - public Hashtable kerning = new Hashtable(); + public HashMap kerning = new HashMap(); public boolean useKerning = true; public int width[] = null; @@ -57,11 +58,11 @@ public class SingleByteFont extends Font implements FontDescriptor { return (useKerning & kerning.isEmpty()); } - public final java.util.Hashtable getKerningInfo() { + public final java.util.HashMap getKerningInfo() { if (useKerning) return kerning; else - return new Hashtable(); + return new HashMap(); } public byte getSubType() { diff --git a/src/org/apache/fop/render/ps/PSGraphics2D.java b/src/org/apache/fop/render/ps/PSGraphics2D.java index d2fe4d3b2..bedcfd94c 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 @@ -518,40 +518,40 @@ return false; 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 041cf74d7..746a424cc 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -42,9 +42,9 @@ 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.ArrayList; +import java.util.HashMap; import java.awt.geom.AffineTransform; import java.awt.geom.Dimension2D; import java.awt.Point; @@ -239,10 +239,10 @@ public class PSRenderer extends AbstractRenderer { write("/FOPFonts 100 dict dup begin"); // 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"); } @@ -250,9 +250,9 @@ public class PSRenderer extends AbstractRenderer { write("%%EndResource"); //Rewrite font encodings - 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"); @@ -770,9 +770,9 @@ public class PSRenderer extends AbstractRenderer { String fontWeight = area.getFontState().getFontWeight(); //comment("% --- LineArea begin font-weight="+fontWeight); - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); this.currentYPosition = ry - area.getPlacementOffset(); b.render(this); } diff --git a/src/org/apache/fop/render/svg/SVGRenderer.java b/src/org/apache/fop/render/svg/SVGRenderer.java index 7cb6254b4..c2e930a81 100644 --- a/src/org/apache/fop/render/svg/SVGRenderer.java +++ b/src/org/apache/fop/render/svg/SVGRenderer.java @@ -36,7 +36,7 @@ import java.awt.Color; import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.geom.Rectangle2D; -import java.util.Hashtable; +import java.util.HashMap; import java.net.URL; import java.net.MalformedURLException; import java.io.OutputStream; @@ -60,8 +60,8 @@ public class SVGRenderer extends AbstractRenderer { protected int pageHeight = 0; protected int pageNumber = 0; - protected Hashtable fontNames = new Hashtable(); - protected Hashtable fontStyles = new Hashtable(); + protected HashMap fontNames = new HashMap(); + protected HashMap fontStyles = new HashMap(); protected Color saveColor = null; protected IDReferences idReferences = null; diff --git a/src/org/apache/fop/render/txt/TXTRenderer.java b/src/org/apache/fop/render/txt/TXTRenderer.java index b954cb1d1..6cec9c672 100755 --- a/src/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/org/apache/fop/render/txt/TXTRenderer.java @@ -30,9 +30,7 @@ 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; +import java.util.ArrayList; /** * Renderer that renders areas to plain text @@ -296,7 +294,7 @@ public class TXTRenderer extends PrintRenderer { */ } - private void xferLineBytes(int startpos, int bitcount, Vector save, + private void xferLineBytes(int startpos, int bitcount, ArrayList save, int start2) { /* * Not yet implemented @@ -403,7 +401,7 @@ public class TXTRenderer extends PrintRenderer { * { * String line = "\033*b" + dlen + "W" + new String(bytes, 0, dlen); * //currentStream.add(line); - * save.addElement(line); + * save.add(line); * } */ } @@ -662,7 +660,7 @@ public class TXTRenderer extends PrintRenderer { * long dx = 0; * long dy = TwoAsquared * b; * int rectlen = iw - 2 * irx; - * Vector bottomlines = new Vector(); + * ArrayList bottomlines = new ArrayList(); * int x0 = tx; * // Set Transparency modes and select shading. * currentStream.add("\033*v0n1O\033*c" + (int)(100 - ((0.3f * thecolor.red() + 0.59f * thecolor.green() + 0.11f * thecolor.blue()) * 100f)) + "G\033*v2T"); @@ -720,7 +718,7 @@ public class TXTRenderer extends PrintRenderer { * } * // Draw the bottom. * for ( int countr = bottomlines.size() - 1 ; countr >= 0 ; countr-- ) - * currentStream.add((String)bottomlines.elementAt(countr)); + * currentStream.add((String)bottomlines.get(countr)); * // End raster graphics * currentStream.add("\033*rB"); * // Return to regular print mode. @@ -733,7 +731,7 @@ public class TXTRenderer extends PrintRenderer { } // Add a polyline or polygon. Does not support fills yet!!! - protected void addPolyline(Vector points, int posx, int posy, + protected void addPolyline(ArrayList points, int posx, int posy, PDFColor fc, PDFColor sc, float sw, boolean close) {} @@ -1265,7 +1263,7 @@ public class TXTRenderer extends PrintRenderer { * float ty = tg.y; * float currentX = x + tx; * float currentY = y + ty; - * Vector list = tg.textList; + * ArrayList list = tg.textList; * for ( Enumeration e = list.elements() ; e.hasMoreElements() ; ) * { * Object o = e.nextElement(); @@ -1395,13 +1393,13 @@ public class TXTRenderer extends PrintRenderer { * xpos = currentX; * ypos = currentY; * if ( tsg.ylist.size() > charPos ) - * ypos = y + ty + ((Float)tsg.ylist.elementAt(charPos)).floatValue(); + * ypos = y + ty + ((Float)tsg.ylist.get(charPos)).floatValue(); * if ( tsg.dylist.size() > charPos ) - * ypos = ypos + ((Float)tsg.dylist.elementAt(charPos)).floatValue(); + * ypos = ypos + ((Float)tsg.dylist.get(charPos)).floatValue(); * if ( tsg.xlist.size() > charPos ) - * xpos = x + tx + ((Float)tsg.xlist.elementAt(charPos)).floatValue(); + * xpos = x + tx + ((Float)tsg.xlist.get(charPos)).floatValue(); * if ( tsg.dxlist.size() > charPos ) - * xpos = xpos + ((Float)tsg.dxlist.elementAt(charPos)).floatValue(); + * xpos = xpos + ((Float)tsg.dxlist.get(charPos)).floatValue(); * switch (ch) * { * case ' ': diff --git a/src/org/apache/fop/render/xml/XMLRenderer.java b/src/org/apache/fop/render/xml/XMLRenderer.java index c579a545f..42cdb5e69 100644 --- a/src/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/org/apache/fop/render/xml/XMLRenderer.java @@ -26,8 +26,7 @@ import org.apache.avalon.framework.logger.Logger; import java.io.IOException; import java.io.PrintWriter; import java.io.OutputStream; -import java.util.Enumeration; -import java.util.Hashtable; +import java.util.ArrayList; /** * Renderer that renders areas to XML for debugging purposes. @@ -203,9 +202,9 @@ public class XMLRenderer implements Renderer { */ public void renderAreaContainer(AreaContainer area) { writeStartTag(""); - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); } writeEndTag(""); @@ -218,9 +217,9 @@ public class XMLRenderer implements Renderer { */ public void renderBodyAreaContainer(BodyAreaContainer area) { writeStartTag(""); - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); } writeEndTag(""); @@ -242,9 +241,9 @@ public class XMLRenderer implements Renderer { */ public void renderSpanArea(SpanArea area) { writeStartTag(""); - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); } writeEndTag(""); @@ -274,12 +273,12 @@ public class XMLRenderer implements Renderer { writeStartTag(baText.toString()); // write out marker info - java.util.Vector markers = area.getMarkers(); + ArrayList markers = area.getMarkers(); if (!markers.isEmpty()) { writeStartTag(""); - for (int m = 0; m < markers.size(); m++) { + for (int i = 0; i < markers.size(); i++) { org.apache.fop.fo.flow.Marker marker = - (org.apache.fop.fo.flow.Marker)markers.elementAt(m); + (org.apache.fop.fo.flow.Marker)markers.get(i); StringBuffer maText = new StringBuffer(); maText.append(""); } - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); } writeEndTag(""); @@ -312,12 +311,12 @@ public class XMLRenderer implements Renderer { writeStartTag(iaText.toString()); // write out marker info - java.util.Vector markers = area.getMarkers(); + ArrayList markers = area.getMarkers(); if (!markers.isEmpty()) { writeStartTag(""); - for (int m = 0; m < markers.size(); m++) { + for (int i = 0; i < markers.size(); i++) { org.apache.fop.fo.flow.Marker marker = - (org.apache.fop.fo.flow.Marker)markers.elementAt(m); + (org.apache.fop.fo.flow.Marker)markers.get(i); StringBuffer maText = new StringBuffer(); maText.append(""); } - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); } writeEndTag(""); @@ -425,9 +424,9 @@ public class XMLRenderer implements Renderer { String fontWeight = area.getFontState().getFontWeight(); writeStartTag(""); } - Enumeration e = area.getChildren().elements(); - while (e.hasMoreElements()) { - Box b = (Box)e.nextElement(); + ArrayList children = area.getChildren(); + for (int i = 0; i < children.size(); i++) { + Box b = (Box)children.get(i); b.render(this); } if (!isCoarseXml()) diff --git a/src/org/apache/fop/svg/PDFGraphics2D.java b/src/org/apache/fop/svg/PDFGraphics2D.java index 69acebab5..cca6ce82c 100644 --- a/src/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/org/apache/fop/svg/PDFGraphics2D.java @@ -7,34 +7,32 @@ package org.apache.fop.svg; -import org.apache.fop.pdf.*; -import org.apache.fop.layout.*; +import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.ColorSpace; import org.apache.fop.fonts.*; -import org.apache.fop.render.pdf.*; import org.apache.fop.image.*; -import org.apache.fop.datatypes.ColorSpace; +import org.apache.fop.layout.*; +import org.apache.fop.pdf.*; +import org.apache.fop.render.pdf.*; import org.apache.fop.render.pdf.CIDFont; import org.apache.fop.render.pdf.fonts.LazyFont; -import org.apache.fop.apps.FOPException; import org.apache.batik.ext.awt.g2d.*; import org.apache.batik.ext.awt.image.GraphicsUtil; -import java.text.AttributedCharacterIterator; -import java.text.CharacterIterator; import java.awt.*; import java.awt.Font; import java.awt.Image; -import java.awt.image.*; import java.awt.font.*; import java.awt.geom.*; +import java.awt.image.*; import java.awt.image.renderable.*; import java.io.*; - -import java.util.Map; +import java.text.AttributedCharacterIterator; +import java.text.CharacterIterator; +import java.util.ArrayList; import java.util.HashMap; -import java.util.Vector; -import java.util.Hashtable; +import java.util.Map; /** * This concrete implementation of AbstractGraphics2D is a @@ -681,40 +679,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); @@ -911,7 +909,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { currentStream.write("BT\n"); - Hashtable kerning = null; + HashMap kerning = null; boolean kerningAvailable = false; kerning = fontState.getKerning(); @@ -988,9 +986,9 @@ public class PDFGraphics2D extends AbstractGraphics2D { } private void addKerning(StringWriter buf, Integer ch1, Integer ch2, - Hashtable kerning, String startText, + HashMap kerning, String startText, String endText) { - Hashtable kernPair = (Hashtable)kerning.get(ch1); + HashMap kernPair = (HashMap)kerning.get(ch1); if (kernPair != null) { Integer width = (Integer)kernPair.get(ch2); diff --git a/src/org/apache/fop/svg/SVGElementMapping.java b/src/org/apache/fop/svg/SVGElementMapping.java index cabf3667f..35b18641e 100644 --- a/src/org/apache/fop/svg/SVGElementMapping.java +++ b/src/org/apache/fop/svg/SVGElementMapping.java @@ -7,9 +7,6 @@ package org.apache.fop.svg; -import java.util.Enumeration; -import java.util.HashMap; - import org.apache.fop.fo.DirectPropertyListBuilder; import org.apache.fop.fo.TreeBuilder; import org.apache.fop.fo.FOTreeBuilder; @@ -18,6 +15,8 @@ import org.apache.fop.apps.Driver; import org.apache.batik.util.XMLResourceDescriptor; +import java.util.HashMap; + public class SVGElementMapping implements ElementMapping { private static HashMap foObjs = null; diff --git a/src/org/apache/fop/svg/SVGUserAgent.java b/src/org/apache/fop/svg/SVGUserAgent.java index 24fe7766b..2d23b2b88 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..69d723a09 100644 --- a/src/org/apache/fop/tools/anttasks/Compare.java +++ b/src/org/apache/fop/tools/anttasks/Compare.java @@ -7,12 +7,14 @@ package org.apache.fop.tools.anttasks; - -import java.util.*; -import java.io.*; import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; + +import java.io.*; import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.StringTokenizer; /** * This class is an extension of Ant, a script utility from @@ -48,12 +50,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(filenameList); } private boolean compareBytes(File oldFile, File newFile) { diff --git a/src/org/apache/fop/tools/anttasks/Fop.java b/src/org/apache/fop/tools/anttasks/Fop.java index 0a62013f4..bd914fb0a 100644 --- a/src/org/apache/fop/tools/anttasks/Fop.java +++ b/src/org/apache/fop/tools/anttasks/Fop.java @@ -49,7 +49,7 @@ import org.apache.avalon.framework.logger.Logger; */ public class Fop extends Task { File foFile; - Vector filesets = new Vector(); + ArrayList filesets = new ArrayList(); File outFile; File outDir; String format; //MIME type @@ -84,7 +84,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); } /** @@ -297,7 +297,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/tools/anttasks/RunTest.java b/src/org/apache/fop/tools/anttasks/RunTest.java index 53e58f89b..1de30b59f 100644 --- a/src/org/apache/fop/tools/anttasks/RunTest.java +++ b/src/org/apache/fop/tools/anttasks/RunTest.java @@ -76,15 +76,14 @@ public class RunTest extends Task { ClassLoader loader = new URLClassLoader(new URL[] { new URL("file:build/fop.jar") }); - Hashtable diff = runConverter(loader, "areatree", + HashMap diff = runConverter(loader, "areatree", "reference/output/"); if (diff != null &&!diff.isEmpty()) { System.out.println("===================================="); System.out.println("The following files differ:"); boolean broke = false; - for (Enumeration keys = diff.keys(); - keys.hasMoreElements(); ) { - Object fname = keys.nextElement(); + for (Iterator keys = diff.keySet().iterator(); keys.hasNext(); ) { + Object fname = keys.next(); Boolean pass = (Boolean)diff.get(fname); System.out.println("file: " + fname + " - reference success: " + pass); @@ -165,11 +164,11 @@ public class RunTest extends Task { * file in the base directory. * @param loader the class loader to use to run the tests with */ - protected Hashtable runConverter(ClassLoader loader, String dest, + protected HashMap runConverter(ClassLoader loader, String dest, String compDir) { String converter = "org.apache.fop.tools.TestConverter"; - Hashtable diff = null; + HashMap diff = null; try { Class cla = Class.forName(converter, true, loader); Object tc = cla.newInstance(); @@ -185,7 +184,7 @@ public class RunTest extends Task { meth = cla.getMethod("runTests", new Class[] { String.class, String.class, String.class }); - diff = (Hashtable)meth.invoke(tc, new Object[] { + diff = (HashMap)meth.invoke(tc, new Object[] { testsuite, dest, compDir }); } catch (Exception e) { diff --git a/src/org/apache/fop/tools/xslt/TraxTransform.java b/src/org/apache/fop/tools/xslt/TraxTransform.java index d997c1a27..d9010ee07 100644 --- a/src/org/apache/fop/tools/xslt/TraxTransform.java +++ b/src/org/apache/fop/tools/xslt/TraxTransform.java @@ -13,7 +13,7 @@ import java.io.FileInputStream; import java.io.InputStream; import java.io.Writer; -import java.util.Hashtable; +import java.util.HashMap; import org.w3c.dom.Document; /** @@ -25,7 +25,7 @@ public class TraxTransform { /** * Cache of compiled stylesheets (filename, StylesheetRoot) */ - private static Hashtable _stylesheetCache = new Hashtable(); + private static HashMap _stylesheetCache = new HashMap(); public static Transformer getTransformer(String xsltFilename, boolean cache) { diff --git a/src/org/apache/fop/viewer/LoadableProperties.java b/src/org/apache/fop/viewer/LoadableProperties.java index 4b28907a7..8ea837306 100644 --- a/src/org/apache/fop/viewer/LoadableProperties.java +++ b/src/org/apache/fop/viewer/LoadableProperties.java @@ -7,8 +7,9 @@ package org.apache.fop.viewer; -import java.io.*; import org.apache.fop.messaging.MessageHandler; + +import java.io.*; import java.util.*; /** diff --git a/src/org/apache/fop/viewer/PreviewDialog.java b/src/org/apache/fop/viewer/PreviewDialog.java index 4370435db..a0f694afb 100644 --- a/src/org/apache/fop/viewer/PreviewDialog.java +++ b/src/org/apache/fop/viewer/PreviewDialog.java @@ -668,7 +668,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); } -- 2.39.5