jeremias 2003/03/27 02:36:29
Modified: src/java/org/apache/fop/pdf PDFCIDSystemInfo.java
PDFAnnotList.java PDFAction.java
PDFCIDFontDescriptor.java PDFArray.java
PDFCIDFont.java
Log:
The PDF object number doesn't get passed to the constructor anymore. Adjust for that.
Use the toPDFString() (returns String) method instead of toPDF() (returns byte[])
where appropriate. String to byte[] conversion is done in PDFObject in a well-defined
location instead of scattered around the codebase.
Revision Changes Path
1.2 +3 -15 xml-fop/src/java/org/apache/fop/pdf/PDFCIDSystemInfo.java
Index: PDFCIDSystemInfo.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFCIDSystemInfo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFCIDSystemInfo.java 11 Mar 2003 13:05:09 -0000 1.1
+++ PDFCIDSystemInfo.java 27 Mar 2003 10:36:28 -0000 1.2
@@ -77,31 +77,19 @@
}
/**
- * produce the PDF representation for the object.
- *
- * unlike the other objects, the CIDSystemInfo is written directly inside
- * the referencing object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- return toPDFString().getBytes();
- }
-
- /**
* Create a string for the CIDSystemInfo dictionary.
* The entries are placed as an inline dictionary.
*
* @return the string for the CIDSystemInfo entry with the inline dictionary
*/
public String toPDFString() {
- StringBuffer p = new StringBuffer();
+ StringBuffer p = new StringBuffer(64);
p.setLength(0);
p.append("/CIDSystemInfo << /Registry (");
p.append(registry);
- p.append(")/Ordering (");
+ p.append(") /Ordering (");
p.append(ordering);
- p.append(")/Supplement ");
+ p.append(") /Supplement ");
p.append(supplement);
p.append(" >>");
return p.toString();
1.2 +14 -32 xml-fop/src/java/org/apache/fop/pdf/PDFAnnotList.java
Index: PDFAnnotList.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFAnnotList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFAnnotList.java 11 Mar 2003 13:05:09 -0000 1.1
+++ PDFAnnotList.java 27 Mar 2003 10:36:28 -0000 1.2
@@ -51,7 +51,7 @@
package org.apache.fop.pdf;
// Java
-import java.util.Vector;
+import java.util.List;
/**
* class representing an object which is a list of annotations.
@@ -64,23 +64,7 @@
/**
* the /Annot objects
*/
- protected Vector links = new Vector();
-
- /**
- * the number of /Annot objects
- */
- protected int count = 0;
-
- /**
- * create a /Annots object.
- *
- * @param number the object's number
- */
- public PDFAnnotList(int number) {
-
- /* generic creation of object */
- super(number);
- }
+ private List links = new java.util.Vector();
/**
* add an /Annot object of /Subtype /Link.
@@ -88,8 +72,7 @@
* @param link the PDFLink to add.
*/
public void addAnnot(PDFObject link) {
- this.links.addElement(link);
- this.count++;
+ this.links.add(link);
}
/**
@@ -98,23 +81,22 @@
* @return the number of links
*/
public int getCount() {
- return this.count;
+ return this.links.size();
}
/**
- * represent the object in PDF
- *
- * @return the PDF string
+ * @see org.apache.fop.pdf.PDFObject#toPDFString()
*/
- public byte[] toPDF() {
- StringBuffer p = new StringBuffer(this.number + " " + this.generation
- + " obj\n[\n");
- for (int i = 0; i < this.count; i++) {
- p = p.append(((PDFObject)links.elementAt(i)).referencePDF()
- + "\n");
+ public String toPDFString() {
+ StringBuffer p = new StringBuffer(128);
+ p.append(getObjectID());
+ p.append("[\n");
+ for (int i = 0; i < getCount(); i++) {
+ p.append(((PDFObject)links.get(i)).referencePDF());
+ p.append("\n");
}
- p = p.append("]\nendobj\n");
- return p.toString().getBytes();
+ p.append("]\nendobj\n");
+ return p.toString();
}
/*
1.2 +0 -28 xml-fop/src/java/org/apache/fop/pdf/PDFAction.java
Index: PDFAction.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFAction.java 11 Mar 2003 13:05:09 -0000 1.1
+++ PDFAction.java 27 Mar 2003 10:36:28 -0000 1.2
@@ -57,25 +57,6 @@
/**
- * create an Action object.
- * this constructor is used for passing on the object number to the PDFObject
- *
- * @param number the object's number
- */
- public PDFAction(int number) {
-
- /* generic creation of object */
- super(number);
- }
-
- /**
- * empty constructor for PDFAction.
- * this constructor is used when there is no additional object being created
- *
- */
- public PDFAction() { }
-
- /**
* represent the action to call
* this method should be implemented to return the action which gets
* called by the Link Object. This could be a reference to another object
@@ -85,14 +66,5 @@
*/
public abstract String getAction();
-
- /**
- * represent the object in PDF
- * this method should be implemented to return the PDF which is to be
- * generated by the Action object
- *
- * @return the PDF string
- */
- public abstract byte[] toPDF();
}
1.2 +2 -3 xml-fop/src/java/org/apache/fop/pdf/PDFCIDFontDescriptor.java
Index: PDFCIDFontDescriptor.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFCIDFontDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFCIDFontDescriptor.java 11 Mar 2003 13:05:09 -0000 1.1
+++ PDFCIDFontDescriptor.java 27 Mar 2003 10:36:28 -0000 1.2
@@ -72,7 +72,6 @@
/**
* create the /FontDescriptor object
*
- * @param number the object's number
* @param basefont the base font name
* @param fontBBox the bounding box for the described font
* @param flags various characteristics of the font
@@ -81,11 +80,11 @@
* @param italicAngle the angle of the vertical dominant strokes
* @param lang the language
*/
- public PDFCIDFontDescriptor(int number, String basefont, int[] fontBBox,
+ public PDFCIDFontDescriptor(String basefont, int[] fontBBox,
int capHeight, int flags, int italicAngle,
int stemV, String lang) {
- super(number, basefont, fontBBox[3], fontBBox[1], capHeight, flags,
+ super(basefont, fontBBox[3], fontBBox[1], capHeight, flags,
new PDFRectangle(fontBBox), italicAngle, stemV);
this.lang = lang;
1.2 +7 -10 xml-fop/src/java/org/apache/fop/pdf/PDFArray.java
Index: PDFArray.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFArray.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFArray.java 11 Mar 2003 13:05:09 -0000 1.1
+++ PDFArray.java 27 Mar 2003 10:36:28 -0000 1.2
@@ -62,32 +62,29 @@
/**
* create the array object
*
- * @param number the object's number
* @param values the actual array wrapped by this object
*/
- public PDFArray(int number, int[] values) {
+ public PDFArray(int[] values) {
/* generic creation of PDF object */
- super(number);
+ super();
/* set fields using paramaters */
this.values = values;
}
/**
- * produce the PDF representation for the object
- *
- * @return the PDF
+ * @see org.apache.fop.pdf.PDFObject#toPDFString()
*/
- public byte[] toPDF() {
- StringBuffer p = new StringBuffer();
- p.append(this.number + " " + this.generation + " obj\n[");
+ public String toPDFString() {
+ StringBuffer p = new StringBuffer(64);
+ p.append(getObjectID() + "[");
for (int i = 0; i < values.length; i++) {
p.append(" ");
p.append(values[i]);
}
p.append("]\nendobj\n");
- return p.toString().getBytes();
+ return p.toString();
}
}
1.2 +10 -25 xml-fop/src/java/org/apache/fop/pdf/PDFCIDFont.java
Index: PDFCIDFont.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFCIDFont.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFCIDFont.java 11 Mar 2003 13:05:09 -0000 1.1
+++ PDFCIDFont.java 27 Mar 2003 10:36:28 -0000 1.2
@@ -78,7 +78,6 @@
/**
* Create the /Font object
- * @param number PDF object number
* @param basefont Name of the basefont
* @param cidtype CID type
* @param dw default width
@@ -88,11 +87,11 @@
* @param supplement Supplement number
* @param descriptor CID font descriptor
*/
- public PDFCIDFont(int number, String basefont, CIDFontType cidtype, int dw,
+ public PDFCIDFont(String basefont, CIDFontType cidtype, int dw,
int[] w, String registry, String ordering,
int supplement, PDFCIDFontDescriptor descriptor) {
- this(number, basefont, cidtype, dw,
+ this(basefont, cidtype, dw,
new PDFWArray(w),
new PDFCIDSystemInfo(registry, ordering, supplement),
descriptor);
@@ -100,7 +99,6 @@
/**
* Create the /Font object
- * @param number PDF object number
* @param basefont Name of the basefont
* @param cidtype CID type
* @param dw default width
@@ -108,11 +106,11 @@
* @param systemInfo CID system info
* @param descriptor CID font descriptor
*/
- public PDFCIDFont(int number, String basefont, CIDFontType cidtype, int dw,
+ public PDFCIDFont(String basefont, CIDFontType cidtype, int dw,
int[] w, PDFCIDSystemInfo systemInfo,
PDFCIDFontDescriptor descriptor) {
- this(number, basefont, cidtype, dw,
+ this(basefont, cidtype, dw,
new PDFWArray(w),
systemInfo,
descriptor);
@@ -120,7 +118,6 @@
/**
* Create the /Font object
- * @param number PDF object number
* @param basefont Name of the basefont
* @param cidtype CID type
* @param dw default width
@@ -128,11 +125,11 @@
* @param systemInfo CID system info
* @param descriptor CID font descriptor
*/
- public PDFCIDFont(int number, String basefont, CIDFontType cidtype, int dw,
+ public PDFCIDFont(String basefont, CIDFontType cidtype, int dw,
PDFWArray w, PDFCIDSystemInfo systemInfo,
PDFCIDFontDescriptor descriptor) {
- super(number);
+ super();
this.basefont = basefont;
this.cidtype = cidtype;
@@ -229,24 +226,12 @@
}
/**
- * Produce the PDF representation for the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- return toPDFString().getBytes();
- }
-
- /**
- * Produce the PDF representation for the object
- * @return the generated code
+ * @see org.apache.fop.pdf.PDFObject#toPDFString()
*/
public String toPDFString() {
- StringBuffer p = new StringBuffer();
- p.append(this.number);
- p.append(" ");
- p.append(this.generation);
- p.append(" obj\n<< /Type /Font");
+ StringBuffer p = new StringBuffer(128);
+ p.append(getObjectID());
+ p.append("<< /Type /Font");
p.append("\n/BaseFont /");
p.append(this.basefont);
if (cidMap != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]