Thread: [FOray-commit] SF.net SVN: foray: [9720] trunk/foray (Page 14)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-06-07 23:23:08
|
Revision: 9720
http://svn.sourceforge.net/foray/?rev=9720&view=rev
Author: victormote
Date: 2007-06-07 16:22:49 -0700 (Thu, 07 Jun 2007)
Log Message:
-----------
Remove a small Batik dependency by creating an SVG Utility class.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/NamespaceSVG.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java
Added Paths:
-----------
trunk/foray/foray-common/src/java/org/foray/common/SvgUtil.java
Added: trunk/foray/foray-common/src/java/org/foray/common/SvgUtil.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/SvgUtil.java (rev 0)
+++ trunk/foray/foray-common/src/java/org/foray/common/SvgUtil.java 2007-06-07 23:22:49 UTC (rev 9720)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.common;
+
+/**
+ * Utility class containing some useful SVG-related tools.
+ */
+public final class SvgUtil {
+
+ /** The namespace designation for SVG. */
+ public static final String SVG_NAMESPACE_URI = "http://www.w3.org/2000/svg";
+
+ /**
+ * Private Constructor. This class is a utility class, and should never be
+ * instantiated.
+ */
+ private SvgUtil() { }
+
+}
Property changes on: trunk/foray/foray-common/src/java/org/foray/common/SvgUtil.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/NamespaceSVG.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/NamespaceSVG.java 2007-06-07 23:05:29 UTC (rev 9719)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/NamespaceSVG.java 2007-06-07 23:22:49 UTC (rev 9720)
@@ -28,6 +28,7 @@
package org.foray.fotree.svg;
+import org.foray.common.SvgUtil;
import org.foray.fotree.FOTreeBuilder;
import org.foray.fotree.FObj;
import org.foray.fotree.Namespace;
@@ -61,7 +62,7 @@
* {@inheritDoc}
*/
public String getNamespaceURI() {
- return "http://www.w3.org/2000/svg";
+ return SvgUtil.SVG_NAMESPACE_URI;
}
/**
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java 2007-06-07 23:05:29 UTC (rev 9719)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java 2007-06-07 23:22:49 UTC (rev 9720)
@@ -30,6 +30,7 @@
import org.foray.common.FOrayConstants;
import org.foray.common.SVGUserAgent;
+import org.foray.common.SvgUtil;
import org.foray.fotree.FONode;
import org.foray.fotree.FObjScaled;
import org.foray.fotree.ForeignXML;
@@ -101,7 +102,7 @@
protected Document createDOMDocument() {
final DOMImplementation impl =
SVGDOMImplementation.getDOMImplementation();
- final String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
+ final String svgNS = SvgUtil.SVG_NAMESPACE_URI;
return impl.createDocument(svgNS, "svg", null);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-08 20:07:52
|
Revision: 9723
http://svn.sourceforge.net/foray/?rev=9723&view=rev
Author: victormote
Date: 2007-06-08 13:07:50 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
Add a test for inline SVG at the FOTree level.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
Added Paths:
-----------
trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java
trunk/foray/resource/test/fo/graphic-001.fo
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2007-06-08 19:45:52 UTC (rev 9722)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2007-06-08 20:07:50 UTC (rev 9723)
@@ -32,6 +32,7 @@
import org.foray.app.area.TestBorder;
import org.foray.app.area.TestMetadata;
import org.foray.app.fo.TestFont;
+import org.foray.app.fo.TestGraphic;
import org.foray.app.fo.TestInvalidXml;
import junit.framework.Test;
@@ -53,6 +54,7 @@
/* First the FO Tree tests. */
testSuite.addTestSuite(TestInvalidXml.class);
testSuite.addTestSuite(TestFont.class);
+ testSuite.addTestSuite(TestGraphic.class);
/* Now the Area Tree tests. */
testSuite.addTestSuite(TestBorder.class);
Added: trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java (rev 0)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java 2007-06-08 20:07:50 UTC (rev 9723)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.app.fo;
+
+import org.foray.core.FOrayException;
+import org.foray.fotree.FONode;
+import org.foray.fotree.FOTreeBuilder;
+import org.foray.fotree.fo.obj.Block;
+import org.foray.fotree.fo.obj.Flow;
+import org.foray.fotree.fo.obj.InstreamForeignObject;
+import org.foray.fotree.svg.obj.SVGElement;
+
+/**
+ * Tests of various graphic capabilities at the FO Tree level.
+ */
+public class TestGraphic extends AbstractFoTreeTest {
+
+ /**
+ * Test of fo/graphic-001.fo.
+ * This file contains an fo:instream-foreign-object with a simple SVG in it.
+ * @throws FOrayException For errors creating the FO Tree.
+ */
+ public void testGraphic001() throws FOrayException {
+ final FoDocumentReader reader = FoDocumentReader.getInstance();
+ final FOTreeBuilder foTree = reader.buildFoTree(
+ "fo/graphic-001.fo");
+ final Flow flow = this.getFlow(foTree);
+
+ /* The second child should be a block ... */
+ FONode node = flow.getChildAt(1);
+ assertTrue(node instanceof Block);
+ final Block block = (Block) node;
+
+ /* ... which contains an InstreamForeignObject ... */
+ node = block.getChildAt(0);
+ assertTrue(node instanceof InstreamForeignObject);
+ final InstreamForeignObject ifo = (InstreamForeignObject) node;
+
+ /* ... which contains an SVGElement ... */
+ node = ifo.getChildAt(0);
+ assertTrue(node instanceof SVGElement);
+ final SVGElement svgElement = (SVGElement) node;
+
+ /* ... for which we can find the width and height. */
+
+ /* The pixel width is 20. At the default screen resolution of 96 dpi,
+ * the millipoints are (20 / 96) * 72000 = 15000. */
+ assertEquals(15000, svgElement.intrinsicContentWidth());
+ assertEquals(15000, svgElement.intrinsicContentHeight());
+ }
+
+}
Property changes on: trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/resource/test/fo/graphic-001.fo
===================================================================
--- trunk/foray/resource/test/fo/graphic-001.fo (rev 0)
+++ trunk/foray/resource/test/fo/graphic-001.fo 2007-06-08 20:07:50 UTC (rev 9723)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<fo:layout-master-set>
+ <fo:simple-page-master
+ master-name="simple"
+ page-height="11in"
+ page-width="8.5in"
+ margin-top="1in"
+ margin-bottom="1in"
+ margin-left="1in"
+ margin-right="1in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+</fo:layout-master-set>
+
+<fo:page-sequence master-reference="simple">
+<fo:flow flow-name="xsl-region-body">
+
+<fo:block>The following block contains an inline SVG wrapped in a
+fo:foreign-xml object.</fo:block>
+
+<fo:block><fo:instream-foreign-object>
+
+<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"
+ xml:space="preserve">
+ <g style="fill:red; stroke:#000000">
+ <rect x="0" y="0" width="15" height="15"/>
+ <rect x="5" y="5" width="15" height="15"/>
+ </g>
+</svg>
+
+</fo:instream-foreign-object></fo:block>
+
+</fo:flow>
+</fo:page-sequence>
+</fo:root>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-08 21:33:13
|
Revision: 9724
http://svn.sourceforge.net/foray/?rev=9724&view=rev
Author: victormote
Date: 2007-06-08 14:33:11 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
1. Implement new axsl requirement for a GraphicServer method to create an SVGGraphic from an already-parsed SVGDocument.
2. Replace some FOTree code for instream SVG with new logic in the Graphic module.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java 2007-06-08 20:07:50 UTC (rev 9723)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java 2007-06-08 21:33:11 UTC (rev 9724)
@@ -32,7 +32,6 @@
import org.foray.common.SVGUserAgent;
import org.foray.common.SvgUtil;
import org.foray.fotree.FONode;
-import org.foray.fotree.FObjScaled;
import org.foray.fotree.ForeignXML;
import org.foray.fotree.Namespace;
import org.foray.fotree.PropertyListUnparsed;
@@ -40,11 +39,12 @@
import org.axsl.foR.FoTreeException;
import org.axsl.foR.ProxyFactory;
+import org.axsl.graphicR.GraphicException;
+import org.axsl.graphicR.SVGGraphic;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.UnitProcessor;
import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.batik.dom.svg.SVGOMDocument;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
@@ -54,11 +54,14 @@
import java.awt.geom.AffineTransform;
/**
- * class representing svg:svg pseudo flow object.
+ * The content of an inline SVG document.
*/
public class SVGElement extends ForeignXML
implements org.axsl.foR.svg.SvgElement {
+ /** The SVG Graphic instance for this inline SVG. */
+ private SVGGraphic svg;
+
/** The Batik bridge context for this element. */
private BridgeContext bridgeContext = null;
@@ -167,32 +170,28 @@
* {@inheritDoc}
*/
public int intrinsicContentWidth() {
- // 'width' attribute - default is 100%
- String s = getSVGRoot().getAttributeNS(null,
- SVGOMDocument.SVG_WIDTH_ATTRIBUTE);
- if (s.length() == 0) {
- s = SVGOMDocument.SVG_SVG_WIDTH_DEFAULT_VALUE;
+ try {
+ return this.getSVG().absoluteWidth(
+ FOrayConstants.DEFAULT_SCREEN_RESOLUTION);
+ } catch (final GraphicException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- final int pixels = (int) UnitProcessor.svgHorizontalLengthToUserSpace(s,
- SVGOMDocument.SVG_WIDTH_ATTRIBUTE, getUnitProcessorContext());
- return FObjScaled.pixelsToMillipoints(pixels,
- FOrayConstants.DEFAULT_SCREEN_RESOLUTION);
+ return -1;
}
/**
* {@inheritDoc}
*/
public int intrinsicContentHeight() {
- // 'height' attribute - default is 100%
- String s = getSVGRoot().getAttributeNS(null,
- SVGOMDocument.SVG_HEIGHT_ATTRIBUTE);
- if (s.length() == 0) {
- s = SVGOMDocument.SVG_SVG_HEIGHT_DEFAULT_VALUE;
+ try {
+ return this.getSVG().absoluteHeight(
+ FOrayConstants.DEFAULT_SCREEN_RESOLUTION);
+ } catch (final GraphicException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- final int pixels = (int) UnitProcessor.svgVerticalLengthToUserSpace(s,
- SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, getUnitProcessorContext());
- return FObjScaled.pixelsToMillipoints(pixels,
- FOrayConstants.DEFAULT_SCREEN_RESOLUTION);
+ return -1;
}
/**
@@ -209,4 +208,18 @@
this.getChildren().add(child);
}
+ /**
+ * Returns the SVG Graphic for the content of this object.
+ * @return The SVG Graphic for the content of this object.
+ * @throws GraphicException For errors creating the SVG Graphic from the
+ * SVG Document.
+ */
+ private SVGGraphic getSVG() throws GraphicException {
+ if (this.svg == null) {
+ final SVGDocument svgDocument = this.getSVGDocument();
+ this.svg = this.getGraphicServer().makeSvgGraphic(svgDocument);
+ }
+ return this.svg;
+ }
+
}
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java 2007-06-08 20:07:50 UTC (rev 9723)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java 2007-06-08 21:33:11 UTC (rev 9724)
@@ -348,8 +348,11 @@
// pixel Width is not valid
return -1;
}
- return pixelWidth / pixelsPerInch * WKConstants.POINTS_PER_INCH
- * WKConstants.MILLIPOINTS_PER_POINT;
+ final int computedWidth = Math.round(
+ ((float) pixelWidth / (float) pixelsPerInch)
+ * WKConstants.POINTS_PER_INCH
+ * WKConstants.MILLIPOINTS_PER_POINT);
+ return computedWidth;
}
/**
@@ -382,8 +385,11 @@
// pixel Height is not valid
return -1;
}
- return pixelHeight / pixelsPerInch * WKConstants.POINTS_PER_INCH
- * WKConstants.MILLIPOINTS_PER_POINT;
+ final int computedHeight = Math.round(
+ ((float) pixelHeight / (float) pixelsPerInch)
+ * WKConstants.POINTS_PER_INCH
+ * WKConstants.MILLIPOINTS_PER_POINT);
+ return computedHeight;
}
/**
@@ -562,4 +568,14 @@
this.inverted = inverted;
}
+ /**
+ * Allows subclasses to set the "basics parsed" flag if they have already
+ * parsed the basics.
+ * @param basicsParsed Set to true to indicate that the basics have already
+ * been parsed and do not need to be parsed again.
+ */
+ protected void setBasicsParsed(final boolean basicsParsed) {
+ this.basicsParsed = basicsParsed;
+ }
+
}
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-06-08 20:07:50 UTC (rev 9723)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-06-08 21:33:11 UTC (rev 9724)
@@ -43,9 +43,12 @@
import org.axsl.graphicR.GraphicException;
import org.axsl.graphicR.GraphicServer;
+import org.axsl.graphicR.SVGGraphic;
import org.apache.commons.logging.Log;
+import org.w3c.dom.svg.SVGDocument;
+
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -245,6 +248,14 @@
}
/**
+ * {@inheritDoc}
+ */
+ public SVGGraphic makeSvgGraphic(final SVGDocument svgDocument)
+ throws GraphicException {
+ return new org.foray.graphic.SVGGraphic(this, svgDocument);
+ }
+
+ /**
* Clear the image cache.
*/
public synchronized void resetCache() {
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-08 20:07:50 UTC (rev 9723)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-08 21:33:11 UTC (rev 9724)
@@ -67,7 +67,7 @@
private SVGDocument doc;
/**
- * Constructor.
+ * Constructor for the case of an unparsed URL.
* @param server The parent graphic server.
* @param url The URL which contains the graphic content.
* @param bis The reusable input stream containing the bytes from
@@ -79,6 +79,27 @@
}
/**
+ * Constructor for the case of a parsed {@link SVGDocument}.
+ * @param server The parent graphic server.
+ * @param svgDocument The parsed SVGDocument. This must not be null.
+ */
+ public SVGGraphic(final FOrayGraphicServer server,
+ final SVGDocument svgDocument) {
+ super(server, null, null);
+ if (svgDocument == null) {
+ throw new NullPointerException("Null SVGDocument");
+ }
+ this.doc = svgDocument;
+ try {
+ this.parseBasics();
+ } catch (final IOException e) {
+ /* The section that generates this exception is bypassed for this
+ * case, so we can safely ignore this. */
+ }
+ this.setBasicsParsed(true);
+ }
+
+ /**
* {@inheritDoc}
*/
public void loadImage() throws GraphicException {
@@ -127,8 +148,8 @@
* {@inheritDoc}
*/
public void parseBasics() throws IOException {
- // parse document and get the size attributes of the svg element
- try {
+ /* If the document has not yet been parsed, parse it. */
+ if (this.doc == null) {
final SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(
this.getServer().getSVGParserClassName());
/* It seems klunky to open another stream here, but the
@@ -138,7 +159,12 @@
*/
final SVGDocument doc = (SVGDocument) factory.createDocument(
getUrl().toString(), getUrl().openStream());
+ this.doc = doc;
+ }
+ /* Get the size attributes of the svg element. */
+ try {
+
final UserAgent userAgent = new MUserAgent(new AffineTransform());
final BridgeContext ctx = new BridgeContext(userAgent);
@@ -147,23 +173,28 @@
e);
String s;
- // 'width' attribute - default is 100%
+
+ /* Set the width (in pixels). */
s = e.getAttributeNS(null, SVGOMDocument.SVG_WIDTH_ATTRIBUTE);
if (s.length() == 0) {
+ /* Default is 100%. */
s = SVGOMDocument.SVG_SVG_WIDTH_DEFAULT_VALUE;
}
- setPixelWidth((int)
+ final float pixelWidth =
UnitProcessor.svgHorizontalLengthToUserSpace(s,
- SVGOMDocument.SVG_WIDTH_ATTRIBUTE, uctx));
+ SVGOMDocument.SVG_WIDTH_ATTRIBUTE, uctx);
+ setPixelWidth((int) pixelWidth);
- // 'height' attribute - default is 100%
+ /* Set the height (in pixels). */
s = e.getAttributeNS(null, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE);
if (s.length() == 0) {
+ /* Default is 100%. */
s = SVGOMDocument.SVG_SVG_HEIGHT_DEFAULT_VALUE;
}
- setPixelHeight((int) UnitProcessor.svgVerticalLengthToUserSpace(
- s, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx));
-
+ final float pixelHeight =
+ UnitProcessor.svgVerticalLengthToUserSpace(s,
+ SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx);
+ setPixelHeight((int) pixelHeight);
} catch (final NoClassDefFoundError ncdfe) {
getLogger().error("Batik not in class path");
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-08 22:12:37
|
Revision: 9726
http://svn.sourceforge.net/foray/?rev=9726&view=rev
Author: victormote
Date: 2007-06-08 15:12:39 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
1. Implement new axsl requirement for GraphicServer to create an empty SVGDocument.
2. Use new method to remove another Batik dependency.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/ForeignXML.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/ForeignXML.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/ForeignXML.java 2007-06-08 21:36:26 UTC (rev 9725)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/ForeignXML.java 2007-06-08 22:12:39 UTC (rev 9726)
@@ -87,9 +87,10 @@
* Constructor.
* @param parent The parent FObj.
* @param propertyList The property list for this FObj.
+ * @throws FoTreeException For errors during construction.
*/
public ForeignXML(final InstreamForeignObject parent,
- final PropertyListUnparsed propertyList) {
+ final PropertyListUnparsed propertyList) throws FoTreeException {
super(parent, propertyList);
this.parent = parent;
this.domDocument = createDOMDocument();
@@ -115,8 +116,10 @@
/**
* Create and return a DOM {@link Document} instance.
* @return The newly-created DOM {@link Document} instance.
+ * @throws FoTreeException For errors creating an appropriate DOM document
+ * for this object.
*/
- protected abstract Document createDOMDocument();
+ protected abstract Document createDOMDocument() throws FoTreeException;
/**
* Returns the DOM Document accumulated within this foreign XML.
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java 2007-06-08 21:36:26 UTC (rev 9725)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java 2007-06-08 22:12:39 UTC (rev 9726)
@@ -29,7 +29,6 @@
package org.foray.fotree.svg.obj;
import org.foray.common.FOrayConstants;
-import org.foray.common.SvgUtil;
import org.foray.fotree.FONode;
import org.foray.fotree.ForeignXML;
import org.foray.fotree.Namespace;
@@ -41,9 +40,6 @@
import org.axsl.graphicR.GraphicException;
import org.axsl.graphicR.SVGGraphic;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
-
-import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;
@@ -61,9 +57,10 @@
* Constructor.
* @param parent The parent FObj.
* @param propertyList The property list for this FObj.
+ * @throws FoTreeException For errors during construction.
*/
public SVGElement(final InstreamForeignObject parent,
- final PropertyListUnparsed propertyList) {
+ final PropertyListUnparsed propertyList) throws FoTreeException {
super(parent, propertyList);
}
@@ -91,11 +88,12 @@
/**
* {@inheritDoc}
*/
- protected Document createDOMDocument() {
- final DOMImplementation impl =
- SVGDOMImplementation.getDOMImplementation();
- final String svgNS = SvgUtil.SVG_NAMESPACE_URI;
- return impl.createDocument(svgNS, "svg", null);
+ protected Document createDOMDocument() throws FoTreeException {
+ try {
+ return this.getGraphicServer().makeSvgDocument();
+ } catch (final GraphicException e) {
+ throw new FoTreeException(e);
+ }
}
/**
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-06-08 21:36:26 UTC (rev 9725)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-06-08 22:12:39 UTC (rev 9726)
@@ -29,6 +29,7 @@
package org.foray.graphic;
import org.foray.common.Logging;
+import org.foray.common.SvgUtil;
import org.foray.common.sax.SaxParser;
import org.foray.common.url.URLUtil;
import org.foray.graphic.factory.BMPFactory;
@@ -45,8 +46,11 @@
import org.axsl.graphicR.GraphicServer;
import org.axsl.graphicR.SVGGraphic;
+import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.commons.logging.Log;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
import org.w3c.dom.svg.SVGDocument;
import java.io.BufferedInputStream;
@@ -278,4 +282,15 @@
return this.svgParserClassName;
}
+ /**
+ * {@inheritDoc}
+ */
+ public SVGDocument makeSvgDocument() throws GraphicException {
+ final DOMImplementation impl =
+ SVGDOMImplementation.getDOMImplementation();
+ final String svgNS = SvgUtil.SVG_NAMESPACE_URI;
+ final Document dom = impl.createDocument(svgNS, "svg", null);
+ return (SVGDocument) dom;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-08 23:02:34
|
Revision: 9729
http://svn.sourceforge.net/foray/?rev=9729&view=rev
Author: victormote
Date: 2007-06-08 16:02:26 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
Remove a Batik dependency by leveraging the new GraphicServer capabilities.
Modified Paths:
--------------
trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java
trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java
trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java
trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java
trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java
trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java
trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java
trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java
trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java
trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -115,7 +115,7 @@
final FileOutputStream outputStream = getFileOutputStream();
final OutputTarget outputTarget = OutputTargetFactory.makeOutputTarget(
outputType, outputOptions, outputStream,
- session.getLogger());
+ session.getLogger(), session.getGraphicServer());
/*
* Instantiate and configure the FOrayTarget(s). Multiple targets can
Modified: trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -39,6 +39,7 @@
import org.foray.render.txt.TXTRenderer;
import org.foray.render.xml.XMLRenderer;
+import org.axsl.graphicR.GraphicServer;
import org.axsl.output.OutputTarget;
import org.axsl.pdfW.PDFDocument;
@@ -77,13 +78,16 @@
* @param outputStream The output stream to which the target will be
* written.
* @param logger The logger.
+ * @param graphicServer The GraphicServer to be used for output targets that
+ * create a graphic (like the SVG Renderer).
* @return The newly-created OutputTarget instance.
* @throws FOrayException For errors creating the target.
*/
public static OutputTarget makeOutputTarget(
final OutputTargetType rendererType,
final OutputConfig outputOptions, final OutputStream outputStream,
- final Log logger) throws FOrayException {
+ final Log logger, final GraphicServer graphicServer)
+ throws FOrayException {
OutputTarget renderer = null;
switch (rendererType) {
case AWT: {
@@ -115,7 +119,7 @@
break;
}
case SVG: {
- renderer = new SVGRenderer(logger, outputOptions);
+ renderer = new SVGRenderer(logger, outputOptions, graphicServer);
break;
}
default: {
Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -313,7 +313,7 @@
final OutputTarget outputTarget =
OutputTargetFactory.makeOutputTarget(
this.task.getRendererType(), this.outputConfig, out,
- session.getLogger());
+ session.getLogger(), session.getGraphicServer());
new FOrayTarget(document, outputTarget, null, out);
session.process();
Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -341,7 +341,8 @@
renderOptions.parseOption("consistentOutput", "true",
SessionConfig.PRECEDENCE_DEFAULT);
final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
- rendererType, renderOptions, bos, session.getLogger());
+ rendererType, renderOptions, bos, session.getLogger(),
+ session.getGraphicServer());
new FOrayTarget(document, renderer, null, bos);
Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -73,7 +73,8 @@
//Setup Renderer
final OutputStream out = new FileOutputStream(pdf);
final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
- OutputTargetType.PDF, null, out, session.getLogger());
+ OutputTargetType.PDF, null, out, session.getLogger(),
+ session.getGraphicServer());
//Setup FOrayTarget
new FOrayTarget(document, renderer, null, out);
Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -90,7 +90,8 @@
//Setup Renderer
final OutputStream out = new FileOutputStream(pdf);
final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
- OutputTargetType.PDF, null, out, session.getLogger());
+ OutputTargetType.PDF, null, out, session.getLogger(),
+ session.getGraphicServer());
//Setup FOrayTarget
new FOrayTarget(document, renderer, null, out);
Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -90,7 +90,8 @@
//Setup Renderer
final OutputStream out = new FileOutputStream(pdf);
final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
- OutputTargetType.PDF, null, out, session.getLogger());
+ OutputTargetType.PDF, null, out, session.getLogger(),
+ session.getGraphicServer());
//Setup FOrayTarget
new FOrayTarget(document, renderer, null, out);
Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -194,7 +194,7 @@
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
OutputTargetType.PDF, null, output,
- session.getLogger());
+ session.getLogger(), session.getGraphicServer());
// Setup FOrayTarget
new FOrayTarget(document, renderer, null, output);
@@ -240,7 +240,7 @@
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
OutputTargetType.PDF, null, output,
- session.getLogger());
+ session.getLogger(), session.getGraphicServer());
// Setup FOrayTarget
new FOrayTarget(document, renderer, null, output);
Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java
===================================================================
--- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -139,7 +139,7 @@
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final OutputTarget renderer = OutputTargetFactory.makeOutputTarget(
OutputTargetType.PDF, null, output,
- document.getLogger());
+ document.getLogger(), document.getGraphicServer());
// Setup FOrayTarget
final FOrayTarget target = new FOrayTarget(document, renderer, null,
Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-08 22:39:14 UTC (rev 9728)
+++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-08 23:02:26 UTC (rev 9729)
@@ -47,6 +47,7 @@
import org.axsl.fontR.FontConsumer;
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicException;
+import org.axsl.graphicR.GraphicServer;
import org.axsl.graphicR.SVGGraphic;
import org.apache.batik.dom.svg.SVGDOMImplementation;
@@ -56,7 +57,6 @@
import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
import org.apache.commons.logging.Log;
-import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -105,12 +105,19 @@
/** The current page number. */
private int pageNumber = 0;
+ /** The Graphic Server to use for creation and handling of the SVG
+ * document.*/
+ private GraphicServer graphicServer;
+
/**
* Constructor.
* @param logger The logger.
* @param renderConfig The configuration for this renderer.
+ * @param graphicServer The Graphic Server to use for creation and handling
+ * of the SVG document.
*/
- public SVGRenderer(final Log logger, final OutputConfig renderConfig) {
+ public SVGRenderer(final Log logger, final OutputConfig renderConfig,
+ final GraphicServer graphicServer) {
super(logger, renderConfig);
}
@@ -610,9 +617,11 @@
* {@inheritDoc}
*/
public void startOutput() throws IOException {
- final DOMImplementation impl =
- SVGDOMImplementation.getDOMImplementation();
- this.svgDocument = impl.createDocument(SVGRenderer.SVG_NS, "svg", null);
+ try {
+ this.svgDocument = this.graphicServer.makeSvgDocument();
+ } catch (final GraphicException e) {
+ throw new IOException(e.getMessage());
+ }
final ProcessingInstruction pi =
this.svgDocument.createProcessingInstruction(
"xml",
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-08 23:26:29
|
Revision: 9731
http://svn.sourceforge.net/foray/?rev=9731&view=rev
Author: victormote
Date: 2007-06-08 16:26:31 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
1. Implement new axsl method allowing the GraphicServer to write an SVG document to an output stream.
2. Use new GraphicServer capability to remove a Batik dependency.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-06-08 23:05:50 UTC (rev 9730)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-06-08 23:26:31 UTC (rev 9731)
@@ -47,6 +47,10 @@
import org.axsl.graphicR.SVGGraphic;
import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.batik.transcoder.TranscoderInput;
+import org.apache.batik.transcoder.TranscoderOutput;
+import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
import org.apache.commons.logging.Log;
import org.w3c.dom.DOMImplementation;
@@ -56,6 +60,8 @@
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -293,4 +299,22 @@
return (SVGDocument) dom;
}
+ /**
+ * {@inheritDoc}
+ */
+ public void writeSvgDocument(final SVGDocument svgDocument,
+ final OutputStream outputStream) {
+ final SVGTranscoder svgT = new SVGTranscoder();
+ final TranscoderInput input = new TranscoderInput(svgDocument);
+ final OutputStreamWriter osw = new OutputStreamWriter(outputStream);
+ final TranscoderOutput output = new TranscoderOutput(osw);
+ try {
+ svgT.transcode(input, output);
+ } catch (final TranscoderException e) {
+ getLogger().error("could not write svg file :" + e.getMessage());
+ getLogger().error(e.getMessage());
+ }
+
+ }
+
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-08 23:05:50 UTC (rev 9730)
+++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-08 23:26:31 UTC (rev 9731)
@@ -51,10 +51,6 @@
import org.axsl.graphicR.GraphicServer;
import org.axsl.graphicR.SVGGraphic;
-import org.apache.batik.transcoder.TranscoderException;
-import org.apache.batik.transcoder.TranscoderInput;
-import org.apache.batik.transcoder.TranscoderOutput;
-import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
import org.apache.commons.logging.Log;
import org.w3c.dom.Document;
@@ -68,7 +64,6 @@
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
-import java.io.OutputStreamWriter;
/**
* A {@link Renderer} implementation that writes the document as SVG.
@@ -76,7 +71,7 @@
public class SVGRenderer extends Renderer {
/** The SVG document being created. */
- private Document svgDocument;
+ private SVGDocument svgDocument;
/** The root element of the SVG document. */
private Element svgRoot;
@@ -633,19 +628,8 @@
public void stopOutput() throws IOException {
this.svgRoot.setAttributeNS(null, "width", "" + this.totalWidth);
this.svgRoot.setAttributeNS(null, "height", "" + this.totalHeight);
-// svgRoot.setAttributeNS(null, "viewBox", "0 0 " + pageWidth + " "
-// + pageHeight);
- final SVGTranscoder svgT = new SVGTranscoder();
- final TranscoderInput input = new TranscoderInput(this.svgDocument);
- final OutputStreamWriter osw = new OutputStreamWriter(
+ this.graphicServer.writeSvgDocument(this.svgDocument,
this.getOutputStream());
- final TranscoderOutput output = new TranscoderOutput(osw);
- try {
- svgT.transcode(input, output);
- } catch (final TranscoderException e) {
- getLogger().error("could not write svg file :" + e.getMessage());
- getLogger().error(e.getMessage());
- }
this.getOutputStream().flush();
this.svgDocument = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-09 17:36:38
|
Revision: 9733
http://svn.sourceforge.net/foray/?rev=9733&view=rev
Author: victormote
Date: 2007-06-09 10:36:38 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Conform to axsl change from getSVGDocument to getSVGGraphic.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java 2007-06-09 00:10:18 UTC (rev 9732)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java 2007-06-09 17:36:38 UTC (rev 9733)
@@ -33,6 +33,7 @@
import org.axsl.foR.fo.GraftingPoint;
import org.axsl.foR.svg.SvgElement;
import org.axsl.graphicR.Graphic;
+import org.axsl.graphicR.GraphicException;
import org.w3c.dom.svg.SVGDocument;
@@ -80,9 +81,14 @@
* {@inheritDoc}
*/
public SVGDocument getSVGDocument() {
- // Cast verified at construction.
final SvgElement generatedBy = traitGeneratedBy();
- return generatedBy.getSVGDocument();
+ try {
+ return generatedBy.getSVGGraphic().getSVGDocument();
+ } catch (final GraphicException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
}
/**
@@ -140,6 +146,7 @@
* {@inheritDoc}
*/
public SvgElement traitGeneratedBy() {
+ /* Cast verified at construction. */
return (SvgElement) this.getLinkage().getFONode();
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java 2007-06-09 00:10:18 UTC (rev 9732)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/svg/obj/SVGElement.java 2007-06-09 17:36:38 UTC (rev 9733)
@@ -41,7 +41,6 @@
import org.axsl.graphicR.SVGGraphic;
import org.w3c.dom.Document;
-import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;
/**
@@ -104,18 +103,18 @@
}
/**
- * {@inheritDoc}
+ * Returns the SVGDocument.
+ * @return Thbe SVGDocument.
*/
- public SVGDocument getSVGDocument() {
+ private SVGDocument getSVGDocument() {
return (SVGDocument) this.getDocument();
}
/**
- * Returns the root element of the ancestor SVG document.
- * @return The root element of the ancestor SVG document.
+ * {@inheritDoc}
*/
- public Element getSVGRoot() {
- return getSVGDocument().getRootElement();
+ public SVGGraphic getSVGGraphic() {
+ return this.svg;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-09 18:27:25
|
Revision: 9734
http://svn.sourceforge.net/foray/?rev=9734&view=rev
Author: victormote
Date: 2007-06-09 11:27:25 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Conform to axsl change from getSVGDocument to getSVGGraphic.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java
trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java 2007-06-09 17:36:38 UTC (rev 9733)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/SVGArea.java 2007-06-09 18:27:25 UTC (rev 9734)
@@ -33,10 +33,8 @@
import org.axsl.foR.fo.GraftingPoint;
import org.axsl.foR.svg.SvgElement;
import org.axsl.graphicR.Graphic;
-import org.axsl.graphicR.GraphicException;
+import org.axsl.graphicR.SVGGraphic;
-import org.w3c.dom.svg.SVGDocument;
-
import java.util.Collections;
import java.util.List;
@@ -80,15 +78,9 @@
/**
* {@inheritDoc}
*/
- public SVGDocument getSVGDocument() {
+ public SVGGraphic getSVGGraphic() {
final SvgElement generatedBy = traitGeneratedBy();
- try {
- return generatedBy.getSVGGraphic().getSVGDocument();
- } catch (final GraphicException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
+ return generatedBy.getSVGGraphic();
}
/**
Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2007-06-09 17:36:38 UTC (rev 9733)
+++ trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2007-06-09 18:27:25 UTC (rev 9734)
@@ -521,16 +521,11 @@
graphics.setFont(f);
} else {
if (img instanceof SVGGraphic) {
- try {
- final SVGDocument svg = ((SVGGraphic) img).getSVGDocument();
- final Rectangle contentRect = new Rectangle(
- area.crOriginX(), area.crOriginY(), area.crIPD(),
- area.crBPD());
- renderSVGDocument(svg,
- Renderer.convertMillipointRectangle(contentRect),
- null);
- } catch (final GraphicException e) { }
-
+ final SVGGraphic svg = (SVGGraphic) img;
+ final Rectangle contentRect = new Rectangle(area.crOriginX(),
+ area.crOriginY(), area.crIPD(), area.crBPD());
+ renderSVGDocument(svg,
+ Renderer.convertMillipointRectangle(contentRect), null);
} else {
final String urlString = img.getURL().toString();
@@ -726,11 +721,10 @@
* {@inheritDoc}
*/
public void render(final SVGArea area) {
- final SVGDocument doc = area.getSVGDocument();
final Rectangle2D.Float contentRectangle = new Rectangle2D.Float(
toPoints(area.crOriginX()), toPoints(area.crOriginY()),
toPoints(area.crIPD()), toPoints(area.crBPD()));
- renderSVGDocument(doc, contentRectangle, null);
+ renderSVGDocument(area.getSVGGraphic(), contentRectangle, null);
}
/**
@@ -738,42 +732,42 @@
*/
protected void drawSVG(final GraphicArea area, final SVGGraphic graphic,
final Rectangle contentRectangle, final Rectangle clipRectangle) {
- SVGDocument svgDocument;
- try {
- svgDocument = graphic.getSVGDocument();
- } catch (final GraphicException e) {
- /* For some reason the SVGDocument is not usable. There is nothing
- * to do. */
- return;
- }
- renderSVGDocument(svgDocument,
+ renderSVGDocument(graphic,
Renderer.convertMillipointRectangle(contentRectangle),
Renderer.convertMillipointRectangle(clipRectangle));
}
/**
* Renders an SVG document.
- * @param doc The document to be rendered.
+ * @param graphic The SVG to be rendered.
* @param contentRectangle The rectangle to which the graphic should be
* scaled during drawing.
* @param clipRectangle The rectangle to which the content should be clipped
* after any scaling.
*/
- protected void renderSVGDocument(final SVGDocument doc,
+ protected void renderSVGDocument(final SVGGraphic graphic,
final Rectangle2D.Float contentRectangle,
final Rectangle2D.Float clipRectangle) {
+ SVGDocument svgDocument;
+ try {
+ svgDocument = graphic.getSVGDocument();
+ } catch (final GraphicException e) {
+ /* For some reason the SVGDocument is not usable. There is nothing
+ * to do. */
+ return;
+ }
final float x = contentRectangle.x;
final float y = contentRectangle.y;
final float w = contentRectangle.width;
final float h = contentRectangle.height;
- final GraphicsNode root = getGraphicsNode(doc);
+ final GraphicsNode root = getGraphicsNode(svgDocument);
if (root == null) {
return;
}
graphics.translate(x, pageHeight - y);
- final SVGSVGElement svg = doc.getRootElement();
+ final SVGSVGElement svg = svgDocument.getRootElement();
final AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
w, h);
AffineTransform inverse = null;
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-09 17:36:38 UTC (rev 9733)
+++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-06-09 18:27:25 UTC (rev 9734)
@@ -290,7 +290,16 @@
final Rectangle2D.Float contentRectangle = new Rectangle2D.Float(
toPoints(area.crOriginX()), toPoints(area.crOriginY()),
toPoints(area.crIPD()), toPoints(area.crBPD()));
- getContentStream().drawSVGDocument(area.getSVGDocument(),
+ final SVGGraphic svgGraphic = area.getSVGGraphic();
+ SVGDocument svgDocument = null;
+ try {
+ svgDocument = svgGraphic.getSVGDocument();
+ } catch (final GraphicException e) {
+ this.getLogger().error("Error getting SVGDocument in "
+ + this.getClass().getName());
+ return;
+ }
+ getContentStream().drawSVGDocument(svgDocument,
contentRectangle, null, this.getFontConsumer(),
getStrokeSVGText());
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2007-06-09 17:36:38 UTC (rev 9733)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2007-06-09 18:27:25 UTC (rev 9734)
@@ -67,7 +67,6 @@
import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
-import org.w3c.dom.Document;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGSVGElement;
@@ -509,18 +508,26 @@
public void render(final SVGArea area) {
final int x = area.crOriginX();
final int y = area.crOriginY();
- renderSVGDocument(area.getSVGDocument(), x, y, area);
+ renderSVGDocument(area.getSVGGraphic(), x, y, area);
}
/**
* Render an SVG document to PostScript.
- * @param doc The SVG document to render.
+ * @param svgGraphic The SVG graphic to be rendered.
* @param x The x coordindate to the beginning of the SVG, in millipoints.
* @param y The y coordindate to the beginning of the SVG, in millipoints.
* @param area The area containing the graphic to be rendered.
*/
- protected void renderSVGDocument(final Document doc, final int x,
+ protected void renderSVGDocument(final SVGGraphic svgGraphic, final int x,
final int y, final GraphicArea area) {
+ SVGDocument doc = null;
+ try {
+ doc = svgGraphic.getSVGDocument();
+ } catch (final GraphicException e) {
+ this.getLogger().error("Error getting SVGDocument in "
+ + this.getClass().getName());
+ return;
+ }
BridgeContext ctx = makeBridgeContext();
GVTBuilder builder = new GVTBuilder();
@@ -538,7 +545,7 @@
float h = (float) ctx.getDocumentSize().getHeight();
//log.debug("drawing SVG image: "+x+"/"+y+" "+w+"/"+h);
- final SVGSVGElement svg = ((SVGDocument) doc).getRootElement();
+ final SVGSVGElement svg = doc.getRootElement();
final AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
w, h);
@@ -600,13 +607,9 @@
return;
}
if (image instanceof SVGGraphic) {
- try {
- renderSVGDocument(((SVGGraphic) image).getSVGDocument(),
- contentRectangle.x, contentRectangle.y, area);
- } catch (final GraphicException e) {
- getLogger().error("Error rendering SVG image");
- getLogger().error(e.getMessage());
- }
+ final SVGGraphic svgGraphic = (SVGGraphic) image;
+ renderSVGDocument(svgGraphic, contentRectangle.x,
+ contentRectangle.y, area);
} else if (image instanceof EPSGraphic) {
renderEPS((EPSGraphic) image, contentRectangle.x,
contentRectangle.y, contentRectangle.width,
Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-09 17:36:38 UTC (rev 9733)
+++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-09 18:27:25 UTC (rev 9734)
@@ -413,12 +413,9 @@
} else {
if (img instanceof SVGGraphic) {
- try {
- final SVGDocument svg = ((SVGGraphic) img).getSVGDocument();
- renderSVGDocument(svg, toPoints(x),
- this.pageHeight - toPoints(y));
- } catch (final GraphicException e) { }
-
+ final SVGGraphic svgGraphic = (SVGGraphic) img;
+ renderSVGDocument(svgGraphic, toPoints(x),
+ this.pageHeight - toPoints(y));
// } else {
//
// String urlString = img.getURL().toString();
@@ -564,20 +561,28 @@
public void render(final SVGArea area) {
final float x = toPoints(area.crOriginX());
final float y = this.pageHeight - toPoints(area.crOriginY());
- final Document doc = area.getSVGDocument();
- renderSVGDocument(doc, x, y);
+ final SVGGraphic svgGraphic = area.getSVGGraphic();
+ renderSVGDocument(svgGraphic, x, y);
}
/**
* Renders an SVG Document.
- * @param doc The document to be rendered.
+ * @param svgGraphic The document to be rendered.
* @param x The x coordinate at which the document should be rendered,
* in points (??).
* @param y The y coordindate at which the document should be rendered,
* in points (??).
*/
- protected void renderSVGDocument(final Document doc, final float x,
+ protected void renderSVGDocument(final SVGGraphic svgGraphic, final float x,
final float y) {
+ Document doc = null;
+ try {
+ doc = svgGraphic.getSVGDocument();
+ } catch (final GraphicException e) {
+ this.getLogger().error("Error getting SVGDocument in "
+ + this.getClass().getName());
+ return;
+ }
final SVGSVGElement svg = ((SVGDocument) doc).getRootElement();
final Element view = this.svgDocument.createElementNS(
SvgUtil.SVG_NAMESPACE_URI, "svg");
Modified: trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2007-06-09 17:36:38 UTC (rev 9733)
+++ trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2007-06-09 18:27:25 UTC (rev 9734)
@@ -47,8 +47,6 @@
import org.apache.commons.logging.Log;
-import org.w3c.dom.svg.SVGSVGElement;
-
import java.awt.Color;
import java.awt.Rectangle;
import java.io.IOException;
@@ -510,35 +508,11 @@
}
/**
- * Renders an SVG graphic.
- * @param svg The SVG graphic to render.
- * @param x The x coordinate at which the SVG graphic should be rendered.
- * @param y The y coordinate at which the SVG graphic should be rendered.
- */
- void renderSVG(final SVGSVGElement svg, final int x, final int y) {
- /*
- * SVG - Not yet implemented
- * NodeList nl = svg.getChildNodes();
- * for(int count = 0; count < nl.getLength(); count++) {
- * Node n = nl.item(count);
- * if(n instanceof SVGElement) {
- * renderElement((SVGElement)n, x, y);
- * }
- * }
- */
- }
-
- /**
* {@inheritDoc}
*/
public void render(final SVGArea area) {
getLogger().debug("TXTRenderer.renderSVGArea(" + area + ")");
- final int x = area.crOriginX();
- final int y = area.crOriginY();
- final SVGSVGElement svg = area.getSVGDocument().getRootElement();
-
- // TODO - translate and clip to viewbox
- renderSVG(svg, x, y);
+ /* TODO: Implement this?? */
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-09 20:20:12
|
Revision: 9737
http://svn.sourceforge.net/foray/?rev=9737&view=rev
Author: victormote
Date: 2007-06-09 13:20:14 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Conform to axsl changes that allow the Graphic system to render SVG on an AWT device. This effectively moves code from AWTRenderer to SVGGraphic.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-09 20:00:38 UTC (rev 9736)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-09 20:20:14 UTC (rev 9737)
@@ -34,15 +34,22 @@
import org.axsl.graphicR.GraphicException;
import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.bridge.UnitProcessor;
import org.apache.batik.bridge.UserAgent;
+import org.apache.batik.bridge.ViewBox;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.dom.svg.SVGOMDocument;
+import org.apache.batik.gvt.GraphicsNode;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;
+import org.w3c.dom.svg.SVGSVGElement;
+import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
+import java.awt.geom.NoninvertibleTransformException;
+import java.awt.geom.Rectangle2D;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URL;
@@ -206,4 +213,82 @@
return null;
}
+ /**
+ * {@inheritDoc}
+ */
+ public void awtPaint(final Graphics2D graphics,
+ final Rectangle2D.Float contentRectangle,
+ final Rectangle2D.Float clipRectangle, final int pageHeight) {
+ SVGDocument svgDocument;
+ try {
+ svgDocument = this.getSVGDocument();
+ } catch (final GraphicException e) {
+ /* For some reason the SVGDocument is not usable. There is nothing
+ * to do. */
+ return;
+ }
+ final float x = contentRectangle.x;
+ final float y = contentRectangle.y;
+ final float w = contentRectangle.width;
+ final float h = contentRectangle.height;
+ final GraphicsNode root = getGraphicsNode(svgDocument);
+ if (root == null) {
+ return;
+ }
+
+ graphics.translate(x, pageHeight - y);
+
+ final SVGSVGElement svg = svgDocument.getRootElement();
+ final AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
+ w, h);
+ AffineTransform inverse = null;
+ try {
+ inverse = at.createInverse();
+ } catch (final NoninvertibleTransformException e) {
+ }
+ if (! at.isIdentity()) {
+ graphics.transform(at);
+ }
+
+ try {
+ root.paint(graphics);
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+
+ if (inverse != null && !inverse.isIdentity()) {
+ graphics.transform(inverse);
+ }
+ graphics.translate(- x, y - pageHeight);
+ }
+
+ /**
+ * Returns the Batik GraphicsNode to be used.
+ * @param doc The SVG document.
+ * @return The Batik GraphicsNode.
+ */
+ protected GraphicsNode getGraphicsNode(final SVGDocument doc) {
+ final BridgeContext ctx = makeBridgeContextAWT();
+ final GVTBuilder builder = new GVTBuilder();
+ try {
+ return builder.build(ctx, doc);
+ } catch (final Exception e) {
+ getLogger().error("svg graphic could not be built: "
+ + e.getMessage());
+ getLogger().error(e.getMessage());
+ return null;
+ }
+ }
+
+ /**
+ * Creates a BridgeContext instance suitable for use by Batik when rendering
+ * an SVG graphic in an AWT environment.
+ * @return A Batik BridgeContext instance.
+ */
+ public BridgeContext makeBridgeContextAWT() {
+ final MUserAgent userAgent = new MUserAgent(new AffineTransform());
+ userAgent.setLogger(getLogger());
+ return new BridgeContext(userAgent);
+ }
+
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2007-06-09 20:00:38 UTC (rev 9736)
+++ trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2007-06-09 20:20:14 UTC (rev 9737)
@@ -34,7 +34,6 @@
package org.foray.render;
import org.foray.common.FOrayConstants;
-import org.foray.common.MUserAgent;
import org.foray.common.SVGUserAgent;
import org.foray.common.WKConstants;
import org.foray.output.OutputConfig;
@@ -610,17 +609,6 @@
}
/**
- * Creates a BridgeContext instance suitable for use by Batik when rendering
- * an SVG graphic in an AWT environment.
- * @return A Batik BridgeContext instance.
- */
- public BridgeContext makeBridgeContextAWT() {
- final MUserAgent userAgent = new MUserAgent(new AffineTransform());
- userAgent.setLogger(getLogger());
- return new BridgeContext(userAgent);
- }
-
- /**
* Converts a Rectangle storing millipoints to one storing points.
* @param input A rectangle whose dimensions are stored as millipoints.
* @return A new rectangle whose dimensions are stored as points.
Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2007-06-09 20:00:38 UTC (rev 9736)
+++ trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2007-06-09 20:20:14 UTC (rev 9737)
@@ -58,18 +58,10 @@
import org.axsl.fontR.FontConsumer;
import org.axsl.fontR.FontUse;
import org.axsl.graphicR.Graphic;
-import org.axsl.graphicR.GraphicException;
import org.axsl.graphicR.SVGGraphic;
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.bridge.ViewBox;
-import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
-import org.w3c.dom.svg.SVGDocument;
-import org.w3c.dom.svg.SVGSVGElement;
-
import java.awt.Color;
import java.awt.Component;
import java.awt.FontMetrics;
@@ -80,7 +72,6 @@
import java.awt.RenderingHints;
import java.awt.font.LineMetrics;
import java.awt.geom.AffineTransform;
-import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.print.PageFormat;
@@ -748,68 +739,11 @@
protected void renderSVGDocument(final SVGGraphic graphic,
final Rectangle2D.Float contentRectangle,
final Rectangle2D.Float clipRectangle) {
- SVGDocument svgDocument;
- try {
- svgDocument = graphic.getSVGDocument();
- } catch (final GraphicException e) {
- /* For some reason the SVGDocument is not usable. There is nothing
- * to do. */
- return;
- }
- final float x = contentRectangle.x;
- final float y = contentRectangle.y;
- final float w = contentRectangle.width;
- final float h = contentRectangle.height;
- final GraphicsNode root = getGraphicsNode(svgDocument);
- if (root == null) {
- return;
- }
-
- graphics.translate(x, pageHeight - y);
-
- final SVGSVGElement svg = svgDocument.getRootElement();
- final AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
- w, h);
- AffineTransform inverse = null;
- try {
- inverse = at.createInverse();
- } catch (final NoninvertibleTransformException e) {
- }
- if (! at.isIdentity()) {
- graphics.transform(at);
- }
-
- try {
- root.paint(graphics);
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (inverse != null && !inverse.isIdentity()) {
- graphics.transform(inverse);
- }
- graphics.translate(- x, y - pageHeight);
+ graphic.awtPaint(this.graphics, contentRectangle, clipRectangle,
+ this.pageHeight);
}
/**
- * Returns the Batik GraphicsNode to be used.
- * @param doc The SVG document.
- * @return The Batik GraphicsNode.
- */
- protected GraphicsNode getGraphicsNode(final SVGDocument doc) {
- final BridgeContext ctx = makeBridgeContextAWT();
- final GVTBuilder builder = new GVTBuilder();
- try {
- return builder.build(ctx, doc);
- } catch (final Exception e) {
- getLogger().error("svg graphic could not be built: "
- + e.getMessage());
- getLogger().error(e.getMessage());
- return null;
- }
- }
-
- /**
* {@inheritDoc}
*/
public void render(final BookmarkTreeArea area) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-09 21:52:15
|
Revision: 9738
http://svn.sourceforge.net/foray/?rev=9738&view=rev
Author: victormote
Date: 2007-06-09 14:52:14 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Move PSStream from the render module to common, and rename it CharacterOutputStream, so that it can be used by other modules.
Modified Paths:
--------------
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
Added Paths:
-----------
trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java
Removed Paths:
-------------
trunk/foray/foray-render/src/java/org/foray/render/ps/PSStream.java
Added: trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java (rev 0)
+++ trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java 2007-06-09 21:52:14 UTC (rev 9738)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy: victormote $
+ */
+
+package org.foray.common;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Output stream used to write character-based data (that is, Strings) to a
+ * wrapped (byte-based) output stream. Has methods to write Strings as raw
+ * Strings and to write them as lines (appending an end-of-line character).
+ */
+public class CharacterOutputStream extends FilterOutputStream {
+
+ /**
+ * Constructor.
+ * @param out The encapsulated OutputStream.
+ */
+ public CharacterOutputStream(final OutputStream out) {
+ super(out);
+ }
+
+ /**
+ * Writes text to the stream, adding a linefeed at the end.
+ * @param cmd The text to be written to the output stream.
+ * @throws IOException For I/O errors during the write.
+ */
+ public void write(final String cmd) throws IOException {
+ write(cmd.getBytes("US-ASCII"));
+ write('\n');
+ }
+
+ /**
+ * Writes text to the stream (no linefeed is appended).
+ * @param cmd The text to be written to the output stream.
+ * @throws IOException For I/O errors during the write.
+ */
+ public void writeRaw(final String cmd) throws IOException {
+ write(cmd.getBytes("US-ASCII"));
+ }
+
+ /**
+ * Writes an array of bytes to the output stream.
+ * @param cmd The array of bytes to be written to the output stream.
+ * @throws IOException For I/O errors during the write.
+ */
+ public void writeByteArr(final byte[] cmd) throws IOException {
+ write(cmd);
+ write('\n');
+ }
+
+}
Property changes on: trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2007-06-09 20:20:14 UTC (rev 9737)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2007-06-09 21:52:14 UTC (rev 9738)
@@ -33,6 +33,7 @@
package org.foray.render.ps;
+import org.foray.common.CharacterOutputStream;
import org.foray.common.WKConstants;
import org.foray.output.OutputConfig;
import org.foray.ps.FOrayBoundingBox;
@@ -137,7 +138,7 @@
private boolean autoRotateLandscape = false;
/** The stream used to output the PostScript. */
- private PSStream out;
+ private CharacterOutputStream out;
/** Indicates the existence of an I/O error. Set after the first IOException
* so that a second one will trigger a stack trace. */
@@ -1170,7 +1171,7 @@
getLogger().debug("rendering areas to PostScript");
this.pagecount = 0;
- this.out = new PSStream(this.getOutputStream());
+ this.out = new CharacterOutputStream(this.getOutputStream());
write("%!PS-Adobe-3.0");
write("%%Creator: " + getApplicationVersion());
write("%%Pages: (atend)");
Deleted: trunk/foray/foray-render/src/java/org/foray/render/ps/PSStream.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSStream.java 2007-06-09 20:20:14 UTC (rev 9737)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSStream.java 2007-06-09 21:52:14 UTC (rev 9738)
@@ -1,77 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.render.ps;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Specialized output stream used by {@link PSRenderer}.
- */
-public class PSStream extends FilterOutputStream {
-
- /**
- * Constructor.
- * @param out The encapsulated OutputStream.
- */
- public PSStream(final OutputStream out) {
- super(out);
- }
-
- /**
- * Writes text to the stream, adding a linefeed at the end.
- * @param cmd The text to be written to the output stream.
- * @throws IOException For I/O errors during the write.
- */
- public void write(final String cmd) throws IOException {
- write(cmd.getBytes("US-ASCII"));
- write('\n');
- }
-
- /**
- * Writes text to the stream (no linefeed is appended).
- * @param cmd The text to be written to the output stream.
- * @throws IOException For I/O errors during the write.
- */
- public void writeRaw(final String cmd) throws IOException {
- write(cmd.getBytes("US-ASCII"));
- }
-
- /**
- * Writes an array of bytes to the output stream.
- * @param cmd The array of bytes to be written to the output stream.
- * @throws IOException For I/O errors during the write.
- */
- public void writeByteArr(final byte[] cmd) throws IOException {
- write(cmd);
- write('\n');
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-09 22:27:24
|
Revision: 9739
http://svn.sourceforge.net/foray/?rev=9739&view=rev
Author: victormote
Date: 2007-06-09 15:27:26 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Add ability to selectively output comments based on construction-time parameter.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java 2007-06-09 21:52:14 UTC (rev 9738)
+++ trunk/foray/foray-common/src/java/org/foray/common/CharacterOutputStream.java 2007-06-09 22:27:26 UTC (rev 9739)
@@ -39,11 +39,17 @@
*/
public class CharacterOutputStream extends FilterOutputStream {
+ /** Indicates whether comments should be written. */
+ private boolean commentsEnabled;
+
/**
* Constructor.
* @param out The encapsulated OutputStream.
+ * @param commentsEnabled Indicates whether comments should be written.
+ * If false, the method {@link #comment(String)} is ignored.
*/
- public CharacterOutputStream(final OutputStream out) {
+ public CharacterOutputStream(final OutputStream out,
+ final boolean commentsEnabled) {
super(out);
}
@@ -76,4 +82,15 @@
write('\n');
}
+ /**
+ * Writes a given comment, if comments are enabled.
+ * @param comment The comment to be written.
+ * @throws IOException For I/O errors during the write.
+ */
+ public void comment(final String comment) throws IOException {
+ if (this.commentsEnabled) {
+ write(comment);
+ }
+ }
+
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2007-06-09 21:52:14 UTC (rev 9738)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2007-06-09 22:27:26 UTC (rev 9739)
@@ -1171,7 +1171,8 @@
getLogger().debug("rendering areas to PostScript");
this.pagecount = 0;
- this.out = new CharacterOutputStream(this.getOutputStream());
+ this.out = new CharacterOutputStream(this.getOutputStream(),
+ this.enableComments);
write("%!PS-Adobe-3.0");
write("%%Creator: " + getApplicationVersion());
write("%%Pages: (atend)");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-09 22:45:23
|
Revision: 9740
http://svn.sourceforge.net/foray/?rev=9740&view=rev
Author: victormote
Date: 2007-06-09 15:45:22 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Move the MUserAgent class from common to graphic, and rename it BatikUaAwt to clarify its purpose.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaAwt.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/package.html
Removed Paths:
-------------
trunk/foray/foray-common/src/java/org/foray/common/MUserAgent.java
Deleted: trunk/foray/foray-common/src/java/org/foray/common/MUserAgent.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/MUserAgent.java 2007-06-09 22:27:26 UTC (rev 9739)
+++ trunk/foray/foray-common/src/java/org/foray/common/MUserAgent.java 2007-06-09 22:45:22 UTC (rev 9740)
@@ -1,88 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.common;
-
-
-import org.apache.batik.gvt.event.EventDispatcher;
-
-import org.w3c.dom.svg.SVGAElement;
-
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Point;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Dimension2D;
-
-/**
- * An SVGUserAgent extension.
- */
-public class MUserAgent extends SVGUserAgent {
-
- /**
- * Creates a new SVGUserAgent.
- * @param at The AffineTransform instance for this.
- */
- public MUserAgent(final AffineTransform at) {
- super(at);
- }
-
- /**
- * {@inheritDoc}
- */
- public void openLink(final SVGAElement elt) {
- // application.openLink(uri);
- }
-
- /**
- * {@inheritDoc}
- */
- public Point getClientAreaLocationOnScreen() {
- return new Point(0, 0);
- }
-
- /**
- * {@inheritDoc}
- */
- public void setSVGCursor(final Cursor cursor) { }
-
- /**
- * {@inheritDoc}
- */
- public Dimension2D getViewportSize() {
- return new Dimension(DEFAULT_VIEWPORT_WIDTH, DEFAULT_VIEWPORT_HEIGHT);
- }
-
- /**
- * {@inheritDoc}
- */
- public EventDispatcher getEventDispatcher() {
- return null;
- }
-
-}
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-09 22:27:26 UTC (rev 9739)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-09 22:45:22 UTC (rev 9740)
@@ -28,7 +28,7 @@
package org.foray.graphic;
-import org.foray.common.MUserAgent;
+import org.foray.graphic.batik.BatikUaAwt;
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicException;
@@ -162,7 +162,7 @@
/* Get the size attributes of the svg element. */
try {
- final UserAgent userAgent = new MUserAgent(new AffineTransform());
+ final UserAgent userAgent = new BatikUaAwt(new AffineTransform());
final BridgeContext ctx = new BridgeContext(userAgent);
final Element e = doc.getRootElement();
@@ -286,7 +286,7 @@
* @return A Batik BridgeContext instance.
*/
public BridgeContext makeBridgeContextAWT() {
- final MUserAgent userAgent = new MUserAgent(new AffineTransform());
+ final BatikUaAwt userAgent = new BatikUaAwt(new AffineTransform());
userAgent.setLogger(getLogger());
return new BridgeContext(userAgent);
}
Added: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaAwt.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaAwt.java (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaAwt.java 2007-06-09 22:45:22 UTC (rev 9740)
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy: victormote $
+ */
+
+package org.foray.graphic.batik;
+
+
+import org.foray.common.SVGUserAgent;
+
+import org.apache.batik.gvt.event.EventDispatcher;
+
+import org.w3c.dom.svg.SVGAElement;
+
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+
+/**
+ * A Batik UserAgent implementation that is used when drawing an SVG using an
+ * AWT device (screen or printer). For drawing into a PDF, PostScript, or
+ * similar file, see {@link SVGUserAgent}.
+ */
+public class BatikUaAwt extends SVGUserAgent {
+
+ /**
+ * Creates a new SVGUserAgent.
+ * @param at The AffineTransform instance for this.
+ */
+ public BatikUaAwt(final AffineTransform at) {
+ super(at);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void openLink(final SVGAElement elt) {
+ // application.openLink(uri);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Point getClientAreaLocationOnScreen() {
+ return new Point(0, 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setSVGCursor(final Cursor cursor) { }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Dimension2D getViewportSize() {
+ return new Dimension(DEFAULT_VIEWPORT_WIDTH, DEFAULT_VIEWPORT_HEIGHT);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public EventDispatcher getEventDispatcher() {
+ return null;
+ }
+
+}
Property changes on: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaAwt.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/package.html
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/package.html (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/package.html 2007-06-09 22:45:22 UTC (rev 9740)
@@ -0,0 +1,6 @@
+<html>
+<title>org.foray.graphic.batik Package</title>
+<body>
+<p>Classes related to using Batik for SVG processing.</p>
+</body>
+</html>
Property changes on: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/package.html
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-10 03:18:36
|
Revision: 9742
http://svn.sourceforge.net/foray/?rev=9742&view=rev
Author: victormote
Date: 2007-06-09 20:18:35 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Upgrade Batik to 1.6.
Modified Paths:
--------------
trunk/foray/doc/web/app/using/release.html
trunk/foray/foray-common/.classpath
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-pdf/.classpath
trunk/foray/foray-render/.classpath
trunk/foray/foray-render/scripts/build.xml
Added Paths:
-----------
trunk/foray/lib/batik-1.6-awt-util.jar
trunk/foray/lib/batik-1.6-bridge.jar
trunk/foray/lib/batik-1.6-css.jar
trunk/foray/lib/batik-1.6-dom.jar
trunk/foray/lib/batik-1.6-ext.jar
trunk/foray/lib/batik-1.6-gvt.jar
trunk/foray/lib/batik-1.6-parser.jar
trunk/foray/lib/batik-1.6-pdf-transcoder.jar
trunk/foray/lib/batik-1.6-script.jar
trunk/foray/lib/batik-1.6-svg-dom.jar
trunk/foray/lib/batik-1.6-transcoder.jar
trunk/foray/lib/batik-1.6-util.jar
trunk/foray/lib/batik-1.6-xml.jar
trunk/foray/lib/batik-license.txt
Removed Paths:
-------------
trunk/foray/lib/batik.LICENSE.txt
trunk/foray/lib/batik.jar
Modified: trunk/foray/doc/web/app/using/release.html
===================================================================
--- trunk/foray/doc/web/app/using/release.html 2007-06-10 01:10:08 UTC (rev 9741)
+++ trunk/foray/doc/web/app/using/release.html 2007-06-10 03:18:35 UTC (rev 9742)
@@ -51,6 +51,7 @@
should not cause processing errors.
(The bookmark-related objects are fully supported).</li>
<li>Significant improvements to expressions in property values.</li>
+ <li>The Batik libraries (for SVG processing) have been upgraded to 1.6.</li>
</ul>
<h3>Unreleased changes of interest to Developers</h3>
Modified: trunk/foray/foray-common/.classpath
===================================================================
--- trunk/foray/foray-common/.classpath 2007-06-10 01:10:08 UTC (rev 9741)
+++ trunk/foray/foray-common/.classpath 2007-06-10 03:18:35 UTC (rev 9742)
@@ -3,8 +3,8 @@
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/axslCommon"/>
- <classpathentry kind="lib" path="/FOray Lib/batik.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-06-10 01:10:08 UTC (rev 9741)
+++ trunk/foray/foray-graphic/.classpath 2007-06-10 03:18:35 UTC (rev 9742)
@@ -8,8 +8,17 @@
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit.jar"/>
<classpathentry kind="lib" path="/FOray Lib/xmlgraphics-commons-1.1.jar" sourcepath="/FOray Lib-Build/xmlgraphics-commons/xmlgraphics-commons-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-parser.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-transcoder.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-svg-dom.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-dom.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-xml.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-pdf/.classpath
===================================================================
--- trunk/foray/foray-pdf/.classpath 2007-06-10 01:10:08 UTC (rev 9741)
+++ trunk/foray/foray-pdf/.classpath 2007-06-10 03:18:35 UTC (rev 9742)
@@ -9,7 +9,17 @@
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry kind="src" path="/FOrayPS"/>
<classpathentry kind="src" path="/axslPDF-W"/>
- <classpathentry kind="lib" path="/FOray Lib/batik.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-svg-dom.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-dom.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-css.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-transcoder.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-ext.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-render/.classpath
===================================================================
--- trunk/foray/foray-render/.classpath 2007-06-10 01:10:08 UTC (rev 9741)
+++ trunk/foray/foray-render/.classpath 2007-06-10 03:18:35 UTC (rev 9742)
@@ -15,7 +15,12 @@
<classpathentry combineaccessrules="false" kind="src" path="/FOrayPS"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-render/scripts/build.xml
===================================================================
--- trunk/foray/foray-render/scripts/build.xml 2007-06-10 01:10:08 UTC (rev 9741)
+++ trunk/foray/foray-render/scripts/build.xml 2007-06-10 03:18:35 UTC (rev 9742)
@@ -31,7 +31,7 @@
</fileset>
<fileset dir="${lib.dir}">
<include name="axsl*.jar"/>
- <include name="batik.jar"/>
+ <include name="batik*.jar"/>
<include name="commons-logging-*.jar"/>
</fileset>
<fileset dir="${foray.sandbox}/foray-common/build/ant">
Added: trunk/foray/lib/batik-1.6-awt-util.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-awt-util.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-bridge.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-bridge.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-css.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-css.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-dom.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-dom.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-ext.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-ext.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-gvt.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-gvt.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-parser.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-parser.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-pdf-transcoder.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-pdf-transcoder.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-script.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-script.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-svg-dom.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-svg-dom.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-transcoder.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-transcoder.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-util.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-util.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-1.6-xml.jar
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib/batik-1.6-xml.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/foray/lib/batik-license.txt
===================================================================
--- trunk/foray/lib/batik-license.txt (rev 0)
+++ trunk/foray/lib/batik-license.txt 2007-06-10 03:18:35 UTC (rev 9742)
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
Property changes on: trunk/foray/lib/batik-license.txt
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Deleted: trunk/foray/lib/batik.LICENSE.txt
===================================================================
--- trunk/foray/lib/batik.LICENSE.txt 2007-06-10 01:10:08 UTC (rev 9741)
+++ trunk/foray/lib/batik.LICENSE.txt 2007-06-10 03:18:35 UTC (rev 9742)
@@ -1,45 +0,0 @@
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 2000 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Batik" and "Apache Software Foundation" must not be used to
- endorse or promote products derived from this software without prior
- written permission. For written permission, please contact
- ap...@ap....
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation. For more information on the
- Apache Software Foundation, please see <http://www.apache.org/>.
Deleted: trunk/foray/lib/batik.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-10 03:36:19
|
Revision: 9743
http://svn.sourceforge.net/foray/?rev=9743&view=rev
Author: victormote
Date: 2007-06-09 20:36:21 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Add Batik source code to the dev library, and add Eclipse links to it.
Modified Paths:
--------------
trunk/foray/foray-common/.classpath
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-pdf/.classpath
trunk/foray/foray-render/.classpath
Added Paths:
-----------
trunk/foray/lib-build/batik/
trunk/foray/lib-build/batik/batik-1.6-sources.zip
Modified: trunk/foray/foray-common/.classpath
===================================================================
--- trunk/foray/foray-common/.classpath 2007-06-10 03:18:35 UTC (rev 9742)
+++ trunk/foray/foray-common/.classpath 2007-06-10 03:36:21 UTC (rev 9743)
@@ -5,6 +5,6 @@
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-06-10 03:18:35 UTC (rev 9742)
+++ trunk/foray/foray-graphic/.classpath 2007-06-10 03:36:21 UTC (rev 9743)
@@ -11,14 +11,14 @@
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-parser.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-transcoder.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-svg-dom.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-dom.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-xml.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-parser.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-transcoder.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-svg-dom.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-dom.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-xml.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-pdf/.classpath
===================================================================
--- trunk/foray/foray-pdf/.classpath 2007-06-10 03:18:35 UTC (rev 9742)
+++ trunk/foray/foray-pdf/.classpath 2007-06-10 03:36:21 UTC (rev 9743)
@@ -11,15 +11,15 @@
<classpathentry kind="src" path="/axslPDF-W"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-svg-dom.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-dom.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-css.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-transcoder.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-ext.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-svg-dom.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-dom.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-css.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-transcoder.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-ext.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-render/.classpath
===================================================================
--- trunk/foray/foray-render/.classpath 2007-06-10 03:18:35 UTC (rev 9742)
+++ trunk/foray/foray-render/.classpath 2007-06-10 03:36:21 UTC (rev 9743)
@@ -17,10 +17,10 @@
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Added: trunk/foray/lib-build/batik/batik-1.6-sources.zip
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib-build/batik/batik-1.6-sources.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-10 04:22:39
|
Revision: 9744
http://svn.sourceforge.net/foray/?rev=9744&view=rev
Author: victormote
Date: 2007-06-09 21:22:38 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Add SVG java binding source code to dev lib, and add Eclipse links.
Modified Paths:
--------------
trunk/foray/foray-areatree/.classpath
trunk/foray/foray-fotree/.classpath
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-pdf/.classpath
trunk/foray/foray-render/.classpath
Added Paths:
-----------
trunk/foray/lib-build/svg/
trunk/foray/lib-build/svg/svg-1.1-src.zip
Modified: trunk/foray/foray-areatree/.classpath
===================================================================
--- trunk/foray/foray-areatree/.classpath 2007-06-10 03:36:21 UTC (rev 9743)
+++ trunk/foray/foray-areatree/.classpath 2007-06-10 04:22:38 UTC (rev 9744)
@@ -13,6 +13,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslArea-W"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-fotree/.classpath
===================================================================
--- trunk/foray/foray-fotree/.classpath 2007-06-10 03:36:21 UTC (rev 9743)
+++ trunk/foray/foray-fotree/.classpath 2007-06-10 04:22:38 UTC (rev 9744)
@@ -11,6 +11,6 @@
<classpathentry kind="src" path="/axslText"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-06-10 03:36:21 UTC (rev 9743)
+++ trunk/foray/foray-graphic/.classpath 2007-06-10 04:22:38 UTC (rev 9744)
@@ -10,7 +10,7 @@
<classpathentry kind="lib" path="/FOray Lib/xmlgraphics-commons-1.1.jar" sourcepath="/FOray Lib-Build/xmlgraphics-commons/xmlgraphics-commons-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-parser.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
Modified: trunk/foray/foray-pdf/.classpath
===================================================================
--- trunk/foray/foray-pdf/.classpath 2007-06-10 03:36:21 UTC (rev 9743)
+++ trunk/foray/foray-pdf/.classpath 2007-06-10 04:22:38 UTC (rev 9744)
@@ -10,7 +10,7 @@
<classpathentry kind="src" path="/FOrayPS"/>
<classpathentry kind="src" path="/axslPDF-W"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
Modified: trunk/foray/foray-render/.classpath
===================================================================
--- trunk/foray/foray-render/.classpath 2007-06-10 03:36:21 UTC (rev 9743)
+++ trunk/foray/foray-render/.classpath 2007-06-10 04:22:38 UTC (rev 9744)
@@ -16,7 +16,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar"/>
+ <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
Added: trunk/foray/lib-build/svg/svg-1.1-src.zip
===================================================================
(Binary files differ)
Property changes on: trunk/foray/lib-build/svg/svg-1.1-src.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-11 19:17:40
|
Revision: 9748
http://svn.sourceforge.net/foray/?rev=9748&view=rev
Author: victormote
Date: 2007-06-11 12:17:42 -0700 (Mon, 11 Jun 2007)
Log Message:
-----------
1. Add basic implementation of new axsl interface GraphicLink.
2. Stub-in conformance to new axsl changes requiring SVGGraphic to write its content to PostScript and PDF documents.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
trunk/foray/foray-render/src/java/org/foray/render/TempImage.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicLink4a.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java 2007-06-11 15:37:29 UTC (rev 9747)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphic.java 2007-06-11 19:17:42 UTC (rev 9748)
@@ -61,6 +61,9 @@
/** The bit depth (bits per pixel) for a typical 3-channel color image. */
public static final byte BIT_DEPTH_COLOR = 24;
+ /** An empty array of links to be used as the default. */
+ private static final GraphicLink4a[] DEFAULT_LINKS = new GraphicLink4a[0];
+
/**
* The default maximimum number of bytes that need to be read in order to
* extract the basic information from a file.
@@ -117,6 +120,9 @@
/** Set this flag to false if the image is not valid. */
private boolean isValid = true;
+ /** The links associated with this image. */
+ private GraphicLink4a[] links;
+
/**
* Constructor.
* @param server The parent graphic server.
@@ -578,4 +584,23 @@
this.basicsParsed = basicsParsed;
}
+ /**
+ * Returns the links associated with this graphic.
+ * @return The links associated with this graphic.
+ */
+ public GraphicLink4a[] getLinks() {
+ if (this.links == null) {
+ return DEFAULT_LINKS;
+ }
+ return this.links;
+ }
+
+ /**
+ * Sets the links for this graphic.
+ * @param links The new array of links for this graphic.
+ */
+ protected void setLinks(final GraphicLink4a[] links) {
+ this.links = links;
+ }
+
}
Added: trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicLink4a.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicLink4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicLink4a.java 2007-06-11 19:17:42 UTC (rev 9748)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic;
+
+import org.axsl.graphicR.GraphicLink;
+
+import java.awt.Shape;
+import java.net.URI;
+
+/**
+ * The FOray implementation of the {@link GraphicLink} interface.
+ */
+public class GraphicLink4a implements GraphicLink {
+
+ /** The URI for this link. */
+ private URI uri;
+
+ /** The Shape for this link. */
+ private Shape shape;
+
+ /**
+ * Constructor.
+ * @param uri The URI for this link.
+ * @param shape The Shape for this link.
+ */
+ public GraphicLink4a(final URI uri, final Shape shape) {
+ this.uri = uri;
+ this.shape = shape;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public URI getUri() {
+ return uri;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Shape getShape() {
+ return shape;
+ }
+
+}
Property changes on: trunk/foray/foray-graphic/src/java/org/foray/graphic/GraphicLink4a.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-11 15:37:29 UTC (rev 9747)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-11 19:17:42 UTC (rev 9748)
@@ -52,6 +52,7 @@
import java.awt.geom.Rectangle2D;
import java.io.BufferedInputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.URL;
/**
@@ -291,4 +292,21 @@
return new BridgeContext(userAgent);
}
+ /**
+ * {@inheritDoc}
+ */
+ public void drawPS(final OutputStream output, final boolean commentsEnabled,
+ final int x, final int y) {
+ /* TODO: Implement this. */
+ return;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void drawPdfStreamContent(final OutputStream output) {
+ /* TODO: Implement this. */
+ return;
+ }
+
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/TempImage.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/TempImage.java 2007-06-11 15:37:29 UTC (rev 9747)
+++ trunk/foray/foray-render/src/java/org/foray/render/TempImage.java 2007-06-11 19:17:42 UTC (rev 9748)
@@ -32,6 +32,7 @@
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicException;
+import org.axsl.graphicR.GraphicLink;
import java.awt.Color;
import java.awt.color.ColorSpace;
@@ -43,6 +44,9 @@
*/
public class TempImage implements Graphic {
+ /** An array of empty link to be used as a default. */
+ private static final GraphicLink[] EMPTY_LINKS = new GraphicLink[0];
+
/** The image height, in millipoints. */
private int height;
@@ -203,4 +207,11 @@
return null;
}
+ /**
+ * {@inheritDoc}
+ */
+ public GraphicLink[] getLinks() {
+ return EMPTY_LINKS;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-11 20:17:33
|
Revision: 9749
http://svn.sourceforge.net/foray/?rev=9749&view=rev
Author: victormote
Date: 2007-06-11 13:17:34 -0700 (Mon, 11 Jun 2007)
Log Message:
-----------
1. Change default SVG text handling to use the fonts.
2. Clean up some bugs related to SVG text rendering.
Modified Paths:
--------------
trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFTextPainter.java
Modified: trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java
===================================================================
--- trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java 2007-06-11 19:17:42 UTC (rev 9748)
+++ trunk/foray/foray-core/src/java/org/foray/core/SessionConfig.java 2007-06-11 20:17:34 UTC (rev 9749)
@@ -74,7 +74,7 @@
// Skip font-configuration as it can be null.
// Skip hyphenation-base-directory as it is tied to base-directory.
put("language", "en", PRECEDENCE_DEFAULT);
- put("stroke-svg-text", Boolean.TRUE, PRECEDENCE_DEFAULT);
+ put("stroke-svg-text", Boolean.FALSE, PRECEDENCE_DEFAULT);
put("verbosity", "normal", PRECEDENCE_DEFAULT);
put("xml-catalog", null, PRECEDENCE_DEFAULT);
put("mode", "render", PRECEDENCE_DEFAULT);
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-11 19:17:42 UTC (rev 9748)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-11 20:17:34 UTC (rev 9749)
@@ -324,12 +324,6 @@
final FontConsumer fontConsumer,
final boolean strokeSVGText) {
closeTextObject();
- final PDFGraphics2D graphics = getPDFContent4SVG(contentRectangle,
- fontConsumer, doc, strokeSVGText);
- if (graphics == null) {
- // Error messages have already been logged.
- return;
- }
add("q" + EOL);
if (contentRectangle.width != 0 && contentRectangle.height != 0) {
@@ -347,11 +341,20 @@
add("W" + EOL);
add("n" + EOL);
}
- add(graphics.getString());
- add("Q" + EOL);
+
+ final PDFGraphics2D graphics = getPDFContent4SVG(contentRectangle,
+ fontConsumer, doc, strokeSVGText);
+ if (graphics == null) {
+ // Error messages have already been logged.
+ return;
+ }
+ final String svgString = graphics.getString();
+ add(svgString);
// Add annotation accumulated to the list for the current page.
this.page.addAnnotationList(graphics.getAnnotList());
+
+ add("Q" + EOL);
}
/**
@@ -422,14 +425,7 @@
ctx.putBridge(aBridge);
GraphicsNode root;
- try {
- root = builder.build(ctx, svgDocument);
- } catch (final Exception e) {
- getLogger().error("svg graphic could not be built: "
- + e.getMessage());
- getLogger().error(e.getMessage());
- return null;
- }
+ root = builder.build(ctx, svgDocument);
ctx = null;
builder = null;
@@ -438,13 +434,7 @@
contentRectangle, svgDocument, fontConsumer);
graphics.setGraphicContext(new GraphicContext());
- try {
- root.paint(graphics);
- } catch (final Exception e) {
- getLogger().error("svg graphic could not be rendered: "
- + e.getMessage());
- getLogger().error(e.getMessage());
- }
+ root.paint(graphics);
return graphics;
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFTextPainter.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFTextPainter.java 2007-06-11 19:17:42 UTC (rev 9748)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFTextPainter.java 2007-06-11 20:17:34 UTC (rev 9749)
@@ -91,6 +91,7 @@
*/
public PDFTextPainter(final Log logger, final FontConsumer consumer) {
this.logger = logger;
+ this.fontConsumer = consumer;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-12 16:15:06
|
Revision: 9753
http://svn.sourceforge.net/foray/?rev=9753&view=rev
Author: victormote
Date: 2007-06-12 09:15:07 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
Conform to axsl changes to PDFContentStream method.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
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-12 01:59:17 UTC (rev 9752)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-12 16:15:07 UTC (rev 9753)
@@ -318,7 +318,7 @@
/**
* {@inheritDoc}
*/
- public void drawSVGDocument(final SVGDocument doc,
+ public void drawSVGDocument(final SVGGraphic svg,
final Rectangle2D.Float contentRectangle,
final Rectangle2D.Float clipRectangle,
final FontConsumer fontConsumer,
@@ -342,7 +342,14 @@
add("n" + EOL);
}
-
+ SVGDocument doc = null;
+ try {
+ doc = svg.getSVGDocument();
+ } catch (final GraphicException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return;
+ }
final PDFGraphics2D graphics = getPDFContent4SVG(contentRectangle,
fontConsumer, doc, strokeSVGText);
if (graphics == null) {
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-12 01:59:17 UTC (rev 9752)
+++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-06-12 16:15:07 UTC (rev 9753)
@@ -54,7 +54,6 @@
import org.axsl.fontR.Font;
import org.axsl.fontR.FontUse;
import org.axsl.graphicR.Graphic;
-import org.axsl.graphicR.GraphicException;
import org.axsl.graphicR.SVGGraphic;
import org.axsl.pdfW.PDFColor;
import org.axsl.pdfW.PDFContentStream;
@@ -71,8 +70,6 @@
import org.apache.commons.logging.Log;
-import org.w3c.dom.svg.SVGDocument;
-
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.geom.Line2D;
@@ -256,15 +253,7 @@
convertMillipointRectangle(contentRectangle);
final Rectangle2D.Float pdfClipRectangle = convertMillipointRectangle(
clipRectangle);
- SVGDocument svgDocument;
- try {
- svgDocument = graphic.getSVGDocument();
- } catch (final GraphicException e) {
- /* For some reason the SVGDocument is not usable. There is nothing
- * to do. */
- return;
- }
- getContentStream().drawSVGDocument(svgDocument, pdfContentRectangle,
+ getContentStream().drawSVGDocument(graphic, pdfContentRectangle,
pdfClipRectangle, area.getFontConsumer(), getStrokeSVGText());
}
@@ -291,15 +280,7 @@
toPoints(area.crOriginX()), toPoints(area.crOriginY()),
toPoints(area.crIPD()), toPoints(area.crBPD()));
final SVGGraphic svgGraphic = area.getSVGGraphic();
- SVGDocument svgDocument = null;
- try {
- svgDocument = svgGraphic.getSVGDocument();
- } catch (final GraphicException e) {
- this.getLogger().error("Error getting SVGDocument in "
- + this.getClass().getName());
- return;
- }
- getContentStream().drawSVGDocument(svgDocument,
+ getContentStream().drawSVGDocument(svgGraphic,
contentRectangle, null, this.getFontConsumer(),
getStrokeSVGText());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-13 00:29:45
|
Revision: 9765
http://svn.sourceforge.net/foray/?rev=9765&view=rev
Author: victormote
Date: 2007-06-12 17:29:47 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
Move the code converting SVG to PostScript from the Renderer module to Graphics.
Modified Paths:
--------------
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GIFFactory.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GraphicFactory.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PDFFactory.java
trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/java/org/foray/graphic/TempImage.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PSGraphics2D.java
Removed Paths:
-------------
trunk/foray/foray-render/src/java/org/foray/render/TempImage.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-06-13 00:06:39 UTC (rev 9764)
+++ trunk/foray/foray-graphic/.classpath 2007-06-13 00:29:47 UTC (rev 9765)
@@ -21,5 +21,6 @@
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-dom.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-xml.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslFont-R"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/FOrayPS"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-13 00:06:39 UTC (rev 9764)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-13 00:29:47 UTC (rev 9765)
@@ -28,7 +28,11 @@
package org.foray.graphic;
+import org.foray.common.CharacterOutputStream;
+import org.foray.common.SVGUserAgent;
+import org.foray.common.WKConstants;
import org.foray.graphic.batik.BatikUaAwt;
+import org.foray.graphic.batik.PSGraphics2D;
import org.axsl.fontR.FontConsumer;
import org.axsl.graphicR.Graphic;
@@ -42,6 +46,7 @@
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.dom.svg.SVGOMDocument;
import org.apache.batik.gvt.GraphicsNode;
+import org.apache.xmlgraphics.java2d.GraphicContext;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;
@@ -300,11 +305,105 @@
public void drawPS(final OutputStream output, final Point2D location,
final FontConsumer fontConsumer, final boolean strokeText,
final boolean commentsEnabled) {
- /* TODO: Implement this. */
- return;
+ final CharacterOutputStream cos = new CharacterOutputStream(output,
+ commentsEnabled);
+ final double x = location.getX();
+ final double y = location.getY();
+ SVGDocument doc = null;
+ try {
+ doc = this.getSVGDocument();
+ } catch (final GraphicException e) {
+ this.getLogger().error("Error getting SVGDocument in "
+ + this.getClass().getName());
+ return;
+ }
+ BridgeContext ctx = makeBridgeContext();
+ GVTBuilder builder = new GVTBuilder();
+
+ GraphicsNode root;
+ try {
+ root = builder.build(ctx, doc);
+ } catch (final Exception e) {
+ getLogger().error("svg graphic could not be built: "
+ + e.getMessage());
+ getLogger().error(e.getMessage());
+ return;
+ }
+ // get the 'width' and 'height' attributes of the SVG document
+ float w = (float) ctx.getDocumentSize().getWidth();
+ float h = (float) ctx.getDocumentSize().getHeight();
+
+ //log.debug("drawing SVG image: "+x+"/"+y+" "+w+"/"+h);
+ final SVGSVGElement svg = doc.getRootElement();
+ final AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
+ w, h);
+
+ w *= WKConstants.MILLIPOINTS_PER_POINT;
+ h *= WKConstants.MILLIPOINTS_PER_POINT;
+
+ ctx = null;
+ builder = null;
+
+ final float sx = 1;
+ final float sy = -1;
+ final int xOffset = (int) Math.round(x);
+ final int yOffset = (int) Math.round(y);
+
+ try {
+ cos.comment("% --- SVG Area");
+ cos.write("gsave");
+ if (w != 0 && h != 0) {
+ cos.write("newpath");
+ cos.write(x + " " + y + " M");
+ cos.write((x + w) + " " + y + " rlineto");
+ cos.write((x + w) + " " + (y - h) + " rlineto");
+ cos.write(x + " " + (y - h) + " rlineto");
+ cos.write("closepath");
+ cos.write("clippath");
+ }
+ // transform so that the coordinates (0,0) is from the top left
+ // and positive is down and to the right. (0,0) is where the
+ // viewBox puts it.
+ cos.write(xOffset + " " + yOffset + " translate");
+ cos.write(
+ (at.getTranslateX() * WKConstants.MILLIPOINTS_PER_POINT)
+ + " "
+ + (-at.getTranslateY() * WKConstants.MILLIPOINTS_PER_POINT)
+ + " translate");
+ cos.write(sx * at.getScaleX() + " " + sy * at.getScaleY()
+ + " scale");
+
+ final PSGraphics2D graphics = new PSGraphics2D(false, cos);
+ graphics.setGraphicContext(new GraphicContext());
+ try {
+ root.paint(graphics);
+ } catch (final Exception e) {
+ getLogger().error("svg graphic could not be rendered: "
+ + e.getMessage());
+ getLogger().error(e.getMessage());
+ }
+
+ cos.write("grestore");
+
+ cos.comment("% --- SVG Area end");
+ } catch (final IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
/**
+ * Creates a BridgeContext instance for use by Batik when rendering an SVG
+ * graphic.
+ * @return A Batik BridgeContext instance.
+ */
+ public BridgeContext makeBridgeContext() {
+ final SVGUserAgent userAgent = new SVGUserAgent(new AffineTransform());
+ userAgent.setLogger(getLogger());
+ return new BridgeContext(userAgent);
+ }
+
+ /**
* {@inheritDoc}
*/
public void drawPdfStreamContent(final OutputStream output,
Copied: trunk/foray/foray-graphic/src/java/org/foray/graphic/TempImage.java (from rev 9748, trunk/foray/foray-render/src/java/org/foray/render/TempImage.java)
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/TempImage.java (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/TempImage.java 2007-06-13 00:29:47 UTC (rev 9765)
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic;
+
+import org.foray.common.WKConstants;
+
+import org.axsl.graphicR.Graphic;
+import org.axsl.graphicR.GraphicException;
+import org.axsl.graphicR.GraphicLink;
+
+import java.awt.Color;
+import java.awt.color.ColorSpace;
+import java.net.URL;
+
+/**
+ * An implementation of the axsl Graphic interface that provides the ability
+ * to create a pseudo-graphic that can be used by Renderers.
+ */
+public class TempImage implements Graphic {
+
+ /** An array of empty link to be used as a default. */
+ private static final GraphicLink[] EMPTY_LINKS = new GraphicLink[0];
+
+ /** The image height, in millipoints. */
+ private int height;
+
+ /** The image width, in millipoints. */
+ private int width;
+
+ /** The image color space. */
+ private ColorSpace colorSpace;
+
+ /** The bitmap data for the image. */
+ private byte[] bitmaps;
+
+ /** The transparent color. */
+ private Color transparent = Color.white;
+
+ /** The image's URL. */
+ private URL url;
+
+ /**
+ * Constructor.
+ * @param url The image's URL.
+ * @param width The image width, in millipoints.
+ * @param height The image height, in millipoints.
+ * @param result The bitmap data for the image.
+ */
+ public TempImage(final URL url, final int width, final int height,
+ final byte[] result) {
+ this.url = url;
+ this.height = height;
+ this.width = width;
+ this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+ this.bitmaps = result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isInverted() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public URL getURL() {
+ return url;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int pixelWidth() throws GraphicException {
+ return width;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int pixelHeight() throws GraphicException {
+ return height;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ColorSpace getColorSpace() throws GraphicException {
+ return colorSpace;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getBitsPerComponent() throws GraphicException {
+ /* This is a bogus value, intended only to satisfy the interface. */
+ return WKConstants.BITS_PER_BYTE;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTransparent() throws GraphicException {
+ return transparent != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Color getTransparentColor() throws GraphicException {
+ return transparent;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getContent() throws GraphicException {
+ return bitmaps;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getContentSize() throws GraphicException {
+ return width * height
+ * ColorSpace.getInstance(ColorSpace.CS_sRGB).getNumComponents();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void close() { }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Graphic.Type getGraphicType() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Graphic.Compression getCompressionType() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getMimeType() {
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int absoluteWidth(final int pixelsPerInch) throws GraphicException {
+ return -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int absoluteHeight(final int pixelsPerInch) throws GraphicException {
+ return -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getRawSamples() throws GraphicException {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public GraphicLink[] getLinks() {
+ return EMPTY_LINKS;
+ }
+
+}
Copied: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PSGraphics2D.java (from rev 9764, trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java)
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PSGraphics2D.java (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PSGraphics2D.java 2007-06-13 00:29:47 UTC (rev 9765)
@@ -0,0 +1,760 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+/*
+ * Known contributors:
+ * Original author: <a href="mailto:ke...@af...">Keiron Liddle</a>
+ */
+
+package org.foray.graphic.batik;
+
+import org.foray.common.CharacterOutputStream;
+import org.foray.common.WKConstants;
+import org.foray.graphic.TempImage;
+import org.foray.ps.PSColor;
+import org.foray.ps.PSMatrix;
+import org.foray.ps.PSReal;
+
+import org.axsl.graphicR.Graphic;
+
+import org.apache.xmlgraphics.java2d.AbstractGraphics2D;
+import org.apache.xmlgraphics.java2d.GraphicContext;
+
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.TexturePaint;
+import java.awt.color.ColorSpace;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+import java.awt.image.ImageObserver;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+import java.io.IOException;
+import java.text.AttributedCharacterIterator;
+import java.text.CharacterIterator;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Implementation of <tt>AbstractGraphics2D</tt> suitable for integration with
+ * Batik for purposes of converting SVG to PostScript.
+ */
+public class PSGraphics2D extends AbstractGraphics2D {
+
+ /** Constant indicating the number of components needed to describe a
+ * line. */
+ private static final int QTY_LINE_COMPONENTS = 2;
+
+ /** Constant indicating the number of components needed to describe a
+ * cube. */
+ private static final int QTY_CUBIC_COMPONENTS = 6;
+
+ /** The output stream to which we are writing. */
+ private CharacterOutputStream out;
+
+ /** Used to create proper font metrics. */
+ private Graphics2D fmg;
+ {
+ final BufferedImage bi = new BufferedImage(1, 1,
+ BufferedImage.TYPE_INT_ARGB);
+ this.fmg = bi.createGraphics();
+ }
+
+ /**
+ * Create a new PDFGraphics2D with the given pdf document info.
+ * This is used to create a Graphics object for use inside an already
+ * existing document.
+ * @param textAsShapes Indicates whether text should be treated as text
+ * (false), or whether it should be converted to its paths (true).
+ * @param out The output stream to which the content should be written.
+ */
+ public PSGraphics2D(final boolean textAsShapes,
+ final CharacterOutputStream out) {
+ super(textAsShapes);
+ this.out = out;
+ }
+
+ /**
+ * Constructor supporting the {@link #create()} method.
+ * @param g The wrapped graphic.
+ */
+ public PSGraphics2D(final PSGraphics2D g) {
+ super(g);
+ }
+
+ /**
+ * Sets the graphic context.
+ * @param c The new graphic context.
+ */
+ public void setGraphicContext(final GraphicContext c) {
+ gc = c;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Graphics create() {
+ return new PSGraphics2D(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean drawImage(final Image img, final int x, final int y,
+ final ImageObserver observer) {
+ final int width = img.getWidth(observer);
+ final int height = img.getHeight(observer);
+ if (width == -1 || height == -1) {
+ return false;
+ }
+ final Dimension size = new Dimension(width, height);
+ final BufferedImage buf = new BufferedImage(size.width, size.height,
+ BufferedImage.TYPE_INT_ARGB);
+ final int colorComponents = ColorSpace.getInstance(ColorSpace.CS_sRGB)
+ .getNumComponents();
+
+ final 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, width, height);
+ g.clip(new Rectangle(0, 0, buf.getWidth(), buf.getHeight()));
+
+ if (!g.drawImage(img, 0, 0, observer)) {
+ return false;
+ }
+ g.dispose();
+
+ final byte[] result = new byte[buf.getWidth() * buf.getHeight()
+ * colorComponents];
+
+ final Raster raster = buf.getData();
+ final DataBuffer bd = raster.getDataBuffer();
+
+ int count = 0;
+ switch (bd.getDataType()) {
+ case DataBuffer.TYPE_INT:
+ final int[][] idata = ((DataBufferInt) bd).getBankData();
+ for (int i = 0; i < idata.length; i++) {
+ for (int j = 0; j < idata[i].length; j++) {
+ // mask[maskpos++] = (byte)((idata[i][j] >> 24) & 0xFF);
+ if (((idata[i][j] >> WKConstants.SHIFT_3_BYTES)
+ & WKConstants.MAX_8_BIT_UNSIGNED_BYTE)
+ != WKConstants.MAX_8_BIT_UNSIGNED_INT) {
+ result[count++] = WKConstants.MAX_8_BIT_UNSIGNED_BYTE;
+ result[count++] = WKConstants.MAX_8_BIT_UNSIGNED_BYTE;
+ result[count++] = WKConstants.MAX_8_BIT_UNSIGNED_BYTE;
+ } else {
+ result[count++] = (byte) ((idata[i][j]
+ >> WKConstants.SHIFT_2_BYTES)
+ & WKConstants.MAX_8_BIT_UNSIGNED_BYTE);
+ result[count++] = (byte) ((idata[i][j]
+ >> WKConstants.SHIFT_1_BYTE)
+ & WKConstants.MAX_8_BIT_UNSIGNED_BYTE);
+ result[count++] = (byte) ((idata[i][j])
+ & WKConstants.MAX_8_BIT_UNSIGNED_BYTE);
+ }
+ }
+ }
+ break;
+ default:
+ // error
+ break;
+ }
+
+ try {
+ final Graphic graphic = new TempImage(null, width, height, result);
+ final AffineTransform at = getTransform();
+ final double[] matrix = new double[PSMatrix.QTY_ELEMENTS];
+ at.getMatrix(matrix);
+ this.out.write("gsave");
+ final Shape imclip = getClip();
+ writeClip(imclip);
+ this.out.write("1000 -1000 scale");
+ // psRenderer.write("" + matrix[0] + " " + matrix[1] +
+ // " " + matrix[2] + " " + matrix[3] + " " +
+ // matrix[4] + " " + matrix[5] + " cm\n");
+
+ /* TODO: The following line is commented out to avoid having this
+ * class dependent on the PostScript renderer. After this is all
+ * moved to the Graphics package, this needs to be reworked.
+ * The "graphic" needs to be a real Graphic instance of the proper
+ * type, and should then be converted to PostScript here. */
+ graphic.close();
+// this.psRenderer.renderBitmap(graphic, x, -y, width, height);
+ this.out.write("grestore");
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean drawImage(final Image img, final int x, final int y,
+ final int width, final int height, final ImageObserver observer) {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ this.out = null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void draw(final Shape s) {
+ try {
+ this.out.write("gsave");
+ final Shape imclip = getClip();
+ writeClip(imclip);
+ final Color c = getColor();
+ this.out.write(c.getRed() + " " + c.getGreen() + " "
+ + c.getBlue() + " setrgbcolor");
+
+ applyPaint(getPaint(), false);
+ applyStroke(getStroke());
+
+ this.out.write("newpath");
+ final PathIterator iter = s.getPathIterator(getTransform());
+ while (!iter.isDone()) {
+ final double vals[] = new double[PSMatrix.QTY_ELEMENTS];
+ final int type = iter.currentSegment(vals);
+ String matrixString = null;
+ switch (type) {
+ case PathIterator.SEG_CUBICTO:
+ matrixString = matrixToString(vals, QTY_CUBIC_COMPONENTS);
+ this.out.write(matrixString + "curveto");
+ break;
+ case PathIterator.SEG_LINETO:
+ matrixString = matrixToString(vals, QTY_LINE_COMPONENTS);
+ this.out.write(matrixString + "lineto");
+ break;
+ case PathIterator.SEG_MOVETO:
+ matrixString = matrixToString(vals, QTY_LINE_COMPONENTS);
+ this.out.write(matrixString + "M");
+ break;
+ case PathIterator.SEG_QUADTO:
+ // psRenderer.write((1000 * PDFNumber.doubleOut(vals[0])) +
+ // " " + (1000 * PDFNumber.doubleOut(vals[1])) + " " +
+ // (1000 * PDFNumber.doubleOut(vals[2])) + " " +
+ // (1000 * PDFNumber.doubleOut(vals[3])) + " y\n");
+ break;
+ case PathIterator.SEG_CLOSE:
+ this.out.write("closepath");
+ break;
+ default:
+ break;
+ }
+ iter.next();
+ }
+ doDrawing(false, true, false);
+ this.out.write("grestore");
+ } catch (final IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Creates a String representation of a given matrix.
+ * @param matrix The matrix to be converted to a String.
+ * @param qtyElements The number of elements active in the matrix.
+ * @return The String representation of the matrix.
+ */
+ private String matrixToString(final double[] matrix,
+ final int qtyElements) {
+ final StringBuilder buffer = new StringBuilder();
+ for (int i = 0; i < qtyElements; i++) {
+ buffer.append(PSReal.doubleOut(
+ WKConstants.MILLIPOINTS_PER_POINT * matrix[i])
+ + " ");
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Creates code to clip along a given shape.
+ * @param s The shape upon which the clip should be created.
+ * @throws IOException For I/O errors writing the content.
+ */
+ protected void writeClip(final Shape s) throws IOException {
+ final PathIterator iter = s.getPathIterator(getTransform());
+ this.out.write("newpath");
+ while (!iter.isDone()) {
+ final double vals[] = new double[PSMatrix.QTY_ELEMENTS];
+ final int type = iter.currentSegment(vals);
+ String matrixString = null;
+ switch (type) {
+ case PathIterator.SEG_CUBICTO:
+ matrixString = matrixToString(vals, QTY_CUBIC_COMPONENTS);
+ this.out.write(matrixString + "curveto");
+ break;
+ case PathIterator.SEG_LINETO:
+ matrixString = matrixToString(vals, QTY_LINE_COMPONENTS);
+ this.out.write(matrixString + "lineto");
+ break;
+ case PathIterator.SEG_MOVETO:
+ matrixString = matrixToString(vals, QTY_LINE_COMPONENTS);
+ this.out.write(matrixString + "M");
+ break;
+ case PathIterator.SEG_QUADTO:
+ // psRenderer.write(1000 * PDFNumber.doubleOut(vals[0]) +
+ // " " + 1000 * PDFNumber.doubleOut(vals[1]) + " " +
+ // 1000 * PDFNumber.doubleOut(vals[2]) + " " +
+ // 1000 * PDFNumber.doubleOut(vals[3]) + " y\n");
+ break;
+ case PathIterator.SEG_CLOSE:
+ this.out.write("closepath");
+ break;
+ default:
+ break;
+ }
+ iter.next();
+ }
+ // clip area
+ this.out.write("clippath");
+ }
+
+ /**
+ * Apply the paint to this graphic.
+ * @param paint The paint to use.
+ * @param fill Indicates whether the paint is for fill (true) or stroke
+ * (false).
+ */
+ protected void applyPaint(final Paint paint, final boolean fill) {
+ if (paint instanceof GradientPaint) {
+ final GradientPaint gp = (GradientPaint) paint;
+ final Color c1 = gp.getColor1();
+ final Color c2 = gp.getColor2();
+ final Point2D p1 = gp.getPoint1();
+ final Point2D p2 = gp.getPoint2();
+
+ final List<Double> theCoords = new ArrayList<Double>();
+ theCoords.add(new Double(p1.getX()));
+ theCoords.add(new Double(p1.getY()));
+ theCoords.add(new Double(p2.getX()));
+ theCoords.add(new Double(p2.getY()));
+
+ final List<Boolean> theExtend = new ArrayList<Boolean>();
+ theExtend.add(new Boolean(true));
+ theExtend.add(new Boolean(true));
+
+ final List<Double> theDomain = new ArrayList<Double>();
+ theDomain.add(new Double(0));
+ theDomain.add(new Double(1));
+
+ final List<Double> theEncode = new ArrayList<Double>();
+ theEncode.add(new Double(0));
+ theEncode.add(new Double(1));
+ theEncode.add(new Double(0));
+ theEncode.add(new Double(1));
+
+ final List<Double> theBounds = new ArrayList<Double>();
+ theBounds.add(new Double(0));
+ theBounds.add(new Double(1));
+
+ final List<Color> someColors = new ArrayList<Color>();
+
+ someColors.add(c1);
+ someColors.add(c2);
+
+ } else if (paint instanceof TexturePaint) { }
+ }
+
+ /**
+ * Draw the graphic using a specified Stroke.
+ * @param stroke The stroke to use for drawing.
+ * @throws IOException For I/O errors writing the content.
+ */
+ protected void applyStroke(final Stroke stroke) throws IOException {
+ if (stroke instanceof BasicStroke) {
+ final BasicStroke bs = (BasicStroke) stroke;
+
+ final float[] da = bs.getDashArray();
+ if (da != null) {
+ this.out.write("[");
+ for (int count = 0; count < da.length; count++) {
+ this.out.write(""
+ + (WKConstants.MILLIPOINTS_PER_POINT
+ * (int) da[count]));
+ if (count < da.length - 1) {
+ this.out.write(" ");
+ }
+ }
+ this.out.write("] ");
+ final float offset = bs.getDashPhase();
+ this.out.write((WKConstants.MILLIPOINTS_PER_POINT
+ * (int) offset) + " setdash");
+ }
+ final int ec = bs.getEndCap();
+ switch (ec) {
+ case BasicStroke.CAP_BUTT:
+ this.out.write(0 + " setlinecap");
+ break;
+ case BasicStroke.CAP_ROUND:
+ this.out.write(1 + " setlinecap");
+ break;
+ case BasicStroke.CAP_SQUARE:
+ this.out.write(2 + " setlinecap");
+ break;
+ }
+
+ final int lj = bs.getLineJoin();
+ switch (lj) {
+ case BasicStroke.JOIN_MITER:
+ this.out.write(0 + " setlinejoin");
+ break;
+ case BasicStroke.JOIN_ROUND:
+ this.out.write(1 + " setlinejoin");
+ break;
+ case BasicStroke.JOIN_BEVEL:
+ this.out.write(2 + " setlinejoin");
+ ...
[truncated message content] |
|
From: <vic...@us...> - 2007-06-13 01:01:14
|
Revision: 9766
http://svn.sourceforge.net/foray/?rev=9766&view=rev
Author: victormote
Date: 2007-06-12 18:01:12 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
1. Officially remove all Renderer dependencies on Batik.
2. Make Graphics package dependent on PostScript package.
Modified Paths:
--------------
trunk/foray/foray-graphic/scripts/build.xml
trunk/foray/foray-render/.classpath
trunk/foray/foray-render/scripts/build.xml
trunk/foray/scripts/build.xml
Modified: trunk/foray/foray-graphic/scripts/build.xml
===================================================================
--- trunk/foray/foray-graphic/scripts/build.xml 2007-06-13 00:29:47 UTC (rev 9765)
+++ trunk/foray/foray-graphic/scripts/build.xml 2007-06-13 01:01:12 UTC (rev 9766)
@@ -31,6 +31,9 @@
<fileset dir="${foray.sandbox}/foray-common/build/ant">
<include name="*.jar"/>
</fileset>
+ <fileset dir="${foray.sandbox}/foray-ps/build/ant">
+ <include name="*.jar"/>
+ </fileset>
</path>
</target>
Modified: trunk/foray/foray-render/.classpath
===================================================================
--- trunk/foray/foray-render/.classpath 2007-06-13 00:29:47 UTC (rev 9765)
+++ trunk/foray/foray-render/.classpath 2007-06-13 01:01:12 UTC (rev 9766)
@@ -17,10 +17,5 @@
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-render/scripts/build.xml
===================================================================
--- trunk/foray/foray-render/scripts/build.xml 2007-06-13 00:29:47 UTC (rev 9765)
+++ trunk/foray/foray-render/scripts/build.xml 2007-06-13 01:01:12 UTC (rev 9766)
@@ -31,8 +31,8 @@
</fileset>
<fileset dir="${lib.dir}">
<include name="axsl*.jar"/>
- <include name="batik*.jar"/>
<include name="commons-logging-*.jar"/>
+ <include name="svg-*.jar"/>
</fileset>
<fileset dir="${foray.sandbox}/foray-common/build/ant">
<include name="*.jar"/>
Modified: trunk/foray/scripts/build.xml
===================================================================
--- trunk/foray/scripts/build.xml 2007-06-13 00:29:47 UTC (rev 9765)
+++ trunk/foray/scripts/build.xml 2007-06-13 01:01:12 UTC (rev 9766)
@@ -653,7 +653,7 @@
<!-- =================================================================== -->
<!-- Build the Graphic module -->
<!-- =================================================================== -->
- <target name="graphic" depends="common"
+ <target name="graphic" depends="ps"
description="Compile the graphic module">
<property name="module.graphic" value=", graphic"/>
<ant antfile="${foray.sandbox}/foray-graphic/scripts/build.xml"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-13 01:58:10
|
Revision: 9767
http://svn.sourceforge.net/foray/?rev=9767&view=rev
Author: victormote
Date: 2007-06-12 18:58:06 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
1. Conform to axsl changes making some parameters more generic.
2. Change internals of PDF Graphics State to store the FOray implementation instead of an aXSL interface.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java
trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java 2007-06-13 01:01:12 UTC (rev 9766)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java 2007-06-13 01:58:06 UTC (rev 9767)
@@ -28,8 +28,9 @@
package org.foray.pdf;
-import org.axsl.pdfW.PDFColor;
-import org.axsl.pdfW.PDFFont;
+import org.foray.pdf.object.PDFColor;
+import org.foray.pdf.object.PDFFont;
+
import org.axsl.pdfW.PDFLineCapStyle;
import java.awt.Color;
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-13 01:01:12 UTC (rev 9766)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-13 01:58:06 UTC (rev 9767)
@@ -36,12 +36,11 @@
import org.foray.pdf.svg.batik.PDFTextPainter;
import org.axsl.fontR.FontConsumer;
+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.PDFColor;
-import org.axsl.pdfW.PDFFont;
import org.axsl.pdfW.PDFLineCapStyle;
import org.axsl.pdfW.PDFPathPaint;
@@ -54,6 +53,7 @@
import org.w3c.dom.svg.SVGDocument;
+import java.awt.Color;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
@@ -142,29 +142,32 @@
/**
* {@inheritDoc}
*/
- public void setFont(final PDFFont newFont, final float newFontSize) {
+ public void setFont(final FontUse newFont, final float newFontSize) {
+ final PDFFont pdfFont = this.getPDFDocument().getPDFFont(newFont);
openTextObject();
boolean anyChange = false;
- anyChange |= this.getGS().setFont(newFont);
+ anyChange |= this.getGS().setFont(pdfFont);
anyChange |= this.getGS().setFontSize(newFontSize);
if (! anyChange) {
// Nothing needs to change.
return;
}
- final String psStyleName = newFont.getName();
+ final String psStyleName = pdfFont.getName();
add("/" + psStyleName + " " + newFontSize + " Tf" + EOL);
}
/**
* {@inheritDoc}
*/
- public void setStrokeColor(final PDFColor newStrokeColor) {
- if (! this.getGS().setStrokeColor(newStrokeColor)) {
+ public void setStrokeColor(final Color newStrokeColor) {
+ final PDFColor newPDFColor = this.getPDFDocument().createPDFColor(
+ newStrokeColor);
+ if (! this.getGS().setStrokeColor(newPDFColor)) {
// Nothing needs to change.
return;
}
/* TODO: Why isn't the parameter on the next statement "false"?? */
- add(newStrokeColor.getSetterString(true));
+ add(newPDFColor.getSetterString(true));
}
/**
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2007-06-13 01:01:12 UTC (rev 9766)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2007-06-13 01:58:06 UTC (rev 9767)
@@ -40,7 +40,6 @@
import org.axsl.fontR.Font;
import org.axsl.fontR.FontUse;
-import org.axsl.pdfW.PDFColor;
import org.axsl.pdfW.PDFPage;
import org.axsl.pdfW.PDFVersion;
import org.axsl.psR.Encoding;
@@ -725,7 +724,7 @@
public PDFColor createPDFColor(final Color color) {
org.foray.pdf.object.PDFColor pdfColor = null;
for (int i = 0; i < this.usedColors.size(); i++) {
- pdfColor = (org.foray.pdf.object.PDFColor) this.usedColors.get(i);
+ pdfColor = this.usedColors.get(i);
if (pdfColor.getColor().equals(color)) {
return pdfColor;
}
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-13 01:01:12 UTC (rev 9766)
+++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-06-13 01:58:06 UTC (rev 9767)
@@ -60,7 +60,6 @@
import org.axsl.pdfW.PDFDocument;
import org.axsl.pdfW.PDFEncryption;
import org.axsl.pdfW.PDFExplicitDestination;
-import org.axsl.pdfW.PDFFont;
import org.axsl.pdfW.PDFLineCapStyle;
import org.axsl.pdfW.PDFOutlineItem;
import org.axsl.pdfW.PDFOutlineParent;
@@ -296,8 +295,7 @@
/* Set the color. */
final Color color = area.traitColor();
- final PDFColor areaColor = this.getPDFDocument().createPDFColor(color);
- getContentStream().setStrokeColor(areaColor);
+ getContentStream().setStrokeColor(color);
/* Set the word-spacing and letter-spacing. */
final float wordSpacing = toPoints(area.wordSpacing());
@@ -395,9 +393,7 @@
if (size < 1) {
return;
}
- PDFFont pdfFont;
- pdfFont = this.pdfDoc.getPDFFont(fontUse);
- getContentStream().setFont(pdfFont, toPoints(area.traitFontSize()));
+ getContentStream().setFont(fontUse, toPoints(area.traitFontSize()));
/* Paint the text. */
final String textToWrite = new String(text, startIndex, size);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-13 14:50:09
|
Revision: 9768
http://svn.sourceforge.net/foray/?rev=9768&view=rev
Author: victormote
Date: 2007-06-13 07:50:11 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
Conform to axsl changes providing a way for the PDF system to inform the graphic system about font names.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-13 01:58:06 UTC (rev 9767)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-13 14:50:11 UTC (rev 9768)
@@ -37,6 +37,7 @@
import org.axsl.fontR.FontConsumer;
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicException;
+import org.axsl.graphicR.GraphicPdfContext;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
@@ -407,8 +408,8 @@
* {@inheritDoc}
*/
public void drawPdfStreamContent(final OutputStream output,
- final Point2D location, final FontConsumer fontConsumer,
- final boolean strokeText) {
+ final Point2D location, final GraphicPdfContext pdfContext,
+ final FontConsumer fontConsumer, final boolean strokeText) {
/* TODO: Implement this. */
return;
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2007-06-13 01:58:06 UTC (rev 9767)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2007-06-13 14:50:11 UTC (rev 9768)
@@ -71,7 +71,8 @@
* keep track of the character position of each object. The document
* also keeps direct track of the /Root, /Info and /Resources objects.
*/
-public class PDFDocument implements org.axsl.pdfW.PDFDocument {
+public class PDFDocument implements org.axsl.pdfW.PDFDocument,
+ org.axsl.graphicR.GraphicPdfContext {
/** Name of the CharSet that should be used when converting Strings to
* bytes. */
@@ -752,4 +753,12 @@
return DEFAULT_CHARACTERS_PER_LINE;
}
+ /**
+ * {@inheritDoc}
+ */
+ public String getFontName(final FontUse fontUse) {
+ final PDFFont pdfFont = this.getPDFFont(fontUse);
+ return pdfFont.getName();
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-13 15:35:41
|
Revision: 9769
http://svn.sourceforge.net/foray/?rev=9769&view=rev
Author: victormote
Date: 2007-06-13 08:35:40 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
1. Conform to axsl changes regarding passing rectangles instead of points for the PS and PDF rendering of SVG.
2. Move Batik dependencies in PDF package to the Graphic package.
Modified Paths:
--------------
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFAElementBridge.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFANode.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsConfiguration.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphicsDevice.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFTextPainter.java
Removed Paths:
-------------
trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFAElementBridge.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFANode.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphicsConfiguration.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphicsDevice.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFTextPainter.java
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-06-13 14:50:11 UTC (rev 9768)
+++ trunk/foray/foray-graphic/.classpath 2007-06-13 15:35:40 UTC (rev 9769)
@@ -22,5 +22,9 @@
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-xml.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslFont-R"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayPS"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-css.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/FOrayPDF"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/axslPDF-W"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-13 14:50:11 UTC (rev 9768)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-13 15:35:40 UTC (rev 9769)
@@ -29,10 +29,15 @@
package org.foray.graphic;
import org.foray.common.CharacterOutputStream;
+import org.foray.common.Environment;
import org.foray.common.SVGUserAgent;
import org.foray.common.WKConstants;
import org.foray.graphic.batik.BatikUaAwt;
+import org.foray.graphic.batik.PDFAElementBridge;
+import org.foray.graphic.batik.PDFGraphics2D;
+import org.foray.graphic.batik.PDFTextPainter;
import org.foray.graphic.batik.PSGraphics2D;
+import org.foray.pdf.object.PDFDocument;
import org.axsl.fontR.FontConsumer;
import org.axsl.graphicR.Graphic;
@@ -47,6 +52,8 @@
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.dom.svg.SVGOMDocument;
import org.apache.batik.gvt.GraphicsNode;
+import org.apache.batik.gvt.TextPainter;
+import org.apache.batik.gvt.renderer.StrokingTextPainter;
import org.apache.xmlgraphics.java2d.GraphicContext;
import org.w3c.dom.Element;
@@ -56,7 +63,6 @@
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
-import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -303,7 +309,7 @@
/**
* {@inheritDoc}
*/
- public void drawPS(final OutputStream output, final Point2D location,
+ public void drawPS(final OutputStream output, final Rectangle2D location,
final FontConsumer fontConsumer, final boolean strokeText,
final boolean commentsEnabled) {
final CharacterOutputStream cos = new CharacterOutputStream(output,
@@ -408,10 +414,87 @@
* {@inheritDoc}
*/
public void drawPdfStreamContent(final OutputStream output,
- final Point2D location, final GraphicPdfContext pdfContext,
+ final Rectangle2D location, final GraphicPdfContext pdfContext,
final FontConsumer fontConsumer, final boolean strokeText) {
- /* TODO: Implement this. */
- return;
+ SVGDocument doc = null;
+ try {
+ doc = this.getSVGDocument();
+ } catch (final GraphicException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return;
+ }
+ final PDFGraphics2D graphics = getPDFContent4SVG(location,
+ fontConsumer, doc, strokeText);
+ if (graphics == null) {
+ // Error messages have already been logged.
+ return;
+ }
+ final String svgString = graphics.getString();
+ final CharacterOutputStream stream = new CharacterOutputStream(output,
+ true);
+ try {
+ stream.write(svgString);
+ stream.close();
+ } catch (final IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
+ /**
+ * Convert an SVG document to a PDFGraphics2D.
+ * @param contentRectangle The location of the rectangle containing the
+ * SVG content.
+ * @param fontConsumer The font consumer.
+ * @param svgDocument The SVG document.
+ * @param strokeSVGText Indicates whether text should be stroked.
+ * @return The PDFGraphics2D instance for the SVG.
+ */
+ public PDFGraphics2D getPDFContent4SVG(
+ final Rectangle2D contentRectangle,
+ final FontConsumer fontConsumer,
+ final SVGDocument svgDocument, final boolean strokeSVGText) {
+ /* If not running in a graphical environment, log an error message
+ * and skip the SVG. */
+ if (! Environment.isGraphicalEnvironment()) {
+ getLogger().error("Unable to get Graphical Environment required "
+ + "to process SVG. Skipping.");
+ return null;
+ }
+ final SVGUserAgent userAgent = new SVGUserAgent(new AffineTransform());
+ userAgent.setLogger(getLogger());
+ BridgeContext ctx = new BridgeContext(userAgent);
+ GVTBuilder builder = new GVTBuilder();
+ TextPainter textPainter = null;
+ if (strokeSVGText) {
+ textPainter = new StrokingTextPainter();
+ } else {
+ textPainter = new PDFTextPainter(fontConsumer);
+ }
+ ctx.setTextPainter(textPainter);
+
+ final PDFAElementBridge aBridge = new PDFAElementBridge();
+ aBridge.setCurrentTransform(new AffineTransform(1, 0, 0, -1,
+ contentRectangle.getX(), contentRectangle.getY()));
+ ctx.putBridge(aBridge);
+
+ GraphicsNode root;
+ root = builder.build(ctx, svgDocument);
+ ctx = null;
+ builder = null;
+
+ /* TODO: What we really need here is a new GraphicsState, not a complete
+ * new document. */
+ final PDFDocument pdfDocument = new PDFDocument(null, null);
+ final PDFGraphics2D graphics = new PDFGraphics2D(true,
+ pdfDocument,
+ contentRectangle, svgDocument, fontConsumer, this.getLogger());
+ graphics.setGraphicContext(
+ new org.apache.batik.ext.awt.g2d.GraphicContext());
+
+ root.paint(graphics);
+ return graphics;
+ }
+
}
Copied: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFAElementBridge.java (from rev 9512, trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFAElementBridge.java)
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFAElementBridge.java (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFAElementBridge.java 2007-06-13 15:35:40 UTC (rev 9769)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+package org.foray.graphic.batik;
+
+import org.apache.batik.bridge.AbstractGraphicsNodeBridge;
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.gvt.GraphicsNode;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.svg.SVGAElement;
+
+import java.awt.geom.AffineTransform;
+
+/**
+ * Bridge class for the <a> element.
+ *
+ * @author <a href="mailto:ke...@af...">Keiron Liddle</a>
+ */
+public class PDFAElementBridge extends AbstractGraphicsNodeBridge {
+
+ /** The affine transform for this bridge. */
+ private AffineTransform transform;
+
+ /**
+ * Constructs a new bridge for the "a" element.
+ */
+ public PDFAElementBridge() { }
+
+ /**
+ * Sets the current affine transform.
+ * @param tf The new affine transform instance.
+ */
+ public void setCurrentTransform(final AffineTransform tf) {
+ transform = tf;
+ }
+
+ /**
+ * {@inheritDoc}
+ * Returns 'a'.
+ */
+ public String getLocalName() {
+ return SVG_A_TAG;
+ }
+
+ /**
+ * {@inheritDoc}
+ * Creates a <tt>CompositeGraphicsNode</tt>.
+ */
+ protected GraphicsNode instantiateGraphicsNode() {
+ return new PDFANode();
+ }
+
+ /**
+ * {@inheritDoc}
+ * Builds using the specified BridgeContext and element, the
+ * specified graphics node.
+ *
+ * @param ctx the bridge context to use
+ * @param e the element that describes the graphics node to build
+ */
+ @Override
+ public GraphicsNode createGraphicsNode(final BridgeContext ctx,
+ final Element e) {
+ final PDFANode aNode = (PDFANode) super.createGraphicsNode(ctx, e);
+ aNode.setDestination(((SVGAElement) e).getHref().getBaseVal());
+ aNode.setTransform(transform);
+ return aNode;
+ }
+
+ /**
+ * {@inheritDoc}
+ * Returns true as the <a> element is a container.
+ */
+ public boolean isComposite() {
+ return true;
+ }
+
+}
Copied: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFANode.java (from rev 9512, trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFANode.java)
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFANode.java (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFANode.java 2007-06-13 15:35:40 UTC (rev 9769)
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+package org.foray.graphic.batik;
+
+import org.foray.pdf.object.PDFPage;
+
+import org.apache.batik.gvt.CompositeGraphicsNode;
+
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.util.StringTokenizer;
+
+/**
+ * A graphics node that represents an image described as a graphics node.
+ *
+ * @author <a href="mailto:ke...@af...">Keiron Liddle</a>
+ */
+public class PDFANode extends CompositeGraphicsNode {
+
+ /** Constant indicating the X coordinate index in a viewbox. */
+ private static final int VIEWBOX_X_INDEX = 1;
+
+ /** Constant indicating the Y coordinate index in a viewbox. */
+ private static final int VIEWBOX_Y_INDEX = 2;
+
+ /** Constant indicating the width index in a viewbox. */
+ private static final int VIEWBOX_WIDTH_INDEX = 3;
+
+ /** Constant indicating the height index in a viewbox. */
+ private static final int VIEWBOX_HEIGHT_INDEX = 4;
+
+ /** An unknown constant. */
+ private static final int SCALING_CONSTANT = 200;
+
+ /** The destination to which this node points. */
+ private String destination;
+
+ /** The affine transform for this node. */
+ private AffineTransform transform;
+
+ /**
+ * Constructs a new empty <tt>PDFANode</tt>.
+ */
+ public PDFANode() { }
+
+ /**
+ * Set the destination String.
+ * @param dest The new destination for this node.
+ */
+ public void setDestination(final String dest) {
+ destination = dest;
+ }
+
+ /**
+ * Set the affine transform.
+ * @param tf The new affine transform.
+ */
+ public void setTransform(final AffineTransform tf) {
+ transform = tf;
+ }
+
+ /**
+ * Paints this node if it is visible.
+ * @param pdfPage The page on which this node should be painted.
+ * @param g2d The Graphics2D instance to use.
+ */
+ public void paint(final PDFPage pdfPage, final Graphics2D g2d) {
+ if (! isVisible) {
+ return;
+ }
+ super.paint(g2d);
+ if (! (g2d instanceof PDFGraphics2D)) {
+ return;
+ }
+ final PDFGraphics2D pdfg = (PDFGraphics2D) g2d;
+ boolean externalLink = true;
+ final Shape outline = getOutline();
+ if (destination.startsWith("#svgView(viewBox(")) {
+ externalLink = false;
+ final String nums = destination.substring(18,
+ destination.length() - 2);
+ float x = 0;
+ float y = 0;
+ float width = 0;
+ int count = 0;
+ try {
+ final StringTokenizer st = new StringTokenizer(nums, ",");
+ while (st.hasMoreTokens()) {
+ final String tok = st.nextToken();
+ count++;
+ switch(count) {
+ case VIEWBOX_X_INDEX:
+ x = Float.parseFloat(tok);
+ break;
+ case VIEWBOX_Y_INDEX:
+ y = Float.parseFloat(tok);
+ break;
+ case VIEWBOX_WIDTH_INDEX:
+ width = Float.parseFloat(tok);
+ break;
+ case VIEWBOX_HEIGHT_INDEX:
+ break;
+ default:
+ break;
+ }
+ }
+ } catch (final Exception e) {
+ }
+ // these numbers need conversion to current
+ // svg position and scaled for the page
+ destination = "" + x + " " + y + " " + SCALING_CONSTANT / width;
+ }
+ pdfg.addLink(pdfPage, outline, transform, destination, externalLink);
+ }
+
+}
Copied: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java (from rev 9761, trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java)
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2007-06-13 15:35:40 UTC (rev 9769)
@@ -0,0 +1,1028 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+package org.foray.graphic.batik;
+
+import org.foray.common.ColorSpaceCMYK;
+import org.foray.common.WKConstants;
+import org.foray.pdf.object.PDFAnnotList;
+import org.foray.pdf.object.PDFColor;
+import org.foray.pdf.object.PDFDocument;
+import org.foray.pdf.object.PDFFont;
+import org.foray.pdf.object.PDFLink;
+import org.foray.pdf.object.PDFPage;
+import org.foray.pdf.object.PDFPattern;
+import org.foray.pdf.object.PDFString;
+import org.foray.pdf.object.PDFXObject;
+import org.foray.ps.PSMatrix;
+import org.foray.ps.PSReal;
+
+import org.axsl.fontR.FontConsumer;
+import org.axsl.fontR.FontException;
+import org.axsl.fontR.FontUtility;
+
+import org.apache.batik.bridge.ViewBox;
+import org.apache.commons.logging.Log;
+
+import org.w3c.dom.svg.SVGDocument;
+import org.w3c.dom.svg.SVGSVGElement;
+
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.TexturePaint;
+import java.awt.color.ColorSpace;
+import java.awt.font.TextAttribute;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+import java.awt.image.ImageObserver;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+import java.io.StringWriter;
+import java.text.AttributedCharacterIterator;
+import java.text.CharacterIterator;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This concrete implementation of <tt>AbstractGraphics2D</tt> is a
+ * simple help to programmers to get started with their own
+ * implementation of <tt>Graphics2D</tt>.
+ * <tt>DefaultGraphics2D</tt> implements all the abstract methods
+ * is <tt>AbstractGraphics2D</tt> and makes it easy to start
+ * implementing a <tt>Graphic2D</tt> piece-meal.
+ *
+ * @author <a href="mailto:ke...@af...">Keiron Liddle</a>
+ * @version $Id$
+ * @see org.apache.batik.ext.awt.g2d.AbstractGraphics2D
+ */
+public class PDFGraphics2D
+ extends org.apache.batik.ext.awt.g2d.AbstractGraphics2D {
+
+ /** Constant indicating the number of elements in a cubic element, that is,
+ * 6. */
+ public static final byte QTY_ELEMENTS_CUBIC = 6;
+
+ /** Constant indicating the number of elements in a quad element, that is,
+ * 4. */
+ public static final byte QTY_ELEMENTS_QUAD = 4;
+
+ /** Constant indicating the number of elements in a linear element, that is,
+ * 2. */
+ public static final byte QTY_ELEMENTS_LINEAR = 2;
+
+ /** The PDF Document being created. */
+ private PDFDocument pdfDoc;
+
+ /** The current (internal) font. */
+ private org.axsl.fontR.FontUse currentFont;
+
+ /** The current font size in millipoints. */
+ private float currentFontSize;
+
+ /** The current stream to add PDF commands to. */
+ private StringWriter currentStream = new StringWriter();
+
+ /** The current colour for use in svg. */
+ private PDFColor currentColour = new PDFColor(new Color(0, 0, 0));
+
+ /** The current annotation list to add annotations to. */
+ private PDFAnnotList currentAnnotList = null;
+
+ /** The override font. */
+ private org.axsl.fontR.FontUse overrideFont = null;
+
+ /** The override font size, in points. */
+ private float overrideFontSize;
+
+ /** The encapsulated x object. */
+ private PDFXObject xObject;
+
+ /** The font consumer instance for this document. */
+ private FontConsumer fontConsumer;
+
+ /** Used to create proper font metrics. */
+ private Graphics2D fmg;
+
+ /** The logger. */
+ private Log logger;
+
+ /**
+ * Create a new PDFGraphics2D with the given pdf document info.
+ * This is used to create a Graphics object for use inside an already
+ * existing document.
+ * @param textAsShapes Set this to true so that text will be rendered
+ * using curves and not the font.
+ * @param doc The parent PDF Document.
+ * @param contentRectangle The rectangle into which the image content should
+ * be placed.
+ * @param svgDocument The SVG document to be drawn.
+ * @param fontConsumer The font consumer for this document.
+ * @param logger The logger.
+ */
+ public PDFGraphics2D(final boolean textAsShapes, final PDFDocument doc,
+ final Rectangle2D contentRectangle,
+ final SVGDocument svgDocument, final FontConsumer fontConsumer,
+ final Log logger) {
+ super(textAsShapes);
+ pdfDoc = doc;
+ this.logger = logger;
+ this.fontConsumer = fontConsumer;
+ final PDFFont pdfFont = doc.getCurrentGraphicsState().getFont();
+ if (pdfFont == null) {
+ this.currentFont = null;
+ } else {
+ this.currentFont = pdfFont.getFontUse();
+ }
+ currentFontSize = doc.getCurrentGraphicsState().getFontSize();
+ initGraphicalEnvironment();
+ transformCoordinates(contentRectangle, svgDocument);
+ }
+
+ /**
+ * Create a new PDFGraphics2D instance.
+ * @param textAsShapes Set this to true so that text will be rendered
+ * using curves and not the font.
+ */
+ public PDFGraphics2D(final boolean textAsShapes) {
+ super(textAsShapes);
+ }
+
+ /**
+ * This constructor supports the create method.
+ * @param g The encapsulated image.
+ */
+ public PDFGraphics2D(final PDFGraphics2D g) {
+ super(g);
+ }
+
+ /**
+ * Writes the transformation coordinates for a given SVG and rectangle to
+ * the output stream.
+ * @param contentRectangle The rectangle into which the image content should
+ * be placed.
+ * @param svgDocument The SVG Document to be written.
+ */
+ private void transformCoordinates(final Rectangle2D contentRectangle,
+ final SVGDocument svgDocument) {
+ // transform so that the coordinates (0,0) is from the top left
+ // and positive is down and to the right. (0,0) is where the
+ // viewBox puts it.
+ currentStream.write("1 0 0 -1 " + contentRectangle.getX() + " "
+ + contentRectangle.getY() + " cm\n");
+
+ final SVGSVGElement svg = svgDocument.getRootElement();
+ final AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
+ (float) contentRectangle.getWidth(),
+ (float) contentRectangle.getHeight());
+ if (!at.isIdentity()) {
+ /* TODO: This logic needs to be integrated with the regular PDF
+ * classes. */
+ final double[] vals = new double[PSMatrix.QTY_ELEMENTS];
+ at.getMatrix(vals);
+ final String matrixString = octalMatrixToString(vals);
+ currentStream.write(matrixString);
+ currentStream.write("cm\n");
+ }
+ }
+
+ /**
+ * Converts a matrix of octal values to its PDF representation.
+ * @param theMatrix The matrix to be converted.
+ * @return The PDF representation of the matrix.
+ */
+ public static String octalMatrixToString(final double[] theMatrix) {
+ final StringBuilder buffer = new StringBuilder();
+ for (int i = 0; i < theMatrix.length; i++) {
+ buffer.append(PSReal.doubleOut(theMatrix[i],
+ WKConstants.RADIX_BASE_8));
+ buffer.append(" ");
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Converts a matrix of decimal values to its PDF representation.
+ * @param theMatrix The matrix to be converted.
+ * @param numElements The number of elements in the matrix to be included
+ * in the output.
+ * @return The PDF representation of the matrix.
+ */
+ public static String matrixToString(final double[] theMatrix,
+ final int numElements) {
+ final StringBuilder buffer = new StringBuilder();
+ for (int i = 0; i < numElements; i++) {
+ buffer.append(PSReal.doubleOut(theMatrix[i]) + " ");
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Returns this object as the value which should be written to the PDF file.
+ * @return The PDF representation of this object.
+ */
+ public String getString() {
+ return currentStream.toString();
+ }
+
+ /**
+ * Sets the graphic context.
+ * @param c The new graphic context.
+ */
+ public void setGraphicContext(
+ final org.apache.batik.ext.awt.g2d.GraphicContext c) {
+ gc = c;
+ }
+
+ /**
+ * Sets the override font and size.
+ * @param infont The new override font.
+ * @param size The new override font size.
+ */
+ public void setOverrideFontState(final org.axsl.fontR.FontUse infont,
+ final float size) {
+ this.overrideFont = infont;
+ this.overrideFontSize = size;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Graphics create() {
+ return new PDFGraphics2D(this);
+ }
+
+ /**
+ * This is a pdf specific method used to add a link to the pdf document.
+ * @param pdfPage The page on which the link should be placed.
+ * @param bounds The location of the link.
+ * @param trans The affine transform.
+ * @param dest The name of the destination.
+ * @param externalLink Set to true if the link is to an external document.
+ */
+ public void addLink(final PDFPage pdfPage, final Shape bounds,
+ final AffineTransform trans, final String dest,
+ final boolean externalLink) {
+ if (currentAnnotList == null) {
+ currentAnnotList = new PDFAnnotList(pdfDoc);
+ }
+ final AffineTransform at = getTransform();
+ Shape b = at.createTransformedShape(bounds);
+ b = trans.createTransformedShape(b);
+ final Rectangle2D.Float linkRectangle =
+ (Rectangle2D.Float) b.getBounds2D();
+ linkRectangle.height *= -1;
+ PDFLink link = null;
+ if (externalLink) {
+ final String pdfdest = "/XYZ " + dest;
+ link = new PDFLink(pdfDoc, pdfPage, linkRectangle, pdfdest);
+ } else {
+ link = pdfPage.makeLink(linkRectangle, dest, false);
+ }
+ currentAnnotList.addAnnotation(link);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean drawImage(final Image img, final int x, final int y,
+ final ImageObserver observer) {
+ final int width = img.getWidth(observer);
+ final int height = img.getHeight(observer);
+
+ if (width == -1 || height == -1) {
+ return false;
+ }
+
+ final int numChannels = this.currentColour.getColor().getColorSpace()
+ .getNumComponents();
+ final Dimension size = new Dimension(width * numChannels,
+ height * numChannels);
+ final BufferedImage buf = new BufferedImage(size.width, size.height,
+ BufferedImage.TYPE_INT_ARGB);
+
+ final 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, width * numChannels, height * numChannels);
+ 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()
+ * numChannels];
+
+ final Raster raster = buf.getData();
+ final DataBuffer bd = raster....
[truncated message content] |
|
From: <vic...@us...> - 2007-06-13 16:27:32
|
Revision: 9770
http://svn.sourceforge.net/foray/?rev=9770&view=rev
Author: victormote
Date: 2007-06-13 09:27:32 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
1. Move remaining Batik dependency in Common to Graphic.
2. Officially remove Batik dependencies from Common and PDF packages.
3. Note that the build is broken ATM, because of circular dependencies between the Graphic and PDF packages.
Modified Paths:
--------------
trunk/foray/foray-common/.classpath
trunk/foray/foray-common/scripts/build.xml
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-graphic/scripts/build.xml
trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaAwt.java
trunk/foray/foray-pdf/.classpath
trunk/foray/foray-pdf/scripts/build.xml
Added Paths:
-----------
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaDocument.java
Removed Paths:
-------------
trunk/foray/foray-common/src/java/org/foray/common/SVGUserAgent.java
Modified: trunk/foray/foray-common/.classpath
===================================================================
--- trunk/foray/foray-common/.classpath 2007-06-13 15:35:40 UTC (rev 9769)
+++ trunk/foray/foray-common/.classpath 2007-06-13 16:27:32 UTC (rev 9770)
@@ -5,6 +5,5 @@
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.2.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.2-src.zip"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-common/scripts/build.xml
===================================================================
--- trunk/foray/foray-common/scripts/build.xml 2007-06-13 15:35:40 UTC (rev 9769)
+++ trunk/foray/foray-common/scripts/build.xml 2007-06-13 16:27:32 UTC (rev 9770)
@@ -23,7 +23,6 @@
</fileset>
<fileset dir="${lib.dir}">
<include name="axsl*.jar"/>
- <include name="batik*.jar"/>
<include name="commons-logging-*.jar"/>
<include name="commons-io-*.jar"/>
</fileset>
Deleted: trunk/foray/foray-common/src/java/org/foray/common/SVGUserAgent.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/SVGUserAgent.java 2007-06-13 15:35:40 UTC (rev 9769)
+++ trunk/foray/foray-common/src/java/org/foray/common/SVGUserAgent.java 2007-06-13 16:27:32 UTC (rev 9770)
@@ -1,157 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.common;
-
-import org.apache.batik.bridge.UserAgentAdapter;
-import org.apache.commons.logging.Log;
-
-import java.awt.Dimension;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Dimension2D;
-
-/**
- * A User Agent for Batik.
- */
-public class SVGUserAgent extends UserAgentAdapter {
-
- /** The default viewport width, in pixels. */
- protected static final int DEFAULT_VIEWPORT_WIDTH = 100;
-
- /** The default viewport height, in pixels. */
- protected static final int DEFAULT_VIEWPORT_HEIGHT = 100;
-
- /** The current AffineTransform. */
- private AffineTransform currentTransform = null;
-
- /** The logger. */
- private Log log;
-
- /**
- * Creates a new SVGUserAgent.
- * @param at The AffineTransform for this.
- */
- public SVGUserAgent(final AffineTransform at) {
- currentTransform = at;
- }
-
- /**
- * Sets the logger.
- * @param logger The new logger.
- */
- public void setLogger(final Log logger) {
- log = logger;
- }
-
- /**
- * {@inheritDoc}
- */
- public void displayError(final String message) {
- log.error(message);
- }
-
- /**
- * {@inheritDoc}
- */
- public void displayError(final Exception ex) {
- log.error("SVG Error" + ex.getMessage());
- log.error(ex.getMessage());
- }
-
- /**
- * {@inheritDoc}
- */
- public void displayMessage(final String message) {
- log.info(message);
- }
-
- /**
- * {@inheritDoc}
- */
- public float getPixelToMM() {
- return getPixelUnitToMillimeter();
- }
-
- /**
- * {@inheritDoc}
- */
- public float getPixelUnitToMillimeter() {
- // Length of one pixel in inches.
- float temp = 1f / FOrayConstants.DEFAULT_SCREEN_RESOLUTION;
- /* Apply factor converting inches to centimeters */
- temp *= WKConstants.CM_PER_INCH;
- /* Apply factor converting centimeters to millimeters. */
- temp *= WKConstants.MM_PER_CM;
- return temp;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getLanguages() {
- /* userLanguages */
- return "en";
- }
-
- /**
- * {@inheritDoc}
- */
- public String getMedia() {
- return "print";
- }
-
- /**
- * {@inheritDoc}
- */
- public String getUserStyleSheetURI() {
- return null; // userStyleSheetURI;
- }
-
- /**
- * {@inheritDoc}
- */
- public AffineTransform getTransform() {
- return currentTransform;
- }
-
- /**
- * {@inheritDoc}
- */
- public Dimension2D getViewportSize() {
- return new Dimension(DEFAULT_VIEWPORT_WIDTH, DEFAULT_VIEWPORT_HEIGHT);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isXMLParserValidating() {
- return true;
- }
-
-}
-
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2007-06-13 15:35:40 UTC (rev 9769)
+++ trunk/foray/foray-graphic/.classpath 2007-06-13 16:27:32 UTC (rev 9770)
@@ -26,5 +26,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/FOrayPDF"/>
<classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry combineaccessrules="false" kind="src" path="/axslPDF-W"/>
+ <classpathentry kind="lib" path="/FOray Lib/batik-1.6-ext.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/scripts/build.xml
===================================================================
--- trunk/foray/foray-graphic/scripts/build.xml 2007-06-13 15:35:40 UTC (rev 9769)
+++ trunk/foray/foray-graphic/scripts/build.xml 2007-06-13 16:27:32 UTC (rev 9770)
@@ -34,6 +34,11 @@
<fileset dir="${foray.sandbox}/foray-ps/build/ant">
<include name="*.jar"/>
</fileset>
+ <!-- Include the uncompiled PDF code, because it has possibly not yet
+ been compiled. -->
+ <fileset dir="${foray.sandbox}/foray-pdf/src/java">
+ <include name="**/**.java"/>
+ </fileset>
</path>
</target>
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-13 15:35:40 UTC (rev 9769)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2007-06-13 16:27:32 UTC (rev 9770)
@@ -30,7 +30,7 @@
import org.foray.common.CharacterOutputStream;
import org.foray.common.Environment;
-import org.foray.common.SVGUserAgent;
+import org.foray.graphic.batik.BatikUaDocument;
import org.foray.common.WKConstants;
import org.foray.graphic.batik.BatikUaAwt;
import org.foray.graphic.batik.PDFAElementBridge;
@@ -405,7 +405,8 @@
* @return A Batik BridgeContext instance.
*/
public BridgeContext makeBridgeContext() {
- final SVGUserAgent userAgent = new SVGUserAgent(new AffineTransform());
+ final BatikUaDocument userAgent = new BatikUaDocument(
+ new AffineTransform());
userAgent.setLogger(getLogger());
return new BridgeContext(userAgent);
}
@@ -462,7 +463,8 @@
+ "to process SVG. Skipping.");
return null;
}
- final SVGUserAgent userAgent = new SVGUserAgent(new AffineTransform());
+ final BatikUaDocument userAgent = new BatikUaDocument(
+ new AffineTransform());
userAgent.setLogger(getLogger());
BridgeContext ctx = new BridgeContext(userAgent);
GVTBuilder builder = new GVTBuilder();
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaAwt.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaAwt.java 2007-06-13 15:35:40 UTC (rev 9769)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaAwt.java 2007-06-13 16:27:32 UTC (rev 9770)
@@ -29,7 +29,6 @@
package org.foray.graphic.batik;
-import org.foray.common.SVGUserAgent;
import org.apache.batik.gvt.event.EventDispatcher;
@@ -44,9 +43,9 @@
/**
* A Batik UserAgent implementation that is used when drawing an SVG using an
* AWT device (screen or printer). For drawing into a PDF, PostScript, or
- * similar file, see {@link SVGUserAgent}.
+ * similar file, see {@link BatikUaDocument}.
*/
-public class BatikUaAwt extends SVGUserAgent {
+public class BatikUaAwt extends BatikUaDocument {
/**
* Creates a new SVGUserAgent.
Added: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaDocument.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaDocument.java (rev 0)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaDocument.java 2007-06-13 16:27:32 UTC (rev 9770)
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy: victormote $
+ */
+
+package org.foray.graphic.batik;
+
+import org.foray.common.FOrayConstants;
+import org.foray.common.WKConstants;
+
+import org.apache.batik.bridge.UserAgentAdapter;
+import org.apache.commons.logging.Log;
+
+import java.awt.Dimension;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+
+/**
+ * A Batik UserAgent implementation that is used when drawing an SVG into a
+ * document format such as PDF or PostScript.
+ * For drawing on an AWT device, see {@link BatikUaAwt}.
+ */
+public class BatikUaDocument extends UserAgentAdapter {
+
+ /** The default viewport width, in pixels. */
+ protected static final int DEFAULT_VIEWPORT_WIDTH = 100;
+
+ /** The default viewport height, in pixels. */
+ protected static final int DEFAULT_VIEWPORT_HEIGHT = 100;
+
+ /** The current AffineTransform. */
+ private AffineTransform currentTransform = null;
+
+ /** The logger. */
+ private Log log;
+
+ /**
+ * Creates a new SVGUserAgent.
+ * @param at The AffineTransform for this.
+ */
+ public BatikUaDocument(final AffineTransform at) {
+ currentTransform = at;
+ }
+
+ /**
+ * Sets the logger.
+ * @param logger The new logger.
+ */
+ public void setLogger(final Log logger) {
+ log = logger;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void displayError(final String message) {
+ log.error(message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void displayError(final Exception ex) {
+ log.error("SVG Error" + ex.getMessage());
+ log.error(ex.getMessage());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void displayMessage(final String message) {
+ log.info(message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public float getPixelToMM() {
+ return getPixelUnitToMillimeter();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public float getPixelUnitToMillimeter() {
+ // Length of one pixel in inches.
+ float temp = 1f / FOrayConstants.DEFAULT_SCREEN_RESOLUTION;
+ /* Apply factor converting inches to centimeters */
+ temp *= WKConstants.CM_PER_INCH;
+ /* Apply factor converting centimeters to millimeters. */
+ temp *= WKConstants.MM_PER_CM;
+ return temp;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getLanguages() {
+ /* userLanguages */
+ return "en";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getMedia() {
+ return "print";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getUserStyleSheetURI() {
+ return null; // userStyleSheetURI;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public AffineTransform getTransform() {
+ return currentTransform;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Dimension2D getViewportSize() {
+ return new Dimension(DEFAULT_VIEWPORT_WIDTH, DEFAULT_VIEWPORT_HEIGHT);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isXMLParserValidating() {
+ return true;
+ }
+
+}
+
Property changes on: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/BatikUaDocument.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Modified: trunk/foray/foray-pdf/.classpath
===================================================================
--- trunk/foray/foray-pdf/.classpath 2007-06-13 15:35:40 UTC (rev 9769)
+++ trunk/foray/foray-pdf/.classpath 2007-06-13 16:27:32 UTC (rev 9770)
@@ -10,16 +10,5 @@
<classpathentry kind="src" path="/FOrayPS"/>
<classpathentry kind="src" path="/axslPDF-W"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/svg-1.1.jar" sourcepath="/FOray Lib-Build/svg/svg-1.1-src.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-awt-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-bridge.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-util.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-svg-dom.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-gvt.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-dom.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-css.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-script.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-transcoder.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
- <classpathentry kind="lib" path="/FOray Lib/batik-1.6-ext.jar" sourcepath="/FOray Lib-Build/batik/batik-1.6-sources.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-pdf/scripts/build.xml
===================================================================
--- trunk/foray/foray-pdf/scripts/build.xml 2007-06-13 15:35:40 UTC (rev 9769)
+++ trunk/foray/foray-pdf/scripts/build.xml 2007-06-13 16:27:32 UTC (rev 9770)
@@ -26,7 +26,6 @@
</fileset>
<fileset dir="${lib.dir}">
<include name="axsl*.jar"/>
- <include name="batik*.jar"/>
<include name="commons-logging-*.jar"/>
</fileset>
<fileset dir="${foray.sandbox}/foray-common/build/ant">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2007-06-13 17:39:27
|
Revision: 9773
http://svn.sourceforge.net/foray/?rev=9773&view=rev
Author: victormote
Date: 2007-06-13 10:39:26 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
Use the bare FontUse instance in places where it does not need to be wrapped in a PDFFont.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.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-13 17:29:34 UTC (rev 9772)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2007-06-13 17:39:26 UTC (rev 9773)
@@ -32,7 +32,6 @@
import org.foray.pdf.object.PDFAnnotList;
import org.foray.pdf.object.PDFColor;
import org.foray.pdf.object.PDFDocument;
-import org.foray.pdf.object.PDFFont;
import org.foray.pdf.object.PDFLink;
import org.foray.pdf.object.PDFPage;
import org.foray.pdf.object.PDFPattern;
@@ -178,12 +177,6 @@
this.logger = logger;
this.fontConsumer = fontConsumer;
this.pdfContext = pdfContext;
- final PDFFont pdfFont = this.pdfDoc.getCurrentGraphicsState().getFont();
- if (pdfFont == null) {
- this.currentFont = null;
- } else {
- this.currentFont = pdfFont.getFontUse();
- }
currentFontSize = this.pdfDoc.getCurrentGraphicsState().getFontSize();
initGraphicalEnvironment();
transformCoordinates(contentRectangle, svgDocument);
@@ -784,8 +777,7 @@
currentStream.write("cm\n");
currentStream.write("1 0 0 -1 0 0 Tm ");
- final PDFFont pdfFont = new PDFFont(this.pdfDoc, font);
- final PDFString pdfString = new PDFString(this.pdfDoc, s, pdfFont,
+ final PDFString pdfString = new PDFString(this.pdfDoc, s, font,
true);
final String outputString = pdfString.toPDF();
currentStream.write(outputString);
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java 2007-06-13 17:29:34 UTC (rev 9772)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java 2007-06-13 17:39:26 UTC (rev 9773)
@@ -29,8 +29,8 @@
package org.foray.pdf;
import org.foray.pdf.object.PDFColor;
-import org.foray.pdf.object.PDFFont;
+import org.axsl.fontR.FontUse;
import org.axsl.pdfW.PDFLineCapStyle;
import java.awt.Color;
@@ -57,7 +57,7 @@
private float wordSpacing;
/** The font. */
- private PDFFont font;
+ private FontUse font;
/** The font size. */
private float fontSize;
@@ -160,7 +160,7 @@
* @param newFont The new font.
* @return True iff the font was changed.
*/
- public boolean setFont(final PDFFont newFont) {
+ public boolean setFont(final FontUse newFont) {
boolean anyChange = false;
if (! newFont.equals(this.font)) {
this.font = newFont;
@@ -173,7 +173,7 @@
* Returns the font.
* @return The font.
*/
- public PDFFont getFont() {
+ public FontUse getFont() {
return this.font;
}
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-13 17:29:34 UTC (rev 9772)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2007-06-13 17:39:26 UTC (rev 9773)
@@ -131,7 +131,7 @@
final PDFFont pdfFont = this.getPDFDocument().getPDFFont(newFont);
openTextObject();
boolean anyChange = false;
- anyChange |= this.getGS().setFont(pdfFont);
+ anyChange |= this.getGS().setFont(newFont);
anyChange |= this.getGS().setFontSize(newFontSize);
if (! anyChange) {
// Nothing needs to change.
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2007-06-13 17:29:34 UTC (rev 9772)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2007-06-13 17:39:26 UTC (rev 9773)
@@ -32,7 +32,6 @@
import org.axsl.fontR.Font;
import org.axsl.fontR.FontUse;
-import org.axsl.pdfW.PDFFont;
/**
* A PDF String Object, as defined in PDF Reference, 2nd edition, Section 3.2.3.
@@ -51,7 +50,7 @@
private String theString;
/** The Font that should be used to render this String. */
- private PDFFont font;
+ private FontUse font;
/** Indicates whether the text in this string should be kerned or not. */
private boolean kerningActive;
@@ -65,7 +64,7 @@
* kerned or not.
*/
public PDFString(final PDFDocument doc, final String string,
- final PDFFont font, final boolean kerningActive) {
+ final FontUse font, final boolean kerningActive) {
super(doc);
this.theString = string;
this.font = font;
@@ -79,7 +78,6 @@
final StringBuilder buffer = new StringBuilder();
buffer.append("[");
buffer.append(startTextDelimiter());
- final FontUse font = this.font.getFontUse();
for (int i = 0; i < theString.length(); i++) {
final int codePoint = Character.codePointAt(theString, i);
if (Character.isSupplementaryCodePoint(codePoint)) {
@@ -90,10 +88,10 @@
* from the output. */
continue;
}
- final int ch = font.encodeCharacter(codePoint);
+ final int ch = this.font.encodeCharacter(codePoint);
addCharToBuffer(buffer, ch);
if (i + 1 < theString.length()) {
- addKerning(font.getFont(), theString.charAt(i),
+ addKerning(this.font.getFont(), theString.charAt(i),
theString.charAt(i + 1),
buffer);
}
@@ -110,7 +108,7 @@
*/
private void addCharToBuffer(final StringBuilder buffer,
final int glyphIndex) {
- final Font font = this.font.getFontUse().getFont();
+ final Font font = this.font.getFont();
if (font.getFontComplexity() == Font.Complexity.COMPOSITE) {
buffer.append(PDFString.getUnicodeString(glyphIndex));
return;
@@ -168,7 +166,7 @@
* @return The char that denotes the start of text.
*/
private char startTextDelimiter() {
- final Font font = this.font.getFontUse().getFont();
+ final Font font = this.font.getFont();
if (font.getFontComplexity() == Font.Complexity.COMPOSITE) {
return '<';
}
@@ -180,7 +178,7 @@
* @return The char that denotes the end of text.
*/
private char endTextDelimiter() {
- final Font font = this.font.getFontUse().getFont();
+ final Font font = this.font.getFont();
if (font.getFontComplexity() == Font.Complexity.COMPOSITE) {
return '>';
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|