123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /*
- * $Id$
- * Copyright (C) 2001 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.awt.geom.Rectangle2D;
-
- /**
- * class representing an /Annot object of /Subtype /Link
- */
- public class PDFLink extends PDFObject {
- public static final int EXTERNAL = 0;
- public static final int INTERNAL = 1;
-
- float ulx;
- float uly;
- float brx;
- float bry;
- String color;
- PDFAction action;
-
- /**
- * create objects associated with a link annotation (GoToR)
- *
- * @param number the object's number
- * @param producer the application producing the PDF
- */
- public PDFLink(int number, Rectangle2D r) {
- /* generic creation of PDF object */
- super(number);
-
- this.ulx = (float)r.getX();
- this.uly = (float)r.getY();
- this.brx = (float)(r.getX() + r.getWidth());
- this.bry = (float)(r.getY() - r.getHeight());
- this.color = "0 0 0"; // just for now
-
- }
-
- public void setAction(PDFAction action) {
- this.action = action;
- }
-
- /**
- * produce the PDF representation of the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- String p = this.number + " " + this.generation + " obj\n"
- + "<< /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();
- }
-
- /*
- * example
- * 19 0 obj
- * <<
- * /Type /Annot
- * /Subtype /Link
- * /Rect [ 176.032 678.48412 228.73579 692.356 ]
- * /C [ 0.86491 0.03421 0.02591 ]
- * /Border [ 0 0 1 ]
- * /A 28 0 R
- * /H /I
- * >>
- * endobj
- */
- }
|