[FOray-commit] SF.net SVN: foray: [9834] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-06-22 19:40:13
|
Revision: 9834
http://svn.sourceforge.net/foray/?rev=9834&view=rev
Author: victormote
Date: 2007-06-22 12:40:12 -0700 (Fri, 22 Jun 2007)
Log Message:
-----------
Make the content stream independent of its page by moving the responsibility for link creation from the stream to the renderer.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java
trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2007-06-22 16:54:30 UTC (rev 9833)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2007-06-22 19:40:12 UTC (rev 9834)
@@ -842,7 +842,6 @@
* {@inheritDoc}
*/
public void fill(final Shape s) {
- // this.area.getLogger().error("fill");
Color c;
c = getBackground();
if (c.getAlpha() == 0) {
@@ -851,7 +850,7 @@
return;
}
}
- this.write("q");
+// this.write("q");
final Shape imclip = getClip();
writeClip(imclip);
c = getColor();
@@ -894,7 +893,7 @@
}
doDrawing(true, false,
iter.getWindingRule() == PathIterator.WIND_EVEN_ODD);
- this.write("Q");
+// this.write("Q");
}
/**
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-22 16:54:30 UTC (rev 9833)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-22 19:40:12 UTC (rev 9834)
@@ -34,7 +34,6 @@
import org.axsl.fontR.FontUse;
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicException;
-import org.axsl.graphicR.GraphicLink;
import org.axsl.graphicR.SVGGraphic;
import org.axsl.pdfW.PDFLineCapStyle;
import org.axsl.pdfW.PDFPathPaint;
@@ -51,7 +50,6 @@
implements org.axsl.pdfW.PDFContentStream {
/** The page this content stream is attached to. */
- private PDFPage page;
/** State variable indicating whether a text object is currently open. */
private boolean textObjectOpen = false;
@@ -59,11 +57,9 @@
/**
* Create a PDFContentStream.
* @param doc The parent PDF document.
- * @param page The PDF page which content stream contains.
*/
- public PDFContentStream(final PDFDocument doc, final PDFPage page) {
+ public PDFContentStream(final PDFDocument doc) {
super(doc);
- this.page = page;
}
/**
@@ -339,16 +335,6 @@
e.printStackTrace();
}
- /* Add any links found in the SVG to the current page. */
- final GraphicLink[] graphicLinks = svg.getLinks();
- for (GraphicLink graphicLink : graphicLinks) {
- /* TODO: This is untested. */
- final PDFLink newLink = new PDFLink(this.getPDFDocument(),
- this.page, graphicLink.getShape().getBounds2D(),
- graphicLink.getUri().toString());
- this.page.addAnnotation(newLink);
- }
-
add("Q" + EOL);
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java 2007-06-22 16:54:30 UTC (rev 9833)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java 2007-06-22 19:40:12 UTC (rev 9834)
@@ -86,7 +86,7 @@
this.resources = resources;
this.pagewidth = pagewidth;
this.pageheight = pageheight;
- this.contents = new PDFContentStream(this.getPDFDocument(), this);
+ this.contents = new PDFContentStream(this.getPDFDocument());
try {
this.contents.addDefaultFilters();
} catch (final PDFException e) {
@@ -148,14 +148,6 @@
}
/**
- * Add a PDFAnnotation to the collection of annotations on this page.
- * @param annotation The {@link PDFAnnotation} to add.
- */
- public void addAnnotation(final PDFAnnotation annotation) {
- this.getAnnotList().addAnnotation(annotation);
- }
-
- /**
* Add an annotation list to the annotations on this page.
* @param listToAdd The annotation list to add.
*/
Modified: trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-06-22 16:54:30 UTC (rev 9833)
+++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-06-22 19:40:12 UTC (rev 9834)
@@ -54,6 +54,7 @@
import org.axsl.fontR.Font;
import org.axsl.fontR.FontUse;
import org.axsl.graphicR.Graphic;
+import org.axsl.graphicR.GraphicLink;
import org.axsl.graphicR.SVGGraphic;
import org.axsl.pdfW.PDFColor;
import org.axsl.pdfW.PDFContentStream;
@@ -71,9 +72,11 @@
import java.awt.Color;
import java.awt.Rectangle;
+import java.awt.Shape;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
+import java.net.URI;
import java.util.Date;
import java.util.List;
@@ -254,6 +257,7 @@
clipRectangle);
getContentStream().drawSVGDocument(graphic, pdfContentRectangle,
pdfClipRectangle, area.getFontConsumer(), getStrokeSVGText());
+ addSVGLinks(graphic);
}
/**
@@ -282,9 +286,29 @@
getContentStream().drawSVGDocument(svgGraphic,
contentRectangle, null, this.getFontConsumer(),
getStrokeSVGText());
+ addSVGLinks(svgGraphic);
}
/**
+ * Adds any links in the SVG to the current page.
+ * @param svg The SVG whose links should be added to this page.
+ */
+ private void addSVGLinks(final SVGGraphic svg) {
+ /* Add any links found in the SVG to the current page. */
+ final GraphicLink[] graphicLinks = svg.getLinks();
+ for (GraphicLink graphicLink : graphicLinks) {
+ /* TODO: This is untested. */
+ final Shape shape = graphicLink.getShape();
+ final URI target = graphicLink.getUri();
+ /* TODO: Need to compute this value from the URI?? However, if
+ * computable, it doesn't need to be in the interface. */
+ final boolean isExternal = true;
+ this.currentPage.makeLink(shape.getBounds2D(), target.toString(),
+ isExternal);
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
public void renderTextSegment(final GeneralInlineArea area,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|