You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2003/03/27 11:41:13 UTC
cvs commit: xml-fop/src/java/org/apache/fop/pdf PDFGState.java PDFInternalLink.java PDFLink.java
jeremias 2003/03/27 02:41:13
Modified: src/java/org/apache/fop/pdf PDFGState.java
PDFInternalLink.java PDFLink.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 +8 -19 xml-fop/src/java/org/apache/fop/pdf/PDFGState.java
Index: PDFGState.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFGState.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFGState.java 11 Mar 2003 13:05:09 -0000 1.1
+++ PDFGState.java 27 Mar 2003 10:41:13 -0000 1.2
@@ -118,7 +118,7 @@
public static final PDFGState DEFAULT;
static {
- DEFAULT = new PDFGState(0);
+ DEFAULT = new PDFGState();
Map vals = DEFAULT.values;
/*vals.put(LW, new Float(1.0));
vals.put(LC, new Integer(0));
@@ -138,21 +138,11 @@
private Map values = new java.util.HashMap();
/**
- * Create a /ExtGState object.
- *
- * @param number the object's number
- */
- public PDFGState(int number) {
- /* generic creation of object */
- super(number);
- }
-
- /**
* Returns the name of this object
* @return the name
*/
public String getName() {
- return "GS" + this.number;
+ return "GS" + getObjectNumber();
}
/**
@@ -186,18 +176,17 @@
}
/**
- * Represent the object in PDF.
- *
- * @return the PDF string
+ * @see org.apache.fop.pdf.PDFObject#toPDFString()
*/
- public byte[] toPDF() {
- StringBuffer sb = new StringBuffer(this.number + " " + this.generation
- + " obj\n<<\n/Type /ExtGState\n");
+ public String toPDFString() {
+ StringBuffer sb = new StringBuffer(64);
+ sb.append(getObjectID());
+ sb.append("<<\n/Type /ExtGState\n");
appendVal(sb, GSTATE_ALPHA_NONSTROKE);
appendVal(sb, GSTATE_ALPHA_STROKE);
sb.append(">>\nendobj\n");
- return sb.toString().getBytes();
+ return sb.toString();
}
private void appendVal(StringBuffer sb, String name) {
1.2 +3 -5 xml-fop/src/java/org/apache/fop/pdf/PDFInternalLink.java
Index: PDFInternalLink.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFInternalLink.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFInternalLink.java 11 Mar 2003 13:05:09 -0000 1.1
+++ PDFInternalLink.java 27 Mar 2003 10:41:13 -0000 1.2
@@ -77,12 +77,10 @@
}
/**
- * there is nothing to return for the toPDF method, as it should not be called
- *
- * @return an empty string
+ * @see org.apache.fop.pdf.PDFObject#toPDFString()
*/
- public byte[] toPDF() {
- return new byte[0];
+ protected String toPDFString() {
+ throw new UnsupportedOperationException("This method should not be called");
}
}
1.2 +6 -9 xml-fop/src/java/org/apache/fop/pdf/PDFLink.java
Index: PDFLink.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFLink.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PDFLink.java 11 Mar 2003 13:05:09 -0000 1.1
+++ PDFLink.java 27 Mar 2003 10:41:13 -0000 1.2
@@ -77,12 +77,11 @@
/**
* create objects associated with a link annotation (GoToR)
*
- * @param number the object's number
* @param r the rectangle of the link hotspot in absolute coordinates
*/
- public PDFLink(int number, Rectangle2D r) {
+ public PDFLink(Rectangle2D r) {
/* generic creation of PDF object */
- super(number);
+ super();
this.ulx = (float)r.getX();
this.uly = (float)r.getY();
@@ -101,18 +100,16 @@
}
/**
- * produce the PDF representation of the object
- *
- * @return the PDF
+ * @see org.apache.fop.pdf.PDFObject#toPDFString()
*/
- public byte[] toPDF() {
- String p = this.number + " " + this.generation + " obj\n"
+ public String toPDFString() {
+ String s = getObjectID()
+ "<< /Type /Annot\n" + "/Subtype /Link\n" + "/Rect [ "
+ (ulx) + " " + (uly) + " "
+ (brx) + " " + (bry) + " ]\n" + "/C [ "
+ this.color + " ]\n" + "/Border [ 0 0 0 ]\n" + "/A "
+ this.action.getAction() + "\n" + "/H /I\n>>\nendobj\n";
- return p.getBytes();
+ return s;
}
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org