/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.configuration;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Iterator;
+import java.io.File;
+import java.net.URL;
import org.apache.fop.messaging.MessageHandler;
/**
/**
* stores the configuration information
*/
- private static HashMap standardConfiguration = new HashMap(30);
- private static HashMap pdfConfiguration = new HashMap(20);
- private static HashMap awtConfiguration = new HashMap(20);
+ private static Map standardConfiguration = new java.util.HashMap(30);
+ private static Map pdfConfiguration = new java.util.HashMap(20);
+ private static Map awtConfiguration = new java.util.HashMap(20);
/**
- * contains a HashMap of existing HashMaps
+ * contains a Map of existing Maps
*/
- private static HashMap configuration = new HashMap(3);
+ private static Map configuration = new java.util.HashMap(3);
+
+ //URL cache
+ private static URL cachedBaseURL = null;
+ private static URL cachedFontBaseURL = null;
/**
- * loads the configuration types into the configuration HashMap
+ * loads the configuration types into the configuration Map
*/
static {
configuration.put("standard", standardConfiguration);
configuration.put("awt", awtConfiguration);
}
- public static HashMap getConfiguration() {
+ public static Map getConfiguration() {
return configuration;
}
* general access method
*
* @param key a string containing the key value for the configuration value
- * role detemines the configuration target
+ * @param role detemines the configuration target
* @return Object containing the value; normally you would use one of the
- * convenience methods, which return the correct form.
+ * convenience methods, which return the correct form,
* null if the key is not defined.
*/
public static Object getValue(String key, int role) {
}
}
- ;
/**
* convenience methods to access strings values in the configuration
* @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return String a string containing the value
+ * @param role detemines the configuration target
+ * @return String a string containing the value,
* null if the key is not defined.
*/
public static String getStringValue(String key, int role) {
}
}
- ;
/**
* convenience methods to access int values in the configuration
* @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return int a int containing the value
+ * @param role detemines the configuration target
+ * @return int a int containing the value,
* -1 if the key is not defined.
*/
public static int getIntValue(String key, int role) {
}
}
- ;
/**
* convenience methods to access boolean values in the configuration
* @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return Boolean true or false as value
+ * @param role detemines the configuration target
+ * @return Boolean true or false as value,
* null if the key is not defined.
*/
public static Boolean getBooleanValue(String key, int role) {
}
}
- ;
/**
* 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 ArrayList a ArrayList containing the values
+ * @param role detemines the configuration target
+ * @return List a List containing the values,
* null if the key is not defined.
*/
- public static ArrayList getListValue(String key, int role) {
+ public static List getListValue(String key, int role) {
Object obj = Configuration.getValue(key, role);
- if (obj instanceof ArrayList) {
- return (ArrayList)obj;
+ if (obj instanceof List) {
+ return (List)obj;
} else {
return null;
}
}
- ;
/**
- * convenience methods to access map/HashMap values in the configuration
+ * convenience methods to access Map values in the configuration
* @param key a string containing the key value for the configuration value
- * role detemines the configuration target
- * @return HashMap a HashMap containing the values
+ * @param role detemines the configuration target
+ * @return Map a Map containing the values
* null if the key is not defined.
*/
- public static HashMap getHashMapValue(String key, int role) {
+ public static Map getMapValue(String key, int role) {
Object obj = Configuration.getValue(key, role);
- if (obj instanceof HashMap) {
- return (HashMap)obj;
+ if (obj instanceof Map) {
+ return (Map)obj;
} else {
return null;
}
}
- ;
-
/**
* convenience method which retrieves some configuration information
* convenience methods to access int values in the standard configuration
*
* @param key a string containing the key value for the configuration value
- * @return int a int containing the value
+ * @return int a int containing the value,
* -1 if the key is not defined.
*/
public static int getIntValue(String key) {
* convenience methods to access boolean values in the configuration
*
* @param key a string containing the key value for the configuration value
- * @return boolean true or false as value
+ * @return boolean true or false as value,
* null if the key is not defined.
*/
public static Boolean getBooleanValue(String key) {
* convenience methods to access list values in the standard configuration
*
* @param key a string containing the key value for the configuration value
- * @return ArrayList a ArrayList containing the values
+ * @return List a List containing the values,
* null if the key is not defined.
*/
- public static ArrayList getListValue(String key) {
+ public static List getListValue(String key) {
return Configuration.getListValue(key, Configuration.STANDARD);
}
/**
- * convenience methods to access map/HashMap values in the standard configuration
+ * convenience methods to access Map values in the standard configuration
*
* @param key a string containing the key value for the configuration value
- * @return HashMap a HashMap containing the values
+ * @return Map a Map containing the values,
* null if the key is not defined.
*/
- public static HashMap getHashMapValue(String key) {
- return Configuration.getHashMapValue(key, Configuration.STANDARD);
+ public static Map getMapValue(String key) {
+ return Configuration.getMapValue(key, Configuration.STANDARD);
}
/**
- * method to access fonts values in the standard configuration
+ * Method to access fonts values in the standard configuration
*
- * @param key a string containing the key value for the configuration value
- * @return HashMap a HashMap containing the values
+ * @return List a List containing the values,
* null if the key is not defined.
*/
- public static ArrayList getFonts() {
- return (ArrayList)Configuration.getValue("fonts",
+ public static List getFonts() {
+ return (List)Configuration.getValue("fonts",
Configuration.STANDARD);
}
+
+ private static URL buildBaseURL(String directory) throws java.net.MalformedURLException {
+ if (directory == null) return null;
+ File dir = new File(directory);
+ if (dir.isDirectory()) {
+ return dir.toURL();
+ } else {
+ URL baseURL = new URL(directory);
+ return baseURL;
+ }
+ }
+
+ public static URL getBaseURL() {
+ if (cachedBaseURL != null) {
+ return cachedBaseURL;
+ } else {
+ String baseDir = getStringValue("baseDir");
+ try {
+ URL url = buildBaseURL(baseDir);;
+ cachedBaseURL = url;
+ return url;
+ } catch (java.net.MalformedURLException mfue) {
+ throw new RuntimeException("Invalid baseDir specified: "+baseDir+" ("+mfue.getMessage()+")");
+ }
+ }
+ }
+
+
+ public static URL getFontBaseURL() {
+ if (cachedFontBaseURL != null) {
+ return cachedFontBaseURL;
+ } else {
+ URL url = null;
+ String baseDir = getStringValue("fontBaseDir");
+ if (baseDir == null) {
+ url = getBaseURL();
+ } else {
+ try {
+ url = buildBaseURL(baseDir);
+ } catch (java.net.MalformedURLException mfue) {
+ throw new RuntimeException("Invalid fontBaseDir specified: "+baseDir+" ("+mfue.getMessage()+")");
+ }
+ }
+ cachedFontBaseURL = url;
+ return url;
+ }
+ }
+
/**
- * initializes this configuration
+ * Initializes this configuration
+ * @param role detemines the configuration target
* @param config contains the configuration information
*/
- public static void setup(int role, HashMap config) {
+ public static void setup(int role, Map config) {
switch (role) {
case Configuration.STANDARD:
standardConfiguration = config;
default:
MessageHandler.errorln("Can't setup configuration. Unknown configuration role/target");
}
+ invalidateURLCache();
}
/**
- * adds information to the configuration map/HashMap in key,value form
+ * adds information to the configuration Map 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 ArrayList or a HashMap
+ * @param value the configuration information; can be a String, a List or a Map
+ * @param role detemines the configuration target
*/
public static void put(String key, Object value, int role) {
switch (role) {
+ "Putting key:" + key + " - value:"
+ value + " into standard configuration.");
}
+ invalidateURLCache();
}
- ;
-
/**
- * adds information to the standard configuration map/HashMap in key,value form
+ * adds information to the standard configuration Map 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 ArrayList or a HashMap
+ * @param value an Object containing the value; can be a String, a List or a Map
*/
public static void put(String key, Object value) {
Configuration.put(key, value, Configuration.STANDARD);
}
+ private static void invalidateURLCache() {
+ cachedBaseURL = null;
+ cachedFontBaseURL = null;
+ }
+
/**
* debug methods, which writes out all information in this configuration
*/
public static void dumpConfiguration() {
String key;
Object value;
- ArrayList list;
- HashMap map, configuration;
+ List list;
+ Map map, configuration;
String tmp;
System.out.println("Dumping configuration: ");
- HashMap[] configs = {
+ Map[] configs = {
standardConfiguration, pdfConfiguration, awtConfiguration
};
for (int i = 0; i < configs.length; i++) {
value = configuration.get(key);
if (value instanceof String) {
MessageHandler.logln(" value: " + value);
- } else if (value instanceof ArrayList) {
- list = (ArrayList)value;
+ } else if (value instanceof List) {
+ list = (List)value;
MessageHandler.log(" values: ");
for (int j = 0; j < list.size(); j++) {
MessageHandler.log(list.get(j) + " - ");
}
MessageHandler.logln("");
- } else if (value instanceof HashMap) {
- map = (HashMap)value;
+ } else if (value instanceof Map) {
+ map = (Map)value;
MessageHandler.log(" values: ");
Iterator it2 = map.keySet().iterator();
while (it2.hasNext()) {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import org.xml.sax.Locator;
// java
-import java.util.HashMap;
-import java.util.ArrayList;
+import java.util.Map;
+import java.util.List;
// fop
import org.apache.fop.messaging.MessageHandler;
private int datatype = -1;
// store the result configuration
- private static HashMap configuration;
- private static HashMap activeConfiguration;
+ private static Map configuration;
+ private static Map activeConfiguration;
// stores key for new config entry
private String key = "";
- private ArrayList keyStack = new ArrayList();
+ private List keyStack = new java.util.ArrayList();
// stores string value
private String value = "";
private String subkey = "";
// stores list value
- private ArrayList list = new ArrayList(15);
+ private List list = new java.util.ArrayList(15);
- // stores HashMap value
- private HashMap map = new HashMap(15);
+ // stores Map value
+ private Map map = new java.util.HashMap(15);
/**
* locator for line number information
private String role = "standard";
// stores fonts
- private ArrayList fontList = null;
+ private List fontList = null;
// stores information on one font
private FontInfo fontInfo = null;
// information on a font
private String fontName, metricsFile, embedFile, kerningAsString;
private boolean kerning;
- private ArrayList fontTriplets;
+ private List fontTriplets;
// information on a font triplet
private String fontTripletName, weight, style;
}
} else if (localName.equals("configuration")) {}
else if (localName.equals("fonts")) { // list of fonts starts
- fontList = new ArrayList(10);
+ fontList = new java.util.ArrayList(10);
} else if (localName.equals("font")) {
kerningAsString = attributes.getValue("kerning");
if (kerningAsString.equalsIgnoreCase("yes")) {
metricsFile = attributes.getValue("metrics-file");
embedFile = attributes.getValue("embed-file");
fontName = attributes.getValue("name");
- fontTriplets = new ArrayList(5);
+ fontTriplets = new java.util.ArrayList(5);
} else if (localName.equals("font-triplet")) {
fontTripletName = attributes.getValue("name");
weight = attributes.getValue("weight");
} // end characters
/**
- * stores configuration entry into configuration HashMap according to the role
+ * stores configuration entry into configuration Map 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 = (HashMap)configuration.get(role);
+ activeConfiguration = (Map)configuration.get(role);
if (activeConfiguration != null) {
activeConfiguration.put(key, value);
} else {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import java.io.File;
import java.net.URL;
import java.net.MalformedURLException;
-import java.util.ArrayList;
+import java.util.List;
// Fop
import org.apache.fop.apps.FOPException;
+import org.apache.fop.tools.URLBuilder;
/**
* FontInfo contains meta information on fonts (where is the metrics file etc.)
private String metricsFile, embedFile, name;
private boolean kerning;
- private ArrayList fontTriplets;
- private String baseDir;
+ private List fontTriplets;
public FontInfo(String name, String metricsFile, boolean kerning,
- ArrayList fontTriplets, String embedFile) {
+ List fontTriplets, String embedFile) {
this.name = name;
this.metricsFile = metricsFile;
this.embedFile = embedFile;
}
/**
- * @return the (absolute) file name of the metrics file
+ * @return the URL to the metrics file
*/
- public String getMetricsFile() throws FOPException {
- // check if it's a URL and convert it to a filename
+ public URL getMetricsFile() throws FOPException {
try {
- metricsFile = new URL(metricsFile).getFile();
- } catch (MalformedURLException mue) {}
-
- // check if filename is absolute
- if ((new File(metricsFile).isAbsolute())) {
- return metricsFile;
- } else {
- return getBaseDir() + metricsFile;
+ return URLBuilder.buildURL(Configuration.getFontBaseURL(), metricsFile);
+ } catch (Exception e) {
+ throw new FOPException("Invalid font metrics file: "+metricsFile+" ("+e.getMessage()+")");
}
}
/**
- * @return the (absolute) file name of the font
+ * @return the url to the font
*/
- public String getEmbedFile() throws FOPException {
+ public URL getEmbedFile() throws FOPException {
// check if it's a URL and convert it to a filename
- if (embedFile == null) return null;
+ if (embedFile == null) return null;
try {
- embedFile = new URL(embedFile).getFile();
- } catch (MalformedURLException mue) {}
-
- // check if filename is absolute
- if ((new File(embedFile).isAbsolute())) {
- return embedFile;
- } else {
- return getBaseDir() + embedFile;
+ return URLBuilder.buildURL(Configuration.getFontBaseURL(), embedFile);
+ } catch (Exception e) {
+ throw new FOPException("Invalid font file (embedFile): "+metricsFile+" ("+e.getMessage()+")");
}
}
return kerning;
}
- public ArrayList getFontTriplets() {
+ public List getFontTriplets() {
return fontTriplets;
}
- /**
- * @return BaseDir (path)
- */
- private String getBaseDir() throws FOPException {
- baseDir = Configuration.getStringValue("baseDir");
- URL baseURL = null;
- try {
- baseURL = new URL(baseDir);
- } catch (MalformedURLException mue) {
- // if the href contains only a path then file is assumed
- try {
- baseURL = new URL("file:" + baseDir);
- } catch (MalformedURLException mue2) {
- throw new FOPException("Error with baseDir: "
- + mue2.getMessage());
- }
- }
- baseDir = baseURL.getFile();
- return baseDir;
- }
-
-
}
*/
package org.apache.fop.fonts;
-import java.io.FileInputStream;
import java.io.InputStream;
+import java.io.OutputStream;
import java.io.File;
import java.io.IOException;
private byte[] file;
/**
- * Initialisez class and reads stream. Init does not close stream
- * @param stream InputStream to read from
- * @param start initial size av array to read to
- * @param inc if initial size isn't enough, create
+ * Initializes class and reads stream. Init does not close stream
+ * @param in InputStream to read from
* new array with size + inc
*/
- private void init(InputStream stream, int start,
- int inc) throws java.io.IOException {
- fsize = 0;
- current = 0;
-
- file = new byte[start];
-
- int l = stream.read(file, 0, start);
- fsize += l;
-
- if (l == start) {
- // More to read - needs to extend
- byte[] tmpbuf;
-
- while (l > 0) {
- tmpbuf = new byte[file.length + inc];
- System.arraycopy(file, 0, tmpbuf, 0, file.length);
- l = stream.read(tmpbuf, file.length, inc);
- fsize += l;
- file = tmpbuf;
-
- if (l < inc) // whole file read. No need to loop again
+ private void init(InputStream in) throws java.io.IOException {
+ java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
+ try {
+ copyStream(in, bout);
+ this.file = bout.toByteArray();
+ } finally {
+ bout.close();
+ }
+ }
- l = 0;
- }
+ /**@todo Use method from Avalon Excalibur IO or Jakarta Commons IO*/
+ private void copyStream(InputStream in, OutputStream out) throws IOException {
+ final int bufferSize = 2048;
+ final byte[] buffer = new byte[bufferSize];
+ byte[] buf = new byte[bufferSize];
+ int bytesRead;
+ while ((bytesRead = in.read(buf)) != -1) {
+ out.write(buf, 0, bytesRead);
}
}
* @param fileName filename to read
*/
public FontFileReader(String fileName) throws java.io.IOException {
-
- // Get estimates for file size and increment
File f = new File(fileName);
- FileInputStream ins = new FileInputStream(fileName);
- init(ins, (int)(f.length() + 1), (int)(f.length() / 10));
- ins.close();
+ InputStream in = new java.io.FileInputStream(fileName);
+ try {
+ init(in);
+ } finally {
+ in.close();
+ }
+ }
+
+
+ /**
+ * Constructor
+ * @param in InputStream to read from
+ */
+ public FontFileReader(InputStream in) throws java.io.IOException {
+ init(in);
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import org.apache.fop.messaging.MessageHandler;
-import java.io.*;
+import java.io.IOException;
import java.util.Iterator;
-import java.util.HashMap;
-import java.util.ArrayList;
+import java.util.Map;
+import java.util.List;
/**
* Reads a TrueType file and generates a subset
* Create the glyf table and fill in loca table
*/
private void createGlyf(FontFileReader in,
- HashMap glyphs) throws IOException {
+ Map glyphs) throws IOException {
TTFDirTabEntry entry = (TTFDirTabEntry)dirTabs.get("glyf");
int size = 0;
int start = 0;
/**
* Create the hmtx table by copying metrics from original
- * font to subset font. The glyphs HashMap contains an
+ * font to subset font. The glyphs Map contains an
* Integer key and Integer value that maps the original
* metric (key) to the subset metric (value)
*/
private void createHmtx(FontFileReader in,
- HashMap glyphs) throws IOException {
+ Map glyphs) throws IOException {
TTFDirTabEntry entry = (TTFDirTabEntry)dirTabs.get("hmtx");
int longHorMetricSize = glyphs.size() * 2;
}
/**
- * Returns a ArrayList containing the glyph itself plus all glyphs
+ * Returns a List containing the glyph itself plus all glyphs
* that this composite glyph uses
*/
- private ArrayList getIncludedGlyphs(FontFileReader in, int glyphOffset,
+ private List getIncludedGlyphs(FontFileReader in, int glyphOffset,
Integer glyphIdx) throws IOException {
- ArrayList ret = new ArrayList();
+ List ret = new java.util.ArrayList();
ret.add(glyphIdx);
int offset = glyphOffset + (int)mtx_tab[glyphIdx.intValue()].offset
+ 10;
* Rewrite all compositepointers in glyphindex glyphIdx
*
*/
- private void remapComposite(FontFileReader in, HashMap glyphs,
+ private void remapComposite(FontFileReader in, Map glyphs,
int glyphOffset,
Integer glyphIdx) throws IOException {
int offset = glyphOffset + (int)mtx_tab[glyphIdx.intValue()].offset
* mapping
*/
private void scanGlyphs(FontFileReader in,
- HashMap glyphs) throws IOException {
+ Map glyphs) throws IOException {
TTFDirTabEntry entry = (TTFDirTabEntry)dirTabs.get("glyf");
- HashMap newComposites = null;
- HashMap allComposites = new HashMap();
+ Map newComposites = null;
+ Map allComposites = new java.util.HashMap();
int newIndex = glyphs.size();
if (entry != null) {
while (newComposites == null || newComposites.size() > 0) {
// Inefficient to iterate through all glyphs
- newComposites = new HashMap();
+ newComposites = new java.util.HashMap();
for (Iterator e = glyphs.keySet().iterator(); e.hasNext(); ) {
Integer origIndex = (Integer)e.next();
+ mtx_tab[origIndex.intValue()].offset) < 0) {
// origIndex is a composite glyph
allComposites.put(origIndex, glyphs.get(origIndex));
- ArrayList composites =
+ List composites =
getIncludedGlyphs(in, (int)entry.offset,
origIndex);
*/
public byte[] readFont(FontFileReader in, String name,
- HashMap glyphs) throws IOException {
+ Map glyphs) throws IOException {
/*
* Check if TrueType collection, and that the name
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public int getStemV();
public boolean hasKerningInfo();
- public java.util.HashMap getKerningInfo();
+ public java.util.Map getKerningInfo();
public boolean isEmbeddable();
public byte getSubType();
public org.apache.fop.pdf.PDFStream getFontFile(int objNum);
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import org.apache.fop.fo.properties.FontVariant;
import org.apache.fop.render.pdf.CodePointMapping;
-import java.util.HashMap;
+import java.util.Map;
import java.util.StringTokenizer;
public class FontState {
private FontMetric _metric;
private int _letterSpacing;
- private static HashMap EMPTY_HASHMAP = new HashMap();
+ private static Map EMPTY_MAP = new java.util.HashMap();
public FontState(FontInfo fontInfo, String fontFamily, String fontStyle,
return _metric.getXHeight(_fontSize) / 1000;
}
- public HashMap getKerning() {
+ public Map getKerning() {
if (_metric instanceof FontDescriptor) {
- HashMap ret = ((FontDescriptor)_metric).getKerningInfo();
+ Map ret = ((FontDescriptor)_metric).getKerningInfo();
if (ret != null)
return ret;
}
- return EMPTY_HASHMAP;
+ return EMPTY_MAP;
}
public int width(int charnum) {
}
// Use default CodePointMapping
- char d = CodePointMapping.getMapping("WinAnsiEncoding").mapChar(c);
- if (d != 0) {
- c = d;
- } else {
- c = '#';
- }
+ char d = CodePointMapping.getMapping("WinAnsiEncoding").mapChar(c);
+ if (d != 0) {
+ c = d;
+ } else {
+ c = '#';
+ }
return c;
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.awt.Rectangle;
/**
/**
* the character position of each object
*/
- protected ArrayList location = new ArrayList();
+ protected List location = new java.util.ArrayList();
/** List of objects to write in the trailer */
- private ArrayList trailerObjects = new ArrayList();
+ private List trailerObjects = new java.util.ArrayList();
/**
* the counter for object numbering
/**
* the objects themselves
*/
- protected ArrayList objects = new ArrayList();
+ protected List objects = new java.util.ArrayList();
/**
* character position of xref table
/**
* the XObjects
*/
- protected ArrayList xObjects = new ArrayList();
+ protected List xObjects = new java.util.ArrayList();
/**
* the XObjects Map.
* Should be modified (works only for image subtype)
*/
- protected HashMap xObjectsMap = new HashMap();
+ protected Map xObjectsMap = new java.util.HashMap();
/**
* the objects themselves
*/
- protected ArrayList pendingLinks = null;
+ protected List pendingLinks = null;
/**
* Encoding of the PDF
/**
* Make a Type 0 sampled function
*
- * @param theDomain ArrayList objects of Double objects.
+ * @param theDomain List objects of Double objects.
* This is the domain of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theRange ArrayList objects of Double objects.
+ * @param theRange List objects of Double objects.
* This is the Range of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theSize A ArrayList object of Integer objects.
+ * @param theSize A List object of Integer objects.
* This is the number of samples in each input dimension.
* I can't imagine there being more or less than two input dimensions,
* so maybe this should be an array of length 2.
* This attribute is optional.
*
* See page 265 in the PDF 1.3 spec.
- * @param theEncode ArrayList objects of Double objects.
+ * @param theEncode List objects of Double objects.
* This is the linear mapping of input values intop the domain
* of the function's sample table. Default is hard to represent in
* ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
* This attribute is optional.
*
* See page 265 in the PDF 1.3 spec.
- * @param theDecode ArrayList objects of Double objects.
+ * @param theDecode List objects of Double objects.
* This is a linear mapping of sample values into the range.
* The default is just the range.
*
* This is optional, but is almost always used.
*
* Page 265 of the PDF 1.3 spec has more.
- * @param theFilter This is a ArrayList of String objects which are the various filters that
+ * @param theFilter This is a List of String objects which are the various filters that
* have are to be applied to the stream to make sense of it. Order matters,
* so watch out.
*
* @param theFunctionType This is the type of function (0,2,3, or 4).
* It should be 0 as this is the constructor for sampled functions.
*/
- public PDFFunction makeFunction(int theFunctionType, ArrayList theDomain,
- ArrayList theRange, ArrayList theSize,
+ public PDFFunction makeFunction(int theFunctionType, List theDomain,
+ List theRange, List theSize,
int theBitsPerSample, int theOrder,
- ArrayList theEncode, ArrayList theDecode,
+ List theEncode, List theDecode,
StringBuffer theFunctionDataStream,
- ArrayList theFilter) { // Type 0 function
+ List theFilter) { // Type 0 function
PDFFunction function = new PDFFunction(++this.objectcount,
theFunctionType, theDomain,
theRange, theSize,
* make a type Exponential interpolation function
* (for shading usually)
*
- * @param theDomain ArrayList objects of Double objects.
+ * @param theDomain List objects of Double objects.
* This is the domain of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theRange ArrayList of Doubles that is the Range of the function.
+ * @param theRange List of Doubles that is the Range of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theCZero This is a ArrayList of Double objects which defines the function result
+ * @param theCZero This is a List of Double objects which defines the function result
* when x=0.
*
* This attribute is optional.
* It's described on page 268 of the PDF 1.3 spec.
- * @param theCOne This is a ArrayList of Double objects which defines the function result
+ * @param theCOne This is a List of Double objects which defines the function result
* when x=1.
*
* This attribute is optional.
* PDF Spec page 268
* @param theFunctionType The type of the function, which should be 2.
*/
- public PDFFunction makeFunction(int theFunctionType, ArrayList theDomain,
- ArrayList theRange, ArrayList theCZero,
- ArrayList theCOne,
+ public PDFFunction makeFunction(int theFunctionType, List theDomain,
+ List theRange, List theCZero,
+ List theCOne,
double theInterpolationExponentN) { // type 2
PDFFunction function = new PDFFunction(++this.objectcount,
theFunctionType, theDomain,
/**
* Make a Type 3 Stitching function
*
- * @param theDomain ArrayList objects of Double objects.
+ * @param theDomain List objects of Double objects.
* This is the domain of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theRange ArrayList objects of Double objects.
+ * @param theRange List objects of Double objects.
* This is the Range of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theFunctions A ArrayList of the PDFFunction objects that the stitching function stitches.
+ * @param theFunctions A List of the PDFFunction objects that the stitching function stitches.
*
* This attributed is required.
* It is described on page 269 of the PDF spec.
- * @param theBounds This is a ArrayList of Doubles representing the numbers that,
+ * @param theBounds This is a List of Doubles representing the numbers that,
* in conjunction with Domain define the intervals to which each function from
* the 'functions' object applies. It must be in order of increasing magnitude,
* and each must be within Domain.
*
* This attributed is required.
* It's described on page 269 of the PDF 1.3 spec.
- * @param theEncode ArrayList objects of Double objects.
+ * @param theEncode List objects of Double objects.
* This is the linear mapping of input values intop the domain
* of the function's sample table. Default is hard to represent in
* ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
* @param theFunctionType This is the function type. It should be 3,
* for a stitching function.
*/
- public PDFFunction makeFunction(int theFunctionType, ArrayList theDomain,
- ArrayList theRange, ArrayList theFunctions,
- ArrayList theBounds,
- ArrayList theEncode) { // Type 3
+ public PDFFunction makeFunction(int theFunctionType, List theDomain,
+ List theRange, List theFunctions,
+ List theBounds,
+ List theEncode) { // Type 3
PDFFunction function = new PDFFunction(++this.objectcount,
theFunctionType, theDomain,
* @param theFunctionDataStream
*/
public PDFFunction makeFunction(int theNumber, int theFunctionType,
- ArrayList theDomain, ArrayList theRange,
+ List theDomain, List theRange,
StringBuffer theFunctionDataStream) { // Type 4
PDFFunction function = new PDFFunction(++this.objectcount,
theFunctionType, theDomain,
* @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 ArrayList of double's representing a rectangle
+ * @param theBBox List 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 ArrayList of Doubles specifying the domain.
- * @param theMatrix ArrayList of Doubles specifying the matrix.
+ * @param theDomain Optional List of Doubles specifying the domain.
+ * @param theMatrix List 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
*/
public PDFShading makeShading(int theShadingType,
ColorSpace theColorSpace,
- ArrayList theBackground, ArrayList theBBox,
- boolean theAntiAlias, ArrayList theDomain,
- ArrayList theMatrix,
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theDomain,
+ List theMatrix,
PDFFunction theFunction) { // make Shading of Type 1
String theShadingName = new String("Sh" + (++this.shadingCount));
* @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 ArrayList of double's representing a rectangle
+ * @param theBBox List 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 ArrayList of four (type 2) or 6 (type 3) Double
- * @param theDomain ArrayList of Doubles specifying the domain
+ * @param theCoords List of four (type 2) or 6 (type 3) Double
+ * @param theDomain List of Doubles specifying the domain
* @param theFunction the Stitching (PDFfunction type 3) function, even if it's stitching a single function
- * @param theExtend ArrayList of Booleans of whether to extend teh start and end colors past the start and end points
+ * @param theExtend List of Booleans of whether to extend teh start and end colors past the start and end points
* The default is [false, false]
*/
public PDFShading makeShading(int theShadingType,
ColorSpace theColorSpace,
- ArrayList theBackground, ArrayList theBBox,
- boolean theAntiAlias, ArrayList theCoords,
- ArrayList theDomain, PDFFunction theFunction,
- ArrayList theExtend) { // make Shading of Type 2 or 3
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theCoords,
+ List theDomain, PDFFunction theFunction,
+ List theExtend) { // make Shading of Type 2 or 3
String theShadingName = new String("Sh" + (++this.shadingCount));
PDFShading shading = new PDFShading(++this.objectcount,
* @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 ArrayList of double's representing a rectangle
+ * @param theBBox List of double's representing a rectangle
* in the coordinate space that is current at the
* time of shading is imaged. Temporary clipping
* boundary.
* @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 ArrayList of Doubles see PDF 1.3 spec pages 303 to 312.
+ * @param theDecode List of Doubles see PDF 1.3 spec pages 303 to 312.
* @param theFunction the PDFFunction
*/
public PDFShading makeShading(int theShadingType,
ColorSpace theColorSpace,
- ArrayList theBackground, ArrayList theBBox,
+ List theBackground, List theBBox,
boolean theAntiAlias,
int theBitsPerCoordinate,
int theBitsPerComponent,
- int theBitsPerFlag, ArrayList theDecode,
+ int theBitsPerFlag, List theDecode,
PDFFunction theFunction) { // make Shading of type 4,6 or 7
String theShadingName = new String("Sh" + (++this.shadingCount));
* @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 ArrayList of double's representing a rectangle
+ * @param theBBox List 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 ArrayList of Doubles. See page 305 in PDF 1.3 spec.
+ * @param theDecode List of Doubles. See page 305 in PDF 1.3 spec.
* @param theVerticesPerRow number of vertices in each "row" of the lattice.
* @param theFunction The PDFFunction that's mapped on to this shape
*/
public PDFShading makeShading(int theShadingType,
ColorSpace theColorSpace,
- ArrayList theBackground, ArrayList theBBox,
+ List theBackground, List theBBox,
boolean theAntiAlias,
int theBitsPerCoordinate,
- int theBitsPerComponent, ArrayList theDecode,
+ int theBitsPerComponent, List theDecode,
int theVerticesPerRow,
PDFFunction theFunction) { // make shading of Type 5
String theShadingName = new String("Sh" + (++this.shadingCount));
* @param theResources the resources associated with this pattern
* @param thePaintType 1 or 2, colored or uncolored.
* @param theTilingType 1, 2, or 3, constant spacing, no distortion, or faster tiling
- * @param theBBox ArrayList of Doubles: The pattern cell bounding box
+ * @param theBBox List of Doubles: The pattern cell bounding box
* @param theXStep horizontal spacing
* @param theYStep vertical spacing
- * @param theMatrix Optional ArrayList of Doubles transformation matrix
- * @param theXUID Optional ArrayList of Integers that uniquely identify the pattern
+ * @param theMatrix Optional List of Doubles transformation matrix
+ * @param theXUID Optional List of Integers that uniquely identify the pattern
* @param thePatternDataStream The stream of pattern data to be tiled.
*/
public PDFPattern makePattern(int thePatternType, // 1
PDFResources theResources, int thePaintType, int theTilingType,
- ArrayList theBBox, double theXStep, double theYStep, ArrayList theMatrix,
- ArrayList theXUID, StringBuffer thePatternDataStream) {
+ List theBBox, double theXStep, double theYStep, List theMatrix,
+ List theXUID, StringBuffer thePatternDataStream) {
String thePatternName = new String("Pa" + (++this.patternCount));
// int theNumber, String thePatternName,
// PDFResources theResources
* @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:ArrayList of Doubles that specify the matrix.
+ * @param theMatrix Optional:List of Doubles that specify the matrix.
*/
public PDFPattern makePattern(int thePatternType, PDFShading theShading,
- ArrayList theXUID, StringBuffer theExtGState,
- ArrayList theMatrix) {
+ List theXUID, StringBuffer theExtGState,
+ List theMatrix) {
String thePatternName = new String("Pa" + (++this.patternCount));
PDFPattern pattern = new PDFPattern(++this.objectcount,
public PDFPattern createGradient(boolean radial,
ColorSpace theColorspace,
- ArrayList theColors, ArrayList theBounds,
- ArrayList theCoords) {
+ List theColors, List theBounds,
+ List theCoords) {
PDFShading myShad;
PDFFunction myfunky;
PDFFunction myfunc;
- ArrayList theCzero;
- ArrayList theCone;
+ List theCzero;
+ List theCone;
PDFPattern myPattern;
ColorSpace theColorSpace;
double interpolation = (double)1.000;
- ArrayList theFunctions = new ArrayList();
+ List theFunctions = new java.util.ArrayList();
int currentPosition;
int lastPosition = theColors.size() - 1;
} else { // if the center x, center y, and radius specifiy
// the gradient, then assume the same center x, center y,
// and radius of zero for the other necessary component
- ArrayList newCoords = new ArrayList();
+ List newCoords = new java.util.ArrayList();
newCoords.add(theCoords.get(0));
newCoords.add(theCoords.get(1));
newCoords.add(theCoords.get(2));
pl.link = link;
pl.dest = dest;
if(pendingLinks == null) {
- pendingLinks = new ArrayList();
+ pendingLinks = new java.util.ArrayList();
}
pendingLinks.add(pl);
pdf = ("%PDF-" + this.pdfVersion + "\n").getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
pdf = ("%PDF-" + this.pdfVersion + "\n").getBytes();
- }
+ }
stream.write(pdf);
this.position += pdf.length;
trailer = pdf.getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
trailer = pdf.getBytes();
- }
+ }
stream.write(trailer);
}
pdfBytes = pdf.toString().getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
pdfBytes = pdf.toString().getBytes();
- }
+ }
stream.write(pdfBytes);
return pdfBytes.length;
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.pdf;
// Java...
-import java.util.ArrayList;
+import java.util.List;
import java.io.UnsupportedEncodingException;
/**
/**
* Required: 2 * m Array of Double numbers which are possible inputs to the function
*/
- protected ArrayList domain = null;
+ protected List domain = null;
/**
* Required: 2 * n Array of Double numbers which are possible outputs to the function
*/
- protected ArrayList range = null;
+ protected List range = null;
/* ********************TYPE 0***************************** */
// FunctionType 0 specific function guts
* Note: This is really more like two seperate integers, sizeDomain, and sizeRange,
* but since they're expressed as an array in PDF, my implementation reflects that.
*/
- protected ArrayList size = null;
+ protected List size = null;
/**
* Required for Type 0: Number of Bits used to represent each sample value. Limited to 1,2,4,8,12,16,24, or 32
* Required for Type 3: A 2 * k array of Doubles that, taken in pairs, map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function.
* Should be two values per function, usually (0,1), as in [0 1 0 1] for 2 functions.
*/
- protected ArrayList encode = null;
+ protected List encode = null;
/**
* Optinoal for Type 0: A 2 * n array of Doubles which provides a linear mapping of sample values to the range. Defaults to Range.
*/
- protected ArrayList decode = null;
+ protected List decode = null;
/**
* Optional For Type 0: A stream of sample values
protected StringBuffer functionDataStream = null;
/**
- * Required (?) For Type 0: A ArrayList of Strings for the various filters to be used to decode the stream.
+ * Required (?) For Type 0: A List of Strings for the various filters to be used to decode the stream.
* These are how the string is compressed. Flate, LZW, etc.
*/
- protected ArrayList filter = null;
+ protected List filter = null;
/* *************************TYPE 2************************** */
/**
* Required For Type 2: An Array of n Doubles defining the function result when x=0. Default is [0].
*/
- protected ArrayList cZero = null;
+ protected List cZero = null;
/**
* Required For Type 2: An Array of n Doubles defining the function result when x=1. Default is [1].
*/
- protected ArrayList cOne = null;
+ protected List cOne = null;
/**
* Required for Type 2: The interpolation exponent.
/* *************************TYPE 3************************** */
/**
- * Required for Type 3: An ArrayList of PDFFunctions which form an array of k single input functions making up the stitching function.
+ * Required for Type 3: A List of PDFFunctions which form an array of k single input functions making up the stitching function.
*/
- protected ArrayList functions = null;
+ protected List functions = null;
/**
* Optional for Type 3: An array of (k-1) Doubles that, in combination with Domain, define the intervals to which each function from the Functions array apply. Bounds elements must be in order of increasing magnitude, and each value must be within the value of Domain.
* This makes each function responsible for an equal amount of the stitching function.
* It makes the gradient even.
*/
- protected ArrayList bounds = null;
+ protected List bounds = null;
// See encode above, as it's also part of Type 3 Functions.
/* *************************TYPE 4************************** */
* Use null for an optional object parameter if you choose not to use it.
* For optional int parameters, pass the default.
*
- * @param theDomain ArrayList objects of Double objects.
+ * @param theDomain List objects of Double objects.
* This is the domain of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theRange ArrayList objects of Double objects.
+ * @param theRange List objects of Double objects.
* This is the Range of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theSize A ArrayList object of Integer objects.
+ * @param theSize A List object of Integer objects.
* This is the number of samples in each input dimension.
* I can't imagine there being more or less than two input dimensions,
* so maybe this should be an array of length 2.
* This attribute is optional.
*
* See page 265 in the PDF 1.3 spec.
- * @param theEncode ArrayList objects of Double objects.
+ * @param theEncode List objects of Double objects.
* This is the linear mapping of input values intop the domain
* of the function's sample table. Default is hard to represent in
* ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
* This attribute is optional.
*
* See page 265 in the PDF 1.3 spec.
- * @param theDecode ArrayList objects of Double objects.
+ * @param theDecode List objects of Double objects.
* This is a linear mapping of sample values into the range.
* The default is just the range.
*
* This is optional, but is almost always used.
*
* Page 265 of the PDF 1.3 spec has more.
- * @param theFilter This is a ArrayList of String objects which are the various filters that
+ * @param theFilter This is a List of String objects which are the various filters that
* have are to be applied to the stream to make sense of it. Order matters,
* so watch out.
*
* @param theFunctionType This is the type of function (0,2,3, or 4).
* It should be 0 as this is the constructor for sampled functions.
*/
- public PDFFunction(int theNumber, int theFunctionType, ArrayList theDomain,
- ArrayList theRange, ArrayList theSize, int theBitsPerSample,
- int theOrder, ArrayList theEncode, ArrayList theDecode,
- StringBuffer theFunctionDataStream, ArrayList theFilter) {
+ public PDFFunction(int theNumber, int theFunctionType, List theDomain,
+ List theRange, List theSize, int theBitsPerSample,
+ int theOrder, List theEncode, List theDecode,
+ StringBuffer theFunctionDataStream, List theFilter) {
super(theNumber);
this.functionType = 0; // dang well better be 0;
this.size = theSize;
this.bitsPerSample = theBitsPerSample;
this.order = theOrder; // int
- this.encode = theEncode; // ArrayList of int
- this.decode = theDecode; // ArrayList of int
+ this.encode = theEncode; // List of int
+ this.decode = theDecode; // List of int
this.functionDataStream = theFunctionDataStream;
- this.filter = theFilter; // ArrayList of Strings
+ this.filter = theFilter; // List of Strings
// the domain and range are actually two dimensional arrays.
// so if there's not an even number of items, bad stuff
* For optional int parameters, pass the default.
*
* @param theNumber the object's number
- * @param theDomain ArrayList objects of Double objects.
+ * @param theDomain List objects of Double objects.
* This is the domain of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theRange ArrayList of Doubles that is the Range of the function.
+ * @param theRange List of Doubles that is the Range of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theCZero This is a ArrayList of Double objects which defines the function result
+ * @param theCZero This is a List of Double objects which defines the function result
* when x=0.
*
* This attribute is optional.
* It's described on page 268 of the PDF 1.3 spec.
- * @param theCOne This is a ArrayList of Double objects which defines the function result
+ * @param theCOne This is a List of Double objects which defines the function result
* when x=1.
*
* This attribute is optional.
* PDF Spec page 268
* @param theFunctionType The type of the function, which should be 2.
*/
- public PDFFunction(int theNumber, int theFunctionType, ArrayList theDomain,
- ArrayList theRange, ArrayList theCZero, ArrayList theCOne,
+ public PDFFunction(int theNumber, int theFunctionType, List theDomain,
+ List theRange, List theCZero, List theCOne,
double theInterpolationExponentN) {
super(theNumber);
* For optional int parameters, pass the default.
*
* @param theNumber the object's number
- * @param theDomain ArrayList objects of Double objects.
+ * @param theDomain List objects of Double objects.
* This is the domain of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theRange ArrayList objects of Double objects.
+ * @param theRange List objects of Double objects.
* This is the Range of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theFunctions A ArrayList of the PDFFunction objects that the stitching function stitches.
+ * @param theFunctions A List of the PDFFunction objects that the stitching function stitches.
*
* This attributed is required.
* It is described on page 269 of the PDF spec.
- * @param theBounds This is a ArrayList of Doubles representing the numbers that,
+ * @param theBounds This is a List of Doubles representing the numbers that,
* in conjunction with Domain define the intervals to which each function from
* the 'functions' object applies. It must be in order of increasing magnitude,
* and each must be within Domain.
*
* This attributed is required.
* It's described on page 269 of the PDF 1.3 spec.
- * @param theEncode ArrayList objects of Double objects.
+ * @param theEncode List objects of Double objects.
* This is the linear mapping of input values intop the domain
* of the function's sample table. Default is hard to represent in
* ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
* @param theFunctionType This is the function type. It should be 3,
* for a stitching function.
*/
- public PDFFunction(int theNumber, int theFunctionType, ArrayList theDomain,
- ArrayList theRange, ArrayList theFunctions,
- ArrayList theBounds, ArrayList theEncode) {
+ public PDFFunction(int theNumber, int theFunctionType, List theDomain,
+ List theRange, List theFunctions,
+ List theBounds, List theEncode) {
super(theNumber);
this.functionType = 3; // dang well better be 3;
* Use null for an optional object parameter if you choose not to use it.
* For optional int parameters, pass the default.
*
- * @param theDomain ArrayList object of Double objects.
+ * @param theDomain List object of Double objects.
* This is the domain of the function.
* See page 264 of the PDF 1.3 Spec.
- * @param theRange ArrayList object of Double objects.
+ * @param theRange List object of Double objects.
* This is the Range of the function.
* See page 264 of the PDF 1.3 Spec.
* @param theFunctionDataStream This is a stream of arithmetic, boolean, and stack operators and boolean constants.
* @param theFunctionType The type of function which should be 4, as this is
* a Postscript calculator function
*/
- public PDFFunction(int theNumber, int theFunctionType, ArrayList theDomain,
- ArrayList theRange, StringBuffer theFunctionDataStream) {
+ public PDFFunction(int theNumber, int theFunctionType, List theDomain,
+ List theRange, StringBuffer theFunctionDataStream) {
super(theNumber);
this.functionType = 4; // dang well better be 4;
return p.toString().getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
return p.toString().getBytes();
- }
+ }
}
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// Java...
import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
+import java.util.List;
/**
* class representing a PDF Function.
/**
* Either one (1) for tiling, or two (2) for shading.
*/
- protected int patternType = 2; // Default
+ protected int patternType = 2; // Default
/**
* The name of the pattern such as "Pa1" or "Pattern1"
protected int tilingType = 1;
/**
- * ArrayList of Doubles representing the Bounding box rectangle
+ * List of Doubles representing the Bounding box rectangle
*/
- protected ArrayList bBox = null;
+ protected List bBox = null;
/**
* Horizontal spacing
protected PDFShading shading = null;
/**
- * ArrayList of Integers represetning the Extended unique Identifier
+ * List of Integers represetning the Extended unique Identifier
*/
- protected ArrayList xUID = null;
+ protected List xUID = null;
/**
* String representing the extended Graphics state.
* Probably will never be used like this.
*/
protected StringBuffer extGState =
- null; // eventually, need a PDFExtGSState object... but not now.
+ null; // eventually, need a PDFExtGSState object... but not now.
/**
- * ArrayList of Doubles representing the Transformation matrix.
+ * List of Doubles representing the Transformation matrix.
*/
- protected ArrayList matrix = null;
+ protected List matrix = null;
/**
* The stream of a pattern
* @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 ArrayList of Doubles: The pattern cell bounding box
+ * @param theBBox List of Doubles: The pattern cell bounding box
* @param theXStep horizontal spacing
* @param theYStep vertical spacing
- * @param theMatrix Optional ArrayList of Doubles transformation matrix
- * @param theXUID Optional ArrayList of Integers that uniquely identify the pattern
+ * @param theMatrix Optional List of Doubles transformation matrix
+ * @param theXUID Optional List 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, ArrayList theBBox, double theXStep,
- double theYStep, ArrayList theMatrix, ArrayList theXUID,
- StringBuffer thePatternDataStream) {
+ int thePaintType, int theTilingType, List theBBox,
+ double theXStep, double theYStep,
+ List theMatrix, List theXUID,
+ StringBuffer thePatternDataStream) {
super(theNumber);
this.patternName = thePatternName;
* @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:ArrayList of Doubles that specify the matrix.
+ * @param theMatrix Optional:List of Doubles that specify the matrix.
*/
public PDFPattern(int theNumber, String thePatternName,
int thePatternType, PDFShading theShading,
- ArrayList theXUID, StringBuffer theExtGState,
- ArrayList theMatrix) {
+ List theXUID, StringBuffer theExtGState,
+ List theMatrix) {
super(theNumber);
this.patternName = thePatternName;
return p.toString().getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
return p.toString().getBytes();
- }
+ }
}
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* class representing a /Resources object.
/**
* /Font objects keyed by their internal name
*/
- protected HashMap fonts = new HashMap();
+ protected Map fonts = new java.util.HashMap();
- protected ArrayList xObjects = null;
- protected ArrayList patterns = new ArrayList();
- protected ArrayList shadings = new ArrayList();
+ protected List xObjects = null;
+ protected List patterns = new java.util.ArrayList();
+ protected List shadings = new java.util.ArrayList();
/**
* create a /Resources object.
this.patterns.add(thePattern);
}
- public void setXObjects(ArrayList xObjects) {
+ public void setXObjects(List xObjects) {
this.xObjects = xObjects;
}
return p.toString().getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
return p.toString().getBytes();
- }
+ }
}
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// Java...
import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
+import java.util.List;
// FOP
import org.apache.fop.datatypes.ColorSpace;
* The background color. Since shading is opaque,
* this is very rarely used.
*/
- protected ArrayList background = null;
+ protected List background = null;
/**
- * Optional: A ArrayList specifying the clipping rectangle
+ * Optional: A List specifying the clipping rectangle
*/
- protected ArrayList bBox = null;
+ protected List bBox = null;
/**
* Optional: A flag whether or not to filter the shading function
* Optional for Type 3: An array of two numbers between which the blend varies between start and end points. Default is 0, 1.
*/
- protected ArrayList domain = null;
+ protected List domain = null;
/**
* Optional for Type 1: A transformation matrix
*/
- protected ArrayList matrix = null;
+ protected List matrix = null;
/**
* Required for Type 1, 2, and 3:
* 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 ArrayList coords = null;
+ protected List 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 ArrayList extend = null;
+ protected List extend = null;
/**
* Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each vertex coordinate.
* Each type has a differing number of decode array members, so check the spec.
* Page 303 in PDF Spec 1.3
*/
- protected ArrayList decode = null;
+ protected List decode = null;
/**
* Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each color coordinate.
* @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 ArrayList of double's representing a rectangle
+ * @param theBBox List 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 ArrayList of Doubles specifying the domain.
- * @param theMatrix ArrayList of Doubles specifying the matrix.
+ * @param theDomain Optional List of Doubles specifying the domain.
+ * @param theMatrix List 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
*/
public PDFShading(int theNumber, String theShadingName,
int theShadingType, ColorSpace theColorSpace,
- ArrayList theBackground, ArrayList theBBox,
- boolean theAntiAlias, ArrayList theDomain,
- ArrayList theMatrix, PDFFunction theFunction) {
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theDomain,
+ List theMatrix, PDFFunction theFunction) {
super(theNumber);
this.shadingName = theShadingName;
this.shadingType = theShadingType; // 1
* @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 ArrayList of double's representing a rectangle
+ * @param theBBox List 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 ArrayList of four (type 2) or 6 (type 3) Double
- * @param theDomain ArrayList of Doubles specifying the domain
+ * @param theCoords List of four (type 2) or 6 (type 3) Double
+ * @param theDomain List of Doubles specifying the domain
* @param theFunction the Stitching (PDFfunction type 3) function, even if it's stitching a single function
- * @param theExtend ArrayList of Booleans of whether to extend teh start and end colors past the start and end points
+ * @param theExtend List 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,
- ArrayList theBackground, ArrayList theBBox,
- boolean theAntiAlias, ArrayList theCoords,
- ArrayList theDomain, PDFFunction theFunction,
- ArrayList theExtend) {
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theCoords,
+ List theDomain, PDFFunction theFunction,
+ List theExtend) {
super(theNumber);
this.shadingName = theShadingName;
this.shadingType = theShadingType; // 2 or 3
* @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 ArrayList of double's representing a rectangle
+ * @param theBBox List of double's representing a rectangle
* in the coordinate space that is current at the
* time of shading is imaged. Temporary clipping
* boundary.
* @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 ArrayList of Doubles see PDF 1.3 spec pages 303 to 312.
+ * @param theDecode List 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,
- ArrayList theBackground, ArrayList theBBox,
+ List theBackground, List theBBox,
boolean theAntiAlias, int theBitsPerCoordinate,
int theBitsPerComponent, int theBitsPerFlag,
- ArrayList theDecode, PDFFunction theFunction) {
+ List theDecode, PDFFunction theFunction) {
super(theNumber);
this.shadingType = theShadingType; // 4,6 or 7
* @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 ArrayList of double's representing a rectangle
+ * @param theBBox List 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 ArrayList of Doubles. See page 305 in PDF 1.3 spec.
+ * @param theDecode List 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,
- ArrayList theBackground, ArrayList theBBox,
+ List theBackground, List theBBox,
boolean theAntiAlias, int theBitsPerCoordinate,
- int theBitsPerComponent, ArrayList theDecode,
+ int theBitsPerComponent, List theDecode,
int theVerticesPerRow, PDFFunction theFunction) {
super(theNumber);
this.shadingName = theShadingName;
return p.toString().getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
return p.toString().getBytes();
- }
+ }
}
}
import java.io.OutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
+import java.util.List;
/**
* class representing a PDF stream.
/**
* the filters that should be applied
*/
- private ArrayList _filters;
+ private List _filters;
/**
* create an empty stream object
public PDFStream(int number) {
super(number);
_data = new ByteArrayOutputStream();
- _filters = new ArrayList();
+ _filters = new java.util.ArrayList();
}
/**
protected void addDefaultFilters() {
- ArrayList filters = Configuration.getListValue("stream-filter-list",
+ List filters = Configuration.getListValue("stream-filter-list",
Configuration.PDF);
if (filters == null) {
// try getting it as a String
*/
protected String applyFilters() throws IOException {
if (_filters.size() > 0) {
- ArrayList names = new ArrayList();
- ArrayList parms = new ArrayList();
+ List names = new java.util.ArrayList();
+ List parms = new java.util.ArrayList();
// run the filters
for (int i = 0; i < _filters.size(); i++) {
_data.write(tmp);
filter.setApplied(true);
}
- // place the names in our local ArrayList in reverse order
+ // place the names in our local List in reverse order
names.add(0, filter.getName());
parms.add(0, filter.getDecodeParms());
}
}
- private String buildFilterEntries(ArrayList names) {
+ private String buildFilterEntries(List names) {
StringBuffer sb = new StringBuffer();
sb.append("/Filter ");
if (names.size() > 1) {
return sb.toString();
}
- private String buildDecodeParms(ArrayList parms) {
+ private String buildDecodeParms(List parms) {
StringBuffer sb = new StringBuffer();
boolean needParmsEntry = false;
sb.append("/DecodeParms ");
preBytes = preamble.toString().getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
preBytes = preamble.toString().getBytes();
- }
+ }
byte[] postBytes;
try {
postBytes = post.toString().getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
postBytes = post.toString().getBytes();
- }
+ }
byte[] imgData = new byte[preBytes.length + postBytes.length + fopimage.getBitmaps().length];
System.arraycopy (preBytes, 0, imgData, 0, preBytes.length);
p = p + "/Length " + imgStream.getDataLength();
// don't know if it's the good place (other objects can have references to it)
- fopimage.close();
+ //fopimage.close(); //Not really necessary, is it? Only leads to image reloading.
+
p = p + dictEntries;
p = p + ">>\n";
pdfBytes = p.getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
pdfBytes = p.getBytes();
- }
+ }
stream.write(pdfBytes);
length += pdfBytes.length;
// push all the image data on the writer and takes care of length for trailer
pdfBytes = ("endobj\n").getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
pdfBytes = ("endobj\n").getBytes();
- }
+ }
stream.write(pdfBytes);
length += pdfBytes.length;
p = p + ">>\n";
// don't know if it's the good place (other objects can have references to it)
- fopimage.close();
+ //fopimage.close(); //Not really necessary, is it? Only leads to image reloading.
// push the pdf dictionary on the writer
byte[] pdfBytes;
pdfBytes = p.getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
pdfBytes = p.getBytes();
- }
+ }
stream.write(pdfBytes);
length += pdfBytes.length;
// push all the image data on the writer and takes care of length for trailer
pdfBytes = ("endobj\n").getBytes(PDFDocument.ENCODING);
} catch (UnsupportedEncodingException ue) {
pdfBytes = ("endobj\n").getBytes();
- }
+ }
stream.write(pdfBytes);
length += pdfBytes.length;
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import org.apache.fop.layout.*;
import org.apache.fop.layout.inline.*;
import org.apache.fop.datatypes.*;
-import org.apache.fop.render.pdf.FontSetup;
// Avalon
import org.apache.avalon.framework.logger.Logger;
// Java
import java.io.IOException;
import java.io.OutputStream;
-import java.util.ArrayList;
+import java.util.List;
/**
* Abstract base class for all renderers.
- *
+ *
*/
public abstract class AbstractRenderer implements Renderer {
protected Logger log;
}
public void renderSpanArea(SpanArea area) {
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this); // column areas
* @param h the height in millipoints
*/
protected void doBackground(Area area, int x, int y, int w, int h) {
- if (h == 0 || w == 0)
- return;
-
- BackgroundProps props = area.getBackground();
- if (props == null)
- return;
-
- if (props.backColor.alpha() == 0) {
- this.addFilledRect(x, y, w, -h, props.backColor);
- }
-
- // XXX: I'm ignoring area rotation here 8(
- // is this taken care of for me elsewhere in the codebase?
- if (props.backImage != null) {
- int imgW;
- int imgH;
- try {
- // XXX: do correct unit conversion here
- imgW = props.backImage.getWidth() * 1000;
- imgH = props.backImage.getHeight() * 1000;
- }
- catch (FopImageException fie) {
- log.error("Error obtaining bg image width and height", fie);
- return;
- }
-
- int dx = x;
- int dy = y;
- int endX = x + w;
- int endY = y - h;
- int clipW = w % imgW;
- int clipH = h % imgH;
-
- boolean repeatX = true;
- boolean repeatY = true;
- switch (props.backRepeat) {
- case BackgroundRepeat.REPEAT:
- break;
-
- case BackgroundRepeat.REPEAT_X:
- repeatY = false;
- break;
-
- case BackgroundRepeat.REPEAT_Y:
- repeatX = false;
- break;
-
- case BackgroundRepeat.NO_REPEAT:
- repeatX = false;
- repeatY = false;
- break;
-
- case BackgroundRepeat.INHERIT:
- // XXX: what to do here?
- break;
-
- default:
- log.error("Ignoring invalid background-repeat property");
- }
-
- FontState fs = area.getFontState();
-
- while (dy > endY) { // looping through rows
- while (dx < endX) { // looping through cols
- if (dx + imgW <= endX) {
- // no x clipping
- if (dy - imgH >= endY) {
- // no x clipping, no y clipping
- drawImageScaled(dx, dy, imgW, imgH,
- props.backImage, fs);
- }
- else {
- // no x clipping, y clipping
- drawImageClipped(dx, dy,
- 0, 0, imgW, clipH,
- props.backImage, fs);
- }
- }
- else {
- // x clipping
- if (dy - imgH >= endY) {
- // x clipping, no y clipping
- drawImageClipped(dx, dy,
- 0, 0, clipW, imgH,
- props.backImage, fs);
- }
-
- else {
- // x clipping, y clipping
- drawImageClipped(dx, dy,
- 0, 0, clipW, clipH,
- props.backImage, fs);
- }
- }
-
- if (repeatX) {
- dx += imgW;
- }
- else {
- break;
- }
- } // end looping through cols
-
- dx = x;
-
- if (repeatY) {
- dy -= imgH;
- }
- else {
- break;
- }
- } // end looping through rows
- }
+ if (h == 0 || w == 0)
+ return;
+
+ BackgroundProps props = area.getBackground();
+ if (props == null)
+ return;
+
+ if (props.backColor.alpha() == 0) {
+ this.addFilledRect(x, y, w, -h, props.backColor);
+ }
+
+ // XXX: I'm ignoring area rotation here 8(
+ // is this taken care of for me elsewhere in the codebase?
+ if (props.backImage != null) {
+ int imgW;
+ int imgH;
+ try {
+ // XXX: do correct unit conversion here
+ imgW = props.backImage.getWidth() * 1000;
+ imgH = props.backImage.getHeight() * 1000;
+ }
+ catch (FopImageException fie) {
+ log.error("Error obtaining bg image width and height", fie);
+ return;
+ }
+
+ int dx = x;
+ int dy = y;
+ int endX = x + w;
+ int endY = y - h;
+ int clipW = w % imgW;
+ int clipH = h % imgH;
+
+ boolean repeatX = true;
+ boolean repeatY = true;
+ switch (props.backRepeat) {
+ case BackgroundRepeat.REPEAT:
+ break;
+
+ case BackgroundRepeat.REPEAT_X:
+ repeatY = false;
+ break;
+
+ case BackgroundRepeat.REPEAT_Y:
+ repeatX = false;
+ break;
+
+ case BackgroundRepeat.NO_REPEAT:
+ repeatX = false;
+ repeatY = false;
+ break;
+
+ case BackgroundRepeat.INHERIT:
+ // XXX: what to do here?
+ break;
+
+ default:
+ log.error("Ignoring invalid background-repeat property");
+ }
+
+ FontState fs = area.getFontState();
+
+ while (dy > endY) { // looping through rows
+ while (dx < endX) { // looping through cols
+ if (dx + imgW <= endX) {
+ // no x clipping
+ if (dy - imgH >= endY) {
+ // no x clipping, no y clipping
+ drawImageScaled(dx, dy, imgW, imgH,
+ props.backImage, fs);
+ }
+ else {
+ // no x clipping, y clipping
+ drawImageClipped(dx, dy,
+ 0, 0, imgW, clipH,
+ props.backImage, fs);
+ }
+ }
+ else {
+ // x clipping
+ if (dy - imgH >= endY) {
+ // x clipping, no y clipping
+ drawImageClipped(dx, dy,
+ 0, 0, clipW, imgH,
+ props.backImage, fs);
+ }
+
+ else {
+ // x clipping, y clipping
+ drawImageClipped(dx, dy,
+ 0, 0, clipW, clipH,
+ props.backImage, fs);
+ }
+ }
+
+ if (repeatX) {
+ dx += imgW;
+ }
+ else {
+ break;
+ }
+ } // end looping through cols
+
+ dx = x;
+
+ if (repeatY) {
+ dy -= imgH;
+ }
+ else {
+ break;
+ }
+ } // end looping through rows
+ }
}
/**
* This by default calls drawImageScaled() with the image's
* intrinsic width and height, but implementations may
* override this method if it can provide a more efficient solution.
- *
+ *
* @param x the x position of left edge in millipoints
* @param y the y position of top edge in millipoints
* @param image the image to be rendered
* in non-bitmapped images.
*/
protected void drawImage(int x, int y, FopImage image, FontState fs) {
- int w;
- int h;
- try {
- // XXX: convert these units correctly
- w = image.getWidth() * 1000;
- h = image.getHeight() * 1000;
- }
- catch (FopImageException e) {
- log.error("Failed to obtain the image width and height", e);
- return;
- }
- drawImageScaled(x, y, w, h, image, fs);
+ int w;
+ int h;
+ try {
+ // XXX: convert these units correctly
+ w = image.getWidth() * 1000;
+ h = image.getHeight() * 1000;
+ }
+ catch (FopImageException e) {
+ log.error("Failed to obtain the image width and height", e);
+ return;
+ }
+ drawImageScaled(x, y, w, h, image, fs);
}
/**
* Renders an image, scaling it to the given width and height.
* If the scaled width and height is the same intrinsic size
* of the image, the image is not scaled.
- *
+ *
* @param x the x position of left edge in millipoints
* @param y the y position of top edge in millipoints
* @param w the width in millipoints
* in non-bitmapped images.
*/
protected abstract void drawImageScaled(int x, int y, int w, int h,
- FopImage image,
- FontState fs);
+ FopImage image,
+ FontState fs);
/**
- * Renders an image, clipping it as specified.
- *
+ * Renders an image, clipping it as specified.
+ *
* @param x the x position of left edge in millipoints.
* @param y the y position of top edge in millipoints.
* @param clipX the left edge of the clip in millipoints
* in non-bitmapped images.
*/
protected abstract void drawImageClipped(int x, int y,
- int clipX, int clipY,
- int clipW, int clipH,
- FopImage image,
- FontState fs);
+ int clipX, int clipY,
+ int clipW, int clipH,
+ FopImage image,
+ FontState fs);
/**
* Render an image area.
FopImage img = area.getImage();
if (img == null) {
- log.error("Error while loading image : area.getImage() is null");
- }
- else {
- drawImageScaled(x, y, w, h, img, area.getFontState());
- }
+ log.error("Error while loading image: area.getImage() is null");
+ } else {
+ drawImageScaled(x, y, w, h, img, area.getFontState());
+ }
this.currentXPosition += w;
}
this.currentXPosition = this.currentAreaContainerXPosition;
int rx = this.currentAreaContainerXPosition;
int ry = this.currentYPosition;
- // XXX: (mjg@recaldesign.com) I had to use getAllocationWidth()
- // and getMaxHeight() as the content width and height are
- // always 0. Is this supposed to be the case?
- // IMHO, the bg should cover the entire area anyway, not
- // just the parts with content, which makes this correct.
- // Probably want to check this for the other region
- // areas as well.
- int w = area.getAllocationWidth();
- int h = area.getMaxHeight();
+ // XXX: (mjg@recaldesign.com) I had to use getAllocationWidth()
+ // and getMaxHeight() as the content width and height are
+ // always 0. Is this supposed to be the case?
+ // IMHO, the bg should cover the entire area anyway, not
+ // just the parts with content, which makes this correct.
+ // Probably want to check this for the other region
+ // areas as well.
+ int w = area.getAllocationWidth();
+ int h = area.getMaxHeight();
- doBackground(area, rx, ry, w, h);
+ doBackground(area, rx, ry, w, h);
// floats & footnotes stuff
renderAreaContainer(area.getBeforeFloatReferenceArea());
renderAreaContainer(area.getFootnoteReferenceArea());
// main reference area
- ArrayList children = area.getMainReferenceArea().getChildren();
+ List children = area.getMainReferenceArea().getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this); // span areas
} else {
this.currentYPosition -= area.getHeight();
}
-
}
/**
doBackground(area, rx, ry, w, h);
- ArrayList children = area.getChildren();
+ List children = area.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();
+ }
}
/**
this.currentXPosition = this.currentAreaContainerXPosition;
doFrame(area);
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this);
this.currentYPosition -= (area.getPaddingTop()
+ area.getBorderTopWidth());
doFrame(area);
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this);
int bl = this.currentYPosition;
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
if (b instanceof InlineArea) {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
/**
* interface implement by all renderers.
- *
+ *
* a Renderer implementation takes areas/spaces and produces output in
* some format.
*/
/**
* set up renderer options
*/
- public void setOptions(java.util.HashMap options);
+ public void setOptions(java.util.Map options);
/**
* set the producer of the rendering
*/
//public void render(AreaTree areaTree, OutputStream stream) throws IOException, FOPException;
public void render(Page page, OutputStream stream)
- throws IOException, FOPException;
+ throws IOException, FOPException;
/**
* render the given area container
public void renderLeaderArea(LeaderArea area);
public void startRenderer(OutputStream outputStream)
- throws IOException;
+ throws IOException;
public void stopRenderer(OutputStream outputStream)
- throws IOException;
+ throws IOException;
}
import org.apache.fop.layout.FontState;
// Java
-import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.FontMetrics;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
-import java.util.HashMap;
+import java.util.Map;
/**
* This is a FontMetrics to be used for AWT rendering.
/**
* Embed Font List.
*/
- private HashMap embedFontList = null;
+ private Map embedFontList = null;
/**
- * Physical Font Cash.
+ * Physical Font Cache.
*/
- private HashMap fontCash = null;
+ private Map fontCache = null;
/**
* Constructs a new Font-metrics.
* set embed font.
* @param family font-family name
* @param style font style
- * @param fontPath path to phsical font
+ * @param fontURL URL to physical font
*/
- public void setEmbedFont(String family,int style,String fontPath) {
+ public void setEmbedFont(String family, int style, URL fontURL) {
if (embedFontList == null)
- embedFontList = new HashMap();
- embedFontList.put(family+style,fontPath);
+ embedFontList = new java.util.HashMap();
+ embedFontList.put(family+style, fontURL);
}
/**
* @param size font size
*/
public java.awt.Font createFont(String family, int style, int size) {
- String fontPath = null;
+ URL fontURL = null;
if (embedFontList != null)
- fontPath = (String)embedFontList.get(family+style);
- if (fontPath == null)
+ fontURL = (URL)embedFontList.get(family+style);
+ if (fontURL == null)
return new Font(family, style, size);
- // lazy instanciation for fontCash.
- if (fontCash == null)
- fontCash = new HashMap();
- Font cashedFont = (Font)fontCash.get(fontPath);
- if (cashedFont == null) {
+ // lazy instanciation for fontCache.
+ if (fontCache == null)
+ fontCache = new java.util.HashMap();
+ Font cachedFont = (Font)fontCache.get(fontURL.toExternalForm());
+ if (cachedFont == null) {
// Create specified TrueType Font.
- FileInputStream fontStream = null;
+ InputStream fontStream = null;
try {
- MessageHandler.logln("create embedFont "+fontPath);
- fontStream = new FileInputStream(fontPath);
+ MessageHandler.logln("Create embedded AWT font from stream "+fontURL.toExternalForm());
+ fontStream = fontURL.openStream();
// createFont methods supports higer than JDK1.3
// Currently supports only TrueType font.
- cashedFont = Font.createFont(Font.TRUETYPE_FONT,fontStream);
+ cachedFont = Font.createFont(Font.TRUETYPE_FONT, fontStream);
} catch(Throwable th) {
- MessageHandler.error("Failed to create embedFont "+
- fontPath + " : " + th.toString());
+ MessageHandler.error("Failed to create embedded AWT font "+
+ fontURL.toExternalForm() + ": " + th.toString());
// if failed create font, use system "Dialog" logical font
// name for each Locale.
- cashedFont = new Font("Dialog", style, size);
+ cachedFont = new Font("Dialog", style, size);
} finally {
if (fontStream != null)
try { fontStream.close(); } catch(Exception ex) {}
}
- fontCash.put(fontPath,cashedFont);
+ fontCache.put(fontURL.toExternalForm(), cachedFont);
}
- Font font = cashedFont.deriveFont(style, (float)size);
+ Font font = cachedFont.deriveFont(style, (float)size);
return font;
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
protected ProgressListener progressListener = null;
protected Translator res = null;
- protected HashMap fontNames = new HashMap();
- protected HashMap fontStyles = new HashMap();
+ protected Map fontNames = new java.util.HashMap();
+ protected Map fontStyles = new java.util.HashMap();
protected Color saveColor = null;
protected IDReferences idReferences = null;
/**
* options
*/
- protected java.util.HashMap options;
+ protected java.util.Map options;
/**
* set up renderer options
*/
- public void setOptions(java.util.HashMap options) {
+ public void setOptions(java.util.Map options) {
this.options = options;
}
w = w + area.getPaddingLeft() + area.getPaddingRight();
h = h + area.getPaddingTop() + area.getPaddingBottom();
- doBackground(area, rx, ry, w, h);
+ doBackground(area, rx, ry, w, h);
rx = rx - area.getBorderLeftWidth();
ry = ry + area.getBorderTopWidth();
* in non-bitmapped images.
*/
protected void drawImageScaled(int x, int y, int w, int h,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
/**
* in non-bitmapped images.
*/
protected void drawImageClipped(int x, int y,
- int clipX, int clipY,
- int clipW, int clipH,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ int clipX, int clipY,
+ int clipW, int clipH,
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
// correct integer roundoff (aml/rlc)
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import org.apache.fop.layout.FontState;
// Java
+import java.net.URL;
import java.awt.Graphics2D;
import java.awt.Font;
/**
* Create Original Font.
- * @param fontPath path to truetype font
+ * @param fontURL URL to truetype font
*/
- public void setEmbedFont(String fontPath) {
- metric.setEmbedFont(family,style,fontPath);
+ public void setEmbedFont(URL fontURL) {
+ metric.setEmbedFont(family, style, fontURL);
}
/**
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// Java
import java.awt.Font;
import java.awt.Graphics2D;
-import java.util.ArrayList;
+import java.util.List;
+import java.net.URL;
/**
* sets up the AWT fonts. It is similar to
* triplets for lookup
*
* @param fontInfo the font info object to set up
- * @param parent needed, since a live AWT component is needed
- * to get a valid java.awt.FontMetrics object
+ * @param graphics Graphics2D to work on
+ * @throws FOPException in case of an error during font setup
*/
public static void setup(FontInfo fontInfo, Graphics2D graphics)
throws FOPException {
/**
* Add fonts from configuration file starting with
* internalnames F<num>
+ * @param fontInfo FontInfo from Configuration
+ * @param num starting index
+ * @param graphics Graphics2D to work on
+ * @throws FOPException in case of an error during font setup
*/
public static void addConfiguredFonts(
FontInfo fontInfo, int num, Graphics2D graphics)
FontMetricsMapper metric;
String internalName = null;
- ArrayList fontInfos = Configuration.getFonts();
+ List fontInfos = Configuration.getFonts();
if (fontInfos == null)
return;
(org.apache.fop.configuration.FontInfo)fontInfos.get(i);
try {
- String metricsFile = configFontInfo.getMetricsFile();
+ URL metricsFile = configFontInfo.getMetricsFile();
if (metricsFile != null) {
internalName = "F" + num;
num++;
-
- ArrayList triplets = configFontInfo.getFontTriplets();
+
+ List triplets = configFontInfo.getFontTriplets();
for (int j = 0; j < triplets.size(); j++) {
FontTriplet triplet = (FontTriplet)triplets.get(j);
boolean embed = configFontInfo.getEmbedFile() != null;
}
}
} catch (Exception ex) {
- MessageHandler.error("Failed to read font metrics file "
- + configFontInfo.getMetricsFile()
- + " : " + ex.getMessage());
+ MessageHandler.error("Failed to read font metrics file: "
+ + ex.getMessage());
}
}
}
/**
* Return configured font metrics value.
+ *
+ * @param triplet FontTriplet to analyze
+ * @return value indicating font style
*/
private static int getFontMetrics(FontTriplet triplet) {
boolean isBold = ("bold".equalsIgnoreCase(triplet.getWeight()));
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
/**
* options
*/
- protected java.util.HashMap options;
+ protected java.util.Map options;
/**
* create the MIF renderer
/**
* set up renderer options
*/
- public void setOptions(java.util.HashMap options) {
+ public void setOptions(java.util.Map options) {
this.options = options;
}
w = w + area.getPaddingLeft() + area.getPaddingRight();
h = h + area.getPaddingTop() + area.getPaddingBottom();
- doBackground(area, rx, ry, w, h);
+ doBackground(area, rx, ry, w, h);
rx = rx - area.getBorderLeftWidth();
ry = ry + area.getBorderTopWidth();
* Renders an image, scaling it to the given width and height.
* If the scaled width and height is the same intrinsic size
* of the image, the image is not scaled.
- *
+ *
* @param x the x position of left edge in millipoints
* @param y the y position of top edge in millipoints
* @param w the width in millipoints
* in non-bitmapped images.
*/
protected void drawImageScaled(int x, int y, int w, int h,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
-
+
/**
- * Renders an image, clipping it as specified.
- *
+ * Renders an image, clipping it as specified.
+ *
* @param x the x position of left edge in millipoints.
* @param y the y position of top edge in millipoints.
* @param clipX the left edge of the clip in millipoints
* in non-bitmapped images.
*/
protected void drawImageClipped(int x, int y,
- int clipX, int clipY,
- int clipW, int clipH,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ int clipX, int clipY,
+ int clipW, int clipH,
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
/**
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
private int xoffset =
-180; // X Offset to allow for PCL implicit 1/4" left margin.
- private java.util.HashMap options;
+ private java.util.Map options;
/**
* Create the PCL renderer
/**
* set up renderer options
*/
- public void setOptions(java.util.HashMap options) {
+ public void setOptions(java.util.Map options) {
this.options = options;
}
* Renders an image, scaling it to the given width and height.
* If the scaled width and height is the same intrinsic size
* of the image, the image is not scaled.
- *
+ *
* @param x the x position of left edge in millipoints
* @param y the y position of top edge in millipoints
* @param w the width in millipoints
* in non-bitmapped images.
*/
protected void drawImageScaled(int x, int y, int w, int h,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
-
+
/**
- * Renders an image, clipping it as specified.
- *
+ * Renders an image, clipping it as specified.
+ *
* @param x the x position of left edge in millipoints.
* @param y the y position of top edge in millipoints.
* @param clipX the left edge of the clip in millipoints
* in non-bitmapped images.
*/
protected void drawImageClipped(int x, int y,
- int clipX, int clipY,
- int clipW, int clipH,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ int clipX, int clipY,
+ int clipW, int clipH,
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
boolean printBMP(FopImage img, int x, int y, int w,
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.render.pdf;
+
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.net.URL;
+
import org.apache.fop.render.pdf.fonts.*;
+import org.apache.fop.pdf.PDFWArray;
+import org.apache.fop.pdf.PDFCIDFont;
+import org.apache.fop.configuration.ConfigurationReader;
+import org.apache.fop.configuration.Configuration;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.tools.URLBuilder;
+
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.Attributes;
-import java.io.IOException;
-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;
-import org.apache.fop.apps.FOPException;
/**
* Class for reading a metric.xml file and creating a font object.
// private SingleByteFont singleFont = null;
private String text = null;
- private ArrayList cidWidths = null;
+ private List cidWidths = null;
private int cidWidthIndex = 0;
- private HashMap currentKerning = null;
+ private Map currentKerning = null;
- private ArrayList bfranges = null;
+ private List bfranges = null;
- private void createFont(String path) throws FOPException {
+ private void createFont(URL url) throws FOPException {
XMLReader parser = ConfigurationReader.createParser();
if (parser == null)
throw new FOPException("Unable to create SAX parser");
parser.setContentHandler(this);
try {
- parser.parse(path);
+ parser.parse(new InputSource(url.openStream()));
} catch (SAXException e) {
throw new FOPException(e);
} catch (IOException e) {
/**
* Sets the path to embed a font. a null value disables font embedding
*/
- public void setFontEmbedPath(String path) {
+ public void setFontEmbedPath(URL path) {
if (isCID)
multiFont.embedFileName = path;
else
* Construct a FontReader object from a path to a metric.xml file
* and read metric data
*/
- public FontReader(String path) throws FOPException {
+ public FontReader(URL path) throws FOPException {
createFont(path);
}
}
public void startElement(String uri, String localName, String qName,
- Attributes attributes) {
+ Attributes attributes) throws SAXException {
if (localName.equals("font-metrics")) {
if ("TYPE0".equals(attributes.getValue("type"))) {
multiFont = new MultiByteFont();
}
} else if ("embed".equals(localName)) {
if (isCID) {
- // This *is* annoying... should create a common
- // interface for sing/multibytefonts...
- multiFont.embedFileName = attributes.getValue("file");
+ /**@todo This *is* annoying... should create a common
+ interface for sing/multibytefonts...*/
+ String filename = attributes.getValue("file");
+ if (filename != null) {
+ try {
+ multiFont.embedFileName = URLBuilder.buildURL(
+ Configuration.getFontBaseURL(), filename);
+ } catch (java.net.MalformedURLException mfue) {
+ throw new SAXException(mfue);
+ }
+ }
multiFont.embedResourceName = attributes.getValue("class");
} else {
- singleFont.embedFileName = attributes.getValue("file");
+ String filename = attributes.getValue("file");
+ if (filename != null) {
+ try {
+ singleFont.embedFileName = URLBuilder.buildURL(
+ Configuration.getFontBaseURL(), filename);
+ } catch (java.net.MalformedURLException mfue) {
+ throw new SAXException(mfue);
+ }
+ }
singleFont.embedResourceName = attributes.getValue("class");
}
} else if ("cid-widths".equals(localName)) {
cidWidthIndex = getInt(attributes.getValue("start-index"));
- cidWidths = new ArrayList();
+ cidWidths = new java.util.ArrayList();
} else if ("kerning".equals(localName)) {
- currentKerning = new HashMap();
+ currentKerning = new java.util.HashMap();
if (isCID)
multiFont.kerning.put(new Integer(attributes.getValue("kpx1")),
currentKerning);
singleFont.kerning.put(new Integer(attributes.getValue("kpx1")),
currentKerning);
} else if ("bfranges".equals(localName)) {
- bfranges = new ArrayList();
+ bfranges = new java.util.ArrayList();
} else if ("bf".equals(localName)) {
BFEntry entry = new BFEntry();
entry.unicodeStart = getInt(attributes.getValue("us"));
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// Java
import java.util.Iterator;
-import java.util.HashMap;
-import java.util.ArrayList;
+import java.util.Map;
+import java.util.List;
+import java.net.URL;
/**
* sets up the PDF fonts.
String internalName = null;
FontReader reader = null;
- ArrayList fontInfos = Configuration.getFonts();
+ List fontInfos = Configuration.getFonts();
if (fontInfos == null)
return;
(org.apache.fop.configuration.FontInfo)fontInfos.get(i);
try {
- String metricsFile = configFontInfo.getMetricsFile();
+ URL metricsFile = configFontInfo.getMetricsFile();
if (metricsFile != null) {
internalName = "F" + num;
num++;
metricsFile,
configFontInfo.getKerning());
fontInfo.addMetrics(internalName, font);
-
- ArrayList triplets = configFontInfo.getFontTriplets();
+
+ List triplets = configFontInfo.getFontTriplets();
for (int j = 0; j < triplets.size(); j++) {
FontTriplet triplet = (FontTriplet)triplets.get(j);
}
}
} catch (Exception ex) {
- MessageHandler.error("Failed to read font metrics file "
- + configFontInfo.getMetricsFile()
- + " : " + ex.getMessage());
+ MessageHandler.error("Failed to read a font metrics file: "
+ + ex.getMessage());
}
}
}
* @param fontInfo font info object to get font information from
*/
public static void addToResources(PDFDocument doc, FontInfo fontInfo) {
- HashMap fonts = fontInfo.getUsedFonts();
+ Map fonts = fontInfo.getUsedFonts();
Iterator e = fonts.keySet().iterator();
PDFResources resources = doc.getResources();
while (e.hasNext()) {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// Java
import java.io.IOException;
import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.awt.geom.AffineTransform;
import java.awt.geom.Dimension2D;
import java.awt.Point;
/**
* options
*/
- protected java.util.HashMap options;
+ protected java.util.Map options;
- protected ArrayList extensions = null;
+ protected List extensions = null;
/**
* create the PDF renderer
*
* @param options Options for the renderer
*/
- public void setOptions(java.util.HashMap options) {
+ public void setOptions(java.util.Map options) {
this.options = options;
}
StringBuffer pdf = _wordAreaPDF;
pdf.setLength(0);
- HashMap kerning = null;
+ Map kerning = null;
boolean kerningAvailable = false;
kerning = area.getFontState().getKerning();
}
private void addKerning(StringBuffer buf, Integer ch1, Integer ch2,
- HashMap kerning, String startText,
+ Map kerning, String startText,
String endText) {
- HashMap kernPair = (HashMap) kerning.get(ch1);
+ Map kernPair = (Map) kerning.get(ch1);
if (kernPair != null) {
Integer width = (Integer) kernPair.get(ch2);
this.pdfDoc.setIDReferences(idReferences);
this.renderPage(page);
- ArrayList exts = page.getExtensions();
+ List exts = page.getExtensions();
if (exts != null) {
extensions = exts;
}
}
currentPage.setAnnotList(currentAnnotList);
- ArrayList linkSets = page.getLinkSets();
+ List 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();
- ArrayList linkRects = linkSet.getRects();
+ List linkRects = linkSet.getRects();
for (int j = 0; j < linkRects.size(); j++) {
LinkedRectangle lrect = (LinkedRectangle)linkRects.get(j);
currentAnnotList.addLink(
*
* @param exts the list of root extensions to process
*/
- protected void renderRootExtensions(ArrayList extensions) {
+ protected void renderRootExtensions(List extensions) {
if (extensions != null) {
for (int i = 0; i < extensions.size(); i++) {
ExtensionObj ext = (ExtensionObj) extensions.get(i);
outline.setRendererObject(pdfOutline);
// handle sub outlines
- ArrayList v = outline.getOutlines();
+ List v = outline.getOutlines();
for (int i = 0; i < v.size(); i++) {
renderOutline((Outline) v.get(i));
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import org.apache.fop.layout.FontDescriptor;
import org.apache.fop.pdf.PDFStream;
import org.apache.fop.messaging.MessageHandler;
-import java.util.HashMap;
+
+import java.util.Map;
+import java.net.URL;
import org.apache.fop.render.pdf.FontReader;
public class LazyFont extends Font implements FontDescriptor {
-
- private String metricsFileName = null;
- private String fontEmbedPath = null;
+
+ private URL metricsFile = null;
+ private URL fontEmbedPath = null;
private boolean useKerning = false;
-
+
private boolean isMetricsLoaded = false;
private Font realFont = null;
private FontDescriptor realFontDescriptor = null;
-
- public LazyFont(String fontEmbedPath, String metricsFileName, boolean useKerning){
- this.metricsFileName = metricsFileName;
+
+ public LazyFont(URL fontEmbedPath, URL metricsFile, boolean useKerning){
+ this.metricsFile = metricsFile;
this.fontEmbedPath = fontEmbedPath;
this.useKerning = useKerning;
}
-
+
private void load(){
- if(! isMetricsLoaded){
+ if (!isMetricsLoaded) {
isMetricsLoaded = true;
try{
- FontReader reader = new FontReader(metricsFileName);
+ FontReader reader = new FontReader(metricsFile);
reader.useKerning(useKerning);
reader.setFontEmbedPath(fontEmbedPath);
realFont = reader.getFont();
// System.out.println("Metrics " + metricsFileName + " loaded.");
} catch (Exception ex) {
MessageHandler.error("Failed to read font metrics file "
- + metricsFileName
- + " : " + ex.getMessage());
+ + metricsFile.toExternalForm()
+ + ": " + ex.getMessage());
}
}
}
-
+
public Font getRealFont(){
return realFont;
}
-
+
// Font
public String encoding(){
load();
return realFont.encoding();
}
-
+
public String fontName(){
load();
return realFont.fontName();
}
-
+
public byte getSubType(){
load();
return realFont.getSubType();
}
-
+
public char mapChar(char c){
load();
return realFont.mapChar(c);
}
-
+
// FontMetrics
public int getAscender(int size){
load();
return realFont.getAscender(size);
}
-
+
public int getCapHeight(int size){
load();
return realFont.getCapHeight(size);
}
-
+
public int getDescender(int size){
load();
return realFont.getDescender(size);
}
-
+
public int getXHeight(int size){
load();
return realFont.getXHeight(size);
}
-
+
public int getFirstChar(){
load();
return realFont.getFirstChar();
}
-
+
public int getLastChar(){
load();
return realFont.getLastChar();
}
-
+
public int width(int i, int size){
load();
return realFont.width(i, size);
}
-
+
public int[] getWidths(int size){
load();
return realFont.getWidths(size);
}
-
+
// FontDescriptor
public int getCapHeight(){
load();
return realFontDescriptor.getCapHeight();
}
-
+
public int getDescender(){
load();
return realFontDescriptor.getDescender();
}
-
+
public int getAscender(){
load();
return realFontDescriptor.getAscender();
}
-
+
public int getFlags(){
load();
return realFontDescriptor.getFlags();
}
-
+
public int[] getFontBBox(){
load();
return realFontDescriptor.getFontBBox();
}
-
+
public int getItalicAngle(){
load();
return realFontDescriptor.getItalicAngle();
}
-
+
public int getStemV(){
load();
return realFontDescriptor.getStemV();
}
-
+
public boolean hasKerningInfo(){
load();
return realFontDescriptor.hasKerningInfo();
}
-
- public HashMap getKerningInfo(){
+
+ public Map getKerningInfo(){
load();
return realFontDescriptor.getKerningInfo();
}
-
+
public boolean isEmbeddable(){
load();
return realFontDescriptor.isEmbeddable();
}
-
+
public PDFStream getFontFile(int objNum){
load();
return realFontDescriptor.getFontFile(objNum);
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import java.io.FileInputStream;
import java.io.File;
import java.io.BufferedInputStream;
-import java.util.HashMap;
+import java.util.Map;
+import java.net.URL;
/**
* Generic MultiByte (CID) font
0, 0, 0, 0
};
- public String embedFileName = null;
+ public URL embedFileName = null;
public String embedResourceName = null;
public PDFTTFStream embeddedFont = null;
public int defaultWidth = 0;
public byte cidType = PDFCIDFont.CID_TYPE2;
- public HashMap kerning = new HashMap();
+ public Map kerning = new java.util.HashMap();
public boolean useKerning = true;
private String namePrefix = null; // Quasi unique prefix
private static int uniqueCounter = 1;
/**
* usedGlyphs contains orginal, new glyph index
*/
- private HashMap usedGlyphs = new HashMap();
+ private Map usedGlyphs = new java.util.HashMap();
/**
* usedGlyphsIndex contains new glyph, original index
*/
- private HashMap usedGlyphsIndex = new HashMap();
+ private Map usedGlyphsIndex = new java.util.HashMap();
int usedGlyphsCount = 0;
public MultiByteFont() {
return (useKerning & kerning.isEmpty());
}
- public final java.util.HashMap getKerningInfo() {
+ public final Map getKerningInfo() {
if (useKerning)
return kerning;
else
- return new HashMap();
+ return new java.util.HashMap();
}
public byte getSubType() {
public PDFStream getFontFile(int i) {
try {
- FontFileReader reader = new FontFileReader(embedFileName);
+ InputStream in = embedFileName.openStream();
+ FontFileReader reader = new FontFileReader(in);
+ in.close();
TTFSubSetFile subset = new TTFSubSetFile();
byte[] subsetFont = subset.readFont(reader, ttcName, usedGlyphs);
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.BufferedInputStream;
-import java.util.HashMap;
+import java.util.Map;
+import java.net.URL;
/**
* Generic SingleByte font
0, 0, 0, 0
};
- public String embedFileName = null;
+ public URL embedFileName = null;
public String embedResourceName = null;
public PDFStream embeddedFont = null;
public int italicAngle = 0;
public int missingWidth = 0;
- public HashMap kerning = new HashMap();
+ public Map kerning = new java.util.HashMap();
public boolean useKerning = true;
public int width[] = null;
return (useKerning & kerning.isEmpty());
}
- public final java.util.HashMap getKerningInfo() {
+ public final Map getKerningInfo() {
if (useKerning)
return kerning;
else
- return new HashMap();
+ return new java.util.HashMap();
}
public byte getSubType() {
// Get file first
if (embedFileName != null)
try {
- instream = new FileInputStream(embedFileName);
+ instream = embedFileName.openStream();
} catch (Exception e) {
System.out.println("Failed to embed fontfile: "
+ embedFileName);
public char mapChar(char c) {
char d = mapping.mapChar(c);
- if(d != 0)
+ if(d != 0)
return d;
else
- return '#';
+ return '#';
}
}
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.awt.geom.AffineTransform;
import java.awt.geom.Dimension2D;
import java.awt.Point;
protected IDReferences idReferences;
- protected java.util.HashMap options;
+ protected java.util.Map options;
/**
/**
* set up renderer options
*/
- public void setOptions(java.util.HashMap options) {
+ public void setOptions(java.util.Map options) {
this.options = options;
}
write("/FOPFonts 100 dict dup begin");
// write("/gfF1{/Helvetica findfont} bd");
// write("/gfF3{/Helvetica-Bold findfont} bd");
- HashMap fonts = fontInfo.getFonts();
+ Map fonts = fontInfo.getFonts();
Iterator enum = fonts.keySet().iterator();
while (enum.hasNext()) {
String key = (String)enum.next();
String fontWeight = area.getFontState().getFontWeight();
//comment("% --- LineArea begin font-weight="+fontWeight);
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
this.currentYPosition = ry - area.getPlacementOffset();
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.geom.Rectangle2D;
-import java.util.HashMap;
+import java.util.Map;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.OutputStream;
protected int pageHeight = 0;
protected int pageNumber = 0;
- protected HashMap fontNames = new HashMap();
- protected HashMap fontStyles = new HashMap();
+ protected Map fontNames = new java.util.HashMap();
+ protected Map fontStyles = new java.util.HashMap();
protected Color saveColor = null;
protected IDReferences idReferences = null;
/**
* options
*/
- protected java.util.HashMap options;
+ protected java.util.Map options;
/**
* set up renderer options
*/
- public void setOptions(java.util.HashMap options) {
+ public void setOptions(java.util.Map options) {
this.options = options;
}
w = w + area.getPaddingLeft() + area.getPaddingRight();
h = h + area.getPaddingTop() + area.getPaddingBottom();
- doBackground(area, rx, ry, w, h);
+ doBackground(area, rx, ry, w, h);
rx = rx - area.getBorderLeftWidth();
ry = ry + area.getBorderTopWidth();
* Renders an image, scaling it to the given width and height.
* If the scaled width and height is the same intrinsic size
* of the image, the image is not scaled.
- *
+ *
* @param x the x position of left edge in millipoints
* @param y the y position of top edge in millipoints
* @param w the width in millipoints
* in non-bitmapped images.
*/
protected void drawImageScaled(int x, int y, int w, int h,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
-
+
/**
- * Renders an image, clipping it as specified.
- *
+ * Renders an image, clipping it as specified.
+ *
* @param x the x position of left edge in millipoints.
* @param y the y position of top edge in millipoints.
* @param clipX the left edge of the clip in millipoints
* in non-bitmapped images.
*/
protected void drawImageClipped(int x, int y,
- int clipX, int clipY,
- int clipW, int clipH,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ int clipX, int clipY,
+ int clipW, int clipH,
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
public void renderImageArea(ImageArea area) {
throws IOException {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
svgDocument = impl.createDocument(svgNS, "svg", null);
- ProcessingInstruction pi =
+ ProcessingInstruction pi =
svgDocument.createProcessingInstruction(
"xml",
" version=\"1.0\" encoding=\"ISO-8859-1\"");
- svgRoot = svgDocument.getDocumentElement();
+ svgRoot = svgDocument.getDocumentElement();
svgDocument.insertBefore(pi, svgRoot);
- }
+ }
public void stopRenderer(OutputStream outputStream)
throws IOException {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// Java
import java.io.IOException;
import java.io.OutputStream;
-import java.util.ArrayList;
+import java.util.List;
/**
* Renderer that renders areas to plain text.
/**
* options
*/
- protected java.util.HashMap options;
+ protected java.util.Map options;
public TXTRenderer() {}
/**
* set up renderer options
*/
- public void setOptions(java.util.HashMap options) {
+ public void setOptions(java.util.Map options) {
this.options = options;
}
*/
}
- private void xferLineBytes(int startpos, int bitcount, ArrayList save,
+ private void xferLineBytes(int startpos, int bitcount, List save,
int start2) {
/*
* Not yet implemented
* long dx = 0;
* long dy = TwoAsquared * b;
* int rectlen = iw - 2 * irx;
- * ArrayList bottomlines = new ArrayList();
+ * List bottomlines = new java.util.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");
}
// Add a polyline or polygon. Does not support fills yet!!!
- protected void addPolyline(ArrayList points, int posx, int posy,
+ protected void addPolyline(List points, int posx, int posy,
PDFColor fc, PDFColor sc, float sw,
boolean close) {}
* Renders an image, scaling it to the given width and height.
* If the scaled width and height is the same intrinsic size
* of the image, the image is not scaled.
- *
+ *
* @param x the x position of left edge in millipoints
* @param y the y position of top edge in millipoints
* @param w the width in millipoints
* in non-bitmapped images.
*/
protected void drawImageScaled(int x, int y, int w, int h,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
-
+
/**
- * Renders an image, clipping it as specified.
- *
+ * Renders an image, clipping it as specified.
+ *
* @param x the x position of left edge in millipoints.
* @param y the y position of top edge in millipoints.
* @param clipX the left edge of the clip in millipoints
* in non-bitmapped images.
*/
protected void drawImageClipped(int x, int y,
- int clipX, int clipY,
- int clipW, int clipH,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ int clipX, int clipY,
+ int clipW, int clipH,
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
boolean printBMP(FopImage img, int x, int y, int w,
* float ty = tg.y;
* float currentX = x + tx;
* float currentY = y + ty;
- * ArrayList list = tg.textList;
+ * List list = tg.textList;
* for ( Enumeration e = list.elements() ; e.hasMoreElements() ; )
* {
* Object o = e.nextElement();
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import java.io.IOException;
import java.io.PrintWriter;
import java.io.OutputStream;
-import java.util.ArrayList;
+import java.util.List;
/**
* Renderer that renders areas to XML for debugging purposes.
/**
* options
*/
- protected java.util.HashMap options;
+ protected java.util.Map options;
private boolean consistentOutput = false;
public XMLRenderer() {}
/**
* set up renderer options
*/
- public void setOptions(java.util.HashMap options) {
+ public void setOptions(java.util.Map options) {
this.options = options;
Boolean con = (Boolean)options.get("consistentOutput");
if(con != null) {
* Renders an image, scaling it to the given width and height.
* If the scaled width and height is the same intrinsic size
* of the image, the image is not scaled.
- *
+ *
* @param x the x position of left edge in millipoints
* @param y the y position of top edge in millipoints
* @param w the width in millipoints
* in non-bitmapped images.
*/
protected void drawImageScaled(int x, int y, int w, int h,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
-
+
/**
- * Renders an image, clipping it as specified.
- *
+ * Renders an image, clipping it as specified.
+ *
* @param x the x position of left edge in millipoints.
* @param y the y position of top edge in millipoints.
* @param clipX the left edge of the clip in millipoints
* in non-bitmapped images.
*/
protected void drawImageClipped(int x, int y,
- int clipX, int clipY,
- int clipW, int clipH,
- FopImage image,
- FontState fs) {
- // XXX: implement this
+ int clipX, int clipY,
+ int clipW, int clipH,
+ FopImage image,
+ FontState fs) {
+ // XXX: implement this
}
/**
*/
public void renderAreaContainer(AreaContainer area) {
writeStartTag("<AreaContainer name=\"" + area.getAreaName() + "\">");
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this);
*/
public void renderBodyAreaContainer(BodyAreaContainer area) {
writeStartTag("<BodyAreaContainer>");
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this);
*/
public void renderSpanArea(SpanArea area) {
writeStartTag("<SpanArea>");
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this);
writeStartTag(baText.toString());
// write out marker info
- ArrayList markers = area.getMarkers();
+ List markers = area.getMarkers();
if (!markers.isEmpty()) {
writeStartTag("<Markers>");
for (int i = 0; i < markers.size(); i++) {
writeEndTag("</Markers>");
}
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this);
writeStartTag(iaText.toString());
// write out marker info
- ArrayList markers = area.getMarkers();
+ List markers = area.getMarkers();
if (!markers.isEmpty()) {
writeStartTag("<Markers>");
for (int i = 0; i < markers.size(); i++) {
writeEndTag("</Markers>");
}
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this);
String fontWeight = area.getFontState().getFontWeight();
writeStartTag("<LineArea font-weight=\"" + fontWeight + "\">");
}
- ArrayList children = area.getChildren();
+ List children = area.getChildren();
for (int i = 0; i < children.size(); i++) {
Box b = (Box)children.get(i);
b.render(this);
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import java.io.*;
import java.text.AttributedCharacterIterator;
import java.text.CharacterIterator;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
PDFColor currentColour = new PDFColor(0, 0, 0);
/**
- * A registry of images that have already been drawn. They are mapped to
+ * A registry of images that have already been drawn. They are mapped to
* a structure with the PDF xObjectNum, width and height. This
* prevents multiple copies from being stored, which can greatly
* reduce the size of a PDF graphic that uses the same image over and over
* (e.g. graphic bullets, map icons, etc.).
*/
- private HashMap imageInfos = new HashMap();
+ private Map imageInfos = new java.util.HashMap();
+
private static class ImageInfo {
public int width;
public int height;
ImageObserver observer) {
// System.err.println("drawImage:x, y");
- // first we look to see if we've already added this image to
+ // first we look to see if we've already added this image to
// the pdf document. If so, we just reuse the reference;
// otherwise we have to build a FopImage and add it to the pdf
// document
imageInfo = new ImageInfo();
imageInfo.width = img.getWidth(observer);
imageInfo.height = img.getHeight(observer);
-
+
if (imageInfo.width == -1 || imageInfo.height == -1) {
return false;
}
-
+
Dimension size = new Dimension(imageInfo.width * 3, imageInfo.height * 3);
BufferedImage buf = buildBufferedImage(size);
-
+
java.awt.Graphics2D g = buf.createGraphics();
g.setComposite(AlphaComposite.SrcOver);
g.setBackground(new Color(1, 1, 1, 0));
g.setPaint(new Color(1, 1, 1, 0));
g.fillRect(0, 0, imageInfo.width * 3, imageInfo.height * 3);
g.clip(new Rectangle(0, 0, buf.getWidth(), buf.getHeight()));
-
+
if (!g.drawImage(img, 0, 0, buf.getWidth(), buf.getHeight(), observer)) {
return false;
}
g.dispose();
-
+
final byte[] result = new byte[buf.getWidth() * buf.getHeight() * 3];
final byte[] mask = new byte[buf.getWidth() * buf.getHeight()];
-
+
Raster raster = buf.getData();
DataBuffer bd = raster.getDataBuffer();
-
+
int count = 0;
int maskpos = 0;
int[] iarray;
// error
break;
}
-
+
try {
FopImage fopimg = new TempImage("TempImage:" + img.toString(), buf.getWidth(), buf.getHeight(), result, mask);
imageInfo.xObjectNum = this.pdfDoc.addImage(fopimg);
Point2D p2 = gp.getPoint2();
boolean cyclic = gp.isCyclic();
- ArrayList theCoords = new ArrayList();
+ List theCoords = new java.util.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()));
- ArrayList theExtend = new ArrayList();
+ List theExtend = new java.util.ArrayList();
theExtend.add(new Boolean(true));
theExtend.add(new Boolean(true));
- ArrayList theDomain = new ArrayList();
+ List theDomain = new java.util.ArrayList();
theDomain.add(new Double(0));
theDomain.add(new Double(1));
- ArrayList theEncode = new ArrayList();
+ List theEncode = new java.util.ArrayList();
theEncode.add(new Double(0));
theEncode.add(new Double(1));
theEncode.add(new Double(0));
theEncode.add(new Double(1));
- ArrayList theBounds = new ArrayList();
+ List theBounds = new java.util.ArrayList();
theBounds.add(new Double(0));
theBounds.add(new Double(1));
- ArrayList theFunctions = new ArrayList();
+ List theFunctions = new java.util.ArrayList();
- ArrayList someColors = new ArrayList();
+ List someColors = new java.util.ArrayList();
PDFColor color1 = new PDFColor(c1.getRed(), c1.getGreen(),
c1.getBlue());
} else {
fontState = ovFontState;
ovFontState = null;
- }
+ }
String name;
int size;
name = fontState.getFontName();
size = fontState.getFontSize() / 1000;
-
+
if ((!name.equals(this.currentFontName))
|| (size != this.currentFontSize)) {
- this.currentFontName = name;
+ this.currentFontName = name;
this.currentFontSize = size;
currentStream.write("/" + name + " " + size + " Tf\n");
currentStream.write("BT\n");
- HashMap kerning = null;
+ Map kerning = null;
boolean kerningAvailable = false;
kerning = fontState.getKerning();
}
private void addKerning(StringWriter buf, Integer ch1, Integer ch2,
- HashMap kerning, String startText,
+ Map kerning, String startText,
String endText) {
- HashMap kernPair = (HashMap)kerning.get(ch1);
+ Map kernPair = (Map)kerning.get(ch1);
if (kernPair != null) {
Integer width = (Integer)kernPair.get(ch2);